From e7a9e3fd91ea7f3f4b17ca48482542a0a02c6c03 Mon Sep 17 00:00:00 2001 From: torhal Date: Mon, 18 May 2009 06:17:52 +0000 Subject: [PATCH] In AckisRecipeList.lua: Added global table to db defaults, changed addon:TRADE_SKILL_SHOW() to use db.global rather than db.profile. In ARLFrame.lua: Changed GenerateClickableTT() to cycle through menus from Realm -> Name -> Profession, and added support for this in HandleTTClick() --- ARLFrame.lua | 84 +++++++++++++++++++++++++++++++-------------------- AckisRecipeList.lua | 30 +++++++++--------- 2 files changed, 67 insertions(+), 47 deletions(-) diff --git a/ARLFrame.lua b/ARLFrame.lua index 0f409bc..8e2b133 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -3206,7 +3206,7 @@ end ------------------------------------------------------------------------------- -- Alt-Tradeskills tooltip functions ------------------------------------------------------------------------------- -local clicktip = QTipClick:Acquire("ARL_Clickable", 3, "LEFT", "LEFT", "LEFT") +local clicktip = QTipClick:Acquire("ARL_Clickable", 1, "LEFT") local function CreateSpacer(self, line_num, height, r, g, b, a) local line = self:AcquireLine(line_num) local line_tx = line.texture @@ -3222,49 +3222,67 @@ local function CreateSpacer(self, line_num, height, r, g, b, a) end clicktip.CreateSpacer = CreateSpacer --- Description: Function called when tool tip is clicked for alt trade skills - -local function HandleTTClick(cell, event, button) +------------------------------------------------------------------------------- +-- Data used in HandleTTClick() and GenerateClickableTT() +------------------------------------------------------------------------------- +local click_info = { + anchor = nil, + realm = nil, + name = nil, + prof = nil +} +local GenerateClickableTT +-- Description: Function called when tool tip is clicked for alt trade skills +local function HandleTTClick(cell, arg, event) + if not click_info.realm then + click_info.realm = arg + GenerateClickableTT() + elseif not click_info.name then + click_info.name = arg + GenerateClickableTT() + elseif not click_info.prof then + click_info.prof = arg + + -- Print link to chat frame, then reset tip data + wipe(click_info) + clicktip:ClearAllPoints() + clicktip:Hide() + end end +clicktip:SetCallback("OnMouseDown", HandleTTClick) -- Description: Creates a list of names/alts/etc in a tooltip which you can click on -local function GenerateClickableTT(anchor) - --addon.db.profile.tradeskill[prealm][pname][tradename] - local tradeskilllist = addon.db.profile.tradeskill +function GenerateClickableTT(anchor) + --addon.db.global.tradeskill[prealm][pname][tradename] + local tskl_list = addon.db.global.tradeskill local tip = clicktip local y, x - tip:SetCallback("OnMouseDown", HandleTTClick) tip:Clear() - local on_name - -- Parse the realms - for realm in pairs(tradeskilllist) do - y, x = tip:AddNormalLine() - tip:CreateSpacer(y) - -- Parse the names - for name in pairs(tradeskilllist[realm]) do - on_name = true - y, x = tip:AddNormalLine(name.." -") - y, x = tip:SetCell(y, 2, realm..":", QTip.LabelProvider) - -- Parse the professions - for prof in pairs(tradeskilllist[realm][name]) do - if on_name then - y, x = tip:SetCell(y, 3, prof) - on_name = false - else - y, x = tip:AddNormalLine(" ") - y, x = tip:SetCell(y, 3, prof) - end --- tinsert(t, name .. " - " .. realm .. " : " .. prof) - end - y, x = tip:AddNormalLine() - tip:CreateSpacer(y) + if not click_info.realm then + for realm in pairs(tskl_list) do + y, x = tip:AddLine() + tip:SetCell(y, x, realm, realm) + end + elseif not click_info.name then + for name in pairs(tskl_list[click_info.realm]) do + y, x = tip:AddLine() + tip:SetCell(y, x, name, name) end + elseif not click_info.prof then + for prof in pairs(tskl_list[click_info.realm][click_info.name]) do + y, x = tip:AddLine() + tip:SetCell(y, x, prof, prof) + end + end + if anchor then + click_info.anchor = anchor + tip:SetPoint("TOP", anchor, "BOTTOM") + else + tip:SetPoint("TOP", click_info.anchor, "BOTTOM") end - tip:SmartAnchorTo(anchor) tip:Show() --- return strcat(t,"\n") end -- Description: Creates the initial frame to display recipes into diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua index 9d8af21..3840a9c 100644 --- a/AckisRecipeList.lua +++ b/AckisRecipeList.lua @@ -136,11 +136,11 @@ function addon:OnInitialize() -- Set default options, which are to include everything in the scan local defaults = { - profile = { - - -- Saving alts tradeskills + global = { + -- Saving alts tradeskills -Torhal tradeskill = {}, - + }, + profile = { -- Frame options frameopts = { offsetx = 0, @@ -395,7 +395,6 @@ do local IsTradeSkillLinked = IsTradeSkillLinked function addon:TRADE_SKILL_SHOW() - local ownskill = IsTradeSkillLinked() -- If this is our own skill, save it, if not don't save it @@ -407,16 +406,17 @@ do local tradename = GetTradeSkillLine() if (tradelink) then - if (not addon.db.profile.tradeskill) then - addon.db.profile.tradeskill = {} + -- Actual alt information saved here. -Torhal + if (not addon.db.global.tradeskill) then + addon.db.global.tradeskill = {} end - if (not addon.db.profile.tradeskill[prealm]) then - addon.db.profile.tradeskill[prealm] = {} + if (not addon.db.global.tradeskill[prealm]) then + addon.db.global.tradeskill[prealm] = {} end - if (not addon.db.profile.tradeskill[prealm][pname]) then - addon.db.profile.tradeskill[prealm][pname] = {} + if (not addon.db.global.tradeskill[prealm][pname]) then + addon.db.global.tradeskill[prealm][pname] = {} end - addon.db.profile.tradeskill[prealm][pname][tradename] = tradelink + addon.db.global.tradeskill[prealm][pname][tradename] = tradelink end end addon:OpenTradeWindow() @@ -2693,9 +2693,11 @@ do end --Description: Clears all saved tradeskills - function addon:ClearSavedSkills() + wipe(addon.db.global.tradeskill) - addon.db.profile.tradeskill = {} + if addon.db.profile.tradeskill then + addon.db.profile.tradeskill = nil + end end -- 1.7.9.5