Exemple #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);
            }
Exemple #2
0
            private void DrawFileListTab()
            {
                if (!ImGui.BeginTabItem(LabelFileListTab))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem);
                ImGuiCustom.HoverTooltip(TooltipFilesTab);

                ImGui.SetNextItemWidth(-1);
                if (ImGui.BeginListBox(LabelFileListHeader, AutoFillSize))
                {
                    raii.Push(ImGui.EndListBox);
                    UpdateFilenameList();
                    using var colorRaii = new ImGuiRaii.Color();
                    foreach (var(name, _, color, _) in _fullFilenameList !)
                    {
                        colorRaii.Push(ImGuiCol.Text, color);
                        ImGui.Selectable(name.FullName);
                        colorRaii.Pop();
                    }
                }
                else
                {
                    _fullFilenameList = null;
                }
            }
Exemple #3
0
            private void DrawAboutTab()
            {
                if (!_editMode && Meta.Description.Length == 0)
                {
                    return;
                }

                if (!ImGui.BeginTabItem(LabelAboutTab))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem);

                var desc  = Meta.Description;
                var flags = _editMode
                    ? ImGuiInputTextFlags.EnterReturnsTrue | ImGuiInputTextFlags.CtrlEnterForNewLine
                    : ImGuiInputTextFlags.ReadOnly;

                if (_editMode)
                {
                    if (ImGui.InputTextMultiline(LabelDescEdit, ref desc, 1 << 16,
                                                 AutoFillSize, flags))
                    {
                        Meta.Description = desc;
                        _selector.SaveCurrentMod();
                    }

                    ImGuiCustom.HoverTooltip(TooltipAboutEdit);
                }
                else
                {
                    ImGui.TextWrapped(desc);
                }
            }
            private bool DrawMultiSelectorEditBegin(OptionGroup group)
            {
                var groupName = group.GroupName;

                if (ImGuiCustom.BeginFramedGroupEdit(ref groupName) &&
                    groupName != group.GroupName &&
                    !Meta !.Groups.ContainsKey(groupName))
                {
                    var oldConf = Mod !.Settings[group.GroupName];
                    Meta.Groups.Remove(group.GroupName);
                    Mod.FixSpecificSetting(group.GroupName);
                    if (groupName.Length > 0)
                    {
                        Meta.Groups[groupName] = new OptionGroup()
                        {
                            GroupName     = groupName,
                            SelectionType = SelectType.Multi,
                            Options       = group.Options,
                        };
                        Mod.Settings[groupName] = oldConf;
                    }

                    return(true);
                }

                return(false);
            }
            private void DrawVersion()
            {
                if (_editMode)
                {
                    ImGui.BeginGroup();
                    ImGui.Text("(Version ");

                    ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, ZeroVector);
                    ImGui.SameLine();
                    var version = Meta !.Version;
                    if (ImGuiCustom.ResizingTextInput(LabelEditVersion, ref version, 16) &&
                        version != Meta.Version)
                    {
                        Meta.Version = version;
                        _selector.SaveCurrentMod();
                    }

                    ImGui.SameLine();
                    ImGui.Text(")");
                    ImGui.PopStyleVar();
                    ImGui.EndGroup();
                }
                else if (Meta !.Version.Length > 0)
                {
                    ImGui.Text($"(Version {Meta.Version})");
                }
            }
 private static void DrawNoModsAvailable()
 {
     ImGui.Text("You don't have any mods :(");
     ImGuiCustom.VerticalDistance(20f);
     ImGui.Text("You'll need to install them first by creating a folder close to the root of your drive (preferably an SSD).");
     ImGui.Text("For example: D:/ffxiv/mods/");
     ImGui.Text("And pasting that path into the settings tab and clicking the 'Rediscover Mods' button.");
     ImGui.Text("You can return to this tab once you've done that.");
 }
            private void DrawWebsite()
            {
                ImGui.BeginGroup();
                if (_editMode)
                {
                    ImGui.TextColored(GreyColor, "from");
                    ImGui.SameLine();
                    var website = Meta !.Website;
                    if (ImGuiCustom.ResizingTextInput(LabelEditWebsite, ref website, 512) &&
                        website != Meta.Website)
                    {
                        Meta.Website = website;
                        _selector.SaveCurrentMod();
                    }
                }
                else if (Meta !.Website.Length > 0)
                {
                    if (_currentWebsite != Meta.Website)
                    {
                        _currentWebsite = Meta.Website;
                        _validWebsite   = Uri.TryCreate(Meta.Website, UriKind.Absolute, out var uriResult) &&
                                          (uriResult.Scheme == Uri.UriSchemeHttps || uriResult.Scheme == Uri.UriSchemeHttp);
                    }

                    if (_validWebsite)
                    {
                        if (ImGui.SmallButton(ButtonOpenWebsite))
                        {
                            try
                            {
                                var process = new ProcessStartInfo(Meta.Website)
                                {
                                    UseShellExecute = true,
                                };
                                Process.Start(process);
                            }
                            catch (System.ComponentModel.Win32Exception)
                            {
                                // Do nothing.
                            }
                        }

                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip(Meta.Website);
                        }
                    }
                    else
                    {
                        ImGui.TextColored(GreyColor, "from");
                        ImGui.SameLine();
                        ImGui.Text(Meta.Website);
                    }
                }

                ImGui.EndGroup();
            }
Exemple #8
0
            private static void DrawLine(string path, string name)
            {
                ImGui.TableNextColumn();
                ImGuiCustom.CopyOnClickSelectable(path);

                ImGui.TableNextColumn();
                ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltLeft);
                ImGui.SameLine();
                ImGuiCustom.CopyOnClickSelectable(name);
            }
            private void DrawName()
            {
                var name = Meta !.Name;

                if (ImGuiCustom.InputOrText(_editMode, LabelEditName, ref name, 64) &&
                    name.Length > 0 && name != Meta.Name)
                {
                    Meta.Name = name;
                    _selector.SaveCurrentMod();
                }
            }
Exemple #10
0
            private void DrawCleanCollectionButton()
            {
                if (ImGui.Button("Clean Settings"))
                {
                    var changes = ModFunctions.CleanUpCollection(_manager.Collections.CurrentCollection.Settings,
                                                                 _manager.BasePath.EnumerateDirectories());
                    _manager.Collections.CurrentCollection.UpdateSettings(changes);
                }

                ImGuiCustom.HoverTooltip(
                    "Remove all stored settings for mods not currently available and fix invalid settings.\nUse at own risk.");
            }
            private void DrawMultiSelectorEdit(OptionGroup group)
            {
                var nameBoxStart = CheckMarkSize;
                var flag         = Mod !.Settings[group.GroupName];
                var modChanged   = DrawMultiSelectorEditBegin(group);

                for (var i = 0; i < group.Options.Count; ++i)
                {
                    var opt   = group.Options[i];
                    var label = $"##{group.GroupName}_{i}";
                    DrawMultiSelectorCheckBox(group, i, flag, label);

                    ImGui.SameLine();
                    var newName = opt.OptionName;

                    if (nameBoxStart == CheckMarkSize)
                    {
                        nameBoxStart = ImGui.GetCursorPosX();
                    }

                    ImGui.SetNextItemWidth(MultiEditBoxWidth);
                    if (ImGui.InputText($"{label}_l", ref newName, 64, ImGuiInputTextFlags.EnterReturnsTrue))
                    {
                        if (newName.Length == 0)
                        {
                            group.Options.RemoveAt(i);
                            var bitmaskFront = (1 << i) - 1;
                            var bitmaskBack  = ~(bitmaskFront | (1 << i));
                            Mod.Settings[group.GroupName] = (flag & bitmaskFront) | ((flag & bitmaskBack) >> 1);
                            modChanged = true;
                        }
                        else if (newName != opt.OptionName)
                        {
                            group.Options[i] = new Option()
                            {
                                OptionName = newName, OptionDesc = opt.OptionDesc, OptionFiles = opt.OptionFiles
                            };
                            _selector.SaveCurrentMod();
                        }
                    }
                }

                DrawMultiSelectorEditAdd(group, nameBoxStart);

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

                ImGuiCustom.EndFramedGroup();
            }
Exemple #12
0
            public void DrawCurrentCollectionSelector(bool tooltip)
            {
                var index = _currentCollectionIndex;
                var combo = ImGui.Combo(LabelCurrentCollection, ref index, _collectionNames);

                ImGuiCustom.HoverTooltip(
                    "This collection will be modified when using the Installed Mods tab and making changes. It does not apply to anything by itself.");

                if (combo)
                {
                    SetCurrentCollection(index, false);
                }
            }
Exemple #13
0
            private static void DrawFileLine(FileInfo file, GamePath path)
            {
                ImGui.TableNextColumn();
                ImGuiCustom.CopyOnClickSelectable(path);

                ImGui.TableNextColumn();
                ImGui.PushFont(UiBuilder.IconFont);
                ImGui.TextUnformatted($"{( char )FontAwesomeIcon.LongArrowAltLeft}");
                ImGui.PopFont();

                ImGui.TableNextColumn();
                ImGuiCustom.CopyOnClickSelectable(file.FullName);
            }
Exemple #14
0
            private void DrawName()
            {
                var name = Meta !.Name;

                if (ImGuiCustom.InputOrText(_editMode, LabelEditName, ref name, 64) && _modManager.RenameMod(name, Mod !.Data))
                {
                    _selector.SelectModOnUpdate(Mod.Data.BasePath.Name);
                    if (!_modManager.Config.ModSortOrder.ContainsKey(Mod !.Data.BasePath.Name))
                    {
                        Mod.Data.Rename(name);
                    }
                }
            }
Exemple #15
0
            private ImGuiRaii.EndStack DrawMultiSelectorEditBegin(OptionGroup group)
            {
                var groupName = group.GroupName;

                if (ImGuiCustom.BeginFramedGroupEdit(ref groupName))
                {
                    if (_modManager.ChangeModGroup(group.GroupName, groupName, Mod.Data) && Mod.Data.Meta.RefreshHasGroupsWithConfig())
                    {
                        _selector.Cache.TriggerFilterReset();
                    }
                }

                return(ImGuiRaii.DeferredEnd(ImGuiCustom.EndFramedGroup));
            }
Exemple #16
0
            private void DrawNewCharacterCollection()
            {
                ImGui.InputTextWithHint("##New Character", "New Character Name", ref _newCharacterName, 32);

                ImGui.SameLine();
                if (ImGuiCustom.DisableButton("Create New Character Collection", _newCharacterName.Length > 0))
                {
                    _manager.Collections.CreateCharacterCollection(_newCharacterName);
                    _currentCharacterIndices[_newCharacterName] = 0;
                    _newCharacterName = string.Empty;
                }

                ImGuiCustom.HoverTooltip(
                    "A character collection will be used whenever you manually redraw a character with the Name you have set up.\n"
                    + "If you enable automatic character redraws in the Settings tab, penumbra will try to use Character collections for corresponding characters automatically.\n");
            }
Exemple #17
0
            private void DrawPriority()
            {
                var priority = Mod !.Settings.Priority;

                ImGui.SetNextItemWidth(50 * ImGuiHelpers.GlobalScale);
                if (ImGui.InputInt("Priority", ref priority, 0) && priority != Mod !.Settings.Priority)
                {
                    Mod.Settings.Priority = priority;
                    _base.SaveCurrentCollection(Mod.Data.Resources.MetaManipulations.Count > 0);
                    _selector.Cache.TriggerFilterReset();
                }

                ImGuiCustom.HoverTooltip(
                    "Higher priority mods take precedence over other mods in the case of file conflicts.\n"
                    + "In case of identical priority, the alphabetically first mod takes precedence.");
            }
            private void DrawAuthor()
            {
                ImGui.BeginGroup();
                ImGui.TextColored(GreyColor, "by");

                ImGui.SameLine();
                var author = Meta !.Author;

                if (ImGuiCustom.InputOrText(_editMode, LabelEditAuthor, ref author, 64) &&
                    author != Meta.Author)
                {
                    Meta.Author = author;
                    _selector.SaveCurrentMod();
                }

                ImGui.EndGroup();
            }
Exemple #19
0
            private void DrawForcedCollectionSelector()
            {
                var index = _currentForcedIndex;

                if (ImGui.Combo("##Forced Collection", ref index, _collectionNamesWithNone) && index != _currentForcedIndex)
                {
                    _manager.Collections.SetForcedCollection(_collections[index]);
                    _currentForcedIndex = index;
                }

                ImGuiCustom.HoverTooltip(
                    "Mods in the forced collection are always loaded if not overwritten by anything in the current or character-based collection.\n"
                    + "Please avoid mixing meta-manipulating mods in Forced and other collections, as this will probably not work correctly.");

                ImGui.SameLine();
                ImGuiHelpers.ScaledDummy(24, 0);
                ImGui.SameLine();
                ImGui.Text("Forced Collection");
            }
Exemple #20
0
            private void DrawDefaultCollectionSelector()
            {
                var index = _currentDefaultIndex;

                if (ImGui.Combo("##Default Collection", ref index, _collectionNamesWithNone) && index != _currentDefaultIndex)
                {
                    _manager.Collections.SetDefaultCollection(_collections[index]);
                    _currentDefaultIndex = index;
                }

                ImGuiCustom.HoverTooltip(
                    "Mods in the default collection are loaded for any character that is not explicitly named in the character collections below.\n"
                    + "They also take precedence before the forced collection.");

                ImGui.SameLine();
                ImGuiHelpers.ScaledDummy(24, 0);
                ImGui.SameLine();
                ImGui.Text("Default Collection");
            }
            public void Draw()
            {
                if (Mod == null)
                {
                    return;
                }

                try
                {
                    var ret = ImGui.BeginChild(LabelModPanel, AutoFillSize, true);
                    if (!ret)
                    {
                        return;
                    }

                    DrawHeaderLine();

                    // Next line with fixed distance.
                    ImGuiCustom.VerticalDistance(HeaderLineDistance);

                    DrawEnabledMark();
                    if (_base._plugin !.Configuration !.ShowAdvanced)
                    {
                        ImGui.SameLine();
                        DrawEditableMark();
                    }

                    // Next line, if editable.
                    if (_editMode)
                    {
                        DrawEditLine();
                    }

                    Details.Draw(_editMode);

                    ImGui.EndChild();
                }
                catch (Exception ex)
                {
                    PluginLog.LogError(ex, "f**k");
                }
            }
Exemple #22
0
            private void DrawFileSwapTab()
            {
                if (_editMode)
                {
                    DrawFileSwapTabEdit();
                    return;
                }

                if (!Meta.FileSwaps.Any() || !ImGui.BeginTabItem(LabelFileSwapTab))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem);

                const ImGuiTableFlags flags = ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollX;

                ImGui.SetNextItemWidth(-1);
                if (!ImGui.BeginTable(LabelFileSwapHeader, 3, flags, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndTable);

                foreach (var(source, target) in Meta.FileSwaps)
                {
                    ImGui.TableNextColumn();
                    ImGuiCustom.CopyOnClickSelectable(source);

                    ImGui.TableNextColumn();
                    ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltRight);

                    ImGui.TableNextColumn();
                    ImGuiCustom.CopyOnClickSelectable(target);

                    ImGui.TableNextRow();
                }
            }
            public void Draw()
            {
                var ret = ImGui.BeginTabItem(LabelTab);

                if (!ret)
                {
                    return;
                }

                DrawRootFolder();

                DrawRediscoverButton();
                ImGui.SameLine();
                DrawOpenModsButton();

                ImGuiCustom.VerticalDistance(DefaultVerticalSpace);
                DrawEnabledBox();

                ImGuiCustom.VerticalDistance(DefaultVerticalSpace);
                DrawInvertModOrderBox();

                ImGuiCustom.VerticalDistance(DefaultVerticalSpace);
                DrawShowAdvancedBox();

                if (_config.ShowAdvanced)
                {
                    DrawAdvancedSettings();
                }

                if (_configChanged)
                {
                    _config.Save();
                    _configChanged = false;
                }

                ImGui.EndTabItem();
            }
Exemple #24
0
            private void DrawNewCollectionInput()
            {
                ImGui.InputTextWithHint("##New Collection", "New Collection", ref _newCollectionName, 64);

                using var style = ImGuiRaii.PushStyle(ImGuiStyleVar.Alpha, 0.5f, _newCollectionName.Length == 0);

                if (ImGui.Button("Create New Empty Collection") && _newCollectionName.Length > 0)
                {
                    CreateNewCollection(new Dictionary <string, ModSettings>());
                }

                ImGui.SameLine();
                if (ImGui.Button("Duplicate Current Collection") && _newCollectionName.Length > 0)
                {
                    CreateNewCollection(_manager.Collections.CurrentCollection.Settings);
                }

                style.Pop();

                var deleteCondition = _manager.Collections.Collections.Count > 1 &&
                                      _manager.Collections.CurrentCollection.Name != ModCollection.DefaultCollection;

                ImGui.SameLine();
                if (ImGuiCustom.DisableButton("Delete Current Collection", deleteCondition))
                {
                    _manager.Collections.RemoveCollection(_manager.Collections.CurrentCollection.Name);
                    SetCurrentCollection(_manager.Collections.CurrentCollection, true);
                    UpdateNames();
                }

                if (Penumbra.Config.ShowAdvanced)
                {
                    ImGui.SameLine();
                    DrawCleanCollectionButton();
                }
            }
            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);
            }
Exemple #26
0
            private void DrawFileSwapTabEdit()
            {
                if (!ImGui.BeginTabItem(LabelFileSwapTab))
                {
                    return;
                }

                using var raii = ImGuiRaii.DeferredEnd(ImGui.EndTabItem);

                ImGui.SetNextItemWidth(-1);
                if (!ImGui.BeginListBox(LabelFileSwapHeader, AutoFillSize))
                {
                    return;
                }

                raii.Push(ImGui.EndListBox);

                var swaps = Meta.FileSwaps.Keys.ToArray();

                ImGui.PushFont(UiBuilder.IconFont);
                var arrowWidth = ImGui.CalcTextSize(FontAwesomeIcon.LongArrowAltRight.ToIconString()).X;

                ImGui.PopFont();

                var width = (ImGui.GetWindowWidth() - arrowWidth - 4 * ImGui.GetStyle().ItemSpacing.X) / 2;

                for (var idx = 0; idx < swaps.Length + 1; ++idx)
                {
                    var    key         = idx == swaps.Length ? GamePath.GenerateUnchecked("") : swaps[idx];
                    var    value       = idx == swaps.Length ? GamePath.GenerateUnchecked("") : Meta.FileSwaps[key];
                    string keyString   = key;
                    string valueString = value;

                    ImGui.SetNextItemWidth(width);
                    if (ImGui.InputTextWithHint($"##swapLhs_{idx}", "Enter new file to be replaced...", ref keyString,
                                                GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue))
                    {
                        var newKey = new GamePath(keyString);
                        if (newKey.CompareTo(key) != 0)
                        {
                            if (idx < swaps.Length)
                            {
                                Meta.FileSwaps.Remove(key);
                            }

                            if (newKey != string.Empty)
                            {
                                Meta.FileSwaps[newKey] = value;
                            }

                            _selector.SaveCurrentMod();
                            _selector.ReloadCurrentMod();
                        }
                    }

                    if (idx >= swaps.Length)
                    {
                        continue;
                    }

                    ImGui.SameLine();
                    ImGuiCustom.PrintIcon(FontAwesomeIcon.LongArrowAltRight);
                    ImGui.SameLine();

                    ImGui.SetNextItemWidth(width);
                    if (ImGui.InputTextWithHint($"##swapRhs_{idx}", "Enter new replacement path...", ref valueString,
                                                GamePath.MaxGamePathLength,
                                                ImGuiInputTextFlags.EnterReturnsTrue))
                    {
                        var newValue = new GamePath(valueString);
                        if (newValue.CompareTo(value) != 0)
                        {
                            Meta.FileSwaps[key] = newValue;
                            _selector.SaveCurrentMod();
                            _selector.Cache.TriggerListReset();
                        }
                    }
                }
            }