changeset 46:a35539b8e151 Prospect Me 2

Updated the Tooltip to display a color coded profit margin. Red < 15%, Yellow <30%, Green >30%. Also added support for previous globalized constants
author Vynn <mischivin@gmail.com>
date Wed, 16 Nov 2016 00:47:56 -0500
parents b267cddd6496
children 4c684bba5777
files ProspectMe_Tooltip.lua
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ProspectMe_Tooltip.lua	Wed Nov 16 00:45:01 2016 -0500
+++ b/ProspectMe_Tooltip.lua	Wed Nov 16 00:47:56 2016 -0500
@@ -1,6 +1,3 @@
-local ORE = select(7,GetItemInfo(123918)) -- Get Ore Subclass from a known quantity (leystone ore)
-local HERB = select(7,GetItemInfo(128304)) -- Get Herb Subclass from a known quantity (yseralline seed)
-
 local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", }
 
 local function Initialize()
@@ -81,9 +78,9 @@
 				--NumofEachQuality, Percent of Each Quality
 				self:AddLine(" ")
 				self:AddLine("Prospect Me",0.5,1,0.5)
-				if spellid == 225902 or spellid == 225904 or subclass == ORE then
+				if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then
 					self:AddLine("Times Prospected: " .. ProspectMe.Results[item].TimesProspected)
-				elseif spellid == 210116 or subclass == HERB then
+				elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then
 					self:AddLine("Times Milled: " .. ProspectMe.Results[item].TimesProspected)
 				else
 					self:AddLine("Times Processed: " .. ProspectMe.Results[item].TimesProspected)
@@ -98,20 +95,25 @@
 					self:AddDoubleLine("Cost to Mass Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
 				elseif spellid == 210116 then
 					self:AddDoubleLine("Cost to Mass Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
-				elseif subclass == ORE then
+				elseif subclass == ProspectMe.Vars.ORE then
 					self:AddDoubleLine("Cost to Prospect: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
-				elseif subclass == HERB then
+				elseif subclass == ProspectMe.Vars.HERB then
 					self:AddDoubleLine("Cost to Mill: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
 				else
 					self:AddDoubleLine("Cost to Process: " .. ProspectMe.FormatPrice(ctp), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn))
 				end
-				if lifetimeReturn-(ctp) > 0 then
-					self:AddLine("Estimated Profit: " ..ProspectMe.FormatPrice(lifetimeReturn-(ctp)))
-					self:AddLine(" ")
+				self:AddLine(" ")
+				local margin = (lifetimeReturn/ctp*100)-100
+				if margin > 30 then
+					self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin:  |cff00ff00" .. string.format("[%.1f%%]", margin))
+				elseif margin > 15 then
+					self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin:  |cffffff00" .. string.format("[%.1f%%]", margin))
+				elseif margin > 0 then
+					self:AddLine("Estimated Profit: " .. ProspectMe.FormatPrice(lifetimeReturn-(ctp)) .. "\nMargin:  |cffff0000" .. string.format("[%.1f%%]", margin))
 				else
 					self:AddLine("No profit to be made",1,0,0)
-					self:AddLine(" ")
 				end
+				self:AddLine(" ")
 				local t
 				if IsAltKeyDown() == ProspectMe.Config.PerSession then
 					t = ProspectMe.Results