Пример #1
0
            public static void DrawPopup(ConfigWindow window)
            {
                if (_mod == null)
                {
                    return;
                }

                using var popup = ImRaii.Popup(PopupName);
                if (!popup)
                {
                    return;
                }

                if (ImGui.IsWindowAppearing())
                {
                    ImGui.SetKeyboardFocusHere();
                }

                ImGui.InputTextMultiline("##editDescription", ref _newDescription, 4096, ImGuiHelpers.ScaledVector2(800, 800));
                ImGui.Dummy(window._defaultSpace);

                var buttonSize = ImGuiHelpers.ScaledVector2(100, 0);
                var width      = 2 * buttonSize.X
                                 + 4 * ImGui.GetStyle().FramePadding.X
                                 + ImGui.GetStyle().ItemSpacing.X;

                ImGui.SetCursorPosX((800 * ImGuiHelpers.GlobalScale - width) / 2);

                var oldDescription = _newDescriptionIdx == Input.Description
                    ? _mod.Description
                    : _mod.Groups[_newDescriptionIdx].Description;

                var tooltip = _newDescription != oldDescription ? string.Empty : "No changes made yet.";

                if (ImGuiUtil.DrawDisabledButton("Save", buttonSize, tooltip, tooltip.Length > 0))
                {
                    switch (_newDescriptionIdx)
                    {
                    case Input.Description:
                        Penumbra.ModManager.ChangeModDescription(_mod.Index, _newDescription);
                        break;

                    case >= 0:
                        Penumbra.ModManager.ChangeGroupDescription(_mod, _newDescriptionIdx, _newDescription);
                        break;
                    }

                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();
                if (ImGui.Button("Cancel", buttonSize) ||
                    ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.Escape)))
                {
                    _newDescriptionIdx = Input.None;
                    _newDescription    = string.Empty;
                    ImGui.CloseCurrentPopup();
                }
            }