diff ProspectMe_Tooltip.lua @ 58:f9b6c0305908

Added an integrity check to incoming data to make sure the ItemID is a valid ore/herb Updated tooltips to allow hiding of the economics data (in addition to the existing toggles for granular results) Updated tooltips to give better hints when the player hasn't prospected/milled an item before
author Vynn <mischivin@gmail.com>
date Mon, 28 Nov 2016 12:09:11 -0500
parents 60f990099d03
children
line wrap: on
line diff
--- a/ProspectMe_Tooltip.lua	Sun Nov 20 23:15:57 2016 -0500
+++ b/ProspectMe_Tooltip.lua	Mon Nov 28 12:09:11 2016 -0500
@@ -100,68 +100,85 @@
 				self:AddLine(" ")
 				
 				-- Economics Text Block
-				local spelltext
-				if spellid == 225902 or spellid == 225904 then
-					spelltext = "Mass Prospect"
-				elseif spellid == 210116 then
-					spelltext = "Mass Mill"
-				elseif subclass == ProspectMe.Vars.ORE then
-					spelltext = "Prospect"
-				elseif subclass == ProspectMe.Vars.HERB then
-					spelltext = "Mill" 
-				else
-					spelltext = "Process"
+				if ProspectMe.Config.ShowEconomics then
+					local spelltext
+					if spellid == 225902 or spellid == 225904 then
+						spelltext = "Mass Prospect"
+					elseif spellid == 210116 then
+						spelltext = "Mass Mill"
+					elseif subclass == ProspectMe.Vars.ORE then
+						spelltext = "Prospect"
+					elseif subclass == ProspectMe.Vars.HERB then
+						spelltext = "Mill" 
+					else
+						spelltext = "Process"
+					end
+					if spellid then
+						ctp = price * 20
+						lifetimeReturn = lifetimeReturn * 4
+					end
+					local profit = lifetimeReturn - ctp
+					local margin = (lifetimeReturn / ctp * 100) - 100
+					self:AddDoubleLine("Estimated Profit:  " .. ProspectMe.FormatPrice(profit), "Cost to " .. spelltext .. ":  " .. ProspectMe.FormatPrice(ctp),1,1,1,1,1,1)
+					if margin < 15 then
+						color = "|cffff0000"
+					elseif margin < 30 then
+						color = "|cffffff00"
+					else
+						color = "|cff00ff00"
+					end
+					self:AddDoubleLine("Margin:  " .. color .. string.format("[%.1f%%]", margin),  "Average Return:  " .. ProspectMe.FormatPrice(lifetimeReturn),1,1,1,1,1,1)
+					self:AddLine(" ")
 				end
-				if spellid then
-					ctp = price * 20
-					lifetimeReturn = lifetimeReturn * 4
-				end
-				local profit = lifetimeReturn - ctp
-				local margin = (lifetimeReturn / ctp * 100) - 100
-				self:AddDoubleLine("Estimated Profit:  " .. ProspectMe.FormatPrice(profit), "Cost to " .. spelltext .. ":  " .. ProspectMe.FormatPrice(ctp),1,1,1,1,1,1)
-				if margin < 15 then
-					color = "|cffff0000"
-				elseif margin < 30 then
-					color = "|cffffff00"
-				else
-					color = "|cff00ff00"
-				end
-				self:AddDoubleLine("Margin:  " .. color .. string.format("[%.1f%%]", margin),  "Average Return:  " .. ProspectMe.FormatPrice(lifetimeReturn),1,1,1,1,1,1)
-				self:AddLine(" ")
 				
 				-- Results Text Block
-				local t
-				if IsAltKeyDown() == ProspectMe.Config.PerSession then
-					t = ProspectMe.Results
-					self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
-				else
-					t = ProspectMe.Session
-					self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
-				end
-				if t[item] then
-					for q = 7, 0, -1 do
-						for result, num in pairs(t[item]) do 
-							if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
-								local p, n = "", ""
-								if ProspectMe.Config.ShowPercent then
-									p = num/t[item].TimesProspected*100
-									if p < 10 then
-										p = string.format("|cffffffff[%.1f%%] ", p)
+				local quals = ProspectMe.Config.ShowQualities
+				if quals.Junk or quals.Common or quals.Uncommon or quals.Rare or quals.Epic then
+					local hint = true
+					local tab
+					if IsAltKeyDown() == ProspectMe.Config.PerSession then
+						tab = ProspectMe.Results
+						self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
+					else
+						tab = ProspectMe.Session
+						self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5)
+					end
+					if tab[item] then
+						for q = 7, 0, -1 do
+							for result, num in pairs(tab[item]) do 
+								if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then
+									hint = false
+									local p, n = "", ""
+									if ProspectMe.Config.ShowPercent then
+										p = num/tab[item].TimesProspected*100
+										if p < 10 then
+											p = string.format("|cffffffff[%.1f%%] ", p)
+										else
+											p = string.format("|cffffffff[%.0f%%] ", p)
+										end
 									else
-										p = string.format("|cffffffff[%.0f%%] ", p)
+										p = ""
 									end
-								else
-									p = ""
+									if ProspectMe.Config.ShowNumber then
+										n = "|cffffffffx" .. num
+									else
+										n = ""
+									end
+									self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
 								end
-								if ProspectMe.Config.ShowNumber then
-									n = "|cffffffffx" .. num
-								else
-									n = ""
-								end
-								self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result)))
 							end
 						end
 					end
+					if hint then
+						if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then
+							self:AddLine("|cffffffffTry Prospecting some ore to see your results!")
+						elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then
+							self:AddLine("|cffffffffTry Milling some plants to see your results!")
+						else
+							self:Addline("|cffffffffTry processing some material to see your results!")
+						end
+					end
+
 					--self:AddLine(" ")
 				end
 			end