Skip to content

Commit

Permalink
[+] CustomLogo
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 4, 2024
1 parent 7e54679 commit d84b2f3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ DEBUG</DefineConstants>
<Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\ShowNetErrorDetail.cs" />
<Compile Include="UX\CustomFont.cs" />
<Compile Include="UX\CustomLogo.cs" />
<Compile Include="UX\CustomNoteSkin.cs" />
<Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" />
Expand Down
1 change: 1 addition & 0 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public override void OnInitializeMelon()
Patch(typeof(CustomVersionString));
Patch(typeof(CustomPlaceName));
Patch(typeof(RunCommandOnEvents));
Patch(typeof(CustomLogo));
// Utils
Patch(typeof(JudgeAdjust));
# if DEBUG
Expand Down
57 changes: 57 additions & 0 deletions AquaMai/UX/CustomLogo.cs
Original file line number Diff line number Diff line change
@@ -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<Sprite> segaLogo = new();
private static List<Sprite> 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<Sprite> 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<Image>().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<Image>().sprite = (allNetLogo[UnityEngine.Random.Range(0, allNetLogo.Count)]);
}
}
}
}
3 changes: 1 addition & 2 deletions AquaMai/UX/RandomBgm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace AquaMai.UX
public class RandomBgm
{
private static List<string> _acbs = new List<string>();
private static Random _rng = new Random();

[HarmonyPostfix]
[HarmonyPatch(typeof(SoundManager), "Initialize")]
Expand Down Expand Up @@ -43,7 +42,7 @@ public static void PrePlay(ref SoundManager.AcbID acbID, int cueID)
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<SoundCtrl>.Instance.LoadCueSheet((int)acbID, acb);
MelonLogger.Msg($"Picked {acb} for {cueIndex}, result: {result}");
Expand Down

0 comments on commit d84b2f3

Please sign in to comment.