fix bsg bug that loses context on search, fixing multiselect drawing when mouse starts over unsearched item that becomes searched
This commit is contained in:
1
.vscode/tasks.json
vendored
1
.vscode/tasks.json
vendored
@@ -13,6 +13,7 @@
|
|||||||
"presentation": {
|
"presentation": {
|
||||||
"echo": true,
|
"echo": true,
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
|
"revealProblems": "onProblem",
|
||||||
"focus": false,
|
"focus": false,
|
||||||
"panel": "shared",
|
"panel": "shared",
|
||||||
"showReuseMessage": false,
|
"showReuseMessage": false,
|
||||||
|
@@ -196,12 +196,12 @@ public class MultiSelect
|
|||||||
SecondaryItems.Clear();
|
SecondaryItems.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<DragItemContext> ItemContexts
|
public static IEnumerable<MultiSelectItemContext> ItemContexts
|
||||||
{
|
{
|
||||||
get { return SelectedItems.Keys; }
|
get { return SelectedItems.Keys; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<DragItemContext> SecondaryContexts
|
public static IEnumerable<MultiSelectItemContext> SecondaryContexts
|
||||||
{
|
{
|
||||||
get { return SecondaryItems.Keys; }
|
get { return SecondaryItems.Keys; }
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using EFT.InventoryLogic;
|
||||||
|
using EFT.UI;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UIFixes;
|
namespace UIFixes;
|
||||||
@@ -32,22 +34,18 @@ public class MultiSelectDebug : MonoBehaviour
|
|||||||
|
|
||||||
builder.Append("<b>MultiSelect</b>\n");
|
builder.Append("<b>MultiSelect</b>\n");
|
||||||
builder.AppendFormat("Active: <color={0}>{1}</color>\n", MultiSelect.Active ? "green" : "red", MultiSelect.Active);
|
builder.AppendFormat("Active: <color={0}>{1}</color>\n", MultiSelect.Active ? "green" : "red", MultiSelect.Active);
|
||||||
|
builder.AppendFormat("Hovered: <color=aqua>{0}</color>\n", FormatItemContext(ItemUiContext.Instance.R().ItemContext));
|
||||||
builder.AppendFormat("Items: <color=yellow>{0}</color>\n", MultiSelect.Count);
|
builder.AppendFormat("Items: <color=yellow>{0}</color>\n", MultiSelect.Count);
|
||||||
|
|
||||||
foreach (DragItemContext itemContext in MultiSelect.SortedItemContexts())
|
foreach (MultiSelectItemContext itemContext in MultiSelect.SortedItemContexts())
|
||||||
{
|
{
|
||||||
LocationInGrid location = itemContext.ItemAddress is GridItemAddress gridAddress ? MultiGrid.GetGridLocation(gridAddress) : null;
|
builder.AppendFormat("{0}\n", FormatItemContext(itemContext));
|
||||||
builder.AppendFormat("x{0} {1} {2} {3}\n",
|
|
||||||
itemContext.Item.StackObjectsCount,
|
|
||||||
itemContext.ItemAddress.Container.ID,
|
|
||||||
location != null ? $"({location.x}, {location.y})" : "(slot)",
|
|
||||||
itemContext.Item.Name.Localized());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiSelect.SecondaryContexts.Any())
|
if (MultiSelect.SecondaryContexts.Any())
|
||||||
{
|
{
|
||||||
builder.AppendFormat("Secondary Items: <color=yellow>{0}</color>\n", MultiSelect.SecondaryCount);
|
builder.AppendFormat("Secondary Items: <color=yellow>{0}</color>\n", MultiSelect.SecondaryCount);
|
||||||
foreach (DragItemContext itemContext in MultiSelect.SecondaryContexts)
|
foreach (MultiSelectItemContext itemContext in MultiSelect.SecondaryContexts)
|
||||||
{
|
{
|
||||||
builder.AppendFormat("x{0} {1}\n", itemContext.Item.StackObjectsCount, itemContext.Item.ToString());
|
builder.AppendFormat("x{0} {1}\n", itemContext.Item.StackObjectsCount, itemContext.Item.ToString());
|
||||||
}
|
}
|
||||||
@@ -59,4 +57,20 @@ public class MultiSelectDebug : MonoBehaviour
|
|||||||
|
|
||||||
GUI.Box(guiRect, guiContent, guiStyle);
|
GUI.Box(guiRect, guiContent, guiStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FormatItemContext(ItemContextAbstractClass itemContext)
|
||||||
|
{
|
||||||
|
if (itemContext == null)
|
||||||
|
{
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
string locationString = location != null ? $"({location.x}, {location.y})" : "(slot)";
|
||||||
|
|
||||||
|
return $"x{itemContext.Item.StackObjectsCount} {address.Container.ID} {locationString} {itemContext.Item.Name.Localized()}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ public static class MultiSelectPatches
|
|||||||
// Workarounds
|
// Workarounds
|
||||||
new DisableSplitPatch().Enable();
|
new DisableSplitPatch().Enable();
|
||||||
new DisableSplitTargetPatch().Enable();
|
new DisableSplitTargetPatch().Enable();
|
||||||
|
new FixSearchedContextPatch().Enable();
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
new ItemViewClickPatch().Enable();
|
new ItemViewClickPatch().Enable();
|
||||||
@@ -425,6 +426,71 @@ public static class MultiSelectPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FixSearchedContextPatch : ModulePatch
|
||||||
|
{
|
||||||
|
private static string CurrentContextSearchingId = null;
|
||||||
|
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(GridView), nameof(GridView.OnItemAdded));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static void Prefix(GridView __instance, GEventArgs2 eventArgs, TraderControllerClass ___traderControllerClass, ItemUiContext ___itemUiContext_0)
|
||||||
|
{
|
||||||
|
if (eventArgs.To.Container != __instance.Grid || eventArgs.Status != CommandStatus.Begin)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Item item = eventArgs.Item;
|
||||||
|
if (___itemUiContext_0.ItemContextAbstractClass?.Item != eventArgs.Item)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationInGrid locationInGrid = ((GridItemAddress)eventArgs.To).LocationInGrid;
|
||||||
|
|
||||||
|
bool searchable = !(___traderControllerClass != null && ___traderControllerClass.CanSearch && ___traderControllerClass.ID != eventArgs.OwnerId);
|
||||||
|
if (!searchable || !locationInGrid.isSearched)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemView itemView = __instance.method_9(item, iv => !iv.IsSearched);
|
||||||
|
if (itemView != null)
|
||||||
|
{
|
||||||
|
CurrentContextSearchingId = item.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(GridView __instance, GEventArgs2 eventArgs, ItemUiContext ___itemUiContext_0, Dictionary<string, ItemView> ___dictionary_0)
|
||||||
|
{
|
||||||
|
if (eventArgs.To.Container != __instance.Grid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CurrentContextSearchingId == eventArgs.Item.Id)
|
||||||
|
{
|
||||||
|
if (eventArgs.Status == CommandStatus.Succeed)
|
||||||
|
{
|
||||||
|
if (___dictionary_0.TryGetValue(eventArgs.Item.Id, out ItemView itemView))
|
||||||
|
{
|
||||||
|
___itemUiContext_0.RegisterCurrentItemContext(itemView.ItemContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentContextSearchingId = null;
|
||||||
|
}
|
||||||
|
else if (eventArgs.Status == CommandStatus.Failed)
|
||||||
|
{
|
||||||
|
CurrentContextSearchingId = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class GridViewCanAcceptPatch : ModulePatch
|
public class GridViewCanAcceptPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
|
Reference in New Issue
Block a user