diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index e0ae62e0..fabd9e6c 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -338,6 +338,7 @@ DEBUG + diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 935a0c88..a94cab76 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -164,6 +164,7 @@ namespace AquaMai Patch(typeof(CustomVersionString)); Patch(typeof(CustomPlaceName)); Patch(typeof(RunCommandOnEvents)); + Patch(typeof(CustomLogo)); // Utils Patch(typeof(JudgeAdjust)); # if DEBUG diff --git a/AquaMai/UX/CustomLogo.cs b/AquaMai/UX/CustomLogo.cs new file mode 100644 index 00000000..9d6d42c5 --- /dev/null +++ b/AquaMai/UX/CustomLogo.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.IO; +using HarmonyLib; +using Monitor; +using Process; +using UnityEngine; +using UnityEngine.UI; + +namespace AquaMai.UX; + +public class CustomLogo +{ + private static List segaLogo = new(); + private static List allNetLogo = new(); + + public static void DoCustomPatch(HarmonyLib.Harmony h) + { + EnumSprite(segaLogo, Path.Combine(Environment.CurrentDirectory, "LocalAssets", "SegaLogo")); + EnumSprite(allNetLogo, Path.Combine(Environment.CurrentDirectory, "LocalAssets", "AllNetLogo")); + } + + private static void EnumSprite(List collection, string path) + { + if (!Directory.Exists(path)) return; + foreach (var file in Directory.EnumerateFiles(path, "*.png")) + { + var data = File.ReadAllBytes(file); + var texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false); + if (texture2D.LoadImage(data)) + { + collection.Add(Sprite.Create(texture2D, new Rect(0f, 0f, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f))); + } + } + } + + [HarmonyPatch(typeof(AdvertiseProcess), "OnStart")] + [HarmonyPostfix] + private static void AdvProcessPostFix(AdvertiseMonitor[] ____monitors) + { + if (segaLogo.Count > 0) + { + foreach (var monitor in ____monitors) + { + monitor.transform.Find("Canvas/Main/SegaAllNet_LOGO/NUL_ADT_SegaAllNet_LOGO/SegaLogo").GetComponent().sprite = segaLogo[UnityEngine.Random.Range(0, segaLogo.Count)]; + } + } + + if (allNetLogo.Count > 0) + { + foreach (var monitor in ____monitors) + { + monitor.transform.Find("Canvas/Main/SegaAllNet_LOGO/NUL_ADT_SegaAllNet_LOGO/AllNetLogo").GetComponent().sprite = (allNetLogo[UnityEngine.Random.Range(0, allNetLogo.Count)]); + } + } + } +} diff --git a/AquaMai/UX/RandomBgm.cs b/AquaMai/UX/RandomBgm.cs index 0f62a15a..1b5322cc 100644 --- a/AquaMai/UX/RandomBgm.cs +++ b/AquaMai/UX/RandomBgm.cs @@ -12,7 +12,6 @@ namespace AquaMai.UX public class RandomBgm { private static List _acbs = new List(); - private static Random _rng = new Random(); [HarmonyPostfix] [HarmonyPatch(typeof(SoundManager), "Initialize")] @@ -43,7 +42,7 @@ namespace AquaMai.UX case Cue.BGM_COLLECTION: case Cue.BGM_RESULT_CLEAR: case Cue.BGM_RESULT: - var acb = _acbs[_rng.Next(_acbs.Count)]; + var acb = _acbs[UnityEngine.Random.Range(0, _acbs.Count)]; acbID = SoundManager.AcbID.Max; var result = Singleton.Instance.LoadCueSheet((int)acbID, acb); MelonLogger.Msg($"Picked {acb} for {cueIndex}, result: {result}");