vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[-------------------------------------------------------------------------------- |
2 | ItemSync Framework |
||
3 | |||
4 | Author: Derkyle |
||
5 | Website: http://www.manaflux.com |
||
6 | -----------------------------------------------------------------------------------]] |
||
7 | |||
8 | ISYNC_VERSION = 12.4; --version |
||
9 | |||
10 | --EMBED |
||
11 | ISync = {}; |
||
12 | |||
13 | --REALM_NUM |
||
14 | ISYNC_REALM_NUM = 0; |
||
15 | |||
16 | --GLOBALS |
||
17 | ISYNC_LOADYES = 0; |
||
18 | ISYNC_VARLOAD = 0; |
||
19 | ISYNC_LOADONCE = 0; |
||
20 | ISYNC_DB_MAX = 12; |
||
21 | |||
22 | |||
23 | --HOOKS |
||
24 | local ISync_HookedMoney; |
||
25 | local ISync_HookedOnShow; |
||
26 | |||
27 | local ISChatRepChk = ""; |
||
28 | local SetDB_RepeatChk = ""; |
||
29 | local ItemSync_MouseArray = { }; |
||
30 | |||
31 | |||
32 | --------------------------------------------------- |
||
33 | -- ISync:PrimaryLoad() |
||
34 | --------------------------------------------------- |
||
35 | function ISync:PrimaryLoad() |
||
36 | |||
37 | --display loaded |
||
38 | if( DEFAULT_CHAT_FRAME ) then |
||
39 | DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FDerkyle's ItemSync Ver. ["..ISYNC_VERSION.."]|r |cffffffffType: /itemsync /isync /ims /is"); |
||
40 | end |
||
41 | |||
42 | -- Register our slash command |
||
43 | --------------------------------------------------- |
||
44 | SLASH_ITEMSYNC1 = "/itemsync"; |
||
45 | SLASH_ITEMSYNC2 = "/isync"; |
||
46 | SLASH_ITEMSYNC3 = "/ims"; |
||
47 | SLASH_ITEMSYNC4 = "/is"; |
||
48 | SlashCmdList["ITEMSYNC"] = ISync_SlashCommand; |
||
49 | |||
50 | |||
51 | --this is for AxuItemMenus :) Thanks Axu! |
||
52 | if (AxuItemMenus_AddConfigToggle) then |
||
53 | |||
54 | AxuItemMenus_AddConfigToggle({ |
||
55 | id = "isync", -- this appears in my previous snippet |
||
56 | default = true, -- feature enabled by default |
||
57 | -- consider localizing the following: |
||
58 | text = "ItemSync", |
||
59 | helptext = "Enable pop-up menus in ItemSync" |
||
60 | }); |
||
61 | end |
||
62 | |||
63 | tinsert(UISpecialFrames, "ISync_MainFrame"); |
||
64 | |||
65 | end |
||
66 | |||
67 | |||
68 | --------------------------------------------------- |
||
69 | -- ISync:OnPrimaryEvent() |
||
70 | --------------------------------------------------- |
||
71 | function ISync:OnPrimaryEvent(event,arg1,arg2,arg3,arg4,arg5) |
||
72 | |||
73 | |||
74 | if( event == "VARIABLES_LOADED" ) then |
||
75 | |||
76 | --enable primary data structure |
||
77 | if( not ISyncDB ) then ISyncDB = { }; end |
||
78 | if( not ISyncDB_Names ) then ISyncDB_Names = { }; end |
||
79 | |||
80 | --check favorites |
||
81 | if( not ISyncFav ) then ISyncFav = { }; end |
||
82 | if( not ISyncFav[UnitName("player")] ) then ISyncFav[UnitName("player")] = { }; end |
||
83 | |||
84 | --check for old version, if we are starting fresh add it as current |
||
85 | if(ISyncOpt and ISyncOpt.Version) then |
||
86 | ISync:SetVar({"ISYNC_VER","OLDVERSION"}, ISyncOpt.Version); |
||
87 | ISyncOpt = nil; |
||
88 | ISyncOpt = { }; --delete it so we can recreate |
||
89 | |||
90 | -- ISync_DBPopUp:Show(); |
||
91 | |||
92 | elseif(not ISync:SetVar({"ISYNC_VER","OLDVERSION"}, ISYNC_VERSION, "CHK")) then |
||
93 | ISync:SetVar({"ISYNC_VER","OLDVERSION"}, ISYNC_VERSION); |
||
94 | |||
95 | -- ISync_DBPopUp:Show(); |
||
96 | end |
||
97 | |||
98 | --reset |
||
99 | GameTooltip.isDisplayDone = nil; |
||
100 | GameTooltip.SendtoMods = nil; |
||
101 | |||
102 | --options check and set |
||
103 | ISync:SetVar({"OPT","PRICE"}, 1); |
||
104 | ISync:SetVar({"OPT","VENDOR"}, 1); |
||
105 | ISync:SetVar({"OPT","MONEYSET"}, 1); |
||
106 | ISync:SetVar({"OPT","ITEMCOUNTDISPLAY"}, 0); |
||
107 | ISync:SetVar({"OPT","RARITY_DD"}, "name"); |
||
108 | ISync:SetVar({"OPT","SHOWMONEYICONS"}, 0); |
||
109 | ISync:SetVar({"OPT","ITEMCOUNT_VALID"}, 0); |
||
110 | ISync:SetVar({"OPT","ITEMCOUNT_INVALID"}, 0); |
||
111 | ISync:SetVar({"OPT","MINIMAP_SHOW"}, 0); |
||
112 | ISync:SetVar({"OPT","MINIMAP_LOC"}, 305); |
||
113 | ISync:SetVar({"OPT","TOOLTIPITEMICONS"}, 1); |
||
114 | ISync:SetVar({"OPT","LINKFETCH"}, 0); |
||
115 | ISync:SetVar({"OPT","MOUSEOVERINSPECT"}, 1); |
||
116 | --layout |
||
117 | ISync:SetVar({"LAYOUT","GOLD"}, "|c00FFFFFF%s|r|c00E2CD54"..ISYNC_OPTGOLD1.."|r "); |
||
118 | ISync:SetVar({"LAYOUT","SILVER"}, "|c00FFFFFF%s|r|c00AEAEAE"..ISYNC_OPTSILVER1.."|r "); |
||
119 | ISync:SetVar({"LAYOUT","COPPER"}, "|c00FFFFFF%s|r|c00D7844D"..ISYNC_OPTCOPPER1.."|r"); |
||
120 | --alerts |
||
121 | ISync:SetVar({"ALERT","QUALITY"}, 0); |
||
122 | ISync:SetVar({"ALERT","INVALID"}, 0); |
||
123 | --mods |
||
124 | ISync:SetVar({"MOD","AMAS"}, 0); |
||
125 | ISync:SetVar({"MOD","AUCTIONEER"}, 0); |
||
126 | ISync:SetVar({"MOD","REAGENTINFO"}, 0); |
||
127 | --filters |
||
128 | ISync:SetVar({"FILTERS",0}, 1); |
||
129 | ISync:SetVar({"FILTERS",1}, 1); |
||
130 | ISync:SetVar({"FILTERS",2}, 1); |
||
131 | ISync:SetVar({"FILTERS",3}, 1); |
||
132 | ISync:SetVar({"FILTERS",4}, 1); |
||
133 | ISync:SetVar({"FILTERS",5}, 1); |
||
134 | --bagview |
||
135 | ISync:SetVar({"BAGVIEW","SHOWSTACKED"}, 1); |
||
136 | ISync:SetVar({"BAGVIEW","SHOWNIL"}, 0); |
||
137 | ISync:SetVar({"BAGVIEW","SORT_VALUE"}, 1); |
||
138 | ISync:SetVar({"BAGVIEW","SORT_RARITY"}, 0); |
||
139 | --required refresh for new items |
||
140 | ISync:SetVar({"REQUIRED","REFRESH"}, 0); |
||
141 | |||
142 | |||
143 | --check for data |
||
144 | if (not ISync:GrabDataProfile() ) then |
||
145 | ISYNC_LOADYES = 0; |
||
146 | DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FItemSync:|r |cffffffffNo profile could be generated. ItemSync has been halted.|r"); |
||
147 | else |
||
148 | ISYNC_LOADYES = 1; |
||
149 | ISYNC_REALM_NUM = ISync:GrabDataProfile(); |
||
150 | end--if (not ISync:GrabDataProfile() ) then |
||
151 | |||
152 | |||
153 | ISync:Fav_DD_Load(); |
||
154 | ISync:MiniMapButton_Init(); |
||
155 | |||
156 | |||
157 | |||
158 | elseif( event == "PLAYER_TARGET_CHANGED" ) then |
||
159 | |||
160 | --check first |
||
161 | if(ISYNC_LOADYES == 1) then |
||
162 | if(not UnitIsUnit("target", "player") and UnitIsPlayer("target") ) then |
||
163 | ISync:InspectTarget("target"); |
||
164 | end |
||
165 | end |
||
166 | |||
167 | --mouseover |
||
168 | elseif( event == "UPDATE_MOUSEOVER_UNIT" ) then |
||
169 | |||
170 | --check first |
||
171 | if(ISYNC_LOADYES == 1) then |
||
172 | --check to see if the user allowed it |
||
173 | if(ISync:SetVar({"OPT","MOUSEOVERINSPECT"}, 1, "COMPARE")) then |
||
174 | if(not UnitIsUnit("mouseover", "player") and UnitIsPlayer("mouseover") ) then |
||
175 | ISync:InspectTarget("mouseover"); |
||
176 | end |
||
177 | end |
||
178 | end |
||
179 | |||
180 | --the inventory has been updated so lets check it again |
||
181 | elseif( event == "UNIT_INVENTORY_CHANGED" ) then |
||
182 | |||
183 | if(ISYNC_LOADYES == 1 and arg1 == "player" ) then ISync_CoreFrame.unitinvchanged = .2; end |
||
184 | |||
185 | --bank frame opened so lets scan that too |
||
186 | elseif( event == "BANKFRAME_OPENED" ) then |
||
187 | |||
188 | if(ISYNC_LOADYES == 1) then ISync:ScanBank(); end |
||
189 | |||
190 | --scan auction window |
||
191 | elseif( event == "AUCTION_ITEM_LIST_UPDATE" ) then |
||
192 | |||
193 | if(ISYNC_LOADYES == 1) then ISync:ScanAuction(); end |
||
194 | |||
195 | --scan merchant window |
||
196 | elseif( event == "MERCHANT_SHOW" ) then |
||
197 | |||
198 | if(ISYNC_LOADYES == 1) then ISync:MerchantMoneyScan(this); end |
||
199 | if(ISYNC_LOADYES == 1) then ISync:VendorScan(); end |
||
200 | if(ISYNC_LOADYES == 1) then ISync:BV_Refresh(); end |
||
201 | |||
202 | --scan tooltip money |
||
203 | elseif( event == "BAG_UPDATE" ) then |
||
204 | |||
205 | if(ISYNC_LOADYES == 1) then ISync_CoreFrame.bagupdate = .2; end |
||
206 | |||
207 | elseif ( event == "PLAYER_ENTERING_WORLD" ) then |
||
208 | |||
209 | if(ISYNC_LOADYES == 1 and ISYNC_LOADONCE == 0) then |
||
210 | |||
211 | |||
212 | ---VERSION CHECKS |
||
213 | ---------------------------------------------------------- |
||
214 | |||
215 | ISync:SetVar({"ISYNC_VER","VERSION"}, ISYNC_VERSION); --create if it doesn't exist |
||
216 | |||
217 | --check update |
||
218 | if(tonumber(ISync:SetVar({"ISYNC_VER","VERSION"}, ISYNC_VERSION)) < ISYNC_VERSION) then |
||
219 | |||
220 | ISync:CleanupDB(nil, nil); --force it |
||
221 | |||
222 | ISync:SetVar({"ISYNC_VER","VERSION"}, ISYNC_VERSION, "TRUE"); |
||
223 | |||
224 | end |
||
225 | ---------------------------------------------------------- |
||
226 | |||
227 | |||
228 | ISync:InspectTarget("player"); |
||
229 | ISync:ScanInv(); |
||
230 | ISync:ItemDisplay_Update(); |
||
231 | ISYNC_LOADONCE = 1; |
||
232 | |||
233 | end |
||
234 | |||
235 | --rest |
||
236 | else |
||
237 | |||
238 | --send to parse, it's chat information to be parsed |
||
239 | --since sometimes chat informations loves to send doubles lets check for that |
||
240 | if(ISYNC_LOADYES == 1 and arg1) then |
||
241 | |||
242 | --check for repeats |
||
243 | if(ISChatRepChk ~= event..arg1) then |
||
244 | ISChatRepChk = event..arg1; |
||
245 | ISync:ProcessLinks(arg1, "CHAT", nil, nil); |
||
246 | end |
||
247 | |||
248 | end |
||
249 | |||
250 | end--end event checks |
||
251 | |||
252 | |||
253 | end |
||
254 | |||
255 | |||
256 | |||
257 | --------------------------------------------------- |
||
258 | -- ISync:OnUpdateTriggered() |
||
259 | --------------------------------------------------- |
||
260 | function ISync:OnUpdateTriggered(elapsed) |
||
261 | |||
262 | --BAG_UPDATE |
||
263 | if(ISync_CoreFrame.bagupdate) then |
||
264 | |||
265 | --update the laspe |
||
266 | ISync_CoreFrame.bagupdate = ISync_CoreFrame.bagupdate - elapsed; |
||
267 | |||
268 | --check if the timer ran out |
||
269 | if ( ISync_CoreFrame.bagupdate <= 0 ) then |
||
270 | |||
271 | ISync:BV_Refresh(); |
||
272 | ISync_CoreFrame.bagupdate = nil; |
||
273 | |||
274 | end |
||
275 | |||
276 | end |
||
277 | |||
278 | |||
279 | --UNIT_INVENTORY_CHANGED |
||
280 | if(ISync_CoreFrame.unitinvchanged) then |
||
281 | |||
282 | --update the laspe |
||
283 | ISync_CoreFrame.unitinvchanged = ISync_CoreFrame.unitinvchanged - elapsed; |
||
284 | |||
285 | --check if the timer ran out |
||
286 | if ( ISync_CoreFrame.unitinvchanged <= 0 ) then |
||
287 | |||
288 | --inspect user and inventory |
||
289 | ISync:InspectTarget("player"); |
||
290 | ISync:ScanInv(); |
||
291 | ISync:BV_Refresh(); |
||
292 | ISync_CoreFrame.unitinvchanged = nil; |
||
293 | |||
294 | end |
||
295 | |||
296 | end |
||
297 | |||
298 | end |
||
299 | |||
300 | |||
301 | |||
302 | ----------------------------------------------------------------------------------------------------- |
||
303 | ----------------------------------------------------------------------------------------------------- |
||
304 | ----------------------------------------------------------------------------------------------------- |
||
305 | ----------------------------------------------------------------------------------------------------- |
||
306 | ----------------------------------------------------------------------------------------------------- |
||
307 | ----------------------------------------------------------------------------------------------------- |
||
308 | |||
309 | |||
310 | --------------------------------------------------- |
||
311 | -- ISync:ProcessLinks() |
||
312 | --------------------------------------------------- |
||
313 | function ISync:ProcessLinks(sText, sEvent, sVendorPrice, sVendorQty) |
||
314 | |||
315 | if(ISYNC_LOADYES == 0) then return nil; end --don't run if the profile didn't load |
||
316 | if(not sText) then return nil; end --no data no parsing |
||
317 | if(not ISyncDB) then return nil; end --the database should have been created |
||
318 | if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end --don't even bother |
||
319 | |||
320 | --locals |
||
321 | local item, name, color, sPL, xPL1, xPL2; |
||
322 | |||
323 | --do the loop |
||
324 | for color, item, name in string.gfind(sText, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do |
||
325 | |||
326 | --make sure we have data to process |
||
327 | if( color and item and name ) then |
||
328 | |||
329 | sPL = string.gsub(item, "^(%d+):(%d+):(%d+):(%d+)$", "%1:0:%3:0"); |
||
330 | xPL1 = string.gsub(item, "^(%d+):(%d+):(%d+):(%d+)$", "%1"); |
||
331 | xPL2 = string.gsub(item, "^(%d+):(%d+):(%d+):(%d+)$", "%3"); |
||
332 | |||
333 | if(not sPL or not xPL1 or not xPL2) then return nil; end --don't bother |
||
334 | |||
335 | xPL1 = tonumber(xPL1); |
||
336 | xPL2 = tonumber(xPL2); |
||
337 | |||
338 | --sometimes in chat the information isnt grabbed because not been clicked on |
||
339 | --but we can get around this by setting it to the tooltip |
||
340 | ----------------------------------------------------------------------- |
||
341 | if(sEvent and sEvent == "CHAT") then |
||
342 | |||
343 | local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X, equipType_X, iconTexture_X = GetItemInfo("item:"..sPL); |
||
344 | |||
345 | if(not name_X) then |
||
346 | ISync_MainFrame.TooltipButton = this:GetID(); |
||
347 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
348 | GameTooltip:SetHyperlink("item:"..sPL); |
||
349 | GameTooltip:Hide(); |
||
350 | end |
||
351 | |||
352 | end |
||
353 | ----------------------------------------------------------------------- |
||
354 | |||
355 | --grab the info |
||
356 | local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X, equipType_X, iconTexture_X = GetItemInfo("item:"..sPL); |
||
357 | |||
358 | |||
359 | --check |
||
360 | if(name_X and link_X and quality_X and ISync:SetVar({"FILTERS",quality_X}, 1, "COMPARE")) then |
||
361 | |||
362 | |||
363 | --if we don't have it then add it |
||
364 | if(not ISync:FetchDB(xPL1, "chk")) then |
||
365 | |||
366 | |||
367 | --check for SPOOFS |
||
368 | if(not ISync:CheckSpoof(item, equipType_X, quality_X)) then return nil; end |
||
369 | |||
370 | --add the item |
||
371 | ISync:SetDB(xPL1, "subitem", xPL2); |
||
372 | ISync:SetDB(xPL1, "quality", quality_X); |
||
373 | |||
374 | --parse it |
||
375 | ISync:Do_Parse(UIParent, ISyncTooltip, xPL1, link_X); |
||
376 | |||
377 | --check if we have it as a subitem, if not add it |
||
378 | elseif(xPL2 ~= 0 and not ISync:FetchDB(xPL1, "subitem", xPL2)) then |
||
379 | |||
380 | ISync:SetDB(xPL1, "subitem", xPL2); |
||
381 | |||
382 | end--if(not ISync:FetchDB(name_X, "item")) then |
||
383 | |||
384 | |||
385 | ------------------------------------------------- |
||
386 | --VENDOR INFORMATION |
||
387 | if(sVendorPrice or sVendorQty) then |
||
388 | |||
389 | --check vendor stuff |
||
390 | if(sVendorPrice) then |
||
391 | ISync:SetDB(xPL1, "vendor", sVendorPrice); |
||
392 | end |
||
393 | if(sVendorQty) then |
||
394 | ISync:SetDB(xPL1, "vendorqty", sVendorQty); |
||
395 | end |
||
396 | |||
397 | end |
||
398 | ------------------------------------------------- |
||
399 | |||
400 | |||
401 | end--if(name_X) then |
||
402 | |||
403 | end--if( color and item and name ) then |
||
404 | |||
405 | end--for color, item, name |
||
406 | |||
407 | end |
||
408 | |||
409 | |||
410 | --------------------------------------------------- |
||
411 | -- ISync:CheckSpoof() |
||
412 | -- This code is inspired by Brodrick |
||
413 | --------------------------------------------------- |
||
414 | --sLink cannot have itemid: in the front |
||
415 | function ISync:CheckSpoof(sLink, sEquipT, sQuality) |
||
416 | |||
417 | --check |
||
418 | if(not sLink or not sEquipT or not sQuality) then return nil; end |
||
419 | |||
420 | --folks were starting to use empty values to create spoofs. |
||
421 | if(sLink == "0:0:0:0") then return nil; end |
||
422 | |||
423 | |||
424 | --grab the item information based on it's string id |
||
425 | local _, _, sItemID, sEnchant, sItemStat, sSetBonus = string.find( sLink, "(%d+):(%d+):(%d+):(%d+)" ); |
||
426 | |||
427 | |||
428 | --make sure |
||
429 | if(not sEnchant or not sItemID or not sItemStat) then return nil; end |
||
430 | |||
431 | |||
432 | --grab array of items that can't have items stats |
||
433 | local ChkItem = { |
||
434 | [""] = 2, |
||
435 | ["INVTYPE_TRINKET"] = 2, |
||
436 | ["INVTYPE_AMMO"] = 2, |
||
437 | ["INVTYPE_THROWN"] = 2, |
||
438 | ["INVTYPE_BAG"] = 2, |
||
439 | ["INVTYPE_TABARD"] = 2, |
||
440 | ["INVTYPE_BODY"] = 2, --INVTYPE_BODY is not INVTYPE_CHEST or INVTYPE_ROBE |
||
441 | ["INVTYPE_HOLDABLE"] = 1, |
||
442 | ["INVTYPE_FINGER"] = 1, |
||
443 | ["INVTYPE_WAIST"] = 1, |
||
444 | } |
||
445 | |||
446 | |||
447 | --first check the stats |
||
448 | if ( sItemStat and tonumber(sItemStat) > 0 ) then |
||
449 | |||
450 | --check quality, greens, blues and one epic are allowed to have 'of the' only |
||
451 | if ( sQuality ~= 2 and sQuality ~= 3 and sItemID ~= "20039" ) then |
||
452 | --20039: is dark iron boots which is an exception |
||
453 | |||
454 | --error this item is invalid return nil |
||
455 | return nil; |
||
456 | |||
457 | --only certain items can have bonues 'of the' |
||
458 | elseif( ChkItem[sEquipT] == 2 ) then |
||
459 | |||
460 | --error this item is invalid return nil |
||
461 | return nil; |
||
462 | end |
||
463 | |||
464 | |||
465 | end |
||
466 | |||
467 | |||
468 | --check for enchants |
||
469 | if ( sEnchant and tonumber(sEnchant) > 0 ) then |
||
470 | |||
471 | --only armor and weapons can have enchants |
||
472 | if ( ChkItem[sEquipT] ) then |
||
473 | |||
474 | return nil; |
||
475 | |||
476 | end |
||
477 | end |
||
478 | |||
479 | |||
480 | --everything checks out so return true |
||
481 | return 1; |
||
482 | |||
483 | |||
484 | end |
||
485 | |||
486 | |||
487 | ----------------------------------------------------------------------------------------------------- |
||
488 | ----------------------------------------------------------------------------------------------------- |
||
489 | ----------------------------------------------------------------------------------------------------- |
||
490 | ----------------------------------------------------------------------------------------------------- |
||
491 | ----------------------------------------------------------------------------------------------------- |
||
492 | ----------------------------------------------------------------------------------------------------- |
||
493 | |||
494 | --------------------------------------------------- |
||
495 | -- ISync:InspectTarget() |
||
496 | --------------------------------------------------- |
||
497 | function ISync:InspectTarget(sTarget) |
||
498 | |||
499 | if(sTarget == "mouseover") then |
||
500 | --we don't want to check the user over and over and over again |
||
501 | |||
502 | local sName = UnitName(sTarget); --get their name |
||
503 | local sGetTime = GetTime(); --get current time |
||
504 | local sLastScan = ItemSync_MouseArray[sName]; --get last time scanned if any |
||
505 | |||
506 | if ( sLastScan and sGetTime - sLastScan < 120 ) then --check if we have scanned them anytime soon |
||
507 | return nil; --we did so return nil |
||
508 | end |
||
509 | |||
510 | --initiate if not there |
||
511 | ItemSync_MouseArray.iCount = (ItemSync_MouseArray.iCount or 0); |
||
512 | if(ItemSync_MouseArray.iCount and ItemSync_MouseArray.iCount < 0) then ItemSync_MouseArray.iCount = 0; end |
||
513 | |||
514 | |||
515 | --we didn't so lets add them to the array |
||
516 | --first fix the array if we have exceeded our limit |
||
517 | if( ItemSync_MouseArray.iCount > 100 ) then |
||
518 | |||
519 | --clean array |
||
520 | for xKey, xVar in ItemSync_MouseArray do |
||
521 | |||
522 | if(xKey ~= "iCount") then |
||
523 | |||
524 | if(xVar and (GetTime() - xVar) > 120) then --time expired so lets remove |
||
525 | ItemSync_MouseArray[xKey] = nil; |
||
526 | ItemSync_MouseArray.iCount = ItemSync_MouseArray.iCount - 1; --decrease |
||
527 | end |
||
528 | |||
529 | end |
||
530 | end |
||
531 | |||
532 | end |
||
533 | |||
534 | --if for some reason it's still bigger then limit, then reset it. We don't want a memory leak. |
||
535 | if(ItemSync_MouseArray.iCount > 100) then |
||
536 | ItemSync_MouseArray = nil; |
||
537 | ItemSync_MouseArray = { }; |
||
538 | end |
||
539 | |||
540 | ItemSync_MouseArray[sName] = GetTime(); |
||
541 | ItemSync_MouseArray.iCount = (ItemSync_MouseArray.iCount or 0) + 1; |
||
542 | |||
543 | end--if(sTarget == "mouseover") then |
||
544 | |||
545 | |||
546 | for i = 1, 19, 1 do |
||
547 | local link = GetInventoryItemLink(sTarget, i); |
||
548 | if( link ) then |
||
549 | ISync:ProcessLinks(link, nil, nil, nil) |
||
550 | end |
||
551 | end--for i = 1, 19, 1 do |
||
552 | |||
553 | end |
||
554 | |||
555 | |||
556 | |||
557 | --------------------------------------------------- |
||
558 | -- ISync:ScanInv() |
||
559 | --------------------------------------------------- |
||
560 | function ISync:ScanInv() |
||
561 | |||
562 | local bagid, size, slotid, link; |
||
563 | |||
564 | for bagid=0,NUM_BAG_FRAMES,1 do |
||
565 | |||
566 | size = GetContainerNumSlots(bagid); |
||
567 | |||
568 | if( size ) then |
||
569 | for slotid = size, 1, -1 do |
||
570 | link = GetContainerItemLink(bagid, slotid); |
||
571 | if( link ) then ISync:ProcessLinks(link, nil, nil, nil); end |
||
572 | end |
||
573 | end |
||
574 | end |
||
575 | |||
576 | end |
||
577 | |||
578 | |||
579 | --------------------------------------------------- |
||
580 | -- ISync:ScanBank() |
||
581 | --------------------------------------------------- |
||
582 | function ISync:ScanBank() |
||
583 | |||
584 | local bagid, size, slotid, link; |
||
585 | |||
586 | --Bank Container |
||
587 | size = GetContainerNumSlots(BANK_CONTAINER); |
||
588 | for slotid = size, 1, -1 do |
||
589 | link = GetContainerItemLink(BANK_CONTAINER, slotid); |
||
590 | if( link ) then ISync:ProcessLinks(link, nil, nil, nil); end |
||
591 | end |
||
592 | |||
593 | --Bank Bag Containers |
||
594 | for bagid= NUM_BAG_SLOTS + 1, (NUM_BAG_SLOTS + NUM_BANKBAGSLOTS), 1 do |
||
595 | |||
596 | size = GetContainerNumSlots(bagid); |
||
597 | if( size ) then |
||
598 | for slotid = size, 1, -1 do |
||
599 | link = GetContainerItemLink(bagid, slotid); |
||
600 | if( link ) then ISync:ProcessLinks(link, nil, nil, nil); end |
||
601 | end |
||
602 | end |
||
603 | end |
||
604 | |||
605 | end |
||
606 | |||
607 | |||
608 | --------------------------------------------------- |
||
609 | -- ISync:ScanAuction() |
||
610 | --------------------------------------------------- |
||
611 | function ISync:ScanAuction() |
||
612 | local numBatchAuctions, totalAuctions = GetNumAuctionItems("list"); |
||
613 | local auctionid; |
||
614 | local link; |
||
615 | |||
616 | if( numBatchAuctions > 0 ) then |
||
617 | for auctionid = 1, numBatchAuctions do |
||
618 | link = GetAuctionItemLink("list", auctionid); |
||
619 | if( link ) then ISync:ProcessLinks(link, nil, nil, nil); end |
||
620 | end |
||
621 | end |
||
622 | |||
623 | end |
||
624 | |||
625 | |||
626 | |||
627 | |||
628 | --------------------------------------------------- |
||
629 | -- ISync:VendorScan() |
||
630 | --------------------------------------------------- |
||
631 | function ISync:VendorScan() |
||
632 | |||
633 | --only do if merchant window is opened |
||
634 | if(not MerchantFrame:IsVisible()) then return nil; end |
||
635 | |||
636 | local numMerchantItems = GetMerchantNumItems(); |
||
637 | local name, texture, price, quantity, numAvailable, isUsable; |
||
638 | |||
639 | for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do |
||
640 | local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i); |
||
641 | |||
642 | if ( index <= numMerchantItems ) then |
||
643 | name, texture, price, quantity, numAvailable, isUsable = GetMerchantItemInfo(index); |
||
644 | |||
645 | --get the link for the item |
||
646 | local link = GetMerchantItemLink(index) |
||
647 | |||
648 | --if there is a link, quantity, and a price then set it to be stored with |
||
649 | --vendor price and information |
||
650 | if (link and quantity and price) then |
||
651 | |||
652 | ISync:ProcessLinks(link, nil , price, quantity); |
||
653 | |||
654 | --for some reason there isn't any so lets just add it anyways |
||
655 | elseif (link) then |
||
656 | |||
657 | ISync:ProcessLinks(link, nil, nil, nil); |
||
658 | end |
||
659 | |||
660 | end--if ( index <= numMerchantItems ) then |
||
661 | |||
662 | end--for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do |
||
663 | |||
664 | end |
||
665 | |||
666 | |||
667 | |||
668 | |||
669 | |||
670 | --------------------------------------------------- |
||
671 | -- ISync:MerchantMoneyScan() |
||
672 | --------------------------------------------------- |
||
673 | function ISync:MerchantMoneyScan(frame) |
||
674 | |||
675 | local costOfItem; |
||
676 | |||
677 | GameTooltip:Hide(); |
||
678 | |||
679 | for bag=0,NUM_BAG_FRAMES do |
||
680 | for slot=1,GetContainerNumSlots(bag) do |
||
681 | |||
682 | local link = GetContainerItemLink(bag, slot); |
||
683 | |||
684 | if (link and link ~= "") then |
||
685 | |||
686 | --get the name of the link |
||
687 | local sID = ISync:GetCoreID(link); |
||
688 | |||
689 | if(sID) then |
||
690 | |||
691 | --reset |
||
692 | ISYNC_ITEMCOST = 0; |
||
693 | costOfItem = 0; |
||
694 | |||
695 | --we had to change it to gametooltip because that is what is processing the money |
||
696 | GameTooltip:SetBagItem(bag, slot); --set the bag slot to grab tooltip |
||
697 | |||
698 | --hide again |
||
699 | GameTooltip:Hide(); |
||
700 | |||
701 | local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bag, slot); |
||
702 | |||
703 | if( itemCount and itemCount > 0 and tonumber(ISYNC_ITEMCOST)) then --anything divided by 1 is itself |
||
704 | costOfItem = floor(ISYNC_ITEMCOST / itemCount); |
||
705 | end |
||
706 | |||
707 | |||
708 | if(costOfItem and costOfItem ~= 0 and tonumber(costOfItem)) then |
||
709 | |||
710 | ISync:SetDB(sID, "price", costOfItem); |
||
711 | |||
712 | elseif(tonumber(costOfItem) and costOfItem < 1) then |
||
713 | |||
714 | --it equals zero so lets put n for the nosellprice to show |
||
715 | ISync:SetDB(sID, "price", -1); |
||
716 | end |
||
717 | |||
718 | end--if(sName) then |
||
719 | |||
720 | end--if (link and link ~= "") then |
||
721 | |||
722 | end--for slot=1,GetContainerNumSlots(bag) do |
||
723 | |||
724 | end--for bag=0,NUM_BAG_FRAMES do |
||
725 | |||
726 | end |
||
727 | |||
728 | |||
729 | ----------------------------------------------------------------------------------------------------- |
||
730 | ----------------------------------------------------------------------------------------------------- |
||
731 | ----------------------------------------------------------------------------------------------------- |
||
732 | ----------------------------------------------------------------------------------------------------- |
||
733 | ----------------------------------------------------------------------------------------------------- |
||
734 | ----------------------------------------------------------------------------------------------------- |
||
735 | |||
736 | |||
737 | --------------------------------------------------- |
||
738 | -- ISync:FetchDB() |
||
739 | --------------------------------------------------- |
||
740 | function ISync:FetchDB(sID, SDelimiter, sCompare) |
||
741 | |||
742 | if(not sID or not SDelimiter) then return nil; end |
||
743 | if(not ISyncDB) then return nil; end |
||
744 | if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end |
||
745 | if(not ISyncDB[ISYNC_REALM_NUM][sID]) then return nil; end |
||
746 | if(ISYNC_LOADYES == 0) then return nil; end |
||
747 | if(not tonumber(sID)) then return nil; end --only allow numbers to store |
||
748 | |||
749 | sID = tonumber(sID); --convert to number |
||
750 | |||
751 | if(SDelimiter == "chk") then return 1; end |
||
752 | |||
753 | --set the delimiters |
||
754 | if(SDelimiter == "quality") then SDelimiter = 1; |
||
755 | elseif(SDelimiter == "price") then SDelimiter = 2; |
||
756 | elseif(SDelimiter == "wl") then SDelimiter = 3; |
||
757 | elseif(SDelimiter == "wt") then SDelimiter = 4; |
||
758 | elseif(SDelimiter == "ts") then SDelimiter = 5; |
||
759 | elseif(SDelimiter == "at") then SDelimiter = 6; |
||
760 | elseif(SDelimiter == "st") then SDelimiter = 7; |
||
761 | elseif(SDelimiter == "level") then SDelimiter = 8; |
||
762 | elseif(SDelimiter == "vendor") then SDelimiter = 9; |
||
763 | elseif(SDelimiter == "vendorqty") then SDelimiter = 10; |
||
764 | elseif(SDelimiter == "idchk") then SDelimiter = 11; |
||
765 | elseif(SDelimiter == "subitem") then SDelimiter = 12; |
||
766 | else return nil; end |
||
767 | |||
768 | local sArray = ISync:SplitData(ISyncDB[ISYNC_REALM_NUM][sID], "°"); |
||
769 | |||
770 | --convert to strings |
||
771 | if(sCompare and type(sCompare) ~= "string") then sCompare = tostring(sCompare); end |
||
772 | |||
773 | --do loop |
||
774 | for i = 1, ISYNC_DB_MAX do |
||
775 | |||
776 | --check |
||
777 | if(i == SDelimiter) then |
||
778 | |||
779 | --make sure we have something to return and that its |
||
780 | --not the subitems array |
||
781 | if(sArray and sArray[i] and i ~= 12) then --12 = subitems |
||
782 | |||
783 | --we have something now check to see if we want to compare |
||
784 | if(sCompare) then |
||
785 | |||
786 | --check compare |
||
787 | if(sArray[i] == sCompare) then |
||
788 | return sArray[i]; |
||
789 | else |
||
790 | return nil; |
||
791 | end |
||
792 | |||
793 | --we don't want to compare so just send regular |
||
794 | else |
||
795 | return sArray[i]; |
||
796 | end |
||
797 | |||
798 | --there was an error |
||
799 | return nil; |
||
800 | |||
801 | --it is the subitems they want |
||
802 | elseif(sArray and sArray[i] and i == 12) then --12 = subitems |
||
803 | |||
804 | --check if we have an empty |
||
805 | if(sArray[i] == "0" or tonumber(sArray[i]) and tonumber(sArray[i]) == 0) then |
||
806 | return nil; |
||
807 | end |
||
808 | |||
809 | local yArray = ISync:SplitData(sArray[12], "º"); --12 = subitems |
||
810 | |||
811 | --check if we are comparing |
||
812 | if(sCompare) then |
||
813 | |||
814 | --loop |
||
815 | for sKey, sVar in yArray do |
||
816 | if(sVar == sCompare) then return sVar; end |
||
817 | end |
||
818 | |||
819 | --there was an error |
||
820 | return nil; |
||
821 | |||
822 | else |
||
823 | if(not yArray) then return nil; else return yArray; end |
||
824 | end |
||
825 | |||
826 | --there was an error |
||
827 | return nil; |
||
828 | |||
829 | --something went wrong |
||
830 | else |
||
831 | return nil; |
||
832 | |||
833 | end--if(sArray and sArray[i] and i ~= 12) |
||
834 | |||
835 | |||
836 | break; --break out of for loop |
||
837 | |||
838 | |||
839 | end--if(i == SDelimiter) then |
||
840 | |||
841 | end--for i = 1, ISYNC_DB_MAX do |
||
842 | |||
843 | |||
844 | --return empty space |
||
845 | return nil; |
||
846 | end |
||
847 | |||
848 | |||
849 | --------------------------------------------------- |
||
850 | -- ISync:SetDB() |
||
851 | --------------------------------------------------- |
||
852 | function ISync:SetDB(sID, SDelimiter, sValue, sOpt) |
||
853 | |||
854 | if(not sID or not SDelimiter or not sValue) then return nil; end |
||
855 | if(not ISyncDB) then return nil; end |
||
856 | if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end |
||
857 | if(ISYNC_LOADYES == 0) then return nil; end |
||
858 | if(not tonumber(sID)) then return nil; end --only allow numbers to store |
||
859 | |||
860 | sID = tonumber(sID); --convert to number |
||
861 | |||
862 | |||
863 | --check for repeating to add to db, this causes lag |
||
864 | --------------------------------------------- |
||
865 | local sSdx = ""; |
||
866 | |||
867 | if(sID) then |
||
868 | sSdx = sSdx..tostring(sID); |
||
869 | end |
||
870 | if(SDelimiter) then |
||
871 | sSdx = sSdx..tostring(SDelimiter); |
||
872 | end |
||
873 | if(sValue) then |
||
874 | sSdx = sSdx..tostring(sValue); |
||
875 | end |
||
876 | if(sOpt) then |
||
877 | sSdx = sSdx..tostring(sOpt); |
||
878 | end |
||
879 | |||
880 | if(sSdx == SetDB_RepeatChk) then return nil; end |
||
881 | |||
882 | SetDB_RepeatChk = sSdx; --set it |
||
883 | |||
884 | --------------------------------------------- |
||
885 | |||
886 | --check the filter |
||
887 | if(SDelimiter and SDelimiter == "quality" and tonumber(sValue)) then |
||
888 | if(not ISync:SetVar({"FILTERS",tonumber(sValue)}, 1, "COMPARE")) then return nil; end |
||
889 | end |
||
890 | |||
891 | |||
892 | --set the delimiters |
||
893 | if(SDelimiter == "quality") then SDelimiter = 1; |
||
894 | elseif(SDelimiter == "price") then SDelimiter = 2; |
||
895 | elseif(SDelimiter == "wl") then SDelimiter = 3; |
||
896 | elseif(SDelimiter == "wt") then SDelimiter = 4; |
||
897 | elseif(SDelimiter == "ts") then SDelimiter = 5; |
||
898 | elseif(SDelimiter == "at") then SDelimiter = 6; |
||
899 | elseif(SDelimiter == "st") then SDelimiter = 7; |
||
900 | elseif(SDelimiter == "level") then SDelimiter = 8; |
||
901 | elseif(SDelimiter == "vendor") then SDelimiter = 9; |
||
902 | elseif(SDelimiter == "vendorqty") then SDelimiter = 10; |
||
903 | elseif(SDelimiter == "idchk") then SDelimiter = 11; |
||
904 | elseif(SDelimiter == "subitem") then SDelimiter = 12; |
||
905 | else return nil; end |
||
906 | |||
907 | --since we use a string we must convert numerics to strings as well |
||
908 | if(type(sValue) == "number") then sValue = tostring(sValue); end |
||
909 | |||
910 | --create if doesn't exist |
||
911 | if(not ISyncDB[ISYNC_REALM_NUM][sID]) then |
||
912 | ISyncDB[ISYNC_REALM_NUM][sID] = 0; |
||
913 | |||
914 | --increment |
||
915 | ISync:SetVar({"OPT","ITEMCOUNT_VALID"},(tonumber(ISync:SetVar({"OPT","ITEMCOUNT_VALID"},0))+1), "TRUE"); |
||
916 | ISync:ItemDisplay_Update(); |
||
917 | --set that we require a refresh if we have a new item |
||
918 | if(ISync_SortIndex) then ISync:SetVar({"REQUIRED","REFRESH"}, 1, "TRUE"); end |
||
919 | |||
920 | end |
||
921 | |||
922 | local sArray = ISync:SplitData(ISyncDB[ISYNC_REALM_NUM][sID], "°"); |
||
923 | local finalStr = ""; |
||
924 | local subItemStr; |
||
925 | |||
926 | ---------------------------------------------- |
||
927 | --before we continue lets fix the subitems if we have too |
||
928 | --basically this is to remove a value from the array ;) |
||
929 | if(sArray and sArray[12] and SDelimiter == 12 and sOpt and string.upper(sOpt) == "TRUE") then |
||
930 | |||
931 | local yArray = ISync:SplitData(sArray[12], "º"); |
||
932 | |||
933 | --loop |
||
934 | for sKey, sVar in yArray do |
||
935 | if(not subItemStr and sVar ~= sValue) then |
||
936 | subItemStr = sVar; |
||
937 | elseif(subItemStr and sVar ~= sValue) then |
||
938 | subItemStr = subItemStr.."º"..sVar; |
||
939 | end |
||
940 | end |
||
941 | |||
942 | --if nothing then default |
||
943 | if(not subItemStr) then subItemStr = 0; end |
||
944 | |||
945 | --change the value to store it below and store back into array |
||
946 | sArray[12] = subItemStr; |
||
947 | sValue = subItemStr; |
||
948 | |||
949 | |||
950 | elseif(sArray and sArray[12] and SDelimiter == 12 and sOpt and string.upper(sOpt) == "REPLACE") then |
||
951 | |||
952 | --they want to replace the entire subitem string |
||
953 | sArray[12] = sValue; |
||
954 | |||
955 | --else just add to end |
||
956 | elseif(sArray and sArray[12] and SDelimiter == 12 and not sOpt) then |
||
957 | |||
958 | |||
959 | --check if we have this already in the array |
||
960 | local yArray = ISync:SplitData(sArray[12], "º"); |
||
961 | |||
962 | --loop |
||
963 | for sKey, sVar in yArray do |
||
964 | if(sVar == sValue) then |
||
965 | return nil; --don't do it cause we have this # already |
||
966 | end |
||
967 | end |
||
968 | |||
969 | |||
970 | --save the array for processing |
||
971 | local sOld = sArray[12]; |
||
972 | |||
973 | --check for empty (in case were starting off) |
||
974 | if(sOld == "0" or tonumber(sOld) and tonumber(sOld) == 0) then |
||
975 | sValue = sValue; --update value to be stored below |
||
976 | sArray[12] = sValue; --update array |
||
977 | else |
||
978 | sValue = sOld.."º"..sValue; --update value to be stored below |
||
979 | sArray[12] = sOld.."º"..sValue; --update array |
||
980 | end |
||
981 | |||
982 | |||
983 | sOld = nil; --reset |
||
984 | |||
985 | end |
||
986 | ---------------------------------------------- |
||
987 | |||
988 | |||
989 | --do loop |
||
990 | for i = 1, ISYNC_DB_MAX do |
||
991 | |||
992 | --do not add the delimiter to the end duh |
||
993 | if(i ~= ISYNC_DB_MAX) then |
||
994 | |||
995 | --if the delimiter matches then replace |
||
996 | if(i == SDelimiter) then |
||
997 | finalStr = finalStr..sValue.."°"; |
||
998 | else |
||
999 | --if it doesn't then check for old and add, if not then add zero |
||
1000 | if(sArray and sArray[i]) then |
||
1001 | finalStr = finalStr..sArray[i].."°"; |
||
1002 | else |
||
1003 | finalStr = finalStr.."0°"; |
||
1004 | end |
||
1005 | end |
||
1006 | |||
1007 | --it does equal the last |
||
1008 | --don't add a delimiter at end |
||
1009 | else |
||
1010 | |||
1011 | --if the delimiter matches then replace |
||
1012 | if(i == SDelimiter) then |
||
1013 | finalStr = finalStr..sValue; |
||
1014 | else |
||
1015 | --if it doesn't then check for old and add, if not then add zero |
||
1016 | if(sArray and sArray[i]) then |
||
1017 | finalStr = finalStr..sArray[i]; |
||
1018 | else |
||
1019 | finalStr = finalStr.."0"; |
||
1020 | end |
||
1021 | end |
||
1022 | |||
1023 | |||
1024 | end--if(i ~= ISYNC_DB_MAX) then |
||
1025 | |||
1026 | |||
1027 | end--for i = 1, ISYNC_DB_MAX do |
||
1028 | |||
1029 | |||
1030 | --store it |
||
1031 | ISyncDB[ISYNC_REALM_NUM][sID] = finalStr; |
||
1032 | |||
1033 | |||
1034 | --reset |
||
1035 | sArray = nil; |
||
1036 | if(yArray) then yArray = nil; end |
||
1037 | |||
1038 | --return value and delimiter num |
||
1039 | return SDelimiter, sValue; |
||
1040 | |||
1041 | end |
||
1042 | |||
1043 | |||
1044 | |||
1045 | --------------------------------------------------- |
||
1046 | -- ISync:SplitData() |
||
1047 | --------------------------------------------------- |
||
1048 | function ISync:SplitData(sData, sDelimiter) |
||
1049 | |||
1050 | --first check for data |
||
1051 | if(not sData) then return nil; end |
||
1052 | |||
1053 | --now check for a delimiter |
||
1054 | if(not sDelimiter) then return nil; end |
||
1055 | |||
1056 | --make sure the data is a string |
||
1057 | if (type(sData) ~= "string") then return nil; end |
||
1058 | |||
1059 | |||
1060 | local list = {} |
||
1061 | local pos = 1 |
||
1062 | if strfind("", sDelimiter, 1) then -- this would result in endless loops |
||
1063 | end |
||
1064 | while 1 do |
||
1065 | local first, last = strfind(sData, sDelimiter, pos) |
||
1066 | if first then -- found? |
||
1067 | |||
1068 | --do not insert empty values |
||
1069 | if(strsub(sData, pos, first-1) ~= "") then |
||
1070 | |||
1071 | tinsert(list, strsub(sData, pos, first-1)) |
||
1072 | |||
1073 | end |
||
1074 | pos = last+1 |
||
1075 | else |
||
1076 | |||
1077 | --do not insert empty values |
||
1078 | if(strsub(sData, pos) ~= "") then |
||
1079 | |||
1080 | tinsert(list, strsub(sData, pos)) |
||
1081 | |||
1082 | end |
||
1083 | |||
1084 | break |
||
1085 | end |
||
1086 | end |
||
1087 | return list |
||
1088 | |||
1089 | end |
||
1090 | |||
1091 | |||
1092 | ----------------------------------------------------------------------------------------------------- |
||
1093 | ----------------------------------------------------------------------------------------------------- |
||
1094 | ----------------------------------------------------------------------------------------------------- |
||
1095 | ----------------------------------------------------------------------------------------------------- |
||
1096 | ----------------------------------------------------------------------------------------------------- |
||
1097 | ----------------------------------------------------------------------------------------------------- |
||
1098 | |||
1099 | --------------------------------------------------- |
||
1100 | -- ISync:SlashCommand |
||
1101 | --------------------------------------------------- |
||
1102 | function ISync_SlashCommand(msg) |
||
1103 | |||
1104 | |||
1105 | if (msg == nil) then |
||
1106 | |||
1107 | if(ISYNC_LOADYES == 1) then |
||
1108 | |||
1109 | ISync:MainFrame_Binding(); |
||
1110 | end |
||
1111 | |||
1112 | return nil; |
||
1113 | end |
||
1114 | |||
1115 | |||
1116 | local num, offset, command, args = string.find (msg, "^(%w+)%s*(.*)$"); |
||
1117 | |||
1118 | |||
1119 | if (command == nil) then |
||
1120 | |||
1121 | if(ISYNC_LOADYES == 1) then |
||
1122 | |||
1123 | ISync:MainFrame_Binding(); |
||
1124 | end |
||
1125 | |||
1126 | return nil; |
||
1127 | |||
1128 | --the user is preforming a search |
||
1129 | elseif (string.lower(command) == "search" and args ~= nil or args ~= "") then |
||
1130 | |||
1131 | |||
1132 | if(ISync.SF_Reset and ISync_TextEditBox and ISYNC_LOADYES == 1 ) then |
||
1133 | |||
1134 | --reset first |
||
1135 | ISync:SF_Reset(); |
||
1136 | |||
1137 | ISync_TextEditBox:SetText(args); |
||
1138 | |||
1139 | ISYNC_SHOWSEARCH_CHK = 1; |
||
1140 | |||
1141 | --only show if it's hidden |
||
1142 | if ( not ISync_MainFrame:IsVisible() ) then |
||
1143 | ISync_MainFrame:Show(); |
||
1144 | end |
||
1145 | |||
1146 | ISync:Main_Refresh(); |
||
1147 | |||
1148 | |||
1149 | end |
||
1150 | |||
1151 | |||
1152 | --the user is preforming a search (with just s instead of search) |
||
1153 | elseif (string.lower(command) == "s" and args ~= nil or args ~= "") then |
||
1154 | |||
1155 | |||
1156 | if(ISync.SF_Reset and ISync_TextEditBox and ISYNC_LOADYES == 1 ) then |
||
1157 | |||
1158 | --reset first |
||
1159 | ISync:SF_Reset(); |
||
1160 | |||
1161 | ISync_TextEditBox:SetText(args); |
||
1162 | |||
1163 | ISYNC_SHOWSEARCH_CHK = 1; |
||
1164 | |||
1165 | --only show if it's hidden |
||
1166 | if ( not ISync_MainFrame:IsVisible() ) then |
||
1167 | ISync_MainFrame:Show(); |
||
1168 | end |
||
1169 | |||
1170 | ISync:Main_Refresh(); |
||
1171 | |||
1172 | end |
||
1173 | |||
1174 | --the user is preforming a search |
||
1175 | elseif (string.lower(command) == "itemid") then |
||
1176 | |||
1177 | ISync:ItemIDSearch_Binding(); |
||
1178 | |||
1179 | --the user is preforming a search |
||
1180 | elseif (string.lower(command) == "fav" or string.lower(command) == "favorites") then |
||
1181 | |||
1182 | if(ISYNC_LOADYES == 1) then |
||
1183 | |||
1184 | ISync:FavFrame_Binding(); |
||
1185 | end |
||
1186 | |||
1187 | |||
1188 | |||
1189 | --the user is reseting the windows |
||
1190 | elseif (string.lower(command) == "resetwindow") then |
||
1191 | |||
1192 | getglobal("ISync_MainFrame"):ClearAllPoints(); getglobal("ISync_MainFrame"):SetPoint("CENTER", UIParent, "CENTER", 0, 0); |
||
1193 | getglobal("ISync_BV_Frame"):ClearAllPoints(); getglobal("ISync_BV_Frame"):SetPoint("CENTER", UIParent, "CENTER", 0, 0); |
||
1194 | getglobal("ISync_ItemIDFrame"):ClearAllPoints(); getglobal("ISync_ItemIDFrame"):SetPoint("CENTER", UIParent, "CENTER", 0, 0); |
||
1195 | getglobal("ISync_ID_Frame"):ClearAllPoints(); getglobal("ISync_ID_Frame"):SetPoint("CENTER", UIParent, "CENTER", 0, 0); |
||
1196 | |||
1197 | getglobal("ISync_FavFrame"):ClearAllPoints(); getglobal("ISync_FavFrame"):SetPoint("CENTER", UIParent, "CENTER", 400, 0); |
||
1198 | getglobal("ISync_OptionsFrame"):ClearAllPoints(); getglobal("ISync_OptionsFrame"):SetPoint("CENTER", UIParent, "CENTER", 400, 0); |
||
1199 | getglobal("ISync_FiltersFrame"):ClearAllPoints(); getglobal("ISync_FiltersFrame"):SetPoint("CENTER", UIParent, "CENTER", 400, 0); |
||
1200 | getglobal("ISync_SearchFrame"):ClearAllPoints(); getglobal("ISync_SearchFrame"):SetPoint("CENTER", UIParent, "CENTER", 400, 0); |
||
1201 | getglobal("ISync_HelpFrame"):ClearAllPoints(); getglobal("ISync_HelpFrame"):SetPoint("CENTER", UIParent, "CENTER", 400, 0); |
||
1202 | |||
1203 | |||
1204 | --the user is preforming a search |
||
1205 | elseif (string.lower(command) == "help") then |
||
1206 | |||
1207 | if( DEFAULT_CHAT_FRAME ) then |
||
1208 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00ItemSync Ver. ["..ISYNC_VERSION.."]|r"); |
||
1209 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00/itemsync, /isync, /ims, /is, /bagview, /bv, /bagv|r"); |
||
1210 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00 |r"); |
||
1211 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00ItemSync "..ISYNC_BT_SEARCH..": /is search itemname, /is s itemname|r"); |
||
1212 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00ItemSync "..ISYNC_BT_ITEMID..": /is itemid|r"); |
||
1213 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00ItemSync "..ISYNC_BT_FAVORITES..": /is fav, /is favorites|r"); |
||
1214 | DEFAULT_CHAT_FRAME:AddMessage("|c00FFFF00ItemSync "..ISYNC_SLASHRESETWINDOWS..": /is resetwindow|r"); |
||
1215 | end |
||
1216 | |||
1217 | |||
1218 | else |
||
1219 | |||
1220 | if(ISYNC_LOADYES == 1) then |
||
1221 | |||
1222 | ISync:MainFrame_Binding(); |
||
1223 | end |
||
1224 | |||
1225 | end |
||
1226 | |||
1227 | |||
1228 | end |
||
1229 | |||
1230 | |||
1231 | ----------------------------------------------------------------------------------------------------- |
||
1232 | ----------------------------------------------------------------------------------------------------- |
||
1233 | ----------------------------------------------------------------------------------------------------- |
||
1234 | ----------------------------------------------------------------------------------------------------- |
||
1235 | ----------------------------------------------------------------------------------------------------- |
||
1236 | ----------------------------------------------------------------------------------------------------- |
||
1237 | |||
1238 | --MODDERS NEED TO UPDATE! THESE FUNCTIONS WILL BE REMOVED IN FUTURE UPDATES OF ITEMSYNC! |
||
1239 | |||
1240 | |||
1241 | --hookback functions (THESE ARE OLD AND SHOULD BE REMOVED BY MODDERS) |
||
1242 | --ISync:SetData() |
||
1243 | function ISync:SetData(sID, SDelimiter, sValue, sOpt) |
||
1244 | |||
1245 | --users the numbered system |
||
1246 | if(tonumber(sID)) then |
||
1247 | |||
1248 | return ISync:SetDB(sID, SDelimiter, sValue, sOpt); |
||
1249 | |||
1250 | --uses old names |
||
1251 | else |
||
1252 | for index, value in ISyncDB_Names do |
||
1253 | |||
1254 | if(string.lower(sID) == string.lower(sID)) then |
||
1255 | |||
1256 | return ISync:SetDB(sID, SDelimiter, sValue, sOpt); |
||
1257 | |||
1258 | end--if(string.lower(value) == string.lower(text)) then |
||
1259 | |||
1260 | end |
||
1261 | |||
1262 | |||
1263 | end |
||
1264 | |||
1265 | return nil; |
||
1266 | end |
||
1267 | --ISync:GetData() |
||
1268 | function ISync:GetData(sID, SDelimiter, sOpt) |
||
1269 | |||
1270 | |||
1271 | --users the numbered system |
||
1272 | if(tonumber(sID)) then |
||
1273 | |||
1274 | return ISync:FetchDB(sID, SDelimiter, sOpt); |
||
1275 | |||
1276 | --uses old names |
||
1277 | else |
||
1278 | for index, value in ISyncDB_Names do |
||
1279 | |||
1280 | if(string.lower(sID) == string.lower(sID)) then |
||
1281 | |||
1282 | return ISync:FetchDB(sID, SDelimiter, sOpt); |
||
1283 | |||
1284 | end--if(string.lower(value) == string.lower(text)) then |
||
1285 | |||
1286 | end |
||
1287 | |||
1288 | |||
1289 | end |
||
1290 | |||
1291 | return nil; |
||
1292 | |||
1293 | end |
||
1294 |