Sample trade menu through current typed access
This commit is contained in:
parent
10186bd078
commit
071c1febbd
2 changed files with 37 additions and 39 deletions
|
|
@ -7921,33 +7921,44 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root)
|
|||
"UI",
|
||||
"Menu",
|
||||
"TradeMenu.cs"));
|
||||
var requiredTradeMenuSharedDocumentSymbols = new[] { "private void OnDestroy()" };
|
||||
var compactTradeMenu = CompactSource(tradeMenu);
|
||||
var requiredTradeMenuSharedDocumentSymbols = new[]
|
||||
{
|
||||
".RuntimeState(\"unity-trade\").CurrentCatalog()",
|
||||
".RuntimeState(\"unity-trade\").CurrentPlayerSettings()",
|
||||
"private void OnDestroy()"
|
||||
};
|
||||
var missingTradeMenuSharedDocumentSymbols = requiredTradeMenuSharedDocumentSymbols
|
||||
.Where(symbol => !tradeMenu.Contains(symbol, StringComparison.Ordinal))
|
||||
.Where(symbol => !compactTradeMenu.Contains(symbol, StringComparison.Ordinal) &&
|
||||
!tradeMenu.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (missingTradeMenuSharedDocumentSymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"TradeMenu should bind shared catalog/settings through managed reactive Aetheria documents with menu lifetime disposal: " +
|
||||
"TradeMenu should sample shared catalog/settings through named current typed Aetheria documents: " +
|
||||
string.Join(", ", missingTradeMenuSharedDocumentSymbols));
|
||||
}
|
||||
|
||||
RequireReactiveTypedDocumentAccess(
|
||||
tradeMenu,
|
||||
"TradeMenu",
|
||||
"AetheriaRuntimeCatalogSnapshot",
|
||||
"_catalog",
|
||||
var forbiddenTradeMenuSharedDocumentSymbols = new[]
|
||||
{
|
||||
"CultMeshReactiveDocument<",
|
||||
".ReactiveCatalogSnapshot(\"unity-trade\")",
|
||||
"AetheriaRuntimeCatalogSession",
|
||||
"ResolveClient().State.ObserveCatalog()");
|
||||
RequireReactiveTypedDocumentAccess(
|
||||
tradeMenu,
|
||||
"TradeMenu",
|
||||
"AetheriaRuntimePlayerSettingsDocument",
|
||||
"_playerSettings",
|
||||
".ReactivePlayerSettingsDocument(\"unity-trade\")",
|
||||
"AetheriaRuntimeCatalogSession",
|
||||
"AetheriaRuntimePlayerSettingsSession",
|
||||
".ObservePlayer()");
|
||||
"ResolveClient().State.ObserveCatalog()",
|
||||
".ObservePlayer()",
|
||||
"_catalog?.Dispose()",
|
||||
"_playerSettings?.Dispose()"
|
||||
}
|
||||
.Where(symbol => tradeMenu.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (forbiddenTradeMenuSharedDocumentSymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"TradeMenu still routes catalog/settings through wrapper/session/reactive handles instead of current typed documents: " +
|
||||
string.Join(", ", forbiddenTradeMenuSharedDocumentSymbols));
|
||||
}
|
||||
|
||||
var inventoryMenu = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Text.RegularExpressions;
|
|||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
|
@ -37,8 +36,6 @@ public class TradeMenu : MonoBehaviour
|
|||
private UIDocument _filterSurfaceDocument;
|
||||
private UIDocument _rowActionSurfaceDocument;
|
||||
private UIDocument _tradeItemSurfaceDocument;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _playerSettings;
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityObservedDockingIndex _observedDockingIndex;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _cargoSelectorSurfaceChrome = PanelChrome(360f, 420f, Align.FlexEnd);
|
||||
|
|
@ -586,47 +583,37 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
private void ClearClientCaches()
|
||||
{
|
||||
_catalog?.Dispose();
|
||||
_playerSettings?.Dispose();
|
||||
_catalog = null;
|
||||
_playerSettings = null;
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot CatalogSnapshot()
|
||||
{
|
||||
if (_catalog != null)
|
||||
return _catalog.Current;
|
||||
|
||||
try
|
||||
{
|
||||
_catalog = AetheriaUnityRuntimeClientProvider
|
||||
.ReactiveCatalogSnapshot("unity-trade");
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeState("unity-trade")
|
||||
.CurrentCatalog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to bind Aetheria runtime catalog for trade menu: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to read Aetheria runtime catalog for trade menu: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return _catalog?.Current;
|
||||
}
|
||||
|
||||
private AetheriaRuntimePlayerSettingsDocument PlayerSettingsSnapshot()
|
||||
{
|
||||
if (_playerSettings != null)
|
||||
return _playerSettings.Current;
|
||||
|
||||
try
|
||||
{
|
||||
_playerSettings = AetheriaUnityRuntimeClientProvider
|
||||
.ReactivePlayerSettingsDocument("unity-trade");
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeState("unity-trade")
|
||||
.CurrentPlayerSettings();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to bind Aetheria player settings for trade menu: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to read Aetheria player settings for trade menu: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return _playerSettings?.Current;
|
||||
}
|
||||
|
||||
private string ResolveManufacturerName(AetheriaRuntimeCatalogItem item)
|
||||
|
|
|
|||
Loading…
Reference in a new issue