Read menu docking through current typed state
This commit is contained in:
parent
2a03386ddd
commit
ca8b5858a2
4 changed files with 68 additions and 72 deletions
|
|
@ -34,21 +34,9 @@ public class MenuPanel : MonoBehaviour
|
|||
private MenuTabBinding _current;
|
||||
private UIDocument _tabSurfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _tabSurfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityObservedDockingIndex _observedDockingIndex;
|
||||
|
||||
public MenuTab CurrentTab { get; private set; }
|
||||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
{
|
||||
if (!ReferenceEquals(_observedEntityIndex, observedEntityIndex))
|
||||
{
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
}
|
||||
|
||||
public void ShowTab(MenuTab tab)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
|
@ -108,8 +96,6 @@ public class MenuPanel : MonoBehaviour
|
|||
AetheriaEveUnitySurfaceHost.DestroyDocument(_tabSurfaceDocument);
|
||||
_tabSurfaceDocument = null;
|
||||
}
|
||||
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
private void RenderTabSurface()
|
||||
|
|
@ -162,8 +148,7 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
private MenuTabBinding[] ResolveVisibleTabs()
|
||||
{
|
||||
var isDocked = TryResolveObservedDockingIndex(out var dockingIndex) &&
|
||||
dockingIndex.TryResolveCurrentDocking(out var docking) &&
|
||||
var isDocked = TryResolveCurrentDocking(out var docking) &&
|
||||
docking.IsDocked;
|
||||
return _tabs.Values
|
||||
.Where(tabBinding => !tabBinding.RequireDock || isDocked)
|
||||
|
|
@ -172,14 +157,21 @@ public class MenuPanel : MonoBehaviour
|
|||
.ToArray();
|
||||
}
|
||||
|
||||
private bool TryResolveObservedDockingIndex(out AetheriaUnityObservedDockingIndex dockingIndex)
|
||||
private static bool TryResolveCurrentDocking(out AetheriaRuntimeCurrentDockingDocument docking)
|
||||
{
|
||||
dockingIndex = null;
|
||||
if (_observedEntityIndex == null)
|
||||
docking = null;
|
||||
try
|
||||
{
|
||||
docking = AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeState("unity-runtime-menu-tabs")
|
||||
.CurrentDockingState();
|
||||
return docking != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria runtime docking for menu tabs: {ex.Message}");
|
||||
return false;
|
||||
|
||||
dockingIndex = _observedDockingIndex ??= new AetheriaUnityObservedDockingIndex(_observedEntityIndex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetTabLabel(MenuTabBinding tabBinding)
|
||||
|
|
|
|||
Loading…
Reference in a new issue