diff --git a/Core.lua b/Core.lua index 13f6e575..ba6fe8fe 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,28 +714,38 @@ function eventFrame:PLAYER_ENTERING_WORLD() end end --- REVIEW: --- local function RegisterGlobalClickCastings() --- ClickCastFrames = ClickCastFrames or {} +local function registerGlobalClickCastings() + ClickCastFrames = ClickCastFrames or {} --- if ClickCastFrames then --- for frame, options in pairs(ClickCastFrames) do --- F:RegisterFrame(frame) --- end --- end + 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 --- ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v) --- if v == nil or v == false then --- F:UnregisterFrame(k) --- else --- F:RegisterFrame(k) --- end --- end}) - --- F:IterateAllUnitButtons(function (b) --- ClickCastFrames[b] = true --- end) --- end function eventFrame:PLAYER_LOGIN() F:Debug("|cffbbbbbb=== PLAYER_LOGIN ===") @@ -768,7 +779,7 @@ function eventFrame:PLAYER_LOGIN() -- REVIEW: register unitframes for click casting -- RegisterGlobalClickCastings() -- 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 29df004e..cd8c5f18 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 b1b3388a..4b499dd1 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 809a7606..3c3653ea 100644 --- a/Modules/ClickCastings.lua +++ b/Modules/ClickCastings.lua @@ -14,7 +14,7 @@ local listButtons = {} local clickCastingTable local loaded local LoadProfile -local alwaysTargeting, smartResurrection +local alwaysTargeting, smartResurrection, hookBlizzardFrames ------------------------------------------------- -- changes ------------------------------------------------- @@ -556,6 +556,7 @@ local function UpdateClickCastings(noReload, onlyqueued) end smartResurrection = Cell.vars.clickCastings["smartResurrection"] + hookBlizzardFrames = Cell.vars.clickCastings["hookBlizzardFrames"] if not noReload then if clickCastingsTab:IsVisible() then @@ -568,34 +569,25 @@ local function UpdateClickCastings(noReload, onlyqueued) local snippet = GetBindingSnippet() F:Debug(snippet) - -- REVIEW: - -- local clickFrames = Cell.clickCastFrames - -- if onlyqueued then - -- clickFrames = Cell.clickCastFrameQueue - -- end - -- for b, val in pairs(clickFrames) do - -- Cell.clickCastFrameQueue[b] = nil - -- -- clear if attribute already set - -- ClearClickCastings(b) - -- if val then - -- -- update bindingClicks - -- b:SetAttribute("snippet", snippet) - -- SetBindingClicks(b) - - -- -- load db and set attribute - -- ApplyClickCastings(b) - -- end - -- end - - 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) + 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 @@ -616,7 +608,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({ @@ -640,6 +632,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 ------------------------------------------------- @@ -647,10 +651,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) local items = { { @@ -696,10 +700,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) local items = { { @@ -1630,6 +1634,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 ac25d181..8ab9d09a 100644 --- a/Utils.lua +++ b/Utils.lua @@ -802,24 +802,36 @@ end ------------------------------------------------- local combinedHeader = "CellRaidFrameHeader0" local separatedHeaders = {"CellRaidFrameHeader1", "CellRaidFrameHeader2", "CellRaidFrameHeader3", "CellRaidFrameHeader4", "CellRaidFrameHeader5", "CellRaidFrameHeader6", "CellRaidFrameHeader7", "CellRaidFrameHeader8"} +Cell.blizzardFrames = { + "PlayerFrame", + "TargetFrame", + "PetFrame", + "PartyMemberFrame1", + "PartyMemberFrame2", + "PartyMemberFrame3", + "PartyMemberFrame4", + "PartyMemberFrame1PetFrame", + "PartyMemberFrame2PetFrame", + "PartyMemberFrame3PetFrame", + "PartyMemberFrame4PetFrame", +} +Cell.clickCastCellFrames = {} +Cell.clickCastFrames = {} +Cell.clickCastFrameQueue = {} --- REVIEW: --- Cell.clickCastFrames = {} --- Cell.clickCastFrameQueue = {} - --- function F:RegisterFrame(frame) --- Cell.clickCastFrames[frame] = true --- Cell.clickCastFrameQueue[frame] = true -- put into queue --- Cell:Fire("UpdateQueuedClickCastings") --- end +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) --- Cell.clickCastFrames[frame] = nil -- ignore --- Cell.clickCastFrameQueue[frame] = false -- mark for only cleanup --- Cell:Fire("UpdateQueuedClickCastings") --- end +function F:UnregisterFrame(frame, isCell) + Cell.clickCastFrames[frame] = nil -- ignore + Cell.clickCastFrameQueue[frame] = nil -- mark for only cleanup +end --- REVIEW: updateBlizzardFrames function F:IterateAllUnitButtons(func, updateCurrentGroupOnly, updateQuickAssist, updateBlizzardFrames) -- solo if not updateCurrentGroupOnly or (updateCurrentGroupOnly and Cell.vars.groupType == "solo") then