mirror of https://github.com/hykilpikonna/AquaDX
[+] Support 2p SelectionDetail
parent
8fa356242e
commit
0eec8dea05
|
@ -14,52 +14,87 @@ namespace AquaMai.UX;
|
||||||
|
|
||||||
public class SelectionDetail
|
public class SelectionDetail
|
||||||
{
|
{
|
||||||
private static Window window;
|
private static readonly Window[] window = new Window[2];
|
||||||
public static MusicSelectProcess.MusicSelectData SelectData { get; private set; }
|
private static MusicSelectProcess.MusicSelectData SelectData { get; set; }
|
||||||
public static int Difficulty { get; private set; }
|
private static readonly int[] difficulty = new int[2];
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(MusicSelectMonitor), "UpdateRivalScore")]
|
[HarmonyPatch(typeof(MusicSelectMonitor), "UpdateRivalScore")]
|
||||||
public static void ScrollUpdate(MusicSelectProcess ____musicSelect, MusicSelectMonitor __instance)
|
public static void ScrollUpdate(MusicSelectProcess ____musicSelect, MusicSelectMonitor __instance)
|
||||||
{
|
{
|
||||||
if (__instance != ____musicSelect.MonitorArray[0]) return;
|
int player;
|
||||||
if (window != null)
|
if (__instance == ____musicSelect.MonitorArray[0])
|
||||||
{
|
{
|
||||||
window.Close();
|
player = 0;
|
||||||
}
|
}
|
||||||
|
else if (__instance == ____musicSelect.MonitorArray[1])
|
||||||
|
{
|
||||||
|
player = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window[player] != null)
|
||||||
|
{
|
||||||
|
window[player].Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
var userData = Singleton<UserDataManager>.Instance.GetUserData(player);
|
||||||
|
if (!userData.IsEntry) return;
|
||||||
|
|
||||||
if (____musicSelect.IsRandomIndex()) return;
|
if (____musicSelect.IsRandomIndex()) return;
|
||||||
|
|
||||||
SelectData = ____musicSelect.GetMusic(0);
|
SelectData = ____musicSelect.GetMusic(0);
|
||||||
if (SelectData == null) return;
|
if (SelectData == null) return;
|
||||||
Difficulty = ____musicSelect.GetDifficulty(0);
|
difficulty[player] = ____musicSelect.GetDifficulty(player);
|
||||||
|
|
||||||
window = __instance.gameObject.AddComponent<Window>();
|
window[player] = player == 0 ? __instance.gameObject.AddComponent<P1Window>() : __instance.gameObject.AddComponent<P2Window>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Window : MonoBehaviour
|
private class P1Window : Window
|
||||||
|
{
|
||||||
|
protected override int player => 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class P2Window : Window
|
||||||
|
{
|
||||||
|
protected override int player => 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private abstract class Window : MonoBehaviour
|
||||||
{
|
{
|
||||||
private GUIWindow window;
|
private GUIWindow window;
|
||||||
|
protected abstract int player { get; }
|
||||||
|
|
||||||
private void Start()
|
public 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);
|
var x = Screen.width / 2f - 100;
|
||||||
|
if (!AquaMai.AppConfig.UX.SinglePlayer)
|
||||||
|
{
|
||||||
|
var halfPlayerWidth = Screen.height / 1920f * 1080 / 2;
|
||||||
|
x += halfPlayerWidth * (player == 0 ? -1 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
window = GUIWindow.Begin($"ID: {SelectData.MusicData.name.id}", x, 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(MusicDirHelper.LookupPath(SelectData.MusicData.name.id).Split('/').Reverse().ToArray()[3]);
|
||||||
window.Label(SelectData.MusicData.genreName?.str);
|
window.Label(SelectData.MusicData.genreName?.str);
|
||||||
window.Label(SelectData.MusicData.AddVersion?.str);
|
window.Label(SelectData.MusicData.AddVersion?.str);
|
||||||
window.Label($"{SelectData.MusicData.notesData[Difficulty]?.level}.{SelectData.MusicData.notesData[Difficulty]?.levelDecimal}");
|
var notesData = SelectData.MusicData.notesData[difficulty[player]];
|
||||||
|
window.Label($"{notesData?.level}.{notesData?.levelDecimal}");
|
||||||
|
|
||||||
var rate = CalcB50(SelectData.MusicData);
|
var rate = CalcB50(SelectData.MusicData, difficulty[player]);
|
||||||
if (rate > 0)
|
if (rate > 0)
|
||||||
{
|
{
|
||||||
window.Label($"SSS+ => DXRating += {rate}");
|
window.Label($"SSS+ => DXRating += {rate}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint CalcB50(MusicData musicData)
|
private uint CalcB50(MusicData musicData, int difficulty)
|
||||||
{
|
{
|
||||||
var newRate = new UserRate(musicData.name.id, Difficulty, 1010000, (uint)musicData.version);
|
var newRate = new UserRate(musicData.name.id, difficulty, 1010000, (uint)musicData.version);
|
||||||
var user = Singleton<UserDataManager>.Instance.GetUserData(0);
|
var user = Singleton<UserDataManager>.Instance.GetUserData(player);
|
||||||
var userLowRate = (newRate.OldFlag ? user.RatingList.RatingList : user.RatingList.NewRatingList).Last();
|
var userLowRate = (newRate.OldFlag ? user.RatingList.RatingList : user.RatingList.NewRatingList).Last();
|
||||||
|
|
||||||
if (newRate.SingleRate > userLowRate.SingleRate)
|
if (newRate.SingleRate > userLowRate.SingleRate)
|
||||||
|
@ -72,7 +107,7 @@ public class SelectionDetail
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
window.Draw();
|
window?.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
|
Loading…
Reference in New Issue