diff --git a/CHANGES.txt b/CHANGES.txt new file mode 100644 index 0000000..7304d01 --- /dev/null +++ b/CHANGES.txt @@ -0,0 +1,13 @@ +changeset: 73:b5da2520f443 +tag: v2.7.2.0 +user: Vynn <mischivin@gmail.com> +date: Thu Mar 30 20:08:49 2017 -0400 +summary: Updated Prospect Me for client v7.2 + + +changeset: 72:708946031901 +user: Vynn <mischivin@gmail.com> +date: Sat Feb 18 10:48:31 2017 -0500 +summary: Updated TOC for next intended version + + diff --git a/Modules/ProspectMe_Config.lua b/Modules/ProspectMe_Config.lua new file mode 100644 index 0000000..a0552de --- /dev/null +++ b/Modules/ProspectMe_Config.lua @@ -0,0 +1,184 @@ +local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) +local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") +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 EconToggle = CreateFrame( "CheckButton", "ProspectMeEconToggle", 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 SpewMessage(handle, msg) + if handle == "loaded" then + print(PM_LOADMSG) + elseif handle == "help" then + print(PM_HELPMSG) + SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) + 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_ECON, PM_ECONTOOLTIP) + 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 ResetDatabase() + if ProspectMe.Results then + ProspectMe.Results = {} + end +end + +local function UpdateConfig() + ProspectMe.Config.ShowQualities.Junk = ProspectMePoorToggle:GetChecked() + ProspectMe.Config.ShowQualities.Common = ProspectMeCommonToggle:GetChecked() + ProspectMe.Config.ShowQualities.Uncommon = ProspectMeUncommonToggle:GetChecked() + ProspectMe.Config.ShowQualities.Rare = ProspectMeRareToggle:GetChecked() + ProspectMe.Config.ShowQualities.Epic = ProspectMeEpicToggle:GetChecked() + ProspectMe.Config.ShowEconomics = ProspectMeEconToggle:GetChecked() + ProspectMe.Config.PerSession = ProspectMeSessionToggle:GetChecked() + ProspectMe.Config.ShowPercent = ProspectMePercentToggle:GetChecked() + ProspectMe.Config.ShowNumber = ProspectMeNumberToggle:GetChecked() +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")) + + ProspectMeEconToggle:SetPoint( "TOPLEFT", 32, -46 ) + ProspectMeEconToggle:SetScript("OnClick", UpdateConfig) + ProspectMeEconToggle:SetChecked(ProspectMe.Config.ShowEconomics) + ProspectMeEconToggleText:SetText(PM_ECONTOGGLE) + ProspectMeEconToggle.tooltipText = PM_ECONTOOLTIP + + ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -70 ) + ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) + ProspectMeSessionToggle:SetChecked(ProspectMe.Config.PerSession) + ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) + ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP + + ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -94 ) + ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) + ProspectMePercentToggle:SetChecked(ProspectMe.Config.ShowPercent) + ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) + ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP + + ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -118 ) + ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) + ProspectMeNumberToggle:SetChecked(ProspectMe.Config.ShowNumber) + ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) + ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP + + ProspectMeEpicToggle:SetPoint( "TOPLEFT", 32, -142 ) + ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) + ProspectMeEpicToggle:SetChecked(ProspectMe.Config.ShowQualities.Epic) + ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) + ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP + + ProspectMeRareToggle:SetPoint( "TOPLEFT", 32, -166 ) + ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) + ProspectMeRareToggle:SetChecked(ProspectMe.Config.ShowQualities.Rare) + ProspectMeRareToggleText:SetText(PM_RARETOGGLE) + ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP + + ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 32, -190 ) + ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) + ProspectMeUncommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Uncommon) + ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) + ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP + + ProspectMeCommonToggle:SetPoint( "TOPLEFT", 32, -214 ) + ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) + ProspectMeCommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Common) + ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) + ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP + + ProspectMePoorToggle:SetPoint( "TOPLEFT", 32, -238 ) + ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) + ProspectMePoorToggle:SetChecked(ProspectMe.Config.ShowQualities.Poor) + ProspectMePoorToggleText:SetText(PM_POORTOGGLE) + ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP + + 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 + +local function EventHandler(event, arg1) + if (ProspectMe.Config) then + PM_ConfigInit() + end + SpewMessage("loaded") +end + +function SlashCmdList.PROSPECTME(msg, editbox) + if msg == PM_CONFIG then + InterfaceOptionsFrame_OpenToCategory(ProspectMeFrame) + elseif msg == PM_ECON then + ProspectMeEconToggle:SetChecked(not ProspectMeEconToggle: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", EventHandler) diff --git a/Modules/ProspectMe_Migrate.lua b/Modules/ProspectMe_Migrate.lua new file mode 100644 index 0000000..d3e253b --- /dev/null +++ b/Modules/ProspectMe_Migrate.lua @@ -0,0 +1,41 @@ +local ORE = select(7,GetItemInfo(123918)) +local HERB = select(7,GetItemInfo(128304)) + +local function Initialize () + ProspectMe.Migrate = function () + print("Attempting to migrate ProspectMe database") + if PM_ResultsTable then + print("|cffffff00ProspectMe v1 database found|r") + for Container, Item in pairs(PM_ResultsTable) do + local C = tonumber(Container) + local B = nil + local RT = {} + for Result, Quantity in pairs (Item) do + if Result == "timesProspected" then + B = Quantity + else + RT[tonumber(Result)] = Quantity + end + end + if select(7,GetItemInfo(C)) == ORE or select(7,GetItemInfo(C)) == HERB then + ProspectMe.AddEntry(C, B, RT) + end + end + print("|cff00ff00Database migrated sucessfully!|r") + PM_ResultsTable = nil + PM_ItemTable = nil + PM_Config = nil + else + print("|cffff0000Error, ProspectMe v1 database not found|r") + end + end + + if PM_ResultsTable then + print("ProspectMe v1 database found, to migrate your database to v2 run the command |cff00ff00/script ProspectMe.Migrate()|r \n |cffff0000Warning, this action is irreversable!|r") + end +end + +local frame = CreateFrame("FRAME", "ProspectMe_Value") +frame:RegisterEvent("VARIABLES_LOADED") +--frame:SetScript("OnEvent", EventHandler) +frame:SetScript("OnEvent", Initialize) diff --git a/Modules/ProspectMe_Tables.lua b/Modules/ProspectMe_Tables.lua new file mode 100644 index 0000000..e5a929a --- /dev/null +++ b/Modules/ProspectMe_Tables.lua @@ -0,0 +1,117 @@ +local function Initialize () + + --clear out tables before setting them fresh on load + ProspectMe.Tables = {} + + ProspectMe.Tables.Herbs = { + [765] = 1, -- Silverleaf + [785] = 0, -- Mageroyal + [2447] = 1, -- Peacebloom + [2449] = 1, -- Earthroot + [2450] = 25, -- Briarthorn + [2452] = 25, -- Swiftthistle + [2453] = 25, -- Bruiseweed + [3355] = 75, -- Wild Steelbloom + [3356] = 75, -- Kingsblood + [3357] = 75, -- Liferoot + [3358] = 125, -- Khadgar's Whisker + [3369] = 75, -- Grave Moss + [3818] = 125, -- Fadeleaf + [3819] = 125, -- Dragon's Teeth + [3820] = 25, -- Stranglekelp + [3821] = 125, -- Goldthorn + [4625] = 175, -- Firebloom + [8831] = 175, -- Purple Lotus + [8836] = 175, -- Arthas' Tears + [8838] = 175, -- Sungrass + [8839] = 175, -- Blindweed + [8845] = 175, -- Ghost Mushroom + [8846] = 175, -- Gromsblood + [13463] = 225, -- Dreamfoil + [13464] = 225, -- Golden Sansam + [13465] = 225, -- Mountain Silversage + [13466] = 225, -- Sorrowmoss + [13467] = 200, -- Icecap + [22785] = 275, -- Felweed + [22786] = 275, -- Dreaming Glory + [22787] = 275, -- Ragveil + [22789] = 275, -- Terocone + [22790] = 275, -- Ancient Lichen + [22791] = 275, -- Netherbloom + [22792] = 275, -- Nightmare Vine + [22793] = 275, -- Mana Thistle + [36901] = 325, -- Goldclover + [36903] = 325, -- Adder's Tongue + [36904] = 325, -- Tiger Lily + [36905] = 325, -- Lichbloom + [36906] = 325, -- Icethorn + [36907] = 325, -- Talandra's Rose + [37921] = 325, -- Deadnettle + [39970] = 325, -- Fire Leaf + [52983] = 425, -- Cinderbloom + [52984] = 425, -- Stormvine + [52985] = 450, -- Azshara's Veil + [52986] = 450, -- Heartblossom + [52987] = 475, -- Twilight Jasmine + [52988] = 475, -- Whiptail + [72234] = 500, -- Green Tea Leaf + [72235] = 500, -- Silkweed + [72237] = 500, -- Rain Poppy + [79010] = 500, -- Snow Lily + [79011] = 500, -- Fool's Cap + [89639] = 500, -- Desecrated Herb + [109124] = 0, -- Frostweed + [109125] = 0, -- Fireweed + [109126] = 0, -- Gorgrond Flytrap + [109127] = 0, -- Starflower + [109128] = 0, -- Nagrand Arrowbloom + [109129] = 0, -- Talador Orchid + [109130] = 0, -- Chameleon Lotus + [124101] = 0, -- Aethril + [124102] = 0, -- Dreamleaf + [124103] = 0, -- Foxflower + [124104] = 0, -- Fjarnskaggl + [124105] = 0, -- Starlight Rose + [124106] = 0, -- Felwort + [128304] = 0, -- Yseralline Seed + [151565] = 0, -- Astral Glory + [152505] = 0, -- Riverbud + [152511] = 0, -- Sea Stalk + [152506] = 0, -- Star Moss + [152507] = 0, -- Akunda's Bite + [152508] = 0, -- Winter's Kiss + [152509] = 0, -- Siren's Pollen + [152510] = 0, -- Anchor Weed + } + + ProspectMe.Tables.Ores = { + [2770] = 1, -- Copper Ore + [2771] = 50, -- Tin Ore + [2772] = 125, -- Iron Ore + [3858] = 175, -- Mithril Ore + [10620] = 250, -- Thorium Ore + [23424] = 275, -- Fel Iron Ore + [23425] = 325, -- Adamantite Ore + [36909] = 350, -- Cobalt Ore + [36910] = 450, -- Titanium Ore + [36912] = 400, -- Saronite Ore + [52183] = 500, -- Pyrite Ore + [52185] = 475, -- Elementium Ore + [53038] = 425, -- Obsidium Ore + [72092] = 500, -- Ghost Iron Ore + [72093] = 550, -- Kyparite + [72094] = 600, -- Black Trillium Ore + [72103] = 600, -- White Trillium Ore + [123918] = 0, -- Leystone Ore + [123919] = 0, -- Felslate + [151564] = 0, -- Empyrium + [152512] = 0, -- Monelite + [152579] = 0, -- Storm Silver + [152513] = 0, -- Platinum + } + +end + +local frame = CreateFrame("FRAME", "ProspectMe_Tables") +frame:RegisterEvent("VARIABLES_LOADED") +frame:SetScript("OnEvent", Initialize) diff --git a/Modules/ProspectMe_Tooltip.lua b/Modules/ProspectMe_Tooltip.lua new file mode 100644 index 0000000..b5a2125 --- /dev/null +++ b/Modules/ProspectMe_Tooltip.lua @@ -0,0 +1,209 @@ +local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", } + +local function Initialize() + ProspectMe.FormatPrice = function (value) + + local GSC_GOLD="ffffd100" + local GSC_SILVER="ffe6e6e6" + local GSC_COPPER="ffc8602c" + + local g, s, c + local digits = 0 + local gsc + local neg = false + + --if value is negative, record it and get the absolute value so log10 works + if value < 0 then + neg = true + value = math.abs(value) + end + + + 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 + --if the original number was negative, add the symbol back in + if neg then + gsc = "|cffff0000(|r" .. gsc .. "|cffff0000)|r" + end + return gsc + end + + 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 + return tonumber(string.format("%.0f", averageReturn)) + end +end + +local cleared = true +local function OnTooltipCleared(self) + cleared = true +end + +local function OnTooltipSetItem(self) + if cleared then + local tooltipLink = select(2, self:GetItem()) + local spellid = select(3, self:GetSpell()) + local item = nil + if spellid == 225902 then + item = 123918 + elseif spellid == 225904 then + item = 123919 + elseif spellid == 210116 then + item = 128304 + elseif tooltipLink then + item = tonumber(tooltipLink:match("Hitem:(%d+)")) + spellid = nil + else + item = nil + spellid = nil + end + if item then + if ProspectMe.Results[item] then + local price = ProspectMe.GetItemValue(item) + local lifetimeReturn = ProspectMe.GetReturn(item) + local subclass = select(7,GetItemInfo(item)) + local ctp = price * 5 + --NumofEachQuality, Percent of Each Quality + self:AddLine(" ") + local color + if ProspectMe.Results[item].TimesProspected < 100 then + color = "|cffff0000" + elseif ProspectMe.Results[item].TimesProspected < 200 then + color = "|cffffff00" + else + color = "|cff00ff00" + end + + -- SKill Text Block "" + local skilltext + if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then + skilltext = "Prospected" + elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then + skilltext = "Milled" + else + skilltext = "Processed" + end + self:AddDoubleLine("Prospect Me","Times " .. skilltext .. ": " .. color .. ProspectMe.Results[item].TimesProspected,1,0.82,0,1,1,1) + self:AddLine(" ") + + -- Economics Text Block + if ProspectMe.Config.ShowEconomics then + local spelltext + if spellid == 225902 or spellid == 225904 then + spelltext = "Mass Prospect" + elseif spellid == 210116 then + spelltext = "Mass Mill" + elseif subclass == ProspectMe.Vars.ORE then + spelltext = "Prospect" + elseif subclass == ProspectMe.Vars.HERB then + spelltext = "Mill" + else + spelltext = "Process" + end + if spellid then + ctp = price * 20 + lifetimeReturn = lifetimeReturn * 4 + end + local profit = lifetimeReturn - ctp + local margin = (lifetimeReturn / ctp * 100) - 100 + self:AddDoubleLine("Estimated Profit: " .. ProspectMe.FormatPrice(profit), "Cost to " .. spelltext .. ": " .. ProspectMe.FormatPrice(ctp),1,1,1,1,1,1) + if margin < 15 then + color = "|cffff0000" + elseif margin < 30 then + color = "|cffffff00" + else + color = "|cff00ff00" + end + self:AddDoubleLine("Margin: " .. color .. string.format("[%.1f%%]", margin), "Average Return: " .. ProspectMe.FormatPrice(lifetimeReturn),1,1,1,1,1,1) + self:AddLine(" ") + end + + -- Results Text Block + local quals = ProspectMe.Config.ShowQualities + if quals.Junk or quals.Common or quals.Uncommon or quals.Rare or quals.Epic then + local hint = true + local tab + if IsAltKeyDown() == ProspectMe.Config.PerSession then + tab = ProspectMe.Results + self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5) + else + tab = ProspectMe.Session + self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5) + end + if tab[item] then + for q = 7, 0, -1 do + for result, num in pairs(tab[item]) do + if result ~= "TimesProspected" and select(3, GetItemInfo(result)) == q and ProspectMe.Config.ShowQualities[Quality[q]] then + hint = false + local p, n = "", "" + if ProspectMe.Config.ShowPercent then + p = num/tab[item].TimesProspected*100 + if p < 10 then + p = string.format("|cffffffff[%.1f%%] ", p) + else + p = string.format("|cffffffff[%.0f%%] ", p) + end + else + p = "" + end + if ProspectMe.Config.ShowNumber then + n = "|cffffffffx" .. num + else + n = "" + end + self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result))) + end + end + end + end + if hint then + if spellid == 225902 or spellid == 225904 or subclass == ProspectMe.Vars.ORE then + self:AddLine("|cffffffffTry Prospecting some ore to see your results!") + elseif spellid == 210116 or subclass == ProspectMe.Vars.HERB then + self:AddLine("|cffffffffTry Milling some plants to see your results!") + else + self:AddLine("|cffffffffTry processing some material to see your results!") + end + end + + --self:AddLine(" ") + end + end + cleared = true + end + end +end + +GameTooltip:HookScript("OnTooltipCleared", OnTooltipCleared) +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) diff --git a/Modules/ProspectMe_Value.lua b/Modules/ProspectMe_Value.lua new file mode 100644 index 0000000..8175aee --- /dev/null +++ b/Modules/ProspectMe_Value.lua @@ -0,0 +1,28 @@ +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 TSMAPI then -- TSM's Support + v = TSMAPI:GetItemValue(itemID, "DBMinBuyout") + elseif AucAdvanced then -- Auctioneer Support + v = AucAdvanced.API.GetMarketValue(select(2, GetItemInfo(itemID))) + 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 +end + +local frame = CreateFrame("FRAME", "ProspectMe_Value") +frame:RegisterEvent("VARIABLES_LOADED") +--frame:SetScript("OnEvent", EventHandler) +frame:SetScript("OnEvent", Initialize) diff --git a/ProspectMe.lua b/ProspectMe.lua new file mode 100644 index 0000000..2f7be57 --- /dev/null +++ b/ProspectMe.lua @@ -0,0 +1,336 @@ +--[[ +Event Flow --> UNIT_SPELLCAST_SUCCEDED --> Prospecting --> Set Multiplier --> LOOT_OPENED --> parse --> ITEM_LOCKED (Get Item ID) --> LOOT_CLOSED (Add Results) + --> Mass Prospecting (Get Item ID from spell) --> Set Multiplier --> CHAT_MSG_LOOT --> parse --> TRADE_SKILL_UPDATE (Add Results) + +]] + +--[[ +Declarations of constants. +]] + +local PROSPECT_SPELLID = 31252 +local MILLING_SPELLID = 51005 +local MASS_PROSPECT_FELSLATE_SPELLID = 225904 +local MASS_PROSPECT_LEYSTONE_SPELLID = 225902 +local MASS_PROSPECT_EMPYRIUM_SPELLID = 247761 + +local MASS_PROSPECT_MONELITE_SPELLID = 256611 +local MASS_PROSPECT_STORMSILVER_SPELLID = 256613 +local MASS_PROSPECT_PLATINUM_SPELLID = 256622 + +local MASS_MILLING_YSERALLINE_SPELLID = 210116 +local MASS_MILLING_DREAMLEAF_SPELLID = 209659 +local MASS_MILLING_FOXFLOWER_SPELLID = 209660 +local MASS_MILLING_FOXFLOWER_SPELLID = 209660 +local MASS_MILLING_FJARNSKAGGL_SPELLID = 209661 +local MASS_MILLING_FELWORT_SPELLID = 209664 +local MASS_MILLING_AETHRIL_SPELLID = 209658 +local MASS_MILLING_ASTRALGLORY_SPELLID = 247861 +local MASS_MILLING_STARLIGHTROSE_SPELLID = 209662 + +local MASS_MILLING_RiVERBUD_SPELLID = 256217 +local MASS_MILLING_SEASTALK_SPELLID = 256223 +local MASS_MILLING_STARMOSS_SPELLID = 256218 +local MASS_MILLING_AKUNDASBITE_SPELLID = 256219 +local MASS_MILLING_WINTERSKISS_SPELLID = 256220 +local MASS_MILLING_SIRENSPOLLEN_SPELLID = 256221 +local MASS_MILLING_ANCHORWEED_SPELLID = 256308 + + +local PROSPECT = GetSpellInfo(PROSPECT_SPELLID) +local MILLING = GetSpellInfo(MILLING_SPELLID) +local MASS_PROSPECT_FELSLATE = GetSpellInfo(MASS_PROSPECT_FELSLATE_SPELLID) +local MASS_PROSPECT_LEYSTONE = GetSpellInfo(MASS_PROSPECT_LEYSTONE_SPELLID) +local MASS_PROSPECT_EMPYRIUM = GetSpellInfo(MASS_PROSPECT_EMPYRIUM_SPELLID) + +local MASS_PROSPECT_MONELITE = GetSpellInfo(MASS_PROSPECT_MONELITE_SPELLID) +local MASS_PROSPECT_STORMSILVER = GetSpellInfo(MASS_PROSPECT_STORMSILVER_SPELLID) +local MASS_PROSPECT_PLATINUM = GetSpellInfo(MASS_PROSPECT_PLATINUM_SPELLID) + +local MASS_MILLING_YSERALLINE = GetSpellInfo(MASS_MILLING_YSERALLINE_SPELLID) +local MASS_MILLING_DREAMLEAF = GetSpellInfo(MASS_MILLING_DREAMLEAF_SPELLID) +local MASS_MILLING_FOXFLOWER = GetSpellInfo(MASS_MILLING_FOXFLOWER_SPELLID) +local MASS_MILLING_FJARNSKAGGL = GetSpellInfo(MASS_MILLING_FJARNSKAGGL_SPELLID) +local MASS_MILLING_FELWORT = GetSpellInfo(MASS_MILLING_FELWORT_SPELLID) +local MASS_MILLING_AETHRIL = GetSpellInfo(MASS_MILLING_AETHRIL_SPELLID) +local MASS_MILLING_ASTRALGLORY = GetSpellInfo(MASS_MILLING_ASTRALGLORY_SPELLID) +local MASS_MILLING_STARLIGHTROSE = GetSpellInfo(MASS_MILLING_STARLIGHTROSE_SPELLID) + +local MASS_MILLING_RiVERBUD = GetSpellInfo(MASS_MILLING_RiVERBUD_SPELLID) +local MASS_MILLING_SEASTALK = GetSpellInfo(MASS_MILLING_SEASTALK_SPELLID) +local MASS_MILLING_STARMOSS = GetSpellInfo(MASS_MILLING_STARMOSS_SPELLID) +local MASS_MILLING_AKUNDASBITE = GetSpellInfo(MASS_MILLING_AKUNDASBITE_SPELLID) +local MASS_MILLING_WINTERSKISS = GetSpellInfo(MASS_MILLING_WINTERSKISS_SPELLID) +local MASS_MILLING_SIRENSPOLLEN = GetSpellInfo(MASS_MILLING_SIRENSPOLLEN_SPELLID) +local MASS_MILLING_ANCHORWEED = GetSpellInfo(MASS_MILLING_ANCHORWEED_SPELLID) + +local VALIDSPELLS = { + [PROSPECT] = true, + [MILLING] = true, + [MASS_PROSPECT_LEYSTONE] = true, + [MASS_PROSPECT_FELSLATE] = true, + [MASS_PROSPECT_EMPYRIUM] = true, + [MASS_MILLING_YSERALLINE] = true, + [MASS_MILLING_DREAMLEAF] = true, + [MASS_MILLING_FOXFLOWER] = true, + [MASS_MILLING_FJARNSKAGGL] = true, + [MASS_MILLING_FELWORT] = true, + [MASS_MILLING_AETHRIL] = true, + [MASS_MILLING_ASTRALGLORY] = true, + [MASS_MILLING_STARLIGHTROSE] = true, + [MASS_MILLING_RiVERBUD] = true, + [MASS_MILLING_SEASTALK] = true, + [MASS_MILLING_STARMOSS] = true, + [MASS_MILLING_AKUNDASBITE] = true, + [MASS_MILLING_WINTERSKISS] = true, + [MASS_MILLING_SIRENSPOLLEN] = true, + [MASS_MILLING_ANCHORWEED] = true, +} + +--[[ +Local Variables +]] +local ContainerID = nil +local Table = {} +local ParseResults = false +local MassMultiplier = 1 +local Results = {} + +--[[ +Initialize - Dets default config variables if they don't exist, ensures all our functions exist and are included in the table in their current form. +]] +local function Initialize() + --[[ + Sets Default Variables + ]] + if not ProspectMe.Config then + ProspectMe.Config = { + ShowQualities = { + Junk = false, + Common = false, + Uncommon = true, + Rare = true, + Epic = true, + }, + PerSession = false, + ShowPercent = true, + ShowNumber = true, + ShowEconomics = true, + } + end + if not ProspectMe.Results then + ProspectMe.Results = {} + end + ProspectMe.Session = {} + + --[[ + Sets Global Constants + ]] + if not ProspectMe.Vars then + ProspectMe.Vars = {} + end + ProspectMe.Vars.ORE = select(7,GetItemInfo(123918)) -- Get Ore Subclass from a known quantity (leystone ore) + ProspectMe.Vars.HERB = select(7,GetItemInfo(128304)) -- Get Herb Subclass from a known quantity (yseralline seed) + + + ProspectMe.Debug = function (...) + for k, v in pairs(...) do + print("key: " .. k " | value: " .. v) + end + end + + --[[ + Begins the capture process, sets variables where we have them. Prospecting and Milling (non MASS) require an extra step to get the ContainerID + ]] + ProspectMe.BeginCapture = function (spell) + if spell == PROSPECT or spell == MILLING then + MassMultiplier = 1 + ParseResults = true + elseif spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_PROSPECT_EMPYRIUM or spell == MASS_PROSPECT_MONELITE or spell == MASS_PROSPECT_STORMSILVER or spell == MASS_PROSPECT_PLATINUM or spell == MASS_MILLING_YSERALLINE or spell == MASS_MILLING_DREAMLEAF or spell == MASS_MILLING_FOXFLOWER or spell == MASS_MILLING_FJARNSKAGGL or spell == MASS_MILLING_FELWORT or spell == MASS_MILLING_AETHRIL or spell == MASS_MILLING_ASTRALGLORY or spell == MASS_MILLING_STARLIGHTROSE or spell == MASS_MILLING_RiVERBUD or spell == MASS_MILLING_SEASTALK or spell == MASS_MILLING_STARMOSS or spell == MASS_MILLING_AKUNDASBITE or spell == MASS_MILLING_WINTERSKISS or spell == MASS_MILLING_SIRENSPOLLEN or spell == MASS_MILLING_ANCHORWEED then + MassMultiplier = 4 + ParseResults = true + C_Timer.After(0.5, function () if ParseResults then ProspectMe.EndCapture() end end ) --Fallback if you're using the tradeskill buttons to craft with the window closed. + if spell == MASS_PROSPECT_FELSLATE then + ContainerID = 123919 + end + if spell == MASS_PROSPECT_LEYSTONE then + ContainerID = 123918 + end + if spell == MASS_PROSPECT_EMPYRIUM then + ContainerID = 151564 + end + if spell == MASS_PROSPECT_MONELITE then + ContainerID = 152512 + end + if spell == MASS_PROSPECT_STORMSILVER then + ContainerID = 152579 + end + if spell == MASS_PROSPECT_PLATINUM then + ContainerID = 152513 + end + if spell == MASS_MILLING_YSERALLINE then + ContainerID = 128304 + end + if spell == MASS_MILLING_DREAMLEAF then + ContainerID = 124102 + end + if spell == MASS_MILLING_FOXFLOWER then + ContainerID = 124103 + end + if spell == MASS_MILLING_FJARNSKAGGL then + ContainerID = 124104 + end + if spell == MASS_MILLING_FELWORT then + ContainerID = 124106 + end + if spell == MASS_MILLING_AETHRIL then + ContainerID = 124101 + end + if spell == MASS_MILLING_ASTRALGLORY then + ContainerID = 151565 + end + if spell == MASS_MILLING_STARLIGHTROSE then + ContainerID = 124105 + end + if spell == MASS_MILLING_RiVERBUD then + ContainerID = 152505 + end + if spell == MASS_MILLING_SEASTALK then + ContainerID = 152511 + end + if spell == MASS_MILLING_STARMOSS then + ContainerID = 152506 + end + if spell == MASS_MILLING_AKUNDASBITE then + ContainerID = 152507 + end + if spell == MASS_MILLING_WINTERSKISS then + ContainerID = 152508 + end + if spell == MASS_MILLING_SIRENSPOLLEN then + ContainerID = 152509 + end + if spell == MASS_MILLING_ANCHORWEED then + ContainerID = 152510 + end + else + ParseResults = false + end + + Results = {} + end + + --[[ + Ends the capture process and resets variables so they're ready for use the next time. + ]] + ProspectMe.EndCapture = function (event, ...) + if ParseResults then + ProspectMe.AddEntry(ContainerID, MassMultiplier, Results) + end + ParseResults = false + MassMultiplier = 1 + ContainerID = nil + end + + --[[ + Creates an table entry, if it does not exist, and adds results to the entry. + Expects the Item ID and pairs of arguments in table with key being the result's ItemID and value being the quantity returned + ]] + ProspectMe.AddEntry = function (ItemID, BatchSize, ResultsTable) + if ProspectMe.Tables.Ores[ItemID] or ProspectMe.Tables.Herbs[ItemID] then + if not ProspectMe.Results[ItemID] then + ProspectMe.Results[ItemID] = { TimesProspected = 0 } + end + if not ProspectMe.Session[ItemID] then + ProspectMe.Session[ItemID] = { TimesProspected = 0 } + end + for k, v in pairs(ResultsTable) do + if not ProspectMe.Results[ItemID][k] then + ProspectMe.Results[ItemID][k] = v + else + ProspectMe.Results[ItemID][k] = ProspectMe.Results[ItemID][k] + v + end + if not ProspectMe.Session[ItemID][k] then + ProspectMe.Session[ItemID][k] = v + else + ProspectMe.Session[ItemID][k] = ProspectMe.Session[ItemID][k] + v + end + end + ProspectMe.Results[ItemID].TimesProspected = ProspectMe.Results[ItemID].TimesProspected + BatchSize + ProspectMe.Session[ItemID].TimesProspected = ProspectMe.Session[ItemID].TimesProspected + BatchSize + else + print("Attempted to create invalid entry for ID: ", ItemID) + end + end + + --[[ + Parses the results of the spellcast or loot containerand returns a table of those results in key/value pairs of item/quantity. + Expects an event and a set of arguments if the event has them. + ]] + ProspectMe.GetResults = function (event, ...) + if event == "CHAT_MSG_LOOT" then + local ItemID = tonumber((...):match("Hitem:(%d+)")) + if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then + ItemID = 129100 + end + local Quantity = tonumber((...):match("|h|rx(%d+)")) + if Quantity == nil then + Quantity = 1 + end + Results[ItemID] = Quantity + end + if event == "LOOT_OPENED" then + for i = 1, GetNumLootItems() do + local ItemID = tonumber(GetLootSlotLink(i):match("Hitem:(%d+)")) + if ItemID == 129099 or ItemID == 130200 or ItemID == 130201 or ItemID == 130202 or ItemID == 130203 or ItemID == 130204 then + ItemID = 129100 + end + local Quantity = select(3, GetLootSlotInfo(i)) + Results[ItemID] = Quantity + end + end + end +end + + +local function EventHandler(self, event, ...) + if event == "VARIABLES_LOADED" then + Initialize() + end + + if event == "UNIT_SPELLCAST_SUCCEEDED" then + local unit, _ , spellID = ... + local spellInfo = GetSpellInfo(spellID); + if unit == "player" and VALIDSPELLS[spellInfo] then + ProspectMe.BeginCapture(spellInfo) + end + end + if event == "CHAT_MSG_LOOT" or "LOOT_OPENED" then + if ParseResults then + ProspectMe.GetResults(event, ...) + end + ProspectMeDebug = Results + end + if event == "ITEM_LOCKED" then + if ParseResults then + local bag, slot = ... + ContainerID = select(10, GetContainerItemInfo(bag, slot)) + end + end + if event == "TRADE_SKILL_LIST_UPDATE" or event == "LOOT_CLOSED" then + if ParseResults then + ProspectMe.EndCapture() + end + end +end + +local frame = CreateFrame("FRAME", "ProspectMe") +frame:RegisterEvent("VARIABLES_LOADED") +frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED") +frame:RegisterEvent("CHAT_MSG_LOOT") +frame:RegisterEvent("LOOT_OPENED") +frame:RegisterEvent("ITEM_LOCKED") +frame:RegisterEvent("LOOT_CLOSED") +frame:RegisterEvent("TRADE_SKILL_LIST_UPDATE") +frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") +frame:SetScript("OnEvent", EventHandler) diff --git a/ProspectMe.toc b/ProspectMe.toc new file mode 100644 index 0000000..1f47afe --- /dev/null +++ b/ProspectMe.toc @@ -0,0 +1,19 @@ +## Interface: 80000 +## Title: Prospect Me +## Notes: An addon for tracking the results of prospecting. +## Author: Vynn of Khadgar (US) +## Version: 2.7.2.0 +## SavedVariables: ProspectMe, PM_ResultsTable +## X-Category: +## X-Website: +## X-Email: + +localization.lua + +Modules\ProspectMe_Value.lua +Modules\ProspectMe_Tooltip.lua +Modules\ProspectMe_Config.lua +Modules\ProspectMe_Migrate.lua +Modules\ProspectMe_Tables.lua + +ProspectMe.lua diff --git a/localization.lua b/localization.lua new file mode 100644 index 0000000..a442fa8 --- /dev/null +++ b/localization.lua @@ -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_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" +PM_ECON = "econ" + +-- Options Frame checkbox names +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 Numeric Results" +PM_ECONTOGGLE = "Show Economic Summary" + +-- 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_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" +PM_ECONTOOLTIP = "Toggles the display of detailed market stats including, cost, return, net profit, and margin"