mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-11 08:17:26 +08:00
[F] SelectionDetail Font size
[RF] Move SelectionDetail to Utils [RF] Remove UrGui [RF] Refactor SelectionDetail
This commit is contained in:
47
AquaMai/Utils/LogNetworkErrors.cs
Normal file
47
AquaMai/Utils/LogNetworkErrors.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Diagnostics;
|
||||
using HarmonyLib;
|
||||
using Manager;
|
||||
using Manager.Operation;
|
||||
using MelonLoader;
|
||||
using Net.Packet;
|
||||
|
||||
namespace AquaMai.Utils;
|
||||
|
||||
public class LogNetworkErrors
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(Packet), "ProcImpl")]
|
||||
public static void Postfix(PacketState __result, Packet __instance)
|
||||
{
|
||||
if (__result == PacketState.Error)
|
||||
{
|
||||
MelonLogger.Msg($"[LogNetworkErrors] {__instance.Query.Api}: {__instance.Status}");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(DataDownloader), "NotifyOffline")]
|
||||
public static void DataDownloader()
|
||||
{
|
||||
MelonLogger.Msg("[LogNetworkErrors] DataDownloader NotifyOffline");
|
||||
var stackTrace = new StackTrace();
|
||||
MelonLogger.Msg(stackTrace.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(OnlineCheckInterval), "NotifyOffline")]
|
||||
public static void OnlineCheckInterval()
|
||||
{
|
||||
MelonLogger.Msg("[LogNetworkErrors] OnlineCheckInterval NotifyOffline");
|
||||
var stackTrace = new StackTrace();
|
||||
MelonLogger.Msg(stackTrace.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(OperationManager), "IsAliveAimeServer", MethodType.Getter)]
|
||||
public static void IsAliveAimeServer(bool __result)
|
||||
{
|
||||
if (__result == false)
|
||||
MelonLogger.Msg($"[LogNetworkErrors] IsAliveAimeServer Is {__result}");
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using Manager;
|
||||
using Monitor;
|
||||
using Process;
|
||||
using UnityEngine;
|
||||
using UrGUI.GUIWindow;
|
||||
|
||||
namespace AquaMai.Utils;
|
||||
|
||||
@@ -80,33 +79,6 @@ public class PractiseMode
|
||||
SetSpeed();
|
||||
}
|
||||
|
||||
private class DebugWindow : MonoBehaviour
|
||||
{
|
||||
private GUIWindow window;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
window = GUIWindow.Begin("练习模式 测试");
|
||||
window.Button("暂停", () => DebugFeature.Pause = !DebugFeature.Pause);
|
||||
window.SameLine();
|
||||
window.Button("向前", () => DebugFeature.Seek(-1000));
|
||||
window.Button("向后", () => DebugFeature.Seek(1000));
|
||||
window.SameLine(1, 1, 1);
|
||||
window.Button("循环开始", () => repeatStart = DebugFeature.CurrentPlayMsec);
|
||||
window.Button("循环结束", () => SetRepeatEnd(DebugFeature.CurrentPlayMsec));
|
||||
window.Button("循环解除", ClearRepeat);
|
||||
window.SameLine(1, 1, 1);
|
||||
window.Button("加速", SpeedUp);
|
||||
window.Button("减速", SpeedDown);
|
||||
window.Button("速度重置", SpeedReset);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
window?.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
public static PractiseModeUI ui;
|
||||
|
||||
[HarmonyPatch(typeof(GameProcess), "OnStart")]
|
||||
@@ -124,11 +96,7 @@ public class PractiseMode
|
||||
[HarmonyPatch(typeof(GenericProcess), "OnUpdate")]
|
||||
public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F12))
|
||||
{
|
||||
____monitors[0].gameObject.AddComponent<DebugWindow>();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.F11))
|
||||
if (Input.GetKeyDown(KeyCode.F11))
|
||||
{
|
||||
____monitors[0].gameObject.AddComponent<PractiseModeUI>();
|
||||
}
|
||||
|
||||
@@ -1,65 +1,42 @@
|
||||
using System;
|
||||
using AquaMai.Fix;
|
||||
using AquaMai.Helpers;
|
||||
using Manager;
|
||||
using UnityEngine;
|
||||
using UrGUI.GUIWindow;
|
||||
|
||||
namespace AquaMai.Utils;
|
||||
|
||||
public class PractiseModeUI : MonoBehaviour
|
||||
{
|
||||
private float playerWidth;
|
||||
private float playerCenter;
|
||||
private float windowTop;
|
||||
private float controlHeight;
|
||||
private float margin;
|
||||
private float sideButtonWidth;
|
||||
private float centerButtonWidth;
|
||||
private int fontSize;
|
||||
private static float windowTop => Screen.height - GuiSizes.PlayerWidth + GuiSizes.PlayerWidth * .22f;
|
||||
private static float controlHeight => GuiSizes.PlayerWidth * .13f;
|
||||
private static float sideButtonWidth => GuiSizes.PlayerWidth * .1f;
|
||||
private static float centerButtonWidth => GuiSizes.PlayerWidth * .28f;
|
||||
private static int fontSize => (int)(GuiSizes.PlayerWidth * .02f);
|
||||
|
||||
public void Start()
|
||||
{
|
||||
playerWidth = Screen.height / 1920f * 1080;
|
||||
if (AquaMai.AppConfig.UX.SinglePlayer)
|
||||
{
|
||||
playerCenter = Screen.width / 2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCenter = Screen.width / 2f - playerWidth / 2;
|
||||
}
|
||||
|
||||
windowTop = Screen.height - playerWidth + playerWidth * .22f;
|
||||
controlHeight = playerWidth * .13f;
|
||||
margin = playerWidth * .01f;
|
||||
sideButtonWidth = playerWidth * .1f;
|
||||
centerButtonWidth = playerWidth * .28f;
|
||||
fontSize = (int)(playerWidth * .02f);
|
||||
}
|
||||
|
||||
public Rect GetButtonRect(int pos, int row)
|
||||
private static Rect GetButtonRect(int pos, int row)
|
||||
{
|
||||
float x;
|
||||
float width;
|
||||
switch (pos)
|
||||
{
|
||||
case 0:
|
||||
x = playerCenter - centerButtonWidth / 2 - sideButtonWidth - margin;
|
||||
x = GuiSizes.PlayerCenter - centerButtonWidth / 2 - sideButtonWidth - GuiSizes.Margin;
|
||||
width = sideButtonWidth;
|
||||
break;
|
||||
case 1:
|
||||
x = playerCenter - centerButtonWidth / 2;
|
||||
x = GuiSizes.PlayerCenter - centerButtonWidth / 2;
|
||||
width = centerButtonWidth;
|
||||
break;
|
||||
case 2:
|
||||
x = playerCenter + centerButtonWidth / 2 + margin;
|
||||
x = GuiSizes.PlayerCenter + centerButtonWidth / 2 + GuiSizes.Margin;
|
||||
width = sideButtonWidth;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(pos), pos, null);
|
||||
}
|
||||
|
||||
return new Rect(x, windowTop + (margin + controlHeight) * row + margin, width, controlHeight);
|
||||
return new Rect(x, windowTop + (GuiSizes.Margin + controlHeight) * row + GuiSizes.Margin, width, controlHeight);
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
@@ -72,10 +49,10 @@ public class PractiseModeUI : MonoBehaviour
|
||||
buttonStyle.fontSize = fontSize;
|
||||
|
||||
GUI.Box(new Rect(
|
||||
playerCenter - centerButtonWidth / 2 - sideButtonWidth - margin * 2,
|
||||
GuiSizes.PlayerCenter - centerButtonWidth / 2 - sideButtonWidth - GuiSizes.Margin * 2,
|
||||
windowTop,
|
||||
centerButtonWidth + sideButtonWidth * 2 + margin * 4,
|
||||
controlHeight * 4 + margin * 5
|
||||
centerButtonWidth + sideButtonWidth * 2 + GuiSizes.Margin * 4,
|
||||
controlHeight * 4 + GuiSizes.Margin * 5
|
||||
), "");
|
||||
|
||||
GUI.Button(GetButtonRect(0, 0), "Seek <<");
|
||||
|
||||
122
AquaMai/Utils/SelectionDetail.cs
Normal file
122
AquaMai/Utils/SelectionDetail.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System.Collections.Generic;
|
||||
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;
|
||||
|
||||
namespace AquaMai.Utils;
|
||||
|
||||
public class SelectionDetail
|
||||
{
|
||||
private static readonly Window[] window = new Window[2];
|
||||
private static MusicSelectProcess.MusicSelectData SelectData { get; set; }
|
||||
private static readonly int[] difficulty = new int[2];
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(MusicSelectMonitor), "UpdateRivalScore")]
|
||||
public static void ScrollUpdate(MusicSelectProcess ____musicSelect, MusicSelectMonitor __instance)
|
||||
{
|
||||
int player;
|
||||
if (__instance == ____musicSelect.MonitorArray[0])
|
||||
{
|
||||
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;
|
||||
|
||||
SelectData = ____musicSelect.GetMusic(0);
|
||||
if (SelectData == null) return;
|
||||
difficulty[player] = ____musicSelect.GetDifficulty(player);
|
||||
|
||||
window[player] = player == 0 ? __instance.gameObject.AddComponent<P1Window>() : __instance.gameObject.AddComponent<P2Window>();
|
||||
}
|
||||
|
||||
private class P1Window : Window
|
||||
{
|
||||
protected override int player => 0;
|
||||
}
|
||||
|
||||
private class P2Window : Window
|
||||
{
|
||||
protected override int player => 1;
|
||||
}
|
||||
|
||||
private abstract class Window : MonoBehaviour
|
||||
{
|
||||
protected abstract int player { get; }
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
var dataToShow = new List<string>();
|
||||
dataToShow.Add($"ID: {SelectData.MusicData.name.id}");
|
||||
dataToShow.Add(MusicDirHelper.LookupPath(SelectData.MusicData.name.id).Split('/').Reverse().ToArray()[3]);
|
||||
if (SelectData.MusicData.genreName is not null) // SelectData.MusicData.genreName.str may not correct
|
||||
dataToShow.Add(Singleton<DataManager>.Instance.GetMusicGenre(SelectData.MusicData.genreName.id)?.genreName);
|
||||
if (SelectData.MusicData.AddVersion is not null)
|
||||
dataToShow.Add(Singleton<DataManager>.Instance.GetMusicVersion(SelectData.MusicData.AddVersion.id)?.genreName);
|
||||
var notesData = SelectData.MusicData.notesData[difficulty[player]];
|
||||
dataToShow.Add($"{notesData?.level}.{notesData?.levelDecimal}");
|
||||
|
||||
var rate = CalcB50(SelectData.MusicData, difficulty[player]);
|
||||
if (rate > 0)
|
||||
{
|
||||
dataToShow.Add($"SSS+ => DXRating += {rate}");
|
||||
}
|
||||
|
||||
|
||||
var x = GuiSizes.PlayerCenter - 100 + GuiSizes.PlayerWidth * player;
|
||||
var y = Screen.height * 0.87f;
|
||||
|
||||
var labelStyle = GUI.skin.GetStyle("label");
|
||||
labelStyle.fontSize = GuiSizes.FontSize;
|
||||
labelStyle.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
GUI.Box(new Rect(x, y, 200, dataToShow.Count * GuiSizes.LabelHeight + 2 * GuiSizes.Margin), "");
|
||||
for (var i = 0; i < dataToShow.Count; i++)
|
||||
{
|
||||
GUI.Label(new Rect(x, y + GuiSizes.Margin + i * GuiSizes.LabelHeight, 200, GuiSizes.LabelHeight), dataToShow[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private uint CalcB50(MusicData musicData, int difficulty)
|
||||
{
|
||||
var newRate = new UserRate(musicData.name.id, difficulty, 1010000, (uint)musicData.version);
|
||||
var user = Singleton<UserDataManager>.Instance.GetUserData(player);
|
||||
var userLowRate = (newRate.OldFlag ? user.RatingList.RatingList : user.RatingList.NewRatingList).Last();
|
||||
|
||||
if (newRate.SingleRate > userLowRate.SingleRate)
|
||||
{
|
||||
return newRate.SingleRate - userLowRate.SingleRate;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user