Fix multiselect refreshing to parent context

This commit is contained in:
Tyfon
2024-07-16 00:59:35 -07:00
parent e731a4fec4
commit a35c0f1084
4 changed files with 13 additions and 7 deletions

View File

@@ -162,7 +162,10 @@ public class MultiSelect
if (oldItemContext != null)
{
MultiSelectItemContext newContext = oldItemContext.Refresh();
if (newContext != null)
{
SelectedItems.Add(newContext, SelectedItems[oldItemContext]);
}
SelectedItems.Remove(oldItemContext);
oldItemContext.Dispose();
@@ -462,10 +465,15 @@ public class MultiSelectItemContext : DragItemContext
}
public MultiSelectItemContext Refresh()
{
if (Item == ItemContextAbstractClass.Item)
{
return new MultiSelectItemContext(ItemContextAbstractClass, ItemRotation);
}
return null;
}
public void UpdateDragContext(DragItemContext itemContext)
{
SetPosition(itemContext.CursorPosition, itemContext.ItemPosition);

View File

@@ -66,9 +66,7 @@ public class MultiSelectDebug : MonoBehaviour
}
ItemAddress address = itemContext is DragItemContext dragItemContext ? dragItemContext.ItemAddress : itemContext.Item.CurrentAddress;
LocationInGrid location = address is GridItemAddress gridAddress ?
itemContext is MultiSelectItemContext ? MultiGrid.GetGridLocation(gridAddress) : gridAddress.LocationInGrid :
null;
LocationInGrid location = address is GridItemAddress gridAddress ? gridAddress.LocationInGrid : null;
string locationString = location != null ? $"({location.x}, {location.y})" : "(slot)";
return $"x{itemContext.Item.StackObjectsCount} {address.Container.ID} {locationString} {itemContext.Item.Name.Localized()}";

View File

@@ -4,7 +4,7 @@
<TargetFramework>net471</TargetFramework>
<AssemblyName>Tyfon.UIFixes</AssemblyName>
<Description>SPT UI Fixes</Description>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Configurations>Debug;Release</Configurations>

View File

@@ -1,6 +1,6 @@
{
"name": "uifixes",
"version": "2.2.0",
"version": "2.2.1",
"main": "src/mod.js",
"license": "MIT",
"author": "Tyfon",