private void GenerateOptions(ModOptions options, ModConfig config) { var enableDrop = new ModOptionToggle("toggle", "Checkbox", config.enableDropdown); options.AddModOption(enableDrop); enableDrop.ValueChanged += DisableDrop_ValueChanged; var choices = new ModSelectionOptionChoices(); choices.Add("toggle", "Toggle"); choices.Add("on", "Always On"); choices.Add("off", "Always Off"); dropdown = new ModOptionSelection("drop", "Dropdown", choices, config.dropdownChoice, config.enableDropdown) { hoverTextDictionary = new Dictionary <string, string> { { "on", "Hover text for Always On" }, { "off", "Hover text for Always Off" } } }; options.AddModOption(dropdown); dropdown.ValueChanged += Dropdown_ValueChanged; var checkbox2 = new ModOptionToggle("toggle2", "Checkbox2", config.checkbox2); options.AddModOption(checkbox2); options.AddModOption(new ModOptionToggle("toggle3", "Always On", false)); var slider = new ModOptionRange("range", "Slider", 10, 25, 1, config.rangeValue, true); var stepper = new ModOptionStepper("stepper", "Plus/Minus Controls", (decimal)5.0, (decimal)105.0, (decimal)1.5, config.stepperValue, DisplayType.PERCENT); options.AddModOption(slider); options.AddModOption(stepper); options.AddModOption(new ModOptionToggle("stepperCheck", "Show Stepper Value", false)); options.AddModOption(new ModOptionToggle("toggle5", "Checkbox5")); options.AddModOption(new ModOptionToggle("toggle6", "Checkbox6")); options.AddModOption(new ModOptionToggle("toggle7", "Checkbox7")); options.AddModOption(new ModOptionToggle("toggle8", "Checkbox8")); var saveButton = new ModOptionTrigger("okButton", "OK Button", OptionActionType.OK); options.AddModOption(saveButton); saveButton.ActionTriggered += (id) => { config.dropdownChoice = dropdown.Selection; config.enableDropdown = enableDrop.IsOn; this.Helper.WriteConfig <ModConfig>(config); }; GraphicsEvents.OnPostRenderEvent += (sender, e) => { if (dropdown.Selection == "off") { checkbox2.IsOn = false; } if (dropdown.Selection == "on" || (options.GetOptionWithIdentifier("toggle3") as ModOptionToggle).IsOn) { Game1.spriteBatch.DrawString(Game1.dialogueFont, dropdown.Choices.LabelOf("on"), new Vector2(Game1.getMouseX(), Game1.getMouseY()), Color.Black); } if (toggledOn) { Game1.spriteBatch.DrawString(Game1.dialogueFont, dropdown.Choices.LabelOf("toggle"), new Vector2(Game1.getMouseX(), Game1.getMouseY() + 12 * Game1.pixelZoom), Color.Black); } if ((options.GetOptionWithIdentifier("stepperCheck") as ModOptionToggle).IsOn) { Game1.spriteBatch.DrawString(Game1.dialogueFont, stepper.Value.ToString(), new Vector2(Game1.getMouseX(), Game1.getMouseY() + 12 * Game1.pixelZoom), Color.Black); } }; }
/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { Settings = IModSettingsFramework.Instance; var options = new ModOptions(this); Settings.AddModOptions(options); var testbox = options.GetOptionWithIdentifier <ModOptionToggle>("test") ?? new ModOptionToggle("test", "Test"); options.AddModOption(testbox); var list = new ModSelectionOptionChoices(); list.Add("available", "Option Available"); list.Add("second", "Option 2"); var disabledDrop = options.GetOptionWithIdentifier <ModOptionSelection>("disabled") ?? new ModOptionSelection("disabled", "Disabled Dropdown", list, 0, false); options.AddModOption(disabledDrop); var stepper = options.GetOptionWithIdentifier <ModOptionStepper>("stepper") ?? new ModOptionStepper("stepper", "Plus/Minus Controls", (decimal)5.0, (decimal)105.0, (decimal)1.5, 26, DisplayType.PERCENT); options.AddModOption(stepper); var label = options.GetOptionWithIdentifier <ModOptionCategoryLabel>("catlabel") ?? new ModOptionCategoryLabel("catlabel", "Category Label"); options.AddModOption(label); var button = options.GetOptionWithIdentifier <ModOptionTrigger>("setButton") ?? new ModOptionTrigger("setButton", "Click Me!", OptionActionType.SET); button.ActionTriggered += (identifier) => { options.GetOptionWithIdentifier("disabled").enabled = !options.GetOptionWithIdentifier("disabled").enabled; }; options.AddModOption(button); var clearButton = options.GetOptionWithIdentifier <ModOptionTrigger>("clearButton") ?? new ModOptionTrigger("clearButton", "Clear Button", OptionActionType.CLEAR); clearButton.type = OptionActionType.CLEAR; clearButton.ActionTriggered += (identifier) => { switch (clearButton.type) { case OptionActionType.CLEAR: clearButton.LabelText = "Are you sure?"; clearButton.type = OptionActionType.OK; break; case OptionActionType.OK: clearButton.LabelText = "Cleared"; clearButton.type = OptionActionType.DONE; break; case OptionActionType.DONE: clearButton.LabelText = "Clear Button"; clearButton.type = OptionActionType.CLEAR; break; default: clearButton.LabelText = "Clear Button"; clearButton.type = OptionActionType.CLEAR; break; } }; options.AddModOption(clearButton); options.AddModOption(new ModOptionTrigger("doneButton", "Done Button", OptionActionType.DONE)); options.AddModOption(new ModOptionTrigger("giftButton", "Gift Button", OptionActionType.GIFT)); var saveButton = new ModOptionTrigger("okButton", "OK Button", OptionActionType.OK); options.AddModOption(saveButton); options.AddModOption(new ModOptionSelection("empty", "Empty Dropdown", new ModSelectionOptionChoices())); saveButton.ActionTriggered += (id) => { // gather all options from ModOptions and update ModConfig }; SaveEvents.AfterLoad += SaveEvents_AfterLoad; }