From 97d7e0a10d7ff1c2a6ace6cec0db67a2077394c3 Mon Sep 17 00:00:00 2001 From: MattEqualsCoder Date: Sun, 22 Sep 2024 21:58:46 -0400 Subject: [PATCH] Added changes for keysanity minimal ui --- .../Configuration/ConfigTypes/UIGridLocation.cs | 5 +++++ .../Services/TrackerWindowService.cs | 5 +++++ .../ViewModels/TrackerWindowItemPanelViewModel.cs | 15 +++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/TrackerCouncil.Smz3.Data/Configuration/ConfigTypes/UIGridLocation.cs b/src/TrackerCouncil.Smz3.Data/Configuration/ConfigTypes/UIGridLocation.cs index 38f049ced..8ed3ef4ba 100644 --- a/src/TrackerCouncil.Smz3.Data/Configuration/ConfigTypes/UIGridLocation.cs +++ b/src/TrackerCouncil.Smz3.Data/Configuration/ConfigTypes/UIGridLocation.cs @@ -39,4 +39,9 @@ public UIGridLocation() { } /// Collection of object identifiers to look up for this location /// public ICollection Identifiers { get; set; } = new List(); + + /// + /// Map of identifier to images to use + /// + public Dictionary ReplacementImages { get; set; } = new(); } diff --git a/src/TrackerCouncil.Smz3.UI/Services/TrackerWindowService.cs b/src/TrackerCouncil.Smz3.UI/Services/TrackerWindowService.cs index f5997327d..75840df61 100644 --- a/src/TrackerCouncil.Smz3.UI/Services/TrackerWindowService.cs +++ b/src/TrackerCouncil.Smz3.UI/Services/TrackerWindowService.cs @@ -573,9 +573,14 @@ private TrackerWindowPanelViewModel GetItemPanelViewModel(UIGridLocation gridLoc items[item] = fileName; } + var replacementImages = + gridLocation.ReplacementImages.ToDictionary(x => x.Key, + x => uiService.GetSpritePath("Items", x.Value, out _)); + var model = new TrackerWindowItemPanelViewModel() { Items = items, + ItemReplacementImages = replacementImages, ConnectedItems = connectedItems, LabelImage = labelImage, IsLabelActive = items.Keys.Any(x => x.State.TrackingState > 0), diff --git a/src/TrackerCouncil.Smz3.UI/ViewModels/TrackerWindowItemPanelViewModel.cs b/src/TrackerCouncil.Smz3.UI/ViewModels/TrackerWindowItemPanelViewModel.cs index a2d7459b3..a287184af 100644 --- a/src/TrackerCouncil.Smz3.UI/ViewModels/TrackerWindowItemPanelViewModel.cs +++ b/src/TrackerCouncil.Smz3.UI/ViewModels/TrackerWindowItemPanelViewModel.cs @@ -34,6 +34,8 @@ public class TrackerWindowItemPanelViewModel : TrackerWindowPanelViewModel public Dictionary? Items { get; set; } + public Dictionary ItemReplacementImages { get; set; } = []; + public List? ConnectedItems { get; set; } [Reactive] public int ItemCount { get; set; } @@ -59,7 +61,7 @@ public void UpdateItem(Item? item, string? path) if (Items != null && item != null && !string.IsNullOrEmpty(path)) { var key = Items.Keys.First(x => x.Type == item.Type); - Items[key] = path; + Items[key] = GetItemPath(item, path); } if (ConnectedItems != null) @@ -95,7 +97,7 @@ public override List GetMainImages() images.Add(new TrackerWindowPanelImage { - ImagePath = item.Value, + ImagePath = GetItemPath(item.Key ,item.Value), IsActive = isActive }); @@ -200,4 +202,13 @@ public override List GetMenuItems() return menuItems; } + + private string GetItemPath(Item item, string desiredPath) + { + if (ItemReplacementImages.TryGetValue(item.Name, out var replacementImage)) + { + return replacementImage ?? desiredPath; + } + return desiredPath; + } }