mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add option to configure minimum window size.
This commit is contained in:
parent
d403f44256
commit
f9cc88cbb0
4 changed files with 79 additions and 6 deletions
|
|
@ -79,6 +79,7 @@ public class CommandHandler : IDisposable
|
|||
"reload" => Reload(arguments),
|
||||
"redraw" => Redraw(arguments),
|
||||
"lockui" => SetUiLockState(arguments),
|
||||
"size" => SetUiMinimumSize(arguments),
|
||||
"debug" => SetDebug(arguments),
|
||||
"collection" => SetCollection(arguments),
|
||||
"mod" => SetMod(arguments),
|
||||
|
|
@ -110,6 +111,7 @@ public class CommandHandler : IDisposable
|
|||
_chat.Print(new SeStringBuilder()
|
||||
.AddCommand("lockui", "Toggle the locked state of the main Penumbra window. Can be used with [on|off] to force specific state.")
|
||||
.BuiltString);
|
||||
_chat.Print(new SeStringBuilder().AddCommand("size", "Reset the minimum config window size to its default values.").BuiltString);
|
||||
_chat.Print(new SeStringBuilder()
|
||||
.AddCommand("debug", "Toggle debug mode for Penumbra. Can be used with [on|off] to force specific state.").BuiltString);
|
||||
_chat.Print(new SeStringBuilder()
|
||||
|
|
@ -203,6 +205,16 @@ public class CommandHandler : IDisposable
|
|||
return true;
|
||||
}
|
||||
|
||||
private bool SetUiMinimumSize(string _)
|
||||
{
|
||||
if (_config.MinimumSize.X == Configuration.Constants.MinimumSizeX && _config.MinimumSize.Y == Configuration.Constants.MinimumSizeY)
|
||||
return false;
|
||||
_config.MinimumSize.X = Configuration.Constants.MinimumSizeX;
|
||||
_config.MinimumSize.Y = Configuration.Constants.MinimumSizeY;
|
||||
_config.Save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SetCollection(string arguments)
|
||||
{
|
||||
if (arguments.Length == 0)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using OtterGui;
|
||||
|
|
@ -50,6 +51,8 @@ public class Configuration : IPluginConfiguration, ISavable
|
|||
public int OptionGroupCollapsibleMin { get; set; } = 5;
|
||||
|
||||
public bool DebugSeparateWindow = false;
|
||||
public Vector2 MinimumSize = new(Constants.MinimumSizeX, Constants.MinimumSizeY);
|
||||
|
||||
#if DEBUG
|
||||
public bool DebugMode { get; set; } = true;
|
||||
#else
|
||||
|
|
@ -144,6 +147,8 @@ public class Configuration : IPluginConfiguration, ISavable
|
|||
public const int MaxScaledSize = 80;
|
||||
public const int DefaultScaledSize = 20;
|
||||
public const int MinScaledSize = 5;
|
||||
public const int MinimumSizeX = 900;
|
||||
public const int MinimumSizeY = 675;
|
||||
|
||||
public static readonly ISortMode<Mod>[] ValidSortModes =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ public sealed class ConfigWindow : Window
|
|||
_validityChecker = checker;
|
||||
|
||||
RespectCloseHotkey = true;
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
MinimumSize = new Vector2(900, 675),
|
||||
MaximumSize = new Vector2(4096, 2160),
|
||||
};
|
||||
tutorial.UpdateTutorialStep();
|
||||
IsOpen = _config.DebugMode;
|
||||
}
|
||||
|
|
@ -66,6 +61,11 @@ public sealed class ConfigWindow : Window
|
|||
Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
|
||||
else
|
||||
Flags &= ~(ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove);
|
||||
SizeConstraints = new WindowSizeConstraints()
|
||||
{
|
||||
MinimumSize = _config.MinimumSize,
|
||||
MaximumSize = new Vector2(4096, 2160),
|
||||
};
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ public class SettingsTab : ITab
|
|||
private readonly DalamudServices _dalamud;
|
||||
private readonly HttpApi _httpApi;
|
||||
|
||||
private int _minimumX = int.MaxValue;
|
||||
private int _minimumY = int.MaxValue;
|
||||
|
||||
public SettingsTab(Configuration config, FontReloader fontReloader, TutorialService tutorial, Penumbra penumbra,
|
||||
FileDialogService fileDialog, ModManager modManager, ModFileSystemSelector selector, CharacterUtility characterUtility,
|
||||
ResidentResourceManager residentResources, DalamudServices dalamud, ModExportManager modExportManager, HttpApi httpApi)
|
||||
|
|
@ -637,6 +640,7 @@ public class SettingsTab : ITab
|
|||
if (!header)
|
||||
return;
|
||||
|
||||
DrawMinimumDimensionConfig();
|
||||
Checkbox("Auto Deduplicate on Import",
|
||||
"Automatically deduplicate mod files on import. This will make mod file sizes smaller, but deletes (binary identical) files.",
|
||||
_config.AutoDeduplicateOnImport, v => _config.AutoDeduplicateOnImport = v);
|
||||
|
|
@ -652,6 +656,58 @@ public class SettingsTab : ITab
|
|||
ImGui.NewLine();
|
||||
}
|
||||
|
||||
/// <summary> Draw two integral inputs for minimum dimensions of this window. </summary>
|
||||
private void DrawMinimumDimensionConfig()
|
||||
{
|
||||
var x = _minimumX == int.MaxValue ? (int)_config.MinimumSize.X : _minimumX;
|
||||
var y = _minimumY == int.MaxValue ? (int)_config.MinimumSize.Y : _minimumY;
|
||||
|
||||
var warning = x < Configuration.Constants.MinimumSizeX
|
||||
? y < Configuration.Constants.MinimumSizeY
|
||||
? "Size is smaller than default: This may look undesirable."
|
||||
: "Width is smaller than default: This may look undesirable."
|
||||
: y < Configuration.Constants.MinimumSizeY
|
||||
? "Height is smaller than default: This may look undesirable."
|
||||
: string.Empty;
|
||||
var buttonWidth = UiHelpers.InputTextWidth.X / 2.5f;
|
||||
ImGui.SetNextItemWidth(buttonWidth);
|
||||
if (ImGui.DragInt("##xMinSize", ref x, 0.1f, 500, 1500))
|
||||
_minimumX = x;
|
||||
var edited = ImGui.IsItemDeactivatedAfterEdit();
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(buttonWidth);
|
||||
if (ImGui.DragInt("##yMinSize", ref y, 0.1f, 300, 1500))
|
||||
_minimumY = y;
|
||||
edited |= ImGui.IsItemDeactivatedAfterEdit();
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGuiUtil.DrawDisabledButton("Reset##resetMinSize", new Vector2(buttonWidth / 2 - ImGui.GetStyle().ItemSpacing.X * 2, 0),
|
||||
$"Reset minimum dimensions to ({Configuration.Constants.MinimumSizeX}, {Configuration.Constants.MinimumSizeY}).",
|
||||
x == Configuration.Constants.MinimumSizeX && y == Configuration.Constants.MinimumSizeY))
|
||||
{
|
||||
x = Configuration.Constants.MinimumSizeX;
|
||||
y = Configuration.Constants.MinimumSizeY;
|
||||
edited = true;
|
||||
}
|
||||
|
||||
ImGuiUtil.LabeledHelpMarker("Minimum Window Dimensions",
|
||||
"Set the minimum dimensions for resizing this window. Reducing these dimensions may cause the window to look bad or more confusing and is not recommended.");
|
||||
|
||||
if (warning.Length > 0)
|
||||
ImGuiUtil.DrawTextButton(warning, UiHelpers.InputTextWidth, Colors.PressEnterWarningBg);
|
||||
else
|
||||
ImGui.NewLine();
|
||||
|
||||
if (!edited)
|
||||
return;
|
||||
|
||||
_config.MinimumSize = new Vector2(x, y);
|
||||
_minimumX = int.MaxValue;
|
||||
_minimumY = int.MaxValue;
|
||||
_config.Save();
|
||||
}
|
||||
|
||||
/// <summary> Draw a checkbox for the HTTP API that creates and destroys the web server when toggled. </summary>
|
||||
private void DrawEnableHttpApiBox()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue