[F] SelectionDetail Font size

[RF] Move SelectionDetail to Utils
[RF] Remove UrGui
[RF] Refactor SelectionDetail
pull/55/head
Clansty 2024-09-29 23:12:22 +08:00
parent 43997f2215
commit 78a396ce4b
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
11 changed files with 110 additions and 102 deletions

View File

@ -284,9 +284,6 @@ DEBUG</DefineConstants>
<Reference Include="UnityEngine.XRModule"> <Reference Include="UnityEngine.XRModule">
<HintPath>Libs\UnityEngine.XRModule.dll</HintPath> <HintPath>Libs\UnityEngine.XRModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="UrGUI">
<HintPath>Libs\UrGUI.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Cheat\MapUnlock.cs" /> <Compile Include="Cheat\MapUnlock.cs" />
@ -304,6 +301,7 @@ DEBUG</DefineConstants>
<Compile Include="Fix\ForcePaidPlay.cs" /> <Compile Include="Fix\ForcePaidPlay.cs" />
<Compile Include="Fix\RemoveEncryption.cs" /> <Compile Include="Fix\RemoveEncryption.cs" />
<Compile Include="Fix\SkipVersionCheck.cs" /> <Compile Include="Fix\SkipVersionCheck.cs" />
<Compile Include="Helpers\GuiSizes.cs" />
<Compile Include="Helpers\MessageHelper.cs" /> <Compile Include="Helpers\MessageHelper.cs" />
<Compile Include="Helpers\MusicDirHelper.cs" /> <Compile Include="Helpers\MusicDirHelper.cs" />
<Compile Include="Helpers\SharedInstances.cs" /> <Compile Include="Helpers\SharedInstances.cs" />
@ -318,9 +316,11 @@ DEBUG</DefineConstants>
<Compile Include="TimeSaving\SkipWarningScreen.cs" /> <Compile Include="TimeSaving\SkipWarningScreen.cs" />
<Compile Include="TouchSensitivity\Enable.cs" /> <Compile Include="TouchSensitivity\Enable.cs" />
<Compile Include="Utils\JudgeAdjust.cs" /> <Compile Include="Utils\JudgeAdjust.cs" />
<Compile Include="Utils\LogNetworkErrors.cs" />
<Compile Include="Utils\LogUserId.cs" /> <Compile Include="Utils\LogUserId.cs" />
<Compile Include="Utils\PractiseMode.cs" /> <Compile Include="Utils\PractiseMode.cs" />
<Compile Include="Utils\PractiseModeUI.cs" /> <Compile Include="Utils\PractiseModeUI.cs" />
<Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\WindowState.cs" /> <Compile Include="Utils\WindowState.cs" />
<Compile Include="UX\CustomPlaceName.cs" /> <Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" /> <Compile Include="UX\CustomVersionString.cs" />
@ -334,7 +334,6 @@ DEBUG</DefineConstants>
<Compile Include="UX\QuickSkip.cs" /> <Compile Include="UX\QuickSkip.cs" />
<Compile Include="UX\RandomBgm.cs" /> <Compile Include="UX\RandomBgm.cs" />
<Compile Include="UX\RunCommandOnEvents.cs" /> <Compile Include="UX\RunCommandOnEvents.cs" />
<Compile Include="UX\SelectionDetail.cs" />
<Compile Include="UX\SinglePlayer.cs" /> <Compile Include="UX\SinglePlayer.cs" />
<Compile Include="UX\TestProof.cs" /> <Compile Include="UX\TestProof.cs" />
</ItemGroup> </ItemGroup>

View File

@ -48,8 +48,6 @@ 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. # 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. # 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 HideSelfMadeCharts=true
# Show detail of selected song in music selection screen
SelectionDetail=true
[Fix] [Fix]
# Allow login with higher data version # Allow login with higher data version
@ -78,6 +76,8 @@ Windowed=false
# If set to 0, windowed mode will remember the user-set size, fullscreen mode will use the current display resolution # If set to 0, windowed mode will remember the user-set size, fullscreen mode will use the current display resolution
Width=0 Width=0
Height=0 Height=0
# Show detail of selected song in music selection screen
SelectionDetail=true
# =================================== # ===================================
# Save some potentially unnecessary time # Save some potentially unnecessary time

View File

@ -57,8 +57,6 @@ CustomPlaceName=""
# 选歌界面按下 Service 键或者键盘上的 “7” 键ADX 默认固件下箭头键中间的圆形按键)切换自制谱的显示和隐藏 # 选歌界面按下 Service 键或者键盘上的 “7” 键ADX 默认固件下箭头键中间的圆形按键)切换自制谱的显示和隐藏
# 是否是自制谱的判断方式是 Axxx 目录里没有 DataConfig.xml 或 OfficialChartsMark.txt 就认为这个目录里是自制谱 # 是否是自制谱的判断方式是 Axxx 目录里没有 DataConfig.xml 或 OfficialChartsMark.txt 就认为这个目录里是自制谱
HideSelfMadeCharts=true HideSelfMadeCharts=true
# 选歌界面显示选择的歌曲的详情
SelectionDetail=true
# =================================== # ===================================
# 修复一些潜在的问题 # 修复一些潜在的问题
@ -94,6 +92,8 @@ Windowed=false
# 如果设为 0窗口化将记住用户设定的大小全屏时将使用当前显示器分辨率 # 如果设为 0窗口化将记住用户设定的大小全屏时将使用当前显示器分辨率
Width=0 Width=0
Height=0 Height=0
# 选歌界面显示选择的歌曲的详情
SelectionDetail=true
# =================================== # ===================================
# 节省一些不知道有用没用的时间 # 节省一些不知道有用没用的时间

View File

@ -34,7 +34,6 @@ namespace AquaMai
public bool LoadLocalBga { get; set; } public bool LoadLocalBga { get; set; }
public bool TestProof { get; set; } public bool TestProof { get; set; }
public bool HideSelfMadeCharts { get; set; } public bool HideSelfMadeCharts { get; set; }
public bool SelectionDetail { get; set; }
public string CustomVersionString { get; set; } = ""; public string CustomVersionString { get; set; } = "";
public string CustomPlaceName { get; set; } = ""; public string CustomPlaceName { get; set; } = "";
public string ExecOnIdle { get; set; } = ""; public string ExecOnIdle { get; set; } = "";
@ -61,6 +60,7 @@ namespace AquaMai
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
public bool PractiseMode { get; set; } public bool PractiseMode { get; set; }
public bool SelectionDetail { get; set; }
} }
public class TimeSavingConfig public class TimeSavingConfig

View File

@ -0,0 +1,12 @@
using UnityEngine;
namespace AquaMai.Helpers;
public static class GuiSizes
{
public static float PlayerWidth => Screen.height / 1920f * 1080;
public static float PlayerCenter => AquaMai.AppConfig.UX.SinglePlayer ? Screen.width / 2f : Screen.width / 2f - PlayerWidth / 2;
public static int FontSize => (int)(PlayerWidth * .015f);
public static float LabelHeight => FontSize * 1.5f;
public static float Margin => PlayerWidth * .005f;
}

Binary file not shown.

View File

@ -140,6 +140,9 @@ namespace AquaMai
Patch(typeof(RunCommandOnEvents)); Patch(typeof(RunCommandOnEvents));
// Utils // Utils
Patch(typeof(JudgeAdjust)); Patch(typeof(JudgeAdjust));
# if DEBUG
Patch(typeof(LogNetworkErrors));
# endif
// Apply patches based on the settings // Apply patches based on the settings
ApplyPatches(); ApplyPatches();

View 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}");
}
}

View File

@ -8,7 +8,6 @@ using Manager;
using Monitor; using Monitor;
using Process; using Process;
using UnityEngine; using UnityEngine;
using UrGUI.GUIWindow;
namespace AquaMai.Utils; namespace AquaMai.Utils;
@ -80,33 +79,6 @@ public class PractiseMode
SetSpeed(); 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; public static PractiseModeUI ui;
[HarmonyPatch(typeof(GameProcess), "OnStart")] [HarmonyPatch(typeof(GameProcess), "OnStart")]
@ -124,11 +96,7 @@ public class PractiseMode
[HarmonyPatch(typeof(GenericProcess), "OnUpdate")] [HarmonyPatch(typeof(GenericProcess), "OnUpdate")]
public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors) public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors)
{ {
if (Input.GetKeyDown(KeyCode.F12)) if (Input.GetKeyDown(KeyCode.F11))
{
____monitors[0].gameObject.AddComponent<DebugWindow>();
}
else if (Input.GetKeyDown(KeyCode.F11))
{ {
____monitors[0].gameObject.AddComponent<PractiseModeUI>(); ____monitors[0].gameObject.AddComponent<PractiseModeUI>();
} }

View File

@ -1,65 +1,42 @@
using System; using System;
using AquaMai.Fix; using AquaMai.Fix;
using AquaMai.Helpers;
using Manager; using Manager;
using UnityEngine; using UnityEngine;
using UrGUI.GUIWindow;
namespace AquaMai.Utils; namespace AquaMai.Utils;
public class PractiseModeUI : MonoBehaviour public class PractiseModeUI : MonoBehaviour
{ {
private float playerWidth; private static float windowTop => Screen.height - GuiSizes.PlayerWidth + GuiSizes.PlayerWidth * .22f;
private float playerCenter; private static float controlHeight => GuiSizes.PlayerWidth * .13f;
private float windowTop; private static float sideButtonWidth => GuiSizes.PlayerWidth * .1f;
private float controlHeight; private static float centerButtonWidth => GuiSizes.PlayerWidth * .28f;
private float margin; private static int fontSize => (int)(GuiSizes.PlayerWidth * .02f);
private float sideButtonWidth;
private float centerButtonWidth;
private int fontSize;
public void Start() private static Rect GetButtonRect(int pos, int row)
{
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)
{ {
float x; float x;
float width; float width;
switch (pos) switch (pos)
{ {
case 0: case 0:
x = playerCenter - centerButtonWidth / 2 - sideButtonWidth - margin; x = GuiSizes.PlayerCenter - centerButtonWidth / 2 - sideButtonWidth - GuiSizes.Margin;
width = sideButtonWidth; width = sideButtonWidth;
break; break;
case 1: case 1:
x = playerCenter - centerButtonWidth / 2; x = GuiSizes.PlayerCenter - centerButtonWidth / 2;
width = centerButtonWidth; width = centerButtonWidth;
break; break;
case 2: case 2:
x = playerCenter + centerButtonWidth / 2 + margin; x = GuiSizes.PlayerCenter + centerButtonWidth / 2 + GuiSizes.Margin;
width = sideButtonWidth; width = sideButtonWidth;
break; break;
default: default:
throw new ArgumentOutOfRangeException(nameof(pos), pos, null); 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() public void OnGUI()
@ -72,10 +49,10 @@ public class PractiseModeUI : MonoBehaviour
buttonStyle.fontSize = fontSize; buttonStyle.fontSize = fontSize;
GUI.Box(new Rect( GUI.Box(new Rect(
playerCenter - centerButtonWidth / 2 - sideButtonWidth - margin * 2, GuiSizes.PlayerCenter - centerButtonWidth / 2 - sideButtonWidth - GuiSizes.Margin * 2,
windowTop, windowTop,
centerButtonWidth + sideButtonWidth * 2 + margin * 4, centerButtonWidth + sideButtonWidth * 2 + GuiSizes.Margin * 4,
controlHeight * 4 + margin * 5 controlHeight * 4 + GuiSizes.Margin * 5
), ""); ), "");
GUI.Button(GetButtonRect(0, 0), "Seek <<"); GUI.Button(GetButtonRect(0, 0), "Seek <<");

View File

@ -1,4 +1,5 @@
using System.Linq; using System.Collections.Generic;
using System.Linq;
using AquaMai.Helpers; using AquaMai.Helpers;
using HarmonyLib; using HarmonyLib;
using MAI2.Util; using MAI2.Util;
@ -8,9 +9,8 @@ using Manager.UserDatas;
using Monitor; using Monitor;
using Process; using Process;
using UnityEngine; using UnityEngine;
using UrGUI.GUIWindow;
namespace AquaMai.UX; namespace AquaMai.Utils;
public class SelectionDetail public class SelectionDetail
{ {
@ -65,31 +65,38 @@ public class SelectionDetail
private abstract class Window : MonoBehaviour private abstract class Window : MonoBehaviour
{ {
private GUIWindow window;
protected abstract int player { get; } protected abstract int player { get; }
public void Start() public void OnGUI()
{ {
var x = Screen.width / 2f - 100; var dataToShow = new List<string>();
if (!AquaMai.AppConfig.UX.SinglePlayer) dataToShow.Add($"ID: {SelectData.MusicData.name.id}");
{ dataToShow.Add(MusicDirHelper.LookupPath(SelectData.MusicData.name.id).Split('/').Reverse().ToArray()[3]);
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]);
if (SelectData.MusicData.genreName is not null) // SelectData.MusicData.genreName.str may not correct if (SelectData.MusicData.genreName is not null) // SelectData.MusicData.genreName.str may not correct
window.Label(Singleton<DataManager>.Instance.GetMusicGenre(SelectData.MusicData.genreName.id)?.genreName); dataToShow.Add(Singleton<DataManager>.Instance.GetMusicGenre(SelectData.MusicData.genreName.id)?.genreName);
if (SelectData.MusicData.AddVersion is not null) if (SelectData.MusicData.AddVersion is not null)
window.Label(Singleton<DataManager>.Instance.GetMusicVersion(SelectData.MusicData.AddVersion.id)?.genreName); dataToShow.Add(Singleton<DataManager>.Instance.GetMusicVersion(SelectData.MusicData.AddVersion.id)?.genreName);
var notesData = SelectData.MusicData.notesData[difficulty[player]]; var notesData = SelectData.MusicData.notesData[difficulty[player]];
window.Label($"{notesData?.level}.{notesData?.levelDecimal}"); dataToShow.Add($"{notesData?.level}.{notesData?.levelDecimal}");
var rate = CalcB50(SelectData.MusicData, difficulty[player]); var rate = CalcB50(SelectData.MusicData, difficulty[player]);
if (rate > 0) if (rate > 0)
{ {
window.Label($"SSS+ => DXRating += {rate}"); 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]);
} }
} }
@ -107,11 +114,6 @@ public class SelectionDetail
return 0; return 0;
} }
private void OnGUI()
{
window?.Draw();
}
public void Close() public void Close()
{ {
Destroy(this); Destroy(this);