]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix orphaned storage grid pieces getting stuck to the cursor (#27960)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 17 May 2024 07:51:28 +0000 (03:51 -0400)
committerGitHub <noreply@github.com>
Fri, 17 May 2024 07:51:28 +0000 (00:51 -0700)
* fix orphaned storage grid pieces getting stuck to the cursor

* instead of denying it, update it smartly

Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs
Content.Client/UserInterface/Systems/Storage/StorageUIController.cs

index e39ac5d322d39e637939f8c6c155e7ea17562c39..a9d7e098265a5893bc327810e3f116ac3ffcb567 100644 (file)
@@ -254,7 +254,7 @@ public sealed class StorageContainer : BaseWindow
 
         //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++)
@@ -275,18 +275,29 @@ public sealed class StorageContainer : BaseWindow
 
                     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);
                     }
index 346469d29dab6012f20c8829e419132018e0363b..97c9d8b7959976331faae5b12841cf3042120e5b 100644 (file)
@@ -314,15 +314,16 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
                     _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();
     }