Mercurial > wow > prospect-me
comparison Modules/ProspectMe_Tooltip.lua @ 60:155fa49865f2 v2.7.1.2-Alpha
Changed directory structure around to clean it up a bit.
| author | Vynn <mischivin@gmail.com> |
|---|---|
| date | Mon, 28 Nov 2016 12:28:35 -0500 |
| parents | ProspectMe_Tooltip.lua@f9b6c0305908 |
| children | 58d886030d65 |
comparison
equal
deleted
inserted
replaced
| 59:ef591210a1e4 | 60:155fa49865f2 |
|---|---|
| 1 local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", } | |
| 2 | |
| 3 local function Initialize() | |
| 4 ProspectMe.FormatPrice = function (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 ProspectMe.GetReturn = function (containerID) | |
| 37 local averageReturn = 0 | |
| 38 if ProspectMe.Results[containerID].TimesProspected > 0 then | |
| 39 for itemID, num in pairs(ProspectMe.Results[containerID]) do | |
| 40 if itemID ~= "TimesProspected" then | |
| 41 averageReturn = averageReturn + ProspectMe.GetItemValue(itemID) * num | |
| 42 end | |
| 43 end | |
| 44 averageReturn = averageReturn/ProspectMe.Results[containerID].TimesProspected | |
| 45 end | |
| 46 return tonumber(string.format("%.0f", averageReturn)) | |
| 47 end | |
| 48 end | |
| 49 | |
| 50 local cleared = true | |
| 51 local function OnTooltipCleared(self) | |
| 52 cleared = true | |
| 53 end | |
| 54 | |
| 55 local function OnTooltipSetItem(self) | |
| 56 if cleared then | |
| 57 local tooltipLink = select(2, self:GetItem()) | |
| 58 local spellid = select(3, self:GetSpell()) | |
| 59 local item = nil | |
| 60 if spellid == 225902 then | |
| 61 item = 123918 | |
| 62 elseif spellid == 225904 then | |
| 63 item = 123919 | |
| 64 elseif spellid == 210116 then | |
| 65 item = 128304 | |
| 66 elseif tooltipLink then | |
| 67 item = tonumber(tooltipLink:match("Hitem:(%d+)")) | |
| 68 spellid = nil | |
| 69 else | |
| 70 item = nil | |
| 71 spellid = nil | |
| 72 end | |
| 73 if item then | |
| 74 if ProspectMe.Results[item] then | |
| 75 local price = ProspectMe.GetItemValue(item) | |
| 76 local lifetimeReturn = ProspectMe.GetReturn(item) | |
| 77 local subclass = select(7,GetItemInfo(item)) | |
| 78 local ctp = price * 5 | |
| 79 --NumofEachQuality, Percent of Each Quality | |
| 80 self:AddLine(" ") | |
| 81 local color | |
| 82 if ProspectMe.Results[item].TimesProspected < 100 then | |
| 83 color = "|cffff0000" | |
| 84 elseif ProspectMe.Results[item].TimesProspected < 200 then | |
| 85 color = "|cffffff00" | |
| 86 else | |
| 87 color = "|cff00ff00" | |
| 88 end | |
| 89 | |
| 90 -- SKill Text Block "" | |
| 91 local skilltext | |
| 92 if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then | |
| 93 skilltext = "Prospected" | |
| 94 elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then | |
| 95 skilltext = "Milled" | |
| 96 else | |
| 97 skilltext = "Processed" | |
| 98 end | |
| 99 self:AddDoubleLine("Prospect Me","Times " .. skilltext .. ": " .. color .. ProspectMe.Results[item].TimesProspected,1,0.82,0,1,1,1) | |
| 100 self:AddLine(" ") | |
| 101 | |
| 102 -- Economics Text Block | |
| 103 if ProspectMe.Config.ShowEconomics then | |
| 104 local spelltext | |
| 105 if spellid == 225902 or spellid == 225904 then | |
| 106 spelltext = "Mass Prospect" | |
| 107 elseif spellid == 210116 then | |
| 108 spelltext = "Mass Mill" | |
| 109 elseif subclass == ProspectMe.Vars.ORE then | |
| 110 spelltext = "Prospect" | |
| 111 elseif subclass == ProspectMe.Vars.HERB then | |
| 112 spelltext = "Mill" | |
| 113 else | |
| 114 spelltext = "Process" | |
| 115 end | |
| 116 if spellid then | |
| 117 ctp = price * 20 | |
| 118 lifetimeReturn = lifetimeReturn * 4 | |
| 119 end | |
| 120 local profit = lifetimeReturn - ctp | |
| 121 local margin = (lifetimeReturn / ctp * 100) - 100 | |
| 122 self:AddDoubleLine("Estimated Profit: " .. ProspectMe.FormatPrice(profit), "Cost to " .. spelltext .. ": " .. ProspectMe.FormatPrice(ctp),1,1,1,1,1,1) | |
| 123 if margin < 15 then | |
| 124 color = "|cffff0000" | |
| 125 elseif margin < 30 then | |
| 126 color = "|cffffff00" | |
| 127 else | |
| 128 color = "|cff00ff00" | |
| 129 end | |
| 130 self:AddDoubleLine("Margin: " .. color .. string.format("[%.1f%%]", margin), "Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn),1,1,1,1,1,1) | |
| 131 self:AddLine(" ") | |
| 132 end | |
| 133 | |
| 134 -- Results Text Block | |
| 135 local quals = ProspectMe.Config.ShowQualities | |
| 136 if quals.Junk or quals.Common or quals.Uncommon or quals.Rare or quals.Epic then | |
| 137 local hint = true | |
| 138 local tab | |
| 139 if IsAltKeyDown() == ProspectMe.Config.PerSession then | |
| 140 tab = ProspectMe.Results | |
| 141 self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5) | |
| 142 else | |
| 143 tab = ProspectMe.Session | |
| 144 self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5) | |
| 145 end | |
| 146 if tab[item] then | |
| 147 for q = 7, 0, -1 do | |
| 148 for result, num in pairs(tab[item]) do | |
| 149 if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then | |
| 150 hint = false | |
| 151 local p, n = "", "" | |
| 152 if ProspectMe.Config.ShowPercent then | |
| 153 p = num/tab[item].TimesProspected*100 | |
| 154 if p < 10 then | |
| 155 p = string.format("|cffffffff[%.1f%%] ", p) | |
| 156 else | |
| 157 p = string.format("|cffffffff[%.0f%%] ", p) | |
| 158 end | |
| 159 else | |
| 160 p = "" | |
| 161 end | |
| 162 if ProspectMe.Config.ShowNumber then | |
| 163 n = "|cffffffffx" .. num | |
| 164 else | |
| 165 n = "" | |
| 166 end | |
| 167 self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result))) | |
| 168 end | |
| 169 end | |
| 170 end | |
| 171 end | |
| 172 if hint then | |
| 173 if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then | |
| 174 self:AddLine("|cffffffffTry Prospecting some ore to see your results!") | |
| 175 elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then | |
| 176 self:AddLine("|cffffffffTry Milling some plants to see your results!") | |
| 177 else | |
| 178 self:Addline("|cffffffffTry processing some material to see your results!") | |
| 179 end | |
| 180 end | |
| 181 | |
| 182 --self:AddLine(" ") | |
| 183 end | |
| 184 end | |
| 185 cleared = true | |
| 186 end | |
| 187 end | |
| 188 end | |
| 189 | |
| 190 GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) | |
| 191 GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) | |
| 192 ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) | |
| 193 ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) | |
| 194 | |
| 195 local frame = CreateFrame("FRAME", "ProspectMe_Value") | |
| 196 frame:RegisterEvent("VARIABLES_LOADED") | |
| 197 --frame:SetScript("OnEvent", EventHandler) | |
| 198 frame:SetScript("OnEvent", Initialize) |
