fix rotation of multiselect dragged item
This commit is contained in:
@@ -135,6 +135,11 @@ namespace UIFixes
|
||||
|
||||
public static void OnNewItemView(GridItemView itemView)
|
||||
{
|
||||
if (!itemView.IsSelectable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MultiSelectItemContext itemContext = SelectedItems.FirstOrDefault(x => x.Key.Item == itemView.Item).Key;
|
||||
if (itemContext != null)
|
||||
{
|
||||
@@ -233,7 +238,7 @@ namespace UIFixes
|
||||
MultiSelectItemContext multiSelectItemContext = SelectedItems.Keys.FirstOrDefault(c => c.Item == first.Item);
|
||||
if (multiSelectItemContext != null)
|
||||
{
|
||||
multiSelectItemContext.SetPosition(first.CursorPosition, first.ItemPosition);
|
||||
multiSelectItemContext.UpdateDragContext(first);
|
||||
return result.Prepend(multiSelectItemContext);
|
||||
}
|
||||
}
|
||||
@@ -461,6 +466,12 @@ namespace UIFixes
|
||||
return new MultiSelectItemContext(ItemContextAbstractClass, ItemRotation);
|
||||
}
|
||||
|
||||
public void UpdateDragContext(ItemContextClass itemContext)
|
||||
{
|
||||
SetPosition(itemContext.CursorPosition, itemContext.ItemPosition);
|
||||
ItemRotation = itemContext.ItemRotation;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
@@ -38,9 +38,9 @@ namespace UIFixes
|
||||
{
|
||||
LocationInGrid location = itemContext.ItemAddress is ItemAddressClass gridAddress ? MultiGrid.GetGridLocation(gridAddress) : null;
|
||||
builder.AppendFormat("x{0} {1} {2} {3}\n",
|
||||
itemContext.Item.StackObjectsCount,
|
||||
itemContext.ItemAddress.ContainerName,
|
||||
location != null ? $"({location.x}, {location.y})" : "slot",
|
||||
itemContext.Item.StackObjectsCount,
|
||||
itemContext.ItemAddress.Container.ID,
|
||||
location != null ? $"({location.x}, {location.y})" : "(slot)",
|
||||
itemContext.Item.Name.Localized());
|
||||
}
|
||||
|
||||
|
@@ -366,18 +366,18 @@ namespace UIFixes
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(GridItemView), nameof(GridItemView.Init));
|
||||
return AccessTools.Method(typeof(ItemView), nameof(ItemView.Init));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(GridItemView __instance)
|
||||
public static void Postfix(ItemView __instance)
|
||||
{
|
||||
if (!MultiSelect.Active)
|
||||
if (!MultiSelect.Active || __instance is not GridItemView gridItemView)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MultiSelect.OnNewItemView(__instance);
|
||||
MultiSelect.OnNewItemView(gridItemView);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net471</TargetFramework>
|
||||
<AssemblyName>Tyfon.UIFixes</AssemblyName>
|
||||
<Description>SPT UI Fixes</Description>
|
||||
<Version>2.0.3</Version>
|
||||
<Version>2.0.4</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Configurations>Debug;Release;Dist</Configurations>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uifixes",
|
||||
"version": "2.0.3",
|
||||
"version": "2.0.4",
|
||||
"main": "src/mod.js",
|
||||
"license": "MIT",
|
||||
"author": "Tyfon",
|
||||
|
Reference in New Issue
Block a user