From 3f20e06e1568ae071244e8991c037dc67231bce1 Mon Sep 17 00:00:00 2001 From: Viktor Ferenczi Date: Sun, 3 Oct 2021 05:51:46 +0200 Subject: [PATCH] Control Panel view state (#13) Control Panel view state * State more in-line with React's model * Listing all blocks from the terminal system * Calls to modify the block properties * Reasonable printing of block properties for initial testing --- EnhancedUI/Content/ControlPanel.html | 3 +- EnhancedUI/Content/ControlPanel.js | 96 +++++++++-- EnhancedUI/Content/Inventory.html | 2 - EnhancedUI/Content/Inventory.js | 4 +- EnhancedUI/Content/common.css | 15 +- EnhancedUI/Content/common.js | 13 +- EnhancedUI/Gui/BrowserViewModel.cs | 32 ---- EnhancedUI/Gui/Chromium.cs | 6 +- EnhancedUI/Gui/ChromiumGuiControl.cs | 14 +- .../{IBrowserViewModel.cs => IPanelState.cs} | 8 +- EnhancedUI/Gui/PanelState.cs | 38 ++++ .../Gui/Terminal/ControlPanel/BlockInfo.cs | 24 --- .../Gui/Terminal/ControlPanel/BlockState.cs | 92 ++++++++++ .../ControlPanelBrowserViewModel.cs | 66 ------- .../ControlPanel/ControlPanelState.cs | 163 ++++++++++++++++++ ...al_CreateControlPanelPageControls_Patch.cs | 4 +- .../MyTerminalControlPanel_Init_Patch.cs | 2 +- .../Inventory/InventoryBrowserViewModel.cs | 17 -- .../Gui/Terminal/Inventory/InventoryState.cs | 12 ++ ...minal_CreateInventoryPageControls_Patch.cs | 2 +- 20 files changed, 428 insertions(+), 185 deletions(-) delete mode 100644 EnhancedUI/Gui/BrowserViewModel.cs rename EnhancedUI/Gui/{IBrowserViewModel.cs => IPanelState.cs} (58%) create mode 100644 EnhancedUI/Gui/PanelState.cs delete mode 100644 EnhancedUI/Gui/Terminal/ControlPanel/BlockInfo.cs create mode 100644 EnhancedUI/Gui/Terminal/ControlPanel/BlockState.cs delete mode 100644 EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelBrowserViewModel.cs create mode 100644 EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelState.cs delete mode 100644 EnhancedUI/Gui/Terminal/Inventory/InventoryBrowserViewModel.cs create mode 100644 EnhancedUI/Gui/Terminal/Inventory/InventoryState.cs diff --git a/EnhancedUI/Content/ControlPanel.html b/EnhancedUI/Content/ControlPanel.html index 73d0eb6..b4b9193 100644 --- a/EnhancedUI/Content/ControlPanel.html +++ b/EnhancedUI/Content/ControlPanel.html @@ -18,8 +18,7 @@

CONTROL PANEL

Browser size: pixels

- +
diff --git a/EnhancedUI/Content/ControlPanel.js b/EnhancedUI/Content/ControlPanel.js index ffc3c29..6241b43 100644 --- a/EnhancedUI/Content/ControlPanel.js +++ b/EnhancedUI/Content/ControlPanel.js @@ -1,16 +1,88 @@ -var state = ''; +var blockStates = null; -async function clearContent() { - $('#blocks').empty(); +async function stateUpdated() { + const blockViews = $('#blocks'); + blockViews.empty(); + + blockStates = await state.GetBlockStates(); + for (const entityId in blockStates) { + renderBlock(blockViews, blockStates[entityId]); + } +} + +function renderBlock(parent, blockState) { + let blockView = $('
'); + blockView.addClass('block'); + blockView.attr('id', 'block-' + blockState.EntityId); + renderBlockInner(blockView, blockState); + parent.append(blockView); +} + +function renderBlockInner(blockView, blockState) { + let id = $('
'); + id.addClass('entityId'); + id.text(blockState.EntityId); + blockView.append(id); + + let type = $('
'); + type.addClass('type'); + type.text(blockState.ClassName + ' | ' + blockState.TypeId + ' | ' + blockState.SubtypeName); + blockView.append(type); + + let name = $('
'); + name.addClass('name'); + name.text(blockState.Name); + blockView.append(name); + + let properties = $('
') + properties.addClass('properties'); + for (const propertyId in blockState.PropertyStates) { + renderBlockProperty(properties, blockState.PropertyStates[propertyId]) + } + blockView.append(properties) + + blockView.append($('
')) +} + +function renderBlockProperty(parent, propertyState) { + let propertyView= $('
'); + propertyView.addClass('property'); + + let value = $('
'); + value.addClass('value'); + switch(propertyState.TypeName) { + case "Boolean": + cb = $('') + cb.attr('type', 'checkbox'); + cb.attr('id', propertyState.Id); + if (propertyState.BoolValue) { + cb.attr('checked', 'checked'); + } + value.append(cb); + label = $('
diff --git a/EnhancedUI/Content/Inventory.js b/EnhancedUI/Content/Inventory.js index 9c4f184..e87997c 100644 --- a/EnhancedUI/Content/Inventory.js +++ b/EnhancedUI/Content/Inventory.js @@ -1,4 +1,2 @@ -async function loadItems() { - const result = await model.TestAdd(1, 2); - $('#result').text(result.toString()); +async function stateUpdated() { } \ No newline at end of file diff --git a/EnhancedUI/Content/common.css b/EnhancedUI/Content/common.css index dcc8ba3..d3b2047 100644 --- a/EnhancedUI/Content/common.css +++ b/EnhancedUI/Content/common.css @@ -12,7 +12,7 @@ html { } body { - overflow: hidden; + /*overflow: hidden;*/ } .fullscreen { @@ -26,4 +26,17 @@ body { .hide { display: none; +} + +label { + padding-left: 0.5ch; +} + +.block { + margin-bottom: 2vh; +} + +.block .property { + margin-top: 0.5vh; + margin-left: 2vw; } \ No newline at end of file diff --git a/EnhancedUI/Content/common.js b/EnhancedUI/Content/common.js index e01a0a1..1a4e0bd 100644 --- a/EnhancedUI/Content/common.js +++ b/EnhancedUI/Content/common.js @@ -1,9 +1,6 @@ -$(document).ready(function () { - $("#window-size").text(`${window.innerWidth}x${window.innerHeight}`); - initializeProxy().then(_ => null); -}); +$(document).ready(async function () { + await CefSharp.BindObjectAsync("state"); + state.NotifyBound(); -async function initializeProxy() { - await CefSharp.BindObjectAsync("model"); - model.MarkLoaded(); -} \ No newline at end of file + $("#window-size").text(`${window.innerWidth}x${window.innerHeight}`); +}); \ No newline at end of file diff --git a/EnhancedUI/Gui/BrowserViewModel.cs b/EnhancedUI/Gui/BrowserViewModel.cs deleted file mode 100644 index dfa6729..0000000 --- a/EnhancedUI/Gui/BrowserViewModel.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CefSharp; -using CefSharp.OffScreen; - -namespace EnhancedUI.Gui -{ - public class BrowserViewModel: IBrowserViewModel - { - public ChromiumWebBrowser? Browser; - private bool loaded; - - public void SetBrowser(ChromiumWebBrowser? browser) - { - Browser = browser; - } - - public bool HasLoaded() - { - return loaded && Browser?.IsBrowserInitialized == true; - } - - public virtual void MarkLoaded() - { - loaded = true; - } - - public virtual void Reload() - { - loaded = false; - Browser?.Reload(); - } - } -} \ No newline at end of file diff --git a/EnhancedUI/Gui/Chromium.cs b/EnhancedUI/Gui/Chromium.cs index a6b90df..bf105a5 100644 --- a/EnhancedUI/Gui/Chromium.cs +++ b/EnhancedUI/Gui/Chromium.cs @@ -15,7 +15,7 @@ public class Chromium : IDisposable public readonly ChromiumWebBrowser Browser; - public Chromium(Vector2I size, object viewModel) + public Chromium(Vector2I size, object state) { videoData = new byte[size.X * size.Y * 4]; @@ -31,11 +31,11 @@ public Chromium(Vector2I size, object viewModel) Browser.JavascriptObjectRepository.ResolveObject += (sender, e) => { var repo = e.ObjectRepository; - if (e.ObjectName == "model") + if (e.ObjectName == "state") { // No CamelCase of Javascript Names repo.NameConverter = null; - repo.Register("model", viewModel, isAsync: true, options: BindingOptions.DefaultBinder); + repo.Register("state", state, isAsync: true, options: BindingOptions.DefaultBinder); } }; } diff --git a/EnhancedUI/Gui/ChromiumGuiControl.cs b/EnhancedUI/Gui/ChromiumGuiControl.cs index 69fb14d..8e5af20 100644 --- a/EnhancedUI/Gui/ChromiumGuiControl.cs +++ b/EnhancedUI/Gui/ChromiumGuiControl.cs @@ -33,13 +33,13 @@ public class ChromiumGuiControl : MyGuiControlBase private bool capsLock; private Vector2I lastValidMousePosition = -Vector2I.One; private List lastPressedKeys = new(); - private readonly IBrowserViewModel viewModel; + private readonly IPanelState state; - public ChromiumGuiControl(WebContent content, string name, IBrowserViewModel viewModel) + public ChromiumGuiControl(WebContent content, string name, IPanelState state) { this.content = content; this.name = name; - this.viewModel = viewModel; + this.state = state; } protected override void OnSizeChanged() @@ -59,12 +59,12 @@ private void CreatePlayerIfNeeded() } var rect = GetVideoScreenRectangle(); - chromium = new Chromium(new Vector2I(rect.Width, rect.Height), viewModel); + chromium = new Chromium(new Vector2I(rect.Width, rect.Height), state); chromium.Ready += OnChromiumReady; chromium.Browser.LoadingStateChanged += OnBrowserLoadingStateChanged; - viewModel.SetBrowser(chromium.Browser); + state.SetBrowser(chromium.Browser); player = new BatchDataPlayer(new Vector2I(rect.Width, rect.Height), chromium.GetVideoData); VideoPlayPatch.RegisterVideoPlayer(name, player); @@ -79,7 +79,7 @@ public override void OnRemoving() return; } - viewModel.SetBrowser(null); + state.SetBrowser(null); chromium.Ready -= OnChromiumReady; chromium.Browser.LoadingStateChanged -= OnBrowserLoadingStateChanged; @@ -145,7 +145,7 @@ public override void Draw(float transitionAlpha, float backgroundTransitionAlpha // Reloads the HTML document private void ReloadPage() { - viewModel.Reload(); + state.Reload(); } private void OpenWebDeveloperTools() diff --git a/EnhancedUI/Gui/IBrowserViewModel.cs b/EnhancedUI/Gui/IPanelState.cs similarity index 58% rename from EnhancedUI/Gui/IBrowserViewModel.cs rename to EnhancedUI/Gui/IPanelState.cs index b1f8341..d57f5dd 100644 --- a/EnhancedUI/Gui/IBrowserViewModel.cs +++ b/EnhancedUI/Gui/IPanelState.cs @@ -2,16 +2,16 @@ namespace EnhancedUI.Gui { - public interface IBrowserViewModel + public interface IPanelState { - // Assigns the current Chromium browser to the view model, required to invoke JavaScript + // Access to the browser instance is required to invoke JavaScript void SetBrowser(ChromiumWebBrowser? browser); // Return True if the page has been loaded - bool HasLoaded(); + bool HasBound(); // Marks the page as loaded - void MarkLoaded(); + void NotifyBound(); // Reloads the page void Reload(); diff --git a/EnhancedUI/Gui/PanelState.cs b/EnhancedUI/Gui/PanelState.cs new file mode 100644 index 0000000..f15e6f0 --- /dev/null +++ b/EnhancedUI/Gui/PanelState.cs @@ -0,0 +1,38 @@ +using CefSharp; +using CefSharp.OffScreen; + +namespace EnhancedUI.Gui +{ + public class PanelState : IPanelState + { + // Stores a reference to the browser, required to invoke JavaScript code (send events from C# to JS) + protected ChromiumWebBrowser? Browser; + + // True value indicates that the state has been bound to a JS accessible global variable already + private bool bound; + + public void SetBrowser(ChromiumWebBrowser? browser) + { + Browser = browser; + } + + // Checks whether the state has been bound to a JS accessible global variable already + public bool HasBound() + { + return bound && Browser?.IsBrowserInitialized == true; + } + + // Invoked by JS code after the state is bound to a global variable + public virtual void NotifyBound() + { + bound = true; + } + + // Reloads the page, which requires re-binding the state to a JS global variable + public virtual void Reload() + { + bound = false; + Browser?.Reload(); + } + } +} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/BlockInfo.cs b/EnhancedUI/Gui/Terminal/ControlPanel/BlockInfo.cs deleted file mode 100644 index 26bee67..0000000 --- a/EnhancedUI/Gui/Terminal/ControlPanel/BlockInfo.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Sandbox.Game.Entities.Cube; - -namespace EnhancedUI.Gui.Terminal.ControlPanel -{ - public class BlockInfo - { - public readonly string Name; - - public override int GetHashCode() - { - return Name.GetHashCode(); - } - - public BlockInfo(MyFunctionalBlock block) - { - Name = block.CustomName.ToString(); - if (Name == "") - { - Name = block.DisplayNameText ?? block.DisplayName; - } - } - } -} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/BlockState.cs b/EnhancedUI/Gui/Terminal/ControlPanel/BlockState.cs new file mode 100644 index 0000000..9e68dbd --- /dev/null +++ b/EnhancedUI/Gui/Terminal/ControlPanel/BlockState.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using Sandbox.Game.Entities.Cube; +using Sandbox.ModAPI.Interfaces; + +namespace EnhancedUI.Gui.Terminal.ControlPanel +{ + public class BlockState + { + public readonly string ClassName; + public readonly string TypeId; + public readonly string SubtypeName; + + public readonly long EntityId; + public readonly string Name; + public readonly string DetailedInfo; + public readonly string CustomData; + + // ReSharper disable once CollectionNeverQueried.Global + public readonly Dictionary PropertyStates = new(); + + public override int GetHashCode() + { + return Name.GetHashCode(); + } + + public BlockState(MyTerminalBlock block) + { + ClassName = block.GetType().Name; + TypeId = block.BlockDefinition.Id.TypeId.ToString(); + SubtypeName = block.BlockDefinition.Id.SubtypeName; + + EntityId = block.EntityId; + Name = block.CustomName.ToString(); + if (Name == "") + { + Name = block.DisplayNameText ?? block.DisplayName; + } + + DetailedInfo = block.DetailedInfo.ToString(); + CustomData = block.CustomData; + + var properties = new List(); + block.GetProperties(properties, null); + foreach (var property in properties) + { + PropertyStates[property.Id] = new BlockPropertyState(block, property); + } + } + } + + public class BlockPropertyState + { + public readonly string Id; + public readonly string TypeName; + + public readonly bool BoolValue; + public readonly long LongValue; + public readonly float FloatValue; + // public readonly Color ColorValue; + + public BlockPropertyState(MyTerminalBlock block, ITerminalProperty property) + { + Id = property.Id; + TypeName = property.TypeName; + + var asBool = property.AsBool(); + if (asBool != null) + { + BoolValue = asBool.GetValue(block); + } + + var asLong = property.As(); + if (asLong != null) + { + LongValue = asLong.GetValue(block); + } + + var asFloat = property.AsFloat(); + if (asFloat != null) + { + FloatValue = asFloat.GetValue(block); + } + + // var asColor = property.AsColor(); + // if (asColor != null) + // { + // ColorValue = asColor.GetValue(block); + // } + } + } +} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelBrowserViewModel.cs b/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelBrowserViewModel.cs deleted file mode 100644 index f294c3d..0000000 --- a/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelBrowserViewModel.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.Collections.Generic; -using CefSharp; -using Sandbox.Game.Entities.Cube; - -namespace EnhancedUI.Gui.Terminal.ControlPanel -{ - public class ControlPanelBrowserViewModel: BrowserViewModel - { - public static ControlPanelBrowserViewModel? Instance; - public MyTerminalBlock? InteractedBlock; - - public ControlPanelBrowserViewModel() - { - Instance = this; - } - - public override void Reload() - { - base.Reload(); - Clear(); - } - - public void Clear() - { - if (HasLoaded()) - { - Browser.ExecuteScriptAsync("clearContent();"); - } - - InteractedBlock = null; - } - - public void Load(MyTerminalBlock block) - { - if (!HasLoaded()) - { - InteractedBlock = null; - return; - } - - if (InteractedBlock?.EntityId == block.EntityId) - return; - - Browser.ExecuteScriptAsync("updateContent();"); - - InteractedBlock = block; - } - - // ReSharper disable once UnusedMember.Global - public List GetBlocks() - { - var blockList = new List(); - if (InteractedBlock == null) - { - return blockList; - } - - foreach (var functionalBlock in InteractedBlock.CubeGrid.GetFatBlocks()) - { - blockList.Add(new BlockInfo(functionalBlock)); - } - - return blockList; - } - } -} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelState.cs b/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelState.cs new file mode 100644 index 0000000..eb28ca4 --- /dev/null +++ b/EnhancedUI/Gui/Terminal/ControlPanel/ControlPanelState.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using CefSharp; +using Sandbox.Game.Entities.Cube; +using Sandbox.ModAPI.Interfaces; + +namespace EnhancedUI.Gui.Terminal.ControlPanel +{ + public class ControlPanelState : PanelState + { + public static ControlPanelState? Instance; + + // Link to SE's data model + private MyTerminalBlock? interactedBlock; + + // Blocks by EntityId + private readonly Dictionary terminalBlocks = new(); + + // Blocks states by EntityId + private readonly Dictionary blockStates = new(); + + // Getters, because CefSharp relays only method calls + // ReSharper disable once UnusedMember.Global + public Dictionary GetBlockStates() => blockStates; + public BlockState GetBlockState(long entityId) => blockStates[entityId]; + + public ControlPanelState() + { + Instance = this; + } + + public override void Reload() + { + base.Reload(); + Clear(); + } + + public void Clear() + { + interactedBlock = null; + + foreach (var terminalBlock in terminalBlocks.Values) + { + terminalBlock.PropertiesChanged -= OnPropertyChanged; + } + + terminalBlocks.Clear(); + blockStates.Clear(); + + if (HasBound()) + { + Browser.ExecuteScriptAsync("stateUpdated();"); + } + } + + public void Update(MyTerminalBlock block) + { + if (!HasBound()) + { + return; + } + + if (interactedBlock?.EntityId == block.EntityId) + { + return; + } + + interactedBlock = block; + + LoadBlockStates(); + + foreach (var terminalBlock in terminalBlocks.Values) + { + terminalBlock.PropertiesChanged += OnPropertyChanged; + } + + Browser.ExecuteScriptAsync("stateUpdated();"); + } + + // ReSharper disable once UnusedMember.Global + + private void LoadBlockStates() + { + terminalBlocks.Clear(); + blockStates.Clear(); + + if (interactedBlock == null) + { + return; + } + + foreach (var terminalBlock in interactedBlock.CubeGrid.GridSystems.TerminalSystem.Blocks) + { + terminalBlocks[terminalBlock.EntityId] = terminalBlock; + blockStates[terminalBlock.EntityId] = new BlockState(terminalBlock); + } + } + + private void OnPropertyChanged(MyTerminalBlock terminalBlock) + { + if (terminalBlock.Closed) + return; + + var entityId = terminalBlock.EntityId; + + blockStates[entityId] = new BlockState(terminalBlock); + + if (HasBound()) + { + Browser.ExecuteScriptAsync("blockStateUpdated('" + entityId + "');"); + } + } + + // Methods to call from JS to change blocks + + public void ModifyBlock(long entityId, string name, string customData) + { + var block = terminalBlocks[entityId]; + if (block.Closed) + return; + + block.Name = name; + block.CustomData = customData; + blockStates[entityId] = new BlockState(block); + + if (HasBound()) + { + Browser.ExecuteScriptAsync("blockStateUpdated('" + entityId + "');"); + } + } + + public void ModifyBlockAttribute(long entityId, string propertyId, object value) + { + var block = terminalBlocks[entityId]; + if (block.Closed) + return; + + var property = block.GetProperty(propertyId); + + switch (value) + { + case bool boolValue: + property.AsBool().SetValue(block, boolValue); + break; + + case long intValue: + property.As().SetValue(block, intValue); + break; + + case float floatValue: + property.AsFloat().SetValue(block, floatValue); + break; + } + + blockStates[entityId] = new BlockState(block); + + if (HasBound()) + { + Browser.ExecuteScriptAsync("blockStateUpdated('" + entityId + "');"); + } + } + } +} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/MyGuiScreenTerminal_CreateControlPanelPageControls_Patch.cs b/EnhancedUI/Gui/Terminal/ControlPanel/MyGuiScreenTerminal_CreateControlPanelPageControls_Patch.cs index e40d438..8de0782 100644 --- a/EnhancedUI/Gui/Terminal/ControlPanel/MyGuiScreenTerminal_CreateControlPanelPageControls_Patch.cs +++ b/EnhancedUI/Gui/Terminal/ControlPanel/MyGuiScreenTerminal_CreateControlPanelPageControls_Patch.cs @@ -27,8 +27,8 @@ private static bool Prefix( page.TextEnum = MySpaceTexts.ControlPanel; page.TextScale = 0.7005405f; - var viewModel = new ControlPanelBrowserViewModel(); - var control = new ChromiumGuiControl(Content, Name, viewModel) + var state = new ControlPanelState(); + var control = new ChromiumGuiControl(Content, Name, state) { Position = new Vector2(0f, 0.005f), Size = new Vector2(0.9f, 0.7f) diff --git a/EnhancedUI/Gui/Terminal/ControlPanel/MyTerminalControlPanel_Init_Patch.cs b/EnhancedUI/Gui/Terminal/ControlPanel/MyTerminalControlPanel_Init_Patch.cs index ad9f52b..70b2e6d 100644 --- a/EnhancedUI/Gui/Terminal/ControlPanel/MyTerminalControlPanel_Init_Patch.cs +++ b/EnhancedUI/Gui/Terminal/ControlPanel/MyTerminalControlPanel_Init_Patch.cs @@ -24,7 +24,7 @@ private static bool Prefix() var block = MyGuiScreenTerminal.InteractedEntity as MyTerminalBlock; if (block != null) { - ControlPanelBrowserViewModel.Instance?.Load(block); + ControlPanelState.Instance?.Update(block); } return false; diff --git a/EnhancedUI/Gui/Terminal/Inventory/InventoryBrowserViewModel.cs b/EnhancedUI/Gui/Terminal/Inventory/InventoryBrowserViewModel.cs deleted file mode 100644 index 383e4c3..0000000 --- a/EnhancedUI/Gui/Terminal/Inventory/InventoryBrowserViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace EnhancedUI.Gui.Terminal.Inventory -{ - public class InventoryBrowserViewModel: BrowserViewModel - { - public static InventoryBrowserViewModel? Instance; - - public InventoryBrowserViewModel() - { - Instance = this; - } - - public int TestAdd(int a, int b) - { - return a + b; - } - } -} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/Inventory/InventoryState.cs b/EnhancedUI/Gui/Terminal/Inventory/InventoryState.cs new file mode 100644 index 0000000..6515552 --- /dev/null +++ b/EnhancedUI/Gui/Terminal/Inventory/InventoryState.cs @@ -0,0 +1,12 @@ +namespace EnhancedUI.Gui.Terminal.Inventory +{ + public class InventoryState: PanelState + { + public static InventoryState? Instance; + + public InventoryState() + { + Instance = this; + } + } +} \ No newline at end of file diff --git a/EnhancedUI/Gui/Terminal/Inventory/MyGuiScreenTerminal_CreateInventoryPageControls_Patch.cs b/EnhancedUI/Gui/Terminal/Inventory/MyGuiScreenTerminal_CreateInventoryPageControls_Patch.cs index 78f9368..9c3774d 100644 --- a/EnhancedUI/Gui/Terminal/Inventory/MyGuiScreenTerminal_CreateInventoryPageControls_Patch.cs +++ b/EnhancedUI/Gui/Terminal/Inventory/MyGuiScreenTerminal_CreateInventoryPageControls_Patch.cs @@ -26,7 +26,7 @@ private static bool Prefix( page.TextEnum = MySpaceTexts.Inventory; page.TextScale = 0.7005405f; - var proxy = new InventoryBrowserViewModel(); + var proxy = new InventoryState(); var control = new ChromiumGuiControl(Content, Name, proxy) { Position = new Vector2(0f, 0.005f),