-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
86 lines (73 loc) · 2.5 KB
/
Config.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
81
82
83
84
85
86
using System.IO;
using MelonLoader;
using MelonLoader.Preferences;
namespace GbHapticsIntegration
{
internal static class Config
{
internal static I_General General = null;
internal static I_HapticDevices HapticDevices = null;
internal static I_HapticEffects HapticEffects = null;
internal class I_General
{
private static MelonPreferences_ReflectiveCategory Category = null;
internal static void Init()
=> General = SetupCategory<I_General>(ref Category, nameof(General));
internal bool Allow_Player_Communication = true;
}
internal class I_HapticDevices
{
private static MelonPreferences_ReflectiveCategory Category = null;
internal static void Init()
=> HapticDevices = SetupCategory<I_HapticDevices>(ref Category, nameof(HapticDevices));
internal bool Head = true;
internal bool VestFront = true;
internal bool VestBack = true;
internal bool HandL = true;
internal bool HandR = true;
internal bool ArmL = true;
internal bool ArmR = true;
}
internal class I_HapticEffects
{
private static MelonPreferences_ReflectiveCategory Category = null;
internal static void Init()
=> HapticEffects = SetupCategory<I_HapticEffects>(ref Category, nameof(HapticEffects));
internal bool Blunt = true;
internal bool Cut = true;
internal bool DrawString = true;
internal bool Gong = true;
internal bool HeartBeat = true;
internal bool PlayerDamage = true;
internal bool PlayerDamage_Arrow = true;
internal bool Shoot = true;
internal bool ShootString = true;
internal bool Stab = true;
internal bool Surprise = true;
internal bool Wobble = true;
}
internal static T SetupCategory<T>(ref MelonPreferences_ReflectiveCategory category, string categoryName, string folderPath = null, string fileName = "Config") where T : new()
{
if (category == null)
{
string FolderPath = GbHapticsIntegration.BaseUserDataDirectory;
if (!string.IsNullOrEmpty(folderPath))
FolderPath = Path.Combine(FolderPath, folderPath);
if (!Directory.Exists(FolderPath))
Directory.CreateDirectory(FolderPath);
string FilePath = Path.Combine(FolderPath, $"{fileName}.cfg");
category = MelonPreferences.CreateCategory<T>(categoryName);
#if DEBUG
category.SetFilePath(FilePath, Debug.Config_Load, Debug.Config_PrintMsg);
#else
category.SetFilePath(FilePath, true, false);
#endif
category.SaveToFile(false);
#if DEBUG
Debug.LogConfigRegister(categoryName, FilePath);
#endif
}
return category.GetValue<T>();
}
}
}