From 264544ebc469d9f7f5cc212f5705147df67aa25b Mon Sep 17 00:00:00 2001 From: OldManAlpha <60587722+OldManAlpha@users.noreply.github.com> Date: Sat, 9 Aug 2025 23:20:17 -0700 Subject: [PATCH] Keys now animate health like mouse buttons --- PTUnitFrame.lua | 6 ++++++ PuppeteerSettings.lua | 7 +++++++ core/OverrideBindings.lua | 10 +++++++++- gui/Settings.lua | 3 +-- gui/component/ButtonEditor.lua | 4 ++-- libs/Util.lua | 5 +++++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/PTUnitFrame.lua b/PTUnitFrame.lua index b05260a..20e2e2b 100644 --- a/PTUnitFrame.lua +++ b/PTUnitFrame.lua @@ -1279,6 +1279,12 @@ function PTUnitFrame:Initialize() end PT.Mouseover = nil PT.MouseoverFrame = nil + if PT.CurrentlyHeldButton and not util.GetAllButtonsSet()[PT.CurrentlyHeldButton] then + self.pressed = false + self:AdjustHealthPosition() + PT.CurrentlyHeldButton = nil + PT.ReapplySpellsTooltip() + end PT.RemoveOverrideBindings() end) button:EnableMouse(true) diff --git a/PuppeteerSettings.lua b/PuppeteerSettings.lua index f1c98f6..93d5a67 100644 --- a/PuppeteerSettings.lua +++ b/PuppeteerSettings.lua @@ -460,6 +460,13 @@ function IsFrameHidden(frameName) return PTOptions.FrameOptions[frameName] and PTOptions.FrameOptions[frameName].Hidden end +function SetFrameHidden(frameName, hidden) + if not PTOptions.FrameOptions[frameName] then + PTOptions.FrameOptions[frameName] = {} + end + PTOptions.FrameOptions[frameName].Hidden = hidden +end + function IsFrameLocked(frameName) return PTOptions.FrameOptions[frameName] and PTOptions.FrameOptions[frameName].Locked end diff --git a/core/OverrideBindings.lua b/core/OverrideBindings.lua index 38bd72e..5ef923f 100644 --- a/core/OverrideBindings.lua +++ b/core/OverrideBindings.lua @@ -33,7 +33,7 @@ function InitOverrideBindingsMapping() util.ClearTable(KeybindIndexMap) local index = 1 for _, button in ipairs(PTOptions.Buttons) do - if not util.ArrayContains(util.GetAllButtons(), button) then + if not util.GetAllButtonsSet()[button] then for _, prefix in ipairs(BindingPrefixes) do KeybindIndexMap[prefix..button] = index end @@ -158,6 +158,8 @@ function HandleKeyPress(index) local button = IndexButtonMap[index] if keystate == "down" then CurrentlyHeldButton = button + MouseoverFrame.pressed = true + MouseoverFrame:AdjustHealthPosition() if button == "MOUSEWHEELUP" or button == "MOUSEWHEELDOWN" then FakeMouseWheelHold(button) end @@ -168,6 +170,8 @@ function HandleKeyPress(index) else if button ~= "MOUSEWHEELUP" and button ~= "MOUSEWHEELDOWN" then CurrentlyHeldButton = nil + MouseoverFrame.pressed = false + MouseoverFrame:AdjustHealthPosition() ReapplySpellsTooltip() end if PTOptions.CastWhenKey == "Key Up" then @@ -185,6 +189,10 @@ local MouseWheelHeldFaker_OnUpdate = function() MouseWheelHeldFaker:SetScript("OnUpdate", nil) if CurrentlyHeldButton == unholdButton then CurrentlyHeldButton = nil + if MouseoverFrame then + MouseoverFrame.pressed = false + MouseoverFrame:AdjustHealthPosition() + end ReapplySpellsTooltip() end end diff --git a/gui/Settings.lua b/gui/Settings.lua index 598333b..29cb070 100644 --- a/gui/Settings.lua +++ b/gui/Settings.lua @@ -744,8 +744,7 @@ function CreateTab_Customize() if not PTOptions.FrameOptions[frameName] then PTOptions.FrameOptions[frameName] = {} end - local options = PTOptions.FrameOptions[frameName] - options.Hidden = self:GetChecked() == 1 + PuppeteerSettings.SetFrameHidden(frameName, self:GetChecked() == 1) Puppeteer.CheckGroup() end) layout:column(2):levelAt(1):layoutComponent(hideFrameCheckbox) diff --git a/gui/component/ButtonEditor.lua b/gui/component/ButtonEditor.lua index 7474cc2..0d9e0c9 100644 --- a/gui/component/ButtonEditor.lua +++ b/gui/component/ButtonEditor.lua @@ -182,10 +182,10 @@ function PTButtonEditor:ContainsButton(button) end function PTButtonEditor:GetNumUsedBindings() - local nonBindingButtons = util.GetAllButtons() + local nonBindingButtons = util.GetAllButtonsSet() local used = 0 for button, _ in pairs(self.LineMap) do - if not util.ArrayContains(nonBindingButtons, button) then + if not nonBindingButtons[button] then used = used + 1 end end diff --git a/libs/Util.lua b/libs/Util.lua index fea44a6..9afeb3d 100644 --- a/libs/Util.lua +++ b/libs/Util.lua @@ -1005,6 +1005,11 @@ function GetAllButtons() return buttons end +local buttonsSet = ToSet(buttons, true) +function GetAllButtonsSet() + return buttonsSet +end + local upButtons = {} for _, button in ipairs(buttons) do table.insert(upButtons, button.."Up")