From 2596fde05b78c2833aea9f2795328fb832c4d678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 22:09:50 +0200 Subject: [PATCH 1/5] Apply click casting for blizzard frames --- Modules/ClickCastings.lua | 2 +- Utils.lua | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index 76f6ea20..aa28e1a2 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -538,7 +538,7 @@ local function UpdateClickCastings(noReload) -- load db and set attribute ApplyClickCastings(b) - end, false, true) + end, false, true, true) previousClickCastings = F:Copy(clickCastingTable) end Cell:RegisterCallback("UpdateClickCastings", "UpdateClickCastings", UpdateClickCastings) diff --git a/Utils.lua b/Utils.lua index cd5eedd9..513a1835 100644 --- a/Utils.lua +++ b/Utils.lua @@ -778,9 +778,26 @@ end ------------------------------------------------- local combinedHeader = "CellRaidFrameHeader0" local separatedHeaders = {"CellRaidFrameHeader1", "CellRaidFrameHeader2", "CellRaidFrameHeader3", "CellRaidFrameHeader4", "CellRaidFrameHeader5", "CellRaidFrameHeader6", "CellRaidFrameHeader7", "CellRaidFrameHeader8"} - -function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist) - -- solo +local blizzardFrames = { + "PlayerFrame", + "TargetFrame", + "PetFrame", + "PartyMemberFrame1", + "PartyMemberFrame2", + "PartyMemberFrame3", + "PartyMemberFrame4", + "PartyMemberFrame1PetFrame", + "PartyMemberFrame2PetFrame", + "PartyMemberFrame3PetFrame", + "PartyMemberFrame4PetFrame", +} +function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) + if updateBlizzardFrames then + for _, b in pairs(blizzardFrames) do + func(_G[b]) + end + end + -- solo if not updateCurrentGroupOnly or (updateCurrentGroupOnly and Cell.vars.groupType == "solo") then for _, b in pairs(Cell.unitButtons.solo) do func(b) From 5de9c1d7970ef202fd79bf27fd0bbddacd0389b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 22:12:57 +0200 Subject: [PATCH 2/5] Handle nils --- Utils.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Utils.lua b/Utils.lua index 513a1835..442a029e 100644 --- a/Utils.lua +++ b/Utils.lua @@ -794,7 +794,10 @@ local blizzardFrames = { function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) if updateBlizzardFrames then for _, b in pairs(blizzardFrames) do - func(_G[b]) + local frame = _G[b] + if frame then + func(frame) + end end end -- solo From d97ef4e466f8cfb84536121329aaee3e76a6c430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Wed, 12 Jun 2024 22:14:27 +0200 Subject: [PATCH 3/5] whitespace --- Utils.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utils.lua b/Utils.lua index 442a029e..b1b97753 100644 --- a/Utils.lua +++ b/Utils.lua @@ -779,9 +779,9 @@ end local combinedHeader = "CellRaidFrameHeader0" local separatedHeaders = {"CellRaidFrameHeader1", "CellRaidFrameHeader2", "CellRaidFrameHeader3", "CellRaidFrameHeader4", "CellRaidFrameHeader5", "CellRaidFrameHeader6", "CellRaidFrameHeader7", "CellRaidFrameHeader8"} local blizzardFrames = { - "PlayerFrame", - "TargetFrame", - "PetFrame", + "PlayerFrame", + "TargetFrame", + "PetFrame", "PartyMemberFrame1", "PartyMemberFrame2", "PartyMemberFrame3", From 5f36a71b71fa30ac29dc031683e6f98048b4d442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 18 Jun 2024 22:45:18 +0200 Subject: [PATCH 4/5] Add custom click casting frames --- Core.lua | 35 +++++++++++++++++++++++++- Core_Cata.lua | 37 ++++++++++++++++++++++++++- Core_Vanilla.lua | 35 +++++++++++++++++++++++++- Modules/ClickCastings.lua | 53 +++++++++++++++++++++++++++------------ Utils.lua | 19 +++++++++++++- 5 files changed, 159 insertions(+), 20 deletions(-) diff --git a/Core.lua b/Core.lua index 86492f07..552fb182 100644 --- a/Core.lua +++ b/Core.lua @@ -375,6 +375,7 @@ function eventFrame:ADDON_LOADED(arg1) if type(CellDB["clickCastings"][Cell.vars.playerClass]) ~= "table" then CellDB["clickCastings"][Cell.vars.playerClass] = { ["useCommon"] = true, + ["hookBlizzardFrames"] = false, ["smartResurrection"] = "disabled", ["alwaysTargeting"] = { ["common"] = "disabled", @@ -713,6 +714,38 @@ function eventFrame:PLAYER_ENTERING_WORLD() end end +local function registerGlobalClickCastings() + ClickCastFrames = ClickCastFrames or {} + + if ClickCastFrames then + for frame, options in pairs(ClickCastFrames) do + F:RegisterFrame(frame, false) + end + end + + ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v) + if v == nil or v == false then + F:UnregisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + else + F:RegisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + end + end}) + + for _, name in pairs(Cell.blizzardFrames) do + local frame = _G[name] + if frame then + F:RegisterFrame(frame, false) + end + end + + F:IterateAllUnitButtons(function (b) + F:RegisterFrame(b, true) + end) + Cell:Fire("UpdateClickCastings") +end + function eventFrame:PLAYER_LOGIN() F:Debug("|cffbbbbbb=== PLAYER_LOGIN ===") eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -743,7 +776,7 @@ function eventFrame:PLAYER_LOGIN() -- update visibility Cell:Fire("UpdateVisibility") -- update click-castings - Cell:Fire("UpdateClickCastings") + registerGlobalClickCastings() -- update indicators -- Cell:Fire("UpdateIndicators") -- NOTE: already update in GROUP_ROSTER_UPDATE -> GroupTypeChanged -> F:UpdateLayout -- update texture and font diff --git a/Core_Cata.lua b/Core_Cata.lua index 8b3d2fee..84285010 100644 --- a/Core_Cata.lua +++ b/Core_Cata.lua @@ -338,6 +338,7 @@ function eventFrame:ADDON_LOADED(arg1) CellCharacterDB["clickCastings"] = { ["class"] = Cell.vars.playerClass, -- NOTE: validate on import ["useCommon"] = true, + ["hookBlizzardFrames"] = false, ["smartResurrection"] = "disabled", ["alwaysTargeting"] = { ["common"] = "disabled", @@ -675,6 +676,40 @@ local function UpdateSpecVars(exceptActiveTalentGroup) end end + +local function registerGlobalClickCastings() + ClickCastFrames = ClickCastFrames or {} + + if ClickCastFrames then + for frame, options in pairs(ClickCastFrames) do + F:RegisterFrame(frame, false) + end + end + + ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v) + if v == nil or v == false then + F:UnregisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + else + F:RegisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + end + end}) + + for _, name in pairs(Cell.blizzardFrames) do + local frame = _G[name] + if frame then + F:RegisterFrame(frame, false) + end + end + + F:IterateAllUnitButtons(function (b) + F:RegisterFrame(b, true) + end) + Cell:Fire("UpdateClickCastings") +end + + function eventFrame:PLAYER_LOGIN() F:Debug("|cffbbbbbb=== PLAYER_LOGIN ===") eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -704,7 +739,7 @@ function eventFrame:PLAYER_LOGIN() -- update visibility Cell:Fire("UpdateVisibility") -- update click-castings - Cell:Fire("UpdateClickCastings") + registerGlobalClickCastings() -- update indicators -- Cell:Fire("UpdateIndicators") -- NOTE: already update in GROUP_ROSTER_UPDATE -> GroupTypeChanged -> F:UpdateLayout -- update texture and font diff --git a/Core_Vanilla.lua b/Core_Vanilla.lua index d63f010f..57dc7268 100644 --- a/Core_Vanilla.lua +++ b/Core_Vanilla.lua @@ -322,6 +322,7 @@ function eventFrame:ADDON_LOADED(arg1) CellCharacterDB["clickCastings"] = { ["class"] = Cell.vars.playerClass, -- validate on import ["useCommon"] = true, + ["hookBlizzardFrames"] = false, ["smartResurrection"] = "disabled", ["alwaysTargeting"] = { ["common"] = "disabled", @@ -611,6 +612,38 @@ function eventFrame:PLAYER_ENTERING_WORLD() end end +local function registerGlobalClickCastings() + ClickCastFrames = ClickCastFrames or {} + + if ClickCastFrames then + for frame, options in pairs(ClickCastFrames) do + F:RegisterFrame(frame, false) + end + end + + ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v) + if v == nil or v == false then + F:UnregisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + else + F:RegisterFrame(k, false) + Cell:Fire("UpdateClickCastings") + end + end}) + + for _, name in pairs(Cell.blizzardFrames) do + local frame = _G[name] + if frame then + F:RegisterFrame(frame, false) + end + end + + F:IterateAllUnitButtons(function (b) + F:RegisterFrame(b, true) + end) + Cell:Fire("UpdateClickCastings") +end + function eventFrame:PLAYER_LOGIN() F:Debug("|cffbbbbbb=== PLAYER_LOGIN ===") eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD") @@ -631,7 +664,7 @@ function eventFrame:PLAYER_LOGIN() -- update visibility Cell:Fire("UpdateVisibility") -- update click-castings - Cell:Fire("UpdateClickCastings") + registerGlobalClickCastings() -- update indicators -- Cell:Fire("UpdateIndicators") -- NOTE: already update in GROUP_ROSTER_UPDATE -> GroupTypeChanged -> F:UpdateLayout -- update texture and font diff --git a/Modules/ClickCastings.lua b/Modules/ClickCastings.lua index aa28e1a2..2c027458 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -16,7 +16,7 @@ local listButtons = {} local clickCastingTable local loaded local LoadProfile -local alwaysTargeting, smartResurrection +local alwaysTargeting, smartResurrection, hookBlizzardFrames ------------------------------------------------- -- changes ------------------------------------------------- @@ -516,6 +516,7 @@ local function UpdateClickCastings(noReload) end smartResurrection = Cell.vars.clickCastings["smartResurrection"] + hookBlizzardFrames = Cell.vars.clickCastings["hookBlizzardFrames"] if not noReload then if clickCastingsTab:IsVisible() then @@ -527,18 +528,25 @@ local function UpdateClickCastings(noReload) local snippet = GetBindingSnippet() F:Debug(snippet) - - F:IterateAllUnitButtons(function(b) + local clickFrames = Cell.clickCastFrames + if not hookBlizzardFrames then + clickFrames = Cell.clickCastCellFrames + end + for b, _ in pairs(Cell.clickCastFrames) do -- clear if attribute already set ClearClickCastings(b) - - -- update bindingClicks - b:SetAttribute("snippet", snippet) - SetBindingClicks(b) - - -- load db and set attribute - ApplyClickCastings(b) - end, false, true, true) + end + for b, val in pairs(clickFrames) do + Cell.clickCastFrameQueue[b] = nil + if val then + -- update bindingClicks + b:SetAttribute("snippet", snippet) + SetBindingClicks(b) + + -- load db and set attribute + ApplyClickCastings(b) + end + end previousClickCastings = F:Copy(clickCastingTable) end Cell:RegisterCallback("UpdateClickCastings", "UpdateClickCastings", UpdateClickCastings) @@ -553,7 +561,7 @@ local function CreateProfilePane() profilePane:SetPoint("TOPLEFT", 5, -5) profileDropdown = Cell:CreateDropdown(profilePane, 412) - profileDropdown:SetPoint("TOPLEFT", profilePane, "TOPLEFT", 5, -27) + profileDropdown:SetPoint("TOPLEFT", profilePane, "TOPLEFT", 5, -22) profileDropdown:SetEnabled(not Cell.isVanilla) profileDropdown:SetItems({ @@ -577,6 +585,18 @@ local function CreateProfilePane() end +local hookBlizzFrames +------------------------------------------------- +-- Hook click casting to blizzard frames +------------------------------------------------- +local function CreateHookBlizzardFramesCB() + hookBlizzFrames = Cell:CreateCheckButton(clickCastingsTab, "Hook to Blizzard Frames", function(checked) + Cell.vars.clickCastings["hookBlizzardFrames"] = checked + Cell:Fire("UpdateClickCastings") + end) + hookBlizzFrames:SetPoint("TOPLEFT", profileDropdown, 0, -22) +end + ------------------------------------------------- -- always targeting ------------------------------------------------- @@ -584,10 +604,10 @@ local targetingDropdown local function CreateTargetingPane() local targetingPane = Cell:CreateTitledPane(clickCastingsTab, L["Always Targeting"], 205, 50) - targetingPane:SetPoint("TOPLEFT", clickCastingsTab, "TOPLEFT", 5, -70) + targetingPane:SetPoint("TOPLEFT", hookBlizzFrames, "TOPLEFT", 5, -22) targetingDropdown = Cell:CreateDropdown(targetingPane, 195) - targetingDropdown:SetPoint("TOPLEFT", targetingPane, "TOPLEFT", 5, -27) + targetingDropdown:SetPoint("TOPLEFT", targetingPane, "TOPLEFT", 5, -22) targetingDropdown:SetItems({ { @@ -631,10 +651,10 @@ local smartResDropdown local function CreateSmartResPane() local smartResPane = Cell:CreateTitledPane(clickCastingsTab, L["Smart Resurrection"], 205, 50) - smartResPane:SetPoint("TOPLEFT", clickCastingsTab, "TOPLEFT", 222, -70) + smartResPane:SetPoint("TOPLEFT", hookBlizzFrames, "TOPLEFT", 222, -22) smartResDropdown = Cell:CreateDropdown(smartResPane, 195) - smartResDropdown:SetPoint("TOPLEFT", smartResPane, "TOPLEFT", 5, -27) + smartResDropdown:SetPoint("TOPLEFT", smartResPane, "TOPLEFT", 5, -22) smartResDropdown:SetItems({ { @@ -1448,6 +1468,7 @@ local function ShowTab(tab) if not init then init = true CreateProfilePane() + CreateHookBlizzardFramesCB() CreateTargetingPane() CreateSmartResPane() CreateListPane() diff --git a/Utils.lua b/Utils.lua index b1b97753..980329fd 100644 --- a/Utils.lua +++ b/Utils.lua @@ -778,7 +778,7 @@ end ------------------------------------------------- local combinedHeader = "CellRaidFrameHeader0" local separatedHeaders = {"CellRaidFrameHeader1", "CellRaidFrameHeader2", "CellRaidFrameHeader3", "CellRaidFrameHeader4", "CellRaidFrameHeader5", "CellRaidFrameHeader6", "CellRaidFrameHeader7", "CellRaidFrameHeader8"} -local blizzardFrames = { +Cell.blizzardFrames = { "PlayerFrame", "TargetFrame", "PetFrame", @@ -791,6 +791,23 @@ local blizzardFrames = { "PartyMemberFrame3PetFrame", "PartyMemberFrame4PetFrame", } +Cell.clickCastCellFrames = {} +Cell.clickCastFrames = {} +Cell.clickCastFrameQueue = {} + +function F:RegisterFrame(frame, isCell) + Cell.clickCastFrames[frame] = true + if isCell then + Cell.clickCastCellFrames[frame] = true + end + Cell.clickCastFrameQueue[frame] = true -- put into queue +end + +function F:UnregisterFrame(frame, isCell) + Cell.clickCastFrames[frame] = nil -- ignore + Cell.clickCastFrameQueue[frame] = nil -- mark for only cleanup +end + function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) if updateBlizzardFrames then for _, b in pairs(blizzardFrames) do From 5d67f4f5ab86f25beffe54dff547b1037632fc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20K=C3=B3bor?= Date: Tue, 18 Jun 2024 22:48:36 +0200 Subject: [PATCH 5/5] remove old code --- Utils.lua | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Utils.lua b/Utils.lua index 980329fd..8c70aba1 100644 --- a/Utils.lua +++ b/Utils.lua @@ -809,14 +809,6 @@ function F:UnregisterFrame(frame, isCell) end function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) - if updateBlizzardFrames then - for _, b in pairs(blizzardFrames) do - local frame = _G[b] - if frame then - func(frame) - end - end - end -- solo if not updateCurrentGroupOnly or (updateCurrentGroupOnly and Cell.vars.groupType == "solo") then for _, b in pairs(Cell.unitButtons.solo) do