[+] Some font features
Build AquaMai / build (SDEZ) (push) Has been cancelled Details
Build AquaMai / build (SDGA145) (push) Has been cancelled Details

pull/56/head
Clansty 2024-10-02 23:28:33 +08:00
parent bae5a7c838
commit ac375abf5e
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
6 changed files with 84 additions and 0 deletions

View File

@ -298,6 +298,7 @@ DEBUG</DefineConstants>
<Compile Include="Fix\ExtendNotesPool.cs" />
<Compile Include="Fix\FixCharaCrash.cs" />
<Compile Include="Fix\FixCheckAuth.cs" />
<Compile Include="Fix\FontFix.cs" />
<Compile Include="Fix\ForceAsServer.cs" />
<Compile Include="Fix\ForceFreePlay.cs" />
<Compile Include="Fix\ForcePaidPlay.cs" />
@ -332,6 +333,7 @@ DEBUG</DefineConstants>
<Compile Include="Utils\PractiseModeUI.cs" />
<Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\ShowNetErrorDetail.cs" />
<Compile Include="UX\CustomFont.cs" />
<Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" />
<Compile Include="UX\DemoMaster.cs" />

View File

@ -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

View File

@ -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 输出到日志

View File

@ -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

View File

@ -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<TMP_FontAsset> 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);
}
}

View File

@ -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;
}
}