Storage sidebar fix (#34680)

This commit is contained in:
metalgearsloth
2025-01-28 10:09:52 +11:00
committed by GitHub
parent 69eccc4e92
commit 3e091c4dfa
2 changed files with 9 additions and 18 deletions

View File

@@ -201,7 +201,8 @@ public sealed class StorageWindow : BaseWindow
#region Sidebar #region Sidebar
_sidebar.Children.Clear(); _sidebar.Children.Clear();
_sidebar.Rows = boundingGrid.Height + 1; var rows = boundingGrid.Height + 1;
_sidebar.Rows = rows;
var exitButton = new TextureButton var exitButton = new TextureButton
{ {
@@ -243,12 +244,10 @@ public sealed class StorageWindow : BaseWindow
}; };
_sidebar.AddChild(exitContainer); _sidebar.AddChild(exitContainer);
var offset = 1; var offset = 2;
if (_entity.System<StorageSystem>().NestedStorage && boundingGrid.Height > 0) if (_entity.System<StorageSystem>().NestedStorage && rows > 0)
{ {
offset += 1;
_backButton = new TextureButton _backButton = new TextureButton
{ {
TextureNormal = _backTexture, TextureNormal = _backTexture,
@@ -280,7 +279,7 @@ public sealed class StorageWindow : BaseWindow
{ {
new TextureRect new TextureRect
{ {
Texture = boundingGrid.Height > 2 ? _sidebarMiddleTexture : _sidebarBottomTexture, Texture = rows > 2 ? _sidebarMiddleTexture : _sidebarBottomTexture,
TextureScale = new Vector2(2, 2), TextureScale = new Vector2(2, 2),
Children = Children =
{ {
@@ -293,22 +292,13 @@ public sealed class StorageWindow : BaseWindow
_sidebar.AddChild(backContainer); _sidebar.AddChild(backContainer);
} }
var rows = boundingGrid.Height - offset; var fillerRows = rows - offset;
for (var i = 0; i < rows; i++) for (var i = 0; i < fillerRows; i++)
{ {
_sidebar.AddChild(new TextureRect _sidebar.AddChild(new TextureRect
{ {
Texture = _sidebarMiddleTexture, Texture = i != (fillerRows - 1) ? _sidebarMiddleTexture : _sidebarBottomTexture,
TextureScale = new Vector2(2, 2),
});
}
if (rows > 0)
{
_sidebar.AddChild(new TextureRect
{
Texture = _sidebarBottomTexture,
TextureScale = new Vector2(2, 2), TextureScale = new Vector2(2, 2),
}); });
} }

View File

@@ -1314,6 +1314,7 @@ public abstract class SharedStorageSystem : EntitySystem
} }
Dirty(ent, ent.Comp); Dirty(ent, ent.Comp);
UpdateUI((ent.Owner, ent.Comp));
} }
/// <summary> /// <summary>