This repository was archived by the owner on Oct 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
ModSettings
dani0105 edited this page Apr 13, 2022
·
2 revisions
This class handles the Keybinding buttons in the settings menu. You can also load your configuration and store it.
This class can only be used in or after the load()
method in your mod.
There are not events for this class.
Name | Description |
---|---|
main | Main instance of ModSettings. Use this to load settings or add the Keybidings buttons. |
TextPrefab | This prefab is used to add text in the settings menu |
SpacePrefab | This prefab is used to add space in the settings menu |
KeybindingPrefab | This prefab is used to add keybinding buttons in the settings menu |
KeybindingsHolder | This transforms keep all keybiding buttons. |
void addKeybinding( KeybindingsPC.Key
key, KeybindingsPC.Key
defaultKey, string
name, SFSSettings modSettings);
This method adds simple hotkey buttons in the settings menu
ModSettings.main.addKeybinding( MyLoadedSettings.My_Key, MyDefaultSettings.My_Key, "My_Key", MyLoadedSettings);
void addKeybinding( KeybindingsPC.Key[]
key, KeybindingsPC.Key[]
defaultKey, string
name, SFSSettings modSettings);
This method adds multiple hotkey buttons in the settings menu
ModSettings.main.addKeybinding( MyLoadedSettings.My_Key, MyDefaultSettings.My_Key, "My_Key", MyLoadedSettings);
This method add text in the settings menu
ModSettings.main.addText("My Text");
This function resets all mod keybindings
ModSettings.main.resetKeybindings();
This method loads the mod's keybindings.
MySettings currentSettings = ModSettings.main.loadSettings<MySettings>(MyMod);
// My Main mod class
public class MyMod: SFSMod
{
public static MyMod main;
// My current mod settings.
public MySettings mySettings;
// ModID, Mod Name, Author, Mod Loader, Mod Version
public MyMod() : base("myID","My Mod", "Me", "1.3.x", "v1.0.0")
{
main = this;
}
public override void load()
{
// Add Mod Name in settigs menu
ModSettings.main.addText(this.Name);
MySettings defaultKeys = new MySettings();
this.mySettings = ModSettings.main.loadSettings<MySettings>(this); // load my settings
ModSettings.main.addKeybinding(this.mySettings.MyKey, defaultKeys.MyKey, "My_key", this.mySettings);
}
}
// My Settings class
public class MySettings : SFSSettings
{
// key definition
public KeybindingsPC.Key MyKey = KeyCode.T;
public string getModId()
{
return MyMod.main.ModId;
}
}
- Modloader Installation
- Mods Installation
- How to develop mods
- Code Documentation