vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[--------------------------------------------------------------------------------
2 ItemSyncCore Search Framework
3  
4 Author: Derkyle
5 Website: http://www.manaflux.com
6 -----------------------------------------------------------------------------------]]
7  
8 --lets setup the parse string
9 local ISync_sParse_type = "";
10  
11 ---------------------------------------------------
12 -- ISync:SF_SetSelectedID
13 ---------------------------------------------------
14 function ISync:SF_SetSelectedID(frame, id, names)
15 UIDropDownMenu_SetSelectedID(frame, id);
16 if( not frame ) then
17 frame = this;
18 end
19 UIDropDownMenu_SetText(names[id].name, frame);
20 end
21  
22  
23  
24 ---------------------------------------------------
25 -- ISync:SF_Load()
26 ---------------------------------------------------
27 function ISync:SF_Load()
28  
29 --location
30 UIDropDownMenu_Initialize(ISync_Location_DropDown, ISync.Location_DD_Initialize);
31 ISync:SF_SetSelectedID(ISync_Location_DropDown, 1, ISYNC_DD_LOCATION);
32 UIDropDownMenu_JustifyText("LEFT", ISync_Location_DropDown)
33  
34 --rarity
35 UIDropDownMenu_Initialize(ISync_Rarity_DropDown, ISync.Rarity_DD_Initialize);
36 ISync:SF_SetSelectedID(ISync_Rarity_DropDown, 1, ISYNC_DD_RARITY);
37 UIDropDownMenu_JustifyText("LEFT", ISync_Rarity_DropDown)
38  
39 --weapon
40 UIDropDownMenu_Initialize(ISync_Weapons_DropDown, ISync.Weapons_DD_Initialize);
41 ISync:SF_SetSelectedID(ISync_Weapons_DropDown, 1, ISYNC_DD_WEAPONS);
42 UIDropDownMenu_JustifyText("LEFT", ISync_Weapons_DropDown)
43  
44 --tradeskills
45 UIDropDownMenu_Initialize(ISync_Tradeskills_DropDown, ISync.Tradeskills_DD_Initialize);
46 ISync:SF_SetSelectedID(ISync_Tradeskills_DropDown, 1, ISYNC_DD_TRADESKILLS);
47 UIDropDownMenu_JustifyText("LEFT", ISync_Tradeskills_DropDown)
48  
49 --armor
50 UIDropDownMenu_Initialize(ISync_Armor_DropDown, ISync.Armor_DD_Initialize);
51 ISync:SF_SetSelectedID(ISync_Armor_DropDown, 1, ISYNC_DD_ARMOR);
52 UIDropDownMenu_JustifyText("LEFT", ISync_Armor_DropDown)
53  
54 --shield
55 UIDropDownMenu_Initialize(ISync_Shield_DropDown, ISync.Shield_DD_Initialize);
56 ISync:SF_SetSelectedID(ISync_Shield_DropDown, 1, ISYNC_DD_SHIELD);
57 UIDropDownMenu_JustifyText("LEFT", ISync_Shield_DropDown)
58  
59 --Level
60 UIDropDownMenu_Initialize(ISync_Level_DropDown, ISync.Level_DD_Initialize);
61 ISync:SF_SetSelectedID(ISync_Level_DropDown, 1, ISYNC_DD_LEVEL);
62 UIDropDownMenu_JustifyText("LEFT", ISync_Level_DropDown)
63  
64  
65 --Setup the parser string
66 ISync_sParse_type = "^";
67 for i = 1, ISYNC_DB_MAX, 1 do
68  
69 if(i ~= ISYNC_DB_MAX) then
70 ISync_sParse_type = ISync_sParse_type.."(.-)°";
71 else
72 ISync_sParse_type = ISync_sParse_type.."(.-)$";
73 end
74  
75 end
76  
77  
78 end
79  
80  
81  
82 ---------------------------------------------------
83 -- ISync:Location_DD_Initialize()
84 ---------------------------------------------------
85 function ISync:Location_DD_Initialize()
86 local info;
87 for i = 1, getn(ISYNC_DD_LOCATION), 1 do
88 info = { };
89 info.text = ISYNC_DD_LOCATION[i].name;
90 info.func = ISync.Location_DD_OnClick;
91 UIDropDownMenu_AddButton(info);
92 end
93 info = nil;
94 end
95  
96 function ISync:Rarity_DD_Initialize()
97 local info;
98 for i = 1, getn(ISYNC_DD_RARITY), 1 do
99 info = { };
100 info.text = ISYNC_DD_RARITY[i].name;
101 info.func = ISync.Rarity_DD_OnClick;
102 UIDropDownMenu_AddButton(info);
103 end
104 info = nil;
105 end
106  
107  
108 function ISync:Weapons_DD_Initialize()
109 local info;
110 for i = 1, getn(ISYNC_DD_WEAPONS), 1 do
111 info = { };
112 info.text = ISYNC_DD_WEAPONS[i].name;
113 info.func = ISync.Weapons_DD_OnClick;
114 UIDropDownMenu_AddButton(info);
115 end
116 info = nil;
117 end
118  
119  
120 function ISync:Tradeskills_DD_Initialize()
121 local info;
122 for i = 1, getn(ISYNC_DD_TRADESKILLS), 1 do
123 info = { };
124 info.text = ISYNC_DD_TRADESKILLS[i].name;
125 info.func = ISync.Tradeskills_DD_OnClick;
126 UIDropDownMenu_AddButton(info);
127 end
128 info = nil;
129 end
130  
131  
132 function ISync:Armor_DD_Initialize()
133 local info;
134 for i = 1, getn(ISYNC_DD_ARMOR), 1 do
135 info = { };
136 info.text = ISYNC_DD_ARMOR[i].name;
137 info.func = ISync.Armor_DD_OnClick;
138 UIDropDownMenu_AddButton(info);
139 end
140 info = nil;
141 end
142  
143 function ISync:Shield_DD_Initialize()
144 local info;
145 for i = 1, getn(ISYNC_DD_SHIELD), 1 do
146 info = { };
147 info.text = ISYNC_DD_SHIELD[i].name;
148 info.func = ISync.Shield_DD_OnClick;
149 UIDropDownMenu_AddButton(info);
150 end
151 info = nil;
152 end
153  
154  
155 function ISync:Level_DD_Initialize()
156 local info;
157 for i = 1, getn(ISYNC_DD_LEVEL), 1 do
158 info = { };
159 info.text = ISYNC_DD_LEVEL[i].name;
160 info.func = ISync.Level_DD_OnClick;
161 UIDropDownMenu_AddButton(info);
162 end
163 info = nil;
164 end
165  
166  
167  
168 ---------------------------------------------------
169 -- ISync:Location_DD_OnClick()
170 ---------------------------------------------------
171 function ISync:Location_DD_OnClick()
172 UIDropDownMenu_SetSelectedID(ISync_Location_DropDown, this:GetID());
173 end
174 function ISync:Rarity_DD_OnClick()
175 UIDropDownMenu_SetSelectedID(ISync_Rarity_DropDown, this:GetID());
176 end
177 function ISync:Weapons_DD_OnClick()
178 UIDropDownMenu_SetSelectedID(ISync_Weapons_DropDown, this:GetID());
179 end
180 function ISync:Tradeskills_DD_OnClick()
181 UIDropDownMenu_SetSelectedID(ISync_Tradeskills_DropDown, this:GetID());
182 end
183 function ISync:Armor_DD_OnClick()
184 UIDropDownMenu_SetSelectedID(ISync_Armor_DropDown, this:GetID());
185 end
186 function ISync:Shield_DD_OnClick()
187 UIDropDownMenu_SetSelectedID(ISync_Shield_DropDown, this:GetID());
188 end
189 function ISync:Level_DD_OnClick()
190 UIDropDownMenu_SetSelectedID(ISync_Level_DropDown, this:GetID());
191 end
192  
193  
194  
195 ---------------------------------------------------
196 -- ISync:SF_MatchSearch()
197 ---------------------------------------------------
198 function ISync:SF_MatchSearch(sID, sName, sQuality)
199 local sRarity = 0;
200 local sRarity_string = nil;
201 local sWL = 0;
202 local sWT = 0;
203 local sTS = 0;
204 local sAT = 0;
205 local sST = 0;
206  
207 local sLvl1 = 0;
208 local sLvl2 = 0;
209  
210 local storeLVL;
211 local sParseLink;
212  
213 --check for stuff first
214 if(not sID) then return nil; end
215 if(not tonumber(sID)) then return nil; end
216  
217 sID = tonumber(sID);
218  
219 if(not ISyncDB) then return nil; end --the database should have been created
220 if(not ISyncDB[ISYNC_REALM_NUM][sID]) then return nil; end --don't even bother
221  
222  
223  
224 ISYNC_SHOWSEARCH_CHK = 1; --set search activated
225  
226  
227 --------------------------------------------
228 --check rarity
229 if( ISYNC_DD_RARITY[UIDropDownMenu_GetSelectedID(ISync_Rarity_DropDown)].sortType ) then
230  
231 local sortType = ISYNC_DD_RARITY[UIDropDownMenu_GetSelectedID(ISync_Rarity_DropDown)].sortType;
232  
233 if( sortType == "NONE" ) then
234 sRarity = 0;
235 sRarity_string = nil; --just to make sure
236 else
237 sRarity = 1;
238 sRarity_string = sortType;
239 end
240  
241  
242 end
243  
244  
245  
246 --------------------------------------------
247 --check weapon location
248 if( ISYNC_DD_LOCATION[UIDropDownMenu_GetSelectedID(ISync_Location_DropDown)].sortType ) then
249  
250 local sortType = ISYNC_DD_LOCATION[UIDropDownMenu_GetSelectedID(ISync_Location_DropDown)].sortType;
251  
252 if( sortType == "NONE" ) then
253 sWL = 0;
254 else
255 sWL = ISYNC_WeaponLocation[sortType];
256 end
257 end
258  
259  
260 --------------------------------------------
261  
262 --------------------------------------------
263 --check weapon type
264 if( ISYNC_DD_WEAPONS[UIDropDownMenu_GetSelectedID(ISync_Weapons_DropDown)].sortType ) then
265  
266 local sortType = ISYNC_DD_WEAPONS[UIDropDownMenu_GetSelectedID(ISync_Weapons_DropDown)].sortType;
267  
268 if( sortType == "NONE" ) then
269 sWT = 0;
270 else
271 sWT = ISYNC_WeaponTypes[sortType];
272 end
273 end
274 --------------------------------------------
275  
276  
277 --------------------------------------------
278 --check tradeskill
279 if( ISYNC_DD_TRADESKILLS[UIDropDownMenu_GetSelectedID(ISync_Tradeskills_DropDown)].sortType ) then
280  
281 local sortType = ISYNC_DD_TRADESKILLS[UIDropDownMenu_GetSelectedID(ISync_Tradeskills_DropDown)].sortType;
282  
283 if( sortType == "NONE" ) then
284 sTS = 0;
285 else
286 sTS = ISYNC_TradeSkills[sortType];
287 end
288 end
289 --------------------------------------------
290  
291  
292 --------------------------------------------
293 --check armor type
294 if( ISYNC_DD_ARMOR[UIDropDownMenu_GetSelectedID(ISync_Armor_DropDown)].sortType ) then
295  
296 local sortType = ISYNC_DD_ARMOR[UIDropDownMenu_GetSelectedID(ISync_Armor_DropDown)].sortType;
297  
298 if( sortType == "NONE" ) then
299 sAT = 0;
300 else
301 sAT = ISYNC_ArmorTypes[sortType];
302 end
303 end
304 --------------------------------------------
305  
306  
307 --------------------------------------------
308 --check shield type
309 if( ISYNC_DD_SHIELD[UIDropDownMenu_GetSelectedID(ISync_Shield_DropDown)].sortType ) then
310  
311 local sortType = ISYNC_DD_SHIELD[UIDropDownMenu_GetSelectedID(ISync_Shield_DropDown)].sortType;
312  
313 if( sortType == "NONE" ) then
314 sST = 0;
315 else
316 sST = ISYNC_ShieldTypes[sortType];
317 end
318 end
319 --------------------------------------------
320  
321  
322 --------------------------------------------
323 --check level
324 if( ISYNC_DD_LEVEL[UIDropDownMenu_GetSelectedID(ISync_Level_DropDown)].sortType ) then
325  
326 local sortType = ISYNC_DD_LEVEL[UIDropDownMenu_GetSelectedID(ISync_Level_DropDown)].sortType;
327  
328 if( sortType == "NONE" ) then
329 sLvl1 = 0;
330 sLvl2 = 0;
331 else
332 if(sortType == 0) then
333 sLvl1 = 1;
334 sLvl2 = 5;
335 elseif(sortType == 1) then
336 sLvl1 = 5;
337 sLvl2 = 10;
338 elseif(sortType == 2) then
339 sLvl1 = 10;
340 sLvl2 = 15;
341 elseif(sortType == 3) then
342 sLvl1 = 15;
343 sLvl2 = 20;
344 elseif(sortType == 4) then
345 sLvl1 = 20;
346 sLvl2 = 25;
347 elseif(sortType == 5) then
348 sLvl1 = 25;
349 sLvl2 = 30;
350 elseif(sortType == 6) then
351 sLvl1 = 30;
352 sLvl2 = 35;
353 elseif(sortType == 7) then
354 sLvl1 = 35;
355 sLvl2 = 40;
356 elseif(sortType == 8) then
357 sLvl1 = 40;
358 sLvl2 = 45;
359 elseif(sortType == 9) then
360 sLvl1 = 45;
361 sLvl2 = 50;
362 elseif(sortType == 10) then
363 sLvl1 = 50;
364 sLvl2 = 55;
365 elseif(sortType == 11) then
366 sLvl1 = 55;
367 sLvl2 = 60;
368 end
369 end
370 end
371  
372  
373 --------------------------------------------
374  
375  
376 --Check Text
377 --------------------------------------
378 --------------------------------------
379  
380 if(ISync_TextEditBox:GetText() and ISync_TextEditBox:GetText() ~= "") then
381  
382 ISync_QuickSearch:SetText("");
383  
384 if not string.find( string.lower(sName), string.lower( ISync_TextEditBox:GetText() ) ) then
385 return nil;
386 end
387  
388 elseif(ISync_QuickSearch:GetText() and ISync_QuickSearch:GetText() ~= "") then
389  
390 ISync_TextEditBox:SetText("");
391  
392 if not string.find( string.lower(sName), string.lower( ISync_QuickSearch:GetText() ) ) then
393 return nil;
394 end
395  
396 end
397  
398  
399  
400  
401 --------------------------------------
402 --------------------------------------
403  
404  
405  
406 --Check Rarity
407 --------------------------------------
408 --------------------------------------
409  
410 if(sRarity > 0 and sRarity_string ~= nil) then
411  
412 if ( tonumber(sQuality) ~= tonumber(sRarity_string)) then
413 return nil;
414 end
415  
416  
417 end
418  
419 --------------------------------------
420 --------------------------------------
421  
422  
423 local sStorePattern = ISyncDB[ISYNC_REALM_NUM][sID];
424  
425  
426  
427 --Check Weapon Location
428 --------------------------------------
429 --------------------------------------
430  
431 if(sWL > 0) then
432  
433 sParseLink = nil; --reset
434 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%3");
435  
436 if (tonumber(sParseLink) and tonumber(sParseLink) ~= tonumber(sWL)) then
437 return nil;
438 end
439  
440  
441 end
442  
443 --------------------------------------
444 --------------------------------------
445  
446  
447 --Check Weapon Type
448 --------------------------------------
449 --------------------------------------
450  
451 if(sWT > 0) then
452  
453 --get id
454 sParseLink = nil; --reset
455 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%4");
456  
457  
458 if ( tonumber(sParseLink) and tonumber(sParseLink) ~= tonumber(sWT)) then
459 return nil;
460 end
461  
462  
463 end
464  
465 --------------------------------------
466 --------------------------------------
467  
468  
469 --Check Tradeskill
470 --------------------------------------
471 --------------------------------------
472  
473 if(sTS > 0) then
474  
475 --get id
476 sParseLink = nil; --reset
477 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%5");
478  
479  
480 if ( tonumber(sParseLink) and tonumber(sParseLink) ~= tonumber(sTS)) then
481 return nil;
482 end
483  
484  
485 end
486  
487 --------------------------------------
488 --------------------------------------
489  
490  
491  
492  
493 --Check Armor Type
494 --------------------------------------
495 --------------------------------------
496  
497 if(sAT > 0) then
498  
499  
500 --get id
501 sParseLink = nil; --reset
502 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%6");
503  
504  
505 if ( tonumber(sParseLink) and tonumber(sParseLink) ~= tonumber(sAT)) then
506 return nil;
507 end
508  
509  
510 end
511  
512 --------------------------------------
513 --------------------------------------
514  
515  
516 --Check Shield Type
517 --------------------------------------
518 --------------------------------------
519  
520 if(sST > 0) then
521  
522  
523 --get id
524 sParseLink = nil; --reset
525 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%7");
526  
527  
528 if ( tonumber(sParseLink) and tonumber(sParseLink)~= tonumber(sST)) then
529 return nil;
530 end
531  
532  
533 end
534  
535 --------------------------------------
536 --------------------------------------
537  
538  
539 --Check Level
540 --------------------------------------
541 --------------------------------------
542  
543 if(sLvl1 > 0 and sLvl2 > 0) then
544  
545 --get id
546 sParseLink = nil; --reset
547 sParseLink = string.gsub(sStorePattern, ISync_sParse_type, "%8");
548  
549 if (tonumber(sParseLink) and tonumber(sParseLink) >= sLvl1 and tonumber(sParseLink) <= sLvl2) then
550 --do nothing
551 else
552 return nil;
553 end
554  
555  
556 end
557  
558 --------------------------------------
559 --------------------------------------
560  
561  
562  
563 --if EVERYTHING checks out then return yes
564 --return yes
565 return 1;
566  
567  
568 end
569  
570  
571  
572  
573 ---------------------------------------------------
574 -- ISync:SF_Close()
575 ---------------------------------------------------
576 function ISync:SF_Close()
577  
578 HideUIPanel(ISync_SearchFrame);
579 ISYNC_SHOWSEARCH_CHK = 0; --reset and refresh
580  
581 --reset all to NONE
582 ISync:SF_SetSelectedID(ISync_Location_DropDown, 1, ISYNC_DD_LOCATION);
583 ISync:SF_SetSelectedID(ISync_Rarity_DropDown, 1, ISYNC_DD_RARITY);
584 ISync:SF_SetSelectedID(ISync_Weapons_DropDown, 1, ISYNC_DD_WEAPONS);
585 ISync:SF_SetSelectedID(ISync_Tradeskills_DropDown, 1, ISYNC_DD_TRADESKILLS);
586 ISync:SF_SetSelectedID(ISync_Armor_DropDown, 1, ISYNC_DD_ARMOR);
587 ISync:SF_SetSelectedID(ISync_Shield_DropDown, 1, ISYNC_DD_SHIELD);
588 ISync:SF_SetSelectedID(ISync_Level_DropDown, 1, ISYNC_DD_LEVEL);
589  
590 ISync_TextEditBox:SetText("");
591  
592 end
593  
594  
595  
596 ---------------------------------------------------
597 -- ISync:SF_Reset()
598 ---------------------------------------------------
599 function ISync:SF_Reset()
600  
601  
602 --reset all to NONE
603 ISync:SF_SetSelectedID(ISync_Location_DropDown, 1, ISYNC_DD_LOCATION);
604 ISync:SF_SetSelectedID(ISync_Rarity_DropDown, 1, ISYNC_DD_RARITY);
605 ISync:SF_SetSelectedID(ISync_Weapons_DropDown, 1, ISYNC_DD_WEAPONS);
606 ISync:SF_SetSelectedID(ISync_Tradeskills_DropDown, 1, ISYNC_DD_TRADESKILLS);
607 ISync:SF_SetSelectedID(ISync_Armor_DropDown, 1, ISYNC_DD_ARMOR);
608 ISync:SF_SetSelectedID(ISync_Shield_DropDown, 1, ISYNC_DD_SHIELD);
609 ISync:SF_SetSelectedID(ISync_Level_DropDown, 1, ISYNC_DD_LEVEL);
610  
611 ISync_TextEditBox:SetText("");
612  
613  
614 end