Quantcast

Add initial Blizzard frames integration

James Whitehead II [10-03-10 - 19:43]
Add initial Blizzard frames integration
Filename
BlizzardFrames.lua
Clique.lua
Clique.toc
diff --git a/BlizzardFrames.lua b/BlizzardFrames.lua
new file mode 100644
index 0000000..47b0e8f
--- /dev/null
+++ b/BlizzardFrames.lua
@@ -0,0 +1,150 @@
+local addonName, addon = ...
+
+function addon:Enable_BlizzRaidPullouts()
+    hooksecurefunc("CreateFrame", function(type, name, parent, template)
+        if template == "RaidPulloutButtonTemplate" then
+            local frame = _G[tostring(name) .. "ClearButton"]
+            if frame then
+                ClickCastFrames[frame] = true
+            end
+        end
+    end)
+end
+
+function addon:Enable_BlizzCompactUnitFrames()
+    hooksecurefunc("CompactUnitFrame_SetUpFrame", function(frame, ...)
+        ClickCastFrames[frame] = true
+    end)
+end
+
+function addon:Enable_BlizzArenaFrames()
+    local frames = {
+        ArenaEnemyFrame1,
+        ArenaEnemyFrame2,
+        ArenaEnemyFrame3,
+        ArenaEnemyFrame4,
+        ArenaEnemyFrame5,
+    }
+    for idx, frame in ipairs(frames) do
+        ClickCastFrames[frame] = true
+    end
+end
+
+function addon:Enable_BlizzSelfFrames()
+    local frames = {
+        PlayerFrame,
+        PetFrame,
+        TargetFrame,
+        TargetFrameToT,
+        FocusFrame,
+        FocusFrameToT,
+    }
+    for idx, frame in ipairs(frames) do
+        ClickCastFrames[frame] = true
+    end
+end
+
+function addon:Enable_BlizzPartyFrames()
+    local frames = {
+        PartyMemberFrame1,
+		PartyMemberFrame2,
+		PartyMemberFrame3,
+		PartyMemberFrame4,
+        PartyMemberFrame5,
+		PartyMemberFrame1PetFrame,
+		PartyMemberFrame2PetFrame,
+		PartyMemberFrame3PetFrame,
+        PartyMemberFrame4PetFrame,
+        PartyMemberFrame5PetFrame,
+    }
+    for idx, frame in ipairs(frames) do
+        ClickCastFrames[frame] = true
+    end
+end
+
+function addon:Enable_BlizzCompactParty()
+    local frames = {
+        CompactPartyFrameMemberSelf,
+        CompactPartyFrameMemberSelfBuff1,
+        CompactPartyFrameMemberSelfBuff2,
+        CompactPartyFrameMemberSelfBuff3,
+        CompactPartyFrameMemberSelfDebuff1,
+        CompactPartyFrameMemberSelfDebuff2,
+        CompactPartyFrameMemberSelfDebuff3,
+        CompactPartyFrameMember1,
+        CompactPartyFrameMember1Buff1,
+        CompactPartyFrameMember1Buff2,
+        CompactPartyFrameMember1Buff3,
+        CompactPartyFrameMember1Debuff1,
+        CompactPartyFrameMember1Debuff2,
+        CompactPartyFrameMember1Debuff3,
+        CompactPartyFrameMember2,
+        CompactPartyFrameMember2Buff1,
+        CompactPartyFrameMember2Buff2,
+        CompactPartyFrameMember2Buff3,
+        CompactPartyFrameMember2Debuff1,
+        CompactPartyFrameMember2Debuff2,
+        CompactPartyFrameMember2Debuff3,
+        CompactPartyFrameMember3,
+        CompactPartyFrameMember3Buff1,
+        CompactPartyFrameMember3Buff2,
+        CompactPartyFrameMember3Buff3,
+        CompactPartyFrameMember3Debuff1,
+        CompactPartyFrameMember3Debuff2,
+        CompactPartyFrameMember3Debuff3,
+        CompactPartyFrameMember4,
+        CompactPartyFrameMember4Buff1,
+        CompactPartyFrameMember4Buff2,
+        CompactPartyFrameMember4Buff3,
+        CompactPartyFrameMember4Debuff1,
+        CompactPartyFrameMember4Debuff2,
+        CompactPartyFrameMember4Debuff3,
+        CompactPartyFrameMember5,
+        CompactPartyFrameMember5Buff1,
+        CompactPartyFrameMember5Buff2,
+        CompactPartyFrameMember5Buff3,
+        CompactPartyFrameMember5Debuff1,
+        CompactPartyFrameMember5Debuff2,
+        CompactPartyFrameMember5Debuff3,
+    }
+    for idx, frame in ipairs(frames) do
+        ClickCastFrames[frame] = true
+    end
+end
+
+function addon:Enable_BlizzBossFrames()
+    local frames = {
+        Boss1TargetFrame,
+        Boss2TargetFrame,
+        Boss3TargetFrame,
+        Boss4TargetFrame,
+    }
+    for idx, frame in ipairs(frames) do
+        ClickCastFrames[frame] = true
+    end
+end
+
+
+function addon:EnableBlizzardFrames()
+    self:Enable_BlizzRaidPullouts()
+    self:Enable_BlizzCompactUnitFrames()
+    self:Enable_BlizzArenaFrames()
+    self:Enable_BlizzSelfFrames()
+    self:Enable_BlizzPartyFrames()
+    self:Enable_BlizzCompactParty()
+    self:Enable_BlizzBossFrames()
+    if IsAddOnLoaded("Blizzard_ArenaUI") then
+        self:Enable_BlizzArenaFrames()
+    else
+        local frame = CreateFrame("Frame")
+        frame:RegisterEvent("ADDON_LOADED")
+        frame:SetScript("OnEvent", function(frame, event, ...)
+            if ... == "Blizzard_ArenaUI" then
+                self:UnregisterEvent("ADDON_LOADED")
+                self:SetScript("OnEvent", nil)
+                self:Enable_BlizzArenaFrames()
+            end
+        end)
+    end
+ end
+
diff --git a/Clique.lua b/Clique.lua
index 86f5912..67ded71 100755
--- a/Clique.lua
+++ b/Clique.lua
@@ -39,24 +39,6 @@ function addon:Initialize()
     self:InitializeDatabase()
     self.ccframes = {}

-    -- Compatability with old Clique 1.x registrations
-    local oldClickCastFrames = ClickCastFrames
-
-    ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v)
-        if v == nil then
-            self:UnregisterFrame(k)
-        else
-            self:RegisterFrame(k, v)
-        end
-    end})
-
-    -- Iterate over the frames that were set before we arrived
-    if oldClickCastFrames then
-        for frame, options in pairs(oldClickCastFrames) do
-            self:RegisterFrame(frame, options)
-        end
-    end
-
     -- Registration for group headers (in-combat safe)
     self.header = CreateFrame("Frame", addonName .. "HeaderFrame", UIParent, "SecureHandlerBaseTemplate")
     ClickCastHeader = addon.header
@@ -91,9 +73,30 @@ function addon:Initialize()
     local set, clr = self:GetBindingAttributes()
     self.header:SetAttribute("setup_onenter", set)
     self.header:SetAttribute("setup_onleave", clr)
+
+    -- Clickcast registration systems
+    -- Compatability with old Clique 1.x registrations
+    local oldClickCastFrames = ClickCastFrames
+
+    ClickCastFrames = setmetatable({}, {__newindex = function(t, k, v)
+        if v == nil then
+            self:UnregisterFrame(k)
+        else
+            self:RegisterFrame(k, v)
+        end
+    end})
+
+    -- Iterate over the frames that were set before we arrived
+    if oldClickCastFrames then
+        for frame, options in pairs(oldClickCastFrames) do
+            self:RegisterFrame(frame, options)
+        end
+    end
+    self:EnableBlizzardFrames()
 end

 function addon:RegisterFrame(button)
+    print("Registered frame: " .. tostring(button:GetName()))
     self.ccframes[button] = true

     button:RegisterForClicks("AnyDown")
diff --git a/Clique.toc b/Clique.toc
index 0c677e5..ce78a5b 100755
--- a/Clique.toc
+++ b/Clique.toc
@@ -19,3 +19,5 @@ CliqueOptions.lua

 CliqueTest.xml
 CliqueTest.lua
+
+BlizzardFrames.lua