vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Global Stuff |
2 | local InspectorMode = "Character"; |
||
3 | local RotationMode = "None"; |
||
4 | local ModelRotation = 0; |
||
5 | local RotationAmount = 0.2; |
||
6 | local FrameRateRotationModifier = 10/3; |
||
7 | |||
8 | local WaitingForHonor = 0; |
||
9 | local InHonorRange = 0; |
||
10 | local timePassed = 0; |
||
11 | local timeUpdateOK = 1; |
||
12 | local timePassedTotal = 0; |
||
13 | local honorRequestTimeout = 3; |
||
14 | local honorRequested = 0; |
||
15 | |||
16 | local mouseIsOverButton = 0; |
||
17 | local keyTimer = 0; |
||
18 | local keyTimerMax = 20; |
||
19 | local version = "Inspector v0.9"; |
||
20 | |||
21 | |||
22 | -- Binding info |
||
23 | BINDING_HEADER_INSPECTOR = "Inspector"; |
||
24 | BINDING_NAME_INSPECTOR_BINDING = "Inspect Target"; |
||
25 | |||
26 | |||
27 | -- Slash Commands |
||
28 | SLASH_INSPECTOR1 = "/in"; |
||
29 | SLASH_INSPECTOR_HELP1 = "/inspector"; |
||
30 | SlashCmdList["INSPECTOR"] = InspectorCommand; |
||
31 | SlashCmdList["INSPECTOR_HELP"] = InspectorHelp; |
||
32 | |||
33 | |||
34 | -- Holds all types of info on the slots |
||
35 | local InventorySlots = { |
||
36 | { name="InspectorHeadButton", slot="HeadSlot", item=nil, defaultTexture="Head", displayName="Head" }, |
||
37 | { name="InspectorNeckButton", slot="NeckSlot", item=nil, defaultTexture="Neck", displayName="Neck" }, |
||
38 | { name="InspectorShoulderButton", slot="ShoulderSlot", item=nil, defaultTexture="Shoulder", displayName="Shoulder" }, |
||
39 | { name="InspectorShirtButton", slot="ShirtSlot", item=nil, defaultTexture="Shirt", displayName="Shirt" }, |
||
40 | { name="InspectorChestButton", slot="ChestSlot", item=nil, defaultTexture="Chest", displayName="Chest" }, |
||
41 | { name="InspectorWaistButton", slot="WaistSlot", item=nil, defaultTexture="Waist", displayName="Waist" }, |
||
42 | { name="InspectorLegsButton", slot="LegsSlot", item=nil, defaultTexture="Legs", displayName="Legs" }, |
||
43 | { name="InspectorFeetButton", slot="FeetSlot", item=nil, defaultTexture="Feet", displayName="Feet" }, |
||
44 | { name="InspectorWristButton", slot="WristSlot", item=nil, defaultTexture="Wrists", displayName="Wrists" }, |
||
45 | { name="InspectorHandsButton", slot="HandsSlot", item=nil, defaultTexture="Hands", displayName="Hands" }, |
||
46 | { name="InspectorFinger1Button", slot="Finger0Slot", item=nil, defaultTexture="Finger", displayName="Finger" }, |
||
47 | { name="InspectorFinger2Button", slot="Finger1Slot", item=nil, defaultTexture="Finger", displayName="Finger" }, |
||
48 | { name="InspectorTrinket1Button", slot="Trinket0Slot", item=nil, defaultTexture="Trinket", displayName="Trinket" }, |
||
49 | { name="InspectorTrinket2Button", slot="Trinket1Slot", item=nil, defaultTexture="Trinket", displayName="Trinket" }, |
||
50 | { name="InspectorBackButton", slot="BackSlot", item=nil, defaultTexture="Chest", displayName="Back" }, |
||
51 | { name="InspectorMainHandButton", slot="MainHandSlot", item=nil, defaultTexture="MainHand", displayName="Main Hand" }, |
||
52 | { name="InspectorSecondaryHandButton", slot="SecondaryHandSlot",item=nil, defaultTexture="SecondaryHand", displayName="Off Hand" }, |
||
53 | { name="InspectorRangedButton", slot="RangedSlot", item=nil, defaultTexture="Ranged", displayName="Ranged" }, |
||
54 | { name="InspectorTabardButton", slot="TabardSlot", item=nil, defaultTexture="Tabard", displayName="Tabard" } |
||
55 | }; |
||
56 | |||
57 | |||
58 | |||
59 | |||
60 | ------------ InspectorFrame_OnLoad ------------- |
||
61 | -- What to do when the frame is loaded |
||
62 | ------------------------------------------------ |
||
63 | function InspectorFrame_OnLoad() |
||
64 | -- Make the frame pushable by other frames |
||
65 | UIPanelWindows["InspectorFrame"] = { area = "left", pushable = 5 }; |
||
66 | chatMessage( version.." Loaded!", 0.2, 0.6, 1.0 ); |
||
67 | chatMessage( "Type /inspector for info", 0.2, 0.6, 1.0 ); |
||
68 | |||
69 | -- Hide the honor stuff |
||
70 | InspectorHideHonor(); |
||
71 | end |
||
72 | |||
73 | |||
74 | |||
75 | ------------ InspectorFrameShow ------------- |
||
76 | -- Show the frame and play a sound |
||
77 | --------------------------------------------- |
||
78 | function InspectorFrameShow() |
||
79 | PlaySound("igCharacterInfoOpen"); |
||
80 | ShowUIPanel(InspectorFrame); |
||
81 | end |
||
82 | |||
83 | |||
84 | |||
85 | ------------ InspectorFrameHide ------------- |
||
86 | -- Hide the frame and play a sound |
||
87 | --------------------------------------------- |
||
88 | function InspectorFrameHide() |
||
89 | PlaySound("igCharacterInfoClose"); |
||
90 | HideUIPanel(InspectorFrame); |
||
91 | end |
||
92 | |||
93 | |||
94 | |||
95 | ------------ InspectorHideHonor ------------ |
||
96 | -- Hide all the honor stuff |
||
97 | -------------------------------------------- |
||
98 | function InspectorHideHonor() |
||
99 | InspectorMode = "Character"; |
||
100 | InspectorSwitchMode:SetText("Show Honor"); |
||
101 | InspectorPlayerPVPTodayText:Hide(); |
||
102 | InspectorPlayerPVPTodayHKText:Hide(); |
||
103 | InspectorPlayerPVPTodayHK:Hide(); |
||
104 | InspectorPlayerPVPTodayDKText:Hide(); |
||
105 | InspectorPlayerPVPTodayDK:Hide(); |
||
106 | InspectorPlayerPVPYesterdayText:Hide(); |
||
107 | InspectorPlayerPVPYesterdayHKText:Hide(); |
||
108 | InspectorPlayerPVPYesterdayHK:Hide(); |
||
109 | InspectorPlayerPVPYesterdayHonorText:Hide(); |
||
110 | InspectorPlayerPVPYesterdayHonor:Hide(); |
||
111 | InspectorPlayerPVPThisWeekText:Hide(); |
||
112 | InspectorPlayerPVPThisWeekHKText:Hide(); |
||
113 | InspectorPlayerPVPThisWeekHK:Hide(); |
||
114 | InspectorPlayerPVPThisWeekHonorText:Hide(); |
||
115 | InspectorPlayerPVPThisWeekHonor:Hide(); |
||
116 | InspectorPlayerPVPLastWeekText:Hide(); |
||
117 | InspectorPlayerPVPLastWeekHKText:Hide(); |
||
118 | InspectorPlayerPVPLastWeekHK:Hide(); |
||
119 | InspectorPlayerPVPLastWeekHonorText:Hide(); |
||
120 | InspectorPlayerPVPLastWeekHonor:Hide(); |
||
121 | InspectorPlayerPVPLastWeekStandingText:Hide(); |
||
122 | InspectorPlayerPVPLastWeekStanding:Hide(); |
||
123 | InspectorPlayerPVPLifetimeText:Hide(); |
||
124 | InspectorPlayerPVPLifetimeHKText:Hide(); |
||
125 | InspectorPlayerPVPLifetimeHK:Hide(); |
||
126 | InspectorPlayerPVPLifetimeDKText:Hide(); |
||
127 | InspectorPlayerPVPLifetimeDK:Hide(); |
||
128 | InspectorPlayerPVPLifetimeRankText:Hide(); |
||
129 | InspectorPlayerPVPLifetimeRank:Hide(); |
||
130 | InspectorPlayerPVPRangeText:Hide(); |
||
131 | end |
||
132 | |||
133 | |||
134 | |||
135 | ------------ InspectorShowHonor ------------ |
||
136 | -- Hide all the honor stuff |
||
137 | -------------------------------------------- |
||
138 | function InspectorShowHonor() |
||
139 | InspectorMode = "Honor"; |
||
140 | InspectorSwitchMode:SetText("Show Model"); |
||
141 | InspectorPlayerPVPTodayText:Show(); |
||
142 | InspectorPlayerPVPTodayHKText:Show(); |
||
143 | InspectorPlayerPVPTodayHK:Show(); |
||
144 | InspectorPlayerPVPTodayDKText:Show(); |
||
145 | InspectorPlayerPVPTodayDK:Show(); |
||
146 | InspectorPlayerPVPYesterdayText:Show(); |
||
147 | InspectorPlayerPVPYesterdayHKText:Show(); |
||
148 | InspectorPlayerPVPYesterdayHK:Show(); |
||
149 | InspectorPlayerPVPYesterdayHonorText:Show(); |
||
150 | InspectorPlayerPVPYesterdayHonor:Show(); |
||
151 | InspectorPlayerPVPThisWeekText:Show(); |
||
152 | InspectorPlayerPVPThisWeekHKText:Show(); |
||
153 | InspectorPlayerPVPThisWeekHK:Show(); |
||
154 | InspectorPlayerPVPThisWeekHonorText:Show(); |
||
155 | InspectorPlayerPVPThisWeekHonor:Show(); |
||
156 | InspectorPlayerPVPLastWeekText:Show(); |
||
157 | InspectorPlayerPVPLastWeekHKText:Show(); |
||
158 | InspectorPlayerPVPLastWeekHK:Show(); |
||
159 | InspectorPlayerPVPLastWeekHonorText:Show(); |
||
160 | InspectorPlayerPVPLastWeekHonor:Show(); |
||
161 | InspectorPlayerPVPLastWeekStandingText:Show(); |
||
162 | InspectorPlayerPVPLastWeekStanding:Show(); |
||
163 | InspectorPlayerPVPLifetimeText:Show(); |
||
164 | InspectorPlayerPVPLifetimeHKText:Show(); |
||
165 | InspectorPlayerPVPLifetimeHK:Show(); |
||
166 | InspectorPlayerPVPLifetimeDKText:Show(); |
||
167 | InspectorPlayerPVPLifetimeDK:Show(); |
||
168 | InspectorPlayerPVPLifetimeRankText:Show(); |
||
169 | InspectorPlayerPVPLifetimeRank:Show(); |
||
170 | InspectorPlayerPVPRangeText:Show(); |
||
171 | end |
||
172 | |||
173 | |||
174 | |||
175 | ------------ InspectorShowModel ------------- |
||
176 | -- Show the character's model |
||
177 | --------------------------------------------- |
||
178 | function InspectorShowModel() |
||
179 | InspectorPlayerModel:Show(); |
||
180 | InspectorModelRotationButtonRight:Show(); |
||
181 | InspectorModelRotationButtonLeft:Show(); |
||
182 | end |
||
183 | |||
184 | |||
185 | ------------ InspectorHideModel ------------- |
||
186 | -- Hide the character's model |
||
187 | --------------------------------------------- |
||
188 | function InspectorHideModel() |
||
189 | InspectorPlayerModel:Hide(); |
||
190 | InspectorModelRotationButtonRight:Hide(); |
||
191 | InspectorModelRotationButtonLeft:Hide(); |
||
192 | end |
||
193 | |||
194 | |||
195 | ------------ GetInspectorMode ------------ |
||
196 | -- Returns the current mode |
||
197 | ------------------------------------------ |
||
198 | function GetInspectorMode() |
||
199 | return InspectorMode; |
||
200 | end |
||
201 | |||
202 | |||
203 | |||
204 | ------------- GetModelRotation ------------ |
||
205 | -- Get the model's rotation |
||
206 | ------------------------------------------- |
||
207 | function GetModelRotation() |
||
208 | return ModelRotation; |
||
209 | end |
||
210 | |||
211 | |||
212 | |||
213 | ------------- SetRotationMode ------------- |
||
214 | -- Sets the rotation mode for the model |
||
215 | -- Values: None, Left, Right |
||
216 | ------------------------------------------- |
||
217 | function SetRotationMode( newMode ) |
||
218 | RotationMode = newMode; |
||
219 | end |
||
220 | |||
221 | |||
222 | ------------- SetModelRotation ------------ |
||
223 | -- Set the model's rotation |
||
224 | ------------------------------------------- |
||
225 | function SetModelRotation( newRot ) |
||
226 | ModelRotation = newRot; |
||
227 | |||
228 | -- Check for valid rotations (between zero and 2pi) |
||
229 | if( ModelRotation > (math.pi * 2) ) then |
||
230 | ModelRotation = ModelRotation - (math.pi * 2); |
||
231 | elseif( ModelRotation < 0.0 ) then |
||
232 | ModelRotation = ModelRotation + (math.pi * 2); |
||
233 | end |
||
234 | |||
235 | InspectorPlayerModel:SetRotation( ModelRotation ); |
||
236 | end |
||
237 | |||
238 | |||
239 | |||
240 | ------------- IncrementModelRotation ------------- |
||
241 | -- Increases the model's rotation value |
||
242 | -------------------------------------------------- |
||
243 | function IncrementModelRotation() |
||
244 | SetModelRotation( GetModelRotation() + RotationAmount ); |
||
245 | end |
||
246 | |||
247 | |||
248 | |||
249 | ------------- DecrementModelRotation ---------------- |
||
250 | -- Decreases the model's rotation value |
||
251 | ----------------------------------------------------- |
||
252 | function DecrementModelRotation() |
||
253 | SetModelRotation( GetModelRotation() - RotationAmount ); |
||
254 | end |
||
255 | |||
256 | |||
257 | |||
258 | |||
259 | ------------ InspectorCheckRotation -------------- |
||
260 | -- I was gonna do a "timer", but it looks much |
||
261 | -- better if you rotate every frame. So, just |
||
262 | -- check the mode and Do It Go! |
||
263 | -------------------------------------------------- |
||
264 | function InspectorCheckRotation() |
||
265 | |||
266 | -- Are we rotating? |
||
267 | if( RotationMode == "Left" ) then |
||
268 | -- Update the rotation speed |
||
269 | RotationAmount = ( 1/GetFramerate() ) * FrameRateRotationModifier; |
||
270 | DecrementModelRotation(); |
||
271 | elseif( RotationMode == "Right" ) then |
||
272 | RotationAmount = ( 1/GetFramerate() ) * FrameRateRotationModifier; |
||
273 | IncrementModelRotation(); |
||
274 | end |
||
275 | |||
276 | end |
||
277 | |||
278 | |||
279 | |||
280 | ------------ InspectorCheckCursor ------------- |
||
281 | -- Do we need to change the cursor (for the |
||
282 | -- dressing room stuff?) |
||
283 | ----------------------------------------------- |
||
284 | function InspectorCheckCursor( checkType ) |
||
285 | if( checkType == "Key" ) then |
||
286 | if( IsControlKeyDown() and mouseIsOverButton == 1 ) then |
||
287 | ShowInspectCursor(); |
||
288 | else |
||
289 | ResetCursor(); |
||
290 | end |
||
291 | elseif (checkType == "Mouse" ) then |
||
292 | mouseIsOverButton = 1; |
||
293 | if( IsControlKeyDown() ) then |
||
294 | ShowInspectCursor(); |
||
295 | else |
||
296 | ResetCursor(); |
||
297 | end |
||
298 | elseif ( checkType == "Off" ) then |
||
299 | mouseIsOverButton = 0; |
||
300 | ResetCursor(); |
||
301 | end |
||
302 | |||
303 | end |
||
304 | |||
305 | |||
306 | ------------ KeyTimerUpdate -------------- |
||
307 | -- I need this cause the OnKeyDown and |
||
308 | -- OnKeyUp events eat all my key presses |
||
309 | ------------------------------------------ |
||
310 | function KeyTimerUpdate() |
||
311 | |||
312 | keyTimer = keyTimer + 1; |
||
313 | |||
314 | -- Timer up? |
||
315 | if ( keyTimer >= keyTimerMax ) then |
||
316 | -- Yes! Reset and return true |
||
317 | keyTimer = 0; |
||
318 | return 1; |
||
319 | else |
||
320 | -- No, return false |
||
321 | return 0; |
||
322 | end |
||
323 | |||
324 | end |
||
325 | |||
326 | |||
327 | ----------- InspectorHelp ---------- |
||
328 | -- Show some help on the mod |
||
329 | ------------------------------------ |
||
330 | function InspectorHelp() |
||
331 | chatMessage(" ", 1.0, 1.0, 1.0); |
||
332 | chatMessage(version, 0.2, 0.6, 1.0 ); |
||
333 | chatMessage("/inspector - Show this message", 1.0, 1.0, 1.0); |
||
334 | chatMessage("/in - Inspect your current target", 1.0, 1.0, 1.0); |
||
335 | chatMessage("/in <target's name> - Tries to inspect the target you specify (or the closest match)", 1.0, 1.0, 1.0); |
||
336 | chatMessage("You can also bind a key ('i' for example) to inspect a target", 1.0, 1.0, 1.0); |
||
337 | chatMessage(" ", 1.0, 1.0, 1.0); |
||
338 | end |
||
339 | |||
340 | |||
341 | -------------- InspectorCommand --------------- |
||
342 | -- Process a slash command |
||
343 | ----------------------------------------------- |
||
344 | function InspectorCommand( msg ) |
||
345 | |||
346 | -- Check the contents of the slash command |
||
347 | if( msg == "" or msg == " " ) then |
||
348 | -- No target specified |
||
349 | InspectorCheckInspect(); |
||
350 | else |
||
351 | |||
352 | -- We (hopefully) have a target specified, try to target them |
||
353 | TargetByName( msg ); |
||
354 | InspectorCheckInspect(); |
||
355 | |||
356 | end |
||
357 | |||
358 | end |
||
359 | |||
360 | |||
361 | |||
362 | ------------- InspectorCheckInspect ------------- |
||
363 | -- Check to see if we can inspect, and if we can |
||
364 | -- then lets do it |
||
365 | ------------------------------------------------- |
||
366 | function InspectorCheckInspect() |
||
367 | |||
368 | -- Check to see if our target is valid |
||
369 | if( checkTarget() == 1 ) then |
||
370 | if( not InspectorFrame:IsVisible() ) then |
||
371 | |||
372 | -- GET the inspect info |
||
373 | InspectorInspect(); |
||
374 | |||
375 | -- SHOW the frame |
||
376 | InspectorFrameShow(); |
||
377 | |||
378 | else |
||
379 | |||
380 | -- HIDE the frame |
||
381 | InspectorFrameHide(); |
||
382 | |||
383 | end |
||
384 | end |
||
385 | |||
386 | end |
||
387 | |||
388 | |||
389 | |||
390 | ---------------- InspectorInspect -------------- |
||
391 | -- Actually inspect the target. Here we'll |
||
392 | -- get most of the info, aside from honor |
||
393 | -- stuff. That has to be requested from the |
||
394 | -- server once inside normal inspect range |
||
395 | ------------------------------------------------ |
||
396 | function InspectorInspect() |
||
397 | |||
398 | -- Set the model |
||
399 | InspectorPlayerModel:SetUnit("target"); |
||
400 | |||
401 | -- Reset the model's rotation |
||
402 | SetModelRotation( 0 ); |
||
403 | |||
404 | -- Set the portrait texture |
||
405 | SetPortraitTexture( InspectorPortraitTexture, "target" ); |
||
406 | |||
407 | -- Get the target's name and display it |
||
408 | targetName = UnitName("target"); |
||
409 | InspectorPlayerNameText:SetText( targetName ); |
||
410 | |||
411 | -- Get the info about the target |
||
412 | targetLevel = UnitLevel("target"); |
||
413 | targetRace = UnitRace("target"); |
||
414 | targetClass = UnitClass("target"); |
||
415 | InspectorPlayerInfoText:SetText( "Level "..targetLevel.." "..targetRace.." "..targetClass ); |
||
416 | |||
417 | -- Get guild info about the target |
||
418 | targetGuild, targetGuildRank = GetGuildInfo("target"); |
||
419 | if( targetGuild and targetGuildRank ) then |
||
420 | InspectorPlayerGuildText:SetText( targetGuildRank.." of "..targetGuild ); |
||
421 | else |
||
422 | InspectorPlayerGuildText:SetText( " " ); |
||
423 | end |
||
424 | |||
425 | |||
426 | -- Get the target's PvP Rank info |
||
427 | targetRankName, targetRank = GetPVPRankInfo( UnitPVPRank("target"), "target" ); |
||
428 | if( targetRank and targetRankName ) then |
||
429 | -- Set the text |
||
430 | InspectorPlayerPVPRankText:SetText( targetRankName.." (Rank "..targetRank..")" ); |
||
431 | |||
432 | -- Set the texture |
||
433 | InspectorPlayerPVPRankTexture:SetTexture(format("%s%02d", "Interface\\PvPRankBadges\\PvPRank", targetRank)); |
||
434 | else |
||
435 | InspectorPlayerPVPRankText:SetText( "No PvP Rank" ); |
||
436 | InspectorPlayerPVPRankTexture:SetTexture( "" ); |
||
437 | end |
||
438 | |||
439 | -- This part gets tricky, you need to be within inspect range to |
||
440 | -- get the target's honor info |
||
441 | |||
442 | WaitingForHonor = 1; |
||
443 | if( CheckInteractDistance("target",1) ) then |
||
444 | NotifyInspect("target"); |
||
445 | RequestInspectHonorData(); |
||
446 | InHonorRange = 1; |
||
447 | InspectorPlayerPVPRangeText:SetText("Requesting Honor Stats..."); |
||
448 | InspectorPlayerPVPRangeText:SetTextColor(1.0, 0.82, 0.0); |
||
449 | else |
||
450 | InHonorRange = 0; |
||
451 | InspectorPlayerPVPRangeText:SetText("Move Closer To See Honor Stats"); |
||
452 | InspectorPlayerPVPRangeText:SetTextColor(1.0, 0.0, 0.0); |
||
453 | end |
||
454 | |||
455 | |||
456 | -- Reset the honor info to default values |
||
457 | InspectorPlayerPVPTodayHK:SetText( "??" ); |
||
458 | InspectorPlayerPVPTodayDK:SetText( "??" ); |
||
459 | |||
460 | InspectorPlayerPVPYesterdayHK:SetText( "??" ); |
||
461 | InspectorPlayerPVPYesterdayHonor:SetText( "??" ); |
||
462 | |||
463 | InspectorPlayerPVPThisWeekHK:SetText( "??" ); |
||
464 | InspectorPlayerPVPThisWeekHonor:SetText( "??" ); |
||
465 | |||
466 | InspectorPlayerPVPLastWeekHK:SetText( "??" ); |
||
467 | InspectorPlayerPVPLastWeekHonor:SetText( "??" ); |
||
468 | InspectorPlayerPVPLastWeekStanding:SetText( "??" ); |
||
469 | |||
470 | InspectorPlayerPVPLifetimeHK:SetText( "??" ); |
||
471 | InspectorPlayerPVPLifetimeDK:SetText( "??" ); |
||
472 | InspectorPlayerPVPLifetimeRank:SetText( "??" ); |
||
473 | |||
474 | |||
475 | |||
476 | -- Go through all of the slots |
||
477 | for counter = 1, 19, 1 do |
||
478 | |||
479 | tempTexture = GetInventoryItemTexture( "target", counter ); |
||
480 | tempItem = GetInventoryItemLink( "target", counter ); |
||
481 | |||
482 | -- See if the item exists |
||
483 | if ( tempItem ) then |
||
484 | -- If it does, switch the display |
||
485 | |||
486 | getglobal(InventorySlots[counter].name):SetNormalTexture( tempTexture ); |
||
487 | getglobal(InventorySlots[counter].name):SetPushedTexture( tempTexture ); |
||
488 | |||
489 | -- Also, save the item info |
||
490 | InventorySlots[counter].item = tempItem; |
||
491 | |||
492 | else |
||
493 | -- No item, don't display |
||
494 | -- Clear the saved item info |
||
495 | InventorySlots[counter].item = nil; |
||
496 | |||
497 | getglobal(InventorySlots[counter].name):SetNormalTexture( "Interface\\PaperDoll\\UI-PaperDoll-Slot-"..InventorySlots[counter].defaultTexture ); |
||
498 | getglobal(InventorySlots[counter].name):SetPushedTexture( "Interface\\PaperDoll\\UI-PaperDoll-Slot-"..InventorySlots[counter].defaultTexture ); |
||
499 | |||
500 | end |
||
501 | |||
502 | end |
||
503 | |||
504 | |||
505 | end |
||
506 | |||
507 | |||
508 | |||
509 | |||
510 | |||
511 | |||
512 | ----------- InspectorCheckHonorStatus ------------- |
||
513 | -- This is called each "OnUpdate" to check the |
||
514 | -- status of the honor (if it was requested) |
||
515 | --------------------------------------------------- |
||
516 | function InspectorCheckHonorStatus( timeSinceLastUpdate ) |
||
517 | |||
518 | -- See how much time has passed |
||
519 | -- We're only doing honor stuff once a second |
||
520 | timePassed = timePassed + timeSinceLastUpdate; |
||
521 | |||
522 | -- If we're waiting for honor, see how much "total time" has passed |
||
523 | if( WaitingForHonor == 1 ) then |
||
524 | timePassedTotal = timePassedTotal + timeSinceLastUpdate; |
||
525 | else |
||
526 | timePassedTotal = 0; |
||
527 | end |
||
528 | |||
529 | -- Ok, it's been at least a second, check the honor |
||
530 | if( timePassed > timeUpdateOK ) then |
||
531 | |||
532 | -- Are we waiting for an honor update? |
||
533 | if( WaitingForHonor == 1 ) then |
||
534 | |||
535 | -- Not in honor range yet, so keep checking |
||
536 | if( CheckInteractDistance("target",1) ) then |
||
537 | -- If we're in range and need to request, request the data |
||
538 | if( honorRequested == 0 ) then |
||
539 | NotifyInspect("target"); |
||
540 | RequestInspectHonorData(); |
||
541 | honorRequested = 1; |
||
542 | end |
||
543 | InHonorRange = 1; |
||
544 | InspectorPlayerPVPRangeText:SetText("Requesting Honor Stats..."); |
||
545 | InspectorPlayerPVPRangeText:SetTextColor(1.0, 0.82, 0.0); |
||
546 | else |
||
547 | InHonorRange = 0; |
||
548 | InspectorPlayerPVPRangeText:SetText("Move Closer To See Honor Stats"); |
||
549 | InspectorPlayerPVPRangeText:SetTextColor(1.0, 0.0, 0.0); |
||
550 | end |
||
551 | |||
552 | -- Are we within range yet? |
||
553 | if( InHonorRange == 1 ) then |
||
554 | |||
555 | -- Check to see if we've gotten the honor info yet |
||
556 | if( HasInspectHonorData() ) then |
||
557 | |||
558 | -- We have the honor info, so lets go! |
||
559 | -- Get the target's overall PvP info |
||
560 | todayHK, todayDK, yesterdayHK, yesterdayHonor, thisweekHK, thisweekHonor, lastweekHK, lastweekHonor, lastweekStanding, lifetimeHK, lifetimeDK, lifetimeRank = GetInspectHonorData(); |
||
561 | |||
562 | InspectorPlayerPVPTodayHK:SetText( todayHK ); |
||
563 | InspectorPlayerPVPTodayDK:SetText( todayDK ); |
||
564 | |||
565 | InspectorPlayerPVPYesterdayHK:SetText( yesterdayHK ); |
||
566 | InspectorPlayerPVPYesterdayHonor:SetText( yesterdayHonor ); |
||
567 | |||
568 | InspectorPlayerPVPThisWeekHK:SetText( thisweekHK ); |
||
569 | InspectorPlayerPVPThisWeekHonor:SetText( thisweekHonor ); |
||
570 | |||
571 | InspectorPlayerPVPLastWeekHK:SetText( lastweekHK ); |
||
572 | InspectorPlayerPVPLastWeekHonor:SetText( lastweekHonor ); |
||
573 | InspectorPlayerPVPLastWeekStanding:SetText( lastweekStanding ); |
||
574 | |||
575 | InspectorPlayerPVPLifetimeHK:SetText( lifetimeHK ); |
||
576 | InspectorPlayerPVPLifetimeDK:SetText( lifetimeDK ); |
||
577 | rankName, rankNumber = GetPVPRankInfo(lifetimeRank); |
||
578 | if( rankName and rankNumber ) then |
||
579 | InspectorPlayerPVPLifetimeRank:SetText( rankName.." ("..rankNumber..")" ); |
||
580 | else |
||
581 | InspectorPlayerPVPLifetimeRank:SetText( "None" ); |
||
582 | end |
||
583 | |||
584 | -- We don't need to get the honor data again, |
||
585 | -- so set the waiting variable to 0 (false) |
||
586 | WaitingForHonor = 0; |
||
587 | honorRequested = 0; |
||
588 | InspectorPlayerPVPRangeText:SetText("Honor Stats Loaded"); |
||
589 | InspectorPlayerPVPRangeText:SetTextColor(0.0, 1.0, 0.0); |
||
590 | |||
591 | elseif( timePassedTotal > honorRequestTimeout ) then |
||
592 | -- Ok, it's taken too long to get the honor, |
||
593 | -- so lets try to request it again |
||
594 | NotifyInspect("player"); |
||
595 | NotifyInspect("target"); |
||
596 | RequestInspectHonorData(); |
||
597 | honorRequested = 1; |
||
598 | InspectorPlayerPVPRangeText:SetText("Re-Requesting Honor Stats..."); |
||
599 | InspectorPlayerPVPRangeText:SetTextColor(1.0, 0.82, 0.0); |
||
600 | |||
601 | timePassedTotal = 0; |
||
602 | |||
603 | end |
||
604 | |||
605 | end |
||
606 | end |
||
607 | |||
608 | -- Set the time back to zero (restart the timer basically) |
||
609 | timePassed = 0; |
||
610 | end |
||
611 | |||
612 | end |
||
613 | |||
614 | |||
615 | |||
616 | ------------- InspectorDisplayItemLink -------------- |
||
617 | -- Display the tooltip if the item we're hovering over |
||
618 | ----------------------------------------------------- |
||
619 | function InspectorDisplayItemLink() |
||
620 | |||
621 | -- Get the slot |
||
622 | whichSlot = this:GetID(); |
||
623 | |||
624 | -- Get the item |
||
625 | tempLink = InventorySlots[whichSlot].item; |
||
626 | |||
627 | -- If the item exists, show it |
||
628 | if( tempLink ) then |
||
629 | -- Parse the item |
||
630 | _,_,itemToShow = string.find(InventorySlots[whichSlot].item, "^.*|H(.*)%[.*%].*$"); |
||
631 | |||
632 | -- Show it |
||
633 | GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT"); |
||
634 | GameTooltip:SetHyperlink(itemToShow); |
||
635 | else |
||
636 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
637 | GameTooltip:SetText(InventorySlots[whichSlot].displayName); |
||
638 | end |
||
639 | |||
640 | end |
||
641 | |||
642 | |||
643 | ------------- InspectorChatLinkItem --------------- |
||
644 | -- We need to set up a way for the user to make a |
||
645 | -- chat link from our nifty buttons. As long as |
||
646 | -- all the requirements are met, we're all good |
||
647 | --------------------------------------------------- |
||
648 | function InspectorChatLinkItem( whichButton ) |
||
649 | |||
650 | -- Check to see if everything is correct (left button, holding shift while talking) |
||
651 | if( whichButton == "LeftButton" and IsShiftKeyDown() and ChatFrameEditBox:IsVisible() ) then |
||
652 | |||
653 | -- Slot and item |
||
654 | whichSlot = this:GetID(); |
||
655 | tempLink = InventorySlots[whichSlot].item; |
||
656 | |||
657 | -- Link has to exist |
||
658 | if( tempLink ) then |
||
659 | ChatFrameEditBox:Insert(tempLink); |
||
660 | end |
||
661 | |||
662 | elseif( whichButton == "LeftButton" and IsControlKeyDown() ) then |
||
663 | |||
664 | -- Slot and item |
||
665 | whichSlot = this:GetID(); |
||
666 | tempLink = InventorySlots[whichSlot].item; |
||
667 | |||
668 | -- Link has to exist |
||
669 | if( tempLink ) then |
||
670 | DressUpItemLink(tempLink); |
||
671 | end |
||
672 | |||
673 | end |
||
674 | |||
675 | end |
||
676 | |||
677 | |||
678 | |||
679 | ------------ checkEvents ------------ |
||
680 | -- Watch for events, and do what needs |
||
681 | -- to be done when an event is received |
||
682 | ------------------------------------- |
||
683 | function checkEvents( event ) |
||
684 | |||
685 | if( event == "PLAYER_TARGET_CHANGED" ) then |
||
686 | -- Check to see if the frame and/or the button needs to be closed |
||
687 | |||
688 | -- Frame check |
||
689 | if( checkTarget() == 1 and InspectorFrame:IsVisible() ) then |
||
690 | InspectorInspect(); |
||
691 | elseif( checkTarget() == 0 and UnitName("target") and InspectorFrame:IsVisible() ) then |
||
692 | InspectorFrameHide(); |
||
693 | end |
||
694 | |||
695 | |||
696 | -- See if we need to hide the button |
||
697 | if( checkTarget() == 1 ) then |
||
698 | -- SHOW |
||
699 | InspectorButtonFrame:Show(); |
||
700 | else |
||
701 | -- HIDE |
||
702 | InspectorButtonFrame:Hide(); |
||
703 | end |
||
704 | end |
||
705 | end |
||
706 | |||
707 | |||
708 | |||
709 | -------------- checkTarget ------------- |
||
710 | -- See if the target is valid |
||
711 | -- |
||
712 | -- A valid target is one that is a player |
||
713 | -- and is not ourself |
||
714 | ---------------------------------------- |
||
715 | function checkTarget() |
||
716 | if ( UnitIsPlayer('target') and (not UnitIsUnit("target","player")) ) then |
||
717 | return 1; |
||
718 | else |
||
719 | return 0; |
||
720 | end |
||
721 | end |
||
722 | |||
723 | |||
724 | |||
725 | ---------------- chatMessage --------------- |
||
726 | -- Sends a message to the default chat frame |
||
727 | -- |
||
728 | -- red, green, blue - the amount of each color |
||
729 | -- to use (0.0 - 1.0) |
||
730 | -------------------------------------------- |
||
731 | function chatMessage( message, red, green, blue ) |
||
732 | DEFAULT_CHAT_FRAME:AddMessage( message, red, green, blue ); |
||
733 | end |
||
734 | |||
735 | |||
736 | ---------------- frameMessage --------------- |
||
737 | -- Sends a message to the default chat frame |
||
738 | -- |
||
739 | -- red, green, blue, alpha - the amount of each color |
||
740 | -- to use (0.0 - 1.0) |
||
741 | -- fadeTime - how long until fade out |
||
742 | --------------------------------------------- |
||
743 | function frameMessage( message, red, green, blue, alpha, fadeTime ) |
||
744 | UIErrorsFrame:AddMessage( message, red, green, blue, alpha, fadeTime ); |
||
745 | end |
||
746 | |||
747 | |||
748 | ----------- trace ------------- |
||
749 | -- A simplified version of the |
||
750 | -- frameMessage function for |
||
751 | -- quick testing |
||
752 | ------------------------------- |
||
753 | function trace( message ) |
||
754 | UIErrorsFrame:AddMessage(message, 1.0, 0.0, 0.0, 1.0, 1.0 ); |
||
755 | end |
||
756 |