# HG changeset patch # User Vynn # Date 1418701909 18000 # Node ID 69b46322ff1b4cba461ee218a6f0124c2dd99182 Updated Prospect me for initial client v6.0.3 support. Warning, there may be bugs! diff -r 000000000000 -r 69b46322ff1b ProspectMe.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,157 @@ +local PROSPECT_ID = 31252 +local MILLING_ID = 51005 +local PROSPECT = GetSpellInfo(PROSPECT_ID) +local MILLING = GetSpellInfo(MILLING_ID) +local containerID, containerLink = nil, nil +local getContents = false + +local function PM_Init() + if not PM_ResultsTable then + PM_ResultsTable = {} + PM_ItemTable = {} + end + PM_SessionTable = {} +end + +local function CreateTableEntry(id) + local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(id) + PM_ItemTable[id] = {} + PM_ItemTable[id].name = name + PM_ItemTable[id].link = link + PM_ItemTable[id].quality = quality + PM_ItemTable[id].iLevel = iLevel + PM_ItemTable[id].reqLevel = reqLevel + PM_ItemTable[id].class = class + PM_ItemTable[id].subclass = subclass + PM_ItemTable[id].maxStack = maxStack + PM_ItemTable[id].equipSlot = equipSlot + PM_ItemTable[id].texture = texture + PM_ItemTable[id].vendorPrice = vendorPrice + PM_ItemTable[id].price = PM_GetItemValue(id) +end + +--debugging function to print the databases results +function PM_PrintResults() + for container, k in pairs(PM_ResultsTable) do + print(PM_ItemTable[container].link, PM_ResultsTable[container].timesProspected) + for i, num in pairs(k) do + if i ~= "timesProspected" then + print(PM_ItemTable[i].link, num) + end + end + end +end + +local function GetResults() + --Create tables for the Container if it doesn't exist yet + if not PM_ResultsTable[containerID] then + PM_ResultsTable[containerID] = {timesProspected = 0} + CreateTableEntry(containerID) + end + + --Creates a session table entry, this will be cleared on log out/UI reload + if not PM_SessionTable[containerID] then + PM_SessionTable[containerID] = {timesProspected = 0} + end + + for i = 1, GetNumLootItems() do + local itemID = GetLootSlotLink(i):match("Hitem:(%d+)") + local quantity = select(3, GetLootSlotInfo(i)) + if not PM_ItemTable[itemID] then + CreateTableEntry(itemID) + end + if PM_ResultsTable[containerID][itemID] then + PM_ResultsTable[containerID][itemID] = PM_ResultsTable[containerID][itemID] + quantity + else + PM_ResultsTable[containerID][itemID] = quantity + end + if PM_SessionTable[containerID][itemID] then + PM_SessionTable[containerID][itemID] = PM_SessionTable[containerID][itemID] + quantity + else + PM_SessionTable[containerID][itemID] = quantity + end + end + + PM_ResultsTable[containerID].timesProspected = PM_ResultsTable[containerID].timesProspected + 1 + PM_SessionTable[containerID].timesProspected = PM_SessionTable[containerID].timesProspected + 1 +end + +local function EventHandler(self, event, ...) + if event == "VARIABLES_LOADED" then + PM_Init() + PM_UpdateValues() + end + if event == "UNIT_SPELLCAST_INTERRUPTED" then + local unitID, spell, rank = ... + if unitID == "player" and spell == PROSPECT then + getContents = false + end + end + if event == "LOOT_OPENED" then + if getContents then + GetResults() + end + end + if event == "LOOT_CLOSED" then + getContents = false + end + if event == "AUCTION_ITEM_LIST_UPDATE" then + PM_UpdateValues() + end +end + +local frame = CreateFrame("FRAME", "PM_Frame") +frame:RegisterEvent("VARIABLES_LOADED") +frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") +frame:RegisterEvent("LOOT_OPENED") +frame:RegisterEvent("LOOT_CLOSED") +frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") +frame:SetScript("OnEvent", EventHandler) + +hooksecurefunc("UseContainerItem", function(...) + if getContents then + containerLink = GetContainerItemLink(...) + containerID = containerLink:match("Hitem:(%d+)") + end + +end) + +hooksecurefunc("UseItemByName", function(itemName) + if getContents then + containerLink = select(2, GetItemInfo(itemName)) + containerID = containerLink:match("Hitem:(%d+)") + end +end) + +hooksecurefunc("SpellTargetItem", function(itemName) + if getContents then + containerLink = select(2, GetItemInfo(itemName)) + containerID = containerLink:match("Hitem:(%d+)") + end +end) + +hooksecurefunc("CastSpell", function(...) + local spellName = GetSpellInfo(...) + if spellName:lower() == PROSPECT:lower() or spellName:lower() == MILLING:lower() then + getContents = true + end +end) + +hooksecurefunc("CastSpellByID", function(spellID) + if spellID == PROSPECT_ID or spellID == MILLING_ID then + getContents = true + end +end) + +hooksecurefunc("UseAction", function(actionID) + local spellID = select(2, GetActionInfo(actionID)) + if spellID == PROSPECT_ID or spellID == MILLING_ID then + getContents = true + end +end) + +hooksecurefunc("CastSpellByName", function(spellName, onSelf) + if spellName:lower() == PROSPECT:lower() or spellName:lower() == MILLING:lower() then + getContents = true + end +end) \ No newline at end of file diff -r 000000000000 -r 69b46322ff1b ProspectMe.toc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe.toc Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,16 @@ +## Interface: 60000 +## Title: Prospect Me +## Notes: An addon for tracking the results of prospecting. +## Author: Vynn of Khadgar (US) +## Version: 1.2.1 +## SavedVariables: PM_ResultsTable, PM_ItemTable, PM_Config +## X-Category: +## X-Website: +## X-Email: + +localization.lua +ProspectMe.lua +ProspectMe_Value.lua +ProspectMe_Tooltip.lua +ProspectMe_Config.lua +ProspectMe_Aurora.lua diff -r 000000000000 -r 69b46322ff1b ProspectMe_Aurora.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe_Aurora.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,68 @@ +--To Do +--Create Item Frame +--Layout Item Frame (Icon, name, value, cost to prospect, prospect into) +--Create Scroll Frame/Child +--ability to remove items/results +--Ability to set prices of components. +--Prospect from the frame? + +local DebugID = "52183" +local FWIDTH = 1000 +local FHEIGHT = 1000 +local xOffset = 0 +local yOffset = 0 + + +local function CreateEntry (EntryID) + local FRAMEID = EntryID.."_Frame" + local ICONID = EntryID.."_Icon" + local NAMEID = EntryID.."_Name" + local COSTID = EntryID.."_Cost" + local VALUEID = EntryID.."_Value" + + --if PM_ResultsTable[EntryID] then + + local frame = CreateFrame("Frame", FRAMEID, UIParent) + frame:SetPoint("CENTER", xOffset, yOffset) + frame:SetSize(FWIDTH, FHEIGHT) + + local icon = CreateFrame("Button", ICONID, frame, "SecureActionButtonTemplate") + print(PM_ItemTable[EntryID].texture) + icon:SetPoint("TOP", 0,0) + icon:SetTexture(0,0,1) + + local name = frame:CreateFontString( NAMEID, nil, "GameFontNormal" ) + name:SetPoint("TOP", 0, 32) + name:SetText(PM_ItemTable[EntryID].name) + + local cost = frame:CreateFontString( COSTID, nil, "GameFontNormal" ) + cost:SetPoint("TOP", 16, 32) + cost:SetText(PM_FormatPrice(PM_ItemTable[EntryID].price * 5)) + + local value = frame:CreateFontString( VALUEID, nil, "GameFontNormal" ) + value:SetPoint("TOP", 16, 64) + value:SetText(PM_FormatPrice(PM_GetReturn(EntryID))) + + for i, k in pairs(PM_ResultsTable[EntryID]) do + local off = 128 + if i ~= timesProspected then + local RESULTID = i.."_Result" + local result = CreateFrame("Button", RESULTID, frame, "SecureActionButtonTemplate") + result:SetPoint("TOP",0, off) + result:Settexture(0,1,0) + result:SetText(PM_FormatPrice(PM_ItemTable[i].price)) + off = off + 32 + end + end + frame:Show() + frame:SetToplevel(true) + frame:SetFrameLevel(100) + --end +end + +function PM_Debug() +print("Preparing to Create Entry") +CreateEntry(DebugID) +print("Entry Created!") +end + diff -r 000000000000 -r 69b46322ff1b ProspectMe_Config.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe_Config.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,242 @@ +PM_Config = {} + +local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) +local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") +local ResultsToggle = CreateFrame( "CheckButton", "ProspectMeResultsToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local CommonToggle = CreateFrame( "CheckButton", "ProspectMeCommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local PoorToggle = CreateFrame( "CheckButton", "ProspectMePoorToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local SessionToggle = CreateFrame( "CheckButton", "ProspectMeSessionToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local PercentToggle = CreateFrame( "CheckButton", "ProspectMePercentToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local NumberToggle = CreateFrame( "CheckButton", "ProspectMeNumberToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) +local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" ) +local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" ) + +local function SetDefaults() + PM_Config.results = true + PM_Config.qualities ={[0] = false,[1] = true, [2] = true, [3] = true, [4] = true} + PM_Config.session = false + PM_Config.percent = true + PM_Config.number = true + PM_Config.savedVariables = true +end + +local function SpewMessage(handle, msg) + if handle == "loaded" then + print(PM_LOADMSG) + elseif handle == "help" then + print(PM_HELPMSG) + SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) + SpewMessage(PM_RESULTS, PM_RESULTSTOOLTIP) + SpewMessage(PM_EPIC, PM_EPICTOOLTIP) + SpewMessage(PM_RARE, PM_RARETOOLTIP) + SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP) + SpewMessage(PM_COMMON, PM_COMMONTOOLTIP) + SpewMessage(PM_POOR, PM_POORTOOLTIP) + SpewMessage(PM_SESSION, PM_SESSIONTOOLTIP) + SpewMessage(PM_PERCENT, PM_PERCENTTOOLTIP) + SpewMessage(PM_NUMBER, PM_NUMBERTOOLTIP) + SpewMessage(PM_RESET, PM_RESETTOOLTIP) + else + print("|cFFFFCC00" .. handle .. "|r - " .. msg) + end +end + +local function ClearEntry(id) + if PM_ResultsTable[id] then + wipe(PM_ResultsTable[id]) + end + if PM_SessionTable[id] then + wipe(PM_SessionTable[id]) + end +end + +local function ResetDatabase() + for i, v in pairs(PM_ResultsTable) do + ClearEntry(i) + end + wipe(PM_ResultsTable) + wipe(PM_SessionTable) +end + +local function UpdateConfig() + + PM_Config.results = ProspectMeResultsToggle:GetChecked() + PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() + PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() + PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() + PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() + PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() + PM_Config.session = ProspectMeSessionToggle:GetChecked() + PM_Config.percent = ProspectMePercentToggle:GetChecked() + PM_Config.number = ProspectMeNumberToggle:GetChecked() + + if (PM_Config.results) then + + ProspectMePoorToggle:Enable() + ProspectMeCommonToggle:Enable() + ProspectMeUncommonToggle:Enable() + ProspectMeRareToggle:Enable() + ProspectMeEpicToggle:Enable() + + PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() + PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() + PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() + PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() + PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() + + else + + ProspectMePoorToggle:Disable() + ProspectMeCommonToggle:Disable() + ProspectMeUncommonToggle:Disable() + ProspectMeRareToggle:Disable() + ProspectMeEpicToggle:Disable() + + end +end + +local function PM_ConfigInit() + StaticPopupDialogs["PM_ConfirmReset"] = { + text = PM_RESETWARNING, + button1 = YES, + button2 = NO, + OnAccept = function() + ResetDatabase() + end, + timeout = 30, + whileDead = true, + hideOnEscape = true, + preferredIndex = 3, + } + + ProspectMeFrame.name = "Prospect Me" + + ProspectMeTitle:SetPoint("TOP", 0, -16) + ProspectMeTitle:SetText(GetAddOnMetadata("ProspectMe", "Title") .. " v" .. GetAddOnMetadata("ProspectMe", "Version")) + + ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) + ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) + ProspectMeSessionToggle:SetChecked(PM_Config.session) + ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) + ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP + + ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) + ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) + ProspectMePercentToggle:SetChecked(PM_Config.percent) + ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) + ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP + + ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) + ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) + ProspectMeNumberToggle:SetChecked(PM_Config.number) + ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) + ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP + + ProspectMeResultsToggle:SetPoint( "TOPLEFT", 32, -118 ) + ProspectMeResultsToggle:SetScript("OnClick", UpdateConfig) + ProspectMeResultsToggle:SetChecked(PM_Config.results) + ProspectMeResultsToggleText:SetText(PM_RESULTSTOGGLE) + ProspectMeResultsToggle.tooltipText = PM_RESULTSTOOLTIP + + ProspectMeEpicToggle:SetPoint( "TOPLEFT", 60, -142 ) + ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) + ProspectMeEpicToggle:SetChecked(PM_Config.qualities[4]) + ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) + ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP + + ProspectMeRareToggle:SetPoint( "TOPLEFT", 60, -166 ) + ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) + ProspectMeRareToggle:SetChecked(PM_Config.qualities[3]) + ProspectMeRareToggleText:SetText(PM_RARETOGGLE) + ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP + + ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 60, -190 ) + ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) + ProspectMeUncommonToggle:SetChecked(PM_Config.qualities[2]) + ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) + ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP + + ProspectMeCommonToggle:SetPoint( "TOPLEFT", 60, -214 ) + ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) + ProspectMeCommonToggle:SetChecked(PM_Config.qualities[1]) + ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) + ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP + + ProspectMePoorToggle:SetPoint( "TOPLEFT", 60, -238 ) + ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) + ProspectMePoorToggle:SetChecked(PM_Config.qualities[0]) + ProspectMePoorToggleText:SetText(PM_POORTOGGLE) + ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP + + if (PM_Config.results == false) then + ProspectMePoorToggle:Disable() + ProspectMeCommonToggle:Disable() + ProspectMeUncommonToggle:Disable() + ProspectMeRareToggle:Disable() + ProspectMeEpicToggle:Disable() + end + + ProspectMeResetButton:SetPoint("TOP", 0, -310 ) + ProspectMeResetButton:SetScript("OnClick", function(self) StaticPopup_Show("PM_ConfirmReset") end) + ProspectMeResetButton:SetSize(250, 25) + ProspectMeResetButton:SetText(PM_RESETBUTTON) + + ProspectMeResetText:SetPoint("TOP", 0, -286) + ProspectMeResetText:SetText(PM_RESETTOOLTIP) + + InterfaceOptions_AddCategory(ProspectMeFrame) + +end + +function ProspectMeEventHandler(event, arg1) + if (PM_Config.savedVariables) then + PM_ConfigInit() + else + SetDefaults() + PM_ConfigInit() + end + SpewMessage("loaded") +end + +function SlashCmdList.PROSPECTME(msg, editbox) + if msg == PM_CONFIG then + InterfaceOptionsFrame_OpenToCategory(ProspectMeFrame) + elseif msg == PM_RESULTS then + ProspectMeResultsToggle:SetChecked(not ProspectMeResultsToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_EPIC then + ProspectMeEpicToggle:SetChecked(not ProspectMeEpicToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_RARE then + ProspectMeRareToggle:SetChecked(not ProspectMeRareToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_UNCOMMON then + ProspectMeUncommonToggle:SetChecked(not ProspectMeUncommonToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_COMMON then + ProspectMeCommonToggle:SetChecked(not ProspectMeCommonToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_POOR then + ProspectMePoorToggle:SetChecked(not ProspectMePoorToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_SESSION then + ProspectMeSessionToggle:SetChecked(not ProspectMeSessionToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_PERCENT then + ProspectMePercentToggle:SetChecked(not ProspectMePercentToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_NUMBER then + ProspectMeNumberToggle:SetChecked(not ProspectMeNumberToggle:GetChecked()) + UpdateConfig() + elseif msg == PM_RESET then + StaticPopup_Show("PM_ConfirmReset") + else + SpewMessage("help") + end +end + +ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") +ProspectMeFrame:SetScript("OnEvent", ProspectMeEventHandler) \ No newline at end of file diff -r 000000000000 -r 69b46322ff1b ProspectMe_Tooltip.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe_Tooltip.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,121 @@ +PM_HERBSUBCLASS = select(6, GetAuctionItemSubClasses(6)) +PM_ORESUBCLASS = select(4, GetAuctionItemSubClasses(6)) + +function PM_FormatPrice(value) + + local GSC_GOLD="ffffd100" + local GSC_SILVER="ffe6e6e6" + local GSC_COPPER="ffc8602c" + + 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) + + + 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) + 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 + end + end + averageReturn = averageReturn/PM_ResultsTable[containerID].timesProspected + end + return tonumber(string.format("%.0f", averageReturn)) +end + +local cleared = true +local function OnTooltipCleared(self) + cleared = true +end + +local function OnTooltipSetItem(self) + if cleared then + local name, tooltipLink = self:GetItem() + if tooltipLink then + local item = tooltipLink:match("Hitem:(%d+)") + if PM_ResultsTable[item] then + --NumofEachQuality, Percent of Each Quality + self:AddLine(" ") + self:AddLine("Prospect Me",0.5,1,0.5) + 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 PM_GetReturn(item)-(5 * PM_ItemTable[item].price) > 0 then + self:AddLine("Estimated Profit: " .. PM_FormatPrice(PM_GetReturn(item)-(5 * PM_ItemTable[item].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 + else + 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)) + end + end + end + end + self:AddLine(" ") + end + end + cleared = true + end + end +end + +GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) +GameTooltip:HookScript("OnTooltipSetItem", OnTooltipSetItem) \ No newline at end of file diff -r 000000000000 -r 69b46322ff1b ProspectMe_Value.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe_Value.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +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) + 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 + + 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 diff -r 000000000000 -r 69b46322ff1b localization.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/localization.lua Mon Dec 15 22:51:49 2014 -0500 @@ -0,0 +1,53 @@ +-- slash commands +SLASH_PROSPECTME1, SLASH_PROSPECTME2 = "/prospectme", "/pm" + +-- Load confirmation msg (addon name, version and slash commands are inserted automatically): +--Prospect Me v#.# Loaded - Use /prospectme or /pm for Help! +PM_LOADMSG = "|cFFFFCC00" .. GetAddOnMetadata("ProspectMe", "Title") .. "|r v|cFF00FF00" .. GetAddOnMetadata("ProspectMe", "Version") .. "|r Loaded - Use |cAAFFCC00" .. SLASH_PROSPECTME1 .. "|r or |cAAFFCC00" .. SLASH_PROSPECTME2 .. "|r for Help!" + +-- Help Message (slash commands are inserted automatically): +--Use /prospectme or /pm followed by an argument: +PM_HELPMSG = "Use |cFFFFCC00" .. SLASH_PROSPECTME1 .. "|r or |cFFFFCC00" .. SLASH_PROSPECTME2 .. "|r followed by an argument:" + +--Headers for Options Frame +PM_RESULTSHEADER = "Display Detailed Results" + +PM_RESETBUTTON = "Reset Database" +PM_RESETWARNING = "Resetting Prospect Me will wipe all results from the database! Are you sure you want to do this?" + +-- Arguments for slash handling. Example: /prospectme results. +PM_CONFIG = "config" +PM_RESULTS = "results" +PM_EPIC = "epic" +PM_RARE = "rare" +PM_UNCOMMON = "uncommon" +PM_COMMON = "common" +PM_POOR = "poor" +PM_SESSION = "session" +PM_PERCENT = "percent" +PM_NUMBER = "number" +PM_RESET = "reset" + +-- Options Frame checkbox names +PM_RESULTSTOGGLE = "Show Detailed Results" +PM_EPICTOGGLE = "|c00A335EE[Epic]|r" +PM_RARETOGGLE = "|c000070DD[Rare]|r" +PM_UNCOMMONTOGGLE = "|c001EFF00[Uncommon]|r" +PM_COMMONTOGGLE = "|c00FFFFFF[Common]|r" +PM_POORTOGGLE = "|c009D9D9D[Poor]|r" +PM_SESSIONTOGGLE = "Default to Per-Session Display" +PM_PERCENTTOGGLE = "Show Percentage Results" +PM_NUMBERTOGGLE = "Show Number Results" + +-- Tooltips, displayed with the /prospectme help dialog and when mousing over check boxes in the blizzard interface options frame. +PM_CONFIGTOOLTIP = "Shows the Prospect Me Configuration Frame." +PM_RESULTSTOOLTIP = "Toggles the showing of detailed results in the tooltip." +PM_EPICTOOLTIP = "Toggles the display of Epic quality results." +PM_RARETOOLTIP = "Toggles the display of Rare quality results." +PM_UNCOMMONTOOLTIP = "Toggles the display of Uncommon quality results." +PM_COMMONTOOLTIP = "Toggles the display of Common quality results." +PM_POORTOOLTIP = "Toggles the display of Poor quality results." +PM_SESSIONTOOLTIP = "Toggles the default tooltip display between Lifetime and Session Results. Holding Alt will temporarily display the alternative" +PM_PERCENTTOOLTIP = "Toggles the display of result percentages" +PM_NUMBERTOOLTIP = "Toggles the display of result totals" +PM_RESETTOOLTIP = "Reset the Prospect Me database to an empty state" \ No newline at end of file