-
Notifications
You must be signed in to change notification settings - Fork 2
/
ExampleModuleSettings.cs
66 lines (51 loc) · 2.77 KB
/
ExampleModuleSettings.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
// https://github.com/EverestAPI/Resources/wiki/Your-First-Code-Mod#mod-settings-session-and-save-data
using Microsoft.Xna.Framework.Input;
using YamlDotNet.Serialization;
namespace Celeste.Mod.Example {
// If no SettingName is applied, it defaults to
// modoptions_[typename without settings]_title
// The value is then used to look up the UI text in the dialog files.
// If no dialog text can be found, Everest shows a prettified mod name instead.
[SettingName("modoptions_examplemodule_title")]
public class ExampleModuleSettings : EverestModuleSettings {
// SettingName also works on props, defaulting to
// modoptions_[typename without settings]_[propname]
// Example ON / OFF property with a default value.
public bool ExampleSwitch { get; set; } = false;
[SettingIgnore] // Hide from the options menu, but still load / save it.
public string ExampleHidden { get; set; } = "";
[SettingRange(0, 10)] // Allow choosing a value from 0 (inclusive) to 10 (inclusive).
public int ExampleSlider { get; set; } = 5;
[SettingRange(0, 100, largeRange: true)] // Setting largeRange to true makes this use the more efficient IntSlider
[SettingInGame(false)] // Only show this in the main menu.
public int ExampleMainMenuSlider { get; set; } = 5;
[SettingRange(0, 10)]
[SettingInGame(true)] // Only show this in the in-game menu.
public int ExampleInGameSlider { get; set; } = 5;
[YamlIgnore] // Don't load / save it, but show it in the options menu.
[SettingNeedsRelaunch] // Tell the user to restart for changes to take effect.
public bool LaunchInDebugMode {
get {
return Settings.Instance.LaunchInDebugMode;
}
set {
Settings.Instance.LaunchInDebugMode = value;
}
}
// Example string property. Selecting it will show a file naming-like menu.
// Max length defaults to 12 if the attribute is not set.
[SettingMaxLength(40)]
public string ExampleString { get; set; } = "test";
[SettingNumberInput(allowNegatives: false, maxLength: 3)]
public float ExampleNumEntry { get; set; } = 15f;
[DefaultButtonBinding(Buttons.A, Keys.A)]
public ButtonBinding ExampleButton { get; set; }
public int SomethingWeird { get; set; } = 42;
// Custom entry creation methods are always called Create[propname]Entry
// and offer an alternative to overriding CreateModMenuSection in your module class.
public void CreateSomethingWeirdEntry(TextMenu menu, bool inGame) {
// Create your own menu entry here.
// Maybe you want to create a toggle for an int property?
}
}
}