Skip to content

Commit

Permalink
[+] showBattleAchievement
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jan 10, 2025
1 parent 6c1ab2b commit 224448a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions AquaMai.Core/Resources/Locale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AquaMai.Core/Resources/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,7 @@
<data name="TouchPanelReset" xml:space="preserve">
<value>Touch panel reset</value>
</data>
<data name="UserGhostAchievement" xml:space="preserve">
<value>Battle Target: {0}</value>
</data>
</root>
3 changes: 3 additions & 0 deletions AquaMai.Core/Resources/Locale.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,7 @@
<data name="TouchPanelReset" xml:space="preserve">
<value>触摸面板已重置</value>
</data>
<data name="UserGhostAchievement" xml:space="preserve">
<value>友人对战目标: {0}</value>
</data>
</root>
17 changes: 16 additions & 1 deletion AquaMai.Mods/UX/SelectionDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using AquaMai.Core.Helpers;
using AquaMai.Core.Resources;
using HarmonyLib;
using JetBrains.Annotations;
using MAI2.Util;
using Manager;
using Manager.MaiStudio;
using Manager.UserDatas;
using MelonLoader;
using Monitor;
using Process;
using UnityEngine;
Expand All @@ -21,9 +23,15 @@ namespace AquaMai.Mods.UX;
zh: "选歌界面显示选择的歌曲的详情")]
public class SelectionDetail
{
[ConfigEntry(
en: "Show friend battle target achievement",
zh: "显示友人对战目标分数")]
private static readonly bool showBattleAchievement = false;

private static readonly Window[] window = new Window[2];
private static MusicSelectProcess.MusicSelectData SelectData { get; set; }
private static readonly int[] difficulty = new int[2];
[CanBeNull] private static UserGhost userGhost;

[HarmonyPostfix]
[HarmonyPatch(typeof(MusicSelectMonitor), "UpdateRivalScore")]
Expand Down Expand Up @@ -56,6 +64,8 @@ public static void ScrollUpdate(MusicSelectProcess ____musicSelect, MusicSelectM
SelectData = ____musicSelect.GetMusic(0);
if (SelectData == null) return;
difficulty[player] = ____musicSelect.GetDifficulty(player);
var ghostTarget = ____musicSelect.GetCombineMusic(0).musicSelectData[(int)____musicSelect.ScoreType].GhostTarget;
userGhost = Singleton<GhostManager>.Instance.GetGhostToEnum(ghostTarget);

window[player] = player == 0 ? __instance.gameObject.AddComponent<P1Window>() : __instance.gameObject.AddComponent<P2Window>();
}
Expand Down Expand Up @@ -87,6 +97,11 @@ public void OnGUI()
var notesData = SelectData.MusicData.notesData[difficulty[player]];
dataToShow.Add($"{notesData?.level}.{notesData?.levelDecimal}");

if (userGhost != null)
{
dataToShow.Add(string.Format(Locale.UserGhostAchievement, $"{userGhost.Achievement / 10000m:0.0000}"));
}

var rate = CalcB50(SelectData.MusicData, difficulty[player]);
if (rate > 0)
{
Expand Down Expand Up @@ -140,4 +155,4 @@ public void Close()
Destroy(this);
}
}
}
}

0 comments on commit 224448a

Please sign in to comment.