|
Aaron@0
|
1 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit")
|
|
Aaron@0
|
2 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate")
|
|
Aaron@0
|
3 local tabletest = {}
|
|
Aaron@0
|
4 local db = {}
|
|
Aaron@0
|
5 RecipeProfit.db = db;
|
|
Aaron@0
|
6
|
|
Aaron@0
|
7 function debugprint(val, indent)
|
|
Aaron@0
|
8 indent = indent or "";
|
|
Aaron@0
|
9 if not(type(val) == "table") then
|
|
Aaron@0
|
10 print("Not table: " .. val)
|
|
Aaron@0
|
11 return
|
|
Aaron@0
|
12 end
|
|
Aaron@0
|
13
|
|
Aaron@0
|
14 for k,v in pairs(val) do
|
|
Aaron@0
|
15 if(type(k) == "table" and type(v) == "table") then
|
|
Aaron@0
|
16 print(indent .. "table key: {")
|
|
Aaron@0
|
17 debugprint(k, indent .. " ")
|
|
Aaron@0
|
18 print(indent .. "} = {")
|
|
Aaron@0
|
19 debugprint(v, indent .. " ")
|
|
Aaron@0
|
20 print(indent .. "}")
|
|
Aaron@0
|
21 elseif(type(v) == "table") then
|
|
Aaron@0
|
22 print(indent .. k .. " = {")
|
|
Aaron@0
|
23 debugprint(v, indent .. " ")
|
|
Aaron@0
|
24 print(indent .. "}")
|
|
Aaron@0
|
25 else
|
|
Aaron@0
|
26 print(indent .. k .. " = " .. v)
|
|
Aaron@0
|
27 end
|
|
Aaron@0
|
28 end
|
|
Aaron@0
|
29 end
|
|
Aaron@0
|
30
|
|
Aaron@0
|
31 local options = {
|
|
Aaron@0
|
32 type = "group",
|
|
Aaron@0
|
33 name = "RecipeProfit", -- addon name to import from, don't localize
|
|
Aaron@0
|
34 handler = {},
|
|
Aaron@0
|
35 disabled = false,
|
|
Aaron@0
|
36 args = {
|
|
Aaron@0
|
37 faction = {
|
|
Aaron@0
|
38 order = 1,
|
|
Aaron@0
|
39 name = "Select Database",
|
|
Aaron@0
|
40 desc = "Show a different database",
|
|
Aaron@0
|
41 type = "group",
|
|
Aaron@0
|
42 guiInline = true,
|
|
Aaron@0
|
43 args = {
|
|
Aaron@0
|
44 faction = {
|
|
Aaron@0
|
45 order = 0,
|
|
Aaron@0
|
46 name = "Faction",
|
|
Aaron@0
|
47 desc = "Show a different database.",
|
|
Aaron@0
|
48 type = "select",
|
|
Aaron@0
|
49 values = {
|
|
Aaron@0
|
50 ["Alliance"] = "Alliance",
|
|
Aaron@0
|
51 ["Horde"] = "Horde",
|
|
Aaron@0
|
52 ["default"] = "Default (Determined By Character)",
|
|
Aaron@0
|
53 },
|
|
Aaron@0
|
54 arg = "faction",
|
|
Aaron@0
|
55 },
|
|
Aaron@0
|
56 },
|
|
Aaron@0
|
57 get = function(k) print(k); return db.profile[k.arg]; end,
|
|
Aaron@0
|
58 set = function(k, v) db.profile[k.arg] = v; RecipeProfit:DoMerge(); end,
|
|
Aaron@0
|
59 },
|
|
Aaron@0
|
60 loadData = {
|
|
Aaron@0
|
61 order = 8,
|
|
Aaron@0
|
62 name = "Import Data",
|
|
Aaron@0
|
63 desc = "Load RecipeProfit and import the data to your database.",
|
|
Aaron@0
|
64 type = "execute",
|
|
Aaron@0
|
65 func = function()
|
|
Aaron@0
|
66 RecipeProfit:DoMerge()
|
|
Aaron@0
|
67 end
|
|
Aaron@0
|
68 },
|
|
Aaron@0
|
69 }
|
|
Aaron@0
|
70 }
|
|
Aaron@0
|
71
|
|
Aaron@0
|
72 local defaults = {
|
|
Aaron@0
|
73 faction = nil,
|
|
Aaron@0
|
74 }
|
|
Aaron@0
|
75
|
|
Aaron@0
|
76 function RecipeProfit:OnInitialize()
|
|
Aaron@0
|
77 profile = profile or defaults
|
|
Aaron@0
|
78 db.profile = profile
|
|
Aaron@0
|
79 db.storage = {}
|
|
Aaron@0
|
80
|
|
Aaron@0
|
81 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options)
|
|
Aaron@0
|
82 GatherMate:RegisterDBType("RecipeProfit", db.storage)
|
|
Aaron@0
|
83 GatherMate.db.profile.show["RecipeProfit"] = "always"
|
|
Aaron@0
|
84 GatherMate.nodeIDs["RecipeProfit"] = {}
|
|
Aaron@0
|
85 GatherMate.nodeTextures["RecipeProfit"] = {}
|
|
Aaron@0
|
86 GatherMate.nodeMinHarvest["RecipeProfit"] = {}
|
|
Aaron@0
|
87 nodes = GatherMate.nodeIDs["RecipeProfit"]
|
|
Aaron@0
|
88
|
|
Aaron@0
|
89 for id, note in pairs(RECIPEPROFIT_alliance) do
|
|
Aaron@0
|
90 nodes[note.item.." - ("..note.vendor.." A)"] = id * 10
|
|
Aaron@0
|
91 GatherMate.nodeTextures["RecipeProfit"][id * 10] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
92 end
|
|
Aaron@0
|
93
|
|
Aaron@0
|
94 for id, note in pairs(RECIPEPROFIT_horde) do
|
|
Aaron@0
|
95 nodes[note.item.." - ("..note.vendor.." H)"] = id * 10 + 1
|
|
Aaron@0
|
96 GatherMate.nodeTextures["RecipeProfit"][id * 10 + 1] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
97 end
|
|
Aaron@0
|
98
|
|
Aaron@0
|
99 GatherMate.reverseNodeIDs["RecipeProfit"] = GatherMate:CreateReversedTable(nodes)
|
|
Aaron@0
|
100 GatherMate:GetModule("Config"):UpdateConfig()
|
|
Aaron@0
|
101
|
|
Aaron@0
|
102 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
103 end
|
|
Aaron@0
|
104
|
|
Aaron@0
|
105 function RecipeProfit:OnEnable()
|
|
Aaron@0
|
106 db.profile.faction = db.profile.faction or UnitFactionGroup("player")
|
|
Aaron@0
|
107
|
|
Aaron@0
|
108 RecipeProfit:DoMerge()
|
|
Aaron@0
|
109 end
|
|
Aaron@0
|
110
|
|
Aaron@0
|
111 local ids = {}
|
|
Aaron@0
|
112 function findGoodId(x, y)
|
|
Aaron@0
|
113 if ids[x.." "..y] then
|
|
Aaron@0
|
114 return findGoodId(x + .01, y)
|
|
Aaron@0
|
115 end
|
|
Aaron@0
|
116
|
|
Aaron@0
|
117 ids[x.." "..y] = true
|
|
Aaron@0
|
118 return x, y
|
|
Aaron@0
|
119 end
|
|
Aaron@0
|
120
|
|
Aaron@0
|
121 function RecipeProfit:DoMerge()
|
|
Aaron@0
|
122 ids = {}
|
|
Aaron@0
|
123 GatherMate:ClearDB("RecipeProfit")
|
|
Aaron@0
|
124 for id, note in pairs(db.profile.faction == "Alliance" and RECIPEPROFIT_alliance or RECIPEPROFIT_horde) do
|
|
Aaron@0
|
125 x, y = findGoodId(note.x, note.y)
|
|
Aaron@0
|
126 GatherMate:AddNode(note.map, x / 100, y / 100, "RecipeProfit",
|
|
Aaron@0
|
127 note.item.." - ("..note.vendor.." ".. (db.profile.faction == "Alliance" and "A" or "H") ..")")
|
|
Aaron@0
|
128 end
|
|
Aaron@0
|
129
|
|
Aaron@0
|
130 GatherMate:SendMessage("GatherMateDataImport")
|
|
Aaron@0
|
131 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
132 end
|