# HG changeset patch # User Vynn # Date 1478798774 18000 # Node ID 5cbaaee1e7dbc039caed5a43a2740b4fd9cd1068 # Parent 705d0595006a7aff8134d5803ebde808ec6b4630 Updated Tooltips to support V2 diff -r 705d0595006a -r 5cbaaee1e7db ProspectMe_Tooltip.lua --- a/ProspectMe_Tooltip.lua Thu Nov 10 12:25:50 2016 -0500 +++ b/ProspectMe_Tooltip.lua Thu Nov 10 12:26:14 2016 -0500 @@ -1,53 +1,53 @@ --PM_HERBSUBCLASS = select(6, GetAuctionItemSubClasses(6)) --PM_ORESUBCLASS = select(4, GetAuctionItemSubClasses(6)) ---Hardcoded until I find a better solution now that GetAuctionItemSubClass() has changed -PM_HERBSUBCLASS = "Herb" -PM_ORESUBCLASS = "Metal & Stone" +local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", } -function PM_FormatPrice(value) +local function Initialize() + ProspectMe.FormatPrice = function (value) - local GSC_GOLD="ffffd100" - local GSC_SILVER="ffe6e6e6" - local GSC_COPPER="ffc8602c" + local GSC_GOLD="ffffd100" + local GSC_SILVER="ffe6e6e6" + local GSC_COPPER="ffc8602c" - local g, s, c - local digits = 0 - local gsc + local g, s, c + local digits = 0 + local gsc - g = math.floor(value/10000) - s = math.fmod(math.floor(value/100),100) - c = math.fmod(value,100) + g = math.floor(value/10000) + s = math.fmod(math.floor(value/100),100) + c = math.fmod(value,100) - digits = math.floor(math.log10(value)+1) + digits = math.floor(math.log10(value)+1) - if ( digits < 3 ) then - gsc = string.format(" |c%s%2d|r", GSC_COPPER, c) - elseif ( digits < 5 ) then - gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c) - elseif ( digits < 7 ) then - gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s) - elseif ( digits < 9 ) then - gsc = string.format("|c%s%5d|r", GSC_GOLD, g) - else - gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000) + if ( digits < 3 ) then + gsc = string.format(" |c%s%2d|r", GSC_COPPER, c) + elseif ( digits < 5 ) then + gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_SILVER, s, GSC_COPPER, c) + elseif ( digits < 7 ) then + gsc = string.format("|c%s%2d|r |c%s%02d|r", GSC_GOLD, g, GSC_SILVER, s) + elseif ( digits < 9 ) then + gsc = string.format("|c%s%5d|r", GSC_GOLD, g) + else + gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000) + end + + return gsc end - return gsc -end - -function PM_GetReturn(containerID) - local averageReturn = 0 - if PM_ResultsTable[containerID].timesProspected > 0 then - for itemID, num in pairs(PM_ResultsTable[containerID]) do - if itemID ~= "timesProspected" then - averageReturn = averageReturn + PM_ItemTable[itemID].price * num + ProspectMe.GetReturn = function (containerID) + local averageReturn = 0 + if ProspectMe.Results[containerID].TimesProspected > 0 then + for itemID, num in pairs(ProspectMe.Results[containerID]) do + if itemID ~= "TimesProspected" then + averageReturn = averageReturn + ProspectMe.GetItemValue(itemID) * num + end end + averageReturn = averageReturn/ProspectMe.Results[containerID].TimesProspected end - averageReturn = averageReturn/PM_ResultsTable[containerID].timesProspected + return tonumber(string.format("%.0f", averageReturn)) end - return tonumber(string.format("%.0f", averageReturn)) end local cleared = true @@ -59,59 +59,51 @@ if cleared then local name, tooltipLink = self:GetItem() if tooltipLink then - local item = tooltipLink:match("Hitem:(%d+)") - if PM_ResultsTable[item] then - local lifetimeReturn = PM_GetReturn(item) + local item = tonumber(tooltipLink:match("Hitem:(%d+)")) + if ProspectMe.Results[item] then + local price = ProspectMe.GetItemValue(item) + local lifetimeReturn = ProspectMe.GetReturn(item) --NumofEachQuality, Percent of Each Quality self:AddLine(" ") self:AddLine("Prospect Me",0.5,1,0.5) - -- Subclass Detection is broken in Legion - may need to hard-code this or find another way of getting locatlizes subclass names. - if PM_ItemTable[item].subclass == PM_ORESUBCLASS then - self:AddLine("Times Prospected: " .. PM_ResultsTable[item].timesProspected) - self:AddDoubleLine("Cost to Prospect: " .. PM_FormatPrice(5 * PM_ItemTable[item].price), " Average Return: " .. PM_FormatPrice(PM_GetReturn(item))) - elseif PM_ItemTable[item].subclass == PM_HERBSUBCLASS then - self:AddLine("Times Milled: " .. PM_ResultsTable[item].timesProspected) - self:AddDoubleLine("Cost to Mill: " .. PM_FormatPrice(5 * PM_ItemTable[item].price), " Average Return: " .. PM_FormatPrice(PM_GetReturn(item))) - - end - if lifetimeReturn-(5 * PM_ItemTable[item].price) > 0 then - self:AddLine("Estimated Profit: " .. PM_FormatPrice(lifetimeReturn-(5 * PM_ItemTable[item].price))) + self:AddLine("Times Processed: " .. ProspectMe.Results[item].TimesProspected) + self:AddDoubleLine("Cost to Process: " .. ProspectMe.FormatPrice(5 * price), " Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn)) + if lifetimeReturn-(5 * price) > 0 then + self:AddLine("Estimated Profit: " ..ProspectMe.FormatPrice(lifetimeReturn-(5 * price))) self:AddLine(" ") else self:AddLine("No profit to be made",1,0,0) self:AddLine(" ") end - if PM_Config.results then - local t - if IsAltKeyDown() == PM_Config.session then - t = PM_ResultsTable - self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5) - else - t = PM_SessionTable - self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,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 PM_ItemTable[result].quality == q and PM_Config.qualities[q] then - local p, n = "", "" - if PM_Config.percent then - p = num/t[item].timesProspected*100 - if p < 10 then - p = string.format("[%.1f%%]", p) - else - p = string.format("[%.0f%%]", p) - end + local t + if IsAltKeyDown() == ProspectMe.Config.PerSession then + t = ProspectMe.Results + self:AddDoubleLine("Lifetime Results","Hold/Release Alt to toggle",0.5,0.5,1,0.5,0.5,0.5) + else + t = ProspectMe.Session + self:AddDoubleLine("Session Results","Hold/Release Alt to toggle",0.5,0.5,1,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("[%.1f%%]", p) else - p = "" + p = string.format("[%.0f%%]", p) end - if PM_Config.number then - n = "[" .. num .. "]" - else - n = "" - end - self:AddDoubleLine(p .. PM_ItemTable[result].link .. n, PM_FormatPrice(PM_ItemTable[result].price)) + else + p = "" end + if ProspectMe.Config.ShowNumber then + n = "[" .. num .. "]" + else + n = "" + end + self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result))) end end end @@ -124,4 +116,11 @@ end GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) -GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) \ No newline at end of file +GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) +ItemRefTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) +ItemRefTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) + +local frame = CreateFrame("FRAME", "ProspectMe_Value") +frame:RegisterEvent("VARIABLES_LOADED") +--frame:SetScript("OnEvent", EventHandler) +frame:SetScript("OnEvent", Initialize) \ No newline at end of file diff -r 705d0595006a -r 5cbaaee1e7db ProspectMe_Value.lua --- a/ProspectMe_Value.lua Thu Nov 10 12:25:50 2016 -0500 +++ b/ProspectMe_Value.lua Thu Nov 10 12:26:14 2016 -0500 @@ -1,30 +1,26 @@ -function PM_GetItemValue(itemID) - local v = nil - if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc... - v = GetAuctionBuyout(itemID) +local function Initialize () + ProspectMe.GetItemValue = function (itemID) + local v = nil + + if GetAuctionBuyout then -- if an installed addon supports Tekkub's GetAuctionBuyout API: Auctionator, AuctionLite, etc... + v = GetAuctionBuyout(itemID) + elseif AucAdvanced then -- Auctioneer Support + v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link) + end + + if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand + v = select(11, GetItemInfo(itemID)) + end + + if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!) + v = 0.0 + end + + return tonumber(v) end - - if v == nil then - if AucAdvanced then -- Auctioneer Support - v = AucAdvanced.API.GetMarketValue(PM_ItemTable[itemID].link) - else -- if nothing else, use the vendor price! - v = PM_ItemTable[itemID].vendorPrice - end - end - - if v == nil then -- provides a failsafe if Auctioneer, etc is set to Load on Demand - v = PM_ItemTable[itemID].vendorPrice - end - - if v == nil then -- provides a final failsafe - if we can't find anything, set it to 0 (TY peterwemm!) - v = 0.0 - end - - return tonumber(v) end -function PM_UpdateValues() - for k,v in pairs(PM_ItemTable) do - PM_ItemTable[k].price = PM_GetItemValue(k) - end -end \ No newline at end of file +local frame = CreateFrame("FRAME", "ProspectMe_Value") +frame:RegisterEvent("VARIABLES_LOADED") +--frame:SetScript("OnEvent", EventHandler) +frame:SetScript("OnEvent", Initialize) \ No newline at end of file