Orientation="Vertical"
HorizontalAlignment="Center">
<BoxContainer Orientation="Vertical">
- <BoxContainer Name="StorageContainer"
+ <BoxContainer Name="SingleStorageContainer"
Access="Public"
HorizontalAlignment="Center"
HorizontalExpand="True"
Margin="10">
</BoxContainer>
+ <BoxContainer Name="DoubleStorageContainer"
+ Access="Public"
+ HorizontalAlignment="Stretch"
+ HorizontalExpand="True"
+ Margin="10">
+ <BoxContainer Name="LeftStorageContainer"
+ Access="Public"
+ HorizontalAlignment="Left"
+ HorizontalExpand="True"
+ VerticalAlignment="Bottom"
+ Margin="10">
+ </BoxContainer>
+ <BoxContainer Name="RightStorageContainer"
+ Access="Public"
+ HorizontalAlignment="Right"
+ HorizontalExpand="True"
+ VerticalAlignment="Bottom"
+ Margin="10">
+ </BoxContainer>
+ </BoxContainer>
<BoxContainer Orientation="Horizontal" Name="Hotbar" HorizontalAlignment="Center">
<inventory:ItemSlotButtonContainer
Name="SecondHotbar"
+using System.Linq;
using System.Numerics;
using Content.Client.Examine;
using Content.Client.Hands.Systems;
public Angle DraggingRotation = Angle.Zero;
public bool StaticStorageUIEnabled;
public bool OpaqueStorageWindow;
+ private int _openStorageLimit = -1;
public bool IsDragging => _menuDragHelper.IsDragging;
public ItemGridPiece? CurrentlyDragging => _menuDragHelper.Dragged;
_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
_configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
_configuration.OnValueChanged(CCVars.StorageWindowTitle, OnStorageWindowTitle, true);
+ _configuration.OnValueChanged(CCVars.StorageLimit, OnStorageLimitChanged, true);
+ }
+
+ private void OnStorageLimitChanged(int obj)
+ {
+ _openStorageLimit = obj;
}
private void OnStorageWindowTitle(bool obj)
if (StaticStorageUIEnabled)
{
- UIManager.GetActiveUIWidgetOrNull<HotbarGui>()?.StorageContainer.AddChild(window);
+ var hotbar = UIManager.GetActiveUIWidgetOrNull<HotbarGui>();
+ // this lambda handles the nested storage case
+ // during nested storage, a parent window hides and a child window is
+ // immediately inserted to the end of the list
+ // we can reorder the newly inserted to the same index as the invisible
+ // window in order to prevent an invisible window from being replaced
+ // with a visible one in a different position
+ Action<Control?, Control> reorder = (parent, child) =>
+ {
+ if (parent is null)
+ return;
+
+ var parentChildren = parent.Children.ToList();
+ var invisibleIndex = parentChildren.FindIndex(c => c.Visible == false);
+ if (invisibleIndex == -1)
+ return;
+ child.SetPositionInParent(invisibleIndex);
+ };
+
+ if (_openStorageLimit == 2)
+ {
+ if (hotbar?.LeftStorageContainer.Children.Any(c => c.Visible) == false) // we're comparing booleans because it's bool? and not bool from the optional chaining
+ {
+ hotbar?.LeftStorageContainer.AddChild(window);
+ reorder(hotbar?.LeftStorageContainer, window);
+ }
+ else
+ {
+ hotbar?.RightStorageContainer.AddChild(window);
+ reorder(hotbar?.RightStorageContainer, window);
+ }
+ }
+ else
+ {
+ hotbar?.SingleStorageContainer.AddChild(window);
+ reorder(hotbar?.SingleStorageContainer, window);
+ }
_closeRecentWindowUIController.SetMostRecentlyInteractedWindow(window);
}
else