vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[--------------------------------------------------------------------------------
2 ItemSync Filters Framework
3  
4 Author: Derkyle
5 Website: http://www.manaflux.com
6 -----------------------------------------------------------------------------------]]
7  
8 ---------------------------------------------------
9 -- ISync:Filter_DD_SetSelectedID
10 ---------------------------------------------------
11 function ISync:Filter_DD_SetSelectedID(frame, id, names)
12 UIDropDownMenu_SetSelectedID(frame, id);
13 if( not frame ) then
14 frame = this;
15 end
16 UIDropDownMenu_SetText(names[id].name, frame);
17 end
18  
19  
20  
21 ---------------------------------------------------
22 -- ISync:Filter_DD_Load
23 ---------------------------------------------------
24 function ISync:Filter_DD_Load()
25  
26 --rarity
27 UIDropDownMenu_Initialize(ISync_FilterPurgeRare_DropDown, ISync.Filter_DD_Initialize);
28 ISync:Filter_DD_SetSelectedID(ISync_FilterPurgeRare_DropDown, 1, ISYNC_DD_RARITY);
29 UIDropDownMenu_JustifyText("LEFT", ISync_FilterPurgeRare_DropDown)
30 end
31  
32  
33  
34  
35 ---------------------------------------------------
36 -- ISync:Filter_DD_Initialize
37 ---------------------------------------------------
38 function ISync:Filter_DD_Initialize()
39 local info;
40 for i = 1, getn(ISYNC_DD_RARITY), 1 do
41 info = { };
42 info.text = ISYNC_DD_RARITY[i].name;
43 info.func = ISync.Filter_DD_OnClick;
44 UIDropDownMenu_AddButton(info);
45 end
46  
47 info = nil;
48 end
49  
50  
51 ---------------------------------------------------
52 -- ISync:Filter_DD_OnClick
53 ---------------------------------------------------
54 function ISync:Filter_DD_OnClick()
55 UIDropDownMenu_SetSelectedID(ISync_FilterPurgeRare_DropDown, this:GetID());
56 end
57  
58  
59  
60 --------------------------------------------------------------------------------------------------------------------------------
61 --------------------------------------------------------------------------------------------------------------------------------
62 --------------------------------------------------------------------------------------------------------------------------------
63 --------------------------------------------------------------------------------------------------------------------------------
64 --------------------------------------------------------------------------------------------------------------------------------
65 --------------------------------------------------------------------------------------------------------------------------------
66  
67  
68 ---------------------------------------------------
69 --ISync:FilterPurgeInvalid
70 ---------------------------------------------------
71 function ISync:FilterPurgeInvalid()
72  
73 --make sure we have stuff to work with duh
74 if(not ISyncDB or not ISYNC_REALM_NUM) then return nil; end
75 if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end
76  
77 local index, value;
78  
79 --do the loop
80 for index, value in ISyncDB[ISYNC_REALM_NUM] do
81  
82 sParseLink = ISync:FetchDB(index, "subitem");
83  
84 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
85  
86 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
87  
88 if(not name_X) then
89  
90 ISyncDB[ISYNC_REALM_NUM][index] = nil;
91 end
92  
93  
94 else --it has subitems
95  
96 --make sure it's a table
97 if(type(sParseLink) == "table") then
98  
99 for qindex, qvalue in sParseLink do
100  
101 --check
102 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:"..qvalue..":0");
103  
104 --do we have a valid item?
105 if(not name_X) then
106  
107 ISync:SetDB(index, "subitem", qvalue, "TRUE"); --remove it from array
108 end
109  
110 end--for qindex, qvalue in sParseLink do
111  
112 --check again if we removed all of the subitems
113 sParseLink = ISync:FetchDB(index, "subitem");
114  
115 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
116  
117 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
118  
119 if(not name_X) then
120  
121 ISyncDB[ISYNC_REALM_NUM][index] = nil;
122 end
123  
124 end
125  
126  
127 end--if(type(sParseLink) == "table") then
128  
129 end--if(not sParseLink) then
130  
131 end--for index, value in ISyncDB[ISync_RealmNum] do
132  
133  
134 --call a refresh
135 ISync:Main_Refresh();
136  
137 DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FItemSync: "..ISYNC_INVALIDPURGESUCCESS..".|r");
138  
139 end
140  
141  
142  
143 ---------------------------------------------------
144 -- ISync:FilterPurge
145 ---------------------------------------------------
146 function ISync:FilterPurge()
147 local storeRarity, sParseLink;
148  
149 --make sure we have stuff to work with duh
150 if(not ISyncDB or not ISYNC_REALM_NUM) then return nil; end
151 if(not ISyncDB[ISYNC_REALM_NUM]) then return nil; end
152  
153 local index, value;
154  
155 --grab rarity
156 if( ISYNC_DD_RARITY[UIDropDownMenu_GetSelectedID(ISync_FilterPurgeRare_DropDown)].sortType ) then
157  
158 local sortType = ISYNC_DD_RARITY[UIDropDownMenu_GetSelectedID(ISync_FilterPurgeRare_DropDown)].sortType;
159  
160 if( sortType == "NONE" ) then
161 storeRarity = nil;
162 else
163 storeRarity = sortType;
164 end
165  
166  
167 end
168  
169 storeRarity = tonumber(storeRarity);
170  
171 if(not storeRarity) then
172 DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FItemSync: "..ISYNC_FILTERINVALIDSELECTION..".|r");
173 return nil;
174 end
175  
176 --do the loop
177 for index, value in ISyncDB[ISYNC_REALM_NUM] do
178  
179 sParseLink = ISync:FetchDB(index, "subitem");
180  
181 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
182  
183 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
184  
185 if(quality_X and quality_X == storeRarity) then
186  
187 ISyncDB[ISYNC_REALM_NUM][index] = nil;
188 end
189  
190  
191 else --it has subitems
192  
193 --make sure it's a table
194 if(type(sParseLink) == "table") then
195  
196 for qindex, qvalue in sParseLink do
197  
198 --check
199 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:"..qvalue..":0");
200  
201 --do we have a valid item?
202 if(quality_X and quality_X == storeRarity) then
203  
204 ISync:SetDB(index, "subitem", qvalue, "TRUE"); --remove it from array
205 end
206  
207 end--for qindex, qvalue in sParseLink do
208  
209 --check again if we removed all of the subitems
210 sParseLink = ISync:FetchDB(index, "subitem");
211  
212 if(not sParseLink) then --this item has no subitems, cause it's subitem value = 0
213  
214 local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X = GetItemInfo("item:"..index..":0:0:0");
215  
216 if(quality_X and quality_X == storeRarity) then
217  
218 ISyncDB[ISYNC_REALM_NUM][index] = nil;
219 end
220  
221 end
222  
223  
224 end--if(type(sParseLink) == "table") then
225  
226 end--if(not sParseLink) then
227  
228 end--for index, value in ISyncDB[ISync_RealmNum] do
229  
230  
231 --call a refresh
232 ISync:Main_Refresh();
233  
234 DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FItemSync: "..ISYNC_FILTERPURGESUCCESS..".|r");
235  
236 end
237  
238  
239  
240  
241 ---------------------------------------------------
242 --ISync:Filter_MergeDB
243 ---------------------------------------------------
244 function ISync:Filter_MergeDB()
245  
246 local ICountServ = 0;
247  
248 for ICountServ=0, tonumber(ISync:SetVar({"REALMS","REALMCOUNT"}, 0)) do
249  
250 --make sure it's not zero because zero is used a universal database number
251 if(ICountServ ~= 0) then
252  
253 --make sure we have a database to work with
254 if(ISyncDB and ISyncDB[ICountServ] and ISyncDB[0]) then
255  
256 for index, value in ISyncDB[ICountServ] do
257  
258 --now check to see if we have in the universal database, if we don't add it
259 --if we do then delete from other server
260 if(not ISyncDB[0][index]) then
261  
262 --add it to universal zero
263 ISyncDB[0][index] = value;
264  
265 end
266  
267  
268 end
269  
270 --now delete it
271 ISyncDB[ICountServ] = nil;
272 end
273  
274 end
275  
276 end
277  
278  
279 DEFAULT_CHAT_FRAME:AddMessage("|c00A2D96FItemSync: "..ISYNC_OPTIONS_SERVER_MERGECOMPLETE.."|r");
280 end
281  
282