-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppSettings.cs
80 lines (66 loc) · 2.58 KB
/
AppSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
global using static HellDivers2OneKeyStratagem.SettingsContainer;
using System.Text.Json.Serialization;
using Avalonia.Controls;
namespace HellDivers2OneKeyStratagem;
public class AppSettings
{
public static readonly string ExePath = Environment.ProcessPath!;
public static readonly string ExeFileName = Path.GetFileNameWithoutExtension(ExePath);
public static readonly string ExeDirectory = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string SettingsDirectory = Path.Combine(ExeDirectory, "Settings");
public static readonly string SettingsFile = Path.Combine(SettingsDirectory, "Settings.json");
public static readonly string DataDirectory = Path.Combine(ExeDirectory, "Data");
private static readonly JsonFile<AppSettings> _settingsFile = new(SettingsFile);
public static void Load()
{
var settings = _settingsFile.Load();
if (settings != null)
Settings = settings;
}
public static async Task LoadAsync()
{
var settings = await _settingsFile.LoadAsync();
if (settings != null)
Settings = settings;
}
public static void Save()
{
if (Design.IsDesignMode)
return;
_settingsFile.Save(Settings);
}
public static async Task SaveAsync()
{
if (Design.IsDesignMode)
return;
await _settingsFile.SaveAsync(Settings);
}
public string TriggerKey { get; set; } = "Ctrl";
public string OperateKeys { get; set; } = "WASD";
public bool PlayVoice { get; set; } = true;
public string VoiceName { get; set; } = "晓妮";
public bool EnableSpeechTrigger { get; set; }
public bool EnableSetKeyBySpeech { get; set; }
public List<string> StratagemSets { get; set; } = [];
public string SpeechLocale { get; set; } = "";
[JsonIgnore]
public string SpeechLanguage
{
get
{
var sepPos = SpeechLocale.IndexOf('-');
return sepPos > 0
? SpeechLocale[..sepPos]
: SpeechLocale;
}
}
public string Locale { get; set; } = "";
public double VoiceConfidence { get; set; } = 0.6f;
public string WakeupWord { get; set; } = "";
public bool EnableHotkeyTrigger { get; set; } = true;
public string UpdateUrl { get; set; } = "https://github.com/tifish/HellDivers2OneKeyStratagem/releases/download/latest_release/HellDivers2OneKeyStratagem.7z";
}
public static class SettingsContainer
{
public static AppSettings Settings = new();
}