Compare commits
No commits in common. "3a54a2781fc5b70181706f9b47722b177c07352b" and "c623aa6fff69b4b944193c83dfb5e4a3a59dff15" have entirely different histories.
3a54a2781f
...
c623aa6fff
6 changed files with 23 additions and 168 deletions
|
@ -1,9 +1,6 @@
|
|||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Plugin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace CustomResolution;
|
||||
|
||||
|
@ -18,9 +15,6 @@ public class Configuration : IPluginConfiguration
|
|||
public uint Width = 1024;
|
||||
public uint Height = 1024;
|
||||
|
||||
public VirtualKey HotkeyKey = VirtualKey.NO_KEY;
|
||||
public ModifierKey HotkeyModifier = ModifierKey.NONE;
|
||||
|
||||
public DXVKDWMHackMode DXVKDWMHackMode = DXVKDWMHackMode.Off;
|
||||
|
||||
[NonSerialized]
|
||||
|
@ -74,52 +68,3 @@ public static class DXVKDWMHackModeExt
|
|||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
public enum ModifierKey
|
||||
{
|
||||
NONE = 0,
|
||||
CTRL = 1,
|
||||
ALT = 2,
|
||||
SHIFT = 4
|
||||
}
|
||||
|
||||
public static class VirtualKeyExt
|
||||
{
|
||||
private static readonly Dictionary<VirtualKey, string> _strings = new();
|
||||
|
||||
static VirtualKeyExt()
|
||||
{
|
||||
foreach (var field in typeof(VirtualKey).GetFields(BindingFlags.Public | BindingFlags.Static))
|
||||
{
|
||||
var key = (VirtualKey) field.GetValue(null)!;
|
||||
_strings[key] = key.GetFancyName();
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToHumanNameString(this VirtualKey mode)
|
||||
{
|
||||
return _strings[mode];
|
||||
}
|
||||
|
||||
public static string? ToHumanInfoString(this VirtualKey mode) => mode switch
|
||||
{
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
public static class ModifierKeyExt
|
||||
{
|
||||
public static string ToHumanNameString(this ModifierKey mode) => mode switch
|
||||
{
|
||||
ModifierKey.NONE => "None",
|
||||
ModifierKey.CTRL => "Ctrl",
|
||||
ModifierKey.ALT => "Alt",
|
||||
ModifierKey.SHIFT => "Shift",
|
||||
_ => mode.ToString(),
|
||||
};
|
||||
|
||||
public static string? ToHumanInfoString(this ModifierKey mode) => mode switch
|
||||
{
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<Authors>0x0ade</Authors>
|
||||
<Company></Company>
|
||||
<Version>0.2.1.0</Version>
|
||||
<Version>0.2.0.4</Version>
|
||||
<Description></Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl></PackageProjectUrl>
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
using FFXIVClientStructs.FFXIV.Common.Lua;
|
||||
using FFXIVClientStructs.Interop;
|
||||
using ImGuiNET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -17,8 +14,6 @@ namespace CustomResolution;
|
|||
|
||||
public sealed unsafe class Plugin : IDalamudPlugin
|
||||
{
|
||||
private object _disposeLock = new();
|
||||
|
||||
private readonly HRGN _invisibleRgn;
|
||||
|
||||
private readonly List<Cmd> _cmds;
|
||||
|
@ -73,16 +68,12 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_tickCount = 0;
|
||||
_unloading = true;
|
||||
|
||||
lock (_disposeLock)
|
||||
{
|
||||
_tickCount = 0;
|
||||
Service.Framework.Update -= OnFrameworkUpdate;
|
||||
|
||||
Service.Framework.Update -= OnFrameworkUpdate;
|
||||
|
||||
Service.Framework.RunOnFrameworkThread(Update);
|
||||
}
|
||||
Service.Framework.RunOnFrameworkThread(Update);
|
||||
|
||||
foreach (Cmd cmd in _cmds)
|
||||
{
|
||||
|
@ -319,44 +310,24 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
|||
|
||||
private void OnFrameworkUpdate(IFramework framework)
|
||||
{
|
||||
lock (_disposeLock)
|
||||
var dev = Device.Instance();
|
||||
|
||||
_currentHwnd = (HWND) (IntPtr) dev->hWnd;
|
||||
|
||||
fixed (RECT* currentClientRectPtr = &_currentClientRect)
|
||||
fixed (RECT* currentWindowRectPtr = &_currentWindowRect)
|
||||
{
|
||||
var io = ImGui.GetIO();
|
||||
|
||||
if (Service.Config.HotkeyKey != VirtualKey.NO_KEY &&
|
||||
(ImGuiNative.igIsKeyPressed((ImGuiKey) Service.Config.HotkeyKey, 0) != 0 || Service.KeyState.GetRawValue(Service.Config.HotkeyKey) != 0) &&
|
||||
(Service.Config.HotkeyModifier switch
|
||||
{
|
||||
ModifierKey.NONE => !io.KeyCtrl && !io.KeyAlt && !io.KeyShift,
|
||||
ModifierKey.CTRL => io.KeyCtrl && !io.KeyAlt && !io.KeyShift,
|
||||
ModifierKey.ALT => !io.KeyCtrl && io.KeyAlt && !io.KeyShift,
|
||||
ModifierKey.SHIFT => !io.KeyCtrl && !io.KeyAlt && io.KeyShift,
|
||||
_ => false,
|
||||
}))
|
||||
{
|
||||
Service.Config.IsEnabled = !Service.Config.IsEnabled;
|
||||
Service.Config.Save();
|
||||
}
|
||||
|
||||
var dev = Device.Instance();
|
||||
|
||||
_currentHwnd = (HWND) (IntPtr) dev->hWnd;
|
||||
|
||||
fixed (RECT* currentClientRectPtr = &_currentClientRect)
|
||||
fixed (RECT* currentWindowRectPtr = &_currentWindowRect)
|
||||
{
|
||||
GetClientRect(_currentHwnd, currentClientRectPtr);
|
||||
GetWindowRect(_currentHwnd, currentWindowRectPtr);
|
||||
}
|
||||
|
||||
if (_tickCount++ >= 2)
|
||||
{
|
||||
_tickCount = 0;
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
_tickCount++;
|
||||
GetClientRect(_currentHwnd, currentClientRectPtr);
|
||||
GetWindowRect(_currentHwnd, currentWindowRectPtr);
|
||||
}
|
||||
|
||||
if (_tickCount++ >= 10)
|
||||
{
|
||||
_tickCount = 0;
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
_tickCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ public sealed class PluginUI : IDisposable
|
|||
|
||||
internal PluginUI()
|
||||
{
|
||||
Service.PluginInterface.UiBuilder.DisableGposeUiHide = true;
|
||||
Service.PluginInterface.UiBuilder.Draw += Draw;
|
||||
Service.PluginInterface.UiBuilder.OpenConfigUi += ShowConfigWindow;
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ public sealed class Service
|
|||
[PluginService]
|
||||
public static IChatGui ChatGui { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
public static IKeyState KeyState { get; private set; } = null!;
|
||||
|
||||
public static void PrintChat(string msg)
|
||||
{
|
||||
ChatGui.Print(new XivChatEntry
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
using Dalamud.Game.ClientState.Keys;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace CustomResolution.Windows;
|
||||
|
||||
public class ConfigWindow : Window, IDisposable
|
||||
{
|
||||
private VirtualKey[] _validKeys = new VirtualKey[] { VirtualKey.NO_KEY }.Union(Service.KeyState.GetValidVirtualKeys()).ToArray();
|
||||
|
||||
private int[] _displayCurrentWH = new int[2];
|
||||
private int[] _displayCurrentWindowWH = new int[2];
|
||||
|
||||
private bool _configIsEnabled;
|
||||
private VirtualKey _configHotkeyKey;
|
||||
private ModifierKey _configHotkeyModifier;
|
||||
private bool _configIsScale;
|
||||
private float _configScale;
|
||||
private int[] _configWH = new int[2];
|
||||
|
@ -38,8 +32,6 @@ public class ConfigWindow : Window, IDisposable
|
|||
var config = Service.Config;
|
||||
|
||||
_configIsEnabled = config.IsEnabled;
|
||||
_configHotkeyKey = config.HotkeyKey;
|
||||
_configHotkeyModifier = config.HotkeyModifier;
|
||||
_configIsScale = config.IsScale;
|
||||
_configScale = config.Scale;
|
||||
_configWH[0] = (int) config.Width;
|
||||
|
@ -52,8 +44,6 @@ public class ConfigWindow : Window, IDisposable
|
|||
var config = Service.Config;
|
||||
|
||||
config.IsEnabled = _configIsEnabled;
|
||||
config.HotkeyKey = _configHotkeyKey;
|
||||
config.HotkeyModifier = _configHotkeyModifier;
|
||||
config.IsScale = _configIsScale;
|
||||
config.Scale = _configScale;
|
||||
config.Width = (uint) _configWH[0];
|
||||
|
@ -80,53 +70,6 @@ public class ConfigWindow : Window, IDisposable
|
|||
|
||||
ImGui.Checkbox("Enabled", ref _configIsEnabled);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.Dummy(new Vector2(20, 0));
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.BeginCombo("##_configHotkeyModifier", _configHotkeyModifier.ToHumanNameString()))
|
||||
{
|
||||
foreach (var key in Enum.GetValues<ModifierKey>())
|
||||
{
|
||||
if (ImGui.Selectable(key.ToHumanNameString(), _configHotkeyModifier == key, ImGuiSelectableFlags.None))
|
||||
{
|
||||
_configHotkeyModifier = key;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered() && key.ToHumanInfoString() is { } info)
|
||||
{
|
||||
ImGui.SetTooltip(info);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(160);
|
||||
if (ImGui.BeginCombo("##_configHotkeyKey", _configHotkeyKey.ToHumanNameString()))
|
||||
{
|
||||
foreach (var key in _validKeys)
|
||||
{
|
||||
if (ImGui.Selectable(key.ToHumanNameString(), _configHotkeyKey == key, ImGuiSelectableFlags.None))
|
||||
{
|
||||
_configHotkeyKey = key;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered() && key.ToHumanInfoString() is { } info)
|
||||
{
|
||||
ImGui.SetTooltip(info);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.Text("Hotkey");
|
||||
|
||||
|
||||
if (!_configIsEnabled)
|
||||
{
|
||||
ImGui.BeginDisabled();
|
||||
|
|
Loading…
Add table
Reference in a new issue