示例#1
0
            private float DrawSingleSelectorEdit(OptionGroup group)
            {
                var oldSetting = Mod !.Settings.Settings[group.GroupName];
                var code       = oldSetting;

                if (ImGuiCustom.RenameableCombo($"##{group.GroupName}", ref code, out var newName,
                                                group.Options.Select(x => x.OptionName).ToArray(), group.Options.Count))
                {
                    if (code == group.Options.Count)
                    {
                        if (newName.Length > 0)
                        {
                            Mod.Settings.Settings[group.GroupName] = code;
                            group.Options.Add(new Option()
                            {
                                OptionName  = newName,
                                OptionDesc  = "",
                                OptionFiles = new Dictionary <RelPath, HashSet <GamePath> >(),
                            });
                            _selector.SaveCurrentMod();
                        }
                    }
                    else
                    {
                        if (newName.Length == 0)
                        {
                            _modManager.RemoveModOption(code, group, Mod.Data);
                        }
                        else
                        {
                            if (newName != group.Options[code].OptionName)
                            {
                                group.Options[code] = new Option()
                                {
                                    OptionName  = newName, OptionDesc = group.Options[code].OptionDesc,
                                    OptionFiles = group.Options[code].OptionFiles,
                                };
                                _selector.SaveCurrentMod();
                            }
                        }
                    }

                    if (Mod.Data.Meta.RefreshHasGroupsWithConfig())
                    {
                        _selector.Cache.TriggerFilterReset();
                    }
                }

                if (code != oldSetting)
                {
                    Save();
                }

                ImGui.SameLine();
                var labelEditPos = ImGui.GetCursorPosX();

                DrawSingleSelectorEditGroup(group);

                return(labelEditPos);
            }
            private float DrawSingleSelectorEdit(OptionGroup group)
            {
                var code             = Mod !.Settings[group.GroupName];
                var selectionChanged = false;
                var modChanged       = false;

                if (ImGuiCustom.RenameableCombo($"##{group.GroupName}", ref code, out var newName,
                                                group.Options.Select(x => x.OptionName).ToArray(), group.Options.Count))
                {
                    if (code == group.Options.Count)
                    {
                        if (newName.Length > 0)
                        {
                            selectionChanged = true;
                            modChanged       = true;
                            Mod.Settings[group.GroupName] = code;
                            group.Options.Add(new Option()
                            {
                                OptionName  = newName,
                                OptionDesc  = "",
                                OptionFiles = new Dictionary <RelPath, HashSet <GamePath> >(),
                            });
                        }
                    }
                    else
                    {
                        if (newName.Length == 0)
                        {
                            modChanged = true;
                            group.Options.RemoveAt(code);
                        }
                        else
                        {
                            if (newName != group.Options[code].OptionName)
                            {
                                modChanged          = true;
                                group.Options[code] = new Option()
                                {
                                    OptionName  = newName, OptionDesc = group.Options[code].OptionDesc,
                                    OptionFiles = group.Options[code].OptionFiles,
                                };
                            }

                            selectionChanged |= Mod.Settings[group.GroupName] != code;
                            Mod.Settings[group.GroupName] = code;
                        }

                        selectionChanged |= Mod.FixSpecificSetting(group.GroupName);
                    }
                }

                ImGui.SameLine();
                var labelEditPos = ImGui.GetCursorPosX();

                modChanged |= DrawSingleSelectorEditGroup(group, ref selectionChanged);

                if (modChanged)
                {
                    _selector.SaveCurrentMod();
                }

                if (selectionChanged)
                {
                    Save();
                }

                return(labelEditPos);
            }