{
base.Initialize();
- UIManager.OnScreenChanged += OnScreenChange;
-
_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
_configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
_configuration.OnValueChanged(CCVars.StorageWindowTitle, OnStorageWindowTitle, true);
}
- private void OnScreenChange((UIScreen? Old, UIScreen? New) obj)
- {
- // Handle reconnects with hotbargui.
-
- // Essentially HotbarGui / the screen gets loaded AFTER gamestates at the moment (because clientgameticker manually changes it via event)
- // and changing this may be a massive change.
- // So instead we'll just manually reload it for now.
- if (!StaticStorageUIEnabled ||
- obj.New == null ||
- !EntityManager.TryGetComponent(_player.LocalEntity, out UserInterfaceUserComponent? userComp))
- {
- return;
- }
-
- // UISystemDependency not injected at this point so do it the old fashion way, I love ordering issues.
- var uiSystem = EntityManager.System<SharedUserInterfaceSystem>();
-
- foreach (var bui in uiSystem.GetActorUis((_player.LocalEntity.Value, userComp)))
- {
- if (!uiSystem.TryGetOpenUi<StorageBoundUserInterface>(bui.Entity, StorageComponent.StorageUiKey.Key, out var storageBui))
- continue;
-
- storageBui.ReOpen();
- }
- }
-
private void OnStorageWindowTitle(bool obj)
{
WindowTitle = obj;