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:
Tyfon
2024-07-13 15:54:28 -07:00
parent 1170037614
commit 0277490e8a
4 changed files with 91 additions and 10 deletions

View File

@@ -1,5 +1,7 @@
using System.Linq;
using System.Text;
using EFT.InventoryLogic;
using EFT.UI;
using UnityEngine;
namespace UIFixes;
@@ -32,22 +34,18 @@ public class MultiSelectDebug : MonoBehaviour
builder.Append("<b>MultiSelect</b>\n");
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);
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("x{0} {1} {2} {3}\n",
itemContext.Item.StackObjectsCount,
itemContext.ItemAddress.Container.ID,
location != null ? $"({location.x}, {location.y})" : "(slot)",
itemContext.Item.Name.Localized());
builder.AppendFormat("{0}\n", FormatItemContext(itemContext));
}
if (MultiSelect.SecondaryContexts.Any())
{
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());
}
@@ -59,4 +57,20 @@ public class MultiSelectDebug : MonoBehaviour
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()}";
}
}