From ed97602edf362e696bd9f535c279338b9486eadc Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Tue, 5 Oct 2010 19:47:56 +0100 Subject: [PATCH] Implemented macros, srsly. --- BindConfig.lua | 26 +++++++++++++++++++++++-- Clique.lua | 2 +- Clique.xml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- Utils.lua | 2 ++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/BindConfig.lua b/BindConfig.lua index a35cbc1..60fcd42 100755 --- a/BindConfig.lua +++ b/BindConfig.lua @@ -55,9 +55,14 @@ function CliqueConfig:SetupGUI() self.page1.button_spell:SetText(L["Bind spell"]) self.page1.button_other:SetText(L["Bind other"]) self.page1.button_options:SetText(L["Options"]) - + + self.page2.button_binding:SetText(L["Set binding"]) self.page2.button_save:SetText(L["Save"]) self.page2.button_cancel:SetText(L["Cancel"]) + local desc = L["You can use this page to create a custom macro to be run when activating a binding on a unit. When creating this macro you should keep in mind that you will need to specify the target of any actions in the macro by using the 'mouseover' unit, which is the unit you are clicking on. For example, you can do any of the following:\n\n/cast [target=mouseover] Regrowth\n/cast [@mouseover] Regrowth\n/cast [@mouseovertarget] Taunt\n\nHover over the 'Set binding' button below and either click or press a key with any modifiers you would like included. Then edit the box below to contain the macro you would like to have run when this binding is activated."] + + self.page2.desc:SetText(desc) + self.page2.editbox = CliqueScrollFrameEditBox self.page1:Show() end @@ -192,7 +197,16 @@ function CliqueConfig:Button_OnClick(button) -- Click handler for "Edit" button elseif button == self.page1.button_options then InterfaceOptionsFrame_OpenToCategory("Clique") - elseif button == self.page2.button_cancel then + elseif button == self.page2.button_save then + -- Check the input + local key = self.page2.key + local macrotext = self.page2.editbox:GetText() + local succ, err = addon:AddBinding{ + key = key, + type = "macro", + macrotext = macrotext, + } + self:UpdateList() self.page2:Hide() self.page1:Show() elseif button == self.page2.button_cancel then @@ -334,6 +348,14 @@ function CliqueConfig:BindingButton_OnClick(button, key) end end +function CliqueConfig:MacroBindingButton_OnClick(button, key) + local key = addon:GetCapturedKey(key) + if key then + self.page2.key = key + self.page2.bindText:SetText(addon:GetBindingKeyComboText(key)) + end +end + function CliqueConfig:AcceptSetBinding() local dialog = CliqueDialog local key = dialog.key diff --git a/Clique.lua b/Clique.lua index 7746d6b..e36a5c1 100755 --- a/Clique.lua +++ b/Clique.lua @@ -134,7 +134,7 @@ function addon:InitializeDatabase() end function ATTR(prefix, attr, suffix, value) - local fmt = [[button:SetAttribute("%s%s%s%s%s", "%s")]] + local fmt = [[button:SetAttribute("%s%s%s%s%s", %q)]] return fmt:format(prefix, #prefix > 0 and "-" or "", attr, tonumber(suffix) and "" or "-", suffix, value) end diff --git a/Clique.xml b/Clique.xml index ced18d8..7988e6c 100755 --- a/Clique.xml +++ b/Clique.xml @@ -166,9 +166,12 @@ self:RegisterForClicks("AnyUp") + self:EnableKeyboard(false) - self:EnableKeyboard(true) + if motion then + self:EnableKeyboard(true) + end self:EnableKeyboard(false) @@ -323,8 +326,56 @@ - + + + + + + + + + + + + + + + + + + + +