Skip to content

Commit

Permalink
Process bindings when entering/leaving combat only if required, fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Snakybo committed Feb 11, 2024
1 parent d03531d commit 74bca8c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel

* Add support for Classic Era 1.15.1
* Add icons from Classic Era 1.15.1 to icon picker
* Onky re-process bingings when entering and leaving combat if required [#189]

## [1.14.3] - 2024-01-17

Expand Down Expand Up @@ -1377,6 +1378,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
[0.4.0]: https://github.com/Snakybo/Clicked/releases/tag/0.4.0
[0.3.0]: https://github.com/Snakybo/Clicked/releases/tag/0.3.0

[#189]: https://github.com/Snakybo/Clicked/issues/189
[#186]: https://github.com/Snakybo/Clicked/issues/186
[#184]: https://github.com/Snakybo/Clicked/issues/184
[#182]: https://github.com/Snakybo/Clicked/issues/182
Expand Down
11 changes: 11 additions & 0 deletions Clicked/Config/Bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,17 @@ local function DrawMacroCombat(container, combat)
}

DrawDropdownLoadOption(container, Addon.L["Combat"], items, order, combat)

local binding = GetCurrentBinding()
if binding ~= nil and combat.selected and (binding.type == Addon.BindingTypes.UNIT_MENU or binding.type == Addon.BindingTypes.UNIT_SELECT) then
local text = Addon.L["Combat state checks for this binding require additional processing when entering and leaving combat and may cause slight performance degradation."]

local widget = Addon:GUI_Label(text)
widget:SetFullWidth(true)
widget:SetColor(1, 0, 0)

container:AddChild(widget)
end
end

--- @param container AceGUIContainer
Expand Down
10 changes: 8 additions & 2 deletions Clicked/Core/Clicked.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,21 @@ local function PLAYER_REGEN_DISABLED()
openConfigOnCombatExit = Addon:BindingConfig_Close()

Addon:AbilityTooltips_Refresh()
Clicked:ProcessActiveBindings()

if Addon:IsCombatProcessRequired() then
Clicked:ProcessActiveBindings()
end
end

local function PLAYER_REGEN_ENABLED()
isPlayerInCombat = false

Addon:ProcessFrameQueue()
Addon:AbilityTooltips_Refresh()
Clicked:ProcessActiveBindings()

if Addon:IsCombatProcessRequired() then
Clicked:ProcessActiveBindings()
end

if openConfigOnCombatExit then
Addon:BindingConfig_Open()
Expand Down
15 changes: 15 additions & 0 deletions Clicked/Core/CommandProcessor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Addon.MACRO_FRAME_HANDLER_NAME = "ClickedMacroFrameHandler"
--- @type Button
local macroFrameHandler

--- @type boolean
local requiresCombatProcess = false

-- Local support functions

--- @param frame Frame
Expand Down Expand Up @@ -183,6 +186,7 @@ function Addon:ProcessCommands(commands)

-- Unregister all current keybinds
macroFrameHandler:Hide()
requiresCombatProcess = false

for _, command in ipairs(commands) do
local attributes = {}
Expand Down Expand Up @@ -217,6 +221,10 @@ function Addon:ProcessCommands(commands)
for attribute, value in pairs(attributes) do
targetAttributes[attribute] = value
end

if (command.action == Addon.CommandType.TARGET or command.action == Addon.CommandType.MENU) and command.data ~= nil then
requiresCombatProcess = true
end
end

Addon:StatusOutput_UpdateMacroHandlerAttributes(newMacroFrameHandlerAttributes)
Expand All @@ -229,3 +237,10 @@ function Addon:ProcessCommands(commands)
Addon:UpdateClickCastHeader(newClickCastFrameKeybinds)
Addon:UpdateClickCastFrames(newClickCastFrameAttributes)
end

--- Get whether re-procesing of active bindings should happen when entering and leaving combat.
---
---@return boolean
function Addon:IsCombatProcessRequired()
return requiresCombatProcess
end
1 change: 1 addition & 0 deletions Clicked/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,4 @@ L["Show interface actions"] = true
L["All"] = true
L["External"] = true
L["Filter bindings"] = true
L["Combat state checks for this binding require additional processing when entering and leaving combat and may cause slight performance degradation."] = true

0 comments on commit 74bca8c

Please sign in to comment.