public void Draw() { if (!ForceDraw && (Dalamud.Conditions.Any() || _base._menu.Visible)) { return; } using var color = ImGuiRaii.PushColor(ImGuiCol.Button, 0xFF0000C8, ForceDraw); var ss = ImGui.GetMainViewport().Size + ImGui.GetMainViewport().Pos; ImGui.SetNextWindowViewport(ImGui.GetMainViewport().ID); var windowSize = ImGuiHelpers.ScaledVector2(Width, Height); ImGui.SetNextWindowPos(ss - windowSize - Penumbra.Config.ManageModsButtonOffset * ImGuiHelpers.GlobalScale, ImGuiCond.Always); if (ImGui.Begin(MenuButtonsName, ButtonFlags) && ImGui.Button(MenuButtonLabel, windowSize)) { _base.FlipVisibility(); } ImGui.End(); }
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(); } }
private void DrawDeleteModal() { if (_deleteIndex == null) { return; } ImGui.OpenPopup(DialogDeleteMod); var _ = true; ImGui.SetNextWindowPos(ImGui.GetMainViewport().GetCenter(), ImGuiCond.Appearing, Vector2.One / 2); var ret = ImGui.BeginPopupModal(DialogDeleteMod, ref _, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDecoration); if (!ret) { return; } using var raii = ImGuiRaii.DeferredEnd(ImGui.EndPopup); if (Mod == null) { _deleteIndex = null; ImGui.CloseCurrentPopup(); return; } ImGui.Text("Are you sure you want to delete the following mod:"); var halfLine = new Vector2(ImGui.GetTextLineHeight() / 2); ImGui.Dummy(halfLine); ImGui.TextColored(DeleteModNameColor, Mod.Data.Meta.Name); ImGui.Dummy(halfLine); var buttonSize = ImGuiHelpers.ScaledVector2(120, 0); if (ImGui.Button(ButtonYesDelete, buttonSize)) { ImGui.CloseCurrentPopup(); var mod = Mod; Cache.RemoveMod(mod); _modManager.DeleteMod(mod.Data.BasePath); ModFileSystem.InvokeChange(); ClearSelection(); } ImGui.SameLine(); if (ImGui.Button(ButtonNoDelete, buttonSize)) { ImGui.CloseCurrentPopup(); _deleteIndex = null; } }
/// <inheritdoc/> public override void Draw() { var screenSize = ImGui.GetMainViewport().Size; var windowSize = ImGui.GetWindowSize(); this.Position = (screenSize - windowSize) / 2; ImGui.BeginChild("scrolling", Vector2.Zero, false, ImGuiWindowFlags.NoScrollbar); ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero); ImGuiHelpers.ScaledDummy(0, 340f); ImGui.Text(string.Empty); ImGui.SameLine(150f); ImGui.Image(this.logoTexture.ImGuiHandle, ImGuiHelpers.ScaledVector2(190f, 190f)); ImGuiHelpers.ScaledDummy(0, 20f); var windowX = ImGui.GetWindowSize().X; foreach (var creditsLine in this.creditsText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)) { var lineLenX = ImGui.CalcTextSize(creditsLine).X; ImGui.Dummy(new Vector2((windowX / 2) - (lineLenX / 2), 0f)); ImGui.SameLine(); ImGui.TextUnformatted(creditsLine); } ImGui.PopStyleVar(); if (this.creditsThrottler.Elapsed.TotalMilliseconds > (1000.0f / CreditFPS)) { var curY = ImGui.GetScrollY(); var maxY = ImGui.GetScrollMaxY(); if (curY < maxY - 1) { ImGui.SetScrollY(curY + 1); } } ImGui.EndChild(); }
public void ChangeMod(Mod mod) { if (mod == _mod) { return; } _editor?.Dispose(); _editor = new Mod.Editor(mod, -1, 0); _mod = mod; WindowName = $"{mod.Name}{WindowBaseLabel}"; SizeConstraints = new WindowSizeConstraints { MinimumSize = ImGuiHelpers.ScaledVector2(1000, 600), MaximumSize = 4000 * Vector2.One, }; _selectedFiles.Clear(); }
/// <inheritdoc /> public override void Draw() { var config = Service <DalamudConfiguration> .Get(); var renameModalTitle = Loc.Localize("RenameStyleModalTitle", "Rename Style"); var workStyle = config.SavedStyles[this.currentSel]; workStyle.BuiltInColors ??= StyleModelV1.DalamudStandard.BuiltInColors; var appliedThisFrame = false; var styleAry = config.SavedStyles.Select(x => x.Name).ToArray(); ImGui.Text(Loc.Localize("StyleEditorChooseStyle", "Choose Style:")); if (ImGui.Combo("###styleChooserCombo", ref this.currentSel, styleAry, styleAry.Length)) { var newStyle = config.SavedStyles[this.currentSel]; newStyle.Apply(); appliedThisFrame = true; } if (ImGui.Button(Loc.Localize("StyleEditorAddNew", "Add new style"))) { this.SaveStyle(); var newStyle = StyleModelV1.DalamudStandard; newStyle.Name = GetRandomName(); config.SavedStyles.Add(newStyle); this.currentSel = config.SavedStyles.Count - 1; newStyle.Apply(); appliedThisFrame = true; config.Save(); } ImGui.SameLine(); if (ImGuiComponents.IconButton(FontAwesomeIcon.Trash) && this.currentSel != 0) { this.currentSel--; var newStyle = config.SavedStyles[this.currentSel]; newStyle.Apply(); appliedThisFrame = true; config.SavedStyles.RemoveAt(this.currentSel + 1); config.Save(); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("StyleEditorDeleteStyle", "Delete current style")); } ImGui.SameLine(); if (ImGuiComponents.IconButton(FontAwesomeIcon.Pen) && this.currentSel != 0) { var newStyle = config.SavedStyles[this.currentSel]; this.renameText = newStyle.Name; this.renameModalDrawing = true; ImGui.OpenPopup(renameModalTitle); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("StyleEditorRenameStyle", "Rename style")); } ImGui.SameLine(); ImGuiHelpers.ScaledDummy(5); ImGui.SameLine(); if (ImGuiComponents.IconButton(FontAwesomeIcon.FileExport)) { var selectedStyle = config.SavedStyles[this.currentSel]; var newStyle = StyleModelV1.Get(); newStyle.Name = selectedStyle.Name; ImGui.SetClipboardText(newStyle.Serialize()); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("StyleEditorCopy", "Copy style to clipboard for sharing")); } ImGui.SameLine(); if (ImGuiComponents.IconButton(FontAwesomeIcon.FileImport)) { this.SaveStyle(); var styleJson = ImGui.GetClipboardText(); try { var newStyle = StyleModel.Deserialize(styleJson); newStyle.Name ??= GetRandomName(); if (config.SavedStyles.Any(x => x.Name == newStyle.Name)) { newStyle.Name = $"{newStyle.Name} ({GetRandomName()} Mix)"; } config.SavedStyles.Add(newStyle); newStyle.Apply(); appliedThisFrame = true; this.currentSel = config.SavedStyles.Count - 1; config.Save(); } catch (Exception ex) { Log.Error(ex, "Could not import style"); } } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("StyleEditorImport", "Import style from clipboard")); } ImGui.Separator(); ImGui.PushItemWidth(ImGui.GetWindowWidth() * 0.50f); if (this.currentSel < 2) { ImGui.TextColored(ImGuiColors.DalamudRed, Loc.Localize("StyleEditorNotAllowed", "You cannot edit built-in styles. Please add a new style first.")); } else if (appliedThisFrame) { ImGui.Text(Loc.Localize("StyleEditorApplying", "Applying style...")); } else if (ImGui.BeginTabBar("StyleEditorTabs")) { var style = ImGui.GetStyle(); if (ImGui.BeginTabItem(Loc.Localize("StyleEditorVariables", "Variables"))) { ImGui.BeginChild($"ScrollingVars", ImGuiHelpers.ScaledVector2(0, -32), true, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5); ImGui.SliderFloat2("WindowPadding", ref style.WindowPadding, 0.0f, 20.0f, "%.0f"); ImGui.SliderFloat2("FramePadding", ref style.FramePadding, 0.0f, 20.0f, "%.0f"); ImGui.SliderFloat2("CellPadding", ref style.CellPadding, 0.0f, 20.0f, "%.0f"); ImGui.SliderFloat2("ItemSpacing", ref style.ItemSpacing, 0.0f, 20.0f, "%.0f"); ImGui.SliderFloat2("ItemInnerSpacing", ref style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); ImGui.SliderFloat2("TouchExtraPadding", ref style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); ImGui.SliderFloat("IndentSpacing", ref style.IndentSpacing, 0.0f, 30.0f, "%.0f"); ImGui.SliderFloat("ScrollbarSize", ref style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); ImGui.SliderFloat("GrabMinSize", ref style.GrabMinSize, 1.0f, 20.0f, "%.0f"); ImGui.Text("Borders"); ImGui.SliderFloat("WindowBorderSize", ref style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); ImGui.SliderFloat("ChildBorderSize", ref style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); ImGui.SliderFloat("PopupBorderSize", ref style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); ImGui.SliderFloat("FrameBorderSize", ref style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); ImGui.SliderFloat("TabBorderSize", ref style.TabBorderSize, 0.0f, 1.0f, "%.0f"); ImGui.Text("Rounding"); ImGui.SliderFloat("WindowRounding", ref style.WindowRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("ChildRounding", ref style.ChildRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("FrameRounding", ref style.FrameRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("PopupRounding", ref style.PopupRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("ScrollbarRounding", ref style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("GrabRounding", ref style.GrabRounding, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("LogSliderDeadzone", ref style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); ImGui.SliderFloat("TabRounding", ref style.TabRounding, 0.0f, 12.0f, "%.0f"); ImGui.Text("Alignment"); ImGui.SliderFloat2("WindowTitleAlign", ref style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); var windowMenuButtonPosition = (int)style.WindowMenuButtonPosition + 1; if (ImGui.Combo("WindowMenuButtonPosition", ref windowMenuButtonPosition, "None\0Left\0Right\0")) { style.WindowMenuButtonPosition = (ImGuiDir)(windowMenuButtonPosition - 1); } ImGui.SliderFloat2("ButtonTextAlign", ref style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); ImGui.SameLine(); ImGuiComponents.HelpMarker("Alignment applies when a button is larger than its text content."); ImGui.SliderFloat2("SelectableTextAlign", ref style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); ImGui.SameLine(); ImGuiComponents.HelpMarker("Alignment applies when a selectable is larger than its text content."); ImGui.SliderFloat2("DisplaySafeAreaPadding", ref style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui.SameLine(); ImGuiComponents.HelpMarker( "Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); ImGui.EndTabItem(); ImGui.EndChild(); ImGui.EndTabItem(); } if (ImGui.BeginTabItem(Loc.Localize("StyleEditorColors", "Colors"))) { ImGui.BeginChild("ScrollingColors", ImGuiHelpers.ScaledVector2(0, -30), true, ImGuiWindowFlags.HorizontalScrollbar | ImGuiWindowFlags.NoBackground); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - 5); if (ImGui.RadioButton("Opaque", this.alphaFlags == ImGuiColorEditFlags.None)) { this.alphaFlags = ImGuiColorEditFlags.None; } ImGui.SameLine(); if (ImGui.RadioButton("Alpha", this.alphaFlags == ImGuiColorEditFlags.AlphaPreview)) { this.alphaFlags = ImGuiColorEditFlags.AlphaPreview; } ImGui.SameLine(); if (ImGui.RadioButton("Both", this.alphaFlags == ImGuiColorEditFlags.AlphaPreviewHalf)) { this.alphaFlags = ImGuiColorEditFlags.AlphaPreviewHalf; } ImGui.SameLine(); ImGuiComponents.HelpMarker( "In the color list:\n" + "Left-click on color square to open color picker,\n" + "Right-click to open edit options menu."); foreach (var imGuiCol in Enum.GetValues <ImGuiCol>()) { if (imGuiCol == ImGuiCol.COUNT) { continue; } ImGui.PushID(imGuiCol.ToString()); ImGui.ColorEdit4("##color", ref style.Colors[(int)imGuiCol], ImGuiColorEditFlags.AlphaBar | this.alphaFlags); ImGui.SameLine(0.0f, style.ItemInnerSpacing.X); ImGui.TextUnformatted(imGuiCol.ToString()); ImGui.PopID(); } ImGui.Separator(); foreach (var property in typeof(DalamudColors).GetProperties(BindingFlags.Public | BindingFlags.Instance)) { ImGui.PushID(property.Name); var colorVal = property.GetValue(workStyle.BuiltInColors); if (colorVal == null) { colorVal = property.GetValue(StyleModelV1.DalamudStandard.BuiltInColors); property.SetValue(workStyle.BuiltInColors, colorVal); } var color = (Vector4)colorVal; if (ImGui.ColorEdit4("##color", ref color, ImGuiColorEditFlags.AlphaBar | this.alphaFlags)) { property.SetValue(workStyle.BuiltInColors, color); workStyle.BuiltInColors?.Apply(); } ImGui.SameLine(0.0f, style.ItemInnerSpacing.X); ImGui.TextUnformatted(property.Name); ImGui.PopID(); } ImGui.EndChild(); ImGui.EndTabItem(); } ImGui.EndTabBar(); } ImGui.PopItemWidth(); ImGui.Separator(); if (ImGui.Button(Loc.Localize("Close", "Close"))) { this.IsOpen = false; } ImGui.SameLine(); if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close"))) { this.SaveStyle(); config.ChosenStyle = config.SavedStyles[this.currentSel].Name; Log.Verbose("ChosenStyle = {ChosenStyle}", config.ChosenStyle); this.didSave = true; this.IsOpen = false; } if (ImGui.BeginPopupModal(renameModalTitle, ref this.renameModalDrawing, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar)) { ImGui.Text(Loc.Localize("StyleEditorEnterName", "Please enter the new name for this style.")); ImGui.Spacing(); ImGui.InputText("###renameModalInput", ref this.renameText, 255); const float buttonWidth = 120f; ImGui.SetCursorPosX((ImGui.GetWindowWidth() - buttonWidth) / 2); if (ImGui.Button("OK", new Vector2(buttonWidth, 40))) { config.SavedStyles[this.currentSel].Name = this.renameText; config.Save(); ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } }