Skip to content

Commit

Permalink
Cherry-Pick Wizden PR #27960 (#1067)
Browse files Browse the repository at this point in the history
* fix orphaned storage grid pieces getting stuck to the cursor

* instead of denying it, update it smartly

# Description

This cherry-picks
space-wizards/space-station-14#27960
Which should fix our storage UI bugs.

Co-authored-by: Nemanja <[email protected]>
  • Loading branch information
VMSolidus and EmoGarbage404 authored Oct 17, 2024
1 parent 603b86e commit 0f73ebf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void BuildItemPieces()

//todo. at some point, we may want to only rebuild the pieces that have actually received new data.

_pieceGrid.Children.Clear();
_pieceGrid.RemoveAllChildren();
_pieceGrid.Rows = boundingGrid.Height + 1;
_pieceGrid.Columns = boundingGrid.Width + 1;
for (var y = boundingGrid.Bottom; y <= boundingGrid.Top; y++)
Expand All @@ -275,18 +275,29 @@ public void BuildItemPieces()

if (_entity.TryGetComponent<ItemComponent>(itemEnt, out var itemEntComponent))
{
var gridPiece = new ItemGridPiece((itemEnt, itemEntComponent), itemPos, _entity)
ItemGridPiece gridPiece;

if (_storageController.CurrentlyDragging?.Entity is { } dragging
&& dragging == itemEnt)
{
_storageController.CurrentlyDragging.Orphan();
gridPiece = _storageController.CurrentlyDragging;
}
else
{
MinSize = size,
Marked = Array.IndexOf(containedEntities, itemEnt) switch
gridPiece = new ItemGridPiece((itemEnt, itemEntComponent), itemPos, _entity)
{
0 => ItemGridPieceMarks.First,
1 => ItemGridPieceMarks.Second,
_ => null,
}
};
gridPiece.OnPiecePressed += OnPiecePressed;
gridPiece.OnPieceUnpressed += OnPieceUnpressed;
MinSize = size,
Marked = Array.IndexOf(containedEntities, itemEnt) switch
{
0 => ItemGridPieceMarks.First,
1 => ItemGridPieceMarks.Second,
_ => null,
}
};
gridPiece.OnPiecePressed += OnPiecePressed;
gridPiece.OnPieceUnpressed += OnPieceUnpressed;
}

control.AddChild(gridPiece);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,16 @@ private void OnPieceUnpressed(GUIBoundKeyEventArgs args, ItemGridPiece control)
_entity.GetNetEntity(storageEnt)));
}

_menuDragHelper.EndDrag();
_container?.BuildItemPieces();
}
else //if we just clicked, then take it out of the bag.
{
_menuDragHelper.EndDrag();
_entity.RaisePredictiveEvent(new StorageInteractWithItemEvent(
_entity.GetNetEntity(control.Entity),
_entity.GetNetEntity(storageEnt)));
}
_menuDragHelper.EndDrag();
args.Handle();
}

Expand Down

0 comments on commit 0f73ebf

Please sign in to comment.