private void DrawCharacterCollectionSelectors()
        {
            ImGui.Dummy(_window._defaultSpace);
            if (ImGui.CollapsingHeader("Active Collections", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGui.Dummy(_window._defaultSpace);
                DrawDefaultCollectionSelector();
                ImGui.Dummy(_window._defaultSpace);
                foreach (var name in Penumbra.CollectionManager.Characters.Keys.OrderBy(k => k).ToArray())
                {
                    using var id = ImRaii.PushId(name);
                    DrawCollectionSelector(string.Empty, _window._inputTextWidth.X, ModCollection.Type.Character, true, name);
                    ImGui.SameLine();
                    if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _window._iconButtonSize, string.Empty,
                                                     false,
                                                     true))
                    {
                        Penumbra.CollectionManager.RemoveCharacterCollection(name);
                    }

                    ImGui.SameLine();
                    ImGui.AlignTextToFramePadding();
                    ImGui.TextUnformatted(name);
                }

                DrawNewCharacterCollection();
                ImGui.NewLine();
            }
        }
Esempio n. 2
0
    // The headers for the different meta changes all have basically the same structure for different types.
    private void DrawEditHeader <T>(IReadOnlyCollection <T> items, string label, int numColumns, Action <T, Mod.Editor, Vector2> draw,
                                    Action <Mod.Editor, Vector2> drawNew)
    {
        const ImGuiTableFlags flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.BordersInnerV;

        if (!ImGui.CollapsingHeader($"{items.Count} {label}"))
        {
            return;
        }

        using (var table = ImRaii.Table(label, numColumns, flags))
        {
            if (table)
            {
                drawNew(_editor !, _iconSize);
                ImGui.Separator();
                foreach (var(item, index) in items.ToArray().WithIndex())
                {
                    using var id = ImRaii.PushId(index);
                    draw(item, _editor !, _iconSize);
                }
            }
        }

        ImGui.NewLine();
    }
Esempio n. 3
0
        // Draw a single group selector as a combo box.
        // If a description is provided, add a help marker besides it.
        private void DrawSingleGroup(IModGroup group, int groupIdx)
        {
            if (group.Type != SelectType.Single || !group.IsOption)
            {
                return;
            }

            using var id = ImRaii.PushId(groupIdx);
            var selectedOption = _emptySetting ? 0 : ( int )_settings.Settings[groupIdx];

            ImGui.SetNextItemWidth(_window._inputTextWidth.X * 3 / 4);
            using var combo = ImRaii.Combo(string.Empty, group[selectedOption].Name);
            if (combo)
            {
                for (var idx2 = 0; idx2 < group.Count; ++idx2)
                {
                    if (ImGui.Selectable(group[idx2].Name, idx2 == selectedOption))
                    {
                        Penumbra.CollectionManager.Current.SetModSetting(_mod.Index, groupIdx, ( uint )idx2);
                    }
                }
            }

            combo.Dispose();
            ImGui.SameLine();
            if (group.Description.Length > 0)
            {
                ImGuiUtil.LabeledHelpMarker(group.Name, group.Description);
            }
            else
            {
                ImGui.TextUnformatted(group.Name);
            }
        }
        private static void Checkbox(string label, string tooltip, bool current, Action <bool> setter)
        {
            using var id = ImRaii.PushId(label);
            var tmp = current;

            if (ImGui.Checkbox(string.Empty, ref tmp) && tmp != current)
            {
                setter(tmp);
                Penumbra.Config.Save();
            }

            ImGui.SameLine();
            ImGuiUtil.LabeledHelpMarker(label, tooltip);
        }
Esempio n. 5
0
        private static void DrawOpenDirectoryButton(int id, DirectoryInfo directory, bool condition)
        {
            using var _ = ImRaii.PushId(id);
            var ret = ImGui.Button("Open Directory");

            ImGuiUtil.HoverTooltip("Open this directory in your configured file explorer.");
            if (ret && condition && Directory.Exists(directory.FullName))
            {
                Process.Start(new ProcessStartInfo(directory.FullName)
                {
                    UseShellExecute = true,
                });
            }
        }
Esempio n. 6
0
        public static void Draw(EqpManipulation meta, Mod.Editor editor, Vector2 iconSize)
        {
            DrawMetaButtons(meta, editor, iconSize);

            // Identifier
            ImGui.TableNextColumn();
            ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetStyle().FramePadding.X);
            ImGui.TextUnformatted(meta.SetId.ToString());
            ImGuiUtil.HoverTooltip("Model Set ID");
            var defaultEntry = ExpandedEqpFile.GetDefault(meta.SetId);

            ImGui.TableNextColumn();
            ImGui.SetCursorPosX(ImGui.GetCursorPosX() + ImGui.GetStyle().FramePadding.X);
            ImGui.TextUnformatted(meta.Slot.ToName());
            ImGuiUtil.HoverTooltip("Equip Slot");

            // Values
            ImGui.TableNextColumn();
            using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing,
                                               new Vector2(3 * ImGuiHelpers.GlobalScale, ImGui.GetStyle().ItemSpacing.Y));
            var idx = 0;

            foreach (var flag in Eqp.EqpAttributes[meta.Slot])
            {
                using var id = ImRaii.PushId(idx++);
                var defaultValue = defaultEntry.HasFlag(flag);
                var currentValue = meta.Entry.HasFlag(flag);
                if (Checkmark("##eqp", flag.ToLocalName(), currentValue, defaultValue, out var value))
                {
                    editor.Meta.Change(meta with {
                        Entry = value ? meta.Entry | flag : meta.Entry & ~flag
                    });
                }

                ImGui.SameLine();
            }

            ImGui.NewLine();
        }
Esempio n. 7
0
        // Draw a multi group selector as a bordered set of checkboxes.
        // If a description is provided, add a help marker in the title.
        private void DrawMultiGroup(IModGroup group, int groupIdx)
        {
            if (group.Type != SelectType.Multi || !group.IsOption)
            {
                return;
            }

            using var id = ImRaii.PushId(groupIdx);
            var flags = _emptySetting ? 0u : _settings.Settings[groupIdx];

            Widget.BeginFramedGroup(group.Name, group.Description);
            for (var idx2 = 0; idx2 < group.Count; ++idx2)
            {
                var flag    = 1u << idx2;
                var setting = (flags & flag) != 0;
                if (ImGui.Checkbox(group[idx2].Name, ref setting))
                {
                    flags = setting ? flags | flag : flags & ~flag;
                    Penumbra.CollectionManager.Current.SetModSetting(_mod.Index, groupIdx, flags);
                }
            }

            Widget.EndFramedGroup();
        }
Esempio n. 8
0
            // Draw a line for a single option.
            private static void EditOption(ModPanel panel, IModGroup group, int groupIdx, int optionIdx)
            {
                var option = group[optionIdx];

                using var id = ImRaii.PushId(optionIdx);
                ImGui.TableNextColumn();
                ImGui.AlignTextToFramePadding();
                ImGui.Selectable($"Option #{optionIdx + 1}");
                Source(group, groupIdx, optionIdx);
                Target(panel, group, groupIdx, optionIdx);

                ImGui.TableNextColumn();
                if (Input.Text("##Name", groupIdx, optionIdx, option.Name, out var newOptionName, 256, -1))
                {
                    Penumbra.ModManager.RenameOption(panel._mod, groupIdx, optionIdx, newOptionName);
                }

                ImGui.TableNextColumn();
                if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), panel._window._iconButtonSize,
                                                 "Delete this option.\nHold Control while clicking to delete.", !ImGui.GetIO().KeyCtrl, true))
                {
                    panel._delayedActions.Enqueue(() => Penumbra.ModManager.DeleteOption(panel._mod, groupIdx, optionIdx));
                }

                ImGui.TableNextColumn();
                if (group.Type == SelectType.Multi)
                {
                    if (Input.Priority("##Priority", groupIdx, optionIdx, group.OptionPriority(optionIdx), out var priority,
                                       50 * ImGuiHelpers.GlobalScale))
                    {
                        Penumbra.ModManager.ChangeOptionPriority(panel._mod, groupIdx, optionIdx, priority);
                    }

                    ImGuiUtil.HoverTooltip("Option priority.");
                }
            }
Esempio n. 9
0
        private void EditGroup(int groupIdx)
        {
            var group = _mod.Groups[groupIdx];

            using var id    = ImRaii.PushId(groupIdx);
            using var frame = ImRaii.FramedGroup($"Group #{groupIdx + 1}");

            using var style = ImRaii.PushStyle(ImGuiStyleVar.CellPadding, _cellPadding)
                              .Push(ImGuiStyleVar.ItemSpacing, _itemSpacing);

            if (Input.Text("##Name", groupIdx, Input.None, group.Name, out var newGroupName, 256, _window._inputTextWidth.X))
            {
                Penumbra.ModManager.RenameModGroup(_mod, groupIdx, newGroupName);
            }

            ImGuiUtil.HoverTooltip("Group Name");
            ImGui.SameLine();
            if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), _window._iconButtonSize,
                                             "Delete this option group.\nHold Control while clicking to delete.", !ImGui.GetIO().KeyCtrl, true))
            {
                _delayedActions.Enqueue(() => Penumbra.ModManager.DeleteModGroup(_mod, groupIdx));
            }

            ImGui.SameLine();

            if (Input.Priority("##Priority", groupIdx, Input.None, group.Priority, out var priority, 50 * ImGuiHelpers.GlobalScale))
            {
                Penumbra.ModManager.ChangeGroupPriority(_mod, groupIdx, priority);
            }

            ImGuiUtil.HoverTooltip("Group Priority");

            DrawGroupCombo(group, groupIdx);
            ImGui.SameLine();

            var tt = groupIdx == 0 ? "Can not move this group further upwards." : $"Move this group up to group {groupIdx}.";

            if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.ArrowUp.ToIconString(), _window._iconButtonSize,
                                             tt, groupIdx == 0, true))
            {
                _delayedActions.Enqueue(() => Penumbra.ModManager.MoveModGroup(_mod, groupIdx, groupIdx - 1));
            }

            ImGui.SameLine();
            tt = groupIdx == _mod.Groups.Count - 1
                ? "Can not move this group further downwards."
                : $"Move this group down to group {groupIdx + 2}.";
            if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.ArrowDown.ToIconString(), _window._iconButtonSize,
                                             tt, groupIdx == _mod.Groups.Count - 1, true))
            {
                _delayedActions.Enqueue(() => Penumbra.ModManager.MoveModGroup(_mod, groupIdx, groupIdx + 1));
            }

            ImGui.SameLine();

            if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Edit.ToIconString(), _window._iconButtonSize,
                                             "Edit group description.", false, true))
            {
                _delayedActions.Enqueue(() => DescriptionEdit.OpenPopup(_mod, groupIdx));
            }

            ImGui.SameLine();
            var fileName   = group.FileName(_mod.ModPath, groupIdx);
            var fileExists = File.Exists(fileName);

            tt = fileExists
                ? $"Open the {group.Name} json file in the text editor of your choice."
                : $"The {group.Name} json file does not exist.";
            if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.FileExport.ToIconString(), _window._iconButtonSize, tt, !fileExists, true))
            {
                Process.Start(new ProcessStartInfo(fileName)
                {
                    UseShellExecute = true
                });
            }

            ImGui.Dummy(_window._defaultSpace);

            OptionTable.Draw(this, groupIdx);
        }