comparison ProspectMe_Tooltip.lua @ 0:69b46322ff1b v1.2.1-Alpha

Updated Prospect me for initial client v6.0.3 support. Warning, there may be bugs!
author Vynn
date Mon, 15 Dec 2014 22:51:49 -0500
parents
children e6eec48ecf14
comparison
equal deleted inserted replaced
-1:000000000000 0:69b46322ff1b
1 PM_HERBSUBCLASS = select(6, GetAuctionItemSubClasses(6))
2 PM_ORESUBCLASS = select(4, GetAuctionItemSubClasses(6))
3
4 function PM_FormatPrice(value)
5
6 local GSC_GOLD="ffffd100"
7 local GSC_SILVER="ffe6e6e6"
8 local GSC_COPPER="ffc8602c"
9
10 local g, s, c
11 local digits = 0
12 local gsc
13
14 g = math.floor(value/10000)
15 s = math.fmod(math.floor(value/100),100)
16 c = math.fmod(value,100)
17
18
19 digits = math.floor(math.log10(value)+1)
20
21 if ( digits < 3 ) then
22 gsc = string.format(" |c%s%2d|r", GSC_COPPER, c)
23 elseif ( digits < 5 ) then
24 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c)
25 elseif ( digits < 7 ) then
26 gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s)
27 elseif ( digits < 9 ) then
28 gsc = string.format("|c%s%5d|r", GSC_GOLD, g)
29 else
30 gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000)
31 end
32
33 return gsc
34 end
35
36 function PM_GetReturn(containerID)
37 local averageReturn = 0
38 if PM_ResultsTable[containerID].timesProspected > 0 then
39 for itemID, num in pairs(PM_ResultsTable[containerID]) do
40 if itemID ~= "timesProspected" then
41 averageReturn = averageReturn + PM_ItemTable[itemID].price * num
42 end
43 end
44 averageReturn = averageReturn/PM_ResultsTable[containerID].timesProspected
45 end
46 return tonumber(string.format("%.0f", averageReturn))
47 end
48
49 local cleared = true
50 local function OnTooltipCleared(self)
51 cleared = true
52 end
53
54 local function OnTooltipSetItem(self)
55 if cleared then
56 local name, tooltipLink = self:GetItem()
57 if tooltipLink then
58 local item = tooltipLink:match("Hitem:(%d+)")
59 if PM_ResultsTable[item] then
60 --NumofEachQuality, Percent of Each Quality
61 self:AddLine(" ")
62 self:AddLine("Prospect Me",0.5,1,0.5)
63 if PM_ItemTable[item].subclass == PM_ORESUBCLASS then
64 self:AddLine("Times Prospected: " .. PM_ResultsTable[item].timesProspected)
65 self:AddDoubleLine("Cost to Prospect: " .. PM_FormatPrice(5 * PM_ItemTable[item].price), " Average Return: " .. PM_FormatPrice(PM_GetReturn(item)))
66 elseif PM_ItemTable[item].subclass == PM_HERBSUBCLASS then
67 self:AddLine("Times Milled: " .. PM_ResultsTable[item].timesProspected)
68 self:AddDoubleLine("Cost to Mill: " .. PM_FormatPrice(5 * PM_ItemTable[item].price), " Average Return: " .. PM_FormatPrice(PM_GetReturn(item)))
69
70 end
71 if PM_GetReturn(item)-(5 * PM_ItemTable[item].price) > 0 then
72 self:AddLine("Estimated Profit: " .. PM_FormatPrice(PM_GetReturn(item)-(5 * PM_ItemTable[item].price)))
73 self:AddLine(" ")
74 else
75 self:AddLine("No profit to be made",1,0,0)
76 self:AddLine(" ")
77 end
78 if PM_Config.results then
79 local t
80 if IsAltKeyDown() == PM_Config.session then
81 t = PM_ResultsTable
82 self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
83 else
84 t = PM_SessionTable
85 self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5)
86 end
87 if t[item] then
88 for q = 7, 0, -1 do
89 for result, num in pairs(t[item]) do
90 if result ~= "timesProspected" and PM_ItemTable[result].quality == q and PM_Config.qualities[q] then
91 local p, n = "", ""
92 if PM_Config.percent then
93 p = num/t[item].timesProspected*100
94 if p < 10 then
95 p = string.format("[%.1f%%]", p)
96 else
97 p = string.format("[%.0f%%]", p)
98 end
99 else
100 p = ""
101 end
102 if PM_Config.number then
103 n = "[" .. num .. "]"
104 else
105 n = ""
106 end
107 self:AddDoubleLine(p .. PM_ItemTable[result].link .. n, PM_FormatPrice(PM_ItemTable[result].price))
108 end
109 end
110 end
111 end
112 self:AddLine(" ")
113 end
114 end
115 cleared = true
116 end
117 end
118 end
119
120 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
121 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem)