Repository navigation
Expand file tree
/
Copy pathBetterOptions.cs
More file actions
139 lines (121 loc) · 5.4 KB
/
Copy pathBetterOptions.cs
File metadata and controls
139 lines (121 loc) · 5.4 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using CUCoreLib.Data;
using CUCoreLib.Registries;
using UnityEngine;
namespace Bark.BetterCCL;
public static class BetterOptions
{
private static string CategoryString(Setting.SettingCategory category)
{
return category.ToString().ToLowerInvariant();
}
private static string MakeId(string ns, Setting.SettingCategory category, string key)
{
return $"{ns}.{CategoryString(category)}.{key}";
}
private static string MakeId(string ns, string customCategory, string key)
{
return $"{ns}.{customCategory.ToLowerInvariant().Replace(" ", "_")}.{key}";
}
private static string LabelText(string ns, Setting.SettingCategory category,
string key)
{
return MakeId(ns, category, key);
}
private static string LabelText(string ns, string customCategory, string key)
{
return MakeId(ns, customCategory.ToLowerInvariant().Replace(" ", "_"), key);
}
private static string DescriptionText(string ns, Setting.SettingCategory category,
string key)
{
return $"{MakeId(ns, category, key)}dsc";
}
private static string DescriptionText(string ns, string customCategory, string key)
{
return
$"{MakeId(ns, customCategory.ToLowerInvariant().Replace(" ", "_"), key)}dsc";
}
public static void Float(string ns, string key, Setting.SettingCategory category,
float defaultValue, float min, float max,
Action<float>? apply = null, Func<float, string>? formatValue = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Float(
MakeId(ns, category, key), LabelText(ns, category, key),
DescriptionText(ns, category, key),
category, defaultValue, min, max, apply, formatValue));
}
public static void Int(string ns, string key, Setting.SettingCategory category,
int defaultValue, int min, int max, Action<int>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Int(
MakeId(ns, category, key), LabelText(ns, category, key),
DescriptionText(ns, category, key),
category, defaultValue, min, max, apply));
}
public static void Bool(string ns, string key, Setting.SettingCategory category,
bool defaultValue, Action<bool>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Bool(
MakeId(ns, category, key), LabelText(ns, category, key),
DescriptionText(ns, category, key),
category, defaultValue, apply));
}
public static void Dropdown(string ns, string key, Setting.SettingCategory category,
int defaultValue, ModDropdownChoice[] choices, Action<int>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Dropdown(
MakeId(ns, category, key), LabelText(ns, category, key),
DescriptionText(ns, category, key),
category, defaultValue, choices, apply));
}
public static void Keybind(string ns, string key, Setting.SettingCategory category,
KeyCode defaultValue, Action<KeyCode>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Keybind(
MakeId(ns, category, key), LabelText(ns, category, key),
DescriptionText(ns, category, key),
category, defaultValue, apply));
}
public static void Float(string ns, string key, string customCategory,
float defaultValue, float min, float max,
Action<float>? apply = null, Func<float, string>? formatValue = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Float(
MakeId(ns, customCategory, key), LabelText(ns, customCategory, key),
DescriptionText(ns, customCategory, key),
customCategory, defaultValue, min, max, apply, formatValue));
}
public static void Int(string ns, string key, string customCategory,
int defaultValue, int min, int max, Action<int>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Int(
MakeId(ns, customCategory, key), LabelText(ns, customCategory, key),
DescriptionText(ns, customCategory, key),
customCategory, defaultValue, min, max, apply));
}
public static void Bool(string ns, string key, string customCategory,
bool defaultValue, Action<bool>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Bool(
MakeId(ns, customCategory, key), LabelText(ns, customCategory, key),
DescriptionText(ns, customCategory, key),
customCategory, defaultValue, apply));
}
public static void Dropdown(string ns, string key, string customCategory,
int defaultValue, ModDropdownChoice[] choices, Action<int>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Dropdown(
MakeId(ns, customCategory, key), LabelText(ns, customCategory, key),
DescriptionText(ns, customCategory, key),
customCategory, defaultValue, choices, apply));
}
public static void Keybind(string ns, string key, string customCategory,
KeyCode defaultValue, Action<KeyCode>? apply = null)
{
ModOptionsRegistry.Register(ModOptionDefinition.Keybind(
MakeId(ns, customCategory, key), LabelText(ns, customCategory, key),
DescriptionText(ns, customCategory, key),
customCategory, defaultValue, apply));
}
}