From 56094938f4962841f6d8a6c0b4ef3eeb0b69c4ff Mon Sep 17 00:00:00 2001 From: riperiperi Date: Tue, 4 Oct 2022 23:28:38 +0100 Subject: [PATCH] Correct inventory index when using search. --- TSOClient/tso.client/UI/Panels/UIBuyMode.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/TSOClient/tso.client/UI/Panels/UIBuyMode.cs b/TSOClient/tso.client/UI/Panels/UIBuyMode.cs index ccf029a74..9fa38e0ae 100644 --- a/TSOClient/tso.client/UI/Panels/UIBuyMode.cs +++ b/TSOClient/tso.client/UI/Panels/UIBuyMode.cs @@ -212,6 +212,7 @@ public override void Update(UpdateState state) CurrentInventory.Add(new UICatalogElement { Item = obj, Attributes = item.Attributes ?? new List(), + Tag = item.ObjectPID, Count = (item.AttributeMode == 2 && (item.Attributes?.Count ?? 0) > 0) ? item.Attributes[0] : (int?)null }); } @@ -253,6 +254,12 @@ override protected void Catalog_OnSelectionChange(int selection) { if (selection < LastInventory.Count && Holder.Holding != null) { + if (Catalog.Filtered != Catalog.Selected) + { + var selTag = Catalog.Filtered[selection].Tag; + selection = Catalog.Selected.FindIndex(elem => elem.Tag == selTag); + } + Holder.Holding.InventoryPID = LastInventory[selection].ObjectPID; Holder.Holding.Price = 0; }