From 3cc6d4ec426ec6af5e1537da8c55808c28c2c3b5 Mon Sep 17 00:00:00 2001 From: pschifferer Date: Fri, 23 Jan 2009 04:37:08 +0000 Subject: [PATCH] Changed the template that gets inherited for the reagent items, because the tradeskill template just "stopped working." Refactored tooltip generation for items in the skill list. Disabled tooltip generation on queue items for the time being. --- Cauldron/CauldronMain.lua | 8 ++--- Cauldron/CauldronMain.xml | 34 ++++++-------------- Cauldron/CauldronMainUI.lua | 65 ++++++++++++++++----------------------- Cauldron/CauldronQueue.lua | 22 ++++++------- Cauldron/CauldronTradeskill.lua | 1 + 5 files changed, 51 insertions(+), 79 deletions(-) diff --git a/Cauldron/CauldronMain.lua b/Cauldron/CauldronMain.lua index c9702b4..b61feff 100644 --- a/Cauldron/CauldronMain.lua +++ b/Cauldron/CauldronMain.lua @@ -587,7 +587,7 @@ end ["amount"] = , -- amount of this skill that must be executed ["priority"] = , -- priority of the skill, for ordering in the queue ["icon"] = "", -- the icon path of the skill, for display - ["index"] = , -- the index of the skill, for API call usage + ["link"] = "", }, }, ["main"] = { @@ -597,7 +597,7 @@ end ["amount"] = , ["priority"] = , ["icon"] = "", - ["index"] = , + ["link"] = "", }, }, ["reagents"] = { @@ -605,9 +605,8 @@ end ["tradeskill"] = "", ["name"] = "", ["amount"] = , - ["index"] = , -- the index of the reagent, for API call usage ["icon"] = "", - ["skillIndex"] = , + ["link"] = "", }, }, }, @@ -699,6 +698,7 @@ function Cauldron:Reset() -- close the window Cauldron:Frame_Hide(); + HideUIPanel(TradeSkillFrame); -- reset the shopping list self.db.realm.shopping = CauldronShopping:NewList(); diff --git a/Cauldron/CauldronMain.xml b/Cauldron/CauldronMain.xml index abbf802..310ee6b 100644 --- a/Cauldron/CauldronMain.xml +++ b/Cauldron/CauldronMain.xml @@ -1,11 +1,9 @@ - - - @@ -117,26 +111,20 @@ Cauldron:SkillItem_OnClick(self, button, down); - --[[ GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetTradeSkillItem(self.skillIndex); CursorUpdate(self); - --]] - --[[ GameTooltip:Hide(); ResetCursor(); - --]] - --[[ if GameTooltip:IsOwned(self) then GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:SetTradeSkillItem(self.skillIndex); CursorUpdate(self); end - --]] CursorOnUpdate(self); @@ -352,26 +340,24 @@ -- HandleModifiedItemClick(GetTradeSkillItemLink(TradeSkillFrame.selectedSkill)); - --[[ GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); - GameTooltip:SetTradeSkillItem(self.skillIndex, self.reagentIndex); + if self.link then + GameTooltip:SetHyperlink(self.link); + end CursorUpdate(self); - --]] - --[[ GameTooltip:Hide(); ResetCursor(); - --]] - --[[ if GameTooltip:IsOwned(self) then GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); - GameTooltip:SetTradeSkillItem(self.skillIndex, self.reagentIndex); + if self.link then + GameTooltip:SetHyperlink(self.link); + end CursorUpdate(self); end - --]] CursorOnUpdate(self); diff --git a/Cauldron/CauldronMainUI.lua b/Cauldron/CauldronMainUI.lua index 3836efa..09eb7af 100644 --- a/Cauldron/CauldronMainUI.lua +++ b/Cauldron/CauldronMainUI.lua @@ -173,6 +173,8 @@ function Cauldron:UpdateSkillList() -- iterate over the list of skills for i, skillInfo in ipairs(skillList) do + self:debug("UpdateSkillList: i="..i); + local skillFrame = _G["CauldronSkillItem"..i]; -- check if we have a frame for this position @@ -207,21 +209,25 @@ function Cauldron:UpdateSkillList() nameText = nameText.." ["..skillInfo.available.."]"; end frame:SetText(nameText); - local color = TradeSkillTypeColor[skillInfo.difficulty]; - if color then - frame:SetFontObject(color.font); - frame.r = color.r; - frame.g = color.g; - frame.b = color.b; + if TradeSkillTypeColor then + local color = TradeSkillTypeColor[skillInfo.difficulty]; + if color then + frame:SetFontObject(color.font); + frame.r = color.r; + frame.g = color.g; + frame.b = color.b; + end end -- set category frame = _G["CauldronSkillItem"..i.."SkillCategory"]; frame:SetText(skillInfo.defaultCategory); - frame:SetFontObject(TradeSkillTypeColor.header.font); - frame.r = TradeSkillTypeColor.header.r; - frame.g = TradeSkillTypeColor.header.g; - frame.b = TradeSkillTypeColor.header.b; + if TradeSkillTypeColor then + frame:SetFontObject(TradeSkillTypeColor.header.font); + frame.r = TradeSkillTypeColor.header.r; + frame.g = TradeSkillTypeColor.header.g; + frame.b = TradeSkillTypeColor.header.b; + end -- set favorite check button frame = _G["CauldronSkillItem"..i.."FavoriteButton"]; @@ -266,6 +272,7 @@ function Cauldron:UpdateSkillList() -- set the disclosure button texture frame = _G["CauldronSkillItem"..i.."DiscloseButton"]; frame.skillInfo = skillInfo; + self:debug("UpdateSkillList: skillInfo.name="..skillInfo.name); local reagentsExpanded = self.db.realm.userdata[self.vars.playername].skills[skillName].window.skills[skillInfo.name].expanded; self:debug("UpdateSkillList: reagentsExpanded="..tostring(reagentsExpanded)); if reagentsExpanded then @@ -295,36 +302,27 @@ function Cauldron:UpdateSkillList() local reagentCount = #skillInfo.reagents; for j=1,8 do - self:debug("UpdateSkillList: j="..j); - local reagentFrame = _G["CauldronSkillItem"..i.."ReagentsItemDetail"..j]; - self:debug("UpdateSkillList: reagentFrame="..tostring(reagentFrame)); - local reagentInfo = skillInfo.reagents[j]; - self:debug("UpdateSkillList: reagentInfo="..tostring(reagentInfo)); - reagentFrame.skillIndex = skillInfo.index; - if j > reagentCount then - self:debug("UpdateSkillList: hide the reagent frame"); reagentFrame:Hide(); else - self:debug("UpdateSkillList: show the reagent info"); + local reagentInfo = skillInfo.reagents[j]; + + reagentFrame.skillIndex = skillInfo.index; + reagentFrame.reagentIndex = reagentInfo.index; local reagentNameFrame = _G["CauldronSkillItem"..i.."ReagentsItemDetail"..j.."Name"]; - self:debug("UpdateSkillList: reagentNameFrame="..tostring(reagentNameFrame)); local reagentCountFrame = _G["CauldronSkillItem"..i.."ReagentsItemDetail"..j.."Count"]; - self:debug("UpdateSkillList: reagentCountFrame="..tostring(reagentCountFrame)); - self:debug("UpdateSkillList: show the reagent frame"); reagentFrame:Show(); - self:debug("UpdateSkillList: set the item button texture"); SetItemButtonTexture(reagentFrame, reagentInfo.icon); - self:debug("UpdateSkillList: set the reagent name"); reagentNameFrame:SetText(reagentInfo.name); local playerReagentCount = reagentInfo.toonHas; - -- Grayout items + if playerReagentCount < reagentInfo.numRequired then + -- Grayout items SetItemButtonTextureVertexColor(reagentFrame, 0.5, 0.5, 0.5); reagentNameFrame:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b); else @@ -334,7 +332,7 @@ function Cauldron:UpdateSkillList() if playerReagentCount >= 100 then playerReagentCount = "*"; end - reagentCountFrame:SetText(playerReagentCount.." /"..reagentInfo.numRequired); + reagentCountFrame:SetText(playerReagentCount.."/"..reagentInfo.numRequired); end end @@ -342,8 +340,6 @@ function Cauldron:UpdateSkillList() _G["CauldronSkillItem"..i.."Reagents"]:SetHeight(toolsFrame:GetHeight() + (reagentRows * _G["CauldronSkillItem"..i.."ReagentsItemDetail1"]:GetHeight())); _G["CauldronSkillItem"..i]:SetHeight(_G["CauldronSkillItem"..i.."SkillIcon"]:GetHeight() + _G["CauldronSkillItem"..i.."Reagents"]:GetHeight()); else - self:debug("UpdateSkillList: reagents info not expanded"); - _G["CauldronSkillItem"..i.."Reagents"]:Hide(); frame:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up"); @@ -558,9 +554,7 @@ function Cauldron:UpdateQueue() -- set the icon frame = _G["CauldronQueueItem"..i.."Icon"]; frame:SetNormalTexture(queueInfo.icon); - if skillInfo then - frame.skillIndex = skillInfo.index; - end + frame.link = queueInfo.link; -- set the amount frame = _G["CauldronQueueItem"..i.."IconCount"]; @@ -693,9 +687,7 @@ function Cauldron:UpdateQueue() -- set the icon frame = _G["CauldronQueueIntItem"..i.."Icon"]; frame:SetNormalTexture(queueInfo.icon); - if skillInfo then - frame.skillIndex = skillInfo.index; - end + frame.link = queueInfo.link; -- set the amount frame = _G["CauldronQueueIntItem"..i.."IconCount"]; @@ -812,10 +804,7 @@ function Cauldron:UpdateQueue() -- set the icon frame = _G["CauldronQueueReagentItem"..i.."Icon"]; frame:SetNormalTexture(queueInfo.icon); - if skillInfo then - frame.skillIndex = queueInfo.skillIndex; - frame.reagentIndex = queueInfo.index; - end + frame.link = queueInfo.link; -- local playerReagentCount = 0; -- TODO -- if playerReagentCount < queueInfo.amount then -- frame:SetVertexColor(0.5, 0.5, 0.5, 1.0); diff --git a/Cauldron/CauldronQueue.lua b/Cauldron/CauldronQueue.lua index 6391e2f..b6b3550 100644 --- a/Cauldron/CauldronQueue.lua +++ b/Cauldron/CauldronQueue.lua @@ -11,10 +11,9 @@ CauldronQueue = {}; ["name"] = "", ["icon"] = "", ["tradeskill"] = "", - ["skillIndex"] = , - ["reagentIndex"] = , -- for intermediates ["amount"] = , ["priority"] = , + ["link"] = "", }; The following table describes a reagent needed by items in the queue. @@ -24,8 +23,7 @@ CauldronQueue = {}; ["icon"] = "", ["amount"] = , ["tradeskill"] = "", - ["skillIndex"] = , - ["reagentIndex"] = , -- for intermediates + ["link"] = "", }; --]] @@ -39,14 +37,13 @@ function CauldronQueue:NewQueue() return queue; end -function CauldronQueue:NewItem(name, icon, amount, priority, tradeskill, skillIndex, reagentIndex) +function CauldronQueue:NewItem(name, icon, amount, priority, tradeskill, link) local queueItem = { ["name"] = name or "", ["icon"] = icon or "", ["tradeskill"] = tradeskill or "", - ["skillIndex"] = skillIndex, - ["reagentIndex"] = reagentIndex, + ["link"] = link, ["amount"] = amount or 1, ["priority"] = priority or 0, }; @@ -54,15 +51,14 @@ function CauldronQueue:NewItem(name, icon, amount, priority, tradeskill, skillIn return queueItem; end -function CauldronQueue:NewReagent(name, icon, amount, tradeskill, skillIndex, reagentIndex) +function CauldronQueue:NewReagent(name, icon, amount, tradeskill, link) local reagent = { ["name"] = name or "", ["icon"] = icon or "", ["amount"] = amount or 1, ["tradeskill"] = tradeskill, - ["skillIndex"] = skillIndex, - ["reagentIndex"] = reagentIndex, + ["link"] = link, }; return reagent; @@ -158,7 +154,7 @@ function CauldronQueue:AddItem(queue, skillInfo, amount, suppressCalc) item.amount = item.amount + amount; else -- it's not there, so create a new instance - queue.main[skillInfo.name] = CauldronQueue:NewItem(skillInfo.name, skillInfo.icon, amount, 0, skillInfo.tradeskill, skillInfo.index); + queue.main[skillInfo.name] = CauldronQueue:NewItem(skillInfo.name, skillInfo.icon, amount, nil, skillInfo.tradeskill); end if not suppressCalc then @@ -274,7 +270,7 @@ function CauldronQueue:AddIntermediate(queue, reagent, amount) local skillInfo = Cauldron:GetSkillInfoForItem(reagent.name); -- it's not there, so create a new instance - queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, amount, 0, skillInfo.tradeskill, skillInfo.index, reagent.index); + queue.intermediate[reagent.name] = CauldronQueue:NewItem(reagent.name, reagent.icon, amount, nil, skillInfo.tradeskill); end end @@ -300,7 +296,7 @@ function CauldronQueue:AddReagent(queue, reagent, amount, tradeskill) item.amount = (tonumber(item.amount) or 0) + amount; else -- it's not there, so create a new instance - queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill, reagent.skillIndex, reagent.index); + queue.reagents[reagent.name] = CauldronQueue:NewReagent(reagent.name, reagent.icon, amount, tradeskill); end end diff --git a/Cauldron/CauldronTradeskill.lua b/Cauldron/CauldronTradeskill.lua index da7c7d1..82065dd 100644 --- a/Cauldron/CauldronTradeskill.lua +++ b/Cauldron/CauldronTradeskill.lua @@ -116,6 +116,7 @@ function Cauldron:UpdateSkills() for j=1,GetTradeSkillNumReagents(i) do local rname, rtex, rcount, hasCount = GetTradeSkillReagentInfo(i,j); + self:debug("UpdateSkills: rname="..tostring(rname).."; rtex="..tostring(rtex).."; rcount="..tostring(rcount).."; hasCount="..tostring(hasCount)); if rname then table.insert(skillDB.recipes[name].reagents, { -- 1.7.9.5