|
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@22
|
10 URL:
|
|
Aaron@22
|
11 http://www.wrathguides.com/
|
|
Aaron@22
|
12
|
|
Aaron@22
|
13 License:
|
|
Aaron@22
|
14 This file is a part of "RecipeProfit for GatherMate."
|
|
Aaron@22
|
15
|
|
Aaron@22
|
16 This program is free software; you can redistribute it and/or
|
|
Aaron@22
|
17 modify it under the terms of the GNU General Public License
|
|
Aaron@22
|
18 as published by the Free Software Foundation, either version 3
|
|
Aaron@22
|
19 of the License, or (at your option) any later version.
|
|
Aaron@22
|
20
|
|
Aaron@22
|
21 This program is distributed in the hope that it will be useful,
|
|
Aaron@22
|
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Aaron@22
|
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Aaron@22
|
24 GNU General Public License for more details.
|
|
Aaron@22
|
25
|
|
Aaron@22
|
26 You should have received a copy of the GNU General Public License
|
|
killermonkey99@36
|
27 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
Aaron@22
|
28
|
|
Aaron@22
|
29 Note:
|
|
Aaron@22
|
30 This program's source code is specifically designed to work with
|
|
Aaron@22
|
31 World of Warcraft's interpreted AddOn system.
|
|
Aaron@22
|
32
|
|
Aaron@22
|
33 You have an implicit license to use this program with these facilities
|
|
Aaron@22
|
34 since that is it's designated purpose as per:
|
|
Aaron@22
|
35 http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat
|
|
Aaron@4
|
36
|
|
Aaron@4
|
37 --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))
|
|
Aaron@4
|
38
|
|
Aaron@22
|
39
|
|
killermonkey99@36
|
40 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0")
|
|
killermonkey99@36
|
41
|
|
killermonkey99@36
|
42 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate2")
|
|
killermonkey99@36
|
43
|
|
Aaron@0
|
44 local tabletest = {}
|
|
Aaron@16
|
45 local db = {}
|
|
Aaron@1
|
46 local safeRecipes = {}
|
|
Aaron@16
|
47 local ids = {}
|
|
Aaron@24
|
48 local nodeLookup = {}
|
|
Aaron@16
|
49
|
|
Aaron@17
|
50 local profile
|
|
Aaron@17
|
51
|
|
Aaron@0
|
52 RecipeProfit.db = db;
|
|
Aaron@0
|
53
|
|
Aaron@17
|
54 --[[ Forward Definitions (for local functions) ]]
|
|
Aaron@16
|
55 local get_faction_db,
|
|
Aaron@16
|
56 add_note,
|
|
Aaron@16
|
57 button_update,
|
|
Aaron@16
|
58 find_good_id,
|
|
Aaron@16
|
59 safe_cache_vendor,
|
|
Aaron@17
|
60 get_note_title,
|
|
Aaron@17
|
61 get_next_texture_id,
|
|
Aaron@17
|
62 set_node_constants,
|
|
Aaron@24
|
63 get_colored_note_name,
|
|
Aaron@17
|
64 inject_options;
|
|
Aaron@16
|
65
|
|
Aaron@17
|
66 --[[ Deep table inspection for debugging ]]
|
|
Aaron@0
|
67 function debugprint(val, indent)
|
|
Aaron@0
|
68 indent = indent or "";
|
|
Aaron@0
|
69 if not(type(val) == "table") then
|
|
Aaron@0
|
70 print("Not table: " .. val)
|
|
Aaron@0
|
71 return
|
|
Aaron@0
|
72 end
|
|
Aaron@0
|
73
|
|
Aaron@0
|
74 for k,v in pairs(val) do
|
|
Aaron@0
|
75 if(type(k) == "table" and type(v) == "table") then
|
|
Aaron@0
|
76 print(indent .. "table key: {")
|
|
Aaron@0
|
77 debugprint(k, indent .. " ")
|
|
Aaron@0
|
78 print(indent .. "} = {")
|
|
Aaron@0
|
79 debugprint(v, indent .. " ")
|
|
Aaron@0
|
80 print(indent .. "}")
|
|
Aaron@12
|
81 elseif(type(v) == "table") then
|
|
Aaron@0
|
82 print(indent .. k .. " = {")
|
|
Aaron@0
|
83 debugprint(v, indent .. " ")
|
|
Aaron@0
|
84 print(indent .. "}")
|
|
Aaron@0
|
85 else
|
|
Aaron@12
|
86 if(type(v) ~= "boolean") then
|
|
Aaron@12
|
87 print(indent .. k .. " = " .. v)
|
|
Aaron@12
|
88 else
|
|
Aaron@12
|
89 print(indent .. k .. " = " .. (v and "true" or "false"))
|
|
Aaron@12
|
90 end
|
|
Aaron@0
|
91 end
|
|
Aaron@0
|
92 end
|
|
Aaron@0
|
93 end
|
|
Aaron@8
|
94
|
|
Aaron@0
|
95 local options = {
|
|
Aaron@0
|
96 type = "group",
|
|
Aaron@0
|
97 name = "RecipeProfit", -- addon name to import from, don't localize
|
|
Aaron@0
|
98 handler = {},
|
|
Aaron@0
|
99 disabled = false,
|
|
Aaron@0
|
100 args = {
|
|
killermonkey99@36
|
101 heading = {
|
|
killermonkey99@36
|
102 order = 0,
|
|
killermonkey99@36
|
103 type = "description",
|
|
killermonkey99@36
|
104 name = "Thank you for using RecipeProfit for GatherMate!\n\n"..
|
|
killermonkey99@36
|
105 "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'. "..
|
|
killermonkey99@36
|
106 "You can also email the author at killermonkey99".. --[[anti-spambot]] "@".."gmail.com (please try to put \"RecipeProfit\" in the subject!)\n\n"..
|
|
killermonkey99@36
|
107 "You can toggle the display of RecipeProfit nodes on the map and minimap by changing the options in the general GatherMate 2 menu.",
|
|
killermonkey99@36
|
108 width = "full",
|
|
killermonkey99@36
|
109 },
|
|
Aaron@0
|
110 }
|
|
Aaron@0
|
111 }
|
|
Aaron@0
|
112
|
|
killermonkey99@36
|
113 --maps wowhead IDs to localization independant map ids O_O
|
|
killermonkey99@36
|
114 local zidmap={[1]=27,[3]=17,[4]=19,[8]=38,[10]=34,[11]=40,[12]=30,[14]=4,
|
|
killermonkey99@36
|
115 [15]=141,[16]=181,[17]=11,[28]=22,[33]=37,[38]=35,[40]=39,[41]=32,[44]=36,
|
|
killermonkey99@36
|
116 [45]=16,[46]=29,[47]=26,[51]=28,[65]=488,[66]=496,[67]=495,[85]=20,
|
|
killermonkey99@36
|
117 [130]=21,[139]=23,[141]=41,[148]=42,[210]=492,[215]=9,[267]=24,[331]=43,
|
|
killermonkey99@36
|
118 [357]=121,[361]=182,[394]=490,[400]=61,[405]=101,[406]=81,[440]=161,
|
|
killermonkey99@36
|
119 [490]=201,[493]=241,[495]=491,[616]=606,[618]=281,[1377]=261,[1497]=382,
|
|
killermonkey99@36
|
120 [1519]=301,[1537]=341,[1637]=321,[1638]=362,[1657]=381,[3430]=462,
|
|
killermonkey99@36
|
121 [3433]=463,[3483]=465,[3487]=480,[3518]=477,[3519]=478,[3520]=473,
|
|
killermonkey99@36
|
122 [3521]=467,[3522]=475,[3523]=479,[3524]=464,[3525]=476,[3537]=486,
|
|
killermonkey99@36
|
123 [3557]=471,[3703]=481,[3711]=493,[4080]=499,[4197]=501,[4395]=504,
|
|
killermonkey99@36
|
124 [4709]=607,[4714]=545,[4720]=544,[4737]=605,[4755]=611,[4815]=610,
|
|
killermonkey99@36
|
125 [4922]=700,[5034]=720,[5042]=640,[5095]=708,[5144]=615,[5145]=614,
|
|
killermonkey99@36
|
126 [5146]=613,[5287]=673,[5339]=689,[5416]=737,[5630]=737,[5695]=772
|
|
killermonkey99@36
|
127 }
|
|
killermonkey99@36
|
128
|
|
Aaron@0
|
129 local defaults = {
|
|
Aaron@16
|
130 --submitting cached data not yet implemented
|
|
Aaron@16
|
131 location_cache = {},
|
|
killermonkey99@51
|
132 debugvars = {},
|
|
killermonkey99@51
|
133 blacklist = {},
|
|
Aaron@0
|
134 }
|
|
Aaron@0
|
135
|
|
Aaron@0
|
136 function RecipeProfit:OnInitialize()
|
|
Aaron@17
|
137 profile = RECIPEPROFIT_profile or defaults
|
|
Aaron@7
|
138
|
|
Aaron@1
|
139 for k, v in pairs(defaults) do
|
|
Aaron@1
|
140 profile[k] = profile[k] or v;
|
|
Aaron@1
|
141 end
|
|
Aaron@1
|
142
|
|
Aaron@12
|
143 self:RegisterChatCommand("recipeprofit", "ShowOptions")
|
|
Aaron@12
|
144 self:RegisterChatCommand("rp", "ShowOptions")
|
|
Aaron@12
|
145 self:RegisterChatCommand("profit", "ShowOptions")
|
|
Aaron@12
|
146
|
|
Aaron@0
|
147 db.profile = profile
|
|
Aaron@0
|
148 db.storage = {}
|
|
Aaron@0
|
149
|
|
Aaron@0
|
150 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options)
|
|
Aaron@0
|
151 GatherMate:RegisterDBType("RecipeProfit", db.storage)
|
|
Aaron@8
|
152 GatherMate.db.profile.show["RecipeProfit"] = GatherMate.db.profile.show["RecipeProfit"] or "always"
|
|
Aaron@0
|
153
|
|
Aaron@17
|
154 set_node_constants()
|
|
Aaron@17
|
155 inject_options()
|
|
Aaron@8
|
156
|
|
Aaron@0
|
157 GatherMate:GetModule("Config"):UpdateConfig()
|
|
killermonkey99@36
|
158 GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged")
|
|
Aaron@24
|
159
|
|
Aaron@24
|
160 --[[ hook GetNameForNode for custom highlighting ]]
|
|
Aaron@24
|
161 local oldFunction = GatherMate.GetNameForNode
|
|
Aaron@24
|
162
|
|
Aaron@24
|
163 GatherMate.GetNameForNode = function(lself, type, nodeID)
|
|
Aaron@24
|
164 if(type == "RecipeProfit") then
|
|
Aaron@24
|
165 return get_colored_note_name(lself, nodeID)
|
|
Aaron@24
|
166 else
|
|
Aaron@24
|
167 return oldFunction(lself, type, nodeID)
|
|
Aaron@24
|
168 end
|
|
Aaron@24
|
169 end
|
|
Aaron@24
|
170
|
|
killermonkey99@36
|
171 --[[hook OnProfileChanged to fix cleanup database ]]
|
|
Aaron@26
|
172 local oldFunction2 = GatherMate.OnProfileChanged
|
|
Aaron@26
|
173
|
|
Aaron@26
|
174 GatherMate.OnProfileChanged = function(lself, ...)
|
|
Aaron@26
|
175 lself.db.profile.cleanupRange["RecipeProfit"] = lself.db.profile.cleanupRange["RecipeProfit"] or 15
|
|
killermonkey99@36
|
176 lself.db.profile.show["RecipeProfit"] = lself.db.profile.show["RecipeProfit"] == "never" and "never" or "always";
|
|
Aaron@26
|
177 oldFunction2(lself, ...)
|
|
Aaron@26
|
178 end
|
|
Aaron@26
|
179
|
|
Aaron@0
|
180 end
|
|
Aaron@0
|
181
|
|
Aaron@17
|
182
|
|
Aaron@17
|
183 function RecipeProfit:OnEnable()
|
|
Aaron@17
|
184
|
|
Aaron@17
|
185 _G["MerchantPrevPageButton"]:HookScript("OnClick", self.UpdateButtons)
|
|
Aaron@17
|
186 _G["MerchantNextPageButton"]:HookScript("OnClick", self.UpdateButtons)
|
|
Aaron@17
|
187
|
|
Aaron@17
|
188 self:RegisterEvent("MERCHANT_SHOW", "UpdateButtons")
|
|
Aaron@17
|
189 self:RegisterEvent("MERCHANT_UPDATE", "UpdateButtons")
|
|
Aaron@17
|
190 self:RegisterEvent("BAG_UPDATE", "UpdateButtons")
|
|
Aaron@28
|
191
|
|
Aaron@17
|
192 RecipeProfit:DoMerge()
|
|
killermonkey99@45
|
193 if(GatherMate.db.profile.show["RecipeProfit"] ~= "always" and GatherMate.db.profile.show["RecipeProfit"] ~= "never") then
|
|
killermonkey99@45
|
194 GatherMate.db.profile.show["RecipeProfit"] = "always"
|
|
killermonkey99@45
|
195 GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged")
|
|
killermonkey99@45
|
196 end
|
|
Aaron@17
|
197 end
|
|
Aaron@17
|
198
|
|
killermonkey99@51
|
199 --Forward Functions for command listing
|
|
killermonkey99@51
|
200 local set_var,
|
|
killermonkey99@51
|
201 get_var,
|
|
killermonkey99@51
|
202 show_help,
|
|
killermonkey99@51
|
203 blacklist_add,
|
|
killermonkey99@51
|
204 blacklist_show,
|
|
killermonkey99@51
|
205 blacklist_query
|
|
killermonkey99@51
|
206
|
|
killermonkey99@51
|
207 local commandList --Forward declaration of command list
|
|
killermonkey99@51
|
208
|
|
killermonkey99@51
|
209 function RecipeProfit:ParseCommands(input, level, list)
|
|
killermonkey99@51
|
210 args = {self:GetArgs(input, level)}
|
|
killermonkey99@51
|
211 arg0 = args[#args - 1]
|
|
killermonkey99@51
|
212
|
|
killermonkey99@51
|
213 if(not list[arg0]) then
|
|
killermonkey99@51
|
214 print("Error parsing command. Type /rp help for help with this command.")
|
|
killermonkey99@51
|
215 return
|
|
killermonkey99@51
|
216 end
|
|
killermonkey99@51
|
217
|
|
killermonkey99@51
|
218 if(type(list[arg0]) == "table") then
|
|
killermonkey99@51
|
219 self:ParseCommands(input, level + 1, list[arg0])
|
|
killermonkey99@51
|
220 else
|
|
killermonkey99@51
|
221 list[arg0](input)
|
|
killermonkey99@51
|
222 end
|
|
killermonkey99@51
|
223 end
|
|
killermonkey99@51
|
224
|
|
killermonkey99@51
|
225 function RecipeProfit:ShowOptions(input)
|
|
killermonkey99@51
|
226 if (input ~= "") then
|
|
killermonkey99@51
|
227 self:ParseCommands(input, 1, commandList)
|
|
killermonkey99@51
|
228 else
|
|
killermonkey99@51
|
229 InterfaceOptionsFrame_OpenToCategory("GatherMate 2")
|
|
killermonkey99@51
|
230 LibStub("AceConfigDialog-3.0"):SelectGroup("GatherMate 2", "RecipeProfit")
|
|
killermonkey99@51
|
231 end
|
|
Aaron@12
|
232 end
|
|
Aaron@12
|
233
|
|
Aaron@16
|
234 function RecipeProfit:UpdateButtons(event, ...)
|
|
Aaron@16
|
235 --print("UpdateButtons", event)
|
|
Aaron@28
|
236 if(WorldMapFrame:IsShown()) then
|
|
Aaron@28
|
237 local continent, zone = GetCurrentMapContinent(), GetCurrentMapZone()
|
|
Aaron@28
|
238 SetMapZoom(continent)
|
|
Aaron@28
|
239 SetMapZoom(continent, zone)
|
|
Aaron@28
|
240 else
|
|
Aaron@28
|
241 SetMapZoom(-1)
|
|
Aaron@28
|
242 end
|
|
Aaron@28
|
243
|
|
Aaron@28
|
244 GatherMate:GetModule("Display"):UpdateMaps()
|
|
Aaron@28
|
245
|
|
Aaron@16
|
246 if(not MerchantFrame:IsVisible()) then
|
|
Aaron@16
|
247 --print("UpdateButtons - (Event: ", event, ") - MerchantFrame not visible.");
|
|
Aaron@16
|
248 return;
|
|
Aaron@16
|
249 end
|
|
Aaron@16
|
250
|
|
Aaron@16
|
251 for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do
|
|
Aaron@16
|
252 local buttonframe = _G["MerchantItem"..i];
|
|
Aaron@16
|
253 local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i);
|
|
Aaron@16
|
254 --print(index)
|
|
Aaron@16
|
255 if index <= GetMerchantNumItems() then
|
|
Aaron@16
|
256 button_update(buttonframe)
|
|
Aaron@16
|
257 end
|
|
Aaron@16
|
258 end
|
|
Aaron@17
|
259 end
|
|
Aaron@16
|
260
|
|
Aaron@16
|
261 function RecipeProfit:DoMerge()
|
|
Aaron@16
|
262 ids = {}
|
|
killermonkey99@36
|
263 local alliance = get_faction_db();
|
|
Aaron@16
|
264
|
|
Aaron@16
|
265 GatherMate:ClearDB("RecipeProfit")
|
|
killermonkey99@36
|
266 for id, note in pairs(RECIPEPROFIT_database) do
|
|
killermonkey99@51
|
267 local blacklisted = false;
|
|
killermonkey99@51
|
268
|
|
killermonkey99@51
|
269 for _, v in pairs(RECIPEPROFIT_blacklist) do
|
|
killermonkey99@51
|
270 if(note.stock == -1 and not note.item:find("Recipe:")) then
|
|
killermonkey99@51
|
271 blacklisted = true;
|
|
killermonkey99@51
|
272 end
|
|
killermonkey99@51
|
273
|
|
killermonkey99@51
|
274 if(tonumber(v) == note.entry) then
|
|
killermonkey99@51
|
275 blacklisted = true;
|
|
killermonkey99@51
|
276 end
|
|
killermonkey99@51
|
277 end
|
|
killermonkey99@51
|
278
|
|
killermonkey99@51
|
279 if(not blacklisted) then
|
|
killermonkey99@51
|
280 if((note.a and alliance) or (note.h and not alliance)) then
|
|
killermonkey99@51
|
281 x, y = find_good_id(note.x, note.y)
|
|
killermonkey99@51
|
282 add_note(x, y, note)
|
|
killermonkey99@51
|
283 end
|
|
killermonkey99@36
|
284 end
|
|
Aaron@16
|
285 end
|
|
Aaron@16
|
286
|
|
Aaron@16
|
287 GatherMate:SendMessage("GatherMateDataImport")
|
|
killermonkey99@36
|
288 GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged")
|
|
Aaron@16
|
289 end
|
|
Aaron@16
|
290
|
|
Aaron@16
|
291 function get_note_title(note, factionTag)
|
|
Aaron@16
|
292 if(not factionTag) then
|
|
Aaron@16
|
293 _, factionTag = get_faction_db();
|
|
Aaron@16
|
294 end
|
|
Aaron@16
|
295
|
|
Aaron@16
|
296 return note.item.." - ("..note.vendor.." ".. factionTag ..")";
|
|
Aaron@16
|
297 end
|
|
Aaron@16
|
298
|
|
Aaron@16
|
299 function add_note(x, y, note)
|
|
killermonkey99@36
|
300 local coords = GatherMate.mapData:EncodeLoc(x/100, y/100, 0)
|
|
killermonkey99@36
|
301 local zoneID = zidmap[note.map]
|
|
killermonkey99@51
|
302
|
|
killermonkey99@51
|
303 if(note["realmap"]) then
|
|
killermonkey99@51
|
304 zoneID = note.realmap
|
|
killermonkey99@51
|
305 end
|
|
killermonkey99@51
|
306
|
|
killermonkey99@36
|
307 if(not zoneID) then
|
|
killermonkey99@36
|
308 return
|
|
killermonkey99@36
|
309 end
|
|
Aaron@33
|
310
|
|
killermonkey99@36
|
311 local nodeID = GatherMate.nodeIDs["RecipeProfit"][get_note_title(note, "")]
|
|
killermonkey99@36
|
312 GatherMate:InjectNode(zoneID, coords, "RecipeProfit", nodeID)
|
|
Aaron@16
|
313 end
|
|
Aaron@16
|
314
|
|
Aaron@16
|
315 function get_faction_db()
|
|
Aaron@16
|
316 local factionAlliance = db.profile.faction == "Alliance" or
|
|
Aaron@16
|
317 db.profile.faction == "default" and UnitFactionGroup("player") == "Alliance";
|
|
killermonkey99@36
|
318
|
|
Aaron@16
|
319 if(factionAlliance) then
|
|
killermonkey99@36
|
320 return true, ""
|
|
Aaron@16
|
321 else
|
|
killermonkey99@36
|
322 return false, ""
|
|
Aaron@16
|
323 end
|
|
Aaron@16
|
324 end
|
|
Aaron@16
|
325
|
|
Aaron@16
|
326 function safe_cache_vendor()
|
|
Aaron@16
|
327 if(not profile.location_cache[UnitName("NPC")]) then
|
|
Aaron@16
|
328 SetMapToCurrentZone()
|
|
Aaron@16
|
329 local pos = {}
|
|
Aaron@16
|
330 pos.x, pos.y = GetPlayerMapPosition("player")
|
|
killermonkey99@51
|
331 pos.map = GetCurrentMapAreaID();
|
|
Aaron@16
|
332 profile.location_cache[UnitName("NPC")] = pos
|
|
Aaron@16
|
333 end
|
|
Aaron@16
|
334 end
|
|
Aaron@15
|
335
|
|
Aaron@9
|
336 function button_update(self)
|
|
Aaron@9
|
337 local buttonName = _G[self:GetName().."Name"];
|
|
Aaron@9
|
338 local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID());
|
|
Aaron@9
|
339 if(not link) then
|
|
Aaron@9
|
340 return;
|
|
Aaron@9
|
341 end
|
|
Aaron@9
|
342
|
|
Aaron@9
|
343 local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(link)
|
|
Aaron@9
|
344
|
|
Aaron@16
|
345 if(sType == "Recipe" and safeRecipes[sName]) then
|
|
Aaron@16
|
346 safe_cache_vendor();
|
|
Aaron@9
|
347 SetItemButtonNameFrameVertexColor(self, 0, 0, 1.0);
|
|
Aaron@9
|
348 SetItemButtonSlotVertexColor(self, 0, 0, 0.5);
|
|
Aaron@9
|
349 buttonName:SetText("* " .. sName)
|
|
Aaron@28
|
350
|
|
Aaron@9
|
351 if(GetItemCount(link, true) == 0) then
|
|
Aaron@9
|
352 buttonName:SetTextColor(0,1,1);
|
|
Aaron@9
|
353 elseif(GetItemCount(link, true) < 5) then
|
|
Aaron@9
|
354 buttonName:SetTextColor(1,0,1);
|
|
Aaron@9
|
355 else
|
|
Aaron@9
|
356 buttonName:SetTextColor(1,0,0);
|
|
Aaron@9
|
357 end
|
|
Aaron@28
|
358
|
|
Aaron@9
|
359 else
|
|
Aaron@9
|
360 buttonName:SetTextColor(GameFontNormalSmall:GetTextColor());
|
|
Aaron@9
|
361 end
|
|
Aaron@9
|
362 end
|
|
Aaron@9
|
363
|
|
Aaron@16
|
364 function find_good_id(x, y)
|
|
Aaron@0
|
365 if ids[x.." "..y] then
|
|
Aaron@16
|
366 return find_good_id(x + .01, y)
|
|
Aaron@0
|
367 end
|
|
Aaron@0
|
368
|
|
Aaron@0
|
369 ids[x.." "..y] = true
|
|
Aaron@0
|
370 return x, y
|
|
Aaron@17
|
371 end
|
|
Aaron@17
|
372
|
|
Aaron@17
|
373 local lastNodeTextureId = 0;
|
|
Aaron@17
|
374
|
|
Aaron@17
|
375 function get_next_texture_id()
|
|
Aaron@17
|
376 lastNodeTextureId = lastNodeTextureId + 1;
|
|
Aaron@17
|
377 return lastNodeTextureId;
|
|
Aaron@17
|
378 end
|
|
Aaron@17
|
379
|
|
Aaron@17
|
380 function set_node_constants()
|
|
Aaron@17
|
381 GatherMate.nodeIDs["RecipeProfit"] = {}
|
|
Aaron@17
|
382 GatherMate.nodeTextures["RecipeProfit"] = {}
|
|
Aaron@17
|
383 GatherMate.nodeMinHarvest["RecipeProfit"] = {}
|
|
Aaron@17
|
384
|
|
Aaron@17
|
385 local nodes = GatherMate.nodeIDs["RecipeProfit"]
|
|
killermonkey99@36
|
386 for id, note in pairs(RECIPEPROFIT_database) do
|
|
Aaron@17
|
387 safeRecipes[note.item] = true;
|
|
Aaron@24
|
388 local id = get_next_texture_id();
|
|
killermonkey99@36
|
389
|
|
killermonkey99@36
|
390 nodes[get_note_title(note, "")] = id;
|
|
Aaron@24
|
391 nodeLookup[id] = note;
|
|
Aaron@17
|
392 end
|
|
Aaron@17
|
393
|
|
Aaron@17
|
394 for i = 1, lastNodeTextureId, 1 do
|
|
Aaron@17
|
395 GatherMate.nodeTextures["RecipeProfit"][i] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@17
|
396 end
|
|
Aaron@17
|
397
|
|
Aaron@17
|
398 GatherMate.reverseNodeIDs["RecipeProfit"] = GatherMate:CreateReversedTable(nodes)
|
|
Aaron@17
|
399 end
|
|
Aaron@17
|
400
|
|
Aaron@17
|
401 function inject_options()
|
|
killermonkey99@36
|
402 local acr = LibStub("AceConfigRegistry-3.0")
|
|
killermonkey99@36
|
403 acr:GetOptionsTable("GatherMate 2", "dialog", "RecipeProfit-1.0").args["showRecipeProfit"] = {
|
|
killermonkey99@36
|
404 order = 7,
|
|
Aaron@17
|
405 name = "Show RecipeProfit nodes.",
|
|
Aaron@17
|
406 desc = "Toggle showing nodes added by RecipeProfit.",
|
|
Aaron@17
|
407 type = "select",
|
|
Aaron@17
|
408 values = {
|
|
killermonkey99@36
|
409 always = "Always show",
|
|
killermonkey99@36
|
410 never = "Never show",
|
|
Aaron@17
|
411 },
|
|
Aaron@17
|
412 arg = "RecipeProfit",
|
|
Aaron@17
|
413 }
|
|
Aaron@17
|
414
|
|
killermonkey99@36
|
415 GatherMate:GetModule("Config"):SendMessage("GatherMate2ConfigChanged")
|
|
Aaron@17
|
416 end
|
|
Aaron@24
|
417
|
|
Aaron@24
|
418 function get_colored_note_name(self, nodeID)
|
|
Aaron@24
|
419 local text = self.reverseNodeIDs["RecipeProfit"][nodeID]
|
|
Aaron@24
|
420 local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(nodeLookup[nodeID].itementry)
|
|
Aaron@24
|
421
|
|
Aaron@24
|
422 if(not sLink) then
|
|
killermonkey99@36
|
423 RecipeProfit:ScheduleTimer("UpdateButtons", 3)
|
|
killermonkey99@36
|
424 return "|cFF000000(??) |cFF66DD66" .. text .. "|cFFFF0000 Please Wait (Querying Server)..."
|
|
Aaron@24
|
425 end
|
|
Aaron@24
|
426
|
|
Aaron@24
|
427 local count = GetItemCount(sLink, true)
|
|
Aaron@24
|
428 local prefix = "|cFF888888(" .. count .. ") |cFF66DD66"
|
|
Aaron@24
|
429
|
|
Aaron@24
|
430 if(count == 0) then
|
|
Aaron@24
|
431 prefix = "|cFF00FFFF(" .. count .. ") |cFF66DD66"
|
|
Aaron@24
|
432 elseif(count >= 5) then
|
|
Aaron@24
|
433 prefix = "|cFFFF0000(" .. count .. ") |cFF66DD66"
|
|
Aaron@24
|
434 end
|
|
Aaron@24
|
435
|
|
Aaron@24
|
436 return prefix .. text
|
|
Aaron@24
|
437 end
|
|
killermonkey99@51
|
438
|
|
killermonkey99@51
|
439
|
|
killermonkey99@51
|
440
|
|
killermonkey99@51
|
441
|
|
killermonkey99@51
|
442
|
|
killermonkey99@51
|
443
|
|
killermonkey99@51
|
444
|
|
killermonkey99@51
|
445
|
|
killermonkey99@51
|
446
|
|
killermonkey99@51
|
447 --[[ Debug Commands ]]
|
|
killermonkey99@51
|
448 --[[
|
|
killermonkey99@51
|
449 set_var,
|
|
killermonkey99@51
|
450 get_var,
|
|
killermonkey99@51
|
451 show_help,
|
|
killermonkey99@51
|
452 blacklist_add,
|
|
killermonkey99@51
|
453 blacklist_show
|
|
killermonkey99@51
|
454 --]]
|
|
killermonkey99@51
|
455
|
|
killermonkey99@51
|
456 function set_var(input)
|
|
killermonkey99@51
|
457 print("set_var")
|
|
killermonkey99@51
|
458 end
|
|
killermonkey99@51
|
459
|
|
killermonkey99@51
|
460 function get_var(input)
|
|
killermonkey99@51
|
461 print("get_var")
|
|
killermonkey99@51
|
462 end
|
|
killermonkey99@51
|
463
|
|
killermonkey99@51
|
464 function show_help(input)
|
|
killermonkey99@51
|
465 print("show_help")
|
|
killermonkey99@51
|
466 end
|
|
killermonkey99@51
|
467
|
|
killermonkey99@51
|
468 function blacklist_add(input)
|
|
killermonkey99@51
|
469 if(not profile["blacklist"]) then
|
|
killermonkey99@51
|
470 profile["blacklist"] = {}
|
|
killermonkey99@51
|
471 end
|
|
killermonkey99@51
|
472 _, _, val = RecipeProfit:GetArgs(input,3)
|
|
killermonkey99@51
|
473 table.insert(profile.blacklist, val)
|
|
killermonkey99@51
|
474 print("Added npc id \""..val.."\"to NPC blacklist.");
|
|
killermonkey99@51
|
475 end
|
|
killermonkey99@51
|
476
|
|
killermonkey99@51
|
477 function blacklist_show(input)
|
|
killermonkey99@51
|
478 if(not profile["blacklist"]) then
|
|
killermonkey99@51
|
479 profile["blacklist"] = {}
|
|
killermonkey99@51
|
480 end
|
|
killermonkey99@51
|
481
|
|
killermonkey99@51
|
482 for k,v in ipairs(profile.blacklist) do
|
|
killermonkey99@51
|
483 print(k..": "..v)
|
|
killermonkey99@51
|
484 end
|
|
killermonkey99@51
|
485 end
|
|
killermonkey99@51
|
486
|
|
killermonkey99@51
|
487 function blacklist_query(input)
|
|
killermonkey99@51
|
488 _, _, val = RecipeProfit:GetArgs(input,3)
|
|
killermonkey99@51
|
489 if(not val) then
|
|
killermonkey99@51
|
490 print("oops")
|
|
killermonkey99@51
|
491 return
|
|
killermonkey99@51
|
492 end
|
|
killermonkey99@51
|
493
|
|
killermonkey99@51
|
494 entries = {};
|
|
killermonkey99@51
|
495 for _,note in pairs(RECIPEPROFIT_database) do
|
|
killermonkey99@51
|
496 if(note.vendor:lower():find(val:lower()) and not entries[note.entry]) then
|
|
killermonkey99@51
|
497 entries[note.entry] = true;
|
|
killermonkey99@51
|
498 print(note.vendor.." (ID "..note.entry.."): "..note.x..", "..note.y)
|
|
killermonkey99@51
|
499 end
|
|
killermonkey99@51
|
500 end
|
|
killermonkey99@51
|
501 end
|
|
killermonkey99@51
|
502
|
|
killermonkey99@51
|
503 commandList = {
|
|
killermonkey99@51
|
504 set = set_var,
|
|
killermonkey99@51
|
505 get = get_var,
|
|
killermonkey99@51
|
506 help = show_help,
|
|
killermonkey99@51
|
507 blacklist = {
|
|
killermonkey99@51
|
508 query = blacklist_query,
|
|
killermonkey99@51
|
509 add = blacklist_add,
|
|
killermonkey99@51
|
510 show = blacklist_show
|
|
killermonkey99@51
|
511 }
|
|
killermonkey99@51
|
512 }
|
|
killermonkey99@51
|
513
|