Skip to content

Commit

Permalink
Storage sidebar fix (#34680)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored Jan 27, 2025
1 parent 69eccc4 commit 3e091c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ private void BuildGridRepresentation()

#region Sidebar
_sidebar.Children.Clear();
_sidebar.Rows = boundingGrid.Height + 1;
var rows = boundingGrid.Height + 1;
_sidebar.Rows = rows;

var exitButton = new TextureButton
{
Expand Down Expand Up @@ -243,12 +244,10 @@ private void BuildGridRepresentation()
};

_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
{
TextureNormal = _backTexture,
Expand Down Expand Up @@ -280,7 +279,7 @@ private void BuildGridRepresentation()
{
new TextureRect
{
Texture = boundingGrid.Height > 2 ? _sidebarMiddleTexture : _sidebarBottomTexture,
Texture = rows > 2 ? _sidebarMiddleTexture : _sidebarBottomTexture,
TextureScale = new Vector2(2, 2),
Children =
{
Expand All @@ -293,22 +292,13 @@ private void BuildGridRepresentation()
_sidebar.AddChild(backContainer);
}

var rows = boundingGrid.Height - offset;

for (var i = 0; i < rows; i++)
{
_sidebar.AddChild(new TextureRect
{
Texture = _sidebarMiddleTexture,
TextureScale = new Vector2(2, 2),
});
}
var fillerRows = rows - offset;

if (rows > 0)
for (var i = 0; i < fillerRows; i++)
{
_sidebar.AddChild(new TextureRect
{
Texture = _sidebarBottomTexture,
Texture = i != (fillerRows - 1) ? _sidebarMiddleTexture : _sidebarBottomTexture,
TextureScale = new Vector2(2, 2),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ public void SaveItemLocation(Entity<StorageComponent?> ent, Entity<MetaDataCompo
}

Dirty(ent, ent.Comp);
UpdateUI((ent.Owner, ent.Comp));
}

/// <summary>
Expand Down

0 comments on commit 3e091c4

Please sign in to comment.