Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
disallow naming collisions to block icon loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed Sep 12, 2016
1 parent 315f7e5 commit 1937caf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions FilterExtension/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,27 @@ private void checkAndMarkConflicts()
/// </summary>
private static void loadIcons()
{
GameDatabase.TextureInfo[] texArray = GameDatabase.Instance.databaseTexture.Where(t => t.texture != null && t.texture.height == 32 && t.texture.width == 32).ToArray();
Dictionary<string, GameDatabase.TextureInfo> texDict = texArray.ToDictionary(k => k.name);

GameDatabase.TextureInfo texInfo = null;
Texture2D selectedTex = null;
foreach (GameDatabase.TextureInfo t in texArray)
Dictionary<string, GameDatabase.TextureInfo> texDict = new Dictionary<string, GameDatabase.TextureInfo>();
for (int i = GameDatabase.Instance.databaseTexture.Count - 1; i >= 0; --i)
{
texInfo = GameDatabase.Instance.databaseTexture[i];
if (texInfo.texture != null && texInfo.texture.width == 32 && texInfo.texture.height == 32)
{
texDict.TryAdd(texInfo.name, texInfo);
}
}

foreach (KeyValuePair<string, GameDatabase.TextureInfo> kvp in texDict)
{
GameDatabase.TextureInfo texInfo;
if (texDict.TryGetValue(t.name + "_selected", out texInfo))
if (texDict.TryGetValue(kvp.Value.name + "_selected", out texInfo))
selectedTex = texInfo.texture;
else
selectedTex = t.texture;
selectedTex = kvp.Value.texture;

string name = t.name.Split(new char[] { '/', '\\' }).Last();
RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon(name, t.texture, selectedTex, false);
string name = kvp.Value.name.Split(new char[] { '/', '\\' }).Last();
RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon(name, kvp.Value.texture, selectedTex, false);
Instance.iconDict.TryAdd(icon.name, icon);
}
}
Expand Down
Binary file modified GameData/000_FilterExtensions/FilterExtensions.dll
Binary file not shown.

0 comments on commit 1937caf

Please sign in to comment.