Skip to content

Commit

Permalink
Merge pull request #576 from TheTrackerCouncil/keysanity-minimal-ui
Browse files Browse the repository at this point in the history
Added changes for keysanity minimal ui
  • Loading branch information
MattEqualsCoder authored Sep 23, 2024
2 parents d1fa1cc + 97d7e0a commit a477c0d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public UIGridLocation() { }
/// Collection of object identifiers to look up for this location
/// </summary>
public ICollection<string> Identifiers { get; set; } = new List<string>();

/// <summary>
/// Map of identifier to images to use
/// </summary>
public Dictionary<string, string> ReplacementImages { get; set; } = new();
}
5 changes: 5 additions & 0 deletions src/TrackerCouncil.Smz3.UI/Services/TrackerWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class TrackerWindowItemPanelViewModel : TrackerWindowPanelViewModel

public Dictionary<Item, string>? Items { get; set; }

public Dictionary<string, string?> ItemReplacementImages { get; set; } = [];

public List<Item>? ConnectedItems { get; set; }

[Reactive] public int ItemCount { get; set; }
Expand All @@ -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)
Expand Down Expand Up @@ -95,7 +97,7 @@ public override List<TrackerWindowPanelImage> GetMainImages()

images.Add(new TrackerWindowPanelImage
{
ImagePath = item.Value,
ImagePath = GetItemPath(item.Key ,item.Value),
IsActive = isActive
});

Expand Down Expand Up @@ -200,4 +202,13 @@ public override List<MenuItem> GetMenuItems()

return menuItems;
}

private string GetItemPath(Item item, string desiredPath)
{
if (ItemReplacementImages.TryGetValue(item.Name, out var replacementImage))
{
return replacementImage ?? desiredPath;
}
return desiredPath;
}
}

0 comments on commit a477c0d

Please sign in to comment.