/// <summary> /// Call this during your mod's Load method /// </summary> /// <param name="mod"></param> public static ModSetting CreateModSettingConfig(Mod mod) { ModSetting settings = new ModSetting(mod); settings.AddToModSettings(); return(settings); }
public override void Load() { Mods = new List <Mod>(); if (Main.dedServ) { return; } modSettingsUI = new ModSettingsUI(); modUserInterface = new UserInterface(); modUserInterface.SetState(modSettingsUI); modSettings = new List <ModSetting>(); ControlModSettings = RegisterHotKey("Open Mod Settings", "Oem8"); // The ` key modSettingsUI.Activate(); ModSetting setting = ModSettingsAPI.CreateModSettingConfig(this); // setting.EnableAutoConfig(this); setting.AddComment("This is a barebones framework for modifying supported in-game settings! "); setting.AddBool("isday", "Day Time", true); setting.AddDouble("dayticks", "Current Time", 0, Main.dayLength, true); setting.AddFloat("modifyWidth", "Modify Config Width", 700, 2000, false); setting.AddComment("Version " + this.Version); }
/// <summary> /// Call with your mod to get the ModSettings /// </summary> /// <param name="mod"></param> /// <param name="modSetting"></param> /// <returns></returns> public static bool TryGetModSetting(Mod mod, out ModSetting modSetting) { modSetting = TModSettings.GetModSetting(mod); if (modSetting != null) { return(true); } return(false); }
private void ModListOnClick(UIMouseEvent evt, UIElement listeningElement) { // Make all mod entry buttons that aren't the one activated, non-active // and trigger the mouse up method to reset state accordingly. _settingsContainer.Clear(); _basePanel.RemoveChild(_settingsPanel); ActiveModSetting = null; foreach (UIModEntry me in _modListElements) { if (!me.Equals(listeningElement)) { // Disable other active mod panels me.Active = false; me.MouseUp(evt); } else if (me.Active) { // Clear and re-add the list based from open mod, sorted by index _settingsContainer.AddRange(me.modSetting.GetUIElements()); _settingsContainer.UpdateOrder(); ActiveModSetting = me.modSetting; } if (ActiveModSetting == null && me.Active) { ActiveModSetting = me.modSetting; } } // Restore settings panel if something's open if (ActiveModSetting != null) { _basePanel.Append(_settingsPanel); } }