diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index dfa62a84..a415eba0 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -279,6 +279,9 @@ Libs\UnityEngine.XRModule.dll + + Libs\UrGUI.dll + @@ -311,6 +314,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 5580314a..9fe19af5 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -54,6 +54,8 @@ CustomPlaceName="" # In the song selection screen, press the Service button or the "7" key (the round button in the middle of the arrow keys in the default ADX firmware) to toggle the display of self-made charts. # A directory is considered to contain self-made charts if it does not have DataConfig.xml or OfficialChartsMark.txt in the Axxx directory. HideSelfMadeCharts=true +# Show detail of selected song in music selection screen +SelectionDetail=true [Performance] # Disable some useless delays to speed up the game boot process diff --git a/AquaMai/AquaMai.zh.toml b/AquaMai/AquaMai.zh.toml index b4e0c448..b31dc3b8 100644 --- a/AquaMai/AquaMai.zh.toml +++ b/AquaMai/AquaMai.zh.toml @@ -60,6 +60,8 @@ CustomPlaceName="" # 选歌界面按下 Service 键或者键盘上的 “7” 键(ADX 默认固件下箭头键中间的圆形按键)切换自制谱的显示和隐藏 # 是否是自制谱的判断方式是 Axxx 目录里没有 DataConfig.xml 或 OfficialChartsMark.txt 就认为这个目录里是自制谱 HideSelfMadeCharts=true +# 选歌界面显示选择的歌曲的详情 +SelectionDetail=true # =================================== # 一些性能优化 diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index fc35ce67..aa9de9e0 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -34,6 +34,7 @@ namespace AquaMai public bool LoadLocalBga { get; set; } public bool TestProof { get; set; } public bool HideSelfMadeCharts { get; set; } + public bool SelectionDetail { get; set; } public string CustomVersionString { get; set; } public string CustomPlaceName { get; set; } public string ExecOnIdle { get; set; } diff --git a/AquaMai/FodyWeavers.xml b/AquaMai/FodyWeavers.xml index 4c95b1d1..94b66718 100644 --- a/AquaMai/FodyWeavers.xml +++ b/AquaMai/FodyWeavers.xml @@ -1,7 +1,7 @@  - tomlet + tomlet|urgui $AquaMai$_ - \ No newline at end of file + diff --git a/AquaMai/Libs/UrGUI.dll b/AquaMai/Libs/UrGUI.dll new file mode 100644 index 00000000..46c3194b Binary files /dev/null and b/AquaMai/Libs/UrGUI.dll differ diff --git a/AquaMai/UX/SelectionDetail.cs b/AquaMai/UX/SelectionDetail.cs new file mode 100644 index 00000000..6dd794fe --- /dev/null +++ b/AquaMai/UX/SelectionDetail.cs @@ -0,0 +1,83 @@ +using System.Linq; +using AquaMai.Helpers; +using HarmonyLib; +using MAI2.Util; +using Manager; +using Manager.MaiStudio; +using Manager.UserDatas; +using Monitor; +using Process; +using UnityEngine; +using UrGUI.GUIWindow; + +namespace AquaMai.UX; + +public class SelectionDetail +{ + private static Window window; + public static MusicSelectProcess.MusicSelectData SelectData { get; private set; } + public static int Difficulty { get; private set; } + + [HarmonyPostfix] + [HarmonyPatch(typeof(MusicSelectMonitor), "UpdateRivalScore")] + public static void ScrollUpdate(MusicSelectProcess ____musicSelect, MusicSelectMonitor __instance) + { + if (__instance != ____musicSelect.MonitorArray[0]) return; + if (window != null) + { + window.Close(); + } + + if (____musicSelect.IsRandomIndex()) return; + + SelectData = ____musicSelect.GetMusic(0); + if (SelectData == null) return; + Difficulty = ____musicSelect.GetDifficulty(0); + + window = __instance.gameObject.AddComponent(); + } + + public class Window : MonoBehaviour + { + private GUIWindow window; + + private void Start() + { + window = GUIWindow.Begin($"ID: {SelectData.MusicData.name.id}", Screen.width / 2f - 100, Screen.height * 0.87f, 200, 50, 10, 22, 5, true, true, true); + window.Label(MusicDirHelper.LookupPath(SelectData.MusicData.name.id).Split('/').Reverse().ToArray()[3]); + window.Label(SelectData.MusicData.genreName?.str); + window.Label(SelectData.MusicData.AddVersion?.str); + window.Label($"{SelectData.MusicData.notesData[Difficulty]?.level}.{SelectData.MusicData.notesData[Difficulty]?.levelDecimal}"); + + var rate = CalcB50(SelectData.MusicData); + if (rate > 0) + { + window.Label($"SSS+ => DXRating += {rate}"); + } + } + + private uint CalcB50(MusicData musicData) + { + var newRate = new UserRate(musicData.name.id, Difficulty, 1010000, (uint)musicData.version); + var user = Singleton.Instance.GetUserData(0); + var userLowRate = (newRate.OldFlag ? user.RatingList.RatingList : user.RatingList.NewRatingList).Last(); + + if (newRate.SingleRate > userLowRate.SingleRate) + { + return newRate.SingleRate - userLowRate.SingleRate; + } + + return 0; + } + + private void OnGUI() + { + window.Draw(); + } + + public void Close() + { + Destroy(this); + } + } +}