コード例 #1
0
        private void SaveConfig()
        {
            if (configMin < 1)
            {
                Chat.Print("Minimum price must be positive.");
                configMin = 1;
            }

            if (configMod < 1)
            {
                Chat.Print("Modulo must be positive.");
                configMod = 1;
            }

            configuration.delta = configDelta;
            configuration.min   = configMin;
            configuration.mod   = configMod;

            configuration.alwaysOn = configMode == 2;
            configuration.smart    = configMode == 1;

            configuration.hq      = configHq;
            configuration.verbose = configVerbose;

            PluginInterface.SavePluginConfig(configuration);
        }
コード例 #2
0
 private void SaveConfig()
 {
     _configuration.Lang            = _languageInt;
     _configuration.Channels        = _channels;
     _configuration.NotSelf         = _notSelf;
     _configuration.Whitelist       = _whitelist;
     _configuration.ChosenLanguages = _chosenLanguages;
     _configuration.OneChan         = _oneChan;
     _configuration.OneInt          = _oneInt;
     _configuration.TextColour      = _textColour;
     _configuration.Blacklist       = _blacklist;
     _configuration.TranMode        = _tranMode;
     PluginInterface.SavePluginConfig(_configuration);
 }
コード例 #3
0
        /// <summary>
        /// Protected implementation of Dispose pattern.
        /// </summary>
        /// <param name="disposing">A value indicating whether we are disposing.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (this.isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Save config
                PluginInterface.SavePluginConfig(this.config);

                // Remove command handlers
                PluginInterface.UiBuilder.Draw -= this.BuildMarketBoardUi;
                CommandManager.RemoveHandler("/pmb");
                this.marketBoardWindow.Dispose();

                // Remove context menu handler
                this.contextMenuBase.Functions.ContextMenu.OnOpenInventoryContextMenu -= this.OnContextMenuOpened;
                this.contextMenuBase.Dispose();
            }

            this.isDisposed = true;
        }
コード例 #4
0
 /// <summary>
 /// Save plugin configuration.
 /// </summary>
 public void SaveConfig()
 {
     PluginInterface.SavePluginConfig((IPluginConfiguration)this.Configuration);
 }
コード例 #5
0
        private void OnCommandDebugCombo(string command, string arguments)
        {
            var argumentsParts = arguments.Split();

            switch (argumentsParts[0])
            {
            case "setall":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
                {
                    if (value == CustomComboPreset.None)
                    {
                        continue;
                    }

                    this.Configuration.ComboPresets |= value;
                }

                ChatGui.Print("all SET");
            }
            break;

            case "unsetall":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
                {
                    this.Configuration.ComboPresets &= value;
                }

                ChatGui.Print("all UNSET");
            }
            break;

            case "set":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
                {
                    if (value.ToString().ToLower() != argumentsParts[1].ToLower())
                    {
                        continue;
                    }

                    this.Configuration.ComboPresets |= value;
                }
            }
            break;

            case "toggle":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
                {
                    if (value.ToString().ToLower() != argumentsParts[1].ToLower())
                    {
                        continue;
                    }

                    this.Configuration.ComboPresets ^= value;
                }
            }
            break;

            case "unset":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
                {
                    if (value.ToString().ToLower() != argumentsParts[1].ToLower())
                    {
                        continue;
                    }

                    this.Configuration.ComboPresets &= ~value;
                }
            }
            break;

            case "list":
            {
                foreach (var value in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>().Where(x => x != CustomComboPreset.None))
                {
                    if (argumentsParts[1].ToLower() == "set")
                    {
                        if (this.Configuration.ComboPresets.HasFlag(value))
                        {
                            ChatGui.Print(value.ToString());
                        }
                    }
                    else if (argumentsParts[1].ToLower() == "all")
                    {
                        ChatGui.Print(value.ToString());
                    }
                }
            }
            break;

            default:
                this.isImguiComboSetupOpen = true;
                break;
            }

            PluginInterface.SavePluginConfig(this.Configuration);
        }
コード例 #6
0
        private void UiBuilder_OnBuildUi()
        {
            if (!isImguiComboSetupOpen)
            {
                return;
            }

            var flagsSelected = new bool[orderedByClassJob.Length];
            var hiddenFlags   = new bool[orderedByClassJob.Length];

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                flagsSelected[i] = Configuration.ComboPresets.HasFlag(orderedByClassJob[i]);
                hiddenFlags[i]   = Configuration.HiddenActions[i];
            }

            ImGui.SetNextWindowSize(new Vector2(740, 490));

            ImGui.Begin("Custom Combo Setup", ref isImguiComboSetupOpen, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollbar);

            ImGui.Text("This window allows you to enable and disable custom combos to your liking.");
            ImGui.Separator();

            ImGui.BeginChild("scrolling", new Vector2(0, 400), true, ImGuiWindowFlags.HorizontalScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 5));

            var lastClassJob = 0;

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                var flag     = orderedByClassJob[i];
                var flagInfo = flag.GetAttribute <CustomComboInfoAttribute>();
                if (lastClassJob != flagInfo.ClassJob)
                {
                    lastClassJob = flagInfo.ClassJob;
                    if (ImGui.CollapsingHeader(ClassJobToName((byte)lastClassJob)))
                    {
                        for (int j = i; j < orderedByClassJob.Length; j++)
                        {
                            flag     = orderedByClassJob[j];
                            flagInfo = flag.GetAttribute <CustomComboInfoAttribute>();
                            if (lastClassJob != flagInfo.ClassJob)
                            {
                                break;
                            }
                            ImGui.PushItemWidth(200);
                            ImGui.Checkbox(flagInfo.FancyName, ref flagsSelected[j]);
                            ImGui.PopItemWidth();
                            ImGui.SameLine(275);
                            ImGui.Checkbox("Prevent this chain from updating its icon" + $"##{j}", ref hiddenFlags[j]);
                            ImGui.TextColored(new Vector4(0.68f, 0.68f, 0.68f, 1.0f), $"#{j+1}:" + flagInfo.Description);
                            ImGui.Spacing();
                        }
                    }
                }
            }

            for (var i = 0; i < orderedByClassJob.Length; i++)
            {
                if (flagsSelected[i])
                {
                    Configuration.ComboPresets |= orderedByClassJob[i];
                }
                else
                {
                    Configuration.ComboPresets &= ~orderedByClassJob[i];
                }
                Configuration.HiddenActions[i] = hiddenFlags[i];
            }

            ImGui.PopStyleVar();

            ImGui.EndChild();

            ImGui.Separator();
            if (ImGui.Button("Save"))
            {
                PluginInterface.SavePluginConfig(Configuration);
                UpdateConfig();
            }
            ImGui.SameLine();
            if (ImGui.Button("Save and Close"))
            {
                PluginInterface.SavePluginConfig(Configuration);
                this.isImguiComboSetupOpen = false;
                UpdateConfig();
            }

            ImGui.End();
        }