forked from Cookies_Github_mirror/AquaDX
[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:
49
AquaMai/AquaMai.Mods/GameSettings/CreditConfig.cs
Normal file
49
AquaMai/AquaMai.Mods/GameSettings/CreditConfig.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user