|
Aaron@4
|
1 --[[--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))
|
|
Aaron@4
|
2
|
|
Aaron@4
|
3 RecipeProfit by -[@project-author@]-
|
|
Aaron@4
|
4
|
|
Aaron@4
|
5 Rev: @project-revision@
|
|
Aaron@4
|
6 Updated: @file-date-iso@
|
|
Aaron@4
|
7
|
|
Aaron@4
|
8 --))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))
|
|
Aaron@4
|
9
|
|
Aaron@4
|
10 http://www.wrathguides.com/
|
|
Aaron@4
|
11
|
|
Aaron@4
|
12 --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))
|
|
Aaron@4
|
13
|
|
Aaron@4
|
14 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit")
|
|
Aaron@0
|
15 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate")
|
|
Aaron@0
|
16 local tabletest = {}
|
|
Aaron@0
|
17 local db = {}
|
|
Aaron@1
|
18 local safeRecipes = {}
|
|
Aaron@1
|
19 safer = safeRecipes
|
|
Aaron@0
|
20 RecipeProfit.db = db;
|
|
Aaron@0
|
21
|
|
Aaron@1
|
22
|
|
Aaron@0
|
23 function debugprint(val, indent)
|
|
Aaron@0
|
24 indent = indent or "";
|
|
Aaron@0
|
25 if not(type(val) == "table") then
|
|
Aaron@0
|
26 print("Not table: " .. val)
|
|
Aaron@0
|
27 return
|
|
Aaron@0
|
28 end
|
|
Aaron@0
|
29
|
|
Aaron@0
|
30 for k,v in pairs(val) do
|
|
Aaron@0
|
31 if(type(k) == "table" and type(v) == "table") then
|
|
Aaron@0
|
32 print(indent .. "table key: {")
|
|
Aaron@0
|
33 debugprint(k, indent .. " ")
|
|
Aaron@0
|
34 print(indent .. "} = {")
|
|
Aaron@0
|
35 debugprint(v, indent .. " ")
|
|
Aaron@0
|
36 print(indent .. "}")
|
|
Aaron@0
|
37 elseif(type(v) == "table") then
|
|
Aaron@0
|
38 print(indent .. k .. " = {")
|
|
Aaron@0
|
39 debugprint(v, indent .. " ")
|
|
Aaron@0
|
40 print(indent .. "}")
|
|
Aaron@0
|
41 else
|
|
Aaron@0
|
42 print(indent .. k .. " = " .. v)
|
|
Aaron@0
|
43 end
|
|
Aaron@0
|
44 end
|
|
Aaron@0
|
45 end
|
|
Aaron@0
|
46
|
|
Aaron@0
|
47 local options = {
|
|
Aaron@0
|
48 type = "group",
|
|
Aaron@0
|
49 name = "RecipeProfit", -- addon name to import from, don't localize
|
|
Aaron@0
|
50 handler = {},
|
|
Aaron@0
|
51 disabled = false,
|
|
Aaron@0
|
52 args = {
|
|
Aaron@1
|
53 opt = {
|
|
Aaron@0
|
54 order = 1,
|
|
Aaron@0
|
55 name = "Select Database",
|
|
Aaron@0
|
56 desc = "Show a different database",
|
|
Aaron@0
|
57 type = "group",
|
|
Aaron@0
|
58 guiInline = true,
|
|
Aaron@0
|
59 args = {
|
|
Aaron@0
|
60 faction = {
|
|
Aaron@0
|
61 order = 0,
|
|
Aaron@0
|
62 name = "Faction",
|
|
Aaron@0
|
63 desc = "Show a different database.",
|
|
Aaron@0
|
64 type = "select",
|
|
Aaron@0
|
65 values = {
|
|
Aaron@0
|
66 ["Alliance"] = "Alliance",
|
|
Aaron@0
|
67 ["Horde"] = "Horde",
|
|
Aaron@1
|
68 ["default"] = "Default",
|
|
Aaron@0
|
69 },
|
|
Aaron@0
|
70 arg = "faction",
|
|
Aaron@0
|
71 },
|
|
Aaron@1
|
72
|
|
Aaron@1
|
73 safeBuy = {
|
|
Aaron@1
|
74 order = 1,
|
|
Aaron@1
|
75 name = "Safe Recipe Buy",
|
|
Aaron@1
|
76 desc = "Warn when buying a recipe not on the RecipeProfit list.",
|
|
Aaron@1
|
77 type = "select",
|
|
Aaron@1
|
78 values = {
|
|
Aaron@1
|
79 ["on"] = "On",
|
|
Aaron@1
|
80 ["off"]= "Off",
|
|
Aaron@1
|
81 },
|
|
Aaron@1
|
82 arg = "safebuy",
|
|
Aaron@1
|
83 },
|
|
Aaron@0
|
84 },
|
|
Aaron@1
|
85 get = function(k) return db.profile[k.arg]; end,
|
|
Aaron@0
|
86 set = function(k, v) db.profile[k.arg] = v; RecipeProfit:DoMerge(); end,
|
|
Aaron@0
|
87 },
|
|
Aaron@0
|
88 loadData = {
|
|
Aaron@0
|
89 order = 8,
|
|
Aaron@0
|
90 name = "Import Data",
|
|
Aaron@0
|
91 desc = "Load RecipeProfit and import the data to your database.",
|
|
Aaron@0
|
92 type = "execute",
|
|
Aaron@0
|
93 func = function()
|
|
Aaron@0
|
94 RecipeProfit:DoMerge()
|
|
Aaron@0
|
95 end
|
|
Aaron@0
|
96 },
|
|
Aaron@0
|
97 }
|
|
Aaron@0
|
98 }
|
|
Aaron@0
|
99
|
|
Aaron@0
|
100 local defaults = {
|
|
Aaron@1
|
101 faction = "default",
|
|
Aaron@1
|
102 safebuy = "on",
|
|
Aaron@0
|
103 }
|
|
Aaron@0
|
104
|
|
Aaron@0
|
105 function RecipeProfit:OnInitialize()
|
|
Aaron@0
|
106 profile = profile or defaults
|
|
Aaron@1
|
107 for k, v in pairs(defaults) do
|
|
Aaron@1
|
108 profile[k] = profile[k] or v;
|
|
Aaron@1
|
109 end
|
|
Aaron@1
|
110
|
|
Aaron@0
|
111 db.profile = profile
|
|
Aaron@0
|
112 db.storage = {}
|
|
Aaron@0
|
113
|
|
Aaron@0
|
114 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options)
|
|
Aaron@0
|
115 GatherMate:RegisterDBType("RecipeProfit", db.storage)
|
|
Aaron@0
|
116 GatherMate.db.profile.show["RecipeProfit"] = "always"
|
|
Aaron@0
|
117 GatherMate.nodeIDs["RecipeProfit"] = {}
|
|
Aaron@0
|
118 GatherMate.nodeTextures["RecipeProfit"] = {}
|
|
Aaron@0
|
119 GatherMate.nodeMinHarvest["RecipeProfit"] = {}
|
|
Aaron@0
|
120 nodes = GatherMate.nodeIDs["RecipeProfit"]
|
|
Aaron@0
|
121
|
|
Aaron@0
|
122 for id, note in pairs(RECIPEPROFIT_alliance) do
|
|
Aaron@1
|
123 safeRecipes[note.item] = true;
|
|
Aaron@0
|
124 nodes[note.item.." - ("..note.vendor.." A)"] = id * 10
|
|
Aaron@0
|
125 GatherMate.nodeTextures["RecipeProfit"][id * 10] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
126 end
|
|
Aaron@0
|
127
|
|
Aaron@0
|
128 for id, note in pairs(RECIPEPROFIT_horde) do
|
|
Aaron@1
|
129 safeRecipes[note.item] = true;
|
|
Aaron@0
|
130 nodes[note.item.." - ("..note.vendor.." H)"] = id * 10 + 1
|
|
Aaron@0
|
131 GatherMate.nodeTextures["RecipeProfit"][id * 10 + 1] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
132 end
|
|
Aaron@0
|
133
|
|
Aaron@0
|
134 GatherMate.reverseNodeIDs["RecipeProfit"] = GatherMate:CreateReversedTable(nodes)
|
|
Aaron@0
|
135 GatherMate:GetModule("Config"):UpdateConfig()
|
|
Aaron@0
|
136
|
|
Aaron@0
|
137 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
138 end
|
|
Aaron@0
|
139
|
|
Aaron@0
|
140 function RecipeProfit:OnEnable()
|
|
Aaron@1
|
141 for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do
|
|
Aaron@1
|
142 local buttonframe = _G["MerchantItem"..i];
|
|
Aaron@1
|
143 buttonframe:HookScript("OnUpdate", function(self)
|
|
Aaron@1
|
144 local buttonName = _G[self:GetName().."Name"];
|
|
Aaron@1
|
145 local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID());
|
|
Aaron@2
|
146 if(not link) then
|
|
Aaron@2
|
147 return;
|
|
Aaron@2
|
148 end
|
|
Aaron@2
|
149
|
|
Aaron@1
|
150 local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(link)
|
|
Aaron@1
|
151
|
|
Aaron@1
|
152 if(sType == "Recipe" and safeRecipes[sName]) then
|
|
Aaron@1
|
153 SetItemButtonNameFrameVertexColor(self, 0, 0, 1.0);
|
|
Aaron@1
|
154 SetItemButtonSlotVertexColor(self, 0, 0, 0.5);
|
|
Aaron@2
|
155 buttonName:SetText("* " .. sName)
|
|
Aaron@1
|
156 if(GetItemCount(link, true) == 0) then
|
|
Aaron@1
|
157 buttonName:SetTextColor(0,1,1);
|
|
Aaron@1
|
158 elseif(GetItemCount(link, true) < 5) then
|
|
Aaron@1
|
159 buttonName:SetTextColor(1,0,1);
|
|
Aaron@1
|
160 else
|
|
Aaron@1
|
161 buttonName:SetTextColor(1,0,0);
|
|
Aaron@1
|
162 end
|
|
Aaron@1
|
163 else
|
|
Aaron@1
|
164 buttonName:SetTextColor(GameFontHighlightSmallOutline:GetTextColor());
|
|
Aaron@1
|
165 end
|
|
Aaron@1
|
166 end)
|
|
Aaron@1
|
167
|
|
Aaron@1
|
168 RecipeProfit:DoMerge()
|
|
Aaron@1
|
169 end
|
|
Aaron@0
|
170 end
|
|
Aaron@0
|
171
|
|
Aaron@0
|
172 local ids = {}
|
|
Aaron@0
|
173 function findGoodId(x, y)
|
|
Aaron@0
|
174 if ids[x.." "..y] then
|
|
Aaron@0
|
175 return findGoodId(x + .01, y)
|
|
Aaron@0
|
176 end
|
|
Aaron@0
|
177
|
|
Aaron@0
|
178 ids[x.." "..y] = true
|
|
Aaron@0
|
179 return x, y
|
|
Aaron@0
|
180 end
|
|
Aaron@0
|
181
|
|
Aaron@0
|
182 function RecipeProfit:DoMerge()
|
|
Aaron@0
|
183 ids = {}
|
|
Aaron@1
|
184 selectedDB = db.profile.faction == "Alliance" and RECIPEPROFIT_alliance or
|
|
Aaron@1
|
185 db.profile.faction == "default" and UnitFactionGroup("player") == "Alliance" and
|
|
Aaron@1
|
186 RECIPEPROFIT_alliance or RECIPEPROFIT_horde
|
|
Aaron@0
|
187 GatherMate:ClearDB("RecipeProfit")
|
|
Aaron@1
|
188 for id, note in pairs(selectedDB) do
|
|
Aaron@0
|
189 x, y = findGoodId(note.x, note.y)
|
|
Aaron@0
|
190 GatherMate:AddNode(note.map, x / 100, y / 100, "RecipeProfit",
|
|
Aaron@0
|
191 note.item.." - ("..note.vendor.." ".. (db.profile.faction == "Alliance" and "A" or "H") ..")")
|
|
Aaron@0
|
192 end
|
|
Aaron@0
|
193
|
|
Aaron@0
|
194 GatherMate:SendMessage("GatherMateDataImport")
|
|
Aaron@0
|
195 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
196 end
|