-
Notifications
You must be signed in to change notification settings - Fork 1
/
Settings.cs
421 lines (342 loc) · 24.8 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using FormationSorter.Utilities;
using MCM.Abstractions.Attributes;
using MCM.Abstractions.Attributes.v2;
using MCM.Abstractions.Base.Global;
using MCM.Common;
using TaleWorlds.Core;
using TaleWorlds.InputSystem;
namespace FormationSorter;
internal interface ISettings
{
bool AssignFormationCaptains { get; }
bool AssignNewFormationCaptains { get; }
bool AssignPlayerFormationCaptain { get; }
bool UserDefinedFormationClasses { get; }
FormationClass CompanionFormation { get; }
FormationClass Formation1 { get; }
FormationClass Formation2 { get; }
FormationClass Formation3 { get; }
FormationClass Formation4 { get; }
FormationClass Formation5 { get; }
FormationClass Formation6 { get; }
FormationClass Formation7 { get; }
FormationClass Formation8 { get; }
InputKey OrderKey { get; }
InputKey TierSortKey { get; }
InputKey ShieldSortKey { get; }
InputKey SkirmisherSortKey { get; }
InputKey EqualSortKey { get; }
InputKey InverseSelectKey { get; }
InputKey AllSelectKey { get; }
InputKey CavalryMeleeSelectKey { get; }
InputKey CavalryRangedSelectKey { get; }
InputKey GroundMeleeSelectKey { get; }
InputKey GroundRangedSelectKey { get; }
InputKey MeleeSelectKey { get; }
InputKey RangedSelectKey { get; }
InputKey GroundSelectKey { get; }
InputKey CavalrySelectKey { get; }
}
internal class Settings : ISettings
{
private static Settings instance;
private readonly ISettings provider;
private Settings() => provider = CustomSettings.Instance is null ? DefaultSettings.Instance : CustomSettings.Instance;
internal static Settings Instance => instance ??= new();
public bool AssignFormationCaptains => provider.AssignFormationCaptains;
public bool AssignNewFormationCaptains => provider.AssignNewFormationCaptains;
public bool AssignPlayerFormationCaptain => provider.AssignPlayerFormationCaptain;
public bool UserDefinedFormationClasses => provider.UserDefinedFormationClasses;
public FormationClass CompanionFormation => provider.CompanionFormation;
public FormationClass Formation1 => provider.Formation1;
public FormationClass Formation2 => provider.Formation2;
public FormationClass Formation3 => provider.Formation3;
public FormationClass Formation4 => provider.Formation4;
public FormationClass Formation5 => provider.Formation5;
public FormationClass Formation6 => provider.Formation6;
public FormationClass Formation7 => provider.Formation7;
public FormationClass Formation8 => provider.Formation8;
public InputKey OrderKey => provider.OrderKey;
public InputKey TierSortKey => provider.TierSortKey;
public InputKey ShieldSortKey => provider.ShieldSortKey;
public InputKey SkirmisherSortKey => provider.SkirmisherSortKey;
public InputKey EqualSortKey => provider.EqualSortKey;
public InputKey InverseSelectKey => provider.InverseSelectKey;
public InputKey AllSelectKey => provider.AllSelectKey;
public InputKey CavalryMeleeSelectKey => provider.CavalryMeleeSelectKey;
public InputKey CavalryRangedSelectKey => provider.CavalryRangedSelectKey;
public InputKey GroundMeleeSelectKey => provider.GroundMeleeSelectKey;
public InputKey GroundRangedSelectKey => provider.GroundRangedSelectKey;
public InputKey MeleeSelectKey => provider.MeleeSelectKey;
public InputKey RangedSelectKey => provider.RangedSelectKey;
public InputKey GroundSelectKey => provider.GroundSelectKey;
public InputKey CavalrySelectKey => provider.CavalrySelectKey;
}
internal class DefaultSettings : ISettings
{
private static ISettings instance;
internal static ISettings Instance => instance ??= new DefaultSettings();
bool ISettings.AssignFormationCaptains => true;
bool ISettings.AssignNewFormationCaptains => true;
bool ISettings.AssignPlayerFormationCaptain => true;
bool ISettings.UserDefinedFormationClasses => true;
FormationClass ISettings.CompanionFormation => FormationClass.Unset;
FormationClass ISettings.Formation1 => 0;
FormationClass ISettings.Formation2 => (FormationClass)1;
FormationClass ISettings.Formation3 => (FormationClass)2;
FormationClass ISettings.Formation4 => (FormationClass)3;
FormationClass ISettings.Formation5 => (FormationClass)4;
FormationClass ISettings.Formation6 => (FormationClass)5;
FormationClass ISettings.Formation7 => (FormationClass)6;
FormationClass ISettings.Formation8 => (FormationClass)7;
InputKey ISettings.OrderKey => InputKey.X;
InputKey ISettings.TierSortKey => InputKey.L;
InputKey ISettings.ShieldSortKey => InputKey.LeftShift;
InputKey ISettings.SkirmisherSortKey => InputKey.LeftControl;
InputKey ISettings.EqualSortKey => InputKey.LeftAlt;
InputKey ISettings.InverseSelectKey => InputKey.LeftControl;
InputKey ISettings.AllSelectKey => InputKey.F;
InputKey ISettings.CavalryMeleeSelectKey => InputKey.C;
InputKey ISettings.CavalryRangedSelectKey => InputKey.V;
InputKey ISettings.GroundMeleeSelectKey => InputKey.H;
InputKey ISettings.GroundRangedSelectKey => InputKey.J;
InputKey ISettings.MeleeSelectKey => InputKey.Y;
InputKey ISettings.RangedSelectKey => InputKey.U;
InputKey ISettings.GroundSelectKey => InputKey.N;
InputKey ISettings.CavalrySelectKey => InputKey.M;
}
internal class CustomSettings : AttributeGlobalSettings<CustomSettings>, ISettings
{
public override string Id => SubModule.Id;
public override string DisplayName
=> SubModule.Name + " " + new Version(FileVersionInfo.GetVersionInfo(typeof(CustomSettings).Assembly.Location).FileVersion).ToString(3);
public override string FolderName => SubModule.Id;
public override string FormatType => "xml";
[SettingPropertyDropdown("Companions", Order = 1, RequireRestart = false,
HintText = "When set to Default, companions will simply go into the formation they fit in as if they were a normal unit."),
SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> CompanionFormationDropdown { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.CompanionFormation, DropdownHelper.EnumerateRegularFormations(true));
[SettingPropertyDropdown("Formation #1", Order = 2, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown1 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation1, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #2", Order = 3, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown2 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation2, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #3", Order = 4, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown3 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation3, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #4", Order = 5, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown4 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation4, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #5", Order = 6, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown5 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation5, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #6", Order = 7, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown6 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation6, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #7", Order = 8, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown7 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation7, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Formation #8", Order = 9, RequireRestart = false), SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public Dropdown<FormationClassSelection> FormationDropdown8 { get; set; }
= DropdownHelper.FormationClassSelection(DefaultSettings.Instance.Formation8, DropdownHelper.EnumerateRegularFormations());
[SettingPropertyDropdown("Order Key", Order = 1, RequireRestart = false,
HintText
= "Sort Troops Between Formations order menu key; troops in selected formations will be sorted into their single best formation if one of its kind is among the selected formations."),
SettingPropertyGroup("Order", GroupOrder = 2)]
public Dropdown<KeySelection> OrderKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.OrderKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Tier Sort Key", Order = 2, RequireRestart = false,
HintText = "Tier sorting key; all infantry and cavalry troops will be sorted into separate formations by their tiers."),
SettingPropertyGroup("Order", GroupOrder = 2)]
public Dropdown<KeySelection> TierSortKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.TierSortKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Shield Sorting Modifier Key", Order = 3, RequireRestart = false,
HintText
= "When combined with the Order Key shielded infantry get put into the Infantry formation while unshielded infantry get put into the Heavy Infantry formation."),
SettingPropertyGroup("Order", GroupOrder = 2)]
public Dropdown<KeySelection> ShieldSortKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.ShieldSortKey, DropdownHelper.EnumerateModifiers());
[SettingPropertyDropdown("Skirmisher Sorting Modifier Key", Order = 4, RequireRestart = false,
HintText = "When combined with the Order Key javelineers, rock throwers, etc. get put into the Skirmisher formation instead of Infantry."),
SettingPropertyGroup("Order", GroupOrder = 2)]
public Dropdown<KeySelection> SkirmisherSortKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.SkirmisherSortKey, DropdownHelper.EnumerateModifiers());
[SettingPropertyDropdown("Equal Sorting Modifier Key", Order = 5, RequireRestart = false,
HintText
= "When combined with the Order Key troops will be sorted equally amongst the selected formations instead of being put in only their single best formation."),
SettingPropertyGroup("Order", GroupOrder = 2)]
public Dropdown<KeySelection> EqualSortKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.EqualSortKey, DropdownHelper.EnumerateModifiers());
[SettingPropertyDropdown("Inverse Selection Modifier Key", Order = 6, RequireRestart = false,
HintText
= "When combined with any of the selection keys below, the formations it encompasses will be inverted from their current state, potentially being added or removed from the current selection."),
SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> InverseSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.InverseSelectKey, DropdownHelper.EnumerateModifiers());
[SettingPropertyDropdown("Select All Formations Key", Order = 7, RequireRestart = false, HintText = "This key will select all formations."),
SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> AllSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.AllSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Melee Cavalry Formations Key", Order = 8, RequireRestart = false,
HintText = "This key will select all melee cavalry formations: Cavalry, Light Cavalry, Heavy Cavalry."),
SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> MeleeCavalrySelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.CavalryMeleeSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Ranged Cavalry Formations Key", Order = 9, RequireRestart = false,
HintText = "This key will select all ranged cavalry formations: Horse Archers."), SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> RangedCavalrySelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.CavalryRangedSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Melee Ground Formations Key", Order = 10, RequireRestart = false,
HintText = "This key will select all melee ground formations: Infantry, Heavy Infantry."), SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> GroundMeleeSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.GroundMeleeSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Ranged Ground Formations Key", Order = 11, RequireRestart = false,
HintText = "This key will select all ranged ground formations: Archers, Skirmishers."), SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> GroundRangedSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.GroundRangedSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Melee Formations Key", Order = 12, RequireRestart = false,
HintText = "This key will select all melee formations: Infantry, Cavalry, Heavy Infantry."), SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> MeleeSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.MeleeSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Ranged Formations Key", Order = 13, RequireRestart = false,
HintText = "This key will select all ranged formations: Archers, Skirmishers, Horse Archers."), SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> RangedSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.RangedSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Cavalry Formations Key", Order = 14, RequireRestart = false,
HintText = "This key will select all cavalry formations: Cavalry, Light Cavalry, Heavy Cavalry, Horse Archers."),
SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> CavalrySelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.CavalrySelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyDropdown("Select All Ground Formations Key", Order = 15, RequireRestart = false,
HintText = "This key will select all ground formations: Infantry, Heavy Infantry, Archers, Skirmishers."),
SettingPropertyGroup("Selection", GroupOrder = 3)]
public Dropdown<KeySelection> GroundSelectKeyDropdown { get; set; }
= DropdownHelper.KeySelection(DefaultSettings.Instance.GroundSelectKey, DropdownHelper.EnumerateKeys());
[SettingPropertyBool("Assign Formation Captains", IsToggle = true, Order = 0, RequireRestart = false,
HintText = "Whether or not to assign the best companions as captains over formations."),
SettingPropertyGroup("Assign Formation Captains", GroupOrder = 0)]
public bool AssignFormationCaptains { get; set; } = DefaultSettings.Instance.AssignFormationCaptains;
[SettingPropertyBool("Assign New Formation Captains", Order = 0, RequireRestart = false,
HintText = "Whether or not to freely assign the best companions as captains, or to only use the captains assigned during deployment."),
SettingPropertyGroup("Assign Formation Captains", GroupOrder = 0)]
public bool AssignNewFormationCaptains { get; set; } = DefaultSettings.Instance.AssignNewFormationCaptains;
[SettingPropertyBool("Assign Player Formation Captain", Order = 0, RequireRestart = false,
HintText = "Whether or not to include the player in the list of prospective formation captains."
+ "\nNOTE: The 'Assign New Formation Captains' setting is still taken into account for the player!"),
SettingPropertyGroup("Assign Formation Captains", GroupOrder = 0)]
public bool AssignPlayerFormationCaptain { get; set; } = DefaultSettings.Instance.AssignPlayerFormationCaptain;
[SettingPropertyBool("User-Defined Formation Classes", IsToggle = true, Order = 1, RequireRestart = false,
HintText = "Whether or not to use the user-defined formation classes below in place of the default dynamic formation classes. (highly recommended)"),
SettingPropertyGroup("User-Defined Formation Classes", GroupOrder = 1)]
public bool UserDefinedFormationClasses { get; set; } = DefaultSettings.Instance.UserDefinedFormationClasses;
FormationClass ISettings.CompanionFormation => CompanionFormationDropdown.SelectedValue?.FormationClass ?? DefaultSettings.Instance.CompanionFormation;
FormationClass ISettings.Formation1 => FormationDropdown1.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation1;
FormationClass ISettings.Formation2 => FormationDropdown2.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation2;
FormationClass ISettings.Formation3 => FormationDropdown3.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation3;
FormationClass ISettings.Formation4 => FormationDropdown4.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation4;
FormationClass ISettings.Formation5 => FormationDropdown5.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation5;
FormationClass ISettings.Formation6 => FormationDropdown6.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation6;
FormationClass ISettings.Formation7 => FormationDropdown7.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation7;
FormationClass ISettings.Formation8 => FormationDropdown8.SelectedValue?.FormationClass ?? DefaultSettings.Instance.Formation8;
InputKey ISettings.OrderKey => OrderKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.OrderKey;
InputKey ISettings.TierSortKey => TierSortKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.TierSortKey;
InputKey ISettings.ShieldSortKey => ShieldSortKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.ShieldSortKey;
InputKey ISettings.SkirmisherSortKey => SkirmisherSortKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.SkirmisherSortKey;
InputKey ISettings.EqualSortKey => EqualSortKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.EqualSortKey;
InputKey ISettings.InverseSelectKey => InverseSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.InverseSelectKey;
InputKey ISettings.AllSelectKey => AllSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.AllSelectKey;
InputKey ISettings.CavalryMeleeSelectKey => MeleeCavalrySelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.CavalryMeleeSelectKey;
InputKey ISettings.CavalryRangedSelectKey => RangedCavalrySelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.CavalryRangedSelectKey;
InputKey ISettings.GroundMeleeSelectKey => GroundMeleeSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.GroundMeleeSelectKey;
InputKey ISettings.GroundRangedSelectKey => GroundRangedSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.GroundRangedSelectKey;
InputKey ISettings.MeleeSelectKey => MeleeSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.MeleeSelectKey;
InputKey ISettings.RangedSelectKey => RangedSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.RangedSelectKey;
InputKey ISettings.CavalrySelectKey => CavalrySelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.CavalrySelectKey;
InputKey ISettings.GroundSelectKey => GroundSelectKeyDropdown.SelectedValue?.Key ?? DefaultSettings.Instance.GroundSelectKey;
#pragma warning disable IDE0051
[SettingPropertyBool("S1", Order = 16, RequireRestart = false, HintText = "Spacer for dropdown menus. Blame Aragasas."),
SettingPropertyGroup("Spacers", GroupOrder = 4)]
private bool S1 { get => false; set { } }
[SettingPropertyBool("S2", Order = 17, RequireRestart = false, HintText = "Spacer for dropdown menus. Blame Aragasas."),
SettingPropertyGroup("Spacers", GroupOrder = 4)]
private bool S2 { get => false; set { } }
[SettingPropertyBool("S3", Order = 18, RequireRestart = false, HintText = "Spacer for dropdown menus. Blame Aragasas."),
SettingPropertyGroup("Spacers", GroupOrder = 4)]
private bool S3 { get => false; set { } }
[SettingPropertyBool("S4", Order = 19, RequireRestart = false, HintText = "Spacer for dropdown menus. Blame Aragasas."),
SettingPropertyGroup("Spacers", GroupOrder = 4)]
private bool S4 { get => false; set { } }
[SettingPropertyBool("S5", Order = 20, RequireRestart = false, HintText = "Spacer for dropdown menus. Blame Aragasas."),
SettingPropertyGroup("Spacers", GroupOrder = 4)]
private bool S5 { get => false; set { } }
#pragma warning restore IDE0051
}
internal class FormationClassSelection
{
internal readonly FormationClass? FormationClass;
internal readonly string Name;
internal FormationClassSelection(FormationClass? formationClass, string name = null)
{
FormationClass = formationClass;
Name = name;
}
public override string ToString() => Name ?? (FormationClass is null ? "None" : FormationClass.Value.GetGameTextString());
}
internal class KeySelection
{
internal readonly InputKey? Key;
internal KeySelection(InputKey? key) => Key = key;
public override string ToString() => Key is null or InputKey.Invalid ? "None" : Key.ToString();
}
internal static class DropdownHelper
{
internal static Dropdown<FormationClassSelection> FormationClassSelection(FormationClass defaultFormationClass,
IEnumerable<FormationClassSelection> formationClasses)
{
Dropdown<FormationClassSelection> dropdown = new(formationClasses, 0);
dropdown.SelectedIndex = dropdown.FindIndex(s => s.FormationClass == defaultFormationClass);
return dropdown;
}
internal static IEnumerable<FormationClassSelection> EnumerateRegularFormations(bool includeUnset = false)
{
if (includeUnset)
yield return new(FormationClass.Unset, "Default");
foreach (string name in Enum.GetNames(typeof(FormationClass)))
if (!name.StartsWith("NumberOf") && Enum.TryParse(name, false, out FormationClass formationClass)
&& formationClass < FormationClass.NumberOfRegularFormations)
yield return new(formationClass);
}
internal static Dropdown<KeySelection> KeySelection(InputKey defaultKey, IEnumerable<KeySelection> keys)
{
Dropdown<KeySelection> dropdown = new(keys, 0);
dropdown.SelectedIndex = dropdown.FindIndex(s => s.Key == defaultKey);
return dropdown;
}
private static IEnumerable<int> Range(int from, int to) => Enumerable.Range(from, 1 + to - from);
internal static IEnumerable<KeySelection> EnumerateKeys()
{
yield return new(InputKey.Invalid);
foreach (int i in Range(16, 27)) // Q to ]
yield return new((InputKey)i);
foreach (int i in Range(30, 40)) // A to '
yield return new((InputKey)i);
foreach (int i in Range(44, 53)) // Z to /
yield return new((InputKey)i);
}
internal static IEnumerable<KeySelection> EnumerateModifiers()
{
yield return new(InputKey.Invalid);
yield return new(InputKey.LeftControl);
yield return new(InputKey.LeftShift);
yield return new(InputKey.LeftAlt);
yield return new(InputKey.RightControl);
yield return new(InputKey.RightShift);
yield return new(InputKey.RightAlt);
}
}