vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[--------------------------------------------------------------------------------
2 ItemSync Main GUI Framework
3  
4 Author: Derkyle
5 Website: http://www.manaflux.com
6 -----------------------------------------------------------------------------------]]
7  
8 ISYNC_SHOWINVALID_CHK = 0;
9 ISYNC_SHOWSEARCH_CHK = 0;
10  
11 local ItemSync_Tabs = {
12 { ISYNC_BT_SEARCH, ISYNC_BT_SEARCH, "Interface\\Icons\\INV_Misc_QuestionMark" },
13 { ISYNC_BT_OPTIONS, ISYNC_BT_OPTIONS, "Interface\\Icons\\Trade_Engineering" },
14 { ISYNC_BT_FILTERS, ISYNC_BT_FILTERS, "Interface\\Icons\\Spell_Nature_WispSplode" },
15 { ISYNC_BT_FAVORITES, ISYNC_BT_FAVORITES, "Interface\\Icons\\INV_ValentinesCard01" },
16 { ISYNC_BT_ITEMID, ISYNC_BT_ITEMID, "Interface\\Icons\\Ability_Spy" },
17 { ISYNC_BT_BAGVIEW, ISYNC_BT_BAGVIEW, "Interface\\Icons\\INV_Misc_Bag_18" },
18 };
19  
20 ---------------------------------------------------
21 -- ISync:MainFrame_OnLoad()
22 ---------------------------------------------------
23 function ISync:MainFrame_OnLoad()
24  
25 --setup the tabs
26 for i = 1, 6, 1 do
27 getglobal("ISync_Tab" .. i).tipinfo = ItemSync_Tabs[i][2];
28 getglobal("ISync_Tab" .. i):SetNormalTexture(ItemSync_Tabs[i][3]);
29 end
30  
31  
32 end
33  
34  
35 --------------------------------------------------------------------------------------------------------------------------------
36 --------------------------------------------------------------------------------------------------------------------------------
37 --------------------------------------------------------------------------------------------------------------------------------
38 --------------------------------------------------------------------------------------------------------------------------------
39 --------------------------------------------------------------------------------------------------------------------------------
40 --------------------------------------------------------------------------------------------------------------------------------
41  
42 ---------------------------------------------------
43 -- ISync:ItemDisplay_Update()
44 ---------------------------------------------------
45 function ISync:ItemDisplay_Update()
46  
47 if(ISync:SetVar({"OPT","ITEMCOUNTDISPLAY"}, 1, "COMPARE")) then
48 if(not ISync_ID_Frame:IsVisible()) then ISync_ID_Frame:Show(); end
49 ISync_ID_Frame_Text:SetText(""); --empty current text
50 ISync_ID_Frame_Text:SetText("|c0000FF00Items:|r |c00BDFCC9"..ISync:SetVar({"OPT","ITEMCOUNT_VALID"}, 0).."|r");
51 else
52 ISync_ID_Frame:Hide();
53 end
54  
55 end
56  
57  
58 --------------------------------------------------------------------------------------------------------------------------------
59 --------------------------------------------------------------------------------------------------------------------------------
60 --------------------------------------------------------------------------------------------------------------------------------
61 --------------------------------------------------------------------------------------------------------------------------------
62 --------------------------------------------------------------------------------------------------------------------------------
63 --------------------------------------------------------------------------------------------------------------------------------
64  
65 ---------------------------------------------------
66 -- ISync:MainFrame_Binding()
67 ---------------------------------------------------
68 function ISync:MainFrame_Binding()
69 if(ISYNC_LOADYES == 1) then
70 if ( ISync_MainFrame:IsVisible() ) then ISync_MainFrame:Hide(); else ISync_MainFrame:Show(); end
71 end
72 end
73  
74  
75 ---------------------------------------------------
76 -- ISync:Main_DD_SetSelectedID()
77 ---------------------------------------------------
78 function ISync:Main_DD_SetSelectedID(frame, id, names)
79 UIDropDownMenu_SetSelectedID(frame, id);
80 if( not frame ) then
81 frame = this;
82 end
83 UIDropDownMenu_SetText(names[id].name, frame);
84 end
85  
86  
87 ---------------------------------------------------
88 -- ISync:Main_DD_Initialize()
89 ---------------------------------------------------
90 function ISync:Main_DD_Initialize()
91 local info;
92 for i = 1, getn(ISYNC_DD_SORT), 1 do
93 info = { };
94 info.text = ISYNC_DD_SORT[i].name;
95 info.func = ISync.Main_DD_OnClick;
96 UIDropDownMenu_AddButton(info);
97 end
98 end
99  
100  
101 ---------------------------------------------------
102 -- ISync:Main_DD_Load()
103 ---------------------------------------------------
104 function ISync:Main_DD_Load()
105 UIDropDownMenu_Initialize(ISync_MainFrame_DropDown, ISync.Main_DD_Initialize);
106 ISync:Main_DD_SetSelectedID(ISync_MainFrame_DropDown, 1, ISYNC_DD_SORT);
107 UIDropDownMenu_SetWidth(80);
108 UIDropDownMenu_SetButtonWidth(24);
109 UIDropDownMenu_JustifyText("LEFT", ISync_MainFrame_DropDown)
110 end
111  
112  
113 ---------------------------------------------------
114 -- ISync:Main_DD_OnClick()
115 ---------------------------------------------------
116 function ISync:Main_DD_OnClick()
117 local oldID = UIDropDownMenu_GetSelectedID(ISync_MainFrame_DropDown);
118 UIDropDownMenu_SetSelectedID(ISync_MainFrame_DropDown, this:GetID());
119  
120 if( oldID ~= this:GetID() ) then
121 ISync:SetVar({"OPT","RARITY_DD"}, ISYNC_DD_SORT[UIDropDownMenu_GetSelectedID(ISync_MainFrame_DropDown)].sortType, "TRUE"); --TRUE=force
122 FauxScrollFrame_SetOffset(ISync_MainFrame_ListScrollFrame, 0);
123 getglobal("ISync_MainFrame_ListScrollFrameScrollBar"):SetValue(0);
124 ISync:ListSort();
125 ISync:UpdateScrollFrame();
126 end
127 end
128  
129  
130 --------------------------------------------------------------------------------------------------------------------------------
131 --------------------------------------------------------------------------------------------------------------------------------
132 --------------------------------------------------------------------------------------------------------------------------------
133 --------------------------------------------------------------------------------------------------------------------------------
134 --------------------------------------------------------------------------------------------------------------------------------
135 --------------------------------------------------------------------------------------------------------------------------------
136  
137  
138 ---------------------------------------------------
139 -- ISync:TabClick()
140 ---------------------------------------------------
141 function ISync:TabClick()
142  
143 this:SetChecked(0);
144  
145 if(this:GetID() == 1) then
146 ISync_OptionsFrame:Hide();
147 ISync_FiltersFrame:Hide();
148 if ( ISync_SearchFrame:IsVisible() ) then ISync_SearchFrame:Hide(); else ISync_SearchFrame:Show(); end
149 elseif(this:GetID() == 2) then
150 ISync_FiltersFrame:Hide();
151 ISync_SearchFrame:Hide();
152 if ( ISync_OptionsFrame:IsVisible() ) then ISync_OptionsFrame:Hide(); else ISync_OptionsFrame:Show(); end
153 elseif(this:GetID() == 3) then
154 ISync_OptionsFrame:Hide();
155 ISync_SearchFrame:Hide();
156 if ( ISync_FiltersFrame:IsVisible() ) then ISync_FiltersFrame:Hide(); else ISync_FiltersFrame:Show(); end
157 elseif(this:GetID() == 4) then
158 if ( ISync_FavFrame:IsVisible() ) then ISync_FavFrame:Hide(); else ISync_FavFrame:Show(); end
159 elseif(this:GetID() == 5) then
160 ISync:ItemIDSearch_Binding();
161 elseif(this:GetID() == 6) then
162 ISync:BV_Binding();
163 end
164  
165 end
166  
167  
168  
169 --------------------------------------------------------------------------------------------------------------------------------
170 --------------------------------------------------------------------------------------------------------------------------------
171 --------------------------------------------------------------------------------------------------------------------------------
172 --------------------------------------------------------------------------------------------------------------------------------
173 --------------------------------------------------------------------------------------------------------------------------------
174 --------------------------------------------------------------------------------------------------------------------------------
175  
176 ---------------------------------------------------
177 -- ISync:Main_Refresh()
178 ---------------------------------------------------
179 function ISync:Main_Refresh()
180  
181 if(ISYNC_LOADYES == 0) then return nil; end --don't run if disabled
182  
183 FauxScrollFrame_SetOffset(ISync_MainFrame_ListScrollFrame, 0);
184 getglobal("ISync_MainFrame_ListScrollFrameScrollBar"):SetValue(0);
185 ISync:BuildIndex();
186 ISync:UpdateScrollFrame();
187  
188 end
189  
190  
191 --------------------------------------------------
192 -- ISync:BuildIndex()
193 ---------------------------------------------------
194 function ISync:BuildIndex()
195  
196 if(ISYNC_LOADYES == 0) then return nil; end --don't run if disabled
197  
198 --if we had a refresh check then set it back to zero
199 if(ISync:SetVar({"REQUIRED","REFRESH"}, 1, "COMPARE")) then ISync:SetVar({"REQUIRED","REFRESH"}, 0, "TRUE"); end
200 ISync_MainFrameUpdate:Hide();
201 ------------------------------------------------------
202  
203 local iNew, iValid, iLost, index, value, sParseLink;
204  
205 iValid = 0; --reset
206 iLost = 0; --reset
207  
208  
209 --start the display procedure
210 if(ISYNC_SHOWSEARCH_CHK == 1) then
211  
212 ISync_SortIndex = { };
213 ISync_SortIndex_Name = { };
214 iNew = 1;
215  
216 if(not ISyncDB) then return nil; end
217 if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end
218  
219 --do the loop
220 for index, value in ISyncDB[ISYNC_REALM_NUM] do
221  
222 sParseLink = ISync:FetchDB(index, "subitem");
223  
224 if(not sParseLink) then
225  
226 --check
227 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
228  
229 --do we have a valid item?
230 if(name_X and quality_X and ISync:SF_MatchSearch(index, name_X, quality_X)) then
231  
232 --check to see if we've already added the name
233 if(not ISync_SortIndex_Name[name_X]) then
234  
235 ISync_SortIndex[iNew] = { };
236 ISync_SortIndex[iNew].name = name_X;
237 ISync_SortIndex[iNew].quality = quality_X;
238 ISync_SortIndex[iNew].id = index..":0:0:0";
239 ISync_SortIndex[iNew].idcore = index;
240  
241 ISync_SortIndex_Name[name_X] = 1;
242  
243 iNew = iNew + 1;
244 iValid = iValid + 1;
245  
246 else
247 ISync_SortIndex[iNew] = { };
248 ISync_SortIndex[iNew].name = name_X..iNew; --add it but with a fake number at end
249 ISync_SortIndex[iNew].realname = name_X; --same name item
250 ISync_SortIndex[iNew].quality = quality_X;
251 ISync_SortIndex[iNew].idcore = index;
252 ISync_SortIndex[iNew].id = index..":0:0:0";
253  
254 ISync_SortIndex_Name[name_X..iNew] = 1;
255  
256 iNew = iNew + 1;
257 iValid = iValid + 1;
258  
259 end--if(not ISync_SortIndex_Name[name_X]) then
260  
261  
262 end--if(name_X and quality_X and ISync:SF_MatchSearch(index, name_X, quality_X)) then
263  
264 else
265  
266 -----------------------------------
267 --ADD SUBITEMS AS WELL
268 if(sParseLink and type(sParseLink) == "table") then
269  
270 for qindex, qvalue in sParseLink do
271  
272 --check
273 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:"..qvalue..":0");
274  
275 --do we have a valid item? match with primary quality as well
276 if(name_X and quality_X and ISync:SF_MatchSearch(index, name_X, quality_X)) then
277  
278 ISync_SortIndex[iNew] = { };
279 ISync_SortIndex[iNew].name = name_X;
280 ISync_SortIndex[iNew].quality = quality_X;
281 ISync_SortIndex[iNew].id = index..":0:"..qvalue..":0";
282 ISync_SortIndex[iNew].idcore = index;
283 ISync_SortIndex[iNew].subid = qvalue;
284  
285 iNew = iNew + 1;
286 iValid = iValid + 1;
287 end
288  
289 end--for qindex, qvalue in sParseLink do
290  
291 end--if(type(sParseLink) == "table") then
292 -----------------------------------
293  
294 end--if(not sParseLink) then
295  
296  
297 end--for index, value in ISyncDB[ISync_RealmNum] do
298  
299  
300  
301 elseif(ISYNC_SHOWINVALID_CHK == 1) then
302  
303 ISync_SortIndex = { };
304 ISync_SortIndex_Name = { };
305 iNew = 1;
306  
307 if(not ISyncDB) then return nil; end
308 if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end
309  
310 --do the loop
311 for index, value in ISyncDB[ISYNC_REALM_NUM] do
312  
313 sParseLink = ISync:FetchDB(index, "subitem");
314  
315 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
316  
317 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
318  
319 if(not name_X) then
320  
321 ISync_SortIndex[iNew] = { };
322  
323 if(ISyncDB_Names[index]) then
324 ISync_SortIndex[iNew].name = ISyncDB_Names[index];
325 else
326 ISync_SortIndex[iNew].name = index..":0".." "..ISYNC_SHOWSUBITEM2; --add it but with a fake number at end
327 end
328 ISync_SortIndex[iNew].quality = 0;
329 ISync_SortIndex[iNew].idcore = index;
330 ISync_SortIndex[iNew].id = index..":0:0:0";
331  
332 iNew = iNew + 1;
333 iLost = iLost + 1;
334 end
335  
336  
337 else --it has subitems
338  
339 --make sure it's a table
340 if(type(sParseLink) == "table") then
341  
342 for qindex, qvalue in sParseLink do
343  
344 --check
345 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:"..qvalue..":0");
346  
347 --do we have a valid item?
348 if(not name_X) then
349  
350 ISync_SortIndex[iNew] = { };
351  
352 if(ISyncDB_Names[index]) then
353 ISync_SortIndex[iNew].name = ISyncDB_Names[index].." "..ISYNC_SHOWSUBITEM;
354 else
355 ISync_SortIndex[iNew].name = index..":"..qvalue.." "..ISYNC_SHOWSUBITEM2; --add it but with a fake number at end
356 end
357  
358 ISync_SortIndex[iNew].quality = 0;
359 ISync_SortIndex[iNew].id = index..":0:"..qvalue..":0";
360 ISync_SortIndex[iNew].idcore = index;
361 ISync_SortIndex[iNew].subid = qvalue;
362  
363 iNew = iNew + 1;
364 iLost = iLost + 1
365 end
366  
367 end--for qindex, qvalue in sParseLink do
368  
369 end--if(type(sParseLink) == "table") then
370  
371 end--if(not sParseLink) then
372  
373 end--for index, value in ISyncDB[ISync_RealmNum] do
374  
375  
376  
377 else--do a regular display
378  
379 ISync_SortIndex = { };
380 ISync_SortIndex_Name = { };
381 iNew = 1;
382  
383 if(not ISyncDB) then return nil; end
384 if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end
385  
386  
387 --do the loop
388 for index, value in ISyncDB[ISYNC_REALM_NUM] do
389  
390 sParseLink = ISync:FetchDB(index, "subitem");
391  
392 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
393  
394 --check
395 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
396  
397 --do we have a valid item?
398 if(name_X and quality_X) then
399  
400 --fix the quality if it needs changing, only for primary items
401 if(not ISync:FetchDB(index, "quality", quality_X)) then
402 ISync:SetDB(index, "quality", quality_X);
403 end
404  
405 --check to see if we've already added the name
406 if(not ISync_SortIndex_Name[name_X]) then
407  
408 ISync_SortIndex[iNew] = { };
409 ISync_SortIndex[iNew].name = name_X;
410 ISync_SortIndex[iNew].quality = quality_X;
411 ISync_SortIndex[iNew].id = index..":0:0:0";
412 ISync_SortIndex[iNew].idcore = index;
413  
414 ISync_SortIndex_Name[name_X] = 1;
415  
416 --check for stored names
417 if(not ISyncDB_Names[index]) then ISyncDB_Names[index] = name_X; end
418 if(name_X and ISyncDB_Names[index] and ISyncDB_Names[index] ~= name_X) then ISyncDB_Names[index] = name_X; end
419  
420 iNew = iNew + 1;
421 iValid = iValid + 1;
422  
423 else
424 ISync_SortIndex[iNew] = { };
425 ISync_SortIndex[iNew].name = name_X..iNew; --add it but with a fake number at end
426 ISync_SortIndex[iNew].realname = name_X; --same name item
427 ISync_SortIndex[iNew].quality = quality_X;
428 ISync_SortIndex[iNew].idcore = index;
429 ISync_SortIndex[iNew].id = index..":0:0:0";
430  
431 ISync_SortIndex_Name[name_X..iNew] = 1;
432  
433 if(not ISyncDB_Names[index]) then ISyncDB_Names[index] = name_X; end
434 if(name_X and ISyncDB_Names[index] and ISyncDB_Names[index] ~= name_X) then ISyncDB_Names[index] = name_X; end
435  
436 iNew = iNew + 1;
437 iValid = iValid + 1;
438  
439 end--if(not ISync_SortIndex_Name[name_X]) then
440  
441  
442 else
443 iLost = iLost + 1;
444 end--if(name_X and quality_X) then
445  
446  
447 else --it has subitems
448  
449 --make sure it's a table
450 if(type(sParseLink) == "table") then
451  
452 for qindex, qvalue in sParseLink do
453  
454 --check
455 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:"..qvalue..":0");
456  
457 --do we have a valid item?
458 if(name_X and quality_X) then
459  
460 ISync_SortIndex[iNew] = { };
461 ISync_SortIndex[iNew].name = name_X;
462 ISync_SortIndex[iNew].quality = quality_X;
463 ISync_SortIndex[iNew].id = index..":0:"..qvalue..":0";
464 ISync_SortIndex[iNew].idcore = index;
465 ISync_SortIndex[iNew].subid = qvalue;
466  
467 iNew = iNew + 1;
468 iValid = iValid + 1;
469  
470 else
471 iLost = iLost + 1;
472 end
473  
474 end--for qindex, qvalue in sParseLink do
475  
476 end--if(type(sParseLink) == "table") then
477  
478 end--if(not sParseLink) then
479  
480 end--for index, value in ISyncDB[ISync_RealmNum] do
481  
482 --valid, invalid nums
483 ISync:SetVar({"OPT","ITEMCOUNT_VALID"}, iValid, "TRUE");
484 ISync:SetVar({"OPT","ITEMCOUNT_INVALID"}, iLost, "TRUE");
485  
486 end--end build array
487  
488  
489 ISync_SortIndex_Name = nil;
490  
491 ISync:ListSort();
492 ISync_SortIndex.onePastEnd = iNew;
493 ISync_SortIndex.total = (iValid+iLost);
494 ISync_SortIndex.valid = iValid;
495 ISync_SortIndex.invalid = iLost;
496  
497 ISync:ItemDisplay_Update();
498  
499 end
500  
501  
502  
503 ---------------------------------------------------
504 -- ISync:ListSort()
505 ---------------------------------------------------
506 function ISync:ListSort()
507  
508 if( ISYNC_DD_SORT[UIDropDownMenu_GetSelectedID(ISync_MainFrame_DropDown)].sortType ) then
509  
510 local sortType = ISYNC_DD_SORT[UIDropDownMenu_GetSelectedID(ISync_MainFrame_DropDown)].sortType;
511  
512 if( ISync:SetVar({"OPT","RARITY_DD"}, "name") == "name" ) then
513  
514 ISync:Main_DD_SetSelectedID(ISync_MainFrame_DropDown, 1, ISYNC_DD_SORT);
515  
516 table.sort(ISync_SortIndex, ISync_SortByName);
517  
518 elseif( ISync:SetVar({"OPT","RARITY_DD"}, "name") == "rarity" ) then
519  
520 ISync:Main_DD_SetSelectedID(ISync_MainFrame_DropDown, 2, ISYNC_DD_SORT);
521  
522 table.sort(ISync_SortIndex, ISync_SortColor);
523  
524 end
525  
526  
527 end
528  
529  
530 end
531  
532  
533  
534 ---------------------------------------------------
535 -- ISync_SortByName()
536 ---------------------------------------------------
537 function ISync_SortByName(elem1, elem2)
538  
539 return elem1.name < elem2.name;
540  
541 end
542  
543 ---------------------------------------------------
544 -- ISync_SortColor()
545 ---------------------------------------------------
546 function ISync_SortColor(elem1, elem2)
547 local color1, color2;
548  
549 --get the corresponding quality
550 color1 = elem1.quality;
551 color2 = elem2.quality;
552  
553 color1 = tonumber(color1);
554 color2 = tonumber(color2);
555  
556 if(color1 and color2) then
557  
558 --this sorts the name if the colors match
559 --that way the rarity are also alphabatized within the same rarity
560 if( color1 == color2 ) then
561 return elem1.name < elem2.name;
562 end
563  
564 --return the color if it doesn't match
565 return color2 < color1;
566  
567 else
568 return nil;
569 end
570  
571 end
572  
573  
574 ---------------------------------------------------
575 -- ISync:UpdateScrollFrame()
576 ---------------------------------------------------
577 function ISync:UpdateScrollFrame()
578  
579 local ISYNC_HEIGHT = 16;
580 local ISYNC_SHOWN = 23;
581 local LAST_SHOWN = 1;
582  
583 if(ISYNC_LOADYES == 0) then return nil; end --don't run if disabled
584  
585 if( not ISync_SortIndex or not ISync_SortIndex.onePastEnd) then
586 ISync:BuildIndex();
587 end
588  
589 --double check
590 if(not ISync_SortIndex.onePastEnd) then return nil; end
591  
592 --valid count and invalid count
593 if(ISYNC_SHOWINVALID_CHK == 1) then
594 ISync_MainFrameInfo:SetText("|c0000FF00"..ISYNC_SHOWVALID..":|r |c00BDFCC90|r\n|c00FF0000"..ISYNC_SHOWINVALID..":|r |c00BDFCC9"..ISync_SortIndex.invalid.."|r");
595 else
596 ISync_MainFrameInfo:SetText("|c0000FF00"..ISYNC_SHOWVALID..":|r |c00BDFCC9"..ISync_SortIndex.valid.."|r\n|c00FF0000"..ISYNC_SHOWINVALID..":|r |c00BDFCC9"..ISync_SortIndex.invalid.."|r");
597 end
598  
599 --Since patch 1.4 the 5th arguement must be nill or an error will occur
600 FauxScrollFrame_Update(ISync_MainFrame_ListScrollFrame, ISync_SortIndex.onePastEnd - 1, ISYNC_SHOWN, ISYNC_HEIGHT, nil);
601  
602 --do loop until all slots are filled, or we are out of information
603 for iItem = 1, ISYNC_SHOWN, 1 do
604  
605 local itemIndex = iItem + FauxScrollFrame_GetOffset(ISync_MainFrame_ListScrollFrame);
606 local IMItemObj = getglobal("ISyncItem"..iItem);
607 local IMItemObj_Text = getglobal("ISyncItem"..iItem.."Text");
608 local IMItemObj_Indexed = getglobal("ISyncItem"..iItem.."SubItem");
609 local IMItemObj_GB = getglobal("ISync_ItemIDGB_Button"..iItem);
610 local IMItemObj_GB_Blip = getglobal("ISync_ItemIDGB_Button"..iItem.."_BlipTexture");
611  
612  
613 if(IMItemObj) then
614  
615 --check if were still within bounds
616 if( itemIndex < ISync_SortIndex.onePastEnd and ISync_SortIndex[itemIndex]) then
617  
618 --if not subitem then process normally
619 if(not ISync_SortIndex[itemIndex].realname) then
620  
621 IMItemObj_Text:SetPoint( "LEFT", 19, 1 );
622 IMItemObj_Indexed:Hide();
623 if(ISYNC_SHOWINVALID_CHK == 0) then
624 IMItemObj:SetText(ISync_SortIndex[itemIndex].name);
625 else
626 IMItemObj:SetText("|c00FC5252"..ISync_SortIndex[itemIndex].name.."|r");
627 end
628 IMItemObj.storeID = ISync_SortIndex[itemIndex].id; --store the itemid
629 IMItemObj.storeCore = ISync_SortIndex[itemIndex].idcore;
630  
631 --its a subitem
632 else
633 IMItemObj_Text:SetPoint( "LEFT", 29, 1 );
634 IMItemObj_Indexed:Show();
635 if(ISYNC_SHOWINVALID_CHK == 0) then
636 IMItemObj:SetText(ISync_SortIndex[itemIndex].realname);
637 else
638 IMItemObj:SetText("|c00FC5252"..ISync_SortIndex[itemIndex].realname.."|r");
639 end
640 IMItemObj.storeID = ISync_SortIndex[itemIndex].id; --store the itemid
641 IMItemObj.storeCore = ISync_SortIndex[itemIndex].idcore;
642  
643 end
644  
645 --store the subitem for items to allow for deletion
646 if(ISync_SortIndex[itemIndex].subid) then
647 IMItemObj.storeSubID = ISync_SortIndex[itemIndex].subid;
648 else
649 IMItemObj.storeSubID = nil;
650 end
651 IMItemObj.itemIndex = itemIndex; --store the itemindex for deletion
652  
653 --color accordingly (only when not invalid view)
654 if(ISYNC_SHOWINVALID_CHK == 0) then
655 local grabColor = ITEM_QUALITY_COLORS[tonumber(ISync_SortIndex[itemIndex].quality)];
656 if( grabColor) then
657 IMItemObj:SetTextColor(grabColor.r, grabColor.g, grabColor.b);
658 IMItemObj.r = grabColor.r;
659 IMItemObj.g = grabColor.g;
660 IMItemObj.b = grabColor.b;
661 else
662 IMItemObj.r = 0;
663 IMItemObj.g = 0;
664 IMItemObj.b = 0;
665 end
666 end
667  
668 --check user inputted (only when not invalid view)
669 if(ISYNC_SHOWINVALID_CHK == 0) then
670 if(ISync:FetchDB(ISync_SortIndex[itemIndex].idcore, "idchk", 1)) then
671  
672 IMItemObj_GB_Blip:SetTexture("Interface\\AddOns\\ItemSync\\images\\ISync_ItemID_ItemPic");
673 ISYNC_ITEMID_GREENBUTTON_WARNING2 = ISYNC_ITEMID_GREENBUTTON_WARNING;
674 IMItemObj_GB:Show();
675 IMItemObj_GB.Obj = nil;
676 else
677 IMItemObj_GB:Hide();
678 end
679 else
680 IMItemObj_GB_Blip:SetTexture("Interface\\AddOns\\ItemSync\\images\\ISync_Invalid_ItemPic");
681 ISYNC_ITEMID_GREENBUTTON_WARNING2 = "|c00FF0000"..ISYNC_ITEMISINVALID_TOOLTIP1.."|r";
682 IMItemObj_GB:Show();
683 IMItemObj_GB.Obj = IMItemObj;
684 end
685  
686 --show it
687 IMItemObj:Show();
688  
689 --we deleted an item
690 elseif( itemIndex < ISync_SortIndex.onePastEnd and not ISync_SortIndex[itemIndex]) then
691  
692 IMItemObj.storeID = nil;
693 IMItemObj.storeCore = nil;
694 IMItemObj.storeSubID = nil;
695 IMItemObj.itemIndex = nil;
696 IMItemObj:SetText("|c00FC5252"..ISYNC_DELETE_ITEMMSG.."|r");
697 IMItemObj:Show();
698 IMItemObj_Indexed:Hide();
699 IMItemObj_GB:Hide();
700  
701 else
702 IMItemObj.storeID = nil;
703 IMItemObj.storeCore = nil;
704 IMItemObj.storeSubID = nil;
705 IMItemObj.itemIndex = nil;
706 IMItemObj:SetText("");
707 IMItemObj:Hide();
708 IMItemObj_Indexed:Hide();
709 IMItemObj_GB:Hide();
710  
711  
712 end--if( itemIndex < ISync_SortIndex.onePastEnd ) then
713  
714 end--if(IMItemObj) then
715  
716 end--for iItem = 1, ISYNC_SHOWN, 1 do
717  
718  
719  
720 end
721  
722  
723 --------------------------------------------------------------------------------------------------------------------------------
724 --------------------------------------------------------------------------------------------------------------------------------
725 --------------------------------------------------------------------------------------------------------------------------------
726 --------------------------------------------------------------------------------------------------------------------------------
727 --------------------------------------------------------------------------------------------------------------------------------
728 --------------------------------------------------------------------------------------------------------------------------------
729  
730  
731 ---------------------------------------------------
732 -- ISync:ButtonEnter()
733 ---------------------------------------------------
734 function ISync:ButtonEnter()
735  
736 if(not this.storeID) then return nil; end
737  
738 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X, invType_X, icon_X = GetItemInfo("item:"..this.storeID);
739  
740 if(name_X) then
741 ISync_MainFrame.TooltipButton = this:GetID();
742 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
743 GameTooltip:SetHyperlink(link_X);
744 ISync:Do_Parse(UIParent, ISyncTooltip, this.storeCore, "item:"..this.storeID);
745 ISync:SendtoMods(GameTooltip, name_X, "item:"..this.storeID, 1, quality_X);
746 else
747 ISync_MainFrame.TooltipButton = this:GetID();
748 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
749 GameTooltip:SetHyperlink("item:"..this.storeID);
750  
751 --something went wrong so lets show a message
752 if(not GameTooltip:IsVisible()) then
753  
754 ISync_MainFrame.TooltipButton = this:GetID();
755 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
756 GameTooltip:AddLine(" ", 0, 0, 0);
757 GameTooltip:AddLine("|c00FF0000"..ISYNC_ITEMISINVALID_TOOLTIP1.."|r", 0, 0, 0);
758 GameTooltip:AddLine("|c00A2D96F"..ISYNC_ITEMISINVALID_TOOLTIP2.."|r", 0, 0, 0);
759 GameTooltip:AddLine("|c00FF0000"..ISYNC_ITEMISINVALID_TOOLTIP3.."|r", 0, 0, 0);
760 GameTooltip:AddLine(" ", 0, 0, 0);
761 GameTooltip:AddLine("|c0000FF00"..ISYNC_BT_ITEMID..":|r |c00BDFCC9"..this.storeID.."|r", 0, 0, 0);
762 GameTooltip:AddLine(ISYNC_ITEMISINVALID_TOOLTIP4);
763 GameTooltip:Show();
764  
765 elseif(GameTooltip:IsVisible()) then
766  
767 GameTooltip:AddLine(" ", 0, 0, 0);
768 GameTooltip:AddLine("|c00FF0000"..ISYNC_ITEMISINVALID_TOOLTIP1.."|r", 0, 0, 0);
769 GameTooltip:AddLine("|c00A2D96F"..ISYNC_ITEMISINVALID_TOOLTIP2.."|r", 0, 0, 0);
770 GameTooltip:AddLine("|c00FF0000"..ISYNC_ITEMISINVALID_TOOLTIP3.."|r", 0, 0, 0);
771 GameTooltip:AddLine(" ", 0, 0, 0);
772 GameTooltip:AddLine("|c0000FF00"..ISYNC_BT_ITEMID..":|r |c00BDFCC9"..this.storeID.."|r", 0, 0, 0);
773 GameTooltip:AddLine(ISYNC_ITEMISINVALID_TOOLTIP4);
774 GameTooltip:Show();
775  
776 end
777  
778 end
779  
780 end
781  
782  
783 ---------------------------------------------------
784 -- ISync:ButtonClick()
785 ---------------------------------------------------
786 function ISync:ButtonClick(sButton)
787  
788 if(not this.storeID) then return nil; end
789  
790  
791 if(ISYNC_SHOWINVALID_CHK > 0) then
792  
793 ISync_ItemIDFrameEdit:SetText(this.storeID);
794 ISync_ItemIDFrame:Show();
795  
796 return nil;
797 end
798  
799 --special thanks to Axu for the code :) Support for AxuItemMenus
800 if (AxuItemMenus_EvocationTest and this.storeID and AxuItemMenus_EvocationTest(sButton, "isync")) then
801  
802 AxuItemMenus_FillFromLink("item:"..this.storeID);
803 AxuItemMenus_OpenMenu();
804  
805 elseif (sButton == "LeftButton") then
806  
807  
808 if( ChatFrameEditBox:IsVisible() and this.storeID) then
809  
810 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..this.storeID);
811  
812 if(name_X and link_X and quality_X) then
813  
814 ChatFrameEditBox:Insert("|c"..ISync:ReturnHexColor(quality_X).."|H"..link_X.."|h["..name_X.."]|h|r");
815 end
816  
817 elseif( IsShiftKeyDown() and ChatFrameEditBox:IsVisible() and this.storeID) then
818  
819 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..this.storeID);
820  
821 if(name_X and link_X and quality_X) then
822  
823 ChatFrameEditBox:Insert("|c"..ISync:ReturnHexColor(quality_X).."|H"..link_X.."|h["..name_X.."]|h|r");
824 end
825  
826 elseif( IsControlKeyDown() and this.storeID) then
827  
828 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..this.storeID);
829  
830 if(name_X and link_X and quality_X) then
831 DressUpItemLink(link_X);
832 end
833  
834 end--end checks
835  
836  
837  
838 elseif (sButton == "RightButton") then
839  
840 if(IsAltKeyDown() and this.storeCore and this.storeID and this.itemIndex and ISync:FetchDB(this.storeCore, "chk")) then
841  
842 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..this.storeID);
843  
844 if(name_X and link_X and quality_X) then
845  
846 local newText = string.format(ISYNC_DELETE_MSGRETAKE, "|c"..ISync:ReturnHexColor(quality_X)..name_X.."|r");
847  
848 if(newText) then
849  
850 ISync_MainFrame.DEL_ItemIndex = this.itemIndex;
851 ISync_MainFrame.DEL_CoreID = this.storeCore;
852 if(this.storeSubID) then ISync_MainFrame.DEL_SubID = this.storeSubID; end
853  
854 StaticPopupDialogs["ISYNC_DELETEITEM_CONFIRM"].text = TEXT(newText);
855 StaticPopup_Show("ISYNC_DELETEITEM_CONFIRM");
856 end
857  
858 end--if(name_X and link_X and quality_X) then
859  
860 --add to favorites
861 elseif(IsShiftKeyDown() and IsControlKeyDown() and this.storeCore and this.storeID and this.itemIndex) then
862  
863 if(not ISyncFav or not ISyncFav[UnitName("player")]) then return nil; end
864  
865 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..this.storeID);
866  
867 if(name_X and link_X and quality_X) then
868  
869 if(this.storeSubID) then
870 ISyncFav[UnitName("player")][this.storeCore..":"..this.storeSubID] = 1;
871 else
872 ISyncFav[UnitName("player")][this.storeCore..":0"] = 1;
873 end
874  
875  
876 ISync:Print("|c00A2D96FItemSync:|r "..ISYNC_ADDEDTOFAV.." <<>> |r|c"..ISync:ReturnHexColor(quality_X)..this:GetText().."|r");
877 ISync:Fav_Refresh();
878  
879 end
880  
881 end-- if(IsAltKeyDown() and this.storeCore and this.storeID and ISync:FetchDB(this.storeCore, "chk")) then
882  
883  
884 end
885  
886 end
887  
888  
889 ---------------------------------------------------
890 -- ISync:BlipClick()
891 ---------------------------------------------------
892 function ISync:BlipClick(sButton)
893  
894 if(ISYNC_SHOWINVALID_CHK > 0) then
895  
896 local getObj = getglobal((this:GetParent()):GetName());
897 if(not getObj) then return nil; end
898  
899 getObj = getObj.Obj;
900 if(not getObj) then return nil; end
901  
902 local newText = string.format(ISYNC_DELETE_MSGRETAKE, "|c00FC5252"..getObj:GetText().."|r");
903  
904 if(newText) then
905  
906 ISync_MainFrame.DEL_ItemIndex = getObj.itemIndex;
907 ISync_MainFrame.DEL_CoreID = getObj.storeCore;
908 if(getObj.storeSubID) then ISync_MainFrame.DEL_SubID = getObj.storeSubID; end
909  
910 StaticPopupDialogs["ISYNC_DELETEITEM_CONFIRM"].text = TEXT(newText);
911 StaticPopup_Show("ISYNC_DELETEITEM_CONFIRM");
912 end
913  
914 end
915  
916 end
917  
918  
919 ---------------------------------------------------
920 -- ISync:DeleteItem()
921 ---------------------------------------------------
922 function ISync:DeleteItem()
923  
924 --first check to see if we have something
925 if(not ISync_MainFrame.DEL_ItemIndex) then return nil; end
926  
927 --it's a sub item
928 if(ISync_MainFrame.DEL_SubID) then
929 ISync:SetDB(ISync_MainFrame.DEL_CoreID, "subitem", ISync_MainFrame.DEL_SubID, "TRUE");
930 ISync_SortIndex[ISync_MainFrame.DEL_ItemIndex] = nil; --delete to show as deleted
931 if(ISYNC_SHOWINVALID_CHK > 0) then
932 ISync_SortIndex.invalid = ISync_SortIndex.invalid - 1; --decrease
933 else
934 ISync_SortIndex.valid = ISync_SortIndex.valid - 1; --decrease
935 end
936 ISync:UpdateScrollFrame(); --refresh it
937 else
938 ISyncDB[ISYNC_REALM_NUM][ISync_MainFrame.DEL_CoreID] = nil;
939 ISync_SortIndex[ISync_MainFrame.DEL_ItemIndex] = nil; --delete to show as deleted
940 if(ISYNC_SHOWINVALID_CHK > 0) then
941 ISync_SortIndex.invalid = ISync_SortIndex.invalid - 1; --decrease
942 else
943 ISync_SortIndex.valid = ISync_SortIndex.valid - 1; --decrease
944 end
945 ISync:UpdateScrollFrame(); --refresh it
946 end
947  
948  
949 end
950  
951  
952 ---------------------------------------------------
953 -- ISync:SendtoMods()
954 ---------------------------------------------------
955 function ISync:SendtoMods(sTooltip, sName, sLink, sQty, sQuality)
956  
957 if(not sTooltip or not sName or not sQty) then return nil; end
958 if(sTooltip.SendtoMods) then return nil; end
959  
960 --AuctionMatrix/AuctionSync
961 if(AuctionMatrix_AddTooltipMoney and ISync:SetVar({"MOD","AMAS"}, 1, "COMPARE")) then
962 AuctionMatrix_AddTooltipMoney(sName, sTooltip, sQty);
963 end
964 if(AuctionSync_AddTooltip and ISync:SetVar({"MOD","AMAS"}, 1, "COMPARE")) then
965 AuctionSync_AddTooltip(sTooltip, sName, sLink, sQuality, sQty, nil);
966 end
967  
968 --Auctioneer
969 if(ENHTOOLTIP_VERSION and not EnhTooltip and ISync:SetVar({"MOD","AUCTIONEER"}, 1, "COMPARE")) then
970  
971 local Dlink = "|c"..ISync:ReturnHexColor(sQuality).. "|H"..sLink.."|h["..sName.."]|h|r";
972 if (TT_Clear and TT_TooltipCall and TT_Show) then
973 TT_Clear();
974 TT_TooltipCall(sTooltip, sName, Dlink, sQuality, sQty, 0);
975 TT_Show(sTooltip);
976 end
977  
978 elseif(ENHTOOLTIP_VERSION and EnhTooltip and ISync:SetVar({"MOD","AUCTIONEER"}, 1, "COMPARE")) then
979  
980 if(EnhancedTooltip:IsVisible()) then return nil; end
981  
982 local Dlink = "|c"..ISync:ReturnHexColor(sQuality).. "|H"..sLink.."|h["..sName.."]|h|r";
983 EnhTooltip.ClearTooltip();
984 EnhTooltip.TooltipCall(sTooltip, sName, Dlink, sQuality, sQty, 0);
985 EnhTooltip.ShowTooltip(sTooltip);
986  
987 end
988  
989 --ReagentInfo
990 if(ReagentInfo_AddTooltipInfo and ISync:SetVar({"MOD","REAGENTINFO"}, 1, "COMPARE")) then
991 ReagentInfo_AddTooltipInfo(sTooltip, sName);
992 end
993  
994 sTooltip.SendtoMods = nil;
995  
996 end
997  
998  
999 --------------------------------------------------------------------------------------------------------------------------------
1000 --------------------------------------------------------------------------------------------------------------------------------
1001 --------------------------------------------------------------------------------------------------------------------------------
1002 --------------------------------------------------------------------------------------------------------------------------------
1003 --------------------------------------------------------------------------------------------------------------------------------
1004 --------------------------------------------------------------------------------------------------------------------------------