# HG changeset patch # User Vynn # Date 1479417888 18000 # Node ID 9dae86337a411d61f5654605624a8616f2a52ff9 # Parent dc1504b4c03c63effe510da47d3869e457df5d6f# Parent a2fc078e4d70d08772d80c8a9887f96864ed13a1 Merge Prospect Me v2 Branch to default diff -r dc1504b4c03c -r 9dae86337a41 .hgtags --- a/.hgtags Thu Oct 27 12:51:54 2016 -0400 +++ b/.hgtags Thu Nov 17 16:24:48 2016 -0500 @@ -8,3 +8,4 @@ ddf9b42996da077cf9767035bddd973cb1a14172 v1.7.0.3 a74019b9f87b3034a5498693468c0314e6599a07 v1.7.1.0 4f555aee85e40bcf245e49917e360f2da995172b v1.7.1.1 +b8686c36477fb2931cfdf798a800731bf19e73be v2.7.1.0-Beta diff -r dc1504b4c03c -r 9dae86337a41 ProspectMe.lua --- a/ProspectMe.lua Thu Oct 27 12:51:54 2016 -0400 +++ b/ProspectMe.lua Thu Nov 17 16:24:48 2016 -0500 @@ -1,213 +1,218 @@ -local PROSPECT_ID = 31252 -local MILLING_ID = 51005 -local MASS_PROSPECT_FELSLATE_ID = 225902 -local MASS_PROSPECT_LEYSTONE_ID = 225902 -local MASS_MILLING_YSERALLINE_ID = 210116 -local PROSPECT = GetSpellInfo(PROSPECT_ID):lower() -local MILLING = GetSpellInfo(MILLING_ID):lower() -local MASS_PROSPECT_FELSLATE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower() -local MASS_PROSPECT_LEYSTONE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower() -local MASS_MILLING_YSERALLINE = GetSpellInfo(MASS_PROSPECT_FELSLATE_ID):lower() -local containerID, containerLink = nil, nil -local getContents = false -local bulkMultiplier = 1 --This will be used for mass prospecting/milling in Legion +--[[ +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) -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) +]] + +--[[ +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_MILLING_YSERALLINE_SPELLID = 210116 +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_MILLING_YSERALLINE = GetSpellInfo(MASS_MILLING_YSERALLINE_SPELLID) + +local VALIDSPELLS = { + [PROSPECT] = true, + [MILLING] = true, + [MASS_PROSPECT_LEYSTONE] = true, + [MASS_PROSPECT_FELSLATE] = true, + [MASS_MILLING_YSERALLINE] = 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, + } + 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 (event, ...) + local unit, spell = ... + if unit == "player" then + if spell == PROSPECT or spell == MILLING then + MassMultiplier = 1 + ParseResults = true + elseif spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_MILLING_YSERALLINE 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_MILLING_YSERALLINE then + ContainerID = 128304 + end + else + ParseResults = false + end + 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 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 + + 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 -function PM_GemCleanup() - local cleanupIDs = { "129099", "130200", "130201", "130202", "130203", "130204" } - if not PM_ItemTable["129100"] then - CreateTableEntry("129100") + +local function EventHandler(self, event, ...) + if event == "VARIABLES_LOADED" then + Initialize() end - for i, r in pairs(PM_ResultsTable) do - for k, v in pairs(cleanupIDs) do - if PM_ResultsTable[i][v] then - if not PM_ResultsTable[i]["129100"] then - PM_ResultsTable[i]["129100"] = 0 - end - PM_ResultsTable[i]["129100"] = PM_ResultsTable[i]["129100"] + PM_ResultsTable[i][v] - PM_ResultsTable[i][v] = nil - end + if event == "UNIT_SPELLCAST_SUCCEEDED" then + local unit, spell = ... + if unit == "player" and VALIDSPELLS[spell] then + ProspectMe.BeginCapture(event, ...) end end - for k, v in pairs(cleanupIDs) do - if PM_ItemTable[v] then - PM_ItemTable[v] = nil + 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 function PM_Init() - if not PM_ResultsTable then - PM_ResultsTable = {} - PM_ItemTable = {} - end - PM_SessionTable = {} - PM_GemCleanup() --Run cleanup on excess Gem Chips created in v1.7.0.2 and earlier -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+)") - if itemID == "129099" or itemID == "130200" or itemID == "130201" or itemID == "130202" or itemID == "130203" or itemID == "130204" then --consolidate Colored Gem Chips into their resulting item - itemID = "129100" - end - 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 + bulkMultiplier - PM_SessionTable[containerID].timesProspected = PM_SessionTable[containerID].timesProspected + bulkMultiplier -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 = ... - spell = spell:lower() - if unitID == "player" and (spell == PROSPECT or spell == MILLING or spell == MASS_PROSPECT_FELSLATE or spell == MASS_PROSPECT_LEYSTONE or spell == MASS_MILLING_YSERALLINE)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") +local frame = CreateFrame("FRAME", "ProspectMe") frame:RegisterEvent("VARIABLES_LOADED") -frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") +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) - -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(...):lower() - if spellName == PROSPECT or spellName == MILLING or spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then - getContents = true - if spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then - bulkMultiplier = 4 - else - bulkMultiplier = 1 - end - end -end) - -hooksecurefunc("CastSpellByID", function(spellID) - if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then - getContents = true - if spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then - bulkMultiplier = 4 - else - bulkMultiplier = 1 - end - end -end) - -hooksecurefunc("UseAction", function(actionID) - local spellID = select(2, GetActionInfo(actionID)) - if spellID == PROSPECT_ID or spellID == MILLING_ID or spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then - getContents = true - if spellID == MASS_PROSPECT_FELSTATE_ID or spellID == MASS_PROSPECT_LEYSTONE_ID or spellID == MASS_MILLING_YSERALLINE_ID then - bulkMultiplier = 4 - else - bulkMultiplier = 1 - end - end -end) - -hooksecurefunc("CastSpellByName", function(spellName, onSelf) - spellName = spellName:lower() - if spellName == PROSPECT or spellName == MILLING or spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then - getContents = true - if spellName == MASS_PROSPECT_FELSLATE or spellName == MASS_PROSPECT_LEYSTONE or spellName == MASS_MILLING_YSERALLINE then - bulkMultiplier = 4 - else - bulkMultiplier = 1 - end - end -end) \ No newline at end of file +frame:SetScript("OnEvent", EventHandler) \ No newline at end of file diff -r dc1504b4c03c -r 9dae86337a41 ProspectMe.toc --- a/ProspectMe.toc Thu Oct 27 12:51:54 2016 -0400 +++ b/ProspectMe.toc Thu Nov 17 16:24:48 2016 -0500 @@ -2,8 +2,8 @@ ## Title: Prospect Me ## Notes: An addon for tracking the results of prospecting. ## Author: Vynn of Khadgar (US) -## Version: 1.7.1.1 -## SavedVariables: PM_ResultsTable, PM_ItemTable, PM_Config +## Version: 2.7.1.0 +## SavedVariables: ProspectMe, PM_ResultsTable ## X-Category: ## X-Website: ## X-Email: @@ -13,4 +13,5 @@ ProspectMe_Value.lua ProspectMe_Tooltip.lua ProspectMe_Config.lua +ProspectMe_Migrate.lua diff -r dc1504b4c03c -r 9dae86337a41 ProspectMe_Aurora.lua --- a/ProspectMe_Aurora.lua Thu Oct 27 12:51:54 2016 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ ---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 dc1504b4c03c -r 9dae86337a41 ProspectMe_Config.lua --- a/ProspectMe_Config.lua Thu Oct 27 12:51:54 2016 -0400 +++ b/ProspectMe_Config.lua Thu Nov 17 16:24:48 2016 -0500 @@ -1,10 +1,5 @@ -if not PM_Config then - PM_Config = {} -end - 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" ) @@ -16,22 +11,12 @@ 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) @@ -46,62 +31,21 @@ 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() - if PM_ResultsTable then - for i, v in pairs(PM_ResultsTable) do - ClearEntry(i) - end - wipe(PM_ResultsTable) - end - if PM_SessionTable then - wipe(PM_SessionTable) + if ProspectMe.Results then + ProspectMe.Results = {} end 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 + 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.PerSession = ProspectMeSessionToggle:GetChecked() + ProspectMe.Config.ShowPercent = ProspectMePercentToggle:GetChecked() + ProspectMe.Config.ShowNumber = ProspectMeNumberToggle:GetChecked() end local function PM_ConfigInit() @@ -125,65 +69,51 @@ ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) - ProspectMeSessionToggle:SetChecked(PM_Config.session) + ProspectMeSessionToggle:SetChecked(ProspectMe.Config.PerSession) ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) - ProspectMePercentToggle:SetChecked(PM_Config.percent) + ProspectMePercentToggle:SetChecked(ProspectMe.Config.ShowPercent) ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) - ProspectMeNumberToggle:SetChecked(PM_Config.number) + ProspectMeNumberToggle:SetChecked(ProspectMe.Config.ShowNumber) 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:SetPoint( "TOPLEFT", 32, -118 ) ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) - ProspectMeEpicToggle:SetChecked(PM_Config.qualities[4]) + ProspectMeEpicToggle:SetChecked(ProspectMe.Config.ShowQualities.Epic) ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP - ProspectMeRareToggle:SetPoint( "TOPLEFT", 60, -166 ) + ProspectMeRareToggle:SetPoint( "TOPLEFT", 32, -142 ) ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) - ProspectMeRareToggle:SetChecked(PM_Config.qualities[3]) + ProspectMeRareToggle:SetChecked(ProspectMe.Config.ShowQualities.Rare) ProspectMeRareToggleText:SetText(PM_RARETOGGLE) ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP - ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 60, -190 ) + ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 32, -166 ) ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) - ProspectMeUncommonToggle:SetChecked(PM_Config.qualities[2]) + ProspectMeUncommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Uncommon) ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP - ProspectMeCommonToggle:SetPoint( "TOPLEFT", 60, -214 ) + ProspectMeCommonToggle:SetPoint( "TOPLEFT", 32, -190 ) ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) - ProspectMeCommonToggle:SetChecked(PM_Config.qualities[1]) + ProspectMeCommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Common) ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP - ProspectMePoorToggle:SetPoint( "TOPLEFT", 60, -238 ) + ProspectMePoorToggle:SetPoint( "TOPLEFT", 32, -214 ) ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) - ProspectMePoorToggle:SetChecked(PM_Config.qualities[0]) + ProspectMePoorToggle:SetChecked(ProspectMe.Config.ShowQualities.Poor) 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) @@ -197,11 +127,8 @@ end -function ProspectMeEventHandler(event, arg1) - if (PM_Config.savedVariables) then - PM_ConfigInit() - else - SetDefaults() +local function EventHandler(event, arg1) + if (ProspectMe.Config) then PM_ConfigInit() end SpewMessage("loaded") @@ -245,4 +172,4 @@ end ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") -ProspectMeFrame:SetScript("OnEvent", ProspectMeEventHandler) \ No newline at end of file +ProspectMeFrame:SetScript("OnEvent", EventHandler) \ No newline at end of file diff -r dc1504b4c03c -r 9dae86337a41 ProspectMe_Migrate.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ProspectMe_Migrate.lua Thu Nov 17 16:24:48 2016 -0500 @@ -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) \ No newline at end of file diff -r dc1504b4c03c -r 9dae86337a41 ProspectMe_Tooltip.lua --- a/ProspectMe_Tooltip.lua Thu Oct 27 12:51:54 2016 -0400 +++ b/ProspectMe_Tooltip.lua Thu Nov 17 16:24:48 2016 -0500 @@ -1,53 +1,50 @@ ---PM_HERBSUBCLASS = select(6, GetAuctionItemSubClasses(6)) ---PM_ORESUBCLASS = select(4, GetAuctionItemSubClasses(6)) +local Quality = { [0] = "Junk", [1]= "Common", [2] = "Uncommon", [3] = "Rare", [4] = "Epic", } ---Hardcoded until I find a better solution now that GetAuctionItemSubClass() has changed -PM_HERBSUBCLASS = "Herb" -PM_ORESUBCLASS = "Metal & Stone" +local function Initialize() + ProspectMe.FormatPrice = function (value) -function PM_FormatPrice(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) + end - 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) + 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 @@ -57,65 +54,115 @@ 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 - local lifetimeReturn = PM_GetReturn(item) + 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(" ") - 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))) - + local color + if ProspectMe.Results[item].TimesProspected < 100 then + color = "|cffff0000" + elseif ProspectMe.Results[item].TimesProspected < 200 then + color = "|cffffff00" + else + color = "|cff00ff00" end - if lifetimeReturn-(5 * PM_ItemTable[item].price) > 0 then - self:AddLine("Estimated Profit: " .. PM_FormatPrice(lifetimeReturn-(5 * PM_ItemTable[item].price))) - self:AddLine(" ") + + -- 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 - self:AddLine("No profit to be made",1,0,0) - self:AddLine(" ") + skilltext = "Processed" 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 + self:AddDoubleLine("Prospect Me","Times " .. skilltext .. ": " .. color .. ProspectMe.Results[item].TimesProspected,1,0.82,0,1,1,1) + self:AddLine(" ") + + -- Economics Text Block + 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 < 30 then + color = "|cffffff00" + elseif margin < 15 then + color = "|cffff0000" + 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(" ") + + -- Results Text Block + local t + if IsAltKeyDown() == ProspectMe.Config.PerSession then + t = ProspectMe.Results + self:AddDoubleLine("Lifetime Results","Hold Alt to display",1,0.82,0,0.5,0.5,0.5) + else + t = ProspectMe.Session + self:AddDoubleLine("Session Results","Hold Alt to display",1,0.82,0,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 = "|cffffffffx" .. num + else + n = "" + end + self:AddDoubleLine(p .. select(2, GetItemInfo(result)) .. n, ProspectMe.FormatPrice(ProspectMe.GetItemValue(result))) end end end - self:AddLine(" ") + --self:AddLine(" ") end end cleared = true @@ -124,4 +171,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 dc1504b4c03c -r 9dae86337a41 ProspectMe_Value.lua --- a/ProspectMe_Value.lua Thu Oct 27 12:51:54 2016 -0400 +++ b/ProspectMe_Value.lua Thu Nov 17 16:24:48 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 diff -r dc1504b4c03c -r 9dae86337a41 localization.lua --- a/localization.lua Thu Oct 27 12:51:54 2016 -0400 +++ b/localization.lua Thu Nov 17 16:24:48 2016 -0500 @@ -17,7 +17,6 @@ -- Arguments for slash handling. Example: /prospectme results. PM_CONFIG = "config" -PM_RESULTS = "results" PM_EPIC = "epic" PM_RARE = "rare" PM_UNCOMMON = "uncommon" @@ -29,7 +28,6 @@ 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" @@ -41,7 +39,6 @@ -- 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."