Mercurial > wow > recipeprofit
diff core.lua @ 36:1e73cfb6f363
Updated for 4.0.3 and GatherMate 2
| author | "Aaron Bregger <killermonkey99@gmail.com>" |
|---|---|
| date | Tue, 04 Jan 2011 17:49:34 -0600 |
| parents | 3976960cda3d |
| children | d97f61fad5b6 |
line wrap: on
line diff
--- a/core.lua Tue Jan 04 12:12:59 2011 -0600 +++ b/core.lua Tue Jan 04 17:49:34 2011 -0600 @@ -24,7 +24,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Foobar. If not, see <http://www.gnu.org/licenses/>. + along with this program. If not, see <http://www.gnu.org/licenses/>. Note: This program's source code is specifically designed to work with @@ -37,8 +37,10 @@ --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--)) -local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0") -local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate") +local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0") + +local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate2") + local tabletest = {} local db = {} local safeRecipes = {} @@ -90,88 +92,40 @@ end end -local defaultProfile = { - ["show"] = { - ["RecipeProfit"] = "always", - ["Herb Gathering"] = "never", - ["Extract Gas"] = "never", - ["Fishing"] = "never", - ["Mining"] = "never", - ["Treasure"] = "never", - }, - ["trackShow"] = "active", -} - local options = { type = "group", name = "RecipeProfit", -- addon name to import from, don't localize handler = {}, disabled = false, args = { - opt = { - order = 1, - name = "Select Database", - desc = "Show a different database", - type = "group", - guiInline = true, - args = { - faction = { - order = 0, - name = "Faction", - desc = "Show a different database.", - type = "select", - values = { - ["Alliance"] = "Alliance", - ["Horde"] = "Horde", - ["default"] = "Default", - }, - arg = "faction", - }, - - safeBuy = { - order = 1, - name = "Safe Recipe Buy", - desc = "Warn when buying a recipe not on the RecipeProfit list.", - type = "select", - values = { - --["on"] = "On", - ["off"]= "Off", - }, - arg = "safebuy", - }, - }, - get = function(k) return db.profile[k.arg]; end, - set = function(k, v) db.profile[k.arg] = v; RecipeProfit:DoMerge(); end, - }, - loadData = { - order = 8, - name = "Import Data", - desc = "Load RecipeProfit and import the data to your database.", - type = "execute", - func = function() - RecipeProfit:DoMerge() - end - }, - loadProfile = { - order = 9, - name = "Load RecipeProfit Profile", - desc = "Loads the RecipeProfit Profile into Gathermate for easy recipe tracking.", - type = "execute", - func = function() - GatherMate.db.profiles["RecipeProfit"] = GatherMate.db.profiles["RecipeProfit"] or {} - gmdb = GatherMate.db.profiles["RecipeProfit"] - for k, v in pairs(defaultProfile) do - gmdb[k] = v; - end - GatherMate:SendMessage("OnProfileChanged"); - GatherMate:GetModule("Config"):UpdateConfig() - GatherMate:SendMessage("GatherMateConfigChanged") - GatherMate.db:SetProfile("RecipeProfit") - end - }, + heading = { + order = 0, + type = "description", + name = "Thank you for using RecipeProfit for GatherMate!\n\n".. + "RecipeProfit was recently updated to work with patch 4.0.x and GatherMate 2. If you find any bugs you can report them on curse.com or curseforge.com by contacting the author 'Yuffles'. ".. + "You can also email the author at killermonkey99".. --[[anti-spambot]] "@".."gmail.com (please try to put \"RecipeProfit\" in the subject!)\n\n".. + "You can toggle the display of RecipeProfit nodes on the map and minimap by changing the options in the general GatherMate 2 menu.", + width = "full", + }, } } +--maps wowhead IDs to localization independant map ids O_O +local zidmap={[1]=27,[3]=17,[4]=19,[8]=38,[10]=34,[11]=40,[12]=30,[14]=4, + [15]=141,[16]=181,[17]=11,[28]=22,[33]=37,[38]=35,[40]=39,[41]=32,[44]=36, + [45]=16,[46]=29,[47]=26,[51]=28,[65]=488,[66]=496,[67]=495,[85]=20, + [130]=21,[139]=23,[141]=41,[148]=42,[210]=492,[215]=9,[267]=24,[331]=43, + [357]=121,[361]=182,[394]=490,[400]=61,[405]=101,[406]=81,[440]=161, + [490]=201,[493]=241,[495]=491,[616]=606,[618]=281,[1377]=261,[1497]=382, + [1519]=301,[1537]=341,[1637]=321,[1638]=362,[1657]=381,[3430]=462, + [3433]=463,[3483]=465,[3487]=480,[3518]=477,[3519]=478,[3520]=473, + [3521]=467,[3522]=475,[3523]=479,[3524]=464,[3525]=476,[3537]=486, + [3557]=471,[3703]=481,[3711]=493,[4080]=499,[4197]=501,[4395]=504, + [4709]=607,[4714]=545,[4720]=544,[4737]=605,[4755]=611,[4815]=610, + [4922]=700,[5034]=720,[5042]=640,[5095]=708,[5144]=615,[5145]=614, + [5146]=613,[5287]=673,[5339]=689,[5416]=737,[5630]=737,[5695]=772 +} + local defaults = { faction = "default", safebuy = "on", @@ -203,7 +157,7 @@ inject_options() GatherMate:GetModule("Config"):UpdateConfig() - GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") + GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged") --[[ hook GetNameForNode for custom highlighting ]] local oldFunction = GatherMate.GetNameForNode @@ -216,11 +170,12 @@ end end - --[[ hook OnProfileChanged to fix cleanup database ]] + --[[hook OnProfileChanged to fix cleanup database ]] local oldFunction2 = GatherMate.OnProfileChanged GatherMate.OnProfileChanged = function(lself, ...) lself.db.profile.cleanupRange["RecipeProfit"] = lself.db.profile.cleanupRange["RecipeProfit"] or 15 + lself.db.profile.show["RecipeProfit"] = lself.db.profile.show["RecipeProfit"] == "never" and "never" or "always"; oldFunction2(lself, ...) end @@ -240,8 +195,8 @@ end function RecipeProfit:ShowOptions() - LibStub("AceConfigDialog-3.0"):Open("GatherMate") - LibStub("AceConfigDialog-3.0"):SelectGroup("GatherMate", "RecipeProfit") + InterfaceOptionsFrame_OpenToCategory("GatherMate 2") + LibStub("AceConfigDialog-3.0"):SelectGroup("GatherMate 2", "RecipeProfit") end function RecipeProfit:UpdateButtons(event, ...) @@ -273,16 +228,18 @@ function RecipeProfit:DoMerge() ids = {} - local selectedDB = get_faction_db(); + local alliance = get_faction_db(); GatherMate:ClearDB("RecipeProfit") - for id, note in pairs(selectedDB) do - x, y = find_good_id(note.x, note.y) - add_note(x, y, note) + for id, note in pairs(RECIPEPROFIT_database) do + if((note.a and alliance) or (note.h and not alliance)) then + x, y = find_good_id(note.x, note.y) + add_note(x, y, note) + end end GatherMate:SendMessage("GatherMateDataImport") - GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") + GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged") end function get_note_title(note, factionTag) @@ -294,20 +251,26 @@ end function add_note(x, y, note) - local coords = GatherMate:getID(x / 100, y / 100) - local zoneID = GatherMate.zoneData[note.map][3] - local nodeID = GatherMate.nodeIDs["RecipeProfit"][get_note_title(note, factionTag)] + local coords = GatherMate.mapData:EncodeLoc(x/100, y/100, 0) + local zoneID = zidmap[note.map] + if(not zoneID) then + print("OMFG "..note.map) + return + end - GatherMate:InjectNode(zoneID, coords, "RecipeProfit", nodeID); + local nodeID = GatherMate.nodeIDs["RecipeProfit"][get_note_title(note, "")] + print(nodeID) + GatherMate:InjectNode(zoneID, coords, "RecipeProfit", nodeID) end function get_faction_db() local factionAlliance = db.profile.faction == "Alliance" or db.profile.faction == "default" and UnitFactionGroup("player") == "Alliance"; + if(factionAlliance) then - return RECIPEPROFIT_alliance, "A"; + return true, "" else - return RECIPEPROFIT_horde, "H"; + return false, "" end end @@ -374,17 +337,11 @@ GatherMate.nodeMinHarvest["RecipeProfit"] = {} local nodes = GatherMate.nodeIDs["RecipeProfit"] - for id, note in pairs(RECIPEPROFIT_alliance) do + for id, note in pairs(RECIPEPROFIT_database) do safeRecipes[note.item] = true; local id = get_next_texture_id(); - nodes[get_note_title(note, "A")] = id; - nodeLookup[id] = note; - end - - for id, note in pairs(RECIPEPROFIT_horde) do - safeRecipes[note.item] = true; - local id = get_next_texture_id(); - nodes[get_note_title(note, "H")] = id; + + nodes[get_note_title(note, "")] = id; nodeLookup[id] = note; end @@ -396,35 +353,29 @@ end function inject_options() - GatherMate:GetModule("Config").options.args.display.args.general.args.showGroup.args["showRecipeProfit"] = { - order = 6, + local acr = LibStub("AceConfigRegistry-3.0") + acr:GetOptionsTable("GatherMate 2", "dialog", "RecipeProfit-1.0").args["showRecipeProfit"] = { + order = 7, name = "Show RecipeProfit nodes.", desc = "Toggle showing nodes added by RecipeProfit.", type = "select", values = { - ["always"] = "Always show", - ["never"] = "Never show", + always = "Always show", + never = "Never show", }, arg = "RecipeProfit", } - GatherMate:GetModule("Config").options.args.display.args.general.args.iconGroup.args.tracking.args["showRecipeProfit"] = { - order = 6.5, - name = "RecipeProfit", - desc = "Color of the tracking circle.", - type = "color", - hasAlpha = true, - arg = "RecipeProfit", - } + GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged") end --- TODO: Fix function get_colored_note_name(self, nodeID) local text = self.reverseNodeIDs["RecipeProfit"][nodeID] local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(nodeLookup[nodeID].itementry) if(not sLink) then - return text + RecipeProfit:ScheduleTimer("UpdateButtons", 3) + return "|cFF000000(??) |cFF66DD66" .. text .. "|cFFFF0000 Please Wait (Querying Server)..." end local count = GetItemCount(sLink, true)
