diff --git a/src/MaaWpfGui/Helper/ConfigurationHelper.cs b/src/MaaWpfGui/Helper/ConfigurationHelper.cs index 1e5c2373a7..3f26bb370f 100644 --- a/src/MaaWpfGui/Helper/ConfigurationHelper.cs +++ b/src/MaaWpfGui/Helper/ConfigurationHelper.cs @@ -72,6 +72,18 @@ namespace MaaWpfGui.Helper return defaultValue; } + /// + /// Get a configuration value + /// + /// The config key + /// The default value to return if the key is not existed + /// The config value + public static int GetValue(string key, int defaultValue) + { + var value = GetValue(key, defaultValue.ToString()); + return int.TryParse(value, out var result) ? result : defaultValue; + } + public static string GetGlobalValue(string key, string defaultValue) { var hasValue = _globalKvs.TryGetValue(key, out var value); @@ -148,6 +160,8 @@ namespace MaaWpfGui.Helper return result; } + public static bool ContainsKey(string key, bool isGlobal = false) => isGlobal ? _globalKvs.ContainsKey(key) : _kvs.ContainsKey(key); + /// /// Deletes a configuration ///