From 7afa9cd67165608aa58752e4d03d10482bcbd072 Mon Sep 17 00:00:00 2001 From: torhal Date: Mon, 7 Dec 2009 11:43:03 +0000 Subject: [PATCH] Moved some frame creation out of a do block. In addon:Scan(): If the player knows the current profession (not linked), update the cached skill level. In the NPC tooltip hook: Check to see if the character has equal or greater skill level to that required by the recipe - if not, don't show it. Also added the required skill level next to the recipe name in the tooltip. --- ARLFrame.lua | 40 +++++++++++++++++++++------------------- AckisRecipeList.lua | 25 +++++++++++++++++++------ 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/ARLFrame.lua b/ARLFrame.lua index 7159dad..f9d9fc9 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -2575,33 +2575,35 @@ end -- do ------------------------------------------------------------------------------- -- Create MainPanel.progress_bar and set its scripts ------------------------------------------------------------------------------- +MainPanel.progress_bar = CreateFrame("StatusBar", nil, MainPanel) +MainPanel.progress_bar:SetWidth(195) +MainPanel.progress_bar:SetHeight(14) + +MainPanel.progress_bar:ClearAllPoints() +MainPanel.progress_bar:SetPoint("BOTTOMLEFT", MainPanel, 17, 7) + +MainPanel.progress_bar:SetStatusBarTexture("Interface\\Addons\\AckisRecipeList\\img\\progressbar") +MainPanel.progress_bar:SetOrientation("HORIZONTAL") +MainPanel.progress_bar:SetStatusBarColor(0.25, 0.25, 0.75) + +MainPanel.progress_bar.text = MainPanel.progress_bar:CreateFontString(nil, "ARTWORK") +MainPanel.progress_bar.text:SetWidth(195) +MainPanel.progress_bar.text:SetHeight(14) +MainPanel.progress_bar.text:SetFontObject("GameFontHighlightSmall") + +MainPanel.progress_bar.text:ClearAllPoints() +MainPanel.progress_bar.text:SetPoint("CENTER", MainPanel.progress_bar, "CENTER", 0, 0) +MainPanel.progress_bar.text:SetJustifyH("CENTER") + +-- Default values for the progressbar do - -- Default values for the progressbar local pbMin = 0 local pbMax = 100 local pbCur = 50 - MainPanel.progress_bar = CreateFrame("StatusBar", nil, MainPanel) - MainPanel.progress_bar:SetWidth(195) - MainPanel.progress_bar:SetHeight(14) - - MainPanel.progress_bar:ClearAllPoints() - MainPanel.progress_bar:SetPoint("BOTTOMLEFT", MainPanel, 17, 7) - - MainPanel.progress_bar:SetStatusBarTexture("Interface\\Addons\\AckisRecipeList\\img\\progressbar") - MainPanel.progress_bar:SetOrientation("HORIZONTAL") - MainPanel.progress_bar:SetStatusBarColor(0.25, 0.25, 0.75) MainPanel.progress_bar:SetMinMaxValues(pbMin, pbMax) MainPanel.progress_bar:SetValue(pbCur) - MainPanel.progress_bar.text = MainPanel.progress_bar:CreateFontString(nil, "ARTWORK") - MainPanel.progress_bar.text:SetWidth(195) - MainPanel.progress_bar.text:SetHeight(14) - MainPanel.progress_bar.text:SetFontObject("GameFontHighlightSmall") - - MainPanel.progress_bar.text:ClearAllPoints() - MainPanel.progress_bar.text:SetPoint("CENTER", MainPanel.progress_bar, "CENTER", 0, 0) - MainPanel.progress_bar.text:SetJustifyH("CENTER") MainPanel.progress_bar.text:SetFormattedText("%d / %d - %d%%", pbCur, pbMax, floor(pbCur / pbMax * 100)) end -- do diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua index d76dcb2..b3590a9 100644 --- a/AckisRecipeList.lua +++ b/AckisRecipeList.lua @@ -515,7 +515,7 @@ function addon:OnInitialize() if not recipe["Known"] or shifted then local _, _, _, hex = GetItemQualityColor(recipe["Rarity"]) - self:AddLine("Drops: "..hex..recipe["Name"].."|r") + self:AddLine("Drops: "..hex..recipe["Name"].."|r ("..recipe["Level"]..")") end end return @@ -525,11 +525,13 @@ function addon:OnInitialize() if vendor and vendor["SellList"] then for spell_id in pairs(vendor["SellList"]) do local recipe = RecipeList[spell_id] + local skill_level = Player["Professions"][GetSpellInfo(recipe["Profession"])] + local has_skill = skill_level and skill_level >= recipe["Level"] - if (not recipe["Known"] or shifted) and Player:IsCorrectFaction(recipe["Flags"]) then + if ((not recipe["Known"] and has_skill) or shifted) and Player:IsCorrectFaction(recipe["Flags"]) then local _, _, _, hex = GetItemQualityColor(recipe["Rarity"]) - self:AddLine("Sells: "..hex..recipe["Name"].."|r") + self:AddLine("Sells: "..hex..recipe["Name"].."|r ("..recipe["Level"]..")") end end return @@ -539,11 +541,13 @@ function addon:OnInitialize() if trainer and trainer["TrainList"] then for spell_id in pairs(trainer["TrainList"]) do local recipe = RecipeList[spell_id] + local skill_level = Player["Professions"][GetSpellInfo(recipe["Profession"])] + local has_skill = skill_level and skill_level >= recipe["Level"] - if (not recipe["Known"] or shifted) and Player:IsCorrectFaction(recipe["Flags"]) then + if ((not recipe["Known"] and has_skill) or shifted) and Player:IsCorrectFaction(recipe["Flags"]) then local _, _, _, hex = GetItemQualityColor(recipe["Rarity"]) - self:AddLine("Trains: "..hex..recipe["Name"].."|r") + self:AddLine("Trains: "..hex..recipe["Name"].."|r ("..recipe["Level"]..")") end end return @@ -1455,7 +1459,16 @@ do self:Print(L["OpenTradeSkillWindow"]) return end - Player["Profession"], Player["ProfessionLevel"] = GetTradeSkillLine() + local current_prof, prof_level = GetTradeSkillLine() + + -- Set the current profession and its level, and update the cached data. + Player["Profession"] = current_prof + Player["ProfessionLevel"] = prof_level + + -- Make sure we're only updating a profession the character actually knows - this could be a scan from a tradeskill link. + if not IsTradeSkillLinked() and Player["Professions"][current_prof] then + Player["Professions"][current_prof] = prof_level + end -- Get the current profession Specialty local specialty = SpecialtyTable[Player["Profession"]] -- 1.7.9.5