[RF] AquaMai configuration refactor (#82)

更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用)
旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们

Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default)
Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
This commit is contained in:
Menci
2024-11-25 01:25:19 +08:00
committed by GitHub
parent e9ee31b22a
commit 37044dae01
217 changed files with 6051 additions and 3040 deletions

View File

@@ -0,0 +1,49 @@
using AquaMai.Config.Attributes;
using AquaMai.Core.Attributes;
using HarmonyLib;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: "Set the game to Paid Play (lock credits) or Free Play.",
zh: "设置游戏为付费游玩(锁定可用点数)或免费游玩")]
public class CreditConfig
{
[ConfigEntry(
en: "Set to Free Play (set to false for Paid Play).",
zh: "是否免费游玩(设为 false 时为付费游玩)")]
private static readonly bool isFreePlay = true;
[HarmonyPrefix]
[HarmonyPatch(typeof(Manager.Credit), "IsFreePlay")]
private static bool PreIsFreePlay(ref bool __result)
{
__result = isFreePlay;
return false;
}
[ConfigEntry(
en: "Lock credits amount (only valid in Paid Play). Set to 0 to disable.",
zh: "锁定可用点数数量(仅在付费游玩时有效),设为 0 以禁用")]
private static readonly uint lockCredits = 24;
private static bool ShouldLockCredits => !isFreePlay && lockCredits > 0;
[EnableIf(nameof(ShouldLockCredits))]
[HarmonyPrefix]
[HarmonyPatch(typeof(Manager.Credit), "IsGameCostEnough")]
private static bool PreIsGameCostEnough(ref bool __result)
{
__result = true;
return false;
}
[EnableIf(nameof(ShouldLockCredits))]
[HarmonyPrefix]
[HarmonyPatch(typeof(AMDaemon.CreditUnit), "Credit", MethodType.Getter)]
private static bool PreCredit(ref uint __result)
{
__result = 24;
return false;
}
}

View File

@@ -0,0 +1,27 @@
using AMDaemon;
using AquaMai.Config.Attributes;
using HarmonyLib;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: "If you want to configure in-shop party-link, you should turn this off.",
zh: "如果要配置店内招募的话,应该要把这个关闭")]
public class ForceAsServer
{
[HarmonyPrefix]
[HarmonyPatch(typeof(LanInstall), "IsServer", MethodType.Getter)]
private static bool PreIsServer(ref bool __result)
{
__result = true;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Network), "IsLanAvailable", MethodType.Getter)]
private static bool PreIsLanAvailable(ref bool __result)
{
__result = false;
return false;
}
}

View File

@@ -0,0 +1,50 @@
using System.Threading;
using AquaMai.Config.Attributes;
using HarmonyLib;
using IO;
using Manager.UserDatas;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: "Globally adjust A/B judgment (unit same as in-game options) or increase touch delay.",
zh: "全局调整 A/B 判(单位和游戏里一样)或增加触摸延迟")]
public class JudgeAdjust
{
[ConfigEntry(
en: "Adjust A judgment.",
zh: "调整 A 判")]
private static readonly double a = 0;
[ConfigEntry(
en: "Adjust B judgment.",
zh: "调整 B 判")]
private static readonly double b = 0;
[ConfigEntry(
en: "Increase touch delay.",
zh: "增加触摸延迟")]
private static readonly int touchDelay = 0;
[HarmonyPostfix]
[HarmonyPatch(typeof(UserOption), "GetAdjustMSec")]
public static void GetAdjustMSec(ref float __result)
{
__result += (float)(a * 16.666666d);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(UserOption), "GetJudgeTimingFrame")]
public static void GetJudgeTimingFrame(ref float __result)
{
__result += (float)b;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(NewTouchPanel), "Recv")]
public static void NewTouchPanelRecv()
{
if (touchDelay <= 0) return;
Thread.Sleep(touchDelay);
}
}

View File

@@ -0,0 +1,5 @@
# GameSettings
Overriding or adjusting the game settings that're originally configurable / modifiable, but made into patches for unification, flexibility or convenience.
Patches changing the way the game running / behaving which are not possible in the stock game may need to go to the GameSystem category.

View File

@@ -0,0 +1,154 @@
using System.Collections.Generic;
using System.Reflection;
using AquaMai.Config.Attributes;
using HarmonyLib;
using IO;
using Manager;
using MelonLoader;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: """
Use custom touch sensitivity.
When enabled, the settings in Test mode will not take effect.
When disabled, the settings in Test mode is used.
Sensitivity adjustments in Test mode are not linear.
Default sensitivity in area A: 90, 80, 70, 60, 50, 40, 30, 26, 23, 20, 10.
Default sensitivity in other areas: 70, 60, 50, 40, 30, 20, 15, 10, 5, 1, 1.
A setting of 0 in Test mode corresponds to 40, 20 here, -5 corresponds to 90, 70, +5 corresponds to 10, 1.
The higher the number in Test mode, the lower the number here, resulting in higher sensitivity for official machines.
For ADX, the sensitivity is reversed, so the higher the number here, the higher the sensitivity.
""",
zh: """
使用自定义触摸灵敏度
这里启用之后 Test 里的就不再起作用了
这里禁用之后就还是用 Test 里的调
在 Test 模式下调整的灵敏度不是线性的
A 区默认灵敏度 90, 80, 70, 60, 50, 40, 30, 26, 23, 20, 10
其他区域默认灵敏度 70, 60, 50, 40, 30, 20, 15, 10, 5, 1, 1
Test 里设置的 0 对应的是 40, 20 这一档,-5 是 90, 70+5 是 10, 1
Test 里的数字越大,这里的数字越小,对于官机来说,灵敏度更大
而 ADX 的灵敏度是反的,所以对于 ADX这里的数字越大灵敏度越大
""")]
public class TouchSensitivity
{
[ConfigEntry]
private static readonly byte A1 = 40;
[ConfigEntry]
private static readonly byte A2 = 40;
[ConfigEntry]
private static readonly byte A3 = 40;
[ConfigEntry]
private static readonly byte A4 = 40;
[ConfigEntry]
private static readonly byte A5 = 40;
[ConfigEntry]
private static readonly byte A6 = 40;
[ConfigEntry]
private static readonly byte A7 = 40;
[ConfigEntry]
private static readonly byte A8 = 40;
[ConfigEntry]
private static readonly byte B1 = 20;
[ConfigEntry]
private static readonly byte B2 = 20;
[ConfigEntry]
private static readonly byte B3 = 20;
[ConfigEntry]
private static readonly byte B4 = 20;
[ConfigEntry]
private static readonly byte B5 = 20;
[ConfigEntry]
private static readonly byte B6 = 20;
[ConfigEntry]
private static readonly byte B7 = 20;
[ConfigEntry]
private static readonly byte B8 = 20;
[ConfigEntry]
private static readonly byte C1 = 20;
[ConfigEntry]
private static readonly byte C2 = 20;
[ConfigEntry]
private static readonly byte D1 = 20;
[ConfigEntry]
private static readonly byte D2 = 20;
[ConfigEntry]
private static readonly byte D3 = 20;
[ConfigEntry]
private static readonly byte D4 = 20;
[ConfigEntry]
private static readonly byte D5 = 20;
[ConfigEntry]
private static readonly byte D6 = 20;
[ConfigEntry]
private static readonly byte D7 = 20;
[ConfigEntry]
private static readonly byte D8 = 20;
[ConfigEntry]
private static readonly byte E1 = 20;
[ConfigEntry]
private static readonly byte E2 = 20;
[ConfigEntry]
private static readonly byte E3 = 20;
[ConfigEntry]
private static readonly byte E4 = 20;
[ConfigEntry]
private static readonly byte E5 = 20;
[ConfigEntry]
private static readonly byte E6 = 20;
[ConfigEntry]
private static readonly byte E7 = 20;
[ConfigEntry]
private static readonly byte E8 = 20;
[HarmonyPrefix]
[HarmonyPatch(typeof(NewTouchPanel), "SetTouchPanelSensitivity")]
public static void SetTouchPanelSensitivityPrefix(List<byte> sensitivity)
{
var configType = typeof(TouchSensitivity);
for (var i = 0; i < 34; i++)
{
var area = (InputManager.TouchPanelArea)i;
var field = configType.GetField(area.ToString(), BindingFlags.NonPublic | BindingFlags.Static);
var value = (byte)field.GetValue(null);
sensitivity[i] = value;
}
MelonLogger.Msg("[TouchSensitivity] Applied");
}
}