Use reactive shared state in trade menu
This commit is contained in:
parent
194e45c3bd
commit
a30679a096
2 changed files with 45 additions and 10 deletions
|
|
@ -7107,6 +7107,36 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root)
|
|||
string.Join(", ", missingSchematicDisplaySymbols));
|
||||
}
|
||||
|
||||
var tradeMenu = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"Assets",
|
||||
"Scripts",
|
||||
"UI",
|
||||
"Menu",
|
||||
"TradeMenu.cs"));
|
||||
var requiredTradeMenuSharedDocumentSymbols = new[]
|
||||
{
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _playerSettings",
|
||||
"ResolveClient().Aetheria().ReactiveCatalog()",
|
||||
".Settings",
|
||||
".ReactivePlayer()",
|
||||
"_catalog?.Dispose()",
|
||||
"_playerSettings?.Dispose()",
|
||||
"_catalog?.Current",
|
||||
"_playerSettings?.Current",
|
||||
"private void OnDestroy()"
|
||||
};
|
||||
var missingTradeMenuSharedDocumentSymbols = requiredTradeMenuSharedDocumentSymbols
|
||||
.Where(symbol => !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: " +
|
||||
string.Join(", ", missingTradeMenuSharedDocumentSymbols));
|
||||
}
|
||||
|
||||
var volumeCloudRenderer = File.ReadAllText(Path.Combine(
|
||||
root,
|
||||
"Assets",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ 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 +38,8 @@ public class TradeMenu : MonoBehaviour
|
|||
private UIDocument _rowActionSurfaceDocument;
|
||||
private UIDocument _tradeItemSurfaceDocument;
|
||||
private string _clientStatePath = "";
|
||||
private AetheriaRuntimeCatalogSnapshot _catalog;
|
||||
private AetheriaRuntimePlayerSettingsDocument _playerSettings;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _playerSettings;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _cargoSelectorSurfaceChrome = PanelChrome(360f, 420f, Align.FlexEnd);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _filterSurfaceChrome = PanelChrome(420f, 520f, Align.FlexStart);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _rowActionSurfaceChrome = PanelChrome(320f, 360f, Align.FlexStart);
|
||||
|
|
@ -615,6 +616,8 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
private void ClearClientCaches()
|
||||
{
|
||||
_catalog?.Dispose();
|
||||
_playerSettings?.Dispose();
|
||||
_catalog = null;
|
||||
_playerSettings = null;
|
||||
_dockingState = null;
|
||||
|
|
@ -624,38 +627,38 @@ public class TradeMenu : MonoBehaviour
|
|||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
{
|
||||
if (_catalog != null)
|
||||
return _catalog;
|
||||
return _catalog.Current;
|
||||
|
||||
try
|
||||
{
|
||||
_catalog = ResolveClient().Aetheria().LatestCatalog();
|
||||
_catalog = ResolveClient().Aetheria().ReactiveCatalog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria runtime catalog for trade menu: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to bind Aetheria runtime catalog for trade menu: {ex.Message}");
|
||||
}
|
||||
|
||||
return _catalog;
|
||||
return _catalog?.Current;
|
||||
}
|
||||
|
||||
private AetheriaRuntimePlayerSettingsDocument ResolvePlayerSettings()
|
||||
{
|
||||
if (_playerSettings != null)
|
||||
return _playerSettings;
|
||||
return _playerSettings.Current;
|
||||
|
||||
try
|
||||
{
|
||||
_playerSettings = ResolveClient()
|
||||
.Aetheria()
|
||||
.Settings
|
||||
.LatestPlayer();
|
||||
.ReactivePlayer();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria player settings for trade menu: {ex.Message}");
|
||||
Debug.LogWarning($"Failed to bind Aetheria player settings for trade menu: {ex.Message}");
|
||||
}
|
||||
|
||||
return _playerSettings;
|
||||
return _playerSettings?.Current;
|
||||
}
|
||||
|
||||
private string ResolveManufacturerName(AetheriaRuntimeCatalogItem item)
|
||||
|
|
@ -1305,6 +1308,8 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearClientCaches();
|
||||
|
||||
if (_cargoSelectorSurfaceDocument != null)
|
||||
{
|
||||
AetheriaEveUnitySurfaceHost.DestroyDocument(_cargoSelectorSurfaceDocument);
|
||||
|
|
|
|||
Loading…
Reference in a new issue