Skip to content
Merged

[+] ? #103

Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .config/dotnet-tools.json

This file was deleted.

5 changes: 4 additions & 1 deletion AquaMai.Config/ConfigSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ 这是 AquaMai 的 TOML 配置文件
- 该文件的格式和文字注释是固定的,配置文件将在启动时被重写,无法解析的内容将被删除

试试使用 MaiChartManager 图形化配置 AquaMai 吧!
https://github.com/clansty/MaiChartManager
https://github.com/MuNET-OSS/MaiChartManager
""";

private const string BANNER_EN =
Expand All @@ -43,6 +43,9 @@ This is the TOML configuration file of AquaMai.
- Configuration entries take effect when the corresponding section is enabled, regardless of whether they are uncommented.
- Commented configuration entries retain their default values (shown in the comment), which may change with version updates.
- The format and text comments of this file are fixed. The configuration file will be rewritten at startup, and unrecognizable content will be deleted.

Try using MaiChartManager to configure AquaMai graphically!
https://github.com/MuNET-OSS/MaiChartManager
""";

private readonly IConfigSerializer.Options Options = Options;
Expand Down
1 change: 1 addition & 0 deletions AquaMai.Config/Migration/ConfigMigrationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ConfigMigrationManager : IConfigMigrationManager
new ConfigMigration_V2_0_V2_1(),
new ConfigMigration_V2_1_V2_2(),
new ConfigMigration_V2_2_V2_3(),
new ConfigMigration_V2_3_V2_4(),
}.ToDictionary(m => m.FromVersion);

public string LatestVersion { get; }
Expand Down
73 changes: 73 additions & 0 deletions AquaMai.Config/Migration/ConfigMigration_V2_3_V2_4.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using AquaMai.Config.Interfaces;
using Tomlet.Models;

namespace AquaMai.Config.Migration;

public class ConfigMigration_V2_3_V2_4 : IConfigMigration
{
public string FromVersion => "2.3";
public string ToVersion => "2.4";

public ConfigView Migrate(ConfigView src)
{
var dst = (ConfigView)src.Clone();
dst.SetValue("Version", ToVersion);

if (src.TryGetValue<bool>("GameSystem.KeyMap.DisableIO4", out var disableIO4))
{
dst.SetValue("GameSystem.KeyMap.DisableIO4_1P", disableIO4);
dst.SetValue("GameSystem.KeyMap.DisableIO4_2P", disableIO4);
dst.SetValue("GameSystem.KeyMap.DisableIO4System", disableIO4);
dst.Remove("GameSystem.KeyMap.DisableIO4");
}

if (src.IsSectionEnabled("GameSystem.SkipBoardNoCheck"))
{
dst.EnsureDictionary("GameSystem.OldCabLightBoardSupport");
dst.Remove("GameSystem.SkipBoardNoCheck");
}

if (src.TryGetValue<bool>("GameSystem.MaimollerIO.P1", out var mml1p))
{
dst.SetValue("GameSystem.MaimollerIO.Touch1p", mml1p);
dst.SetValue("GameSystem.MaimollerIO.Button1p", mml1p);
dst.SetValue("GameSystem.MaimollerIO.Led1p", mml1p);
dst.Remove("GameSystem.MaimollerIO.P1");
}

if (src.TryGetValue<bool>("GameSystem.MaimollerIO.P2", out var mml2p))
{
dst.SetValue("GameSystem.MaimollerIO.Touch2p", mml2p);
dst.SetValue("GameSystem.MaimollerIO.Button2p", mml2p);
dst.SetValue("GameSystem.MaimollerIO.Led2p", mml2p);
dst.Remove("GameSystem.MaimollerIO.P2");
}

if (src.TryGetValue<bool>("GameSystem.AdxHidInput.Io4Compact", out var adxDisableButtons))
{
dst.SetValue("GameSystem.AdxHidInput.DisableButtons", adxDisableButtons);
dst.Remove("GameSystem.AdxHidInput.Io4Compact");
}

if (src.IsSectionEnabled("GameSystem.UnstableRate"))
{
dst.EnsureDictionary("Utils.UnstableRate");
dst.Remove("GameSystem.UnstableRate");
}

if (src.IsSectionEnabled("Fancy.CustomSkinsPlusStatic"))
{
dst.EnsureDictionary("Fancy.ResourcesOverride");
dst.Remove("Fancy.CustomSkinsPlusStatic");
}

if (src.IsSectionEnabled("Fancy.RsOverride"))
{
dst.EnsureDictionary("Fancy.ResourcesOverride");
dst.Remove("Fancy.RsOverride");
}

return dst;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace AquaMai.Mods.Fancy;
name: "力大砖飞",
en: "[Dangerous] Full-scene texture / sprite replacement. Static injection.",
zh: "【危险功能】适用于便捷魔改的自定义全场景图片。警告:可能对游戏造成未知性能影响,可能与其他模组冲突?")]
public class CustomSkinsPlusStatic
public class ResourcesOverride
{
[ConfigEntry(name: "资源目录")]
private static string skinsDir = "LocalAssets/ResourcesOverride";
Expand Down
6 changes: 3 additions & 3 deletions AquaMai.Mods/GameSystem/AdxHidInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static void OnBeforeEnableCheck()
if (adxController[i] == null) continue;
TdInit(i);
if (adxController[i].Attributes.ProductId is 0x5767 or 0x5768) continue;
if (io4Compact) continue;
if (disableButtons) continue;
keyEnabled = true;
var p = i;
Thread hidThread = new Thread(() => HidInputThread(p));
Expand Down Expand Up @@ -168,8 +168,8 @@ private static bool IsButtonPushed(int playerNo, int buttonIndex1To8)
[ConfigEntry(name: "按钮 4(最下方的圆形按键)")]
private static readonly IOKeyMap button4 = IOKeyMap.Test;

[ConfigEntry("IO4 兼容模式", zh: "如果你不知道这是什么,请勿开启", hideWhenDefault: true)]
private static readonly bool io4Compact = false;
[ConfigEntry("禁用外键输入")]
private static readonly bool disableButtons = false;

private static AuxiliaryState GetAuxiliaryState()
{
Expand Down
60 changes: 44 additions & 16 deletions AquaMai.Mods/GameSystem/KeyMap.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Reflection;
using AMDaemon;
using AquaMai.Config.Attributes;
Expand All @@ -24,7 +25,7 @@ DebugInput 与 IO4(兼容 IO4 板 / segatools IO4 模拟)独立工作。
public class KeyMap
{
[ConfigEntry(
name: "禁用 IO4",
name: "禁用 IO4(1P)",
en: """
Disable IO4 (IO4-compatible board / segatools IO4 emulation) input.
With IO4 input disabled, your IO4-compatible board or segatools IO4 emulation is ignored.
Expand All @@ -33,7 +34,19 @@ Disable IO4 (IO4-compatible board / segatools IO4 emulation) input.
禁用 IO4(兼容 IO4 板 / segatools IO4 模拟)输入。
在禁用 IO4 输入后,你的兼容 IO4 板或 segatools IO4 模拟将被忽略。
""")]
private static readonly bool disableIO4 = false;
private static readonly bool disableIO4_1P = false;
[ConfigEntry("禁用 IO4(2P)")]
private static readonly bool disableIO4_2P = false;

[ConfigEntry(
name: "禁用 IO4(系统按键)",
en: """
System buttons (test, service) input.
""",
zh: """
禁用系统按键的 IO4 输入,输入源同上。
""")]
private static readonly bool disableIO4System = false;

[ConfigEntry(
name: "禁用 DebugInput",
Expand All @@ -59,30 +72,45 @@ 禁用 DebugFeature Polyfill 的快捷键,比如说回车暂停,左右键快
""")]
public static readonly bool disableDebugFeatureHotkeys = false; // Implemented in DebugFeature

[EnableIf(nameof(disableIO4))]
private static bool DisableIO4 => disableIO4_1P || disableIO4_2P || disableIO4System;
private static List<SwitchInput> disabledSwitchInputs = [];

[EnableIf(nameof(DisableIO4))]
[HarmonyPatch("IO.Jvs+JvsSwitch", ".ctor", MethodType.Constructor, [typeof(int), typeof(string), typeof(KeyCode), typeof(bool), typeof(bool)])]
[HarmonyPrefix]
public static void PreJvsSwitchConstructor(ref bool invert)
[HarmonyPostfix]
public static void PostJvsSwitchConstructor(ref bool ____invert, int playerNo, bool systemButton, SwitchInput ____switchInput)
{
invert = false;
if ((systemButton && disableIO4System) || (playerNo == 0 && disableIO4_1P) || (playerNo == 1 && disableIO4_2P))
{
____invert = false;
disabledSwitchInputs.Add(____switchInput);
}
}

[EnableIf(nameof(disableIO4))]
[HarmonyPatch(typeof(SwitchInput), "get_IsOn")]
[EnableIf(nameof(DisableIO4))]
[HarmonyPatch(typeof(SwitchInput), nameof(SwitchInput.IsOn), MethodType.Getter)]
[HarmonyPrefix]
public static bool PreGetIsOn(ref bool __result)
public static bool PreGetIsOn(ref bool __result, SwitchInput __instance)
{
__result = false;
return false;
if (disabledSwitchInputs.Contains(__instance))
{
__result = false;
return false;
}
return true;
}

[EnableIf(nameof(disableIO4))]
[HarmonyPatch(typeof(SwitchInput), "get_HasOnNow")]
[EnableIf(nameof(DisableIO4))]
[HarmonyPatch(typeof(SwitchInput), nameof(SwitchInput.HasOnNow), MethodType.Getter)]
[HarmonyPrefix]
public static bool PreGetHasOnNow(ref bool __result)
public static bool PreGetHasOnNow(ref bool __result, SwitchInput __instance)
{
__result = false;
return false;
if (disabledSwitchInputs.Contains(__instance))
{
__result = false;
return false;
}
return true;
}

[ConfigEntry]
Expand Down
Loading