From 24eecebf87ca2612ff256bf34785a598bbd5ef82 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Fri, 24 Sep 2010 20:37:00 +0100 Subject: [PATCH] Add test function, fix spellbook binding, add comments --- Clique.lua | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Clique.toc | 1 - Clique.xml | 12 +++++++++ CliqueOptions.lua | 11 +++++--- 4 files changed, 96 insertions(+), 6 deletions(-) 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 @@ + + 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 -- 1.7.9.5