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