-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModSettingsChecker.cs
More file actions
776 lines (631 loc) · 28.6 KB
/
Copy pathModSettingsChecker.cs
File metadata and controls
776 lines (631 loc) · 28.6 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
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.UserInterfaceWindows;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;
using UnityEngine;
// ReSharper disable UnusedMethodReturnValue.Global
namespace Game.Mods.ModSettingsChecker
{
public class ModSettingsChecker
{
private static class ParseHelper
{
public static bool TryInt(string s, out int value, string type, string section, string key)
{
if (int.TryParse(s, out value))
return true;
Debug.LogWarning($"[ModSettingsChecker] Failed to parse int '{s}' for '{section}/{key}' (type: {type}).");
return false;
}
public static bool TryFloat(string s, out float value, string type, string section, string key)
{
if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
return true;
Debug.LogWarning(
$"[Mod Settings Checker] Failed to parse float '{s}' for '{section}/{key}' (type: {type}).");
return false;
}
}
private string _modName;
private readonly Dictionary<string, Mod> _cachedModsByGuid = new Dictionary<string, Mod>();
private readonly Dictionary<string, Mod> _cachedModsByName = new Dictionary<string, Mod>();
private readonly Dictionary<string, string> _existErrorMessages = new Dictionary<string, string>();
private readonly List<string> _errorMessages = new List<string>();
private static FieldInfo fieldInfo;
public static ModSettingsChecker Create()
{
return new ModSettingsChecker();
}
public static void CheckFromCsv(Mod self, string csvName)
{
ModSettingsChecker modChecker = Create().Init(self.Title);
var settingsToCheck = self.GetAsset<TextAsset>(csvName);
if(settingsToCheck)
modChecker.CheckFromCsv(settingsToCheck);
else
Debug.LogError($"{csvName} not found in mod assets!");
}
public ModSettingsChecker Init(string nameOfMod)
{
_modName = nameOfMod;
ClearAll();
DaggerfallStartWindow.OnStartFirstVisible += DaggerfallStartWindow_OnStartFirstVisible;
return this;
}
private void ClearAll()
{
_cachedModsByGuid.Clear();
_cachedModsByName.Clear();
_errorMessages.Clear();
_existErrorMessages.Clear();
}
private void DaggerfallStartWindow_OnStartFirstVisible()
{
foreach (var lines in _errorMessages.Select(errors => WrapText(errors)))
{
lines.Insert(0, $"Warning from {_modName} mod:");
ShowMessageBox(lines.ToArray());
}
foreach (var lines in _existErrorMessages.Select(errors => WrapText(errors.Value)))
{
lines.Insert(0, $"Warning from {_modName} mod:");
ShowMessageBox(lines.ToArray());
}
DaggerfallStartWindow.OnStartFirstVisible -= DaggerfallStartWindow_OnStartFirstVisible;
ClearAll();
}
public void CheckFromCsv(TextAsset csvAsset)
{
string[] lines = csvAsset.text.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
foreach (string line in lines.Skip(1)) // Skip header
{
if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) continue;
string[] fields = line.Split(',');
if (fields.Length < 6)
{
continue;
}
string modGuid = fields[0].Trim();
string section = fields[1].Trim();
string key = fields[2].Trim();
string type = fields[3].Trim().ToLower();
string expectedValue = fields[4].Trim();
string errorMessage = fields[5].Trim();
bool modExists = Check(modGuid, settings =>
{
switch (type)
{
case "bool":
settings.Toggle(section, key, expectedValue.ToLower() == "true", errorMessage);
break;
case "int":
if (ParseHelper.TryInt(expectedValue, out int intVal1, type, section, key))
settings.SliderIntEqual(section, key, intVal1, errorMessage);
break;
case "int.less":
if (ParseHelper.TryInt(expectedValue, out int intVal2, type, section, key))
settings.SliderIntLess(section, key, intVal2, errorMessage);
break;
case "int.greater":
if (ParseHelper.TryInt(expectedValue, out int intVal3, type, section, key))
settings.SliderIntGreater(section, key, intVal3, errorMessage);
break;
case "int.tuple.first.equal":
if (ParseHelper.TryInt(expectedValue, out int intVal4, type, section, key))
settings.TupleIntFirstEqual(section, key, intVal4, errorMessage);
break;
case "int.tuple.second.equal":
if (ParseHelper.TryInt(expectedValue, out int intVal5, type, section, key))
settings.TupleIntSecondEqual(section, key, intVal5, errorMessage);
break;
case "int.tuple.first.less":
if (ParseHelper.TryInt(expectedValue, out int intVal6, type, section, key))
settings.TupleIntFirstLess(section, key, intVal6, errorMessage);
break;
case "int.tuple.second.less":
if (ParseHelper.TryInt(expectedValue, out int intVal7, type, section, key))
settings.TupleIntSecondLess(section, key, intVal7, errorMessage);
break;
case "int.tuple.first.greater":
if (ParseHelper.TryInt(expectedValue, out int intVal8, type, section, key))
settings.TupleIntFirstGreater(section, key, intVal8, errorMessage);
break;
case "int.tuple.second.greater":
if (ParseHelper.TryInt(expectedValue, out int intVal9, type, section, key))
settings.TupleIntSecondGreater(section, key, intVal9, errorMessage);
break;
case "float":
if (ParseHelper.TryFloat(expectedValue, out float floatVal1, type, section, key))
settings.SliderFloatEqual(section, key, floatVal1, errorMessage);
break;
case "float.less":
if (ParseHelper.TryFloat(expectedValue, out float floatVal2, type, section, key))
settings.SliderFloatLess(section, key, floatVal2, errorMessage);
break;
case "float.greater":
if (ParseHelper.TryFloat(expectedValue, out float floatVal3, type, section, key))
settings.SliderFloatGreater(section, key, floatVal3, errorMessage);
break;
case "float.tuple.first.equal":
if (ParseHelper.TryFloat(expectedValue, out float floatVal4, type, section, key))
settings.TupleFloatFirstEqual(section, key, floatVal4, errorMessage);
break;
case "float.tuple.second.equal":
if (ParseHelper.TryFloat(expectedValue, out float floatVal5, type, section, key))
settings.TupleFloatSecondEqual(section, key, floatVal5, errorMessage);
break;
case "float.tuple.first.less":
if (ParseHelper.TryFloat(expectedValue, out float floatVal6, type, section, key))
settings.TupleFloatFirstLess(section, key, floatVal6, errorMessage);
break;
case "float.tuple.second.less":
if (ParseHelper.TryFloat(expectedValue, out float floatVal7, type, section, key))
settings.TupleFloatSecondLess(section, key, floatVal7, errorMessage);
break;
case "float.tuple.first.greater":
if (ParseHelper.TryFloat(expectedValue, out float floatVal8, type, section, key))
settings.TupleFloatFirstGreater(section, key, floatVal8, errorMessage);
break;
case "float.tuple.second.greater":
if (ParseHelper.TryFloat(expectedValue, out float floatVal9, type, section, key))
settings.TupleFloatSecondGreater(section, key, floatVal9, errorMessage);
break;
case "choice.equal":
if (ParseHelper.TryInt(expectedValue, out int intVal10, type, section, key))
settings.MultipleChoiceEqual(section, key, intVal10, errorMessage);
break;
case "choice.not.equal":
if (ParseHelper.TryInt(expectedValue, out int intVal11, type, section, key))
settings.MultipleChoiceNotEqual(section, key, intVal11, errorMessage);
break;
case "string.equal":
settings.TextEqual(section, key, expectedValue, errorMessage);
break;
case "string.not.equal":
settings.TextNotEqual(section, key, expectedValue, errorMessage);
break;
case "string.lower":
settings.TextEqualToLower(section, key, expectedValue.ToLower(), errorMessage);
break;
case "string.lower.not":
settings.TextNotEqualToLower(section, key, expectedValue.ToLower(), errorMessage);
break;
case "string.contains":
settings.TextContains(section, key, expectedValue, errorMessage);
break;
case "string.contains.not":
settings.TextNotContains(section, key, expectedValue, errorMessage);
break;
case "string.contains.lower":
settings.TextContainsToLower(section, key, expectedValue.ToLower(), errorMessage);
break;
case "string.contains.lower.not":
settings.TextNotContainsToLower(section, key, expectedValue.ToLower(), errorMessage);
break;
case "exists":
//Ignore it, it is checked differently
break;
default:
Debug.LogWarning(
$"[Mod Settings Checker] Unknown setting type '{type}' in CSV for setting '{section}/{key}'.");
break;
}
});
if (!modExists && !_existErrorMessages.ContainsKey(modGuid) && type == "exists")
_existErrorMessages.Add(modGuid,errorMessage);
}
}
public bool Check(Mod mod, Action<ModSettingsRequirement> action)
{
if(!_cachedModsByGuid.ContainsKey(mod.GUID))
_cachedModsByGuid.Add(mod.GUID, mod);
return CheckInternal(mod, action);
}
// ReSharper disable once MemberCanBePrivate.Global
public bool Check(string modGuidOrName, Action<ModSettingsRequirement> action)
{
Mod mod = TryGetMod(modGuidOrName);
return mod != null && CheckInternal(mod, action);
}
private bool CheckInternal(Mod mod, Action<ModSettingsRequirement> action)
{
var req = new ModSettingsRequirement(this, mod.GetSettings());
action(req);
return true;
}
private Mod TryGetMod(string modGuidOrName)
{
if (!_cachedModsByGuid.TryGetValue(modGuidOrName, out Mod mod))
{
_cachedModsByName.TryGetValue(modGuidOrName, out mod);
}
if (mod != null)
return mod;
mod = ModManager.Instance.GetModFromGUID(modGuidOrName);
if (mod != null)
{
_cachedModsByGuid.Add(modGuidOrName, mod);
return mod;
}
mod = ModManager.Instance.GetModFromName(modGuidOrName);
if (mod != null)
{
_cachedModsByName.Add(modGuidOrName, mod);
return mod;
}
return null;
}
public void AddUiErrorMessage(string message)
{
_errorMessages.Add(message);
}
private static List<string> WrapText(string input, int maxLineLength = 50)
{
var lines = new List<string>();
if (string.IsNullOrWhiteSpace(input))
return lines;
string[] rawLines = input.Split('\n');
foreach (string rawLine in rawLines)
{
string[] words = rawLine.Trim().Split(' ');
var currentLine = new StringBuilder();
foreach (string word in words)
{
if (currentLine.Length + word.Length + 1 > maxLineLength)
{
lines.Add(currentLine.ToString().TrimEnd());
currentLine.Clear();
}
currentLine.Append(word + " ");
}
if (currentLine.Length > 0)
{
lines.Add(currentLine.ToString().TrimEnd());
}
}
return lines;
}
private static void ShowMessageBox(string[] lines)
{
var messageBox = new DaggerfallMessageBox(DaggerfallUI.UIManager);
messageBox.SetText(lines);
messageBox.ParentPanel.BackgroundColor = Color.clear;
messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Accept);
messageBox.OnButtonClick += (sender, button) => { messageBox.CloseWindow(); };
messageBox.Show();
}
[Obsolete("This method is intended for debugging purposes only. Remove in production code.")]
public static void ShowAllModSettings(string modGuidOrName)
{
Mod mod = ModManager.Instance.GetModFromGUID(modGuidOrName);
if (mod == null)
{
mod = ModManager.Instance.GetModFromName(modGuidOrName);
if (mod == null)
return;
}
ModSettings modSettings = mod.GetSettings();
if (fieldInfo == null)
fieldInfo = typeof(ModSettings).GetField("data", BindingFlags.NonPublic | BindingFlags.Instance);
var data = (ModSettingsData)fieldInfo?.GetValue(modSettings);
if (data != null)
{
Debug.Log($"[Mod Settings Checker] Settings for mod {mod.Title}:");
foreach (Section s in data.Sections)
{
foreach (Key k in s.Keys)
{
string value = null;
switch (k.KeyType)
{
case KeyType.Color:
value = modSettings.GetColor(s.Name, k.Name).ToString();
break;
case KeyType.MultipleChoice:
value = modSettings.GetValue<int>(s.Name, k.Name).ToString();
break;
case KeyType.SliderFloat:
value = modSettings.GetValue<float>(s.Name, k.Name)
.ToString(CultureInfo.InvariantCulture);
break;
case KeyType.SliderInt:
value = modSettings.GetValue<int>(s.Name, k.Name).ToString();
break;
case KeyType.Text:
value = modSettings.GetValue<string>(s.Name, k.Name);
break;
case KeyType.Toggle:
value = modSettings.GetValue<bool>(s.Name, k.Name).ToString();
break;
case KeyType.TupleFloat:
value = modSettings.GetTupleFloat(s.Name, k.Name).ToString();
break;
case KeyType.TupleInt:
value = modSettings.GetTupleInt(s.Name, k.Name).ToString();
break;
default:
Debug.LogWarning($"[Mod Settings Checker] Unknown key type '{k.KeyType}' for '{s.Name}/{k.Name}'.");
break;
}
Debug.Log($"[Mod Settings Checker] Section = '{s.Name}', Key = '{k.Name}', Type = '{k.KeyType}' | Value = '{value}'.");
}
}
}
else
{
Debug.LogError($"[Mod Settings Checker] Failed to get ModSettingsData for mod {mod.Title}.");
}
}
}
public class ModSettingsRequirement
{
private readonly ModSettings _settings;
private readonly ModSettingsChecker _instance;
public ModSettingsRequirement(ModSettingsChecker instance, ModSettings settings)
{
_settings = settings;
_instance = instance;
}
public ModSettingsRequirement Toggle(string section, string key, bool expected, string errorMessage)
{
if (_settings.GetBool(section, key) == expected)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderIntLess(string section, string key, int maxValue, string errorMessage)
{
if (_settings.GetInt(section, key) < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderIntGreater(string section, string key, int minValue, string errorMessage)
{
if (_settings.GetInt(section, key) > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderIntEqual(string section, string key, int expectedValue, string errorMessage)
{
if (_settings.GetInt(section, key) == expectedValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderFloatLess(string section, string key, float maxValue, string errorMessage)
{
if (_settings.GetFloat(section, key) < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderFloatGreater(string section, string key, float minValue,
string errorMessage)
{
if (_settings.GetFloat(section, key) > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement SliderFloatEqual(string section, string key, float expectedValue,
string errorMessage)
{
if (Mathf.Approximately(_settings.GetFloat(section, key), expectedValue))
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntFirstEqual(string section, string key, int expectedValue,
string errorMessage)
{
if (_settings.GetTupleInt(section, key).First == expectedValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntSecondEqual(string section, string key, int expectedValue,
string errorMessage)
{
if (_settings.GetTupleInt(section, key).Second == expectedValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntFirstLess(string section, string key, int maxValue, string errorMessage)
{
if (_settings.GetTupleInt(section, key).First < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntSecondLess(string section, string key, int maxValue, string errorMessage)
{
if (_settings.GetTupleInt(section, key).Second < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntFirstGreater(string section, string key, int minValue,
string errorMessage)
{
if (_settings.GetTupleInt(section, key).First > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleIntSecondGreater(string section, string key, int minValue,
string errorMessage)
{
if (_settings.GetTupleInt(section, key).Second > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatFirstEqual(string section, string key, float expectedValue,
string errorMessage)
{
if (Mathf.Approximately(_settings.GetTupleFloat(section, key).First, expectedValue))
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatSecondEqual(string section, string key, float expectedValue,
string errorMessage)
{
if (Mathf.Approximately(_settings.GetTupleFloat(section, key).Second, expectedValue))
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatFirstLess(string section, string key, float maxValue,
string errorMessage)
{
if (_settings.GetTupleFloat(section, key).First < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatSecondLess(string section, string key, float maxValue,
string errorMessage)
{
if (_settings.GetTupleFloat(section, key).Second < maxValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatFirstGreater(string section, string key, float minValue,
string errorMessage)
{
if (_settings.GetTupleFloat(section, key).First > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TupleFloatSecondGreater(string section, string key, float minValue,
string errorMessage)
{
if (_settings.GetTupleFloat(section, key).Second > minValue)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement MultipleChoiceEqual(string section, string key, int expectedChoice,
string errorMessage)
{
if (_settings.GetValue<int>(section, key) == expectedChoice)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement MultipleChoiceNotEqual(string section, string key, int notExpectedChoice,
string errorMessage)
{
if (_settings.GetValue<int>(section, key) != notExpectedChoice)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextEqual(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key) == text)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextNotEqual(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key) != text)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextEqualToLower(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key)?.ToLower() == text)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextNotEqualToLower(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key)?.ToLower() != text)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextContains(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key)?.Contains(text) == true)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextNotContains(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key)?.ToLower().Contains(text) == false)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextContainsToLower(string section, string key, string text, string errorMessage)
{
if (_settings.GetString(section, key)?.ToLower().Contains(text) == true)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement TextNotContainsToLower(string section, string key, string text,
string errorMessage)
{
if (_settings.GetString(section, key)?.ToLower().Contains(text) == false)
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
public ModSettingsRequirement Custom(Func<ModSettings, bool> check, string errorMessage)
{
if (check(_settings))
{
_instance.AddUiErrorMessage(errorMessage);
}
return this;
}
}
}