2024-02-14 00:05:07 +01:00
|
|
|
|
using Dalamud.Interface.Windowing;
|
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Numerics;
|
|
|
|
|
|
|
|
|
|
namespace CustomResolution.Windows;
|
|
|
|
|
|
|
|
|
|
public class ConfigWindow : Window, IDisposable
|
|
|
|
|
{
|
|
|
|
|
private int[] _displayCurrentWH = new int[2];
|
|
|
|
|
private int[] _displayCurrentWindowWH = new int[2];
|
|
|
|
|
|
2024-02-18 22:48:02 +01:00
|
|
|
|
private bool _configIsEnabled;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
private bool _configIsScale;
|
|
|
|
|
private float _configScale;
|
|
|
|
|
private int[] _configWH = new int[2];
|
2024-03-16 21:29:16 +01:00
|
|
|
|
private DXVKDWMHackMode _configDXVKDWMHackMode;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
|
|
|
|
|
public ConfigWindow() : base(
|
|
|
|
|
"CustomResolution",
|
|
|
|
|
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
|
2024-03-16 21:29:16 +01:00
|
|
|
|
ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.AlwaysAutoResize)
|
2024-02-14 00:05:07 +01:00
|
|
|
|
{
|
|
|
|
|
UpdateFromConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateFromConfig()
|
|
|
|
|
{
|
|
|
|
|
var config = Service.Config;
|
|
|
|
|
|
2024-02-18 22:48:02 +01:00
|
|
|
|
_configIsEnabled = config.IsEnabled;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
_configIsScale = config.IsScale;
|
|
|
|
|
_configScale = config.Scale;
|
|
|
|
|
_configWH[0] = (int) config.Width;
|
|
|
|
|
_configWH[1] = (int) config.Height;
|
2024-03-16 21:29:16 +01:00
|
|
|
|
_configDXVKDWMHackMode = config.DXVKDWMHackMode;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateToConfig()
|
|
|
|
|
{
|
|
|
|
|
var config = Service.Config;
|
|
|
|
|
|
2024-02-18 22:48:02 +01:00
|
|
|
|
config.IsEnabled = _configIsEnabled;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
config.IsScale = _configIsScale;
|
|
|
|
|
config.Scale = _configScale;
|
|
|
|
|
config.Width = (uint) _configWH[0];
|
|
|
|
|
config.Height = (uint) _configWH[1];
|
2024-03-16 21:29:16 +01:00
|
|
|
|
config.DXVKDWMHackMode = _configDXVKDWMHackMode;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
|
|
|
|
|
config.Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw()
|
|
|
|
|
{
|
|
|
|
|
var plugin = Service.Plugin;
|
2024-02-16 00:05:51 +01:00
|
|
|
|
var save = false;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
|
|
|
|
|
_displayCurrentWH[0] = (int) plugin.CurrentWidth;
|
|
|
|
|
_displayCurrentWH[1] = (int) plugin.CurrentHeight;
|
|
|
|
|
_displayCurrentWindowWH[0] = (int) plugin.CurrentWindowWidth;
|
|
|
|
|
_displayCurrentWindowWH[1] = (int) plugin.CurrentWindowHeight;
|
|
|
|
|
|
|
|
|
|
ImGui.BeginDisabled();
|
|
|
|
|
ImGui.InputInt2("Current window size", ref _displayCurrentWindowWH[0]);
|
|
|
|
|
ImGui.InputInt2("Current render size", ref _displayCurrentWH[0]);
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
|
2024-02-18 22:48:02 +01:00
|
|
|
|
ImGui.Checkbox("Enabled", ref _configIsEnabled);
|
|
|
|
|
|
2024-03-16 15:24:19 +01:00
|
|
|
|
if (!_configIsEnabled)
|
|
|
|
|
{
|
|
|
|
|
ImGui.BeginDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-14 00:05:07 +01:00
|
|
|
|
ImGui.Checkbox("Use scale", ref _configIsScale);
|
|
|
|
|
|
|
|
|
|
if (_configIsScale)
|
|
|
|
|
{
|
2024-02-16 00:05:51 +01:00
|
|
|
|
if (ImGui.InputFloat("Scale", ref _configScale, 0.01f, 0.1f, "%.3f", ImGuiInputTextFlags.EnterReturnsTrue))
|
|
|
|
|
{
|
|
|
|
|
save = true;
|
|
|
|
|
}
|
2024-02-14 00:05:07 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-02-18 18:21:18 +01:00
|
|
|
|
ImGui.InputInt2("Size in pixels", ref _configWH[0]);
|
2024-02-14 00:05:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 15:24:19 +01:00
|
|
|
|
if (!_configIsEnabled)
|
|
|
|
|
{
|
|
|
|
|
ImGui.EndDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 21:29:16 +01:00
|
|
|
|
if (ImGui.BeginCombo("Borderless window workaround", _configDXVKDWMHackMode.ToHumanNameString()))
|
|
|
|
|
{
|
|
|
|
|
foreach (var mode in Enum.GetValues<DXVKDWMHackMode>())
|
|
|
|
|
{
|
|
|
|
|
if (ImGui.Selectable(mode.ToHumanNameString(), _configDXVKDWMHackMode == mode, ImGuiSelectableFlags.None))
|
|
|
|
|
{
|
|
|
|
|
_configDXVKDWMHackMode = mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ImGui.IsItemHovered() && mode.ToHumanInfoString() is { } info)
|
|
|
|
|
{
|
|
|
|
|
ImGui.SetTooltip(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.EndCombo();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 15:24:19 +01:00
|
|
|
|
if (ImGui.IsItemHovered())
|
|
|
|
|
{
|
2024-03-16 21:29:16 +01:00
|
|
|
|
ImGui.SetTooltip(@"Fixes DXVK borderless window causing black screens when alt-tabbing.
|
2024-03-16 15:24:19 +01:00
|
|
|
|
This can *possibly* impact performance, depending on your Windows version and GPU.
|
2024-03-16 21:29:16 +01:00
|
|
|
|
|
2024-03-16 15:24:19 +01:00
|
|
|
|
Feel free to experiment with this toggle.
|
2024-03-16 21:29:16 +01:00
|
|
|
|
Make sure to switch the game to windowed and then back to borderless windowed when changing.
|
2024-03-16 15:24:19 +01:00
|
|
|
|
|
|
|
|
|
Works even with the scaling above disabled.
|
|
|
|
|
|
|
|
|
|
Not intended to be used with proper fullscreen.");
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-14 00:05:07 +01:00
|
|
|
|
if (ImGui.Button("Save and apply"))
|
2024-02-16 00:05:51 +01:00
|
|
|
|
{
|
|
|
|
|
save = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (save)
|
2024-02-14 00:05:07 +01:00
|
|
|
|
{
|
|
|
|
|
UpdateToConfig();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|