mirror of
https://github.com/kwsch/NHSE.git
synced 2026-07-19 00:31:38 -05:00
parent
ab3afc23a8
commit
37176b5a1a
|
|
@ -14,7 +14,8 @@ public static class ItemSprite
|
|||
|
||||
public static void Initialize(string path, string[] itemNames)
|
||||
{
|
||||
if (FileLookup.Count > 0)
|
||||
var lookup = FileLookup;
|
||||
if (lookup.Count > 0)
|
||||
return;
|
||||
|
||||
ItemNames = itemNames;
|
||||
|
|
@ -25,7 +26,14 @@ public static void Initialize(string path, string[] itemNames)
|
|||
var fn = Path.GetFileNameWithoutExtension(f);
|
||||
if (fn == null)
|
||||
continue;
|
||||
FileLookup.Add(fn.ToLower(), f);
|
||||
lookup[fn.ToLower()] = f;
|
||||
var index = fn.IndexOf('(');
|
||||
if (index < 0)
|
||||
continue;
|
||||
|
||||
var simplerName = fn.Substring(0, index - 1);
|
||||
if (!lookup.ContainsKey(simplerName))
|
||||
lookup.Add(simplerName, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +86,15 @@ private static bool GetItemImageSprite(ushort id, out string? path)
|
|||
}
|
||||
|
||||
var name = str[id].ToLower();
|
||||
return FileLookup.TryGetValue(name, out path);
|
||||
if (FileLookup.TryGetValue(name, out path))
|
||||
return true;
|
||||
|
||||
var index = name.IndexOf('(');
|
||||
if (index <= 0)
|
||||
return false;
|
||||
|
||||
var simple = name.Substring(0, index - 1);
|
||||
return FileLookup.TryGetValue(simple, out path);
|
||||
}
|
||||
|
||||
public static Bitmap? GetImage(Item item, Font font, int width, int height)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user