Example #1
0
        public override void Entry(IModHelper helper)
        {
            var Settings = IModSettingsFramework.Instance;

            ModEntry.Options = ModOptions.LoadUserSettings(this);
            Settings.AddModOptions(ModEntry.Options);

            ModEntry.Helper  = helper;
            ModEntry.Monitor = base.Monitor;


            // Load Modconfig
            ModConfig = Helper.ReadConfig <ModConfig>();

            // Loads the correct settings on character load
            SaveEvents.AfterLoad          += LoadFeatures;
            SaveEvents.AfterReturnToTitle += RemoveListener;
            SaveEvents.AfterSave          += SaveEvents_AfterSave;

            var skipIntro = Options.GetOptionWithIdentifier <ModOptionToggle>("skipIntro") ?? new ModOptionToggle("skipIntro", "Skip Intro");

            Options.AddModOption(skipIntro);

            // Skip Intro
            if (skipIntro.IsOn)
            {
                MenuEvents.MenuChanged += SkipIntro.onMenuChange;
            }
        }
        private void create_menu()
        {
            options = ModOptions.LoadCharacterSettings(this, Constants.SaveFolderName);
            IModSettingsFramework.Instance.AddModOptions(options);

            var list = new ModSelectionOptionChoices
            {
                { "default", this.Helper.Translation.Get("default") },
                { "v02", this.Helper.Translation.Get("v02") },
                { "v02a", this.Helper.Translation.Get("v02a") },
                { "v02b", this.Helper.Translation.Get("v02b") },
                { "v02c", this.Helper.Translation.Get("v02c") }
            };

            this.DropDown = options.GetOptionWithIdentifier <ModOptionSelection>("bundle") ?? new ModOptionSelection("bundle", "Bundels", list);
            options.AddModOption(this.DropDown);

            this.DropDown.hoverTextDictionary = new Dictionary <string, string>
            {
                { "default", this.Helper.Translation.Get("default.desc") },
                { "v02", this.Helper.Translation.Get("v02.desc") },
                { "v02a", this.Helper.Translation.Get("v02a.desc") },
                { "v02b", this.Helper.Translation.Get("v02b.desc") },
                { "v02c", this.Helper.Translation.Get("v02c.desc") }
            };

            saveButton = new ModOptionTrigger("okButton", this.Helper.Translation.Get("okButton"), OptionActionType.OK);
            options.AddModOption(saveButton);

            saveButton.ActionTriggered += id =>
            {
                this.Monitor.Log("[CCBO] Changing Bundle ...");

                options.SaveCharacterSettings(Constants.SaveFolderName);

                this.Monitor.Log(this.Helper.Translation.Locale);

                InvalidateCache(this.Helper);
                Game1.addHUDMessage(new HUDMessage("Changed Community Center Bundle to: " + this.DropDown.Selection, 3)
                {
                    noIcon = true, timeLeft = HUDMessage.defaultTime
                });
                this.Monitor.Log("[CCBO] Bundle changed successfully. If smth. is missing, you must restart your game.");
            };
        }
Example #3
0
        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);
                }
            };
        }
Example #4
0
        /*********
        ** 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;
        }