From 1bd1acfa3ea34825c3cd301feea366ad0a53c077 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Fri, 15 Dec 2006 02:27:26 +0000 Subject: [PATCH] * Resolved some outstanding issues with click priority, required signifgant changes * Out-of-combat clicks should now have the highest priority, followed by harm/help, followed by default * Resolved an issue with "Click Button" * Identified an issue with the left click binding not working across reloads on the default blizzard raid frames. Do not have a fix for this yet, waiting on Blizzard * Fixed an issue where the blacklist was not properly being applied. Blacklisted frames will no longer have attributes applied to them. --- Clique.lua | 208 ++++++++++++++++++++++++++++++----------------------- CliqueOptions.lua | 18 ++--- 2 files changed, 129 insertions(+), 97 deletions(-) diff --git a/Clique.lua b/Clique.lua index fd202cd..95c5929 100644 --- a/Clique.lua +++ b/Clique.lua @@ -58,13 +58,14 @@ function Clique:Enable() ClickCastFrames = setmetatable({}, {__newindex=newindex}) -- Register all frames that snuck in before we did =) - for frame in pairs(self.ccframes) do - self:RegisterFrame(frame) - end Clique:OptionsOnLoad() Clique:EnableFrames() + for frame in pairs(self.ccframes) do + self:RegisterFrame(frame) + end + -- Define a state header for forms self.stateheader = CreateFrame("Frame", "CliqueStateHeader", UIParent, "SecureStateDriverTemplate") self.stateheader:SetAttribute("statemap-stance-0", "s0") @@ -184,7 +185,7 @@ function Clique:SpellBookButtonPressed() button = self:GetButtonNumber() end - -- Build the SVN/live structure + -- Build the structure local t = { ["button"] = button, ["modifier"] = self:GetModifierText(), @@ -202,74 +203,60 @@ function Clique:SpellBookButtonPressed() end self.editSet[key] = t - - self:SetAction(t) + self:UpdateClicks() self:ListScrollUpdate() end +function Clique:UpdateClicks(frame) + for name in pairs(self.clicksets) do + self:RemoveClickSet(name, frame) + end + + self:ApplyClickSet(L.CLICKSET_DEFAULT, frame) + self:ApplyClickSet(L.CLICKSET_HARMFUL, frame) + self:ApplyClickSet(L.CLICKSET_HELPFUL, frame) + if not InCombatLockdown() then + self:TrimClickSet(L.CLICKSET_HARMFUL, frame) + self:TrimClickSet(L.CLICKSET_HELPFUL, frame) + end + self:ApplyClickSet(L.CLICKSET_OOC, frame) +end + function Clique:CombatLockdown() self:Debug(1, "Going into combat mode") -- Remove all OOC clicks - for k,v in pairs(self.clicksets[L.CLICKSET_OOC]) do - self:DeleteAction(v) - self:Debug(1, "Removing %s, %s", v.type, tostring(v.arg1)) - end - - -- Just bluntly force our clicks back onto the frames - for frame in pairs(self.ccframes) do - self:RegisterFrame(frame) - end + self:RemoveClickSet(L.CLICKSET_OOC) + self:ApplyClickSet(L.CLICKSET_DEFAULT) + self:ApplyClickSet(L.CLICKSET_HARMFUL) + self:ApplyClickSet(L.CLICKSET_HELPFUL) end function Clique:CombatUnlock() self:Debug(1, "Setting any out of combat clicks") - for frame in pairs(self.ccframes) do - for k,v in pairs(self.clicksets[L.CLICKSET_OOC]) do - self:SetAttribute(v,frame) - end - end + self:ApplyClickSet(L.CLICKSET_DEFAULT) + self:ApplyClickSet(L.CLICKSET_HARMFUL) + self:ApplyClickSet(L.CLICKSET_HELPFUL) + self:TrimClickSet(L.CLICKSET_HARMFUL, frame) + self:TrimClickSet(L.CLICKSET_HELPFUL, frame) + self:RemoveClickSet(L.CLICKSET_OOC) end -local queue = {} - -function Clique:CombatDelay(tbl) - if InCombatLockdown() then - if #queue == 0 then - self:Print(L.CANNOT_CHANGE_COMBAT) - end - table.insert(queue, tbl) - eventFrame:Show() - return true - end -end +function Clique:RegisterFrame(frame) + local name = frame:GetName() -function Clique:ClearQueue() - if InCombatLockdown() then return end - - eventFrame:Hide() - self:Print(L.APPLY_QUEUE) - for k,v in ipairs(queue) do - if v.GetAttribute then - self:RegisterFrame(v) - else - if v.delete then - self:DeleteAction(v) - else - self:SetAction(v) - end - end + -- Check to see if we can register this frame at this time + frame:SetAttribute("Clique-test", true) + if frame:GetAttribute("Clique-test") then + frame:SetAttribute("Clique-test", nil) + else + self:Print("Cannot register frame %s", tostring(name)) end - queue = {} -end -function Clique:RegisterFrame(frame) - local name = frame:GetName() if self.profile.blacklist[name] then rawset(self.ccframes, frame, false) return end --- if self:CombatDelay(frame) then return end if not ClickCastFrames[frame] then rawset(self.ccframes, frame, true) if CliqueTextListFrame then @@ -277,13 +264,48 @@ function Clique:RegisterFrame(frame) end end - -- Ensure we have all the buttons registered frame:RegisterForClicks("LeftButtonUp", "MiddleButtonUp", "RightButtonUp", "Button4Up", "Button5Up") - - for name,set in pairs(self.clicksets) do - if name ~= L.CLICKSET_OOC then - for modifier,entry in pairs(set) do - self:SetAttribute(entry, frame) + self:UpdateClicks() +end + +function Clique:ApplyClickSet(name, frame) + local set = self.clicksets[name] + + if frame then + for modifier,entry in pairs(set) do + self:SetAttribute(entry, frame) + end + else + for modifier,entry in pairs(set) do + self:SetAction(entry) + end + end +end + +function Clique:RemoveClickSet(name, frame) + local set = self.clicksets[name] + + if frame then + for modifier,entry in pairs(set) do + self:DeleteAttribute(entry, frame) + end + else + for modifier,entry in pairs(set) do + self:DeleteAction(entry) + end + end +end + +function Clique:TrimClickSet(name) + local base = self.clicksets[L.CLICKSET_OOC] + local set = self.clicksets[name] + + for modifier,entry in pairs(set) do + for modifierbase,entrybase in pairs(base) do + local button = string.format("%s%d", "harmbutton", entrybase.button) + local button2 = string.format("%s%d", "helpbutton", entrybase.button) + if entry.button == button or entry.button == button2 then + self:DeleteAction(entry) end end end @@ -292,25 +314,12 @@ end function Clique:UnregisterFrame(frame) for name,set in pairs(self.clicksets) do for modifier,entry in pairs(set) do - local type,button,value - - if not tonumber(entry.button) then - type,button = select(3, string.find(entry.button, "(%a+)button(%d+)")) - frame:SetAttribute(entry.modifier..entry.button, nil) - button = string.format("-%s%s", type, button) - end - - button = button or entry.button - - entry.delete = true - - frame:SetAttribute(entry.modifier.."type"..button, nil) - frame:SetAttribute(entry.modifier..entry.type..button, nil) + self:DeleteAttribute(entry, frame) end end end -function Clique:DONGLE_PROFILE_CHANGED(event, addon, name) +function Clique:DONGLE_PROFILE_CHANGED(event, addon, svname, name) if addon == "Clique" then self:Print(L.PROFILE_CHANGED, name) for name,set in pairs(self.clicksets) do @@ -335,7 +344,7 @@ function Clique:DONGLE_PROFILE_CHANGED(event, addon, name) end end -function Clique:DONGLE_PROFILE_DELETED(event, addon, name) +function Clique:DONGLE_PROFILE_DELETED(event, addon, svname, name) if addon == "Clique" then self:Print(L.PROFILE_DELETED, name) @@ -344,8 +353,13 @@ function Clique:DONGLE_PROFILE_DELETED(event, addon, name) self:ListScrollUpdate() end end - + function Clique:SetAttribute(entry, frame) + local name = frame:GetName() + if self.profile.blacklist[name] then + return + end + -- Set up any special attributes local type,button,value @@ -401,22 +415,13 @@ function Clique:SetAttribute(entry, frame) frame:SetAttribute(entry.modifier.."unit"..button, entry.arg1) elseif entry.type == "click" then frame:SetAttribute(entry.modifier.."type"..button, entry.type) - frame:SetAttribute(entry.modifier.."delegate"..button, getglobal(entry.arg1)) + frame:SetAttribute(entry.modifier.."clickbutton"..button, getglobal(entry.arg1)) elseif entry.type == "menu" then frame:SetAttribute(entry.modifier.."type"..button, entry.type) end end -function Clique:SetAction(entry) - if self:CombatDelay(entry) then return end - for frame,enabled in pairs(self.ccframes) do - if enabled then - self:SetAttribute(entry, frame) - end - end -end - -function Clique:DeleteAction(entry) +function Clique:DeleteAttribute(entry, frame) local type,button,value if not tonumber(entry.button) then @@ -431,10 +436,35 @@ function Clique:DeleteAction(entry) entry.delete = true - if self:CombatDelay(entry) then return end + frame:SetAttribute(entry.modifier.."type"..button, nil) + frame:SetAttribute(entry.modifier..entry.type..button, nil) +end + +function Clique:SetAction(entry) + for frame,enabled in pairs(self.ccframes) do + if enabled then + self:SetAttribute(entry, frame) + end + end +end + +function Clique:DeleteAction(entry) for frame in pairs(self.ccframes) do - frame:SetAttribute(entry.modifier.."type"..button, nil) - frame:SetAttribute(entry.modifier..entry.type..button, nil) + self:DeleteAttribute(entry, frame) end end + +function test(func, num) + local start = GetTime() + + debugprofilestart() + for i=1,num do + func() + end + local total = GetTime() - start + + ChatFrame1:AddMessage("Calls took a total of " .. total .. "msec") + ChatFrame1:AddMessage("Time per call: " ..(total / num)) +end + \ No newline at end of file diff --git a/CliqueOptions.lua b/CliqueOptions.lua index 2ea3ef7..776d9aa 100644 --- a/CliqueOptions.lua +++ b/CliqueOptions.lua @@ -1088,6 +1088,7 @@ function Clique:ButtonOnClick(button) end self:DeleteAction(entry) + self:UpdateClicks() entry = nil self:ListScrollUpdate() @@ -1098,7 +1099,7 @@ function Clique:ButtonOnClick(button) elseif this == CliqueButtonMax then entry.arg2 = nil self:DeleteAction(entry) - self:SetAction(entry) + self:UpdateClicks() elseif this == CliqueButtonCustom then if CliqueCustomFrame:IsVisible() then CliqueCustomFrame:Hide() @@ -1138,7 +1139,7 @@ function Clique:ButtonOnClick(button) local offset = FauxScrollFrame_GetOffset(CliqueTextListScroll) local selected = self.textlistSelected - offset local button = getglobal("CliqueTextList"..selected) - self:SetProfile(button.name:GetText()) + self.db:SetProfile(button.name:GetText()) elseif this == CliqueButtonNewProfile then StaticPopup_Show("CLIQUE_NEW_PROFILE") elseif this == CliqueButtonDeleteProfile then @@ -1262,12 +1263,13 @@ function Clique:ButtonOnClick(button) local key = self.editEntry.modifier..self.editEntry.button self.editSet[key] = nil self:DeleteAction(self.editEntry) + self:UpdateClicks() self.editEntry = nil end local key = entry.modifier..entry.button self.editSet[key] = entry - self:SetAction(entry) + self:UpdateClicks() self:ButtonOnClick(CliqueCustomButtonCancel) end @@ -1520,7 +1522,7 @@ StaticPopupDialogs["CLIQUE_NEW_PROFILE"] = { local name = this:GetParent():GetName().."EditBox" local button = getglobal(name) local text = button:GetText() - Clique:SetProfile(text) + Clique.db:SetProfile(text) end, timeout = 0, whileDead = 1, @@ -1541,7 +1543,7 @@ StaticPopupDialogs["CLIQUE_NEW_PROFILE"] = { end, EditBoxOnEnterPressed = function() if ( getglobal(this:GetParent():GetName().."Button1"):IsEnabled() == 1 ) then - Clique:SetProfile(this:GetText()) + Clique.db:SetProfile(this:GetText()) this:GetParent():Hide(); end end, @@ -1620,7 +1622,7 @@ function Clique:TextListScrollUpdate() if self.textlist == "PROFILES" then for k,v in pairs(self.db.profiles) do table.insert(work, k) end table.sort(work) - CliqueTextListFrame.title:SetText("Profile: " .. self.db.char.profileKey) + CliqueTextListFrame.title:SetText("Profile: " .. self.db.profileKey) elseif self.textlist == "FRAMES" then for k,v in pairs(self.ccframes) do @@ -1659,7 +1661,7 @@ function Clique:TextListScrollUpdate() end if self.textlistSelected == nil and self.textlist == "PROFILES" then - if work[idx] == self.db.char.profileKey then + if work[idx] == self.db.profileKey then button:SetChecked(true) CliqueButtonSetProfile:Disable() CliqueButtonDeleteProfile:Disable() @@ -1667,7 +1669,7 @@ function Clique:TextListScrollUpdate() button:SetChecked(nil) end elseif idx == self.textlistSelected and self.textlist == "PROFILES" then - if work[idx] == self.db.char.profileKey then + if work[idx] == self.db.profileKey then CliqueButtonSetProfile:Disable() CliqueButtonDeleteProfile:Disable() else -- 1.7.9.5