vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Advanced Trade Skill Window v0.4.0
2 -- copyright 2006 by Rene Schneider (Slarti on EU-Blackhand)
3  
4 -- custom sorting options script file
5  
6 atsw_customsorting={};
7 atsw_customheaders={};
8 atsw_uncategorized={};
9 atsw_opencategory=0;
10  
11 function ATSWCS_OnLoad()
12 if(atsw_customsorting[UnitName("player")]==nil) then
13 atsw_customsorting[UnitName("player")]={};
14 end
15 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]==nil) then
16 atsw_customsorting[UnitName("player")][atsw_selectedskill]={};
17 end
18 if(atsw_customheaders[UnitName("player")]==nil) then
19 atsw_customheaders[UnitName("player")]={};
20 end
21 if(atsw_customheaders[UnitName("player")][atsw_selectedskill]==nil) then
22 atsw_customheaders[UnitName("player")][atsw_selectedskill]={};
23 end
24 FauxScrollFrame_SetOffset(ATSWCSUListScrollFrame, 0);
25 FauxScrollFrame_SetOffset(ATSWCSSListScrollFrame, 0);
26 ATSWCS_UpdateUncategorizedList();
27 ATSWCS_UpdateSkillList();
28 end
29  
30 function ATSWCS_OnHide()
31  
32 end
33  
34 function ATSWCSFrame_OnEvent()
35  
36 end
37  
38 function ATSWCS_HideWindow()
39 HideUIPanel(ATSWCSFrame);
40 end
41  
42 function ATSWCS_Update()
43 ATSWCS_UpdateSkillList();
44 end
45  
46 function ATSWCS_UpdateSkillList()
47 if(atsw_customsorting[UnitName("player")]==nil) then
48 atsw_customsorting[UnitName("player")]={};
49 end
50 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]==nil) then
51 atsw_customsorting[UnitName("player")][atsw_selectedskill]={};
52 end
53 if(atsw_customheaders[UnitName("player")]==nil) then
54 atsw_customheaders[UnitName("player")]={};
55 end
56 if(atsw_customheaders[UnitName("player")][atsw_selectedskill]==nil) then
57 atsw_customheaders[UnitName("player")][atsw_selectedskill]={};
58 end
59 local totalcount=table.getn(atsw_uncategorized);
60 local offset=FauxScrollFrame_GetOffset(ATSWCSUListScrollFrame);
61 for i=1,23,1 do
62 local skillbutton=getglobal("ATSWCSSkill"..i);
63 if(atsw_uncategorized[offset+i]) then
64 skillbutton:SetText(atsw_uncategorized[offset+i].name);
65 skillbutton:Show();
66 skillbutton.skillname=atsw_uncategorized[offset+i].name;
67 local color=ATSWTypeColor[atsw_uncategorized[offset+i].type];
68 if(color) then
69 skillbutton:SetTextColor(color.r, color.g, color.b);
70 end
71 else
72 skillbutton:Hide();
73 end
74 end
75 offset=FauxScrollFrame_GetOffset(ATSWCSSListScrollFrame);
76 local header=1;
77 local skill=0;
78 local i=1-offset;
79 repeat
80 local skillbutton=nil;
81 local skillframe=nil;
82 if(i>=1 and i<=17) then
83 skillbutton=getglobal("ATSWCSCSkill"..i.."SkillButton");
84 skillframe=getglobal("ATSWCSCSkill"..i);
85 end
86 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][header] and skill==0) then
87 if(i>=1 and i<=17) then
88 skillbutton:SetText(atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name);
89 skillbutton:SetTextColor(ATSWTypeColor.header.r, ATSWTypeColor.header.g, ATSWTypeColor.header.b);
90 skillframe.skillname=atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name;
91 skillbutton:GetParent().btype="header";
92 end
93 if(header==atsw_opencategory) then
94 if(i>=1 and i<=17) then skillbutton:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up"); end
95 skill=1;
96 else
97 if(i>=1 and i<=17) then skillbutton:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up"); end
98 header=header+1;
99 end
100 if(i>=1 and i<=17) then
101 getglobal("ATSWCSCSkill"..i.."SkillButtonHighlight"):SetTexture("Interface\\Buttons\\UI-PlusButton-Hilight");
102 skillbutton:UnlockHighlight();
103 skillframe:Show();
104 skillbutton:Show();
105 getglobal("ATSWCSCSkill"..i.."MoveUp"):Show();
106 getglobal("ATSWCSCSkill"..i.."MoveDown"):Show();
107 getglobal("ATSWCSCSkill"..i.."Delete"):Show();
108 end
109 elseif(atsw_opencategory==header) then
110 if(atsw_customsorting[UnitName("player")][atsw_selectedskill] and atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name]) then
111 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill]) then
112 if(i>=1 and i<=17) then
113 skillbutton:SetText(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill].name);
114 skillframe.skillname=atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill].name;
115 skillbutton:SetTextColor(ATSWTypeColor[atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill].type].r, ATSWTypeColor[atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill].type].g, ATSWTypeColor[atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][header].name][skill].type].b);
116 skillframe:Show();
117 skillbutton:Show();
118 skillbutton:SetNormalTexture("");
119 getglobal("ATSWCSCSkill"..i.."MoveUp"):Show();
120 getglobal("ATSWCSCSkill"..i.."MoveDown"):Show();
121 getglobal("ATSWCSCSkill"..i.."Delete"):Show();
122 getglobal("ATSWCSCSkill"..i.."SkillButtonHighlight"):SetTexture("");
123 skillbutton:GetParent().btype="recipe";
124 end
125 skill=skill+1;
126 else
127 if(skill==1) then
128 if(i>=1 and i<=17) then
129 skillbutton:SetText(ATSWCS_NOTHINGINCATEGORY);
130 skillframe.skillname=ATSWCS_NOTHINGINCATEGORY;
131 skillbutton:SetTextColor(0.6, 0.6, 0.6);
132 skillframe:Show();
133 skillbutton:Show();
134 skillbutton:SetNormalTexture("");
135 getglobal("ATSWCSCSkill"..i.."SkillButtonHighlight"):SetTexture("");
136 getglobal("ATSWCSCSkill"..i.."MoveUp"):Hide();
137 getglobal("ATSWCSCSkill"..i.."MoveDown"):Hide();
138 getglobal("ATSWCSCSkill"..i.."Delete"):Hide();
139 end
140 else
141 i=i-1;
142 end
143 skill=0;
144 header=header+1;
145 end
146 else
147 if(skill==1) then
148 if(i>=1 and i<=17) then
149 skillbutton:SetText(ATSWCS_NOTHINGINCATEGORY);
150 skillframe.skillname=ATSWCS_NOTHINGINCATEGORY;
151 skillbutton:SetTextColor(0.6, 0.6, 0.6);
152 skillframe:Show();
153 skillbutton:Show();
154 skillbutton:SetNormalTexture("");
155 getglobal("ATSWCSCSkill"..i.."SkillButtonHighlight"):SetTexture("");
156 getglobal("ATSWCSCSkill"..i.."MoveUp"):Hide();
157 getglobal("ATSWCSCSkill"..i.."MoveDown"):Hide();
158 getglobal("ATSWCSCSkill"..i.."Delete"):Hide();
159 end
160 else
161 i=i-1;
162 end
163 skill=0;
164 header=header+1;
165 end
166 else
167 if(i>=1 and i<=17) then
168 skillbutton:Show();
169 skillframe:Hide();
170 skillframe.skillname=nil;
171 end
172 end
173 i=i+1;
174 until(i>17);
175 local totalcount2=0;
176 if(atsw_customheaders[UnitName("player")][atsw_selectedskill]) then
177 totalcount2=totalcount2+table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]);
178 if(atsw_opencategory~=0) then
179 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][atsw_opencategory].name]) then
180 totalcount2=totalcount2+table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][atsw_opencategory].name]);
181 else
182 totalcount2=totalcount2+1;
183 end
184 end
185 end
186 FauxScrollFrame_Update(ATSWCSUListScrollFrame, totalcount, 23, 16);
187 FauxScrollFrame_Update(ATSWCSSListScrollFrame, totalcount2, 17, 16);
188 ATSW_CreateSkillListing();
189 ATSWFrame_Update();
190 end
191  
192 function ATSWCS_UpdateUncategorizedList()
193 atsw_uncategorized={};
194 for i=1,table.getn(atsw_tradeskilllist),1 do
195 if(ATSWCS_CheckIfCategorized(atsw_tradeskilllist[i].name)==false) then
196 table.insert(atsw_uncategorized,{name=atsw_tradeskilllist[i].name, type=atsw_tradeskilllist[i].type});
197 end
198 end
199 table.sort(atsw_uncategorized,ATSWCS_SortUncategorizedList);
200 end
201  
202 function ATSWCS_SortUncategorizedList(i,j)
203 return string.lower(i.name) < string.lower(j.name);
204 end
205  
206 function ATSWCS_CheckIfCategorized(skillName)
207 if(atsw_customsorting[UnitName("player")]) then
208 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]) then
209 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
210 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
211 for k=1,table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1 do
212 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k].name==skillName) then
213 return true;
214 end
215 end
216 end
217 end
218 end
219 end
220 return false;
221 end
222  
223 function ATSWCS_AddCategory(categoryName)
224 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
225 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name==categoryName) then return; end
226 end
227 table.insert(atsw_customheaders[UnitName("player")][atsw_selectedskill],{name=categoryName, expanded=false});
228 ATSWCS_UpdateSkillList();
229 end
230  
231 function ATSWCS_MoveUp(skillName)
232 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
233 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name==skillName) then
234 if(i>1) then
235 local buffer=atsw_customheaders[UnitName("player")][atsw_selectedskill][i-1];
236 atsw_customheaders[UnitName("player")][atsw_selectedskill][i-1]=atsw_customheaders[UnitName("player")][atsw_selectedskill][i];
237 atsw_customheaders[UnitName("player")][atsw_selectedskill][i]=buffer;
238 break;
239 end
240 end
241 end
242 if(atsw_customsorting[UnitName("player")]) then
243 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]) then
244 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
245 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
246 for k=1,table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1 do
247 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k].name==skillName) then
248 if(k>1) then
249 local buffer=atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k-1];
250 atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k-1]=atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k]
251 atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k]=buffer;
252 break;
253 end
254 end
255 end
256 end
257 end
258 end
259 end
260 ATSWCS_UpdateSkillList();
261 end
262  
263 function ATSWCS_MoveDown(skillName)
264 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
265 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name==skillName) then
266 if(i<table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill])) then
267 local buffer=atsw_customheaders[UnitName("player")][atsw_selectedskill][i+1];
268 atsw_customheaders[UnitName("player")][atsw_selectedskill][i+1]=atsw_customheaders[UnitName("player")][atsw_selectedskill][i];
269 atsw_customheaders[UnitName("player")][atsw_selectedskill][i]=buffer;
270 break;
271 end
272 end
273 end
274 if(atsw_customsorting[UnitName("player")]) then
275 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]) then
276 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
277 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
278 for k=1,table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1 do
279 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k].name==skillName) then
280 if(k<table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name])) then
281 local buffer=atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k+1];
282 atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k+1]=atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k]
283 atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k]=buffer;
284 break;
285 end
286 end
287 end
288 end
289 end
290 end
291 end
292 ATSWCS_UpdateSkillList();
293 end
294  
295 function ATSWCS_Delete(skillName,onlySkill)
296 if(this:GetParent().btype=="header" and onlySkill==nil) then
297 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
298 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name==skillName) then
299 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
300 for j=table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1,-1 do
301 ATSWCS_Delete(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][j].name,true);
302 end
303 end
304 table.remove(atsw_customheaders[UnitName("player")][atsw_selectedskill],i);
305 if(atsw_opencategory==i) then atsw_opencategory=0; end
306 end
307 end
308 end
309 if(atsw_customsorting[UnitName("player")]) then
310 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]) then
311 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
312 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
313 for k=1,table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1 do
314 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k].name==skillName) then
315 table.remove(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name],k);
316 break;
317 end
318 end
319 end
320 end
321 end
322 end
323 ATSWCS_UpdateUncategorizedList();
324 ATSWCS_UpdateSkillList();
325 end
326  
327 function ATSWCSCSkillButton_OnClick(skillName)
328 if(this:GetParent().btype=="header") then
329 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
330 if(atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name==skillName) then
331 if(atsw_opencategory==i) then
332 atsw_opencategory=0;
333 else
334 atsw_opencategory=i;
335 end
336 ATSWCS_UpdateUncategorizedList();
337 ATSWCS_UpdateSkillList();
338 return;
339 end
340 end
341 end
342 if(atsw_customsorting[UnitName("player")]) then
343 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]) then
344 for i=1,table.getn(atsw_customheaders[UnitName("player")][atsw_selectedskill]),1 do
345 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]) then
346 for k=1,table.getn(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name]),1 do
347 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name][k].name==skillName) then
348 table.remove(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][i].name],k);
349 break;
350 end
351 end
352 end
353 end
354 end
355 end
356 ATSWCS_UpdateUncategorizedList();
357 ATSWCS_UpdateSkillList();
358 end
359  
360 function ATSWCSSkillButton_OnClick(skillName)
361 if(atsw_opencategory==0) then return; end
362 for i=1,table.getn(atsw_uncategorized),1 do
363 if(atsw_uncategorized[i].name==skillName) then
364 if(atsw_customsorting[UnitName("player")][atsw_selectedskill]==nil) then atsw_customsorting[UnitName("player")][atsw_selectedskill]={}; end
365 if(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][atsw_opencategory].name]==nil) then atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][atsw_opencategory].name]={}; end
366 table.insert(atsw_customsorting[UnitName("player")][atsw_selectedskill][atsw_customheaders[UnitName("player")][atsw_selectedskill][atsw_opencategory].name],{name=skillName,type=atsw_uncategorized[i].type});
367 end
368 end
369 ATSWCS_UpdateUncategorizedList();
370 ATSWCS_UpdateSkillList();
371 end