core: Fix hotkey handling to take previous game state into account
This commit is contained in:
parent
ff12d438c6
commit
8bb4efc719
2 changed files with 14 additions and 3 deletions
|
@ -41,6 +41,9 @@ public struct ConfigurationV1
|
||||||
public VirtualKey HotkeyKey = VirtualKey.NO_KEY;
|
public VirtualKey HotkeyKey = VirtualKey.NO_KEY;
|
||||||
public ModifierKey HotkeyModifier = ModifierKey.NONE;
|
public ModifierKey HotkeyModifier = ModifierKey.NONE;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
public bool HotkeyKeyDown = false;
|
||||||
|
|
||||||
public SizeConfig()
|
public SizeConfig()
|
||||||
{
|
{
|
||||||
Width = 1024;
|
Width = 1024;
|
||||||
|
|
|
@ -90,10 +90,16 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
||||||
|
|
||||||
private void OnFrameworkUpdateForSize(ref ConfigurationV1.SizeConfig size)
|
private void OnFrameworkUpdateForSize(ref ConfigurationV1.SizeConfig size)
|
||||||
{
|
{
|
||||||
var io = ImGui.GetIO();
|
if (size.HotkeyKey == VirtualKey.NO_KEY)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (size.HotkeyKey != VirtualKey.NO_KEY &&
|
var io = ImGui.GetIO();
|
||||||
(ImGuiNative.igIsKeyPressed((ImGuiKey) size.HotkeyKey, 0) != 0 || Service.KeyState.GetRawValue(size.HotkeyKey) != 0) &&
|
var keyPressedIm = ImGuiNative.igIsKeyPressed((ImGuiKey) size.HotkeyKey, 0) != 0;
|
||||||
|
var keyDownXiv = Service.KeyState.GetRawValue(size.HotkeyKey) != 0;
|
||||||
|
|
||||||
|
if ((keyPressedIm || (keyDownXiv && !size.HotkeyKeyDown)) &&
|
||||||
(size.HotkeyModifier switch
|
(size.HotkeyModifier switch
|
||||||
{
|
{
|
||||||
ModifierKey.NONE => !io.KeyCtrl && !io.KeyAlt && !io.KeyShift,
|
ModifierKey.NONE => !io.KeyCtrl && !io.KeyAlt && !io.KeyShift,
|
||||||
|
@ -106,6 +112,8 @@ public sealed unsafe class Plugin : IDalamudPlugin
|
||||||
size.IsEnabled = !size.IsEnabled;
|
size.IsEnabled = !size.IsEnabled;
|
||||||
Service.Config.Save();
|
Service.Config.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size.HotkeyKeyDown = keyDownXiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFrameworkUpdate(IFramework framework)
|
private void OnFrameworkUpdate(IFramework framework)
|
||||||
|
|
Loading…
Add table
Reference in a new issue