Quantcast

Clique:

James Whitehead II [12-07-06 - 02:04]
Clique:
* Moved some localisation around
* Added an edit box for macrotext when making a custom macro
* Removed outdated Print() function
* Added a "menu" action which will show the unit menu, if stored in the frame.menu variable
Filename
Clique.lua
Clique.toc
Clique.xml
CliqueOptions.lua
Localization.en.lua
diff --git a/Clique.lua b/Clique.lua
index 045a01a..fd202cd 100644
--- a/Clique.lua
+++ b/Clique.lua
@@ -235,7 +235,7 @@ local queue = {}
 function Clique:CombatDelay(tbl)
 	if InCombatLockdown() then
 		if #queue == 0 then
-			self:Print("Cannot make changes in combat.  These changes will be delayed until you exit combat.")
+			self:Print(L.CANNOT_CHANGE_COMBAT)
 		end
 		table.insert(queue, tbl)
 		eventFrame:Show()
@@ -247,7 +247,7 @@ function Clique:ClearQueue()
 	if InCombatLockdown() then return end

 	eventFrame:Hide()
-	self:Print("Out of combat.  Applying all queued changes.")
+	self:Print(L.APPLY_QUEUE)
 	for k,v in ipairs(queue) do
 	    if v.GetAttribute then
 			self:RegisterFrame(v)
@@ -312,7 +312,7 @@ end

 function Clique:DONGLE_PROFILE_CHANGED(event, addon, name)
 	if addon == "Clique" then
-		self:Print("Profile has changed to '%s'.", name)
+		self:Print(L.PROFILE_CHANGED, name)
 		for name,set in pairs(self.clicksets) do
 			for modifier,entry in pairs(set) do
 				self:DeleteAction(entry)
@@ -337,7 +337,7 @@ end

 function Clique:DONGLE_PROFILE_DELETED(event, addon, name)
 	if addon == "Clique" then
-		self:Print("Profile '%s' has been deleted.", name)
+		self:Print(L.PROFILE_DELETED, name)

 		self.textlistSelected = nil
 		self:TextListScrollUpdate()
@@ -402,6 +402,8 @@ function Clique:SetAttribute(entry, frame)
 	elseif entry.type == "click" then
 		frame:SetAttribute(entry.modifier.."type"..button, entry.type)
 		frame:SetAttribute(entry.modifier.."delegate"..button, getglobal(entry.arg1))
+	elseif entry.type == "menu" then
+		frame:SetAttribute(entry.modifier.."type"..button, entry.type)
 	end
 end

@@ -436,10 +438,3 @@ function Clique:DeleteAction(entry)
 	end
 end

-function Clique:Print(msg, ...)
-	if string.find(msg, "%%") then
-		-- This is a string format, so lets format
-		msg = string.format(msg, ...)
-	end
-	ChatFrame1:AddMessage("|cFF33FF99Clique|r: " .. tostring(msg))
-end
diff --git a/Clique.toc b/Clique.toc
index c8a4ebe..caa3f80 100644
--- a/Clique.toc
+++ b/Clique.toc
@@ -6,8 +6,8 @@
 ## OptionalDeps: Dongle

 Dongle.lua
-Clique.lua
 Clique.xml
+Clique.lua
 Localization.en.lua
 Localization.fr.lua
 Localization.de.lua
diff --git a/Clique.xml b/Clique.xml
index e386fa8..5a7a5ad 100644
--- a/Clique.xml
+++ b/Clique.xml
@@ -40,4 +40,57 @@
             </OnClick>
         </Scripts>
         </CheckButton>
+
+	<Frame name="CliqueEditTemplate" virtual="true" hidden="true">
+		  <Size>
+			<AbsDimension x="286" y="106"/>
+		  </Size>
+			<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
+			  <BackgroundInsets>
+				<AbsInset left="4" right="4" top="4" bottom="4" />
+			  </BackgroundInsets>
+			  <TileSize>
+				<AbsValue val="16" />
+			  </TileSize>
+			  <EdgeSize>
+				<AbsValue val="16" />
+			  </EdgeSize>
+			</Backdrop>
+		<Frames>
+		  <ScrollFrame name="$parentScrollFrame" inherits="UIPanelScrollFrameTemplate">
+			<Anchors>
+				<Anchor point="TOPLEFT">
+					<Offset><AbsDimension x="8" y="-8"/></Offset>
+				</Anchor>
+				<Anchor point="BOTTOMRIGHT">
+					<Offset><AbsDimension x="-8" y="8"/></Offset>
+				</Anchor>
+			</Anchors>
+			<ScrollChild>
+			  <EditBox name="$parentEditBox" multiLine="true" letters="255" autoFocus="false">
+				<Size>
+				  <AbsDimension x="270" y="90"/>
+				</Size>
+				<Scripts>
+				  <OnTextChanged>
+					local scrollBar = getglobal(this:GetParent():GetName().."ScrollBar")
+					this:GetParent():UpdateScrollChildRect();
+					local min;
+					local max;
+					min, max = scrollBar:GetMinMaxValues();
+					if ( max > 0 and (this.max ~= max) ) then
+					this.max = max;
+					scrollBar:SetValue(max);
+					end
+				  </OnTextChanged>
+				  <OnEscapePressed>
+					this:ClearFocus();
+				  </OnEscapePressed>
+				</Scripts>
+				<FontString inherits="GameFontHighlightSmall"/>
+			  </EditBox>
+			</ScrollChild>
+		  </ScrollFrame>
+		</Frames>
+	</Frame>
 </Ui>
diff --git a/CliqueOptions.lua b/CliqueOptions.lua
index 093919c..73efa9a 100644
--- a/CliqueOptions.lua
+++ b/CliqueOptions.lua
@@ -574,17 +574,18 @@ function Clique:CreateOptionsFrame()
 	self.radio = {}

 	local buttons = {
-		{type = "actionbar", name = "Change ActionBar"},
-		{type = "action", name = "Action Button"},
-		{type = "pet", name = "Pet Action Button"},
-		{type = "spell", name = "Cast Spell"},
-		{type = "item", name = "Use Item"},
-		{type = "macro", name = "Run Custom Macro"},
-		{type = "stop", name = "Stop Casting"},
-		{type = "target", name = "Target Unit"},
-		{type = "focus", name = "Set Focus"},
-		{type = "assist", name = "Assist Unit"},
-		{type = "click", name = "Click Button"},
+		{type = "actionbar", name = L.ACTION_ACTIONBAR},
+		{type = "action", name = L.ACTION_ACTION},
+		{type = "pet", name = L.ACTION_PET},
+		{type = "spell", name = L.ACTION_SPELL},
+		{type = "item", name = L.ACTION_ITEM},
+		{type = "macro", name = L.ACTION_MACRO},
+		{type = "stop", name = L.ACTION_STOP},
+		{type = "target", name = L.ACTION_TARGET},
+		{type = "focus", name = L.ACTION_FOCUS},
+		{type = "assist", name = L.ACTION_ASSIST},
+		{type = "click", name = L.ACTION_CLICK},
+		{type = "menu", name = L.ACTION_MENU},
 	}

 	for i=1,#buttons do
@@ -722,6 +723,21 @@ function Clique:CreateOptionsFrame()
 	edit.label:SetJustifyH("RIGHT")
 	edit:Hide()

+	-- Multi line edit box
+
+	local edit = CreateFrame("ScrollFrame", "CliqueMulti", CliqueCustomFrame, "CliqueEditTemplate")
+	edit:SetPoint("TOPRIGHT", CliqueCustomArg1, "BOTTOMRIGHT", -10, -27)
+
+	local name = edit:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
+	name:SetText("Macro Text:")
+	name:SetJustifyH("RIGHT")
+	name:SetPoint("RIGHT", CliqueCustomArg2.label)
+
+	local grabber = CreateFrame("Button", "CliqueFocusGrabber", edit)
+	grabber:SetPoint("TOPLEFT", 8, -8)
+	grabber:SetPoint("BOTTOMRIGHT", -8, 8)
+	grabber:SetScript("OnClick", function() CliqueMultiScrollFrameEditBox:SetFocus() end)
+
 	-- Argument 3

 	local edit = CreateFrame("EditBox", "CliqueCustomArg3", CliqueCustomFrame, "InputBoxTemplate")
@@ -1031,6 +1047,8 @@ function Clique:FillListEntry(frame, idx)
 		else
 			frame.name:SetText(string.format("%s%s", entry.arg1, entry.arg5 and " on "..entry.arg5 or ""))
 		end
+	elseif entry.type == "menu" then
+		frame.name:SetText("Show Menu")
 	elseif entry.type == "stop" then
 		frame.name:SetText("Stop Casting")
 	elseif entry.type == "target" then
@@ -1045,6 +1063,8 @@ function Clique:FillListEntry(frame, idx)
 		elseif entry.arg3 then
 			frame.name:SetText(string.format("Item: %s", entry.arg3))
 		end
+	elseif entry.type == "macro" then
+		frame.name:SetText(string.format("Macro: %s", entry.arg1 and entry.arg1 or string.sub(entry.arg2, 1, 20)))
 	end

     frame:Show()
@@ -1151,6 +1171,9 @@ function Clique:ButtonOnClick(button)
 		CliqueCustomArg4:SetText(entry.arg4 or "")
 		CliqueCustomArg5:SetText(entry.arg5 or "")

+		CliqueMultiScrollFrameEditBox:SetText(entry.arg2 or "")
+		CliqueCustomButtonIcon.icon:SetTexture(entry.texture or "Interface\\Icons\\INV_Misc_QuestionMark")
+
 		CliqueCustomButtonBinding.modifier = entry.modifier
 		CliqueCustomButtonBinding.button = self:GetButtonNumber(entry.button)
 		CliqueCustomButtonBinding:SetText(string.format("%s%s", entry.modifier, self:GetButtonText(entry.button)))
@@ -1187,6 +1210,13 @@ function Clique:ButtonOnClick(button)
 		if tonumber(entry.arg4) then entry.arg4 = tonumber(entry.arg4) end
 		if tonumber(entry.arg5) then entry.arg5 = tonumber(entry.arg5) end

+		if entry.type == "macro" then
+			local text = CliqueMultiScrollFrameEditBox:GetText()
+			if text ~= "" then
+				entry.arg2 = text
+			end
+		end
+
 		local pattern = "Hitem.+|h%[(.+)%]|h"
 		if entry.arg1 and string.find(entry.arg1, pattern) then
 			entry.arg1 = select(3, string.find(entry.arg1, pattern))
@@ -1296,27 +1326,27 @@ local buttonSetup = {
 	action = {
 		help = "Simulate a click on an action button.  Specify the number of the action button.",
 		arg1 = "Button Number:",
-		arg2 = "Unit:",
+		arg2 = "(Optional) Unit:",
 	},
 	pet = {
 		help = "Simulate a click on an pet's action button.  Specify the number of the button.",
 		arg1 = "Pet Button Number:",
-		arg2 = "Unit:",
+		arg2 = "(Optional) Unit:",
 	},
 	spell = {
 		help = "Cast a spell from the spellbook.  Takes a spell name, and optionally a bag and slot, or item name to use as the target of the spell (i.e. Feed Pet)",
 		arg1 = "Spell Name:",
-		arg2 = "Rank/Bag Number:",
-		arg3 = "Slot Number:",
-		arg4 = "Item Name:",
-		arg5 = "Unit:",
+		arg2 = "*Rank/Bag Number:",
+		arg3 = "*Slot Number:",
+		arg4 = "*Item Name:",
+		arg5 = "(Optional) Unit:",
 	},
 	item = {
 		help = "Use an item.  Can take either a bag and slot, or an item name.",
 		arg1 = "Bag Number:",
 		arg2 = "Slot Number:",
 		arg3 = "Item Name:",
-		arg4 = "Unit:",
+		arg4 = "(Optional) Unit:",
 	},
 	macro = {
 		help = "Use a custom macro in a given index",
@@ -1328,20 +1358,23 @@ local buttonSetup = {
 	},
 	target = {
 		help = "Targets the unit",
-		arg1 = "Unit:",
+		arg1 = "(Optional) Unit:",
 	},
 	focus = {
 		help = "Sets your \"focus\" unit",
-		arg1 = "Unit:",
+		arg1 = "(Optional) Unit:",
 	},
 	assist = {
 		help = "Assists the unit",
-		arg1 = "Unit:",
+		arg1 = "(Optional) Unit:",
 	},
 	click = {
 		help = "Simulate click on a button",
 		arg1 = "Button Name:",
 	},
+	menu = {
+		help = "Shows the unit pop up menu",
+	},
 }

 function Clique:CustomRadio(button)
@@ -1393,6 +1426,15 @@ function Clique:CustomRadio(button)
 	if entry.arg3 then CliqueCustomArg3:Show() else CliqueCustomArg3:Hide() end
 	if entry.arg4 then CliqueCustomArg4:Show() else CliqueCustomArg4:Hide() end
 	if entry.arg5 then CliqueCustomArg5:Show() else CliqueCustomArg5:Hide() end
+
+	-- Handle MacroText
+	if this.type == "macro" then
+		CliqueCustomArg2:Hide()
+		CliqueMulti:Show()
+		CliqueMultiScrollFrameEditBox:SetText("")
+	else
+		CliqueMulti:Hide()
+	end
 end

 function Clique:UpdateIconFrame()
diff --git a/Localization.en.lua b/Localization.en.lua
index 05d6072..24d863a 100644
--- a/Localization.en.lua
+++ b/Localization.en.lua
@@ -42,6 +42,23 @@ local L = Clique.Locals
 	L.BERSERKERSTANCE = "Berserker Stance"

 	L.BINDING_NOT_DEFINED     = "Binding not defined"
+	L.CANNOT_CHANGE_COMBAT    = "Cannot make changes in combat.  These changes will be delayed until you exit combat."
+	L.APPLY_QUEUE             = "Out of combat.  Applying all queued changes."
+	L.PROFILE_CHANGED         = "Profile has changed to '%s'."
+	L.PROFILE_DELETED         = "Profile '%s' has been deleted."
+
+	L.ACTION_ACTIONBAR = "Change ActionBar"
+	L.ACTION_ACTION = "Action Button"
+	L.ACTION_PET = "Pet Action Button"
+	L.ACTION_SPELL = "Cast Spell"
+	L.ACTION_ITEM = "Use Item"
+	L.ACTION_MACRO = "Run Custom Macro"
+	L.ACTION_STOP = "Stop Casting"
+	L.ACTION_TARGET = "Target Unit"
+	L.ACTION_FOCUS = "Set Focus"
+	L.ACTION_ASSIST = "Assist Unit"
+	L.ACTION_CLICK = "Click Button"
+	L.ACTION_MENU = "Show Menu"

 	L.HELP_TEXT               = "Welcome to Clique.  For basic operation, you can navigate the spellbook and decide what spell you'd like to bind to a specific click.  Then click on that spell with whatever click-binding you would like.  For example, navigate to \"Flash Heal\" and shift-LeftClick on it to bind that spell to Shift-LeftClick."
 	L.CUSTOM_HELP             = "This is the Clique custom edit screen.  From here you can configure any of the combinations that the UI makes available to us in response to clicks.  Select a base action from the left column.  You can then click on the button below to set the binding you'd like, and then supply the arguments required (if any)."