vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ Characters Viewer: View equipment and inventory of alternate characters. |
2 | Author: Flisher |
||
3 | Contributor: Vincent of Blackhand |
||
4 | Galmok |
||
5 | Sinaloit |
||
6 | Legorol |
||
7 | |||
8 | |||
9 | Version: 1.03 (Cosmos Revision : $Rev: 3761 $) |
||
10 | Last Changed by: $LastChangedBy: Flisher $ |
||
11 | Date: $Date: 2006-07-06 10:52:10 -0400 (jeu., 06 juil. 2006) $ |
||
12 | |||
13 | Official Distribution site: http://www.curse-gaming.com/mod.php?addid=490 |
||
14 | Also packaged in Cosmos: http://www.cosmosui.org |
||
15 | |||
16 | Planned feature for the next version: |
||
17 | - Adding Bank Timestamping in the GUI |
||
18 | - Adding HK/DK in the GUI |
||
19 | |||
20 | Version history: |
||
21 | 1.03 - Fixed the Bank Background, thank to bsmorgan for giving me the fix |
||
22 | 1.02 - Fixed a German Localization, thank's to Maischter from ui.worldofwar.net community |
||
23 | 1.01 - Merged Startust German localization file |
||
24 | 1.00 - Fixed a typo in the merge of the WakyHorse sex fix, note that you might have to reload each char to fix the sex data |
||
25 | Version under 1.0 change are available in the readme.txt file included in the zip file. |
||
26 | |||
27 | ]]-- |
||
28 | |||
29 | -- Initialize the variables |
||
30 | |||
31 | local Server = GetRealmName(); |
||
32 | CharactersViewerProfile = {}; |
||
33 | CharactersViewerProfile[Server] = {}; |
||
34 | CharactersViewerConfig = {}; |
||
35 | |||
36 | local function print(msg) SELECTED_CHAT_FRAME:AddMessage("CV: "..msg); end |
||
37 | |||
38 | CharactersViewer = { |
||
39 | -- Functions |
||
40 | |||
41 | unregister = |
||
42 | { |
||
43 | Event = function () |
||
44 | for index, event in CharactersViewer.constant.event do |
||
45 | this:UnregisterEvent(event); -- Event that will be called for initialisation of the addon |
||
46 | end |
||
47 | for index, event in CharactersViewer.constant.toggleEvents do |
||
48 | this:UnregisterEvent(event); |
||
49 | end |
||
50 | end; |
||
51 | }; |
||
52 | |||
53 | register = |
||
54 | { |
||
55 | Event = function () |
||
56 | for index, event in CharactersViewer.constant.event do |
||
57 | this:RegisterEvent(event); -- Event that will be called for initialisation of the addon |
||
58 | end |
||
59 | CharactersViewer.status.register.event = true; |
||
60 | end; |
||
61 | |||
62 | hook = function () |
||
63 | if(Sea) then |
||
64 | Sea.util.hook("Logout", "CharactersViewer.collect.all"); |
||
65 | Sea.util.hook("Quit", "CharactersViewer.collect.all"); |
||
66 | Sea.util.hook("GuildPlayerStatus_Update", "CharactersViewer.Note.Guild_OnUpdate"); |
||
67 | else |
||
68 | CharactersViewer_ORIG_Logout = Logout; |
||
69 | CharactersViewer_ORIG_Quit = Quit; |
||
70 | CharactersViewer_ORIG_GuildPlayerStatus_Update = GuildStatus_Update; |
||
71 | |||
72 | function Quit() |
||
73 | CharactersViewer.collect.all(); |
||
74 | return CharactersViewer_ORIG_Quit(); |
||
75 | end |
||
76 | function Logout() |
||
77 | CharactersViewer.collect.all(); |
||
78 | return CharactersViewer_ORIG_Logout(); |
||
79 | end |
||
80 | |||
81 | function GuildStatus_Update() |
||
82 | CharactersViewer.Note.Guild_OnUpdate(); |
||
83 | CharactersViewer_ORIG_GuildPlayerStatus_Update(); |
||
84 | end |
||
85 | |||
86 | end |
||
87 | CharactersViewer.status.register.hook = true; |
||
88 | end; |
||
89 | |||
90 | cosmos = function () -- Cosmos Button Support -- |
||
91 | if( EarthFeature_AddButton ) then |
||
92 | EarthFeature_AddButton ( |
||
93 | { |
||
94 | id = "CharactersViewer"; |
||
95 | name = BINDING_HEADER_CHARACTERSVIEWER; |
||
96 | subtext = CHARACTERSVIEWER_SHORT_DESC; |
||
97 | tooltip = CHARACTERSVIEWER_DESCRIPTION; |
||
98 | icon = CHARACTERSVIEWER_ICON; |
||
99 | callback = CharactersViewer.Toggle; |
||
100 | test = nil; |
||
101 | } |
||
102 | ); |
||
103 | CharactersViewer.status.register.earth = true; |
||
104 | elseif(Cosmos_RegisterButton) then |
||
105 | Cosmos_RegisterButton ( |
||
106 | BINDING_HEADER_CHARACTERSVIEWER, |
||
107 | CHARACTERSVIEWER_SHORT_DESC, |
||
108 | CHARACTERSVIEWER_DESCRIPTION, |
||
109 | CHARACTERSVIEWER_ICON, |
||
110 | CharactersViewer.Toggle |
||
111 | ); |
||
112 | CharactersViewer.status.register.cosmos = true; |
||
113 | end |
||
114 | end; |
||
115 | |||
116 | myaddon = function () -- Interoperability MyAddOns -- |
||
117 | if(myAddOnsFrame_Register) then |
||
118 | temp = |
||
119 | { name = 'CharactersViewer', |
||
120 | version = CharactersViewer.version.number, |
||
121 | releaseDate = CharactersViewer.version.date, |
||
122 | author = 'Flisher', |
||
123 | email = 'flisher@gmail.com', |
||
124 | website = 'http://www.curse-gaming.com/mod.php?addid=490', |
||
125 | category = MYADDONS_CATEGORY_INVENTORY, |
||
126 | optionsframe = '' |
||
127 | }; |
||
128 | myAddOnsFrame_Register(temp, CHARACTERSVIEWER_USAGE_SUBCMD); |
||
129 | CharactersViewer.status.register.myaddon = true; |
||
130 | end |
||
131 | end; |
||
132 | |||
133 | counselor = function () -- Counselor tip -- |
||
134 | if(Counselor and Counselor.registerTip) then |
||
135 | Counselor.registerTip ( |
||
136 | { id = "CharactersViewer_013"; |
||
137 | addOn = "CharactersViewer"; |
||
138 | type = COUNSELOR_STARTUP; |
||
139 | title = "CharactersViewer Description"; |
||
140 | text = "CharactersViewer is an addons created with the purpose of displaying information about your other characters on the same server,\nYou can call the addons by typing /cv.\n\n If the addons already know information about yout other characters, a dropdown menu will appear in your character paperdoll soo you can compare with your other character."; |
||
141 | tooltip = "What CharactersViewer can do for you!"; |
||
142 | } |
||
143 | ); |
||
144 | CharactersViewer.status.register.counselor = true; |
||
145 | end |
||
146 | end; |
||
147 | |||
148 | ctmod = function() |
||
149 | if(CT_RegisterMod) then |
||
150 | CT_RegisterMod(BINDING_HEADER_CHARACTERSVIEWER, CHARACTERSVIEWER_SHORT_DESC, 4, "Interface\\Buttons\\Button-Backpack-Up", CHARACTERSVIEWER_DESCRIPTION, "switch", "", CharactersViewer.Toggle); |
||
151 | CharactersViewer.status.register.ctmod = true; |
||
152 | |||
153 | end |
||
154 | end; |
||
155 | |||
156 | titanmodmenu = function () |
||
157 | if(TitanModMenu_MenuItems) then |
||
158 | TitanModMenu_MenuItems["CharactersViewer"] = { |
||
159 | frame = "CharactersViewer_Frame", |
||
160 | cat = TITAN_MODMENU_CAT_INVENTORY, |
||
161 | text = BINDING_HEADER_CHARACTERSVIEWER, |
||
162 | func = "CharactersViewer_Toggle" |
||
163 | }; |
||
164 | CharactersViewer.status.register.titanmodmenu = true; |
||
165 | end |
||
166 | end; |
||
167 | |||
168 | slashcmd = function () |
||
169 | -- Register the SlashCommand in the system |
||
170 | --! todo: Regster thing with cosmos slashcmd |
||
171 | SlashCmdList["CHARACTERSVIEWER"] = function(msg) |
||
172 | CharactersViewer.SlashCmd(msg); |
||
173 | end |
||
174 | CharactersViewer.status.register.slashcmd = true; |
||
175 | end; |
||
176 | |||
177 | }; |
||
178 | |||
179 | onLoad = function () |
||
180 | -- Registering Event |
||
181 | CharactersViewer.register.Event(); |
||
182 | |||
183 | ---- Todo: Register slashcommand with sky |
||
184 | CharactersViewer.register.slashcmd(); |
||
185 | |||
186 | -- Registering with other addons -- |
||
187 | CharactersViewer.register.cosmos(); |
||
188 | CharactersViewer.register.myaddon(); |
||
189 | CharactersViewer.register.counselor(); |
||
190 | CharactersViewer.register.ctmod(); |
||
191 | CharactersViewer.register.titanmodmenu(); |
||
192 | |||
193 | end; |
||
194 | |||
195 | SlashCmd = function(msg) -- CharactersViewer.SlashCmd() |
||
196 | -- get the parameter from the ShashCmd |
||
197 | param = CharactersViewer.library.splitstring(msg); |
||
198 | |||
199 | if( param[0] and strlen(param[0]) > 0 ) then |
||
200 | param[0] = strlower(param[0]); |
||
201 | end |
||
202 | if( msg and strlen(msg) > 0 ) then |
||
203 | msg = strlower(msg); |
||
204 | end |
||
205 | |||
206 | if(msg == CHARACTERSVIEWER_SUBCMD_SHOW) then |
||
207 | CharactersViewer_Show(); |
||
208 | |||
209 | elseif(param[0] == CHARACTERSVIEWER_SUBCMD_CLEAR) then |
||
210 | -- if no param[1] (character), then assign the current one. |
||
211 | if(not param[1] ) then |
||
212 | param[1] = UnitName("player"); --! todo: use the new blizzard function |
||
213 | end |
||
214 | |||
215 | -- Make the first character upper, all the other lowercase. |
||
216 | param[1] = string.upper(string.sub(param[1], 1,1)) .. string.lower(string.sub(param[1] , 2)); |
||
217 | |||
218 | -- Check if the data exist, |
||
219 | if(CharactersViewerProfile[Server][param[1]] ~= nil) then |
||
220 | -- The data is confirmed existing, we can wipe it. |
||
221 | CharactersViewerProfile[Server][param[1]] = nil; |
||
222 | |||
223 | --! Make it Sea compatible |
||
224 | print(CHARACTERSVIEWER_PROFILECLEARED .. param[1]); |
||
225 | |||
226 | -- If we cleared ourself, we will collect data |
||
227 | if( param[1] == UnitName("player") ) then |
||
228 | CharactersViewer.collect.all(); |
||
229 | |||
230 | elseif( param[1] == CharactersViewer.index ) then |
||
231 | CharactersViewer.Switch(); |
||
232 | CharactersViewer_PaperDoll_Dropdown2_Toggle(); |
||
233 | else |
||
234 | CharactersViewer_PaperDoll_Dropdown2_Toggle(); |
||
235 | end |
||
236 | |||
237 | else |
||
238 | -- The data isn't existing for that character |
||
239 | --! Make it Sea compatible |
||
240 | print(CHARACTERSVIEWER_NOT_FOUND .. param[1]); |
||
241 | end |
||
242 | |||
243 | elseif(msg == CHARACTERSVIEWER_SUBCMD_CLEARALL) then |
||
244 | CharactersViewerProfile = {}; |
||
245 | --! todo: make it sea compliant |
||
246 | print(CHARACTERSVIEWER_ALLPROFILECLEARED); |
||
247 | CharactersViewer.collect.all(); |
||
248 | CharactersViewer.Switch(); |
||
249 | CharactersViewer_PaperDoll_Dropdown2_Toggle(); |
||
250 | |||
251 | elseif(msg == "") then |
||
252 | CharactersViewer.Toggle(); |
||
253 | |||
254 | elseif(msg == CHARACTERSVIEWER_SUBCMD_PREVIOUS) then |
||
255 | CharactersViewer.Switch(-1); |
||
256 | |||
257 | elseif(msg == CHARACTERSVIEWER_SUBCMD_NEXT) then |
||
258 | CharactersViewer.Switch(1); |
||
259 | |||
260 | elseif(param[0] == CHARACTERSVIEWER_SUBCMD_SWITCH) then |
||
261 | if(not param[1] ) then |
||
262 | param[1] = UnitName("player"); --! todo: use the new blizzard function |
||
263 | end |
||
264 | CharactersViewer.Switch(param[1]); |
||
265 | elseif(msg == CHARACTERSVIEWER_SUBCMD_LIST) then |
||
266 | CharactersViewer.List(); |
||
267 | elseif(msg == CHARACTERSVIEWER_SUBCMD_BANK) then |
||
268 | CharactersViewer.Bank.Toggle(); |
||
269 | elseif(msg == CHARACTERSVIEWER_SUBCMD_RESETLOC ) then |
||
270 | CharactersViewer.ResetLoc(); |
||
271 | elseif(msg == CHARACTERSVIEWER_SUBCMD_BAGS) then |
||
272 | CharactersViewer_Bags(); |
||
273 | elseif(msg == CHARACTERSVIEWER_SUBCMD_BAGUSE) then |
||
274 | CharactersViewer_Bags('use'); |
||
275 | else |
||
276 | print(CHARACTERSVIEWER_USAGE); |
||
277 | local index, subcmdUsage; |
||
278 | for index, subcmdUsage in CHARACTERSVIEWER_USAGE_SUBCMD do |
||
279 | if(subcmdUsage) then |
||
280 | print(subcmdUsage); |
||
281 | end |
||
282 | end |
||
283 | end |
||
284 | end; |
||
285 | |||
286 | Toggle = function () -- Changed by Flisher 2005-06-12 |
||
287 | if(CharactersViewer_Frame:IsVisible()) then |
||
288 | CharactersViewer.Hide(); |
||
289 | else |
||
290 | CharactersViewer_Show(); |
||
291 | end |
||
292 | end; |
||
293 | |||
294 | Hide = function() |
||
295 | HideUIPanel(CharactersViewer_Frame); |
||
296 | CharactersViewerBankFrame:Hide(); |
||
297 | PlaySound("igMainMenuClose"); |
||
298 | end; |
||
299 | |||
300 | ResetLoc = function() |
||
301 | UIPanelWindows["CharactersViewer_Frame"] = { area = "up", pushable = 6 }; |
||
302 | HideUIPanel(CharactersViewer_Frame); |
||
303 | ShowUIPanel(CharactersViewer_Frame); |
||
304 | UIPanelWindows["CharactersViewer_Frame"] = nil; |
||
305 | HideUIPanel(CharactersViewer_Frame); |
||
306 | ShowUIPanel(CharactersViewer_Frame); |
||
307 | CharactersViewer_Frame:SetUserPlaced(); |
||
308 | end; |
||
309 | |||
310 | List = function () |
||
311 | if(CharactersViewerProfile and CharactersViewerProfile[Server]) then |
||
312 | for index, item in CharactersViewerProfile[Server] do |
||
313 | if( CharactersViewerProfile[Server][index]["Type"] and CharactersViewerProfile[Server][index]["Type"] == "Self") then |
||
314 | if( CharactersViewerProfile[Server][index] and CharactersViewerProfile[Server][index]["Data"]) then |
||
315 | local output = index; |
||
316 | if(CharactersViewerProfile[Server][index]["Data"]["Id"] and CharactersViewerProfile[Server][index]["Data"]["Id"]["Class"]) then |
||
317 | output = output .. ", " .. CharactersViewerProfile[Server][index]["Data"]["Id"]["Class"]; |
||
318 | end |
||
319 | if(CharactersViewerProfile[Server][index]["Data"]["Id"] and CharactersViewerProfile[Server][index]["Data"]["Id"]["Level"]) then |
||
320 | output = output .. ", " .. CharactersViewerProfile[Server][index]["Data"]["Id"]["Level"]; |
||
321 | end |
||
322 | if(CharactersViewerProfile[Server][index]["Data"]["Location"] and CharactersViewerProfile[Server][index]["Data"]["Location"]["Zone"]) then |
||
323 | output = output .. ", " .. CharactersViewerProfile[Server][index]["Data"]["Location"]["Zone"]; |
||
324 | end |
||
325 | if( CharactersViewerProfile[Server][index]["Data"]["Mail"] and CharactersViewerProfile[Server][index]["Data"]["Mail"]["HasNewMail"]) then |
||
326 | output = output .. ", " .. HAVE_MAIL; |
||
327 | end |
||
328 | if( CharactersViewerProfile[Server][index]["Data"]["xp"] ) then |
||
329 | local temp = CharactersViewer.library.CalcRestedXP( CharactersViewerProfile[Server][index]["Data"]["xp"] ); |
||
330 | if( temp and temp.estimated > 0 ) then |
||
331 | output = output .. ", " .. temp.levelratio .. " " .. LEVEL .. " " .. CHARACTERSVIEWER_RESTED; |
||
332 | end |
||
333 | if( CharactersViewerProfile[Server][index]["Data"]["xp"]["resting"] and temp.levelratio < 1.5 ) then |
||
334 | output = output .. ", " .. CHARACTERSVIEWER_RESTING; |
||
335 | end |
||
336 | end |
||
337 | print(output); |
||
338 | end |
||
339 | end |
||
340 | end |
||
341 | end |
||
342 | end; |
||
343 | |||
344 | Switch = function (choice) |
||
345 | if(choice == nil) then |
||
346 | choice = UnitName("player"); --! todo: improve |
||
347 | end |
||
348 | |||
349 | if(choice == -1 or choice == 1) then |
||
350 | local current = 0; |
||
351 | local i = 0; |
||
352 | local temp = {}; |
||
353 | for j, name in CharactersViewerProfile[Server] do |
||
354 | if(name["Type"] == "Self") then |
||
355 | i = i + 1; |
||
356 | temp[i] = j; |
||
357 | if(j == CharactersViewer.index ) then |
||
358 | current = i; |
||
359 | end |
||
360 | end |
||
361 | end |
||
362 | current = current + choice; |
||
363 | if(current <= 0) then |
||
364 | choice = temp[i]; |
||
365 | elseif(current > i) then |
||
366 | choice = temp[1]; |
||
367 | else |
||
368 | choice = temp[current]; |
||
369 | end |
||
370 | end |
||
371 | |||
372 | -- Switch the current characterviwer character |
||
373 | choice2 = string.upper(string.sub(choice, 1,1)) .. string.lower(string.sub(choice , 2)); -- Make the first character upper, all the other lowercase. |
||
374 | if(CharactersViewerProfile[Server][choice] ~= nil) then |
||
375 | CharactersViewer.index = choice; |
||
376 | CharactersViewerCurrentIndex = CharactersViewer.index; -- Backward compatibility |
||
377 | elseif(CharactersViewerProfile[Server][choice2] ~= nil) then |
||
378 | CharactersViewer.index = choice2; |
||
379 | CharactersViewerCurrentIndex = CharactersViewer.index; -- Backward compatibility |
||
380 | else |
||
381 | print(CHARACTERSVIEWER_NOT_FOUND .. choice); |
||
382 | CharactersViewer.Hide(); |
||
383 | end |
||
384 | |||
385 | if(CharactersViewer_Frame:IsVisible()) then |
||
386 | CharactersViewer_Show(); |
||
387 | end |
||
388 | |||
389 | if( AC_Target and AC_Target:IsVisible()) then |
||
390 | AC_CV_DropDown_OnClick(name); |
||
391 | end |
||
392 | end; |
||
393 | |||
394 | collect = |
||
395 | { |
||
396 | basic = function (target) |
||
397 | local temp = {}; |
||
398 | |||
399 | -- Set the mana pool if it's a mana user |
||
400 | if( UnitPowerType(target) and UnitPowerType(target) == 0 ) then |
||
401 | if( UnitManaMax(target) and UnitManaMax(target) > 0) then |
||
402 | temp["Mana"] = UnitManaMax(target); |
||
403 | else |
||
404 | temp["Mana"] = "??"; |
||
405 | end |
||
406 | end |
||
407 | |||
408 | if(UnitHealthMax(target) and (UnitHealthMax(target) > 100 or target == "player") ) then |
||
409 | temp["Health"] = UnitHealthMax(target); |
||
410 | else |
||
411 | temp["Health"] = "??"; |
||
412 | end |
||
413 | |||
414 | if(target == "player") then |
||
415 | temp["Defense"] = UnitDefense(target); |
||
416 | -- Set the armor value |
||
417 | local baseArm, effectiveArmor, armor, positiveArm, negativeArm = UnitArmor(target); |
||
418 | temp["Armor"] = baseArm .. ":" .. (baseArm + positiveArm) .. ":" .. positiveArm; -- if they have a debuf on, don't save it |
||
419 | end |
||
420 | return temp; |
||
421 | end; |
||
422 | |||
423 | id = function (target) -- Flisher 2005-07-29 |
||
424 | local Race, RaceEn = UnitRace(target); |
||
425 | local Class, ClassEn = UnitClass(target); |
||
426 | local temp = { |
||
427 | Sex = CharactersViewer.collect.sex(target, 0), |
||
428 | SexId = CharactersViewer.collect.sex(target, 1), |
||
429 | Race = Race, |
||
430 | RaceEn = RaceEn, |
||
431 | Class = Class, |
||
432 | ClassEn = ClassEn, |
||
433 | Level = UnitLevel(target), |
||
434 | Server = Server, |
||
435 | Name = UnitName(target), -- Added 2005-07-28 for easyness of access, by Flisher |
||
436 | }; |
||
437 | return temp; |
||
438 | end; |
||
439 | |||
440 | location = function () -- Flisher 2005-07-29 |
||
441 | return { |
||
442 | Zone = GetZoneText(), |
||
443 | SubZone = GetSubZoneText(), |
||
444 | } |
||
445 | |||
446 | end; |
||
447 | |||
448 | xp = function() -- Flisher 2005-07-29 |
||
449 | return { |
||
450 | max = UnitXPMax("player"); |
||
451 | current = UnitXP("player"); |
||
452 | resting = IsResting() == 1 or false; |
||
453 | bonus = GetXPExhaustion(); |
||
454 | timestamp = time(); |
||
455 | } |
||
456 | end; |
||
457 | |||
458 | mail = function () -- Flisher 2005-07-28 |
||
459 | local temp = {}; |
||
460 | temp["HasNewMail"] = HasNewMail() == 1 or false; |
||
461 | --temp["nb"] = GetInboxNumItems(); |
||
462 | return temp; |
||
463 | end; |
||
464 | |||
465 | sex = function (target, num) -- Flisher 2006-07-01, CharactersViewer.collect.sex |
||
466 | local temp = ""; |
||
467 | temp = mod(UnitSex(target),2); |
||
468 | if( (not num) or num == 0) then |
||
469 | if(temp and temp == 0) then |
||
470 | temp = MALE; |
||
471 | else |
||
472 | temp = FEMALE; |
||
473 | end |
||
474 | end |
||
475 | return temp; |
||
476 | end; |
||
477 | |||
478 | guild = function (target) -- Flisher 2005-07-28 |
||
479 | local temp = {}; |
||
480 | temp["GuildName"], temp["Title"], temp["Rank"] = GetGuildInfo(target); |
||
481 | return temp; |
||
482 | end; |
||
483 | |||
484 | stats = function () -- Flisher 2005-07-28 |
||
485 | -- "stat" is the same as effectiveStat... |
||
486 | -- problem here is if they have a debuff spell on, the values saved will be wrong |
||
487 | local temp = {}; |
||
488 | for index = 1, 5 do |
||
489 | local stat, effectiveStat, posBuff, negBuff = UnitStat("player", index); |
||
490 | temp[index] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff; |
||
491 | end |
||
492 | return temp; |
||
493 | end; |
||
494 | |||
495 | resistance = function () -- Flisher 2005-06-28 |
||
496 | local temp = {}; |
||
497 | for index = 2, 6 do |
||
498 | local base, resistance, positive, negative = UnitResistance("player", index); |
||
499 | temp[index] = resistance; |
||
500 | end |
||
501 | return temp; |
||
502 | end; |
||
503 | |||
504 | combatstats = function () -- Flisher 2005-06-12 |
||
505 | local temp = {}; |
||
506 | temp["D"] = GetDodgeChance(); |
||
507 | if( GetBlockChance() > 0) then |
||
508 | temp["B"] = GetBlockChance(); |
||
509 | end |
||
510 | |||
511 | -- Get Parry Chance |
||
512 | local _, class = UnitClass('player'); |
||
513 | if( class=="MAGE" or class=="WARLOCK" or class=="DRUID" or class=="PRIEST" ) then |
||
514 | temp["P"] = 0; |
||
515 | else |
||
516 | temp["P"] = GetParryChance(); |
||
517 | end |
||
518 | |||
519 | -- Get Crit Chance |
||
520 | local i=0; |
||
521 | repeat |
||
522 | i=i+1; |
||
523 | spellName, subSpellName = GetSpellName(i,BOOKTYPE_SPELL); |
||
524 | until (spellName == ATTACK) or (not spellName) |
||
525 | if(not spellName) then |
||
526 | return temp; |
||
527 | end |
||
528 | CharactersVTooltip:SetOwner(UIParent, "ANCHOR_NONE"); |
||
529 | CharactersVTooltip:SetSpell(i, BOOKTYPE_SPELL); |
||
530 | local _, _, tmpStr = string.find(CharactersVTooltipTextLeft2:GetText(), '(%d+\.%d+)'); |
||
531 | CharactersVTooltip:Hide(); |
||
532 | tmpStr = string.gsub(tmpStr, ",", "."); |
||
533 | temp["C"] = tmpStr; |
||
534 | |||
535 | return temp; |
||
536 | end; |
||
537 | |||
538 | honor = function (target) -- Flisher 2005-06-12 |
||
539 | local temp = {}; |
||
540 | if(UnitPVPRank(target) and GetPVPRankInfo(UnitPVPRank(target)) and UnitPVPRank(target) >= 1) then |
||
541 | temp["rankName"], temp["rankNumber"] = GetPVPRankInfo(UnitPVPRank(target)); |
||
542 | end |
||
543 | temp["HK"],temp["DK"] = GetPVPLifetimeStats(); -- Wakyhorse HK's |
||
544 | return temp; |
||
545 | end; |
||
546 | |||
547 | Equipment = function(target) -- Changed by Flisher 2005-06-12 |
||
548 | local link, texture ; |
||
549 | temp = {} |
||
550 | -- Initialise the equipments |
||
551 | for index = 1, 19 do |
||
552 | link = GetInventoryItemLink(target, index); |
||
553 | texture = GetInventoryItemTexture(target, index); |
||
554 | if( link ) then |
||
555 | for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do |
||
556 | if( color ~= nil and item ~= nil and name ~= nil ) then |
||
557 | temp[index] = { }; |
||
558 | temp[index]["T"] = texture; |
||
559 | temp[index]["L"] = CharactersViewer.library.DeLink(link); |
||
560 | if( GetInventoryItemCount(target, index) > 1 ) then |
||
561 | temp[index]["C"] = GetInventoryItemCount(target, index); |
||
562 | end |
||
563 | end |
||
564 | end |
||
565 | end |
||
566 | end |
||
567 | return temp; |
||
568 | end; |
||
569 | |||
570 | Inventory = function () -- Changed by Flisher 2005-06-12 |
||
571 | local bag, bagname, link, texture, color, item, strings, str; |
||
572 | -- Reset/Initialize |
||
573 | CharactersViewerProfile[Server][UnitName("player")]["Bag"] = {} |
||
574 | |||
575 | for bag = 0,4 do |
||
576 | if(bag == 0) then |
||
577 | bagname = "Backpack"; |
||
578 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag] = { }; |
||
579 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["name"] = GetBagName(bag); |
||
580 | --CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["Item"] = "Backpack"; |
||
581 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["Color"] = "ffffffff"; |
||
582 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["size"] = GetContainerNumSlots(bag); |
||
583 | -- End of warlock workaround |
||
584 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["T"] = "Interface\\Buttons\\Button-Backpack-Up"; |
||
585 | CharactersViewer.collect.Bag(bag); |
||
586 | else |
||
587 | link = GetInventoryItemLink("player", (bag+19)); |
||
588 | texture = GetInventoryItemTexture("player", (bag+19)); |
||
589 | if( link ) then |
||
590 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag] = { }; |
||
591 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["name"] = GetBagName(bag); |
||
592 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["size"] = GetContainerNumSlots(bag); |
||
593 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["L"] = CharactersViewer.library.DeLink(link); |
||
594 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["T"] = texture; |
||
595 | CharactersViewer.collect.Bag(bag); |
||
596 | end |
||
597 | end |
||
598 | end |
||
599 | |||
600 | --Kerying Gathering |
||
601 | bag = KEYRING_CONTAINER; |
||
602 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag] = { }; |
||
603 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["name"] = "Keyring"; |
||
604 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["Color"] = "ffffffff"; |
||
605 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["size"] = GetKeyRingSize(bag); |
||
606 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag]["T"] = "Interface\\ContainerFrame\\KeyRing-Bag-Icon"; |
||
607 | CharactersViewer.collect.Bag(bag); |
||
608 | end; |
||
609 | |||
610 | Bag = function (bag) -- CharactersViewer.collect.Bag Changed by Flisher 2006-07-01 |
||
611 | local slot, strings, str, texture, itemCount, locked, quality, link, color, item, name; |
||
612 | if (bag ~= KEYRING_CONTAINER) then |
||
613 | totalslot = GetContainerNumSlots(bag); |
||
614 | else |
||
615 | totalslot = GetKeyRingSize(); |
||
616 | end |
||
617 | for slot = 1, totalslot do -- loop through all slots in this bag and get items |
||
618 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag][slot] = {}; |
||
619 | texture, itemCount, locked, quality = GetContainerItemInfo(bag,slot); |
||
620 | link = GetContainerItemLink(bag, slot); |
||
621 | if( link ) then |
||
622 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag][slot]["T"] = texture; |
||
623 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag][slot]["L"] = CharactersViewer.library.DeLink(link); |
||
624 | if(itemCount > 1) then |
||
625 | CharactersViewerProfile[Server][UnitName("player")]["Bag"][bag][slot]["C"] = itemCount; |
||
626 | end |
||
627 | end |
||
628 | end |
||
629 | end; |
||
630 | |||
631 | all = function () -- Changed Flisher 2005-06-12 |
||
632 | local bank; |
||
633 | -- Properly initialize the SavedVariable if it do not exist |
||
634 | if( not CharactersViewerProfile ) then |
||
635 | CharactersViewerProfile = {}; |
||
636 | end |
||
637 | -- Properly initialize the current realm if it do not exist |
||
638 | if( not CharactersViewerProfile[Server] ) then |
||
639 | CharactersViewerProfile[Server] = {}; |
||
640 | end |
||
641 | |||
642 | -- Properly initialise the current character data |
||
643 | -- Bank Data protection |
||
644 | if( CharactersViewerProfile[Server][UnitName("player")] and CharactersViewerProfile[Server][UnitName("player")]["Bank"]) then |
||
645 | bank = CharactersViewerProfile[Server][UnitName("player")]["Bank"]; |
||
646 | end |
||
647 | |||
648 | -- GCV Data protection, requested by LordRod |
||
649 | if( CharactersViewerProfile[Server][UnitName("player")] and CharactersViewerProfile[Server][UnitName("player")]["GCV"]) then |
||
650 | gcv = CharactersViewerProfile[Server][UnitName("player")]["GCV"]; |
||
651 | end |
||
652 | |||
653 | -- Data Reinitialisation |
||
654 | CharactersViewerProfile[Server][UnitName("player")] = {}; |
||
655 | |||
656 | |||
657 | -- Bank restore |
||
658 | CharactersViewerProfile[Server][UnitName("player")] = {}; |
||
659 | if( bank ) then |
||
660 | CharactersViewerProfile[Server][UnitName("player")]["Bank"] = bank; |
||
661 | end |
||
662 | |||
663 | -- GCV restore |
||
664 | if( gcv ) then |
||
665 | CharactersViewerProfile[Server][UnitName("player")]["GCV"] = gcv; |
||
666 | end |
||
667 | |||
668 | -- Initialise the type |
||
669 | CharactersViewerProfile[Server][UnitName("player")]["Type"] = "Self"; |
||
670 | CharactersViewerProfile[Server][UnitName("player")]["Timestamp"] = time(); |
||
671 | |||
672 | CharactersViewerProfile[Server][UnitName("player")]["Data"] = { |
||
673 | Type = CharactersViewerProfile[Server][UnitName("player")]["Type"]; |
||
674 | Timestamp = CharactersViewerProfile[Server][UnitName("player")]["Timestamp"]; |
||
675 | Money = GetMoney(), |
||
676 | Guild = CharactersViewer.collect.guild("player"); |
||
677 | Resists = CharactersViewer.collect.resistance(); |
||
678 | Stats = CharactersViewer.collect.stats(); |
||
679 | CombatStats = CharactersViewer.collect.combatstats(); |
||
680 | Mail = CharactersViewer.collect.mail(false); |
||
681 | Id = CharactersViewer.collect.id("player"); |
||
682 | Location = CharactersViewer.collect.location(); |
||
683 | xp = CharactersViewer.collect.xp(); |
||
684 | Honor = CharactersViewer.collect.honor("player"); |
||
685 | Basic = CharactersViewer.collect.basic("player"); |
||
686 | } |
||
687 | |||
688 | CharactersViewerProfile[Server][UnitName("player")]["Equipment"] = CharactersViewer.collect.Equipment("player"); |
||
689 | CharactersViewer.collect.Inventory(); |
||
690 | |||
691 | -- Set the status flag if data was collected at least once sicne the addon loaded |
||
692 | if(not CharactersViewer.status.collected) then |
||
693 | CharactersViewer.status.collected = true; |
||
694 | CharactersViewer.Switch(); |
||
695 | CharactersViewer_PaperDoll_Dropdown2_Toggle(); |
||
696 | end |
||
697 | end; |
||
698 | |||
699 | inspect = function () -- Created by Flisher 2005-08-10 |
||
700 | if( UnitIsPlayer("target") and not UnitIsUnit("player", "target") and UnitName("target") ~= nil and UnitName("target") ~= UNKNOWNOBJECT and UnitName("target") ~= UKNOWNBEING ) then |
||
701 | -- Properly initialize the SavedVariable if it do not exist |
||
702 | if( not CharactersViewerProfile ) then |
||
703 | CharactersViewerProfile = {}; |
||
704 | end |
||
705 | -- Properly initialize the current realm if it do not exist |
||
706 | if( not CharactersViewerProfile[Server] ) then |
||
707 | CharactersViewerProfile[Server] = {}; |
||
708 | end |
||
709 | -- Properly initialise the current character data |
||
710 | CharactersViewerProfile[Server][UnitName("target")] = {}; |
||
711 | |||
712 | -- Initialise the type |
||
713 | CharactersViewerProfile[Server][UnitName("target")]["Type"] = "Inspect"; |
||
714 | CharactersViewerProfile[Server][UnitName("target")]["Timestamp"] = time(); |
||
715 | |||
716 | CharactersViewerProfile[Server][UnitName("target")]["Data"] = { |
||
717 | Type = CharactersViewerProfile[Server][UnitName("target")]["Type"]; |
||
718 | Timestamp = CharactersViewerProfile[Server][UnitName("target")]["Timestamp"]; |
||
719 | Guild = CharactersViewer.collect.guild("target"); |
||
720 | Id = CharactersViewer.collect.id("target"); |
||
721 | Honor = CharactersViewer.collect.honor("target"); |
||
722 | Basic = CharactersViewer.collect.basic("target"); |
||
723 | |||
724 | --Money = GetMoney(), |
||
725 | --Resists = CharactersViewer.collect.resistance(); |
||
726 | --Stats = CharactersViewer.collect.stats(); |
||
727 | --CombatStats = CharactersViewer.collect.combatstats(); |
||
728 | --Mail = CharactersViewer.collect.mail(false); |
||
729 | --Location = CharactersViewer.collect.location(); |
||
730 | --xp = CharactersViewer.collect.xp(); |
||
731 | } |
||
732 | CharactersViewerProfile[Server][UnitName("target")]["Equipment"] = CharactersViewer.collect.Equipment("target"); |
||
733 | --CharactersViewer.collect.Inventory(); |
||
734 | |||
735 | CharactersViewer_PaperDoll_Dropdown2_Toggle(); |
||
736 | end |
||
737 | end; |
||
738 | |||
739 | bank = -- CharactersViewer.collect.bank |
||
740 | { SaveItems = function () -- CharactersViewer.collect.bank.SaveItems |
||
741 | local itemLink,icon,quantity,bagNum_Slots; |
||
742 | CharactersViewerProfile[Server][UnitName("player")]["Bank"] = {}; |
||
743 | CharactersViewerProfile[Server][UnitName("player")]["Bank"]["timestamp"] = time(); -- WakyHorse Bank Timestamp |
||
744 | CharactersViewerProfile[Server][UnitName("player")]["Bank"]["Main"] = {}; |
||
745 | for num = 1, 24 do |
||
746 | itemLink = CharactersViewer.library.DeLink( GetContainerItemLink(BANK_CONTAINER, num) ); |
||
747 | icon, quantity = GetContainerItemInfo(BANK_CONTAINER, num); |
||
748 | if( itemLink ) then |
||
749 | CharactersViewerProfile[Server][UnitName("player")]["Bank"]["Main"][num] = |
||
750 | { |
||
751 | ["T"] = icon, |
||
752 | ["L"] = itemLink |
||
753 | } |
||
754 | end |
||
755 | if(quantity and quantity > 1) then |
||
756 | CharactersViewerProfile[Server][UnitName("player")]["Bank"]["Main"][num]["C"] = quantity; |
||
757 | end |
||
758 | end |
||
759 | for bagNum = 5, 10 do |
||
760 | local bagNum_ID = BankButtonIDToInvSlotID(bagNum, 1); |
||
761 | link = GetInventoryItemLink("player", bagNum_ID); |
||
762 | texture = GetInventoryItemTexture("player", bagNum_ID); |
||
763 | |||
764 | if( link ) then |
||
765 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum] = { }; |
||
766 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum]["name"] = GetBagName(bagNum); |
||
767 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum]["size"] = GetContainerNumSlots(bagNum); |
||
768 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum]["L"] = CharactersViewer.library.DeLink(link); |
||
769 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum]["T"] = texture; |
||
770 | --CharactersViewer.collect.Bag(bag); |
||
771 | end |
||
772 | |||
773 | --itemLink = nil; |
||
774 | |||
775 | for bagItem = 1, GetContainerNumSlots(bagNum) do |
||
776 | itemLink = CharactersViewer.library.DeLink( GetContainerItemLink(bagNum, bagItem) ); |
||
777 | icon, quantity = GetContainerItemInfo(bagNum, bagItem); |
||
778 | if( itemLink ) then |
||
779 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum][bagItem] = |
||
780 | { |
||
781 | ["L"] = itemLink, |
||
782 | ["T"] = icon, |
||
783 | }; |
||
784 | if(quantity and quantity > 1) then |
||
785 | CharactersViewerProfile[Server][UnitName("player")]["Bank"][bagNum][bagItem]["C"] = quantity; |
||
786 | end |
||
787 | end |
||
788 | end |
||
789 | end |
||
790 | end |
||
791 | } |
||
792 | }; |
||
793 | |||
794 | db = { |
||
795 | validate = function () |
||
796 | if(CharactersViewerConfig and CharactersViewerConfig["version"] and CharactersViewerConfig["version"] == CharactersViewer.version.db ) then |
||
797 | return true; |
||
798 | else |
||
799 | return false; |
||
800 | end |
||
801 | end; |
||
802 | |||
803 | init = function () --CharactersViewer.db.init() |
||
804 | CharactersViewerConfig = {}; |
||
805 | CharactersViewerProfile = {}; |
||
806 | ---- Todo: Make the display Sea Compatible |
||
807 | -- Display a warning |
||
808 | print(CHARACTERSVIEWER_ALLPROFILECLEARED); |
||
809 | |||
810 | -- Update the version of the Database |
||
811 | CharactersViewerConfig["version"] = CharactersViewer.version.db; |
||
812 | |||
813 | -- Initialise the Bag Display Status, true by default |
||
814 | CharactersViewerConfig["Bag_Display"] = true; |
||
815 | CharactersViewerConfig["Bag_Location"] = 0; |
||
816 | CharactersViewerConfig["BankBag_Display"] = true; |
||
817 | |||
818 | end; |
||
819 | |||
820 | }; |
||
821 | |||
822 | library = -- CharactersViewer.library |
||
823 | { GetRaceFaction = function( raceEn) -- Wakyhorse Added GetRaceFaction Function Starts here |
||
824 | if (raceEn == "Human" or raceEn == "Dwarf" or raceEn == "Gnome" or raceEn == "NightElf") |
||
825 | then return 1; |
||
826 | end |
||
827 | |||
828 | if (raceEn == "Orc" or raceEn == "Troll" or raceEn == "Scourge" or raceEn == "Tauren") then |
||
829 | return 2; |
||
830 | end |
||
831 | --print("Unknown Race "..race); |
||
832 | return 3; |
||
833 | end; -- Wakyhorse Added GetRaceFaction Function Ends here |
||
834 | |||
835 | |||
836 | splitstring = function (input) -- CharactersViewer.library.splitstring |
||
837 | local list = {}; |
||
838 | local i = 0; |
||
839 | for w in string.gfind(input, "([^ ]+)") do |
||
840 | list[i] = w; |
||
841 | i = i + 1; |
||
842 | end |
||
843 | return list; |
||
844 | end; |
||
845 | |||
846 | returnColor = function (quality) -- CharactersViewer.library.returnColor |
||
847 | color = { |
||
848 | [0] = "ff9d9d9d", -- poor, gray |
||
849 | [1] = "ffffffff", -- common, white |
||
850 | [2] = "ff1eff00", -- uncommon, green |
||
851 | [3] = "ff0070dd", -- rare, blue |
||
852 | [4] = "ffa335ee", -- epic, purple |
||
853 | [5] = "ffff8000", -- legendary, orange |
||
854 | } |
||
855 | return color[quality]; |
||
856 | end; |
||
857 | |||
858 | MakeLink = function(link) -- CharactersViewer.library.MakeLink |
||
859 | local temp = link; |
||
860 | if( link and string.sub(link,1,5) == "item:") then |
||
861 | local name,_,quality = GetItemInfo(link); |
||
862 | local color = CharactersViewer.library.returnColor(quality); |
||
863 | if(name) then |
||
864 | temp = "|c"..color.."|H"..link.."|h["..name.."]|h|r"; |
||
865 | else |
||
866 | temp = false; |
||
867 | end |
||
868 | end |
||
869 | return temp; |
||
870 | end; |
||
871 | |||
872 | DeLink = function(link) -- CharactersViewer.library.DeLink |
||
873 | local temp = link; |
||
874 | if( link and string.sub(link,1,2) == "|c") then |
||
875 | _,_,temp = strfind(link,"|H(item:%d+:%d+:%d+:%d+)|"); |
||
876 | end |
||
877 | return temp; |
||
878 | end; |
||
879 | |||
880 | CalcRestedXP = function (data) -- CharactersViewer.library.CalcRestedXP |
||
881 | local temp = { |
||
882 | estimated = 0; |
||
883 | levelratio = 0; |
||
884 | percentrested = 0; |
||
885 | } |
||
886 | if(data and data["bonus"] and data["resting"] ~= nil and data["max"] and data["timestamp"]) then |
||
887 | local speed = data.resting and 4 or 1; |
||
888 | local estimated = data.bonus; |
||
889 | if(data.timestamp < time()) then |
||
890 | estimated = data.bonus + floor((time()-data.timestamp) * data.max * 1.5 / 864000 / 4 * speed); |
||
891 | if(estimated > (data.max * 1.5) ) then |
||
892 | estimated = (data.max * 1.5); |
||
893 | end |
||
894 | end |
||
895 | temp = { |
||
896 | estimated = estimated; |
||
897 | levelratio = floor(estimated/data.max *10)/10; |
||
898 | percentrested = floor(estimated / (data.max *1.5) *100)/100; |
||
899 | } |
||
900 | end |
||
901 | return temp; |
||
902 | end; |
||
903 | |||
904 | MoneyTotal = function(faction) -- CharactersViewer.library.MoneyTotal |
||
905 | local total = 0; |
||
906 | if( CharactersViewerProfile and CharactersViewerProfile[Server] ) then |
||
907 | for index in CharactersViewerProfile[Server] do |
||
908 | if( CharactersViewerProfile[Server][index]["Data"] and CharactersViewerProfile[Server][index]["Data"]["Money"] ) then |
||
909 | if (CharactersViewerProfile[Server][index]["Data"]["Id"]["RaceEn"]) then |
||
910 | if ( CharactersViewer.library.GetRaceFaction(CharactersViewerProfile[Server][index]["Data"]["Id"]["RaceEn"]) == faction) then |
||
911 | total = total + CharactersViewerProfile[Server][index]["Data"]["Money"]; |
||
912 | end |
||
913 | end |
||
914 | end |
||
915 | end |
||
916 | end |
||
917 | return total; |
||
918 | end; |
||
919 | }; |
||
920 | |||
921 | Mail = { |
||
922 | OnEnter = function() -- CharactersViewer.Mail.OnEnter |
||
923 | local count = ""; |
||
924 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
925 | if(MailTo_InFrame and MailTo_Mail and MailTo_Mail[Server][CharactersViewer.index]) then |
||
926 | count = 0; |
||
927 | for anything in MailTo_Mail[Server][CharactersViewer.index] do |
||
928 | count = count + 1; |
||
929 | end |
||
930 | count = " (" .. count ..")"; |
||
931 | end |
||
932 | GameTooltip:SetText(HAVE_MAIL .. count .. "\n\n" .. CHARACTERSVIEWER_TOOLTIP_MAIL); |
||
933 | end; |
||
934 | |||
935 | OnClick = function(button) -- CharactersViewer.Mail.OnClick |
||
936 | if(MailTo_InFrame) then |
||
937 | if(arg1 == "LeftButton") then |
||
938 | if(MailTo_InFrame:IsVisible() ) then |
||
939 | HideUIPanel(MailTo_InFrame); |
||
940 | else |
||
941 | MailTo_inbox(CharactersViewer.index); |
||
942 | end |
||
943 | elseif(arg1 == "RightButton") then |
||
944 | --CharactersViewer.Bag.Relocate(true); |
||
945 | end |
||
946 | end |
||
947 | end |
||
948 | }; |
||
949 | |||
950 | Bag = { -- CharactersViewer.Bag |
||
951 | Display = function() -- CharactersViewer.Bag.Display |
||
952 | local index2 = 0; |
||
953 | for index = 0,4 do |
||
954 | getglobal("CharactersViewer_ContainerFrame" ..index ):Hide(); |
||
955 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][index]) then |
||
956 | CharactersViewer.Bag.Draw(index, index2, "bag"); |
||
957 | index2 = index2 + 1; |
||
958 | end |
||
959 | end |
||
960 | |||
961 | --keyring |
||
962 | getglobal("CharactersViewer_KeyringContainerFrame"):Hide(); |
||
963 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][KEYRING_CONTAINER]) then |
||
964 | CharactersViewer.Bag.Draw(KEYRING_CONTAINER, "", "keyring"); |
||
965 | index2 = index2 + 1; |
||
966 | end |
||
967 | end; |
||
968 | |||
969 | Hide = function() -- CharactersViewer.Bag.Hide |
||
970 | for index = 0,4 do |
||
971 | bagFrame = getglobal("CharactersViewer_ContainerFrame" ..index ):Hide(); |
||
972 | end |
||
973 | --keyring |
||
974 | bagFrame = getglobal("CharactersViewer_KeyringContainerFrame"):Hide(); |
||
975 | end; |
||
976 | |||
977 | Draw = function(bagID, FrameID, option) -- CharactersViewer.Bag.Draw |
||
978 | local theBag, frame, name, bagTextureSuffix; |
||
979 | if( option == "bag" ) then |
||
980 | theBag = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bagID]; |
||
981 | frame = getglobal("CharactersViewer_ContainerFrame"..(FrameID)); |
||
982 | name = frame:GetName(); |
||
983 | bagTextureSuffix = ""; |
||
984 | |||
985 | elseif( option == "bankbag") then |
||
986 | theBag = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bagID]; |
||
987 | frame = getglobal("CharactersViewer_BankItemsContainerFrame"..(FrameID)); |
||
988 | name = frame:GetName(); |
||
989 | bagTextureSuffix = "-Bank"; |
||
990 | elseif ( option == "keyring" ) then |
||
991 | theBag = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][KEYRING_CONTAINER]; |
||
992 | frame = getglobal("CharactersViewer_KeyringContainerFrame"); |
||
993 | name = frame:GetName(); |
||
994 | bagTextureSuffix = "-Keyring"; |
||
995 | end |
||
996 | frame.size = theBag.size; |
||
997 | size = theBag.size; |
||
998 | id = bagID; |
||
999 | frame:Hide(); |
||
1000 | |||
1001 | local bgTextureTop = getglobal(name.."BackgroundTop"); |
||
1002 | local bgTextureMiddle = getglobal(name.."BackgroundMiddle1"); |
||
1003 | local bgTextureBottom = getglobal(name.."BackgroundBottom"); |
||
1004 | local columns = NUM_CONTAINER_COLUMNS; |
||
1005 | local rows = ceil(size / columns); |
||
1006 | -- if size = 0 then its the backpack |
||
1007 | if ( id == 0 ) then |
||
1008 | --getglobal(name.."MoneyFrame"):Show(); -- not used in CV |
||
1009 | -- Set Backpack texture |
||
1010 | bgTextureTop:SetTexture("Interface\\ContainerFrame\\UI-BackpackBackground"); |
||
1011 | bgTextureTop:SetHeight(256); |
||
1012 | bgTextureTop:SetTexCoord(0, 1, 0, 1); |
||
1013 | |||
1014 | -- Hide unused textures |
||
1015 | for i=1, MAX_BG_TEXTURES do |
||
1016 | getglobal(name.."BackgroundMiddle"..i):Hide(); |
||
1017 | end |
||
1018 | bgTextureBottom:Hide(); |
||
1019 | frame:SetHeight(240); |
||
1020 | else |
||
1021 | -- Not the backpack |
||
1022 | -- Set whether or not its a bank bag |
||
1023 | local bagTextureSuffix = ""; |
||
1024 | if ( id > NUM_BAG_FRAMES ) then |
||
1025 | bagTextureSuffix = "-Bank"; |
||
1026 | elseif ( id == KEYRING_CONTAINER ) then |
||
1027 | bagTextureSuffix = "-Keyring"; |
||
1028 | end |
||
1029 | -- Set textures |
||
1030 | bgTextureTop:SetTexture("Interface\\ContainerFrame\\UI-Bag-Components"..bagTextureSuffix); |
||
1031 | for i=1, MAX_BG_TEXTURES do |
||
1032 | getglobal(name.."BackgroundMiddle"..i):SetTexture("Interface\\ContainerFrame\\UI-Bag-Components"..bagTextureSuffix); |
||
1033 | getglobal(name.."BackgroundMiddle"..i):Hide(); |
||
1034 | end |
||
1035 | bgTextureBottom:SetTexture("Interface\\ContainerFrame\\UI-Bag-Components"..bagTextureSuffix); |
||
1036 | -- Hide the moneyframe since its not the backpack |
||
1037 | --getglobal(name.."MoneyFrame"):Hide(); -- not used in CV |
||
1038 | |||
1039 | local bgTextureCount, height; |
||
1040 | local rowHeight = 41; |
||
1041 | -- Subtract one, since the top texture contains one row already |
||
1042 | local remainingRows = rows-1; |
||
1043 | |||
1044 | -- See if the bag needs the texture with two slots at the top |
||
1045 | local isPlusTwoBag; |
||
1046 | if ( mod(size,columns) == 2 ) then |
||
1047 | isPlusTwoBag = 1; |
||
1048 | end |
||
1049 | |||
1050 | -- Bag background display stuff |
||
1051 | if ( isPlusTwoBag ) then |
||
1052 | bgTextureTop:SetTexCoord(0, 1, 0.189453125, 0.330078125); |
||
1053 | bgTextureTop:SetHeight(72); |
||
1054 | else |
||
1055 | if ( rows == 1 ) then |
||
1056 | -- If only one row chop off the bottom of the texture |
||
1057 | bgTextureTop:SetTexCoord(0, 1, 0.00390625, 0.16796875); |
||
1058 | bgTextureTop:SetHeight(86); |
||
1059 | else |
||
1060 | bgTextureTop:SetTexCoord(0, 1, 0.00390625, 0.18359375); |
||
1061 | bgTextureTop:SetHeight(94); |
||
1062 | end |
||
1063 | end |
||
1064 | -- Calculate the number of background textures we're going to need |
||
1065 | bgTextureCount = ceil(remainingRows/ROWS_IN_BG_TEXTURE); |
||
1066 | |||
1067 | local middleBgHeight = 0; |
||
1068 | -- If one row only special case |
||
1069 | if ( rows == 1 ) then |
||
1070 | bgTextureBottom:SetPoint("TOP", bgTextureMiddle:GetName(), "TOP", 0, 0); |
||
1071 | bgTextureBottom:Show(); |
||
1072 | -- Hide middle bg textures |
||
1073 | for i=1, MAX_BG_TEXTURES do |
||
1074 | getglobal(name.."BackgroundMiddle"..i):Hide(); |
||
1075 | end |
||
1076 | else |
||
1077 | -- Try to cycle all the middle bg textures |
||
1078 | local firstRowPixelOffset = 9; |
||
1079 | local firstRowTexCoordOffset = 0.353515625; |
||
1080 | for i=1, bgTextureCount do |
||
1081 | bgTextureMiddle = getglobal(name.."BackgroundMiddle"..i); |
||
1082 | if ( remainingRows > ROWS_IN_BG_TEXTURE ) then |
||
1083 | -- If more rows left to draw than can fit in a texture then draw the max possible |
||
1084 | height = ( ROWS_IN_BG_TEXTURE*rowHeight ) + firstRowTexCoordOffset; |
||
1085 | bgTextureMiddle:SetHeight(height); |
||
1086 | bgTextureMiddle:SetTexCoord(0, 1, firstRowTexCoordOffset, ( height/BG_TEXTURE_HEIGHT + firstRowTexCoordOffset) ); |
||
1087 | bgTextureMiddle:Show(); |
||
1088 | remainingRows = remainingRows - ROWS_IN_BG_TEXTURE; |
||
1089 | middleBgHeight = middleBgHeight + height; |
||
1090 | else |
||
1091 | -- If not its a huge bag |
||
1092 | bgTextureMiddle:Show(); |
||
1093 | height = remainingRows*rowHeight-firstRowPixelOffset; |
||
1094 | bgTextureMiddle:SetHeight(height); |
||
1095 | bgTextureMiddle:SetTexCoord(0, 1, firstRowTexCoordOffset, ( height/BG_TEXTURE_HEIGHT + firstRowTexCoordOffset) ); |
||
1096 | middleBgHeight = middleBgHeight + height; |
||
1097 | end |
||
1098 | end |
||
1099 | -- Position bottom texture |
||
1100 | bgTextureBottom:SetPoint("TOP", bgTextureMiddle:GetName(), "BOTTOM", 0, 0); |
||
1101 | bgTextureBottom:Show(); |
||
1102 | end |
||
1103 | -- Set the frame height |
||
1104 | frame:SetHeight(bgTextureTop:GetHeight()+bgTextureBottom:GetHeight()+middleBgHeight); |
||
1105 | end |
||
1106 | frame:SetWidth(CONTAINER_WIDTH); |
||
1107 | getglobal(name.."Name"):SetText(theBag.name ); |
||
1108 | getglobal(name.."Portrait"):SetTexture(theBag.T); |
||
1109 | |||
1110 | --[[ |
||
1111 | --Special case code for keyrings |
||
1112 | if ( id == KEYRING_CONTAINER ) then |
||
1113 | getglobal(frame:GetName().."Name"):SetText(KEYRING); |
||
1114 | SetPortraitToTexture(frame:GetName().."Portrait", "Interface\\ContainerFrame\\KeyRing-Bag-Icon"); |
||
1115 | else |
||
1116 | getglobal(frame:GetName().."Name"):SetText(GetBagName(id)); |
||
1117 | SetBagPortaitTexture(getglobal(frame:GetName().."Portrait"), id); |
||
1118 | end |
||
1119 | ]]-- |
||
1120 | |||
1121 | for j=1, size, 1 do |
||
1122 | local index = size - j + 1; |
||
1123 | item = theBag[index]; |
||
1124 | itemButton = getglobal(name.."Item"..j); |
||
1125 | -- Set first button |
||
1126 | if( j == 1 ) then |
||
1127 | -- Anchor the first item differently if its the backpack frame |
||
1128 | if ( id == 0 ) then |
||
1129 | itemButton:SetPoint("BOTTOMRIGHT", name, "BOTTOMRIGHT", -12, 30); |
||
1130 | else |
||
1131 | itemButton:SetPoint("BOTTOMRIGHT", name, "BOTTOMRIGHT", -12, 9); |
||
1132 | end |
||
1133 | else |
||
1134 | if ( mod((j-1), columns) == 0 ) then |
||
1135 | itemButton:SetPoint("BOTTOMRIGHT", name.."Item"..(j - columns), "TOPRIGHT", 0, 4); |
||
1136 | else |
||
1137 | itemButton:SetPoint("BOTTOMRIGHT", name.."Item"..(j - 1), "BOTTOMLEFT", -5, 0); |
||
1138 | end |
||
1139 | end |
||
1140 | end |
||
1141 | |||
1142 | for j = 1, size do |
||
1143 | index = size - (j - 1); |
||
1144 | getglobal(name.."Item"..j):SetID(100 * id + index + 100 ); |
||
1145 | item = theBag[index]; |
||
1146 | itemButton = getglobal(name.."Item"..j); |
||
1147 | if( item ) then |
||
1148 | SetItemButtonTexture(itemButton, item.T); |
||
1149 | SetItemButtonCount(itemButton, item.C); |
||
1150 | else |
||
1151 | SetItemButtonTexture(itemButton,""); |
||
1152 | SetItemButtonCount(itemButton, nil); |
||
1153 | end |
||
1154 | itemButton:Show(); |
||
1155 | end |
||
1156 | for j=size + 1, 36, 1 do |
||
1157 | getglobal(name.."Item"..j):Hide(); |
||
1158 | end |
||
1159 | frame:Show(); |
||
1160 | --PlaySound("igBackPackOpen"); |
||
1161 | end; |
||
1162 | |||
1163 | Toggle = function () -- CharactersViewer.Bag.Toggle |
||
1164 | if(CharactersViewerConfig["Bag_Display"] == true) then |
||
1165 | CharactersViewerConfig["Bag_Display"] = false; |
||
1166 | CharactersViewer.Bag.Hide(); |
||
1167 | else |
||
1168 | CharactersViewerConfig["Bag_Display"] = true; |
||
1169 | CharactersViewer.Bag.Display(); |
||
1170 | end |
||
1171 | end; |
||
1172 | |||
1173 | ToggleButton_OnClick = function(arg1) -- CharactersViewer.Bag.ToggleButton_OnClick |
||
1174 | if(arg1 == "LeftButton") then |
||
1175 | CharactersViewer.Bag.Toggle(); |
||
1176 | elseif(arg1 == "RightButton") then |
||
1177 | --CharactersViewer_ResetBag(); |
||
1178 | CharactersViewer.Bag.Relocate(true); |
||
1179 | end |
||
1180 | end; |
||
1181 | |||
1182 | Relocate = function(change) -- CharactersViewer.Bag.Relocate |
||
1183 | if( change ) then |
||
1184 | if( CharactersViewerConfig["Bag_Location"] == nil ) then |
||
1185 | CharactersViewerConfig["Bag_Location"] = 0; |
||
1186 | else |
||
1187 | CharactersViewerConfig["Bag_Location"] = CharactersViewerConfig["Bag_Location"] +1; |
||
1188 | if( CharactersViewerConfig["Bag_Location"] >= 2) then |
||
1189 | CharactersViewerConfig["Bag_Location"] = 0; |
||
1190 | end |
||
1191 | end |
||
1192 | end |
||
1193 | if( CharactersViewerConfig["Bag_Location"] == 1) then |
||
1194 | -- Bag |
||
1195 | CharactersViewer_ContainerFrame0:SetPoint("TOPLEFT", "CharactersViewer_Frame", "TOPRIGHT"); |
||
1196 | CharactersViewer_ContainerFrame1:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame0", "BOTTOMLEFT" ); |
||
1197 | CharactersViewer_ContainerFrame2:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame1", "BOTTOMLEFT" ); |
||
1198 | CharactersViewer_ContainerFrame3:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame0", "TOPRIGHT"); |
||
1199 | CharactersViewer_ContainerFrame4:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame3", "BOTTOMLEFT" ); |
||
1200 | CharactersViewer_KeyringContainerFrame:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame4", "BOTTOMLEFT" ); |
||
1201 | CharactersViewer_ContainerFrame0:SetUserPlaced(); |
||
1202 | CharactersViewer_ContainerFrame1:SetUserPlaced(); |
||
1203 | CharactersViewer_ContainerFrame2:SetUserPlaced(); |
||
1204 | CharactersViewer_ContainerFrame3:SetUserPlaced(); |
||
1205 | CharactersViewer_ContainerFrame4:SetUserPlaced(); |
||
1206 | CharactersViewer_KeyringContainerFrame:SetUserPlaced(); |
||
1207 | else |
||
1208 | -- Bag |
||
1209 | CharactersViewer_ContainerFrame0:SetPoint("TOPLEFT", "CharactersViewer_Frame", "TOPRIGHT"); |
||
1210 | CharactersViewer_ContainerFrame1:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame0", "TOPRIGHT" ); |
||
1211 | CharactersViewer_ContainerFrame2:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame1", "TOPRIGHT" ); |
||
1212 | CharactersViewer_ContainerFrame3:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame0", "BOTTOMLEFT"); |
||
1213 | CharactersViewer_ContainerFrame4:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame3", "TOPRIGHT" ); |
||
1214 | CharactersViewer_KeyringContainerFrame:SetPoint("TOPLEFT", "CharactersViewer_ContainerFrame4", "TOPRIGHT"); |
||
1215 | CharactersViewer_ContainerFrame0:SetUserPlaced(); |
||
1216 | CharactersViewer_ContainerFrame1:SetUserPlaced(); |
||
1217 | CharactersViewer_ContainerFrame2:SetUserPlaced(); |
||
1218 | CharactersViewer_ContainerFrame3:SetUserPlaced(); |
||
1219 | CharactersViewer_ContainerFrame4:SetUserPlaced(); |
||
1220 | CharactersViewer_KeyringContainerFrame:SetUserPlaced(); |
||
1221 | end |
||
1222 | end; |
||
1223 | |||
1224 | Toggle_Button_OnEnter = function() -- CharactersViewer.Bag.ToggleButton_OnEnter |
||
1225 | ShowUIPanel(GameTooltip); |
||
1226 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1227 | GameTooltip:SetText(CHARACTERSVIEWER_TOOLTIP_BAGRESET); |
||
1228 | end; |
||
1229 | }; |
||
1230 | |||
1231 | Bank = { -- CharactersViewer.Bank |
||
1232 | Toggle = function() -- CharactersViewer.Bank.Toggle |
||
1233 | if(CharactersViewerBankFrame:IsVisible() ) then |
||
1234 | CharactersViewerConfig["Bank_Display"] = false; |
||
1235 | CharactersViewer.Bank.Close() |
||
1236 | else |
||
1237 | CharactersViewerConfig["Bank_Display"] = true; |
||
1238 | CharactersViewer.Bank.Show(); |
||
1239 | end |
||
1240 | end; |
||
1241 | |||
1242 | Toggle_Button_OnEnter = function() -- CharactersViewer.Bag.ToggleButton_OnEnter |
||
1243 | ShowUIPanel(GameTooltip); |
||
1244 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1245 | GameTooltip:SetText(CHARACTERSVIEWER_TOOLTIP_BANKBAG); |
||
1246 | end; |
||
1247 | |||
1248 | ToggleButton_OnClick = function(arg1) -- CharactersViewer.Bank.ToggleButton_OnClick |
||
1249 | if(arg1 == "LeftButton") then |
||
1250 | CharactersViewer.Bank.BagToggle(); |
||
1251 | elseif(arg1 == "RightButton") then |
||
1252 | ----- |
||
1253 | CharactersViewer.Bank.BagRelocate(true); |
||
1254 | end |
||
1255 | end; |
||
1256 | |||
1257 | BagToggle = function () -- CharactersViewer.Bag.Toggle |
||
1258 | if(CharactersViewerConfig["BankBag_Display"] == true) then |
||
1259 | CharactersViewerConfig["BankBag_Display"] = false; |
||
1260 | CharactersViewer.Bank.BagHide(); |
||
1261 | else |
||
1262 | CharactersViewerConfig["BankBag_Display"] = true; |
||
1263 | CharactersViewer.Bank.BagDisplay(); |
||
1264 | end |
||
1265 | end; |
||
1266 | |||
1267 | BagDisplay = function () -- CharactersViewer.Bank.BagDisplay |
||
1268 | if( not CharactersViewer_BankItemsContainerFrame6:IsUserPlaced() |
||
1269 | and not CharactersViewer_BankItemsContainerFrame6:IsUserPlaced() |
||
1270 | and not CharactersViewer_BankItemsContainerFrame7:IsUserPlaced() |
||
1271 | and not CharactersViewer_BankItemsContainerFrame8:IsUserPlaced() |
||
1272 | and not CharactersViewer_BankItemsContainerFrame9:IsUserPlaced() |
||
1273 | and not CharactersViewer_BankItemsContainerFrame10:IsUserPlaced()) then |
||
1274 | CharactersViewer.Bank.BagRelocate(false) |
||
1275 | end |
||
1276 | |||
1277 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] ~= nil) then |
||
1278 | local index2 = 5; |
||
1279 | for index = 5,10 do |
||
1280 | getglobal("CharactersViewer_BankItemsContainerFrame" ..index ):Hide(); |
||
1281 | --- Removed Flisher 2005-05-29 bagFrame:Hide(); |
||
1282 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][index]) then |
||
1283 | CharactersViewer.Bag.Draw(index, index2, "bankbag"); |
||
1284 | index2 = index2 + 1; |
||
1285 | end |
||
1286 | end |
||
1287 | end |
||
1288 | end; |
||
1289 | |||
1290 | BagHide = function() -- CharactersViewer.Bank.BagHide |
||
1291 | for index = 5,10 do |
||
1292 | bagFrame = getglobal("CharactersViewer_BankItemsContainerFrame" ..index ):Hide(); |
||
1293 | end |
||
1294 | end; |
||
1295 | |||
1296 | Close = function() -- CharactersViewer.Bank.Close |
||
1297 | CharactersViewerBankFrame:Hide(); |
||
1298 | end; |
||
1299 | |||
1300 | Show = function () -- CharactersViewer.Bank.Show |
||
1301 | CharactersViewerBankFrame:Hide(); |
||
1302 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] ) then |
||
1303 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Money"] ) then |
||
1304 | --MoneyFrame_Update("CharactersViewerBankItems_MoneyFrame", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Money"]); |
||
1305 | temp1 = CharactersViewer.library.MoneyTotal(1); |
||
1306 | temp2 = CharactersViewer.library.MoneyTotal(2); |
||
1307 | MoneyFrame_Update("CharactersViewerBankItems_MoneyFrameTotal1", temp1); |
||
1308 | MoneyFrame_Update("CharactersViewerBankItems_MoneyFrameTotal2", temp2); |
||
1309 | MoneyFrame_Update("CharactersViewerBankItems_MoneyFrameTotal3", temp1 + temp2); |
||
1310 | if ( temp1 <= 0 ) then |
||
1311 | CharactersViewerBankMoney1:Hide(); |
||
1312 | else |
||
1313 | CharactersViewerBankMoney1:Show(); |
||
1314 | end |
||
1315 | |||
1316 | if ( temp2 <= 0 ) then |
||
1317 | CharactersViewerBankMoney2:Hide(); |
||
1318 | else |
||
1319 | CharactersViewerBankMoney2:Show(); |
||
1320 | end |
||
1321 | |||
1322 | |||
1323 | end |
||
1324 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] ) then |
||
1325 | for slot = 1, 24 do |
||
1326 | button = getglobal("CharactersViewerBankItem_Item" .. slot); |
||
1327 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot] ) then |
||
1328 | SetItemButtonTexture(button, CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].T); |
||
1329 | SetItemButtonCount(button, CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].C); |
||
1330 | button:Show(); |
||
1331 | else |
||
1332 | button:Hide(); |
||
1333 | end |
||
1334 | end |
||
1335 | for bagId = 5, 10 do |
||
1336 | button = getglobal("CharactersViewerBankItems_Bag" .. bagId); |
||
1337 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bagId] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bagId]["T"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bagId]["size"]) then |
||
1338 | SetItemButtonTexture(button, CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bagId].T); |
||
1339 | button:Show(); |
||
1340 | else |
||
1341 | button:Hide(); |
||
1342 | end |
||
1343 | |||
1344 | end |
||
1345 | |||
1346 | end |
||
1347 | end |
||
1348 | ShowUIPanel(CharactersViewerBankFrame); |
||
1349 | end; |
||
1350 | |||
1351 | OnEnter = function() -- CharactersViewer.Bank.OnEnter |
||
1352 | local count = ""; |
||
1353 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1354 | GameTooltip:SetText(CHARACTERSVIEWER_TOOLTIP_BANK); |
||
1355 | end; |
||
1356 | |||
1357 | OnClick = function(button) -- CharactersViewer.Bank.OnClick |
||
1358 | if(arg1 == "LeftButton") then |
||
1359 | CharactersViewer.Bank.Toggle(); |
||
1360 | elseif(arg1 == "RightButton") then |
||
1361 | CharactersViewer.Bank.Relocate(true); |
||
1362 | end |
||
1363 | end; |
||
1364 | |||
1365 | Relocate = function ( change) -- CharactersViewer.Bank.Relocate |
||
1366 | if( CharactersViewerConfig["Bank_Location"] == 1) then |
||
1367 | -- Bag |
||
1368 | CharactersViewerBankFrame:SetPoint("TOPLEFT", "CharactersViewer_Frame", "TOPRIGHT"); |
||
1369 | CharactersViewerBankFrame:SetUserPlaced(0); |
||
1370 | if( change) then |
||
1371 | CharactersViewerConfig["Bank_Location"] = 0; |
||
1372 | end |
||
1373 | else |
||
1374 | -- Bag |
||
1375 | CharactersViewerBankFrame:SetPoint("TOPLEFT", "CharactersViewer_Frame", "BOTTOMLEFT", 0 , 64); |
||
1376 | CharactersViewerBankFrame:SetUserPlaced(0); |
||
1377 | if( change ) then |
||
1378 | CharactersViewerConfig["Bank_Location"] = 1; |
||
1379 | end |
||
1380 | end |
||
1381 | end; |
||
1382 | |||
1383 | BagRelocate = function ( change, bagID ) -- CharactersViewer.Bank.BagRelocate |
||
1384 | if( change ) then |
||
1385 | if( CharactersViewerConfig["BankBag_Location"] == nil ) then |
||
1386 | CharactersViewerConfig["BankBag_Location"] = 0; |
||
1387 | else |
||
1388 | CharactersViewerConfig["BankBag_Location"] = CharactersViewerConfig["BankBag_Location"] +1; |
||
1389 | if( CharactersViewerConfig["BankBag_Location"] >= 2) then |
||
1390 | CharactersViewerConfig["BankBag_Location"] = 0; |
||
1391 | end |
||
1392 | end |
||
1393 | end |
||
1394 | |||
1395 | if( CharactersViewerConfig["BankBag_Location"] == 1) then |
||
1396 | -- Bag |
||
1397 | CharactersViewer_BankItemsContainerFrame5:SetPoint("TOPLEFT", "CharactersViewerBankFrame", "TOPRIGHT" ); |
||
1398 | CharactersViewer_BankItemsContainerFrame6:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame5", "BOTTOMLEFT" ); |
||
1399 | CharactersViewer_BankItemsContainerFrame7:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame6", "BOTTOMLEFT" ); |
||
1400 | CharactersViewer_BankItemsContainerFrame8:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame5", "TOPRIGHT" ); |
||
1401 | CharactersViewer_BankItemsContainerFrame9:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame8", "BOTTOMLEFT" ); |
||
1402 | CharactersViewer_BankItemsContainerFrame10:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame9", "BOTTOMLEFT" ); |
||
1403 | CharactersViewer_BankItemsContainerFrame5:SetUserPlaced(); |
||
1404 | CharactersViewer_BankItemsContainerFrame6:SetUserPlaced(); |
||
1405 | CharactersViewer_BankItemsContainerFrame7:SetUserPlaced(); |
||
1406 | CharactersViewer_BankItemsContainerFrame8:SetUserPlaced(); |
||
1407 | CharactersViewer_BankItemsContainerFrame9:SetUserPlaced(); |
||
1408 | CharactersViewer_BankItemsContainerFrame10:SetUserPlaced(); |
||
1409 | else |
||
1410 | -- Bag |
||
1411 | CharactersViewer_BankItemsContainerFrame5:SetPoint("TOPLEFT", "CharactersViewerBankFrame", "TOPRIGHT" ); |
||
1412 | CharactersViewer_BankItemsContainerFrame6:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame5", "TOPRIGHT" ); |
||
1413 | CharactersViewer_BankItemsContainerFrame7:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame6", "TOPRIGHT" ); |
||
1414 | CharactersViewer_BankItemsContainerFrame8:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame5", "BOTTOMLEFT" ); |
||
1415 | CharactersViewer_BankItemsContainerFrame9:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame8", "TOPRIGHT" ); |
||
1416 | CharactersViewer_BankItemsContainerFrame10:SetPoint("TOPLEFT", "CharactersViewer_BankItemsContainerFrame9", "TOPRIGHT" ); |
||
1417 | CharactersViewer_BankItemsContainerFrame5:SetUserPlaced(); |
||
1418 | CharactersViewer_BankItemsContainerFrame6:SetUserPlaced(); |
||
1419 | CharactersViewer_BankItemsContainerFrame7:SetUserPlaced(); |
||
1420 | CharactersViewer_BankItemsContainerFrame8:SetUserPlaced(); |
||
1421 | CharactersViewer_BankItemsContainerFrame9:SetUserPlaced(); |
||
1422 | CharactersViewer_BankItemsContainerFrame10:SetUserPlaced(); |
||
1423 | end |
||
1424 | end; |
||
1425 | }; |
||
1426 | |||
1427 | Note = { |
||
1428 | Guild_OnUpdate = function () |
||
1429 | local guildOffset = FauxScrollFrame_GetOffset(GuildListScrollFrame); |
||
1430 | if(GuildFrameButton1:IsVisible()) then |
||
1431 | for i=1, GUILDMEMBERS_TO_DISPLAY, 1 do |
||
1432 | local button = getglobal("CharactersViewerGuildFrameNoteButton"..i); |
||
1433 | local name = GetGuildRosterInfo(i + guildOffset); |
||
1434 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][name]) then |
||
1435 | button:Show(); |
||
1436 | else |
||
1437 | button:Hide(); |
||
1438 | end |
||
1439 | end |
||
1440 | end |
||
1441 | end; |
||
1442 | |||
1443 | Guild_OnClick = function (arg1) |
||
1444 | local name = GetGuildRosterInfo(this:GetID() + FauxScrollFrame_GetOffset(GuildListScrollFrame)); |
||
1445 | if( CharactersViewer.index ~= name ) then |
||
1446 | CharactersViewer.Switch(name); |
||
1447 | CharactersViewer_Show(); |
||
1448 | else |
||
1449 | CharactersViewer_Toggle(); |
||
1450 | end |
||
1451 | end; |
||
1452 | |||
1453 | Guild_OnEnter = function () |
||
1454 | ShowUIPanel(GameTooltip); |
||
1455 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1456 | if( CharactersViewerProfile ~= nil and CharactersViewerProfile[Server] ~= nil and CharactersViewerProfile[Server][CharactersViewer.index] ~= nil and CharactersViewerProfile[Server][CharactersViewer.index]["Timestamp"] ~= nil ) then |
||
1457 | GameTooltip:SetText(BINDING_NAME_CHARACTERSVIEWER_TOGGLE .. "\n" .. CHARACTERSVIEWER_SAVEDON .. date(nil, CharactersViewerProfile[Server][CharactersViewer.index]["Timestamp"] ) ); |
||
1458 | else |
||
1459 | GameTooltip:SetText(BINDING_NAME_CHARACTERSVIEWER_TOGGLE) |
||
1460 | end |
||
1461 | end; |
||
1462 | }; |
||
1463 | |||
1464 | -- Variables |
||
1465 | index = nil; -- is now initialised via the first data collect, which should happen before any possible call |
||
1466 | loaded = nil; -- Successful load of the script |
||
1467 | version = |
||
1468 | { db = 62; |
||
1469 | text = "1.03"; |
||
1470 | number = 103; |
||
1471 | date = "July 6th, 2006"; |
||
1472 | }; |
||
1473 | |||
1474 | constant = |
||
1475 | { event = -- CharactersViewer.constant.event |
||
1476 | { |
||
1477 | "VARIABLES_LOADED"; |
||
1478 | "UNIT_NAME_UPDATE"; |
||
1479 | "PLAYER_GUILD_UPDATE"; |
||
1480 | "UNIT_INVENTORY_CHANGED"; |
||
1481 | "PLAYER_LEVEL_UP"; |
||
1482 | "PLAYER_PVP_RANK_CHANGED"; |
||
1483 | "CHARACTER_POINTS_CHANGED"; |
||
1484 | |||
1485 | "MAIL_SHOW"; -- Mail |
||
1486 | "MAIL_CLOSED"; -- Mail |
||
1487 | |||
1488 | "BANKFRAME_OPENED"; -- Bank |
||
1489 | --"BANKFRAME_CLOSED"; -- Bank |
||
1490 | "PLAYERBANKSLOTS_CHANGED"; -- Bank |
||
1491 | "PLAYERBANKBAGSLOTS_CHANGED"; -- Bank |
||
1492 | "BAG_UPDATE"; -- Bank |
||
1493 | |||
1494 | --"PLAYER_MONEY"; -- Money |
||
1495 | }; |
||
1496 | |||
1497 | inventorySlot = |
||
1498 | { |
||
1499 | Name = |
||
1500 | { |
||
1501 | [0] = AMMOSLOT, -- 0 |
||
1502 | [1] = HEADSLOT, -- 1 |
||
1503 | [2] = NECKSLOT, -- 2 |
||
1504 | [3] = SHOULDERSLOT, -- 3 |
||
1505 | [4] = SHIRTSLOT, -- 4 |
||
1506 | [5] = CHESTSLOT, -- 5 |
||
1507 | [6] = WAISTSLOT, -- 6 |
||
1508 | [7] = LEGSSLOT, -- 7 |
||
1509 | [8] = FEETSLOT, -- 8 |
||
1510 | [9] = WRISTSLOT, -- 9 |
||
1511 | [10] = HANDSSLOT, -- 10 |
||
1512 | [11] = FINGER0SLOT, -- 11 |
||
1513 | [12] = FINGER1SLOT, -- 12 |
||
1514 | [13] = TRINKET0SLOT, -- 13 |
||
1515 | [14] = TRINKET1SLOT, -- 14 |
||
1516 | [15] = BACKSLOT, -- 15 |
||
1517 | [16] = MAINHANDSLOT, -- 16 |
||
1518 | [17] = SECONDARYHANDSLOT, -- 17 |
||
1519 | [18] = RANGEDSLOT, -- 18 |
||
1520 | [19] = TABARDSLOT, -- 19 |
||
1521 | }; |
||
1522 | |||
1523 | Texture = |
||
1524 | { |
||
1525 | [0] = ({GetInventorySlotInfo("AMMOSLOT")})[2], -- 0 |
||
1526 | [1] = ({GetInventorySlotInfo("HEADSLOT")})[2], -- 1 |
||
1527 | [2] = ({GetInventorySlotInfo("NECKSLOT")})[2], -- 2 |
||
1528 | [3] = ({GetInventorySlotInfo("SHOULDERSLOT")})[2], -- 3 |
||
1529 | [4] = ({GetInventorySlotInfo("SHIRTSLOT")})[2], -- 4 |
||
1530 | [5] = ({GetInventorySlotInfo("CHESTSLOT")})[2], -- 5 |
||
1531 | [6] = ({GetInventorySlotInfo("WAISTSLOT")})[2], -- 6 |
||
1532 | [7] = ({GetInventorySlotInfo("LEGSSLOT")})[2], -- 7 |
||
1533 | [8] = ({GetInventorySlotInfo("FEETSLOT")})[2], -- 8 |
||
1534 | [9] = ({GetInventorySlotInfo("WRISTSLOT")})[2], -- 9 |
||
1535 | [10] = ({GetInventorySlotInfo("HANDSSLOT")})[2], -- 10 |
||
1536 | [11] = ({GetInventorySlotInfo("FINGER0SLOT")})[2], -- 11 |
||
1537 | [12] = ({GetInventorySlotInfo("FINGER1SLOT")})[2], -- 12 |
||
1538 | [13] = ({GetInventorySlotInfo("TRINKET0SLOT")})[2], -- 13 |
||
1539 | [14] = ({GetInventorySlotInfo("TRINKET1SLOT")})[2], -- 14 |
||
1540 | [15] = ({GetInventorySlotInfo("BACKSLOT")})[2], -- 15 |
||
1541 | [16] = ({GetInventorySlotInfo("MAINHANDSLOT")})[2], -- 16 |
||
1542 | [17] = ({GetInventorySlotInfo("SECONDARYHANDSLOT")})[2], -- 17 |
||
1543 | [18] = ({GetInventorySlotInfo("RANGEDSLOT")})[2], -- 18 |
||
1544 | [19] = ({GetInventorySlotInfo("TABARDSLOT")})[2], -- 19 |
||
1545 | } |
||
1546 | }; |
||
1547 | }; |
||
1548 | |||
1549 | config = { }; |
||
1550 | |||
1551 | status = { |
||
1552 | register = {}; |
||
1553 | -- Known status to be inserted by the code lather |
||
1554 | -- loaded (meaning the initial load/initialisation is done) |
||
1555 | -- collected (true = that the system collected data at least once |
||
1556 | }; |
||
1557 | |||
1558 | debug = { -- Added as I can use many debug flag for developpement - Flisher 2006-06-16 |
||
1559 | |||
1560 | }; |
||
1561 | |||
1562 | }; -- End of CharactersViewer Object |
||
1563 | |||
1564 | -- OnFoo functions |
||
1565 | |||
1566 | function CharactersViewer_OnEvent(event, arg1) -- Cleaned by Flisher 2005-05-31 |
||
1567 | if(event == "VARIABLES_LOADED" and not CharactersViewer.status.loaded) then |
||
1568 | -- Set the Loaded Status to true, to ensure it's not runned twice, we never know with blizzard... |
||
1569 | CharactersViewer.status.loaded = true; |
||
1570 | |||
1571 | -- Configure the panel display and title |
||
1572 | tinsert(UISpecialFrames, "CharactersViewer_Frame"); |
||
1573 | UIPanelWindows["CharactersViewer_Frame"] = nil; |
||
1574 | CharactersViewer_Frame:RegisterForDrag("LeftButton"); |
||
1575 | |||
1576 | tinsert(UISpecialFrames, "CharactersViewerBankFrame"); |
||
1577 | UIPanelWindows["CharactersViewerBankFrame"] = nil; |
||
1578 | --CharactersViewer_Frame:RegisterForDrag("LeftButton"); |
||
1579 | |||
1580 | --UIPanelWindows["CharactersViewerBankFrame"] = { area = "up", pushable = 6 }; |
||
1581 | CharactersViewer_FrameTitleText:SetText("CharactersViewer " .. CharactersViewer.version.text .. " by Flisher"); |
||
1582 | |||
1583 | -- Hooked function |
||
1584 | CharactersViewer.register.hook(); |
||
1585 | |||
1586 | -- Database version checkup, clean the data if the database version is obsolete |
||
1587 | if(CharactersViewer.db.validate() == false) then |
||
1588 | CharactersViewer.db.init(); |
||
1589 | end |
||
1590 | end |
||
1591 | |||
1592 | |||
1593 | -- Escape if we can't properly initialize, gotta be checked after 1.5.0 patch, not trigered on loading, but sometime trigered on mail retrieval |
||
1594 | if( ( event == "UNIT_INVENTORY_CHANGED" and arg1 ~= "player" ) or not UnitName("player") or UnitName("player") == UNKNOWNOBJECT or UnitName("player") == UKNOWNBEING or not Server) then |
||
1595 | return; |
||
1596 | end |
||
1597 | |||
1598 | if(event == "MAIL_SHOW" or event == "MAIL_CLOSED") then |
||
1599 | if(CharactersViewerProfile and CharactersViewerProfile[Server]and CharactersViewerProfile[Server][UnitName("player")]and |
||
1600 | CharactersViewerProfile[Server][UnitName("player")]["Data"] ) then |
||
1601 | CharactersViewerProfile[Server][UnitName("player")]["Data"]["Mail"] = CharactersViewer.collect.mail(true); |
||
1602 | end |
||
1603 | elseif( event == "BANKFRAME_OPENED" or event == "BANKFRAME_CLOSED" or event == "PLAYERBANKSLOTS_CHANGED" or event == "PLAYERBANKBAGSLOTS_CHANGED" ) then |
||
1604 | CharactersViewer.collect.bank.SaveItems(); |
||
1605 | return; |
||
1606 | elseif( event == "BAG_UPDATE" and BankFrame:IsVisible() ) then |
||
1607 | if( tonumber(arg1) and tonumber(arg1) > 4 and tonumber(arg1) <= 10 ) then |
||
1608 | CharactersViewer.collect.bank.SaveItems(); -- Populate all bank / bank bags... |
||
1609 | end |
||
1610 | return; |
||
1611 | else |
||
1612 | CharactersViewer.collect.all(); |
||
1613 | end |
||
1614 | |||
1615 | return; |
||
1616 | end |
||
1617 | |||
1618 | function CharactersViewerItemButton_OnEnter() -- Cleaned by Flisher 2005-05-31 |
||
1619 | local link, text, itemCount; |
||
1620 | -- Detecting if it's from the inventory or equipment |
||
1621 | if(this:GetID() < 100 and this:GetID() > 0) then |
||
1622 | -- Equiped item link |
||
1623 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()]) then |
||
1624 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()].L ; |
||
1625 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()].C) then |
||
1626 | itemCount = CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()].C; |
||
1627 | end |
||
1628 | else |
||
1629 | text = CharactersViewer.constant.inventorySlot.Name[this:GetID()]; |
||
1630 | end |
||
1631 | elseif(this:GetID() > 2000 and this:GetID() < 2100) then |
||
1632 | local slot = this:GetID() - 2000; |
||
1633 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot] ) then |
||
1634 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L ) then |
||
1635 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L; |
||
1636 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].C ) then |
||
1637 | itemCount = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].C; |
||
1638 | end |
||
1639 | end |
||
1640 | else |
||
1641 | text = EMPTY; |
||
1642 | end |
||
1643 | elseif ( (this:GetID() >= 100 and this:GetID() < 600) or (this:GetID() >= -100 and this:GetID() < -80 ) ) then |
||
1644 | -- Inventory item link |
||
1645 | local slot = math.mod( abs(this:GetID() +100), 100); |
||
1646 | local bag = (this:GetID() - slot - 100) / 100; |
||
1647 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L) then |
||
1648 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L; |
||
1649 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].C) then |
||
1650 | itemCount = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].C; |
||
1651 | end |
||
1652 | else |
||
1653 | text = EMPTY; |
||
1654 | end |
||
1655 | elseif(this:GetID() >= 600 and this:GetID() < 1200) then |
||
1656 | -- Inventory item link |
||
1657 | local slot = math.mod(this:GetID(), 100); |
||
1658 | local bag = (this:GetID() - slot - 100) / 100; |
||
1659 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L) then |
||
1660 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L; |
||
1661 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].C) then |
||
1662 | itemCount = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].C; |
||
1663 | end |
||
1664 | else |
||
1665 | text = EMPTY; |
||
1666 | end |
||
1667 | end |
||
1668 | ShowUIPanel(GameTooltip); |
||
1669 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1670 | if(link) then |
||
1671 | if( GetItemInfo(link) ) then |
||
1672 | GameTooltip:SetHyperlink(link); |
||
1673 | else |
||
1674 | GameTooltip:SetText(CHARACTERSVIEWER_NOT_CACHED); |
||
1675 | end |
||
1676 | else |
||
1677 | GameTooltip:SetText(text); |
||
1678 | end |
||
1679 | |||
1680 | -- Book of Crafts inter-operability (http://www.curse-gaming.com/mod.php?addid=1397) |
||
1681 | if(BookOfCrafts_UpdateGameToolTips and link) then |
||
1682 | BookOfCrafts_UpdateGameToolTips(); |
||
1683 | end |
||
1684 | |||
1685 | -- Receipe Book inter-operability (http://www.curse-gaming.com/mod.php?addid=914) |
||
1686 | if( RecipeBook_DoHookedFunction and link) then |
||
1687 | RecipeBook_DoHookedFunction(); |
||
1688 | end |
||
1689 | |||
1690 | |||
1691 | |||
1692 | --Auctioneer inter-operability (http://www.curse-gaming.com/mod.php?addid=146) |
||
1693 | if(TT_TooltipCall and link) then |
||
1694 | local name,_,quality = GetItemInfo(link); |
||
1695 | if(name) then |
||
1696 | if(not itemCount) then |
||
1697 | itemCount = 1; |
||
1698 | end |
||
1699 | TT_Clear(); |
||
1700 | TT_TooltipCall(GameTooltip, name, CharactersViewer.library.MakeLink(link), quality, itemCount); |
||
1701 | TT_Show(GameTooltip); |
||
1702 | end |
||
1703 | end |
||
1704 | |||
1705 | end |
||
1706 | |||
1707 | function CharactersViewer_Tooltip_SetInventoryItem(tooltip, slotid) -- Cleaned by Flisher 2005-05-31 |
||
1708 | local link, text; |
||
1709 | --! if(not CharactersViewer.index) then |
||
1710 | --! CharactersViewer.Switch(); |
||
1711 | --! end |
||
1712 | |||
1713 | if( CharactersViewer.index ~= UnitName("player") ) then |
||
1714 | -- Detecting if it's from the inventory or equipment |
||
1715 | if( slotid < 100 and slotid > 0) then |
||
1716 | -- Equiped item link |
||
1717 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][slotid] ) then |
||
1718 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][slotid].L ; |
||
1719 | else |
||
1720 | text = CharactersViewer.constant.inventorySlot.Name[slotid]; |
||
1721 | end |
||
1722 | elseif(slotid > 2000 and slotid < 2100) then |
||
1723 | local slot = slotid - 2000; |
||
1724 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot] ) then |
||
1725 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L ) then |
||
1726 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L; |
||
1727 | end |
||
1728 | else |
||
1729 | text = EMPTY; |
||
1730 | end |
||
1731 | elseif ( ( slotid >= 100 and slotid < 600) or (slotid >= -100 and slotid < -80 ) ) then |
||
1732 | -- Inventory item link |
||
1733 | local slot = math.mod( abs(slotid+100), 100); |
||
1734 | local bag = (slotid - slot - 100) / 100; |
||
1735 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L) then |
||
1736 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L; |
||
1737 | else |
||
1738 | text = EMPTY; |
||
1739 | end |
||
1740 | elseif( slotid >= 600 and slotid < 1200) then |
||
1741 | -- Inventory item link |
||
1742 | local slot = math.mod(slotid, 100); |
||
1743 | local bag = (slotid - slot - 100) / 100; |
||
1744 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot]and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L) then |
||
1745 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L; |
||
1746 | else |
||
1747 | text = EMPTY; |
||
1748 | end |
||
1749 | end |
||
1750 | |||
1751 | if(link) then |
||
1752 | if( GetItemInfo(link) ) then |
||
1753 | tooltip:SetHyperlink(link); |
||
1754 | if(UnitName("player") ~= CharactersViewer.index) then |
||
1755 | tooltip:AddLine(CharactersViewer.index .. " " .. INVENTORY_TOOLTIP); |
||
1756 | tooltip:Show(); |
||
1757 | else |
||
1758 | tooltip:Show(); |
||
1759 | end |
||
1760 | else |
||
1761 | tooltip:SetText(CHARACTERSVIEWER_NOT_CACHED); |
||
1762 | end |
||
1763 | end |
||
1764 | else |
||
1765 | -- if the player requested is the logged one, use the original game tooltip |
||
1766 | tooltip:SetInventoryItem("player", slotid); |
||
1767 | tooltip:Show(); |
||
1768 | end |
||
1769 | |||
1770 | end |
||
1771 | |||
1772 | function CharactersViewerItemButton_OnClick(arg1) -- Cleaned by Flisher 2005-05-31 |
||
1773 | local link, item; |
||
1774 | -- Detecting if it's from the inventory or equipment |
||
1775 | if(this:GetID() < 100 and this:GetID() > 0 ) then |
||
1776 | -- Equiped item link |
||
1777 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()]) then |
||
1778 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"][this:GetID()].L; |
||
1779 | end |
||
1780 | elseif(this:GetID() > 2000 and this:GetID() < 2100) then |
||
1781 | local slot = this:GetID() - 2000; |
||
1782 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot] ) then |
||
1783 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L ) then |
||
1784 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"]["Main"][slot].L; |
||
1785 | end |
||
1786 | end |
||
1787 | elseif ( ( this:GetID() >= 100 and this:GetID() < 600) or (this:GetID() >= -100 and this:GetID() < -80 ) ) then |
||
1788 | -- Inventory item link |
||
1789 | local slot = math.mod( abs(this:GetID()+100), 100); |
||
1790 | local bag = (this:GetID() - slot - 100) / 100; |
||
1791 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Bag"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L) then |
||
1792 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bag"][bag][slot].L; |
||
1793 | end |
||
1794 | elseif( this:GetID() >= 600 and this:GetID() < 1200) then |
||
1795 | -- Inventory item link |
||
1796 | local slot = math.mod(this:GetID(), 100); |
||
1797 | local bag = (this:GetID() - slot - 100) / 100; |
||
1798 | if ( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L ) then |
||
1799 | link = CharactersViewerProfile[Server][CharactersViewer.index]["Bank"][bag][slot].L; |
||
1800 | end |
||
1801 | end |
||
1802 | link = CharactersViewer.library.MakeLink(link); |
||
1803 | if(IsShiftKeyDown() and ChatFrameEditBox:IsVisible() and link and arg1 == "LeftButton") then |
||
1804 | ChatFrameEditBox:Insert(link); |
||
1805 | end |
||
1806 | if( arg1 == "LeftButton" and IsControlKeyDown() ) then |
||
1807 | DressUpItemLink(link); |
||
1808 | end |
||
1809 | |||
1810 | -- Component interaction, http://www.curse-gaming.com/mod.php?addid=1256, added by Flisher 2005-06-16 |
||
1811 | --! CharactersViewerItemButton_OnClick must be kept in backtracking ability CharactersViewer.button.onclick(); |
||
1812 | if(Comp_TestOnClick and Comp_TestOnClick() and link) then |
||
1813 | return Comp_OnClick(arg1, link); |
||
1814 | end |
||
1815 | end |
||
1816 | |||
1817 | function CharactersViewerMagicResistanceFrame_OnEnter() -- Checked by Flisher 2005-05-31 |
||
1818 | ShowUIPanel(GameTooltip); |
||
1819 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1820 | GameTooltip:SetText(TEXT(getglobal("RESISTANCE"..this:GetID().."_NAME"))); |
||
1821 | end |
||
1822 | |||
1823 | function CharactersViewerDropDown_OnEnter() -- Checked by Flisher 2005-05-31 |
||
1824 | ShowUIPanel(GameTooltip); |
||
1825 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1826 | GameTooltip:SetText(CHARACTERSVIEWER_TOOLTIP_DROPDOWN2); |
||
1827 | end |
||
1828 | |||
1829 | function CharactersViewer_Show() |
||
1830 | CharactersViewer.Hide(); |
||
1831 | local temp; |
||
1832 | if(CharactersViewer.index == UnitName("player")) then |
||
1833 | CharactersViewer.collect.all(); |
||
1834 | end |
||
1835 | |||
1836 | -- Character Name and location |
||
1837 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]) then |
||
1838 | |||
1839 | -- "Name (Zone / SubZone)" |
||
1840 | temp = CharactersViewer.index; |
||
1841 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Location"] ~= nil |
||
1842 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Location"]["Zone"] ~= nil |
||
1843 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Location"]["SubZone"] ~= nil ) then |
||
1844 | temp = temp .. " (" .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Location"]["Zone"] .. " - " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Location"]["SubZone"] .. ")"; |
||
1845 | end |
||
1846 | CharactersViewer_FrameTopText1:SetText(temp); |
||
1847 | |||
1848 | -- Character Honor Rank, Level, Race and Class |
||
1849 | temp = ""; |
||
1850 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"] ~= nil |
||
1851 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["Level"] ~= nil |
||
1852 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["Class"] ~= nil ) then |
||
1853 | temp = temp .. "Level " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["Level"] .. " " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["Class"]; |
||
1854 | end |
||
1855 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Honor"] ~= nil |
||
1856 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Honor"]["rankNumber"] ~= nil |
||
1857 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Honor"]["rankName"] ~= nil) then |
||
1858 | temp = temp .. " (Rank " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Honor"]["rankNumber"] .. ", " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Honor"]["rankName"] .. ")"; |
||
1859 | end |
||
1860 | CharactersViewer_FrameTopText2:SetText(temp); |
||
1861 | |||
1862 | -- Guild Rank and Name display initialisation |
||
1863 | temp = ""; |
||
1864 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Guild"] |
||
1865 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Guild"]["GuildName"] |
||
1866 | and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Guild"]["Title"] ) then |
||
1867 | temp = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Guild"]["Title"] .. " of " .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Guild"]["GuildName"]; |
||
1868 | end |
||
1869 | CharactersViewer_FrameTopText3:SetText(temp); |
||
1870 | |||
1871 | -- Characters stats (str agi spirit intel stam...) |
||
1872 | temp = { "", "", "", "", ""}; |
||
1873 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Stats"]) then |
||
1874 | for index = 1, 5 do |
||
1875 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Stats"][index]) then |
||
1876 | local j = 0, stat, effectiveStat, posBuff, negBuff; |
||
1877 | for w in string.gfind(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Stats"][index], "%d+") do |
||
1878 | j = j + 1; |
||
1879 | if(j == 1) then stat = w; |
||
1880 | elseif(j == 2) then effectiveStat = w; |
||
1881 | elseif(j == 3) then posBuff = w; |
||
1882 | elseif(j == 4) then negBuff = w; |
||
1883 | |||
1884 | end |
||
1885 | end |
||
1886 | end |
||
1887 | temp[index] = effectiveStat; |
||
1888 | end |
||
1889 | end |
||
1890 | for index = 1, 5 do |
||
1891 | getglobal("CharactersViewer_FrameStatsTitle"..index):SetText(TEXT(getglobal("SPELL_STAT"..(index-1).."_NAME"))..":"); |
||
1892 | getglobal("CharactersViewer_FrameStatsText"..index):SetText(temp[index]); |
||
1893 | end |
||
1894 | |||
1895 | |||
1896 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]) then |
||
1897 | -- Initialise the armor display |
||
1898 | temp = ""; |
||
1899 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Armor"]) then |
||
1900 | local j =0, stat, effectiveStat, posBuff, negBuff; |
||
1901 | for w in string.gfind(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Armor"], "%d+") do |
||
1902 | j = j + 1; |
||
1903 | if(j == 1) then stat = w; |
||
1904 | elseif(j == 2) then effectiveStat = w; |
||
1905 | elseif(j == 3) then posBuff = w; |
||
1906 | elseif(j == 4) then negBuff = w; |
||
1907 | end |
||
1908 | temp = effectiveStat; |
||
1909 | end |
||
1910 | end |
||
1911 | CharactersViewer_FrameStatsTitle6:SetText(ARMOR_COLON); |
||
1912 | CharactersViewer_FrameStatsText6:SetText(temp); |
||
1913 | |||
1914 | -- Initialise the Health display |
||
1915 | temp = ""; |
||
1916 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Health"]) then |
||
1917 | temp = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Health"]; |
||
1918 | end |
||
1919 | CharactersViewer_FrameDetailTitle1:SetText(HEALTH_COLON); |
||
1920 | CharactersViewer_FrameDetailText1:SetText(temp); |
||
1921 | |||
1922 | -- Initialise the mana display |
||
1923 | temp = ""; |
||
1924 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Mana"]) then |
||
1925 | temp = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Basic"]["Mana"]; |
||
1926 | end |
||
1927 | CharactersViewer_FrameDetailTitle2:SetText(MANA_COLON); |
||
1928 | CharactersViewer_FrameDetailText2:SetText(temp); |
||
1929 | end |
||
1930 | |||
1931 | |||
1932 | -- Initialize the combats stats (crit, parry, dodge, block...) |
||
1933 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]) then |
||
1934 | temp = ""; |
||
1935 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["C"] ) then |
||
1936 | temp = string.format("%01.2f%%", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["C"] ); |
||
1937 | end |
||
1938 | CharactersViewer_FrameDetailTitle3:SetText(CHARACTERSVIEWER_CRIT ..":"); |
||
1939 | CharactersViewer_FrameDetailText3:SetText(temp); |
||
1940 | |||
1941 | temp = ""; |
||
1942 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["D"] ) then |
||
1943 | temp = string.format("%01.2f%%", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["D"] ); |
||
1944 | end |
||
1945 | CharactersViewer_FrameDetailTitle4:SetText(DODGE ..":"); |
||
1946 | CharactersViewer_FrameDetailText4:SetText(temp); |
||
1947 | |||
1948 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["B"] ) then |
||
1949 | CharactersViewer_FrameDetailTitle5:SetText(BLOCK ..":"); |
||
1950 | CharactersViewer_FrameDetailText5:SetText( string.format("%01.2f%%", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["B"] )); |
||
1951 | end |
||
1952 | CharactersViewer_FrameDetailTitle5:SetText(""); |
||
1953 | CharactersViewer_FrameDetailText5:SetText(""); |
||
1954 | |||
1955 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["P"] ) then |
||
1956 | CharactersViewer_FrameDetailTitle6:SetText(PARRY ..":"); |
||
1957 | CharactersViewer_FrameDetailText6:SetText( string.format("%01.2f%%", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["CombatStats"]["P"] )); |
||
1958 | else |
||
1959 | CharactersViewer_FrameDetailTitle6:SetText(""); |
||
1960 | CharactersViewer_FrameDetailText6:SetText(""); |
||
1961 | end |
||
1962 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"] ) then |
||
1963 | temp = CharactersViewer.library.CalcRestedXP( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"] ); |
||
1964 | if( temp and temp.levelratio ~= nil) then |
||
1965 | temp = temp.levelratio .. " " .. LEVEL .. " " .. CHARACTERSVIEWER_RESTED; |
||
1966 | else |
||
1967 | temp = ""; |
||
1968 | end |
||
1969 | CharactersViewer_FrameDetailTitle7:SetText(XP .. ":"); |
||
1970 | CharactersViewer_FrameDetailText7:SetText(temp); |
||
1971 | |||
1972 | temp = ""; |
||
1973 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"]["current"] ) then |
||
1974 | temp = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"]["current"]; |
||
1975 | else |
||
1976 | temp = "??"; |
||
1977 | end |
||
1978 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"]["max"] ) then |
||
1979 | temp = temp .. "/" .. CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"]["max"]; |
||
1980 | else |
||
1981 | temp = temp .. "/??"; |
||
1982 | end |
||
1983 | CharactersViewer_FrameDetailTitle8:SetText(""); |
||
1984 | CharactersViewer_FrameDetailText8:SetText(temp); |
||
1985 | |||
1986 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["xp"]["resting"] ) then |
||
1987 | CharactersViewer_RestedFrame:Show(); |
||
1988 | else |
||
1989 | CharactersViewer_RestedFrame:Hide(); |
||
1990 | end |
||
1991 | end |
||
1992 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Timestamp"] ~= nil) then |
||
1993 | CharactersViewer_FrameDetailTitle0:SetText(CHARACTERSVIEWER_SAVEDON); |
||
1994 | CharactersViewer_FrameDetailText0:SetText( date(nil, CharactersViewerProfile[Server][CharactersViewer.index]["Timestamp"]) ); |
||
1995 | end |
||
1996 | else |
||
1997 | CharactersViewer_FrameDetailTitle3:SetText(""); |
||
1998 | CharactersViewer_FrameDetailText3:SetText(""); |
||
1999 | CharactersViewer_FrameDetailTitle4:SetText(""); |
||
2000 | CharactersViewer_FrameDetailText4:SetText(""); |
||
2001 | CharactersViewer_FrameDetailTitle5:SetText(""); |
||
2002 | CharactersViewer_FrameDetailText5:SetText(""); |
||
2003 | CharactersViewer_FrameDetailTitle6:SetText(""); |
||
2004 | CharactersViewer_FrameDetailText6:SetText(""); |
||
2005 | CharactersViewer_FrameDetailTitle7:SetText(""); |
||
2006 | CharactersViewer_FrameDetailText7:SetText(""); |
||
2007 | CharactersViewer_FrameDetailTitle8:SetText(""); |
||
2008 | CharactersViewer_FrameDetailText8:SetText(""); |
||
2009 | CharactersViewer_FrameDetailTitle0:SetText(""); |
||
2010 | CharactersViewer_FrameDetailText0:SetText(""); |
||
2011 | CharactersViewer_RestedFrame:Hide(); |
||
2012 | CharactersViewer_MailFrame:Hide(); |
||
2013 | CharactersViewer_MoneyFrame:Hide(); |
||
2014 | end |
||
2015 | |||
2016 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Resists"]) then |
||
2017 | -- Initialise the various resistance display |
||
2018 | for index = 2, 6 do |
||
2019 | temp = ""; |
||
2020 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Resists"][index] ) then |
||
2021 | temp = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Resists"][index]; |
||
2022 | end |
||
2023 | getglobal("CharactersViewerMagicResText"..index):SetText(temp); |
||
2024 | end |
||
2025 | else |
||
2026 | for index = 2, 6 do |
||
2027 | getglobal("CharactersViewerMagicResText"..index):SetText("x"); |
||
2028 | end |
||
2029 | end |
||
2030 | |||
2031 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Money"]) then |
||
2032 | MoneyFrame_Update("CharactersViewer_MoneyFrame", CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Money"]); |
||
2033 | else |
||
2034 | MoneyFrame_Update("CharactersViewer_MoneyFrame", 0 ); |
||
2035 | CharactersViewer_MoneyFrame:Hide(); |
||
2036 | end |
||
2037 | |||
2038 | if(MailTo_InFrame and MailTo_Mail and MailTo_Mail[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Type"] == "Self") then |
||
2039 | --if Inbox is already open, switch inbox to the current character |
||
2040 | if(MailTo_InFrame:IsVisible() ) then |
||
2041 | MailTo_inbox(CharactersViewer.index); |
||
2042 | end |
||
2043 | |||
2044 | -- Count current know mail in the inbox |
||
2045 | local count = 0; |
||
2046 | for anything in MailTo_Mail[Server][CharactersViewer.index] do |
||
2047 | count = count + 1; |
||
2048 | end |
||
2049 | |||
2050 | -- If there is 1 or more mail in inbox, or if mailflag is true, then display the icon with knwon mail. |
||
2051 | if( count > 1 or (CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Mail"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Mail"]["HasNewMail"])) then |
||
2052 | SetItemButtonCount(getglobal("CharactersViewer_MailFrame"), count); |
||
2053 | CharactersViewer_MailFrame:Show(); |
||
2054 | else |
||
2055 | CharactersViewer_MailFrame:Hide(); |
||
2056 | end |
||
2057 | elseif( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Mail"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Mail"]["HasNewMail"]) then |
||
2058 | SetItemButtonCount(getglobal("CharactersViewer_MailFrame"), 0); |
||
2059 | CharactersViewer_MailFrame:Show(); |
||
2060 | else |
||
2061 | CharactersViewer_MailFrame:Hide(); |
||
2062 | end |
||
2063 | end |
||
2064 | |||
2065 | local index, item, button, texture; |
||
2066 | for index = 1, 19 do |
||
2067 | button = getglobal("CharactersViewer_FrameItem"..index); |
||
2068 | texture = getglobal("CharactersViewer_FrameItem"..index.."IconTexture"); |
||
2069 | texture2 = CharactersViewer.constant.inventorySlot.Texture[index]; |
||
2070 | texture:SetTexture(texture2); |
||
2071 | SetItemButtonCount(button, 0); |
||
2072 | end |
||
2073 | for index, item in CharactersViewerProfile[Server][CharactersViewer.index]["Equipment"] do |
||
2074 | button = getglobal("CharactersViewer_FrameItem"..index); |
||
2075 | texture = getglobal("CharactersViewer_FrameItem"..index.."IconTexture"); |
||
2076 | texture:SetTexture(item.T); |
||
2077 | SetItemButtonCount(button, item.C); |
||
2078 | end |
||
2079 | |||
2080 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["SexId"] and CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["RaceEn"]) then |
||
2081 | local temprace, tempsex; |
||
2082 | if(CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["RaceEn"] == "Night Elf") then |
||
2083 | temprace = "NightElf"; |
||
2084 | else |
||
2085 | temprace = CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["RaceEn"]; |
||
2086 | end |
||
2087 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Data"]["Id"]["SexId"] == 0) then |
||
2088 | tempsex = "Male"; |
||
2089 | else |
||
2090 | tempsex = "Female"; |
||
2091 | end |
||
2092 | temp = "Interface\\CharacterFrame\\TemporaryPortrait-" .. tempsex .. "-" .. temprace; |
||
2093 | else |
||
2094 | temp = "Interface\\CharacterFrame\\TempPortrait"; |
||
2095 | end |
||
2096 | CharactersViewer_PortraitTexure:SetTexture(temp); |
||
2097 | |||
2098 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bag"] ) then |
||
2099 | CharactersViewer_Bag_Toggle_Button:Enable(); |
||
2100 | else |
||
2101 | CharactersViewer_Bag_Toggle_Button:Disable(); |
||
2102 | end |
||
2103 | |||
2104 | if( CharactersViewerProfile and CharactersViewerProfile[Server] and CharactersViewerProfile[Server][CharactersViewer.index] and CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] ) then |
||
2105 | CharactersViewer_BankToggle:Show(); |
||
2106 | if( CharactersViewerConfig["Bank_Display"] ) then |
||
2107 | CharactersViewer.Bank.Show(); |
||
2108 | else |
||
2109 | CharactersViewer.Bank.Close(); |
||
2110 | end |
||
2111 | else |
||
2112 | CharactersViewer_BankToggle:Hide(); |
||
2113 | CharactersViewer.Bank.Close(); |
||
2114 | end |
||
2115 | ShowUIPanel(CharactersViewer_Frame); |
||
2116 | |||
2117 | -- bag |
||
2118 | if( not CharactersViewer_ContainerFrame0:IsUserPlaced() |
||
2119 | and not CharactersViewer_ContainerFrame1:IsUserPlaced() |
||
2120 | and not CharactersViewer_ContainerFrame2:IsUserPlaced() |
||
2121 | and not CharactersViewer_ContainerFrame3:IsUserPlaced() |
||
2122 | and not CharactersViewer_ContainerFrame4:IsUserPlaced() |
||
2123 | and not CharactersViewer_KeyringContainerFrame:IsUserPlaced()) then |
||
2124 | CharactersViewer.Bag.Relocate(false) |
||
2125 | end |
||
2126 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bag"] ) then |
||
2127 | if(CharactersViewerConfig["Bag_Display"] == true) then |
||
2128 | CharactersViewer.Bag.Display(); |
||
2129 | else |
||
2130 | CharactersViewer.Bag.Hide(); |
||
2131 | end |
||
2132 | else |
||
2133 | CharactersViewer.Bag.Hide(); |
||
2134 | end |
||
2135 | |||
2136 | if( CharactersViewerProfile[Server][CharactersViewer.index]["Bank"] ) then |
||
2137 | if(CharactersViewerConfig["BankBag_Display"] == true ) then |
||
2138 | CharactersViewer.Bank.BagDisplay(); |
||
2139 | else |
||
2140 | CharactersViewer.Bank.BagHide(); |
||
2141 | end |
||
2142 | else |
||
2143 | CharactersViewer.Bank.BagHide(); |
||
2144 | end |
||
2145 | |||
2146 | end |
||
2147 | |||
2148 | function CharactersViewerDropDown_OnLoad() -- Checked by Flisher 2005-05-31 |
||
2149 | --! enable/disable checkup on this |
||
2150 | UIDropDownMenu_Initialize(this, CharactersViewerDropDown_Initialize); |
||
2151 | UIDropDownMenu_SetText(CHARACTERSVIEWER_SELPLAYER, this); |
||
2152 | UIDropDownMenu_SetWidth(80, this); |
||
2153 | end |
||
2154 | |||
2155 | function CharactersViewerDropDown_OnClick() |
||
2156 | CharactersViewer.Switch(this.value); |
||
2157 | CharactersViewer_Show(); |
||
2158 | |||
2159 | end |
||
2160 | |||
2161 | function CharactersViewerDropDown_Initialize() |
||
2162 | local info = {}; |
||
2163 | for index, item in CharactersViewerProfile[Server] do |
||
2164 | if(CharactersViewerProfile[Server][index]["Type"] == "Self") then |
||
2165 | local realm, player; |
||
2166 | info.text = index; |
||
2167 | info.value = index; |
||
2168 | info.func = CharactersViewerDropDown_OnClick; |
||
2169 | info.notCheckable = nil; |
||
2170 | info.keepShownOnClick = nil; |
||
2171 | UIDropDownMenu_AddButton(info); |
||
2172 | end |
||
2173 | end; |
||
2174 | end |
||
2175 | |||
2176 | function CharactersViewer_PaperDoll_Dropdown2_Toggle() |
||
2177 | --! enable button on/off |
||
2178 | local count = 0; |
||
2179 | for anything in CharactersViewerProfile[Server] do |
||
2180 | count = count + 1; |
||
2181 | end |
||
2182 | if( count > 1 ) then |
||
2183 | getglobal("CharactersViewerDropDown2"):Show(); |
||
2184 | getglobal("CharactersViewerDropDown3"):Show(); |
||
2185 | else |
||
2186 | getglobal("CharactersViewerDropDown2"):Hide(); |
||
2187 | getglobal("CharactersViewerDropDown3"):Hide(); |
||
2188 | end |
||
2189 | end |
||
2190 | |||
2191 | -- Backward / inter-addons compatibility |
||
2192 | |||
2193 | -- Called By EquipCompare, soon to be removed, modified to fit with my new code - Flisher 2005-05-16 |
||
2194 | |||
2195 | function CharactersViewerGetBSIIndex(forceRecreate) |
||
2196 | if(forceRecreate or not CharactersViewerCurrentIndex) then |
||
2197 | CharactersViewer.Switch(); |
||
2198 | end |
||
2199 | return CharactersViewer.index ; -- same as returning CharactersViewerCurrentIndex |
||
2200 | end |
||
2201 | |||
2202 | |||
2203 | -- this one is also for Equipcompare interoperability: |
||
2204 | CHARACTERSVIEWER_VERSION = CharactersViewer.version.number; |
||
2205 | CharactersViewerCurrentIndex = nil -- Not local so someone can hook to it |
||
2206 | |||
2207 | function CharactersViewer_Toggle() -- Changed by Flisher 2005-06-12 |
||
2208 | CharactersViewer.Toggle(); |
||
2209 | end |
||
2210 | |||
2211 | local function Used(bag,nr) |
||
2212 | used = 0; |
||
2213 | for i = 1,nr do |
||
2214 | if(bag[i] and bag[i].L) then used = used+1; end |
||
2215 | end |
||
2216 | return used |
||
2217 | end |
||
2218 | |||
2219 | function CharactersViewer_Bags(arg) |
||
2220 | if(not CharactersViewerProfile) then return; end |
||
2221 | local CV = CharactersViewerProfile[Server] |
||
2222 | if(not CV) then return; end |
||
2223 | local use = arg=='use' |
||
2224 | print(CHARACTERSVIEWER_BAG_USE..Server) |
||
2225 | local text,list,total,bag,tused,used |
||
2226 | for name,data in CV do |
||
2227 | if(data.Type=='Self') then |
||
2228 | list,total,tused = '',0,0 |
||
2229 | for ix,bag in data.Bag do |
||
2230 | if(list~='') then list = list..'+'; end |
||
2231 | if(use) then |
||
2232 | used = Used(bag,bag.size) |
||
2233 | list = list..used..'/' |
||
2234 | tused = tused+used |
||
2235 | end |
||
2236 | list = list..bag.size |
||
2237 | total = total+bag.size |
||
2238 | end |
||
2239 | tused = use and tused..'/' or '' |
||
2240 | text = format("%s: %s=%s%d",name,list,tused,total) |
||
2241 | list,total,tused = '24',24,0; |
||
2242 | if(data.Bank) then |
||
2243 | if(use) then |
||
2244 | used = Used(data.Bank.Main,24) |
||
2245 | list = used..'/24' |
||
2246 | tused = used |
||
2247 | end |
||
2248 | for ix,bag in data.Bank do |
||
2249 | if type(bag)=='table' then |
||
2250 | if(ix~='Main') then |
||
2251 | if(use) then |
||
2252 | used = Used(bag,bag.size) |
||
2253 | list = format("%s+%d/%d",list,used,bag.size) |
||
2254 | tused = tused+used |
||
2255 | else list = list..'+'..bag.size; end |
||
2256 | total = total+bag.size |
||
2257 | end |
||
2258 | end |
||
2259 | end |
||
2260 | tused = use and tused..'/' or '' |
||
2261 | text = format("%s, Bank: %s=%s%d",text,list,tused,total) |
||
2262 | end |
||
2263 | print(text) |
||
2264 | end |
||
2265 | end |
||
2266 | end |