Quantcast

In ARLFrame.lua: Re-worked the alt-tradeskills code to use the new LibQTip-1.0 script methods rather than the LibQTipClick-1.1 methods.

torhal [07-22-09 - 05:59]
In ARLFrame.lua: Re-worked the alt-tradeskills code to use the new LibQTip-1.0 script methods rather than the LibQTipClick-1.1 methods.
In GenerateClickableTT(): Added check to not display the current character's name in the list of alts.
Removed all references to LibQTipClick-1.1 from .pkgmeta, embeds.xml, and AckisRecipeList.toc
Filename
.pkgmeta
ARLFrame.lua
AckisRecipeList.toc
embeds.xml
diff --git a/.pkgmeta b/.pkgmeta
index bc022ae..b8d1c1c 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -72,6 +72,3 @@ externals:
  libs/LibQTip-1.0:
   url: svn://svn.wowace.com/wow/libqtip-1-0/mainline/trunk
   tag: latest
- libs/LibQTipClick-1.1:
-  url: git://git.wowace.com/wow/libqtipclick-1-1/mainline.git
-  tag: latest
diff --git a/ARLFrame.lua b/ARLFrame.lua
index d9c2b8d..825aaa4 100644
--- a/ARLFrame.lua
+++ b/ARLFrame.lua
@@ -31,7 +31,6 @@ local BFAC		= LibStub("LibBabble-Faction-3.0"):GetLookupTable()
 local BC		= LibStub("LibBabble-Class-3.0"):GetLookupTable()
 local L			= LibStub("AceLocale-3.0"):GetLocale(MODNAME)
 local QTip		= LibStub("LibQTip-1.0")
-local QTipClick		= LibStub("LibQTipClick-1.1")

 -------------------------------------------------------------------------------
 -- Upvalued Lua globals
@@ -3278,12 +3277,7 @@ local function SetFramePosition()
 end

 -------------------------------------------------------------------------------
--- Alt-Tradeskills tooltip
--------------------------------------------------------------------------------
-local clicktip
-
--------------------------------------------------------------------------------
--- Data used in HandleTTClick() and GenerateClickableTT()
+-- Data used in GenerateClickableTT() and its support functions.
 -------------------------------------------------------------------------------
 local click_info = {
 	anchor = nil,
@@ -3293,21 +3287,75 @@ local click_info = {
 	name = nil,
 	realm = nil,
 }
+local clicktip
+local GenerateClickableTT	-- Upvalued!

--- Description: Creates a list of names/alts/etc in a tooltip which you can click on
+-------------------------------------------------------------------------------
+-- Clicktip OnMouseUp scripts.
+-------------------------------------------------------------------------------
+local function ChangeRealm(cell, arg, button)
+	click_info.modified = true
+	click_info.realm = nil
+	click_info.change_realm = true
+	click_info.target_realm = nil
+	GenerateClickableTT()
+end
+
+local function SelectRealm(cell, arg, button)
+	click_info.modified = true
+
+	if click_info.change_realm then
+		click_info.target_realm = arg
+	end
+	click_info.realm = arg
+	GenerateClickableTT()
+end

-local function GenerateClickableTT(anchor)
+local function SelectName(cell, arg, button)
+	click_info.modified = true
+	click_info.name = arg
+
+	-- Wipe tradeskill information for the selected toon. -Torhal
+	if IsAltKeyDown() and button == "LeftButton" then
+		local tskl_list = addon.db.global.tradeskill
+		tskl_list[click_info.realm][click_info.name] = nil
+
+		-- See if there are any toons left on the realm. If not, nuke it as well.
+		local found = false
+		for name in pairs(tskl_list[click_info.realm]) do
+			found = true
+		end
+		if not found then
+			tskl_list[click_info.realm] = nil
+		end
+		local anchor = click_info.anchor
+		twipe(click_info)
+		click_info.anchor = anchor
+		GenerateClickableTT()
+		return
+	end
+	GenerateClickableTT()
+end
+
+local function SelectProfession(cell, arg, button)
+	local tskl_list = addon.db.global.tradeskill
+	click_info.modified = true
+	addon:Print(click_info.name .. " - " .. click_info.realm .. ": " .. tskl_list[click_info.realm][click_info.name][arg])
+end
+
+-------------------------------------------------------------------------------
+-- Creates a list of names/alts/etc in a tooltip which can be clicked.
+-------------------------------------------------------------------------------
+function GenerateClickableTT(anchor)
 	local tskl_list = addon.db.global.tradeskill
 	local tip = clicktip
 	local y, x
 	local prealm = GetRealmName()
-	local target_realm
+	local target_realm = prealm

 	if click_info.change_realm then
 		target_realm = click_info.target_realm
 		click_info.change_realm = nil
-	else
-		target_realm = prealm
 	end
 	tip:Clear()

@@ -3321,47 +3369,54 @@ local function GenerateClickableTT(anchor)

 			if not target_realm and (realm ~= prealm) then
 				if not header then
-					tip:AddNormalHeader(L["Other Realms"])
+					tip:AddHeader(L["Other Realms"])
 					tip:AddSeparator()
 					header = true
 				end
 				y, x = tip:AddLine()
-				tip:SetCell(y, x, realm, realm)
+				tip:SetCell(y, x, realm)
+				tip:SetCellScript(y, x, "OnMouseUp", SelectRealm, realm)
 			elseif realm == target_realm then
-				tip:AddNormalHeader(realm)
+				tip:AddHeader(realm)
 				tip:AddSeparator()

 				click_info.realm = realm
 				for name in pairs(tskl_list[click_info.realm]) do
-					y, x = tip:AddLine()
-					tip:SetCell(y, x, name, name)
+					if name ~= UnitName("player") then
+						y, x = tip:AddLine()
+						tip:SetCell(y, x, name)
+						tip:SetCellScript(y, x, "OnMouseUp", SelectName, name)
+					end
 				end
 			end
 		end
 		if other_realms then
 			tip:AddSeparator()
 			y, x = tip:AddLine()
-			tip:SetCell(y, x, L["Other Realms"], "change realm")
+			tip:SetCell(y, x, L["Other Realms"])
+			tip:SetCellScript(y, x, "OnMouseUp", ChangeRealm)
 		end
 		tip:AddSeparator()
 	elseif not click_info.name then
 		local realm_list = tskl_list[click_info.realm]

 		if realm_list then
-			tip:AddNormalLine(click_info.realm)
+			tip:AddLine(click_info.realm)
 			tip:AddSeparator()
 			for name in pairs(realm_list) do
 				y, x = tip:AddLine()
-				tip:SetCell(y, x, name, name)
+				tip:SetCell(y, x, name)
+				tip:SetCellScript(y, x, "OnMouseUp", SelectName, name)
 			end
 			tip:AddSeparator()
 		end
 	else
-		tip:AddNormalHeader(click_info.name)
+		tip:AddHeader(click_info.name)
 		tip:AddSeparator()
 		for prof in pairs(tskl_list[click_info.realm][click_info.name]) do
 			y, x = tip:AddLine()
-			tip:SetCell(y, x, prof, prof)
+			tip:SetCell(y, x, prof)
+			tip:SetCellScript(y, x, "OnMouseUp", SelectProfession, prof)
 		end
 		tip:AddSeparator()
 	end
@@ -3374,54 +3429,6 @@ local function GenerateClickableTT(anchor)
 	tip:Show()
 end

--- Description: Function called when tool tip is clicked for alt trade skills
-
-local function HandleTTClick(event, cell, arg, button)
-	click_info.modified = true
-
-	if arg == "change realm" then
-		click_info.realm = nil
-		click_info.change_realm = true
-		click_info.target_realm = nil
-		GenerateClickableTT()
-		return
-	end
-	local tskl_list = addon.db.global.tradeskill
-
-	if not click_info.realm then
-		if click_info.change_realm then
-			click_info.target_realm = arg
-		end
-		click_info.realm = arg
-		GenerateClickableTT()
-	elseif not click_info.name then
-		click_info.name = arg
-
-		-- Wipe tradeskill information for the selected toon. -Torhal
-		if IsAltKeyDown() and button == "LeftButton" then
-			tskl_list[click_info.realm][click_info.name] = nil
-
-			-- See if there are any toons left on the realm. If not, nuke it as well.
-			local found = false
-			for name in pairs(tskl_list[click_info.realm]) do
-				found = true
-			end
-			if not found then
-				tskl_list[click_info.realm] = nil
-			end
-			local anchor = click_info.anchor
-			twipe(click_info)
-			click_info.anchor = anchor
-			GenerateClickableTT()
-			return
-		end
-		GenerateClickableTT()
-	else
-		-- Print link to chat frame, then reset tip data
-		addon:Print(click_info.name .. " - " .. click_info.realm .. ": " .. tskl_list[click_info.realm][click_info.name][arg])
-	end
-end
-
 -------------------------------------------------------------------------------
 -- Creates the initial frame to display recipes into.
 -------------------------------------------------------------------------------
@@ -4682,15 +4689,14 @@ function InitializeFrame()
 				 function(this, button)
 					 if clicktip then
 						 if not click_info.modified then
-							 clicktip = QTipClick:Release(clicktip)
+							 clicktip = QTip:Release(clicktip)
 							 twipe(click_info)
 						 else
 							 twipe(click_info)
 							 GenerateClickableTT(this)
 						 end
 					 else
-						 clicktip = QTipClick:Acquire("ARL_Clickable", 1, "CENTER")
-						 clicktip:SetCallback("OnMouseDown", HandleTTClick)
+						 clicktip = QTip:Acquire("ARL_Clickable", 1, "CENTER")
 						 twipe(click_info)
 						 if TipTac and TipTac.AddModifiedTip then
 							 TipTac:AddModifiedTip(clicktip, true)
@@ -4700,7 +4706,7 @@ function InitializeFrame()
 				 end)
 	ARL_MiscAltBtn:SetScript("OnHide",
 				 function(this, button)
-					 clicktip = QTipClick:Release(clicktip)
+					 clicktip = QTip:Release(clicktip)
 					 twipe(click_info)
 				 end)

diff --git a/AckisRecipeList.toc b/AckisRecipeList.toc
index 5fe8525..584b8ae 100644
--- a/AckisRecipeList.toc
+++ b/AckisRecipeList.toc
@@ -44,7 +44,7 @@
 ## X-Website: http://www.wowwiki.com/AckisRecipeList/
 ## X-Feedback: http://wow.curse.com/downloads/wow-addons/details/arl.aspx

-## OptionalDeps: Ace3, LibAboutPanel, LibBetterBlizzOptions-1.0, LibBabble-Zone-3.0, LibBabble-Faction-3.0, LibBabble-Boss-3.0, LibBabble-Class-3.0, LibSharedMedia-3.0, LibQTip-1.0, LibQTipClick-1.1, Skillet, ATSW, Manufac, Cauldron, TomTom, TipTac, Carbonite
+## OptionalDeps: Ace3, LibAboutPanel, LibBetterBlizzOptions-1.0, LibBabble-Zone-3.0, LibBabble-Faction-3.0, LibBabble-Boss-3.0, LibBabble-Class-3.0, LibSharedMedia-3.0, LibQTip-1.0, Skillet, ATSW, Manufac, Cauldron, TomTom, TipTac, Carbonite
 ## DefaultState: Enabled

 ## X-WoWI-ID: 5061
diff --git a/embeds.xml b/embeds.xml
index 63721ea..d763009 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -24,6 +24,5 @@
 <Include file="libs\LibSharedMedia-3.0\lib.xml"/>
 <Include file="libs\LibBetterBlizzOptions\LibBetterBlizzOptions-1.0\lib.xml"/>
 <Include file="libs\LibQTip-1.0\lib.xml"/>
-<Include file="libs\LibQTipClick-1.1\lib.xml"/>

 </Ui>
\ No newline at end of file