Quantcast

Add test function, fix spellbook binding, add comments

James Whitehead II [09-24-10 - 19:37]
Add test function, fix spellbook binding, add comments
Filename
Clique.lua
Clique.toc
Clique.xml
CliqueOptions.lua
diff --git a/Clique.lua b/Clique.lua
index 9e4a3f7..e6a359b 100755
--- a/Clique.lua
+++ b/Clique.lua
@@ -78,10 +78,86 @@ end
 function addon:InitializeDatabase()
     -- Force a clean database everytime
     self.profile = {
-        binds = {},
+        binds = {
+        },
     }
 end

+-- This function adds a binding to the player's current profile. The
+-- following options can be included in the click-cast entry:
+--
+-- entry = {
+--     -- The full prefix and suffix of the key being bound
+--     key = "ALT-CTRL-SHIFT-BUTTON1",
+--     -- The icon to be used for displaying this entry
+--     icon = "Interface\\Icons\\Spell_Nature_HealingTouch",
+--
+--     -- Any restricted sets that this click should be applied to
+--     sets = {"ooc", "harm", "help", "frames_blizzard"},
+--
+--     -- The type of the click-binding
+--     type = "spell",
+--     type = "macro",
+--     type = "target",
+--     type = "menu",
+--
+--     -- Any arguments for given click type
+--     spell = "Healing Touch",
+--     macrotext = "/run Nature's Swiftness\n/cast [target=mouseover] Healing Touch",
+--     unit = "mouseover",
+-- }
+
+function addon:AddBinding(entry)
+    print("Adding new binding")
+    for k,v in pairs(entry) do
+        print(k, v)
+    end
+end
+
+function addon:RunTest()
+        -- Create a fake "group header" to test things properly
+    local groupheader = CreateFrame("Button", "MyGroupHeader", UIParent, "SecureGroupHeaderTemplate")
+    SecureHandler_OnLoad(groupheader)
+
+    -- Ensure the group header has a reference to the click-cast header
+    groupheader:SetFrameRef("clickcast_header", addon.header)
+
+    -- Set up the group header to display a solo/party/raid frame
+    groupheader.showRaid = true
+    groupheader.showParty = true
+    groupheader.showPlayer = true
+    groupheader.showSolo = true
+    groupheader.point = "TOP"
+    groupheader.template = "ClickCastUnitTemplate"
+    groupheader.templateType = "Button"
+    groupheader:SetAttribute("initialConfigFunction", [==[
+        self:SetSize(125, 25)
+        self:SetBackdrop(GameTooltip:GetBackdrop())
+        self:SetAttribute("shift-type1", "spell")
+        self:SetAttribute("shift-spell1", "Regrowth")
+        self:SetAttribute("shift-unit1", "player")
+
+        self:SetAttribute("type-cliquebutton1", "spell")
+        self:SetAttribute("spell-cliquebutton1", "Lifebloom")
+        self:SetAttribute("unit-cliquebutton1", "player")
+    ]==])
+
+    groupheader:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
+    groupheader:Show()
+
+    -- TODO: Remove these bindings
+    addon.header:SetAttribute("setup_onenter", [[
+        local buttonName = ...
+        print("Setting up click-bindings for: " .. buttonName)
+        self:ClearBinding("F")
+        self:SetBindingClick(true, "F", buttonName, "cliquebutton1")
+    ]])
+    addon.header:SetAttribute("setup_onleave", [[
+        print("Removing click-bindings")
+        self:ClearBinding("F")
+    ]])
+end
+
 SLASH_CLIQUE1 = "/clique"
 SlashCmdList["CLIQUE"] = function(msg, editbox)
     ShowUIPanel(CliqueConfig)
diff --git a/Clique.toc b/Clique.toc
index 344b7f4..d3caede 100755
--- a/Clique.toc
+++ b/Clique.toc
@@ -7,7 +7,6 @@
 ## OptionalDeps: Dongle

 AddonCore.lua
-Localization.core.lua
 Localization.enUS.lua

 Clique.xml
diff --git a/Clique.xml b/Clique.xml
index ca30933..0290945 100755
--- a/Clique.xml
+++ b/Clique.xml
@@ -303,6 +303,18 @@
                     </Button>
                 </Frames>
             </Frame> <!-- Page 2 - Edit Page -->
+			<Button name="$parentButton1" parentKey="button_add" inherits="MagicButtonTemplate">
+				<Size x="100" y="22"/>
+				<Anchors>
+					<Anchor point="BOTTOMLEFT" />
+				</Anchors>
+			</Button>
+			<Button name="$parentButton2" parentKey="button_edit" inherits="MagicButtonTemplate">
+				<Size x="80" y="22"/>
+				<Anchors>
+					<Anchor point="BOTTOMRIGHT" />
+				</Anchors>
+			</Button>
         </Frames>
         <Scripts>
             <OnLoad>
diff --git a/CliqueOptions.lua b/CliqueOptions.lua
index 14dd4d6..2b7a427 100755
--- a/CliqueOptions.lua
+++ b/CliqueOptions.lua
@@ -34,6 +34,9 @@ function CliqueConfig:SetupGUI()
     self.page1.column1:SetText(L["Action"])
     self.page1.column2:SetText(L["Binding"])

+    self.button_add:SetText(L["Add binding"])
+    self.button_edit:SetText(L["Edit"])
+
     self.page1:Show()
 end

@@ -129,12 +132,12 @@ function CliqueConfig:Spellbook_OnBinding(button, key)
     -- TODO: Support NOT splitting the modifier keys
     local prefix = addon:GetPrefixString(true)

-    local id = SpellBook_GetSpellID(button.spellbutton:GetID());
-    local texture = GetSpellTexture(id, SpellBookFrame.bookType)
-    local name = GetSpellName(id, SpellBookFrame.bookType)
+    local slot = SpellBook_GetSpellBookSlot(button:GetParent());
+    local name, subtype = GetSpellBookItemName(slot, SpellBookFrame.bookType)
+    local texture = GetSpellBookItemTexture(slot, SpellBookFrame.bookType)

     local succ, err = addon:AddBinding{
-        binding = prefix .. key,
+        key = prefix .. key,
         type = "spell",
         spell = name,
         icon = texture