Skip to content

Commit

Permalink
filter skins in favs that dont exist anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
PrashantMohta committed Jul 29, 2024
1 parent 9d0e0b1 commit d4e9e48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CustomKnight/NewUI/UIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ public static void CreateUpdateGUI()
var favSkins = new List<string>();
favSkins.AddRange(CustomKnight.GlobalSettings.FavoriteSkins);
favSkins.AddRange(CustomKnight.GlobalSettings.RecentSkins);
favSkins = favSkins.Distinct().ToList();
for (var index = 0; favSkins.Count < Math.Min(CustomKnight.GlobalSettings.MaxSkinCache, SkinManager.SkinsList.Count); index++)
{
var id = SkinManager.SkinsList[index].GetId();
Expand All @@ -229,6 +228,10 @@ public static void CreateUpdateGUI()
}
foreach (var skinId in favSkins)
{
if (!SkinManager.SkinExistsById(skinId))
{
continue;
}
var skin = SkinManager.GetSkinById(skinId);
var tex = GetSkinIcon(skin);
var skinName = skin.GetName();
Expand Down
10 changes: 10 additions & 0 deletions CustomKnight/Skin/Base/SkinManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ public static bool AddSkin(ISelectableSkin NewSkin)
return !Exists;
}

/// <summary>
/// Checks if a skin from the overall skin list exists that matches a given id.
/// </summary>
/// <param name="id"></param>
/// <returns> true if exists </returns>
public static bool SkinExistsById(string id)
{
return SkinManager.SkinsList.Exists(skin => skin.GetId() == id);
}

/// <summary>
/// Gets a skin from the overall skin list that matches a given id.
/// </summary>
Expand Down

0 comments on commit d4e9e48

Please sign in to comment.