[F] IconLoader

pull/88/head
Clansty 2024-11-22 00:59:25 +08:00
parent 9143b92932
commit 0e02dd660c
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
1 changed files with 74 additions and 78 deletions

View File

@ -24,7 +24,9 @@ public class LoadAssetsPng
private static Dictionary<string, string> framepatternPaths = new();
private static Dictionary<string, string> iconPaths = new();
private static Dictionary<string, string> charaPaths = new();
private static Dictionary<string, string> partnerPaths = new();
//private static Dictionary<string, string> navicharaPaths = new();
private static Dictionary<string, string> tabTitlePaths = new();
private static Dictionary<string, string> localAssetsContents = new();
@ -166,6 +168,7 @@ public class LoadAssetsPng
texture.LoadImage(File.ReadAllBytes(path));
return texture;
}
private static string GetPlatePath(string id)
{
return platePaths.GetValueOrDefault(id);
@ -219,6 +222,7 @@ public class LoadAssetsPng
texture.LoadImage(File.ReadAllBytes(path));
return texture;
}
private static string GetIconPath(string id)
{
return iconPaths.GetValueOrDefault(id);
@ -236,6 +240,7 @@ public class LoadAssetsPng
texture.LoadImage(File.ReadAllBytes(path));
return texture;
}
private static string GetCharaPath(string id)
{
return charaPaths.GetValueOrDefault(id);
@ -253,6 +258,7 @@ public class LoadAssetsPng
texture.LoadImage(File.ReadAllBytes(path));
return texture;
}
private static string GetPartnerPath(string id)
{
return partnerPaths.GetValueOrDefault(id);
@ -466,26 +472,17 @@ public class LoadAssetsPng
}
}
[HarmonyPatch]
public static class IconLoader
{
public static IEnumerable<MethodBase> TargetMethods()
{
var AM = typeof(AssetManager);
var method = AM.GetMethod("GetIconTexture2D", new[] { typeof(string) });
if (method != null)
{
yield return method;
}
}
public static bool Prefix(string filename, ref Texture2D __result, AssetManager __instance)
// Private | Instance
[HarmonyPrefix]
[HarmonyPatch(typeof(AssetManager), "GetIconTexture2D", typeof(string))]
public static bool IconLoader(string filename, ref Texture2D __result, AssetManager __instance)
{
var matches = Regex.Matches(filename, @"UI_Icon_(\d+)\.png");
if (matches.Count < 1)
{
return true;
}
MelonLogger.Msg(filename);
var id = matches[0].Groups[1].Value;
@ -494,7 +491,6 @@ public class LoadAssetsPng
return false;
}
}
[HarmonyPatch]
public static class CharaLoader