From a9672d3015bfdc1c828d0d70acc4fd4a6e9b26c5 Mon Sep 17 00:00:00 2001 From: Xruptor Date: Fri, 26 Aug 2016 20:08:40 -0400 Subject: [PATCH] Some fixes to the Professions window -Added some more smart sorting and processing for professions with no recipes. --- modules/professions.lua | 49 +++++++++++++++++++++++++++++++---------------- modules/search.lua | 6 +----- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/modules/professions.lua b/modules/professions.lua index 9f5104c..fd0d98e 100644 --- a/modules/professions.lua +++ b/modules/professions.lua @@ -43,41 +43,58 @@ function Professions:AddEntry(entry, isHeader) local highlightColor = {1, 0, 0} local label = AceGUI:Create("InteractiveLabel") - label.userdata.highlight = label.frame:CreateTexture(nil, "BACKGROUND") --userdata gets deleted when widget is recycled - label.userdata.highlight:SetAllPoints() - label.userdata.highlight:SetBlendMode("ADD") - label.userdata.highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") --userdata gets deleted when widget is recycled - label.userdata.highlight:Hide() - + --I know you aren't supposed to but I'm going to have to put it on the label object. Only because when using userdata the texture sticks around even with release. + --So I'm forced to have to add it to label and do a custom OnRelease to get rid of it for other addons. + if not label.headerhighlight then + label.headerhighlight = label.frame:CreateTexture(nil, "BACKGROUND") --userdata gets deleted when widget is recycled + label.headerhighlight:SetAllPoints() + label.headerhighlight:SetBlendMode("ADD") + label.headerhighlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") --userdata gets deleted when widget is recycled + end + --remove the highlight texture on widget release for other addons + local oldOnRelease = label.OnRelease + label.OnRelease = function(self) + if self.headerhighlight then + self.headerhighlight:SetTexture(nil) + self.headerhighlight = nil + end + if oldOnRelease then + oldOnRelease(self) + end + end + label.userdata.color = {1, 1, 1} - + label.headerhighlight:Hide() --hide on default + if isHeader then label:SetText(entry.player) label:SetFont("Fonts\\FRIZQT__.TTF", 14, THICKOUTLINE) label:SetFullWidth(true) label:SetColor(unpack(label.userdata.color)) - label.userdata.highlight:Show() label.label:SetJustifyH("CENTER") --don't like doing this until they update Ace3GUI label.userdata.isHeader = isHeader + label.userdata.hasRecipes = false + label.headerhighlight:Show() else - label:SetText(entry.name) + local labelText = entry.name..format(" |cFFFFFFFF(%s)|r", entry.level) + label:SetText(labelText) label:SetFont("Fonts\\FRIZQT__.TTF", 14, THICKOUTLINE) label:SetFullWidth(true) - if entry.recipeIndex <= 2 then + if entry.recipes then label.userdata.color = {153/255,204/255,51/255} --primary profession color it green else label.userdata.color = {102/255,153/255,1} --gathering profession color it blue end - label.userdata.highlight:Hide() label:SetColor(unpack(label.userdata.color)) label.label:SetJustifyH("LEFT")--don't like doing this until they update Ace3GUI label.userdata.isHeader = isHeader + label.userdata.hasRecipes = entry.recipes end label:SetCallback( "OnClick", function (widget, sometable, button) - if "LeftButton" == button then + if "LeftButton" == button and label.userdata.hasRecipes then print("left") end end) @@ -115,8 +132,10 @@ function Professions:DisplayList() local playerName = BSYC:GetCharacterRealmInfo(yName, yRealm) for q, r in pairs(v) do - local tName, tLevel = strsplit(",", r) - table.insert(tmp, { name=tName, level=tLevel, player=playerName, recipeIndex=q } ) + local chkRecipes = false + local tName, tLevel, tRecipeList = strsplit(",", r) + if tRecipeList then chkRecipes = true end + table.insert(tmp, { name=tName, level=tLevel, player=playerName, recipeIndex=q, recipes=chkRecipes } ) count = count + 1 end @@ -138,6 +157,4 @@ function Professions:DisplayList() self.scrollframe.frame:Hide() end - - end \ No newline at end of file diff --git a/modules/search.lua b/modules/search.lua index e879e53..56be3bf 100644 --- a/modules/search.lua +++ b/modules/search.lua @@ -135,11 +135,7 @@ function Search:AddEntry(entry) label:SetCallback( "OnClick", function (widget, sometable, button) - if "LeftButton" == button then - print("left") - elseif "RightButton" == button then - print("right") - end + ChatEdit_InsertLink(link) end) label:SetCallback( "OnEnter", -- 1.7.9.5