mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-14 04:07:31 +08:00
[+] Use the png jacket as bga
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using System.Text.RegularExpressions;
|
||||
using MelonLoader;
|
||||
|
||||
namespace AquaMai.UX
|
||||
{
|
||||
@@ -27,26 +26,49 @@ namespace AquaMai.UX
|
||||
}
|
||||
|
||||
var id = matches[0].Groups[1].Value;
|
||||
foreach (var ext in new[] { ".jpg", ".png", ".webp", ".bmp", ".gif" })
|
||||
{
|
||||
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext)))
|
||||
{
|
||||
filename = id + ext;
|
||||
}
|
||||
}
|
||||
|
||||
var localPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", filename);
|
||||
if (File.Exists(localPath))
|
||||
var texture = GetJacketTexture2D(id);
|
||||
if (texture is null)
|
||||
{
|
||||
__result = new Texture2D(1, 1);
|
||||
ImageConversion.LoadImage(__result, File.ReadAllBytes(localPath));
|
||||
__result = __instance.LoadAsset<Texture2D>($"Jacket/UI_Jacket_{id}.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = __instance.LoadAsset<Texture2D>($"Jacket/UI_Jacket_{id}.png");
|
||||
__result = texture;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string GetJacketPath(string id)
|
||||
{
|
||||
foreach (var ext in new[] { ".jpg", ".png", ".webp", ".bmp", ".gif" })
|
||||
{
|
||||
if (File.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext)))
|
||||
{
|
||||
return Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Texture2D GetJacketTexture2D(string id)
|
||||
{
|
||||
var path = GetJacketPath(id);
|
||||
if (path == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var texture = new Texture2D(1, 1);
|
||||
texture.LoadImage(File.ReadAllBytes(path));
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static Texture2D GetJacketTexture2D(int id)
|
||||
{
|
||||
return GetJacketTexture2D($"{id:000000}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user