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 15:24:19 +01:00
|
|
|
|
private bool _configIsDXVKDWMHackEnabled;
|
2024-02-14 00:05:07 +01:00
|
|
|
|
|
|
|
|
|
public ConfigWindow() : base(
|
|
|
|
|
"CustomResolution",
|
|
|
|
|
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
|
|
|
|
|
ImGuiWindowFlags.NoScrollWithMouse)
|
|
|
|
|
{
|
2024-03-16 15:24:19 +01:00
|
|
|
|
Size = new Vector2(430, 212);
|
2024-02-14 00:05:07 +01:00
|
|
|
|
SizeCondition = ImGuiCond.Always;
|
|
|
|
|
|
|
|
|
|
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 15:24:19 +01:00
|
|
|
|
_configIsDXVKDWMHackEnabled = config.IsDXVKDWMHackEnabled;
|
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 15:24:19 +01:00
|
|
|
|
config.IsDXVKDWMHackEnabled = _configIsDXVKDWMHackEnabled;
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui.Checkbox("Apply borderless window workaround", ref _configIsDXVKDWMHackEnabled);
|
|
|
|
|
if (ImGui.IsItemHovered())
|
|
|
|
|
{
|
|
|
|
|
ImGui.SetTooltip(@"Fixes DXVK borderless window acting like exclusive fullscreen.
|
|
|
|
|
In other words: Fixes black screen flashing when alt-tabbing.
|
|
|
|
|
This can *possibly* impact performance, depending on your Windows version and GPU.
|
|
|
|
|
Feel free to experiment with this toggle.
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|