mirror of https://github.com/hykilpikonna/AquaDX
[O] enforce type for SetEntryValue and some comment and type chore
parent
e3b06b110f
commit
da36ef4002
|
@ -6,7 +6,7 @@ public interface IConfig
|
||||||
{
|
{
|
||||||
public interface IEntryState
|
public interface IEntryState
|
||||||
{
|
{
|
||||||
public bool IsDefault { get; set; }
|
public bool IsDefault { get; }
|
||||||
public object DefaultValue { get; }
|
public object DefaultValue { get; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class Config : IConfig
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Null default value for entry {entry.Path} is not allowed.");
|
throw new InvalidOperationException($"Null default value for entry {entry.Path} is not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
entries.Add(entry.Path, new EntryState()
|
entries.Add(entry.Path, new EntryState()
|
||||||
{
|
{
|
||||||
IsDefault = true,
|
IsDefault = true,
|
||||||
|
@ -75,6 +76,7 @@ public class Config : IConfig
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"Type {type.FullName} is not a config section.");
|
throw new ArgumentException($"Type {type.FullName} is not a config section.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections[section.Path];
|
return sections[section.Path];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,8 +93,13 @@ public class Config : IConfig
|
||||||
|
|
||||||
public void SetEntryValue(IReflectionManager.IEntry entry, object value)
|
public void SetEntryValue(IReflectionManager.IEntry entry, object value)
|
||||||
{
|
{
|
||||||
|
if (value.GetType() != entry.Field.FieldType)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Value type {value.GetType().FullName} does not match entry type {entry.Field.FieldType.FullName}.");
|
||||||
|
}
|
||||||
|
|
||||||
entry.Field.SetValue(null, value);
|
entry.Field.SetValue(null, value);
|
||||||
entries[entry.Path].IsDefault = false;
|
entries[entry.Path].IsDefault = false;
|
||||||
entries[entry.Path].Value = value;
|
entries[entry.Path].Value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ public class JudgeAdjust
|
||||||
[ConfigEntry(
|
[ConfigEntry(
|
||||||
en: "Increase touch delay.",
|
en: "Increase touch delay.",
|
||||||
zh: "增加触摸延迟")]
|
zh: "增加触摸延迟")]
|
||||||
private static readonly int touchDelay = 0;
|
private static readonly uint touchDelay = 0;
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(UserOption), "GetAdjustMSec")]
|
[HarmonyPatch(typeof(UserOption), "GetAdjustMSec")]
|
||||||
|
@ -45,6 +45,6 @@ public class JudgeAdjust
|
||||||
public static void NewTouchPanelRecv()
|
public static void NewTouchPanelRecv()
|
||||||
{
|
{
|
||||||
if (touchDelay <= 0) return;
|
if (touchDelay <= 0) return;
|
||||||
Thread.Sleep(touchDelay);
|
Thread.Sleep((int)touchDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace AquaMai.Mods.GameSystem;
|
||||||
Not recommand to enable when SinglePlayer is off.
|
Not recommand to enable when SinglePlayer is off.
|
||||||
""",
|
""",
|
||||||
zh: """
|
zh: """
|
||||||
去除游戏中的倒计时(隐藏并设为 65535 秒)
|
去除并隐藏游戏中的倒计时
|
||||||
没有开启单人模式时,不建议启用
|
没有开启单人模式时,不建议启用
|
||||||
""")]
|
""")]
|
||||||
public class DisableTimeout
|
public class DisableTimeout
|
||||||
|
|
Loading…
Reference in New Issue