Merge branch 'v1-dev' of https://github.com/hykilpikonna/AquaDX into v1-dev

This commit is contained in:
Azalea
2024-11-21 12:12:09 -05:00
2 changed files with 76 additions and 80 deletions

View File

@@ -68,7 +68,7 @@ public class BasicFix
ServicePointManager.ServerCertificateValidationCallback = null; ServicePointManager.ServerCertificateValidationCallback = null;
} }
[HarmonyPostfix] [HarmonyPrefix]
[HarmonyPatch(typeof(MAI2System.Config), "IsTarget", MethodType.Getter)] [HarmonyPatch(typeof(MAI2System.Config), "IsTarget", MethodType.Getter)]
private static bool ForceNonTarget(ref bool __result) private static bool ForceNonTarget(ref bool __result)
{ {
@@ -77,7 +77,7 @@ public class BasicFix
return false; return false;
} }
[HarmonyPostfix] [HarmonyPrefix]
[HarmonyPatch(typeof(MAI2System.Config), "IsIgnoreError", MethodType.Getter)] [HarmonyPatch(typeof(MAI2System.Config), "IsIgnoreError", MethodType.Getter)]
private static bool ForceIgnoreError(ref bool __result) private static bool ForceIgnoreError(ref bool __result)
{ {

View File

@@ -17,14 +17,16 @@ namespace AquaMai.UX;
public class LoadAssetsPng public class LoadAssetsPng
{ {
private static string[] imageExts = [".jpg", ".png", ".jpeg"]; private static string[] imageExts = [".jpg", ".png", ".jpeg"];
private static Dictionary<string, string> jacketPaths = new(); private static Dictionary<string, string> jacketPaths = new();
private static Dictionary<string, string> framePaths = new(); private static Dictionary<string, string> framePaths = new();
private static Dictionary<string, string> platePaths = new(); private static Dictionary<string, string> platePaths = new();
private static Dictionary<string, string> framemaskPaths = new(); private static Dictionary<string, string> framemaskPaths = new();
private static Dictionary<string, string> framepatternPaths = new(); private static Dictionary<string, string> framepatternPaths = new();
private static Dictionary<string, string> iconPaths = new(); private static Dictionary<string, string> iconPaths = new();
private static Dictionary<string, string> charaPaths = new(); private static Dictionary<string, string> charaPaths = new();
private static Dictionary<string, string> partnerPaths = new();
private static Dictionary<string, string> partnerPaths = new();
//private static Dictionary<string, string> navicharaPaths = new(); //private static Dictionary<string, string> navicharaPaths = new();
private static Dictionary<string, string> tabTitlePaths = new(); private static Dictionary<string, string> tabTitlePaths = new();
private static Dictionary<string, string> localAssetsContents = new(); private static Dictionary<string, string> localAssetsContents = new();
@@ -41,24 +43,24 @@ public class LoadAssetsPng
if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
var idStr = Path.GetFileName(file).Substring("ui_jacket_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_jacket_".Length, 6);
jacketPaths[idStr] = file; jacketPaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\frame"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\frame")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\frame"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\frame")))
{ {
if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
var idStr = Path.GetFileName(file).Substring("ui_frame_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_frame_".Length, 6);
framePaths[idStr] = file; framePaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\nameplate"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\nameplate")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\nameplate"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\nameplate")))
{ {
if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
var idStr = Path.GetFileName(file).Substring("ui_plate_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_plate_".Length, 6);
platePaths[idStr] = file; platePaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framemask"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framemask")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framemask"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framemask")))
{ {
@@ -66,7 +68,7 @@ public class LoadAssetsPng
var idStr = Path.GetFileName(file).Substring("ui_framemask_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_framemask_".Length, 6);
framemaskPaths[idStr] = file; framemaskPaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framepattern"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framepattern")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framepattern"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framepattern")))
{ {
@@ -74,7 +76,7 @@ public class LoadAssetsPng
var idStr = Path.GetFileName(file).Substring("ui_framepattern_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_framepattern_".Length, 6);
framepatternPaths[idStr] = file; framepatternPaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\icon"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\icon")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\icon"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\icon")))
{ {
@@ -82,30 +84,30 @@ public class LoadAssetsPng
var idStr = Path.GetFileName(file).Substring("ui_icon_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_icon_".Length, 6);
iconPaths[idStr] = file; iconPaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\chara"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\chara")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\chara"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\chara")))
{ {
if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
var idStr = Path.GetFileName(file).Substring("ui_chara_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_chara_".Length, 6);
charaPaths[idStr] = file; charaPaths[idStr] = file;
} }
if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\partner"))) if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\partner")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\partner"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\partner")))
{ {
if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
var idStr = Path.GetFileName(file).Substring("ui_Partner_".Length, 6); var idStr = Path.GetFileName(file).Substring("ui_Partner_".Length, 6);
partnerPaths[idStr] = file; partnerPaths[idStr] = file;
} }
//if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_21"))) //if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_21")))
// foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_", charaid))) // foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_", charaid)))
//{ //{
// if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; // if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue;
//var idStr = Path.GetFileName(file).Substring("ui_navichara_".Length, 6); //var idStr = Path.GetFileName(file).Substring("ui_navichara_".Length, 6);
// navicharaPaths[idStr] = file; // navicharaPaths[idStr] = file;
// } // }
if (Directory.Exists(Path.Combine(aDir, @"Common\Sprites\Tab\Title"))) if (Directory.Exists(Path.Combine(aDir, @"Common\Sprites\Tab\Title")))
foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"Common\Sprites\Tab\Title"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"Common\Sprites\Tab\Title")))
{ {
@@ -147,8 +149,8 @@ public class LoadAssetsPng
public static Texture2D GetJacketTexture2D(int id) public static Texture2D GetJacketTexture2D(int id)
{ {
return GetJacketTexture2D($"{id:000000}"); return GetJacketTexture2D($"{id:000000}");
} }
private static string GetFramePath(string id) private static string GetFramePath(string id)
{ {
return framePaths.GetValueOrDefault(id); return framePaths.GetValueOrDefault(id);
@@ -165,7 +167,8 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetPlatePath(string id) private static string GetPlatePath(string id)
{ {
return platePaths.GetValueOrDefault(id); return platePaths.GetValueOrDefault(id);
@@ -182,8 +185,8 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetFrameMaskPath(string id) private static string GetFrameMaskPath(string id)
{ {
return framemaskPaths.GetValueOrDefault(id); return framemaskPaths.GetValueOrDefault(id);
@@ -200,8 +203,8 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetFramePatternPath(string id) private static string GetFramePatternPath(string id)
{ {
return framepatternPaths.GetValueOrDefault(id); return framepatternPaths.GetValueOrDefault(id);
@@ -218,7 +221,8 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetIconPath(string id) private static string GetIconPath(string id)
{ {
return iconPaths.GetValueOrDefault(id); return iconPaths.GetValueOrDefault(id);
@@ -235,7 +239,8 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetCharaPath(string id) private static string GetCharaPath(string id)
{ {
return charaPaths.GetValueOrDefault(id); return charaPaths.GetValueOrDefault(id);
@@ -252,12 +257,13 @@ public class LoadAssetsPng
var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false);
texture.LoadImage(File.ReadAllBytes(path)); texture.LoadImage(File.ReadAllBytes(path));
return texture; return texture;
} }
private static string GetPartnerPath(string id) private static string GetPartnerPath(string id)
{ {
return partnerPaths.GetValueOrDefault(id); return partnerPaths.GetValueOrDefault(id);
} }
public static Texture2D GetPartnerTexture2D(string id) public static Texture2D GetPartnerTexture2D(string id)
{ {
var path = GetPartnerPath(id); var path = GetPartnerPath(id);
@@ -360,8 +366,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] [HarmonyPatch]
public static class FrameLoader public static class FrameLoader
{ {
@@ -386,8 +392,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] [HarmonyPatch]
public static class PlateLoader public static class PlateLoader
{ {
@@ -412,8 +418,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] [HarmonyPatch]
public static class FrameMaskLoader public static class FrameMaskLoader
{ {
@@ -438,8 +444,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] [HarmonyPatch]
public static class FramePatternLoader public static class FramePatternLoader
{ {
@@ -464,38 +470,28 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] // Private | Instance
public static class IconLoader [HarmonyPrefix]
[HarmonyPatch(typeof(AssetManager), "GetIconTexture2D", typeof(string))]
public static bool IconLoader(string filename, ref Texture2D __result, AssetManager __instance)
{ {
public static IEnumerable<MethodBase> TargetMethods() var matches = Regex.Matches(filename, @"UI_Icon_(\d+)\.png");
if (matches.Count < 1)
{ {
var AM = typeof(AssetManager); return true;
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) MelonLogger.Msg(filename);
{ var id = matches[0].Groups[1].Value;
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;
var texture = GetIconTexture2D(id); var texture = GetIconTexture2D(id);
__result = texture ?? __instance.LoadAsset<Texture2D>($"Icon/UI_Icon_{id}.png"); __result = texture ?? __instance.LoadAsset<Texture2D>($"Icon/UI_Icon_{id}.png");
return false;
}
return false;
}
}
[HarmonyPatch] [HarmonyPatch]
public static class CharaLoader public static class CharaLoader
{ {
@@ -520,8 +516,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
[HarmonyPatch] [HarmonyPatch]
public static class PartnerLoader public static class PartnerLoader
{ {
@@ -546,8 +542,8 @@ public class LoadAssetsPng
return false; return false;
} }
} }
/* /*
[HarmonyPatch] [HarmonyPatch]
public static class FrameLoader public static class FrameLoader
{ {
@@ -574,4 +570,4 @@ public class LoadAssetsPng
} }
} }
*/ */
} }