From d3fe92cc73c025f650d4bd749cb2adbd4f3c1b3c Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 2 Oct 2024 23:28:33 +0800 Subject: [PATCH 1/7] [+] Some font features --- AquaMai.csproj | 2 ++ AquaMai.toml | 6 ++++++ AquaMai.zh.toml | 6 ++++++ Config.cs | 2 ++ Fix/FontFix.cs | 32 ++++++++++++++++++++++++++++++++ UX/CustomFont.cs | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 Fix/FontFix.cs create mode 100644 UX/CustomFont.cs diff --git a/AquaMai.csproj b/AquaMai.csproj index a83253de..9965e89f 100644 --- a/AquaMai.csproj +++ b/AquaMai.csproj @@ -298,6 +298,7 @@ DEBUG + @@ -332,6 +333,7 @@ DEBUG + diff --git a/AquaMai.toml b/AquaMai.toml index 07c4d557..d0136c7f 100644 --- a/AquaMai.toml +++ b/AquaMai.toml @@ -50,6 +50,9 @@ 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 +# Place font.ttf in the LocalAssets directory to replace the game's global font +# Cannot be used together with FontFix +CustomFont=false [Fix] # Allow login with higher data version @@ -64,6 +67,9 @@ ForcePaidPlay=false ExtendNotesPool=128 # Force the frame rate limit to 60 FPS and disable vSync. Do not use if your game has no issues FrameRateLock=false +# Use Microsoft YaHei Bold to display characters not in the font library +# Cannot be used together with CustomFont +FontFix=true [Utils] # Log user ID on login diff --git a/AquaMai.zh.toml b/AquaMai.zh.toml index 2a2666bc..4b137e67 100644 --- a/AquaMai.zh.toml +++ b/AquaMai.zh.toml @@ -59,6 +59,9 @@ CustomPlaceName="" # 选歌界面按下 Service 键或者键盘上的 “7” 键(ADX 默认固件下箭头键中间的圆形按键)切换自制谱的显示和隐藏 # 是否是自制谱的判断方式是 Axxx 目录里没有 DataConfig.xml 或 OfficialChartsMark.txt 就认为这个目录里是自制谱 HideSelfMadeCharts=true +# 在 LocalAssets 目录下放置 font.ttf 可以替换游戏的全局字体 +# 不可以和 FontFix 一起使用 +CustomFont=false # =================================== # 修复一些潜在的问题 @@ -80,6 +83,9 @@ ForcePaidPlay=false ExtendNotesPool=128 # 强制设置帧率上限为 60 帧并关闭垂直同步。如果你的游戏没有问题,请不要使用 FrameRateLock=false +# 在显示字库里没有的字时使用微软雅黑 Bold 显示 +# 不可以和 CustomFont 一起使用 +FontFix=true [Utils] # 登录时将 UserID 输出到日志 diff --git a/Config.cs b/Config.cs index be04e42a..6c21f836 100644 --- a/Config.cs +++ b/Config.cs @@ -38,6 +38,7 @@ namespace AquaMai public bool LoadLocalBga { get; set; } public bool TestProof { get; set; } public bool HideSelfMadeCharts { get; set; } + public bool CustomFont { get; set; } public string CustomVersionString { get; set; } = ""; public string CustomPlaceName { get; set; } = ""; public string ExecOnIdle { get; set; } = ""; @@ -53,6 +54,7 @@ namespace AquaMai public bool ForcePaidPlay { get; set; } public int ExtendNotesPool { get; set; } public bool FrameRateLock { get; set; } + public bool FontFix { get; set; } } public class UtilsConfig diff --git a/Fix/FontFix.cs b/Fix/FontFix.cs new file mode 100644 index 00000000..400989c7 --- /dev/null +++ b/Fix/FontFix.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using HarmonyLib; +using MelonLoader; +using TMPro; +using UnityEngine; +using UnityEngine.TextCore.LowLevel; + +namespace AquaMai.Fix; + +public class FontFix +{ + private static TMP_FontAsset fontAsset; + private static List fixedFonts = []; + + public static void DoCustomPatch(HarmonyLib.Harmony h) + { + var font = new Font(@"C:\Windows\Fonts\msyhbd.ttc"); + fontAsset = TMP_FontAsset.CreateFontAsset(font, 90, 9, GlyphRenderMode.SDFAA, 8192, 8192); + } + + [HarmonyPatch(typeof(TextMeshProUGUI), "Awake")] + [HarmonyPostfix] + public static void PostFix(TextMeshProUGUI __instance) + { + if (fixedFonts.Contains(__instance.font)) return; +# if DEBUG + MelonLogger.Msg($"[FontFix] Fixing font: {__instance.font.name}"); +# endif + __instance.font.fallbackFontAssetTable.Add(fontAsset); + fixedFonts.Add(__instance.font); + } +} diff --git a/UX/CustomFont.cs b/UX/CustomFont.cs new file mode 100644 index 00000000..d1f03bcb --- /dev/null +++ b/UX/CustomFont.cs @@ -0,0 +1,36 @@ +using System; +using System.IO; +using HarmonyLib; +using MelonLoader; +using TMPro; +using UnityEngine; +using UnityEngine.TextCore.LowLevel; + +namespace AquaMai.UX; + +public class CustomFont +{ + private static TMP_FontAsset fontAsset; + + public static void DoCustomPatch(HarmonyLib.Harmony h) + { + var fontPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", "font.ttf"); + if (!File.Exists(fontPath)) return; + + var font = new Font(fontPath); + + // 不设置成 8192 的话,贴图会用完,剩下的字显示不出来 + fontAsset = TMP_FontAsset.CreateFontAsset(font, 90, 9, GlyphRenderMode.SDFAA, 8192, 8192); + } + + [HarmonyPatch(typeof(TextMeshProUGUI), "Awake")] + [HarmonyPostfix] + public static void PostFix(TextMeshProUGUI __instance) + { + if (fontAsset is null) return; +# if DEBUG + MelonLogger.Msg($"{__instance.font.name} {__instance.text}"); +# endif + __instance.font = fontAsset; + } +} From 49540ce53bbdcb4e133a4c130b9fa18742894af5 Mon Sep 17 00:00:00 2001 From: Clansty Date: Thu, 3 Oct 2024 16:40:51 +0800 Subject: [PATCH 2/7] [F] SinglePlayer without remove mask --- Fix/BasicFix.cs | 16 ++++++++-------- UX/SinglePlayer.cs | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Fix/BasicFix.cs b/Fix/BasicFix.cs index 3a6e10b8..98d33336 100644 --- a/Fix/BasicFix.cs +++ b/Fix/BasicFix.cs @@ -47,14 +47,6 @@ public class BasicFix return false; } - [HarmonyPrefix] - [HarmonyPatch(typeof(NetHttpClient), "CheckServerHash")] - private static bool CheckServerHash(ref bool __result) - { - __result = true; - return false; - } - [HarmonyPrefix] [HarmonyPatch(typeof(GameManager), "CalcSpecialNum")] private static bool CalcSpecialNum(ref int __result) @@ -81,4 +73,12 @@ public class BasicFix break; } } + + [HarmonyPrefix] + [HarmonyPatch(typeof(NetHttpClient), "CheckServerHash")] + private static bool CheckServerHash(ref bool __result) + { + __result = true; + return false; + } } diff --git a/UX/SinglePlayer.cs b/UX/SinglePlayer.cs index 8f419914..476f3ecf 100644 --- a/UX/SinglePlayer.cs +++ b/UX/SinglePlayer.cs @@ -20,6 +20,7 @@ namespace AquaMai.UX { left.transform.position = Vector3.zero; right.localScale = Vector3.zero; + GameObject.Find("Mask").transform.position = new Vector3(540f, 0f, 0f); } [HarmonyPrefix] From ffa173d7a2185ac0af78edcd6daa8e9bace46c7b Mon Sep 17 00:00:00 2001 From: Clansty Date: Thu, 3 Oct 2024 17:05:00 +0800 Subject: [PATCH 3/7] [+] Show play time on PractiseModeUI --- Utils/PractiseModeUI.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Utils/PractiseModeUI.cs b/Utils/PractiseModeUI.cs index 10f89a17..216e47cd 100644 --- a/Utils/PractiseModeUI.cs +++ b/Utils/PractiseModeUI.cs @@ -81,6 +81,9 @@ public class PractiseModeUI : MonoBehaviour GUI.Label(GetButtonRect(1, 2), $"{Locale.Speed} {PractiseMode.speed * 100:000}%"); GUI.Button(GetButtonRect(2, 2), Locale.SpeedUp); GUI.Button(GetButtonRect(1, 3), Locale.SpeedReset); + + GUI.Label(GetButtonRect(0, 3), TimeSpan.FromMilliseconds(DebugFeature.CurrentPlayMsec).ToString(@"mm\:ss\.fff")); + GUI.Label(GetButtonRect(2, 3), TimeSpan.FromMilliseconds(NotesManager.Instance().getPlayFinalMsec()).ToString(@"mm\:ss\.fff")); } public void Update() From b233d72eaac68a92cfc1f56c908b025223efce19 Mon Sep 17 00:00:00 2001 From: Clansty Date: Thu, 3 Oct 2024 20:02:10 +0800 Subject: [PATCH 4/7] [F] Fix text shadow a little bit --- UX/CustomFont.cs | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/UX/CustomFont.cs b/UX/CustomFont.cs index d1f03bcb..94661311 100644 --- a/UX/CustomFont.cs +++ b/UX/CustomFont.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using HarmonyLib; using MelonLoader; using TMPro; @@ -10,6 +12,7 @@ namespace AquaMai.UX; public class CustomFont { + private static Font font; private static TMP_FontAsset fontAsset; public static void DoCustomPatch(HarmonyLib.Harmony h) @@ -17,9 +20,7 @@ public class CustomFont var fontPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", "font.ttf"); if (!File.Exists(fontPath)) return; - var font = new Font(fontPath); - - // 不设置成 8192 的话,贴图会用完,剩下的字显示不出来 + font = new Font(fontPath); fontAsset = TMP_FontAsset.CreateFontAsset(font, 90, 9, GlyphRenderMode.SDFAA, 8192, 8192); } @@ -27,10 +28,44 @@ public class CustomFont [HarmonyPostfix] public static void PostFix(TextMeshProUGUI __instance) { - if (fontAsset is null) return; + if (font is null) return; # if DEBUG MelonLogger.Msg($"{__instance.font.name} {__instance.text}"); # endif + + var materialOrigin = __instance.fontMaterial; + var materialSharedOrigin = __instance.fontSharedMaterial; __instance.font = fontAsset; +# if DEBUG + MelonLogger.Msg($"shaderKeywords {materialOrigin.shaderKeywords.Join()} {__instance.fontMaterial.shaderKeywords.Join()}"); +# endif + // __instance.fontSharedMaterial = materialSharedOrigin; + + // 这样之后该有描边的地方整个字后面都是阴影,它不知道哪里是边 + // materialOrigin.mainTexture = __instance.fontMaterial.mainTexture; + // materialOrigin.mainTextureOffset = __instance.fontMaterial.mainTextureOffset; + // materialOrigin.mainTextureScale = __instance.fontMaterial.mainTextureScale; + // __instance.fontMaterial.CopyPropertiesFromMaterial(materialOrigin); + + // 这样了之后有描边了,但是描边很细 + // __instance.fontMaterial.shader = materialOrigin.shader; + foreach (var keyword in materialOrigin.shaderKeywords) + { + __instance.fontMaterial.EnableKeyword(keyword); + } + // __instance.fontMaterial.globalIlluminationFlags = materialOrigin.globalIlluminationFlags; + + // 原来是 underlay,但是复制这三个属性之后就又变成整个字后面都是阴影了 + // __instance.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayOffsetY, materialOrigin.GetFloat(ShaderUtilities.ID_UnderlayOffsetY)); + // __instance.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayOffsetX, materialOrigin.GetFloat(ShaderUtilities.ID_UnderlayOffsetX)); + // __instance.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayDilate, materialOrigin.GetFloat(ShaderUtilities.ID_UnderlayDilate)); + + // if(materialOrigin.shaderKeywords.Contains(ShaderUtilities.Keyword_Underlay)) + // { + // __instance.fontMaterial.EnableKeyword(ShaderUtilities.Keyword_Glow); + // __instance.fontMaterial.SetFloat(ShaderUtilities.ID_GlowOuter, .5f); + // // __instance.fontMaterial.SetFloat(ShaderUtilities.ID_UnderlayOffsetX, materialOrigin.GetFloat(ShaderUtilities.ID_UnderlayOffsetX)); + // } + } } From 16427e3c80bc0cee396486de9aab1df7173a5593 Mon Sep 17 00:00:00 2001 From: Clansty Date: Thu, 3 Oct 2024 20:51:42 +0800 Subject: [PATCH 5/7] [+] PracticeMode config entry --- AquaMai.toml | 3 +++ AquaMai.zh.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/AquaMai.toml b/AquaMai.toml index d0136c7f..6aed4500 100644 --- a/AquaMai.toml +++ b/AquaMai.toml @@ -90,6 +90,9 @@ Height=0 SelectionDetail=true # Display framerate FrameRateDisplay=false +# Practice mode, activated by pressing Test in the game +# Must be used together with TestProof +PracticeMode=true # =================================== # Save some potentially unnecessary time diff --git a/AquaMai.zh.toml b/AquaMai.zh.toml index 4b137e67..1e4cc113 100644 --- a/AquaMai.zh.toml +++ b/AquaMai.zh.toml @@ -108,6 +108,9 @@ SelectionDetail=true ShowNetErrorDetail=true # 显示帧率 FrameRateDisplay=false +# 练习模式,在游戏中按 Test 打开 +# 必须和 TestProof 一起用 +PracticeMode=true # =================================== # 节省一些不知道有用没用的时间 From 668d862fe07885c2e6467f61e8f4c2378f031ea2 Mon Sep 17 00:00:00 2001 From: Clansty Date: Fri, 4 Oct 2024 00:26:54 +0800 Subject: [PATCH 6/7] [O] update config example --- AquaMai.toml | 40 ++++++++++++++++++++++++++++++++++------ AquaMai.zh.toml | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/AquaMai.toml b/AquaMai.toml index 6aed4500..abf0af21 100644 --- a/AquaMai.toml +++ b/AquaMai.toml @@ -80,12 +80,6 @@ JudgeAdjustA=0.0 JudgeAdjustB=0.0 # Touch screen delay, unit is milliseconds, one second = 1000 milliseconds. Must be an integer TouchDelay=0 -# Window the game -Windowed=false -# Width and height for windowed mode, rendering resolution for fullscreen mode -# If set to 0, windowed mode will remember the user-set size, fullscreen mode will use the current display resolution -Width=0 -Height=0 # Show detail of selected song in music selection screen SelectionDetail=true # Display framerate @@ -114,6 +108,16 @@ SkipTrackStart=true # Show reason when net icon is gray ShowNetErrorDetail=true +[WindowState] +# If not enabled, no operations will be performed on the game window +Enable=false +# Window the game +Windowed=false +# Width and height for windowed mode, rendering resolution for fullscreen mode +# If set to 0, windowed mode will remember the user-set size, fullscreen mode will use the current display resolution +Width=0 +Height=0 + [TouchSensitivity] # Enable custom sensitivity # When enabled, the settings in Test mode will not take effect @@ -159,3 +163,27 @@ E5=20 E6=20 E7=20 E8=20 + +[CustomKeyMap] +Enable = false +# These settings will work regardless of whether you have enabled segatools' io4 emulation +Test = "ScrollLock" +Service = "Pause" +Button1_1P = "W" +Button2_1P = "E" +Button3_1P = "D" +Button4_1P = "C" +Button5_1P = "X" +Button6_1P = "Z" +Button7_1P = "A" +Button8_1P = "Q" +Select_1P = "Alpha3" +Button1_2P = "Keypad8" +Button2_2P = "Keypad9" +Button3_2P = "Keypad6" +Button4_2P = "Keypad3" +Button5_2P = "Keypad2" +Button6_2P = "Keypad1" +Button7_2P = "Keypad4" +Button8_2P = "Keypad7" +Select_2P = "KeypadMultiply" diff --git a/AquaMai.zh.toml b/AquaMai.zh.toml index 1e4cc113..316df68e 100644 --- a/AquaMai.zh.toml +++ b/AquaMai.zh.toml @@ -96,12 +96,6 @@ JudgeAdjustA=0.0 JudgeAdjustB=0.0 # 触摸屏延迟,单位为毫秒,一秒 = 1000 毫秒。必须是整数 TouchDelay=0 -# 窗口化游戏 -Windowed=false -# 宽度和高度窗口化时为游戏窗口大小,全屏时为渲染分辨率 -# 如果设为 0,窗口化将记住用户设定的大小,全屏时将使用当前显示器分辨率 -Width=0 -Height=0 # 选歌界面显示选择的歌曲的详情 SelectionDetail=true # 出现灰网时显示原因 @@ -131,6 +125,16 @@ SkipGameOverScreen=true # 跳过乐曲开始界面 SkipTrackStart=true +[WindowState] +# 不启用的话,不会对游戏窗口做任何操作 +Enable=false +# 窗口化游戏 +Windowed=false +# 宽度和高度窗口化时为游戏窗口大小,全屏时为渲染分辨率 +# 如果设为 0,窗口化将记住用户设定的大小,全屏时将使用当前显示器分辨率 +Width=0 +Height=0 + [TouchSensitivity] # 是否启用自定义灵敏度 # 这里启用之后 Test 里的就不再起作用了 @@ -176,3 +180,27 @@ E5=20 E6=20 E7=20 E8=20 + +[CustomKeyMap] +Enable = false +# 这里的设置无论你是否启用了 segatools 的 io4 模拟都会工作 +Test = "ScrollLock" +Service = "Pause" +Button1_1P = "W" +Button2_1P = "E" +Button3_1P = "D" +Button4_1P = "C" +Button5_1P = "X" +Button6_1P = "Z" +Button7_1P = "A" +Button8_1P = "Q" +Select_1P = "Alpha3" +Button1_2P = "Keypad8" +Button2_2P = "Keypad9" +Button3_2P = "Keypad6" +Button4_2P = "Keypad3" +Button5_2P = "Keypad2" +Button6_2P = "Keypad1" +Button7_2P = "Keypad4" +Button8_2P = "Keypad7" +Select_2P = "KeypadMultiply" From 6d9a83881da527f78fb2d7282f6d719a2bdb41dd Mon Sep 17 00:00:00 2001 From: Clansty Date: Fri, 4 Oct 2024 16:12:14 +0800 Subject: [PATCH 7/7] [F] PractiseMode --- AquaMai.toml | 2 +- AquaMai.zh.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AquaMai.toml b/AquaMai.toml index abf0af21..5bafe809 100644 --- a/AquaMai.toml +++ b/AquaMai.toml @@ -86,7 +86,7 @@ SelectionDetail=true FrameRateDisplay=false # Practice mode, activated by pressing Test in the game # Must be used together with TestProof -PracticeMode=true +PractiseMode=true # =================================== # Save some potentially unnecessary time diff --git a/AquaMai.zh.toml b/AquaMai.zh.toml index 316df68e..bbbdb668 100644 --- a/AquaMai.zh.toml +++ b/AquaMai.zh.toml @@ -104,7 +104,7 @@ ShowNetErrorDetail=true FrameRateDisplay=false # 练习模式,在游戏中按 Test 打开 # 必须和 TestProof 一起用 -PracticeMode=true +PractiseMode=true # =================================== # 节省一些不知道有用没用的时间