|
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@12
|
14 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0")
|
|
Aaron@0
|
15 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate")
|
|
Aaron@0
|
16 local tabletest = {}
|
|
Aaron@7
|
17 db = {}
|
|
Aaron@1
|
18 local safeRecipes = {}
|
|
Aaron@1
|
19 safer = safeRecipes
|
|
Aaron@0
|
20 RecipeProfit.db = db;
|
|
Aaron@0
|
21
|
|
Aaron@0
|
22 function debugprint(val, indent)
|
|
Aaron@0
|
23 indent = indent or "";
|
|
Aaron@0
|
24 if not(type(val) == "table") then
|
|
Aaron@0
|
25 print("Not table: " .. val)
|
|
Aaron@0
|
26 return
|
|
Aaron@0
|
27 end
|
|
Aaron@0
|
28
|
|
Aaron@0
|
29 for k,v in pairs(val) do
|
|
Aaron@0
|
30 if(type(k) == "table" and type(v) == "table") then
|
|
Aaron@0
|
31 print(indent .. "table key: {")
|
|
Aaron@0
|
32 debugprint(k, indent .. " ")
|
|
Aaron@0
|
33 print(indent .. "} = {")
|
|
Aaron@0
|
34 debugprint(v, indent .. " ")
|
|
Aaron@0
|
35 print(indent .. "}")
|
|
Aaron@12
|
36 elseif(type(v) == "table") then
|
|
Aaron@0
|
37 print(indent .. k .. " = {")
|
|
Aaron@0
|
38 debugprint(v, indent .. " ")
|
|
Aaron@0
|
39 print(indent .. "}")
|
|
Aaron@0
|
40 else
|
|
Aaron@12
|
41 if(type(v) ~= "boolean") then
|
|
Aaron@12
|
42 print(indent .. k .. " = " .. v)
|
|
Aaron@12
|
43 else
|
|
Aaron@12
|
44 print(indent .. k .. " = " .. (v and "true" or "false"))
|
|
Aaron@12
|
45 end
|
|
Aaron@0
|
46 end
|
|
Aaron@0
|
47 end
|
|
Aaron@0
|
48 end
|
|
Aaron@8
|
49
|
|
Aaron@7
|
50 local defaultProfile = {
|
|
Aaron@7
|
51 ["show"] = {
|
|
Aaron@7
|
52 ["RecipeProfit"] = "always",
|
|
Aaron@7
|
53 ["Herb Gathering"] = "never",
|
|
Aaron@7
|
54 ["Extract Gas"] = "never",
|
|
Aaron@7
|
55 ["Fishing"] = "never",
|
|
Aaron@7
|
56 ["Mining"] = "never",
|
|
Aaron@7
|
57 ["Treasure"] = "never",
|
|
Aaron@7
|
58 },
|
|
Aaron@8
|
59 ["trackShow"] = "active",
|
|
Aaron@7
|
60 }
|
|
Aaron@0
|
61
|
|
Aaron@0
|
62 local options = {
|
|
Aaron@0
|
63 type = "group",
|
|
Aaron@0
|
64 name = "RecipeProfit", -- addon name to import from, don't localize
|
|
Aaron@0
|
65 handler = {},
|
|
Aaron@0
|
66 disabled = false,
|
|
Aaron@0
|
67 args = {
|
|
Aaron@1
|
68 opt = {
|
|
Aaron@0
|
69 order = 1,
|
|
Aaron@0
|
70 name = "Select Database",
|
|
Aaron@0
|
71 desc = "Show a different database",
|
|
Aaron@0
|
72 type = "group",
|
|
Aaron@0
|
73 guiInline = true,
|
|
Aaron@0
|
74 args = {
|
|
Aaron@0
|
75 faction = {
|
|
Aaron@0
|
76 order = 0,
|
|
Aaron@0
|
77 name = "Faction",
|
|
Aaron@0
|
78 desc = "Show a different database.",
|
|
Aaron@0
|
79 type = "select",
|
|
Aaron@0
|
80 values = {
|
|
Aaron@0
|
81 ["Alliance"] = "Alliance",
|
|
Aaron@0
|
82 ["Horde"] = "Horde",
|
|
Aaron@1
|
83 ["default"] = "Default",
|
|
Aaron@0
|
84 },
|
|
Aaron@0
|
85 arg = "faction",
|
|
Aaron@0
|
86 },
|
|
Aaron@1
|
87
|
|
Aaron@1
|
88 safeBuy = {
|
|
Aaron@1
|
89 order = 1,
|
|
Aaron@1
|
90 name = "Safe Recipe Buy",
|
|
Aaron@1
|
91 desc = "Warn when buying a recipe not on the RecipeProfit list.",
|
|
Aaron@1
|
92 type = "select",
|
|
Aaron@1
|
93 values = {
|
|
Aaron@7
|
94 --["on"] = "On",
|
|
Aaron@1
|
95 ["off"]= "Off",
|
|
Aaron@1
|
96 },
|
|
Aaron@1
|
97 arg = "safebuy",
|
|
Aaron@1
|
98 },
|
|
Aaron@0
|
99 },
|
|
Aaron@1
|
100 get = function(k) return db.profile[k.arg]; end,
|
|
Aaron@0
|
101 set = function(k, v) db.profile[k.arg] = v; RecipeProfit:DoMerge(); end,
|
|
Aaron@0
|
102 },
|
|
Aaron@0
|
103 loadData = {
|
|
Aaron@0
|
104 order = 8,
|
|
Aaron@0
|
105 name = "Import Data",
|
|
Aaron@0
|
106 desc = "Load RecipeProfit and import the data to your database.",
|
|
Aaron@0
|
107 type = "execute",
|
|
Aaron@0
|
108 func = function()
|
|
Aaron@0
|
109 RecipeProfit:DoMerge()
|
|
Aaron@0
|
110 end
|
|
Aaron@0
|
111 },
|
|
Aaron@7
|
112 loadProfile = {
|
|
Aaron@7
|
113 order = 9,
|
|
Aaron@7
|
114 name = "Load RecipeProfit Profile",
|
|
Aaron@7
|
115 desc = "Loads the RecipeProfit Profile into Gathermate for easy recipe tracking.",
|
|
Aaron@7
|
116 type = "execute",
|
|
Aaron@7
|
117 func = function()
|
|
Aaron@7
|
118 GatherMate.db.profiles["RecipeProfit"] = GatherMate.db.profiles["RecipeProfit"] or {}
|
|
Aaron@7
|
119 gmdb = GatherMate.db.profiles["RecipeProfit"]
|
|
Aaron@7
|
120 for k, v in pairs(defaultProfile) do
|
|
Aaron@7
|
121 gmdb[k] = v;
|
|
Aaron@7
|
122 end
|
|
Aaron@7
|
123 GatherMate:SendMessage("OnProfileChanged");
|
|
Aaron@7
|
124 GatherMate:GetModule("Config"):UpdateConfig()
|
|
Aaron@7
|
125 GatherMate:SendMessage("GatherMateConfigChanged")
|
|
Aaron@7
|
126 GatherMate.db:SetProfile("RecipeProfit")
|
|
Aaron@7
|
127 end
|
|
Aaron@7
|
128 },
|
|
Aaron@0
|
129 }
|
|
Aaron@0
|
130 }
|
|
Aaron@0
|
131
|
|
Aaron@0
|
132 local defaults = {
|
|
Aaron@1
|
133 faction = "default",
|
|
Aaron@1
|
134 safebuy = "on",
|
|
Aaron@0
|
135 }
|
|
Aaron@0
|
136
|
|
Aaron@0
|
137 function RecipeProfit:OnInitialize()
|
|
Aaron@0
|
138 profile = profile or defaults
|
|
Aaron@7
|
139
|
|
Aaron@1
|
140 for k, v in pairs(defaults) do
|
|
Aaron@1
|
141 profile[k] = profile[k] or v;
|
|
Aaron@1
|
142 end
|
|
Aaron@1
|
143
|
|
Aaron@12
|
144 self:RegisterChatCommand("recipeprofit", "ShowOptions")
|
|
Aaron@12
|
145 self:RegisterChatCommand("rp", "ShowOptions")
|
|
Aaron@12
|
146 self:RegisterChatCommand("profit", "ShowOptions")
|
|
Aaron@12
|
147
|
|
Aaron@0
|
148 db.profile = profile
|
|
Aaron@0
|
149 db.storage = {}
|
|
Aaron@0
|
150
|
|
Aaron@0
|
151 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options)
|
|
Aaron@0
|
152 GatherMate:RegisterDBType("RecipeProfit", db.storage)
|
|
Aaron@8
|
153 GatherMate.db.profile.show["RecipeProfit"] = GatherMate.db.profile.show["RecipeProfit"] or "always"
|
|
Aaron@0
|
154 GatherMate.nodeIDs["RecipeProfit"] = {}
|
|
Aaron@0
|
155 GatherMate.nodeTextures["RecipeProfit"] = {}
|
|
Aaron@0
|
156 GatherMate.nodeMinHarvest["RecipeProfit"] = {}
|
|
Aaron@0
|
157 nodes = GatherMate.nodeIDs["RecipeProfit"]
|
|
Aaron@0
|
158
|
|
Aaron@0
|
159 for id, note in pairs(RECIPEPROFIT_alliance) do
|
|
Aaron@1
|
160 safeRecipes[note.item] = true;
|
|
Aaron@0
|
161 nodes[note.item.." - ("..note.vendor.." A)"] = id * 10
|
|
Aaron@0
|
162 GatherMate.nodeTextures["RecipeProfit"][id * 10] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
163 end
|
|
Aaron@0
|
164
|
|
Aaron@0
|
165 for id, note in pairs(RECIPEPROFIT_horde) do
|
|
Aaron@1
|
166 safeRecipes[note.item] = true;
|
|
Aaron@0
|
167 nodes[note.item.." - ("..note.vendor.." H)"] = id * 10 + 1
|
|
Aaron@0
|
168 GatherMate.nodeTextures["RecipeProfit"][id * 10 + 1] = "Interface\\Icons\\INV_Scroll_05"
|
|
Aaron@0
|
169 end
|
|
Aaron@0
|
170
|
|
Aaron@0
|
171 GatherMate.reverseNodeIDs["RecipeProfit"] = GatherMate:CreateReversedTable(nodes)
|
|
Aaron@8
|
172
|
|
Aaron@8
|
173 GatherMate:GetModule("Config").options.args.display.args.general.args.showGroup.args["showRecipeProfit"] = {
|
|
Aaron@8
|
174 order = 6,
|
|
Aaron@8
|
175 name = "Show RecipeProfit nodes.",
|
|
Aaron@8
|
176 desc = "Toggle showing nodes added by RecipeProfit.",
|
|
Aaron@8
|
177 type = "select",
|
|
Aaron@8
|
178 values = {
|
|
Aaron@8
|
179 ["always"] = "Always show",
|
|
Aaron@8
|
180 ["never"] = "Never show",
|
|
Aaron@8
|
181 },
|
|
Aaron@8
|
182 arg = "RecipeProfit",
|
|
Aaron@8
|
183 }
|
|
Aaron@8
|
184
|
|
Aaron@8
|
185 GatherMate:GetModule("Config").options.args.display.args.general.args.iconGroup.args.tracking.args["showRecipeProfit"] = {
|
|
Aaron@8
|
186 order = 6.5,
|
|
Aaron@8
|
187 name = "RecipeProfit",
|
|
Aaron@8
|
188 desc = "Color of the tracking circle.",
|
|
Aaron@8
|
189 type = "color",
|
|
Aaron@8
|
190 hasAlpha = true,
|
|
Aaron@8
|
191 arg = "RecipeProfit",
|
|
Aaron@8
|
192 }
|
|
Aaron@8
|
193
|
|
Aaron@0
|
194 GatherMate:GetModule("Config"):UpdateConfig()
|
|
Aaron@0
|
195 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
196 end
|
|
Aaron@0
|
197
|
|
Aaron@12
|
198 function RecipeProfit:ShowOptions()
|
|
Aaron@13
|
199 LibStub("AceConfigDialog-3.0"):Open("GatherMate")
|
|
Aaron@13
|
200 LibStub("AceConfigDialog-3.0"):SelectGroup("GatherMate", "RecipeProfit")
|
|
Aaron@12
|
201 end
|
|
Aaron@12
|
202
|
|
Aaron@15
|
203
|
|
Aaron@9
|
204 function button_update(self)
|
|
Aaron@9
|
205 local buttonName = _G[self:GetName().."Name"];
|
|
Aaron@9
|
206 local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID());
|
|
Aaron@9
|
207 if(not link) then
|
|
Aaron@9
|
208 return;
|
|
Aaron@9
|
209 end
|
|
Aaron@9
|
210
|
|
Aaron@9
|
211 local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(link)
|
|
Aaron@9
|
212
|
|
Aaron@9
|
213 if(sType == "Recipe" and safeRecipes[sName]) then
|
|
Aaron@9
|
214 SetItemButtonNameFrameVertexColor(self, 0, 0, 1.0);
|
|
Aaron@9
|
215 SetItemButtonSlotVertexColor(self, 0, 0, 0.5);
|
|
Aaron@9
|
216 buttonName:SetText("* " .. sName)
|
|
Aaron@9
|
217 if(GetItemCount(link, true) == 0) then
|
|
Aaron@9
|
218 buttonName:SetTextColor(0,1,1);
|
|
Aaron@9
|
219 elseif(GetItemCount(link, true) < 5) then
|
|
Aaron@9
|
220 buttonName:SetTextColor(1,0,1);
|
|
Aaron@9
|
221 else
|
|
Aaron@9
|
222 buttonName:SetTextColor(1,0,0);
|
|
Aaron@9
|
223 end
|
|
Aaron@9
|
224 else
|
|
Aaron@9
|
225 buttonName:SetTextColor(GameFontNormalSmall:GetTextColor());
|
|
Aaron@9
|
226 end
|
|
Aaron@9
|
227 end
|
|
Aaron@9
|
228
|
|
Aaron@9
|
229 function RecipeProfit:UpdateButtons(event)
|
|
Aaron@9
|
230 --print("UpdateButtons", event)
|
|
Aaron@12
|
231 if(not MerchantFrame:IsVisible()) then
|
|
Aaron@12
|
232 --print("UpdateButtons - (Event: ", event, ") - MerchantFrame not visible.");
|
|
Aaron@12
|
233 return;
|
|
Aaron@12
|
234 end
|
|
Aaron@12
|
235
|
|
Aaron@1
|
236 for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do
|
|
Aaron@1
|
237 local buttonframe = _G["MerchantItem"..i];
|
|
Aaron@9
|
238 local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i);
|
|
Aaron@9
|
239 --print(index)
|
|
Aaron@9
|
240 if index <= GetMerchantNumItems() then
|
|
Aaron@9
|
241 button_update(buttonframe)
|
|
Aaron@12
|
242 --[[else
|
|
Aaron@9
|
243 --print(i, index, GetMerchantNumItems())
|
|
Aaron@9
|
244 local itemButton = _G["MerchantItem"..i.."ItemButton"];
|
|
Aaron@9
|
245 local merchantButton = _G["MerchantItem"..i];
|
|
Aaron@9
|
246 itemButton.price = nil;
|
|
Aaron@9
|
247 itemButton.hasItem = nil;
|
|
Aaron@9
|
248 itemButton:Hide();
|
|
Aaron@9
|
249 SetItemButtonNameFrameVertexColor(merchantButton, 0.5, 0.5, 0.5);
|
|
Aaron@9
|
250 SetItemButtonSlotVertexColor(merchantButton,0.4, 0.4, 0.4);
|
|
Aaron@9
|
251 _G["MerchantItem"..i.."Name"]:SetText("");
|
|
Aaron@9
|
252 _G["MerchantItem"..i.."MoneyFrame"]:Hide();
|
|
Aaron@9
|
253 _G["MerchantItem"..i.."AltCurrencyFrame"]:Hide();
|
|
Aaron@12
|
254 ]]
|
|
Aaron@9
|
255 end
|
|
Aaron@9
|
256 end
|
|
Aaron@9
|
257 end
|
|
Aaron@9
|
258
|
|
Aaron@1
|
259
|
|
Aaron@9
|
260 function RecipeProfit:OnEnable()
|
|
Aaron@7
|
261
|
|
Aaron@9
|
262 _G["MerchantPrevPageButton"]:HookScript("OnClick", self.UpdateButtons)
|
|
Aaron@9
|
263 _G["MerchantNextPageButton"]:HookScript("OnClick", self.UpdateButtons)
|
|
Aaron@9
|
264
|
|
Aaron@9
|
265 self:RegisterEvent("MERCHANT_SHOW", "UpdateButtons")
|
|
Aaron@9
|
266 self:RegisterEvent("MERCHANT_UPDATE", "UpdateButtons")
|
|
Aaron@12
|
267 self:RegisterEvent("BAG_UPDATE", "UpdateButtons")
|
|
Aaron@7
|
268
|
|
Aaron@7
|
269 RecipeProfit:DoMerge()
|
|
Aaron@0
|
270 end
|
|
Aaron@0
|
271
|
|
Aaron@0
|
272 local ids = {}
|
|
Aaron@0
|
273 function findGoodId(x, y)
|
|
Aaron@0
|
274 if ids[x.." "..y] then
|
|
Aaron@0
|
275 return findGoodId(x + .01, y)
|
|
Aaron@0
|
276 end
|
|
Aaron@0
|
277
|
|
Aaron@0
|
278 ids[x.." "..y] = true
|
|
Aaron@0
|
279 return x, y
|
|
Aaron@0
|
280 end
|
|
Aaron@0
|
281
|
|
Aaron@0
|
282 function RecipeProfit:DoMerge()
|
|
Aaron@0
|
283 ids = {}
|
|
Aaron@7
|
284 selectedDB = (db.profile.faction == "Alliance" or
|
|
Aaron@7
|
285 db.profile.faction == "default" and UnitFactionGroup("player") == "Alliance") and
|
|
Aaron@1
|
286 RECIPEPROFIT_alliance or RECIPEPROFIT_horde
|
|
Aaron@0
|
287 GatherMate:ClearDB("RecipeProfit")
|
|
Aaron@1
|
288 for id, note in pairs(selectedDB) do
|
|
Aaron@0
|
289 x, y = findGoodId(note.x, note.y)
|
|
Aaron@0
|
290 GatherMate:AddNode(note.map, x / 100, y / 100, "RecipeProfit",
|
|
Aaron@7
|
291 note.item.." - ("..note.vendor.." "..
|
|
Aaron@7
|
292 ((db.profile.faction == "Alliance" or db.profile.faction == "default" and
|
|
Aaron@7
|
293 UnitFactionGroup("player") == "Alliance") and "A" or "H") ..")")
|
|
Aaron@0
|
294 end
|
|
Aaron@0
|
295
|
|
Aaron@0
|
296 GatherMate:SendMessage("GatherMateDataImport")
|
|
Aaron@0
|
297 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
|
|
Aaron@0
|
298 end
|