-
Notifications
You must be signed in to change notification settings - Fork 4
/
Settings.cs
80 lines (70 loc) · 2.96 KB
/
Settings.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
using BlueprintCore.Utils;
using Kingmaker.Localization;
using ModMenu.Settings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityModManagerNet;
using Menu = ModMenu.ModMenu;
namespace MoreCantrips
{
class Settings
{
private const string RootKey = "morecantrips.settings";
private static readonly string RootStringKey = "MoreCantrips.Settings";
internal static bool IsEnabled(string key)
{
return Menu.GetSettingValue<bool>(GetKey(key.ToLower()));
}
private static string GetKey(string partialKey)
{
return ($"{RootKey}.{partialKey}").ToLower();
}
internal static bool IsCharOpsPlusEnabled()
{
return UnityModManager.modEntries.Where(
mod => mod.Info.Id.Equals("CharacterOptionsPlus") && mod.Enabled && !mod.ErrorOnLoading)
.Any();
}
internal static bool IsLevelableAivuEnabled()
{
return UnityModManager.modEntries.Where(
mod => mod.Info.Id.Equals("LevelableAivu") && mod.Enabled && !mod.ErrorOnLoading)
.Any();
}
internal static bool ScalingOn()
{
return UnityModManager.modEntries.Where(
mod => mod.Info.Id.Equals("PhoenixCantrips") && mod.Enabled && !mod.ErrorOnLoading)
.Any() && Menu.GetSettingValue<bool>(GetKey("phoenixcantrips.settings.scaling"));
}
public static void Make()
{
LocalizationTool.LoadLocalizationPack("Mods\\MoreCantrips\\Localization\\Settings.json");
LocalizationTool.LoadLocalizationPack("Mods\\MoreCantrips\\Localization\\LocalizedStrings.json");
var builder = SettingsBuilder.New(RootKey, GetString("Title"));
builder.AddToggle(MakeToggle("Firebolt", true, true));
builder.AddToggle(MakeToggle("BurningTouch", true, true));
builder.AddToggle(MakeToggle("PainfulNote", true, true));
builder.AddToggle(MakeToggle("DissonantTouch", true, true));
builder.AddToggle(MakeToggle("LesserCorrosiveTouch", true, true));
builder.AddToggle(MakeToggle("LesserShockingGrasp", true, true));
builder.AddToggle(MakeToggle("FrostyTouch", true, true));
ModMenu.ModMenu.AddSettings(builder);
}
private static LocalizedString GetString(string key, bool usePrefix = true)
{
var fullKey = usePrefix ? $"{RootStringKey}.{key}" : key;
return LocalizationTool.GetString(fullKey);
}
private static Toggle MakeToggle(string keyStub, bool defaultVal, bool desc = true)
{
var toggle = Toggle.New($"{RootKey}.{keyStub.ToLower()}", defaultVal, GetString(keyStub));
if (desc)
toggle.WithLongDescription(GetString($"{keyStub}.Desc"));
return toggle;
}
}
}