Inline runtime menu tab bindings into MenuPanel
This commit is contained in:
parent
4c4ab8561a
commit
79d8e8b6b9
6 changed files with 77 additions and 150 deletions
|
|
@ -507,7 +507,7 @@ Console.WriteLine("Renderer-local debug panels: obsolete uGUI field tester autho
|
|||
Console.WriteLine("Main-menu settings authority: player name, gameplay, and graphics settings return through typed player-settings commits");
|
||||
Console.WriteLine("Main-menu settings shell: settings/input/audio subpages lower through Eve UI Toolkit surfaces instead of PropertiesPanel buttons");
|
||||
Console.WriteLine("Sector-map zone details shell: zone inspection lowers through an Eve UI Toolkit surface instead of PropertiesPanel rows");
|
||||
Console.WriteLine("Runtime menu tab shell: tab navigation lowers through an Eve UI Toolkit surface instead of MenuTabButton click wiring");
|
||||
Console.WriteLine("Runtime menu tab shell: MenuPanel owns tab metadata and lowers navigation through an Eve UI Toolkit surface");
|
||||
Console.WriteLine("Inventory ship-settings shell: background ship tuning lowers through an Eve UI Toolkit surface instead of PropertiesPanel.AddField");
|
||||
Console.WriteLine("Inventory cargo-item shell: cargo item inspection lowers through an Eve UI Toolkit surface instead of PropertiesPanel.Inspect");
|
||||
Console.WriteLine("Trade cargo-selector shell: target cargo selection lowers through an Eve UI Toolkit surface instead of ContextMenu.AddOption");
|
||||
|
|
@ -2556,15 +2556,24 @@ static void RequireRuntimeMenuTabsUseEveSurface(string root)
|
|||
throw new InvalidOperationException("Cannot verify runtime menu tab shell; MenuPanel.cs is missing.");
|
||||
}
|
||||
|
||||
var legacyTabButtonPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "MenuTabButton.cs");
|
||||
if (File.Exists(legacyTabButtonPath))
|
||||
{
|
||||
throw new InvalidOperationException("MenuPanel tab metadata still has a surviving MenuTabButton component shell.");
|
||||
}
|
||||
|
||||
var source = File.ReadAllText(menuPanelPath);
|
||||
var requiredSymbols = new[]
|
||||
{
|
||||
"MenuTabsSurfaceId",
|
||||
"MenuTabBinding",
|
||||
"TabBindings = Array.Empty<MenuTabBinding>();",
|
||||
"RenderTabSurface(",
|
||||
"HandleTabSurfaceCommand(",
|
||||
"ResolveTabSurfaceDocument(",
|
||||
"BuildTabSurfaceDefinition(",
|
||||
"ResolveVisibleTabs(",
|
||||
"GetTabLabel(",
|
||||
"GetTabCommand(",
|
||||
"new EveUiToolkitSurfaceLowerer()",
|
||||
"TabButtons.gameObject.SetActive(false)"
|
||||
|
|
@ -2583,6 +2592,7 @@ static void RequireRuntimeMenuTabsUseEveSurface(string root)
|
|||
|
||||
var forbiddenSymbols = new[]
|
||||
{
|
||||
"MenuTabButton",
|
||||
"tabButton.Button.onClick.AddListener(",
|
||||
"tabButton.gameObject.SetActive(!tabButton.RequireDock || GameManager.DockedEntity != null);",
|
||||
"_tabs[MenuTab.Local].gameObject.SetActive("
|
||||
|
|
|
|||
|
|
@ -1008,7 +1008,6 @@ GameObject:
|
|||
- component: {fileID: 101395093}
|
||||
- component: {fileID: 101395092}
|
||||
- component: {fileID: 101395091}
|
||||
- component: {fileID: 101395094}
|
||||
m_Layer: 5
|
||||
m_Name: Inventory
|
||||
m_TagString: Untagged
|
||||
|
|
@ -1178,23 +1177,6 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 101395089}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &101395094
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 101395089}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d90317f6ecd38754fad9aee92f46b126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TabContents: {fileID: 1997243492}
|
||||
Button: {fileID: 101395091}
|
||||
Tab: 1
|
||||
Text: {fileID: 101395092}
|
||||
RequireDock: 0
|
||||
--- !u!1 &109242180
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -14570,7 +14552,6 @@ GameObject:
|
|||
- component: {fileID: 931657854}
|
||||
- component: {fileID: 931657853}
|
||||
- component: {fileID: 931657852}
|
||||
- component: {fileID: 931657855}
|
||||
m_Layer: 5
|
||||
m_Name: Map
|
||||
m_TagString: Untagged
|
||||
|
|
@ -14740,23 +14721,6 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 931657850}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &931657855
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 931657850}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d90317f6ecd38754fad9aee92f46b126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TabContents: {fileID: 630131158}
|
||||
Button: {fileID: 931657852}
|
||||
Tab: 0
|
||||
Text: {fileID: 931657853}
|
||||
RequireDock: 0
|
||||
--- !u!1 &932155239
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -21908,7 +21872,6 @@ GameObject:
|
|||
- component: {fileID: 1399108422}
|
||||
- component: {fileID: 1399108421}
|
||||
- component: {fileID: 1399108420}
|
||||
- component: {fileID: 1399108419}
|
||||
m_Layer: 5
|
||||
m_Name: Galaxy
|
||||
m_TagString: Untagged
|
||||
|
|
@ -21935,23 +21898,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 1297.74, y: -40}
|
||||
m_SizeDelta: {x: 234.27, y: 56}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1399108419
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1399108417}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d90317f6ecd38754fad9aee92f46b126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TabContents: {fileID: 2056162321}
|
||||
Button: {fileID: 1399108420}
|
||||
Tab: 3
|
||||
Text: {fileID: 1399108421}
|
||||
RequireDock: 0
|
||||
--- !u!114 &1399108420
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -22865,7 +22811,6 @@ GameObject:
|
|||
- component: {fileID: 1464157089}
|
||||
- component: {fileID: 1464157088}
|
||||
- component: {fileID: 1464157087}
|
||||
- component: {fileID: 1464157086}
|
||||
m_Layer: 5
|
||||
m_Name: Trade
|
||||
m_TagString: Untagged
|
||||
|
|
@ -22892,23 +22837,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 928.34, y: -40}
|
||||
m_SizeDelta: {x: 202.55, y: 56}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1464157086
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1464157084}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d90317f6ecd38754fad9aee92f46b126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TabContents: {fileID: 522642867}
|
||||
Button: {fileID: 1464157087}
|
||||
Tab: 2
|
||||
Text: {fileID: 1464157088}
|
||||
RequireDock: 1
|
||||
--- !u!114 &1464157087
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -23282,7 +23210,6 @@ GameObject:
|
|||
- component: {fileID: 1485884356}
|
||||
- component: {fileID: 1485884355}
|
||||
- component: {fileID: 1485884354}
|
||||
- component: {fileID: 1485884353}
|
||||
m_Layer: 5
|
||||
m_Name: Local
|
||||
m_TagString: Untagged
|
||||
|
|
@ -23309,23 +23236,6 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 342.84, y: -40}
|
||||
m_SizeDelta: {x: 275.43, y: 56}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1485884353
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1485884351}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d90317f6ecd38754fad9aee92f46b126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
TabContents: {fileID: 14255051}
|
||||
Button: {fileID: 1485884354}
|
||||
Tab: 4
|
||||
Text: {fileID: 1485884355}
|
||||
RequireDock: 0
|
||||
--- !u!114 &1485884354
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -27453,8 +27363,27 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
GameManager: {fileID: 1009503729}
|
||||
TabButtons: {fileID: 1783772015}
|
||||
ActiveTabColor: {r: 1, g: 0.44583336, b: 0.050000012, a: 1}
|
||||
InactiveTabColor: {r: 0.6981132, g: 0.6981132, b: 0.6981132, a: 1}
|
||||
TabBindings:
|
||||
- Tab: 0
|
||||
TabContents: {fileID: 630131158}
|
||||
Label: Map
|
||||
RequireDock: 0
|
||||
- Tab: 1
|
||||
TabContents: {fileID: 1997243492}
|
||||
Label: Inventory
|
||||
RequireDock: 0
|
||||
- Tab: 2
|
||||
TabContents: {fileID: 522642867}
|
||||
Label: Trade
|
||||
RequireDock: 1
|
||||
- Tab: 3
|
||||
TabContents: {fileID: 2056162321}
|
||||
Label: Galaxy
|
||||
RequireDock: 0
|
||||
- Tab: 4
|
||||
TabContents: {fileID: 14255051}
|
||||
Label: Explore
|
||||
RequireDock: 0
|
||||
--- !u!1 &1733988258
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Eve.Surface;
|
||||
|
|
@ -13,6 +12,15 @@ using UnityEngine.UIElements;
|
|||
|
||||
public class MenuPanel : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
private sealed class MenuTabBinding
|
||||
{
|
||||
public MenuTab Tab;
|
||||
public GameObject TabContents;
|
||||
public string Label;
|
||||
public bool RequireDock;
|
||||
}
|
||||
|
||||
private const string MenuTabsSurfaceType = "surface-state";
|
||||
private const string MenuTabsSurfaceSchema = "gamecult.eve.surface.v1";
|
||||
private const string MenuTabsSurfaceProviderId = "aetheria";
|
||||
|
|
@ -21,13 +29,12 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
public ActionGameManager GameManager;
|
||||
public RectTransform TabButtons;
|
||||
public Color ActiveTabColor;
|
||||
public Color InactiveTabColor;
|
||||
[SerializeField] private MenuTabBinding[] TabBindings = Array.Empty<MenuTabBinding>();
|
||||
|
||||
public event Action<MenuTab> TabChanged;
|
||||
|
||||
private Dictionary<MenuTab, MenuTabButton> _tabs = new Dictionary<MenuTab, MenuTabButton>();
|
||||
private MenuTabButton _current;
|
||||
private readonly Dictionary<MenuTab, MenuTabBinding> _tabs = new Dictionary<MenuTab, MenuTabBinding>();
|
||||
private MenuTabBinding _current;
|
||||
private UIDocument _tabSurfaceDocument;
|
||||
|
||||
public MenuTab CurrentTab { get; private set; }
|
||||
|
|
@ -69,10 +76,13 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var tabButton in TabButtons.GetComponentsInChildren<MenuTabButton>())
|
||||
foreach (var tabBinding in TabBindings)
|
||||
{
|
||||
tabButton.TabContents.SetActive(false);
|
||||
_tabs.Add(tabButton.Tab, tabButton);
|
||||
if (tabBinding?.TabContents == null)
|
||||
continue;
|
||||
|
||||
tabBinding.TabContents.SetActive(false);
|
||||
_tabs[tabBinding.Tab] = tabBinding;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,23 +192,23 @@ public class MenuPanel : MonoBehaviour
|
|||
{
|
||||
var visibleTabs = ResolveVisibleTabs();
|
||||
var commands = visibleTabs
|
||||
.Select(tabButton => new EveCommandTemplate(
|
||||
GetTabCommand(tabButton.Tab),
|
||||
tabButton.Text?.text ?? tabButton.Tab.ToString(),
|
||||
.Select(tabBinding => new EveCommandTemplate(
|
||||
GetTabCommand(tabBinding.Tab),
|
||||
GetTabLabel(tabBinding),
|
||||
"unity-uitoolkit"))
|
||||
.ToArray();
|
||||
|
||||
var buttons = visibleTabs
|
||||
.Select(tabButton =>
|
||||
.Select(tabBinding =>
|
||||
{
|
||||
var label = tabButton.Text?.text ?? tabButton.Tab.ToString();
|
||||
if (tabButton.Tab == CurrentTab)
|
||||
var label = GetTabLabel(tabBinding);
|
||||
if (tabBinding.Tab == CurrentTab)
|
||||
label = $"{label} *";
|
||||
|
||||
return Button(
|
||||
$"{MenuTabsSurfaceId}.{tabButton.Tab.ToString().ToLowerInvariant()}",
|
||||
$"{MenuTabsSurfaceId}.{tabBinding.Tab.ToString().ToLowerInvariant()}",
|
||||
label,
|
||||
GetTabCommand(tabButton.Tab));
|
||||
GetTabCommand(tabBinding.Tab));
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
|
|
@ -224,15 +234,22 @@ public class MenuPanel : MonoBehaviour
|
|||
commands);
|
||||
}
|
||||
|
||||
private MenuTabButton[] ResolveVisibleTabs()
|
||||
private MenuTabBinding[] ResolveVisibleTabs()
|
||||
{
|
||||
return _tabs.Values
|
||||
.Where(tabButton => !tabButton.RequireDock || GameManager.DockedEntity != null)
|
||||
.Where(tabButton => tabButton.Tab != MenuTab.Local || (GameManager.DockedEntity as OrbitalEntity)?.Story != null)
|
||||
.OrderBy(tabButton => (int)tabButton.Tab)
|
||||
.Where(tabBinding => !tabBinding.RequireDock || GameManager.DockedEntity != null)
|
||||
.Where(tabBinding => tabBinding.Tab != MenuTab.Local || (GameManager.DockedEntity as OrbitalEntity)?.Story != null)
|
||||
.OrderBy(tabBinding => (int)tabBinding.Tab)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static string GetTabLabel(MenuTabBinding tabBinding)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(tabBinding.Label)
|
||||
? tabBinding.Tab.ToString()
|
||||
: tabBinding.Label;
|
||||
}
|
||||
|
||||
private static string GetTabCommand(MenuTab tab)
|
||||
{
|
||||
return $"aetheria.runtime_menu.tab.{tab.ToString().ToLowerInvariant()}";
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MenuTabButton : MonoBehaviour
|
||||
{
|
||||
public GameObject TabContents;
|
||||
public Button Button;
|
||||
public MenuTab Tab;
|
||||
public TextMeshProUGUI Text;
|
||||
public bool RequireDock;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d90317f6ecd38754fad9aee92f46b126
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -118,8 +118,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
typed audio controls are still future work. Sector-map zone inspection now
|
||||
lowers through a local Eve/UI Toolkit surface as well instead of rebuilding
|
||||
`PropertiesPanel` rows on each zone click. The runtime in-game menu tab strip
|
||||
now lowers through a local Eve/UI Toolkit surface instead of wiring old
|
||||
`MenuTabButton` clicks. Inventory background ship tuning now lowers through a
|
||||
now lowers through a local Eve/UI Toolkit surface, with `MenuPanel`
|
||||
serializing tab metadata directly instead of routing authority through old
|
||||
`MenuTabButton` components. Inventory background ship tuning now lowers through a
|
||||
local Eve/UI Toolkit surface instead of rebuilding a `PropertiesPanel`
|
||||
float field. Trade target-cargo selection now lowers through a local
|
||||
Eve/UI Toolkit surface instead of rebuilding a `ContextMenu` option list.
|
||||
|
|
@ -1568,9 +1569,9 @@ First Aetheria surfaces to publish:
|
|||
Toolkit surface. `SectorRenderer` still owns reveal/camera behavior, but
|
||||
zone inspection no longer rebuilds `PropertiesPanel` rows when the player
|
||||
clicks a zone.
|
||||
- Done: replace the runtime in-game menu tab strip with an Eve-owned UI
|
||||
Toolkit surface. `MenuPanel` still owns tab-content activation, but old
|
||||
`MenuTabButton` click wiring no longer owns tab navigation.
|
||||
- Done: replace the runtime in-game menu tab strip with an Eve-owned UI
|
||||
Toolkit surface. `MenuPanel` now owns tab-content activation and tab
|
||||
metadata directly; the old `MenuTabButton` component shell is gone.
|
||||
- Done: replace inventory background ship tuning with an Eve-owned UI
|
||||
Toolkit surface. `InventoryMenu` still owns click routing and the
|
||||
gameplay commit primitive still owns mutation, but the old
|
||||
|
|
@ -1961,8 +1962,8 @@ First Aetheria surfaces to publish:
|
|||
`UIDocument` host and a local Eve surface document instead of rebuilding
|
||||
`PropertiesPanel.AddProperty(...)` rows on each zone click.
|
||||
- Runtime in-game menu tab navigation now lowers through a shared UI Toolkit
|
||||
`UIDocument` host and a local Eve surface document instead of wiring
|
||||
`MenuTabButton` click handlers.
|
||||
`UIDocument` host and a local Eve surface document, with `MenuPanel`
|
||||
owning tab metadata directly instead of `MenuTabButton` components.
|
||||
- Inventory background ship tuning now lowers through a shared UI Toolkit
|
||||
`UIDocument` host and a local Eve surface document instead of rebuilding a
|
||||
mutable `PropertiesPanel.AddField(...)` control for shutdown threshold.
|
||||
|
|
|
|||
Loading…
Reference in a new issue