vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | SuperInspect_UI: --------- |
||
4 | copyright 2005-2006 by Chester |
||
5 | |||
6 | ]] |
||
7 | |||
8 | --what is with the inconsistant naming, bliz? |
||
9 | SI_BG = { |
||
10 | [1] = "Dwarf", |
||
11 | [2] = "Human", |
||
12 | [3] = "NightElf", |
||
13 | [4] = "Orc", |
||
14 | [5] = "Scourge", |
||
15 | [6] = "Tauren", |
||
16 | }; |
||
17 | |||
18 | SI_BG_Other = { |
||
19 | [1] = "DruidBalance", |
||
20 | [2] = "DruidFeralCombat", |
||
21 | [3] = "DruidRestoration", |
||
22 | [4] = "HunterBeastMastery", |
||
23 | [5] = "HunterMarksmanship", |
||
24 | [6] = "HunterSurvival", |
||
25 | [7] = "MageArcane", |
||
26 | [8] = "MageFire", |
||
27 | [9] = "MageFrost", |
||
28 | [10] = "PaladinCombat", |
||
29 | [11] = "PaladinHoly", |
||
30 | [12] = "PaladinProtection", |
||
31 | [13] = "PriestDiscipline", |
||
32 | [14] = "PriestHoly", |
||
33 | [15] = "PriestShadow", |
||
34 | [16] = "RogueAssassination", |
||
35 | [17] = "RogueCombat", |
||
36 | [18] = "RogueSubtlety", |
||
37 | [19] = "ShamanElementalCombat", |
||
38 | [20] = "ShamanEnhancement", |
||
39 | [21] = "ShamanRestoration", |
||
40 | [22] = "WarlockCurses", |
||
41 | [23] = "WarlockDestruction", |
||
42 | [24] = "WarlockSummoning", |
||
43 | }; |
||
44 | |||
45 | function SuperInspect_OnLoad() |
||
46 | this:RegisterEvent("UNIT_MODEL_CHANGED"); |
||
47 | this:RegisterEvent("PLAYER_TARGET_CHANGED"); |
||
48 | this:RegisterEvent("UNIT_PORTRAIT_UPDATE"); |
||
49 | this:RegisterEvent("UNIT_INVENTORY_CHANGED"); |
||
50 | |||
51 | SLASH_SUPERINSPECT1 = "/superinspect"; |
||
52 | SlashCmdList["SUPERINSPECT"] = function(msg) |
||
53 | SuperInspect_SlashCommand(msg); |
||
54 | end |
||
55 | |||
56 | end |
||
57 | |||
58 | |||
59 | function SuperInspect_OnEvent() |
||
60 | if( event == "UNIT_MODEL_CHANGED" or event == "UNIT_PORTRAIT_UPDATE") then |
||
61 | SI_AddMessage("|cffffd200UNIT_PORTRAIT_UPDATE"); |
||
62 | if (arg1 == "target" and SuperInspectFrame:IsVisible()) then |
||
63 | --SuperInspect_ModelFrame:SetUnit("target"); |
||
64 | SuperInspect_ModelFrame:RefreshUnit(); |
||
65 | SetPortraitTexture(SuperInspectFramePortrait, "target"); |
||
66 | end |
||
67 | end |
||
68 | if( event == "PLAYER_TARGET_CHANGED") then |
||
69 | --SI_AddMessage("|cffffd200PLAYER_TARGET_CHANGED"); |
||
70 | if (SuperInspectFrame:IsVisible() or SI_Save.targ) then |
||
71 | SuperInspect_UpdateModel("target"); |
||
72 | SI_AddMessage("--UPDATING"); |
||
73 | end |
||
74 | end |
||
75 | if ( event == "UNIT_INVENTORY_CHANGED" ) then |
||
76 | if ( arg1 == "target" ) then |
||
77 | SI_AddMessage( "changed" ) |
||
78 | SuperInspect.bonus = nil; |
||
79 | SuperInspect_InspectPaperDollFrame_OnShow(); |
||
80 | end |
||
81 | return; |
||
82 | end |
||
83 | end |
||
84 | |||
85 | function SuperInspect_Main_OnShow() |
||
86 | if (not SuperInspectFrame.uiScale) then |
||
87 | SuperInspectFrame.uiScale = SuperInspect_GetUIScale(); |
||
88 | end |
||
89 | if (not SI_Save.scale) then |
||
90 | SI_Save.scale = 0.75; |
||
91 | end |
||
92 | if (not SI_Save.default) then |
||
93 | SuperInspectFrame:SetScale(3); |
||
94 | SuperInspect_SetEffectiveScale(this, SI_Save.scale, "UIParent"); |
||
95 | --SuperInspect_ModelFrame:SetScale(SuperInspectFrame:GetEffectiveScale()); |
||
96 | end |
||
97 | if (SI_Save.snd) then |
||
98 | PlaySound("igCharacterInfoOpen"); |
||
99 | end |
||
100 | --SuperInspect_ModelFrame:RefreshUnit(); |
||
101 | end |
||
102 | |||
103 | function SuperInspect_InspectFrame_Show(unit) |
||
104 | if (not unit) then |
||
105 | unit = "target"; |
||
106 | end |
||
107 | SuperInspect.player = UnitIsPlayer(unit); |
||
108 | --SuperInspect.friend = UnitIsFriend(unit, "player"); |
||
109 | SuperInspect_InvFrame:Hide(); |
||
110 | if ( UnitExists(unit) and SuperInspect.player) then |
||
111 | NotifyInspect(unit); |
||
112 | SuperInspect_InvFrame.unit = unit; |
||
113 | SuperInspect_Button_ShowItems:Enable(); |
||
114 | SuperInspect_Button_ShowItems:Show(); |
||
115 | SuperInspect_Button_ShowItems.isDisabled = nil; |
||
116 | SuperInspect_Button_ShowHonor:Enable(); |
||
117 | SuperInspect_Button_ShowHonor:Show(); |
||
118 | SuperInspect_Button_ShowHonor.isVisible = 1; |
||
119 | SuperInspect_Button_ShowHonor.isDisabled = nil; |
||
120 | SuperInspect_Button_ShowBonuses:Show(); |
||
121 | SuperInspect_Button_ShowMobInfo:Hide(); |
||
122 | if (not SI_Save.items or SI_Save.items == 0) then |
||
123 | SuperInspect_InvFrame:Hide(); |
||
124 | --SI_AddMessage("HIDING INV: show items = nil"); |
||
125 | else |
||
126 | SuperInspect_InvFrame:Show(); |
||
127 | --SI_AddMessage("SHOW INV: show items = 1"); |
||
128 | end |
||
129 | --SuperInspect_ShowItems_CheckChecked( SuperInspect_Button_ShowItems ); |
||
130 | if (not SuperInspect_HonorFrame.isShowing) then |
||
131 | SuperInspect_HonorFrame:Hide(); |
||
132 | else |
||
133 | SuperInspect_HonorFrame:Show(); |
||
134 | end |
||
135 | if (CheckInteractDistance("target", 1) and SuperInspect_HonorFrame.isShowing) then |
||
136 | SuperInspect_HonorFrame:Hide(); |
||
137 | SuperInspect_HonorFrame:Show(); |
||
138 | else |
||
139 | SuperInspect_HonorFrame:Hide(); |
||
140 | end |
||
141 | else |
||
142 | SuperInspect_Button_ShowMobInfo:Hide(); |
||
143 | if (not SuperInspect.player) then |
||
144 | SI_MI2_BuildMobInfoTooltip( UnitName("target"), UnitLevel("target") ); |
||
145 | end |
||
146 | SuperInspect_HonorFrame:Hide(); |
||
147 | SuperInspect.honor = nil; |
||
148 | SuperInspect.bonus = nil; |
||
149 | SuperInspect_InvFrame:Hide(); |
||
150 | --SI_AddMessage("HIDING INV: no target"); |
||
151 | SuperInspect_ItemBonusesFrame:Hide(); |
||
152 | SuperInspect_Button_ShowItems:Disable(); |
||
153 | SuperInspect_Button_ShowItems.isDisabled = 1; |
||
154 | SuperInspect_Button_ShowItems:Hide(); |
||
155 | SuperInspect_Button_ShowItems.isVisible = nil; |
||
156 | SuperInspect_Button_ShowHonor:Disable(); |
||
157 | SuperInspect_Button_ShowHonor.isDisabled = 1; |
||
158 | SuperInspect_Button_ShowHonor:Hide(); |
||
159 | SuperInspect_Button_ShowHonor.isVisible = nil; |
||
160 | SuperInspect_Button_ShowBonuses:Hide(); |
||
161 | end |
||
162 | |||
163 | SuperInspect_SetDefaultStyleScale(); |
||
164 | end |
||
165 | |||
166 | --if the player has a target and the inspect frame is visible, check the player's distance to their target |
||
167 | --and disable the honor button if they are too far away |
||
168 | function SuperInspect_Main_OnUpdate() |
||
169 | if ( SuperInspect.isVisible and SuperInspect_Button_ShowHonor.isVisible ) then |
||
170 | if ( not CheckInteractDistance("target", 1) and not SuperInspect_HonorFrame.isShowing ) then--and not SuperInspect_HonorFrame.isShowing |
||
171 | if (SuperInspect.honor) then |
||
172 | return; |
||
173 | end |
||
174 | SuperInspect_Button_ShowHonor:Disable(); |
||
175 | SuperInspect_Button_ShowHonor.isDisabled = 1; |
||
176 | --/script SI_AddMessage(CheckInteractDistance("target", 1)); |
||
177 | |||
178 | else |
||
179 | SuperInspect_Button_ShowHonor:Enable(); |
||
180 | SuperInspect_Button_ShowHonor.isDisabled = nil; |
||
181 | end |
||
182 | end |
||
183 | end |
||
184 | |||
185 | function SuperInspect_InspectPaperDollItemSlotButton_OnLoad() |
||
186 | local slotName = string.gsub(this:GetName(), "SuperInspect_", ""); |
||
187 | local id; |
||
188 | local textureName; |
||
189 | id, textureName = GetInventorySlotInfo(strsub(slotName,8)); |
||
190 | this:SetID(id); |
||
191 | local texture = getglobal(this:GetName().."IconTexture"); |
||
192 | texture:SetTexture(textureName); |
||
193 | this.backgroundTextureName = textureName; |
||
194 | this:RegisterForDrag("LeftButton"); |
||
195 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp"); |
||
196 | --SI_AddMessage(id.." "..slotName.." "..textureName); |
||
197 | end |
||
198 | |||
199 | |||
200 | function SuperInspect_InspectPaperDollItemSlotButton_OnClick(button, ignoreModifiers) |
||
201 | local itemLink = this.link; |
||
202 | --DEFAULT_CHAT_FRAME:AddMessage(GetInventoryItemLink("target", this:GetID())); |
||
203 | --DEFAULT_CHAT_FRAME:AddMessage(this.link); |
||
204 | if (not itemLink and UnitExists("target")) then |
||
205 | itemLink = GetInventoryItemLink("target", this:GetID()); |
||
206 | end |
||
207 | if (not itemLink) then |
||
208 | return; |
||
209 | end |
||
210 | if ( button == "LeftButton" ) then |
||
211 | if ( IsControlKeyDown() and not ignoreModifiers ) then |
||
212 | DressUpItemLink(itemLink); |
||
213 | elseif ( IsShiftKeyDown() and not ignoreModifiers ) then |
||
214 | if ( ChatFrameEditBox:IsVisible() ) then |
||
215 | local link = "|c"..this.c.."|H"..itemLink.."|h["..GetItemInfo(itemLink).."]|h|r"; |
||
216 | ChatFrameEditBox:Insert(link); |
||
217 | end |
||
218 | elseif (UnitPVPName("player") == SuperInspectFrameHeader_Name:GetText()) then |
||
219 | PickupInventoryItem(this:GetID()); |
||
220 | end |
||
221 | elseif ( button == "RightButton" and UnitPVPName("player") == SuperInspectFrameHeader_Name:GetText()) then |
||
222 | UseInventoryItem(this:GetID()); |
||
223 | end |
||
224 | end |
||
225 | |||
226 | function SuperInspect_InspectPaperDollFrame_OnShow() |
||
227 | if (UnitExists("target")) then |
||
228 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectHeadSlot); |
||
229 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectNeckSlot); |
||
230 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectShoulderSlot); |
||
231 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectBackSlot); |
||
232 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectChestSlot); |
||
233 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectShirtSlot); |
||
234 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectTabardSlot); |
||
235 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectWristSlot); |
||
236 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectHandsSlot); |
||
237 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectWaistSlot); |
||
238 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectLegsSlot); |
||
239 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectFeetSlot); |
||
240 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectFinger0Slot); |
||
241 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectFinger1Slot); |
||
242 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectTrinket0Slot); |
||
243 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectTrinket1Slot); |
||
244 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectMainHandSlot); |
||
245 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectSecondaryHandSlot); |
||
246 | SuperInspect_InspectPaperDollItemSlotButton_Update(SuperInspect_InspectRangedSlot); |
||
247 | end |
||
248 | |||
249 | SuperInspect_Button_ShowItems:SetText(SI_ITEMSHIDE); |
||
250 | SuperInspect_Button_ShowBonuses:Enable(); |
||
251 | SI_Save.items = 1; |
||
252 | SuperInspectItemBonusesButton_BuildTooltip(); |
||
253 | end |
||
254 | |||
255 | function SuperInspect_InspectPaperDollItemSlotButton_Update(button) |
||
256 | local unit = SuperInspect_InvFrame.unit; |
||
257 | if (not button or not unit) then |
||
258 | return; |
||
259 | end |
||
260 | local textureName = GetInventoryItemTexture(unit, button:GetID()); |
||
261 | if ( textureName ) then |
||
262 | SetItemButtonTexture(button, textureName); |
||
263 | SetItemButtonCount(button, GetInventoryItemCount(unit, button:GetID())); |
||
264 | button.hasItem = 1; |
||
265 | else |
||
266 | SetItemButtonTexture(button, button.backgroundTextureName); |
||
267 | SetItemButtonCount(button, 0); |
||
268 | button.hasItem = nil; |
||
269 | end |
||
270 | --SI_AddMessage(id.." "..slotName.." "..textureName); |
||
271 | if ( GameTooltip:IsOwned(button) ) then |
||
272 | --SI_AddMessage("GTT IS OWNED"); |
||
273 | if ( texture ) then |
||
274 | --SI_AddMessage(texture); |
||
275 | if ( not GameTooltip:SetInventoryItem(SuperInspect_InvFrame.unit, button:GetID()) ) then |
||
276 | GameTooltip:SetText(TEXT(getglobal(strupper(strsub(button:GetName(), 8))))); |
||
277 | end |
||
278 | else |
||
279 | GameTooltip:Hide(); |
||
280 | end |
||
281 | end |
||
282 | if (UnitExists("target")) then |
||
283 | local line = getglobal("SuperInspect_TTTextLeft1"); |
||
284 | local r, g, b; |
||
285 | local bgBorder = getglobal(button:GetName().."BGTexture"); |
||
286 | local link = GetInventoryItemLink("target", button:GetID()); |
||
287 | if (link) then |
||
288 | --SI_AddMessage(link); |
||
289 | SuperInspect_TT:SetInventoryItem("target", button:GetID()); |
||
290 | r, g, b = line:GetTextColor() |
||
291 | bgBorder:SetVertexColor(r, g, b, 1); --r,g,b,a = FontString:GetTextColor() |
||
292 | bgBorder:Show(); |
||
293 | else |
||
294 | bgBorder:Hide(); |
||
295 | end |
||
296 | |||
297 | if (SI_Save.itembg) then |
||
298 | getglobal(button:GetName().."BGTexture"):SetTexture("Interface\\Addons\\SuperInspect\\gfx\\ItemOverlay_Tab"); |
||
299 | else |
||
300 | getglobal(button:GetName().."BGTexture"):SetTexture("Interface\\Addons\\SuperInspect\\gfx\\ItemOverlay"); |
||
301 | end |
||
302 | |||
303 | if (not SuperInspect.bonus or SuperInspect.bonus ~= UnitName("target")) then |
||
304 | if (not SuperInspectFrame.buts) then |
||
305 | SuperInspectFrame.buts = 0; |
||
306 | end |
||
307 | SuperInspectFrame.buts = SuperInspectFrame.buts + 1; |
||
308 | if (SuperInspectFrame.buts == 1) then |
||
309 | SuperInspect_ItemBonuses_bonuses = {}; |
||
310 | SuperInspect_ItemBonuses_currentset = ""; |
||
311 | SuperInspect_ItemBonuses_sets = {}; |
||
312 | SuperInspect_ItemBonuses_active = nil; |
||
313 | end |
||
314 | SI_AddMessage("|cffC0C0C0"..SuperInspectFrame.buts); |
||
315 | button.link = nil; |
||
316 | if (not link) then |
||
317 | if (SuperInspectFrame.buts == 19) then |
||
318 | --DEFAULT_CHAT_FRAME:AddMessage("OnShow"); |
||
319 | SuperInspectFrame.buts = nil; |
||
320 | SuperInspect.bonus = UnitName("target"); |
||
321 | SuperInspectItemBonusesButton_BuildTooltip(); |
||
322 | end |
||
323 | return; |
||
324 | end |
||
325 | --if (SI_Save.debug) then |
||
326 | -- if (not SI_Save["debugtext"]) then |
||
327 | -- SI_Save["debugtext"] = {}; |
||
328 | -- end |
||
329 | -- SI_Save["debugtext"]["link"] = link; |
||
330 | --end |
||
331 | |||
332 | --"|cffa335ee|Hitem:18282:2523:0:0|h[Core Marksman Rifle]|h|r" |
||
333 | for color, item in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[.-%]|h|r") do |
||
334 | if( item and item ~= "" ) then |
||
335 | button.link = "item:"..string.gsub(item, "^(%d+):(%d+):(%d+):(%d+)$", "%1:0:%3:%4"); |
||
336 | button.c = color; |
||
337 | end |
||
338 | end |
||
339 | |||
340 | --button.iteml = {}; |
||
341 | --button.itemr = {}; |
||
342 | local line, lineR, text; |
||
343 | local durtext = getglobal(button:GetName().."DurabilityNumber"); |
||
344 | durtext:Hide(); |
||
345 | for i=1, (SuperInspect_TT:NumLines()), 1 do |
||
346 | line = getglobal("SuperInspect_TTTextLeft"..i); |
||
347 | if (not line or not line:GetText()) then |
||
348 | durtext:Hide(); |
||
349 | return; |
||
350 | else |
||
351 | if (not SI_Save.durabilityoff) then |
||
352 | SuperInspect_GetItemDurability(button, line:GetText()); |
||
353 | end |
||
354 | SuperInspectItemBonuses_ScanLine(line:GetText(), button:GetID()); |
||
355 | end |
||
356 | end |
||
357 | --if (SuperInspect_ItemBonuses_sets and table.getn( SuperInspect_ItemBonuses_sets ) >= 1) then |
||
358 | |||
359 | --end |
||
360 | if (SuperInspectFrame.buts == 19) then |
||
361 | --DEFAULT_CHAT_FRAME:AddMessage("OnShow"); |
||
362 | SuperInspectFrame.buts = nil; |
||
363 | if (UnitName("target") ~= UnitName("player")) then |
||
364 | SuperInspectItemBonuses_GetSetBonuses(); |
||
365 | end |
||
366 | SuperInspect.bonus = UnitName("target"); |
||
367 | SuperInspectItemBonusesButton_BuildTooltip(); |
||
368 | end |
||
369 | end |
||
370 | end |
||
371 | end |
||
372 | |||
373 | function SuperInspect_BonusInfo_StartCompare() |
||
374 | |||
375 | SuperInspect_ItemBonusesNameCompare:SetText(SuperInspectFrameHeader_Name:GetText()); |
||
376 | SuperInspect_ItemBonusesGuildCompare:SetText(SuperInspectFrameHeader_Guild:GetText().."\n"..SuperInspectFrameHeader_Info:GetText()); |
||
377 | SuperInspect_ItemBonusesGuildCompare:SetTextColor(1, 1, 1); |
||
378 | |||
379 | --SuperInspectFrame_Name |
||
380 | --SuperInspectFrame_Guild |
||
381 | --SuperInspectFrame_Info |
||
382 | |||
383 | for i=1, 5, 1 do |
||
384 | local resTextorg = getglobal("SuperInspect_MagicResText"..i); |
||
385 | local resText = getglobal("SuperInspect_MagicResTextCompare"..i); |
||
386 | resText:Hide(); |
||
387 | if (resTextorg:IsVisible()) then |
||
388 | resText:SetText(resTextorg:GetText()); |
||
389 | resText:Show(); |
||
390 | end |
||
391 | end |
||
392 | SuperInspect_ItemBonusesTextCompare:SetText(SuperInspect_ItemBonusesText:GetText()); |
||
393 | SuperInspect_ItemBonusesTextRCompare:SetText(SuperInspect_ItemBonusesTextR:GetText()); |
||
394 | SuperInspect_ItemBonusesFrameCompare:Show(); |
||
395 | --local iHeight = SuperInspect_ItemBonusesTextCompare:GetHeight(); |
||
396 | SuperInspect_ItemBonusesFrameCompare:SetHeight(SuperInspect_ItemBonusesTextCompare:GetHeight() + 116); |
||
397 | end |
||
398 | |||
399 | function SuperInspect_GetItemDurability(button, line) |
||
400 | local text = getglobal(button:GetName().."DurabilityNumber"); |
||
401 | if (not UnitIsUnit("target", "player")) then |
||
402 | text:Hide(); |
||
403 | return; |
||
404 | end |
||
405 | |||
406 | if(string.sub(line,0,string.len(SI_DURABILITY)) == SI_DURABILITY) then |
||
407 | --SI_AddMessage(SI_DURABILITY); |
||
408 | button.d1, button.d2 = nil, nil; |
||
409 | _, _, button.d1, button.d2 = string.find(line, SI_DURABILITYPATTERN); |
||
410 | if (button.d1 and button.d2) then |
||
411 | --SI_AddMessage(button.d1.." / "..button.d2); |
||
412 | text:SetText(button.d1.."/"..button.d2); |
||
413 | local fraction = (button.d1 / button.d2); |
||
414 | if (fraction > 0.8) then |
||
415 | --text:SetTextColor( 1, 1, 1 ); |
||
416 | --text:SetText(""); |
||
417 | return; |
||
418 | elseif (fraction > 0.6) then |
||
419 | text:SetTextColor( 1, 1, 0.3 ); |
||
420 | --text:SetText("="); |
||
421 | elseif (fraction > 0.4) then |
||
422 | text:SetTextColor( 1, 0.6, 0 ); |
||
423 | --text:SetText("=="); |
||
424 | elseif (fraction > 0.2) then |
||
425 | text:SetTextColor( 1, 0.3, 0 ); |
||
426 | --text:SetText("==="); |
||
427 | else |
||
428 | text:SetTextColor( 1, 0, 0 ); |
||
429 | --text:SetText("===="); |
||
430 | end |
||
431 | text:Show(); |
||
432 | end |
||
433 | end |
||
434 | end |
||
435 | |||
436 | SuperInspect_ItemBonuses_bonuses = {}; |
||
437 | SuperInspect_ItemBonuses_currentset = ""; |
||
438 | SuperInspect_ItemBonuses_sets = {}; |
||
439 | SuperInspect_ItemBonuses_active = nil; |
||
440 | |||
441 | function SuperInspectItemBonuses_ScanLine(line, id) |
||
442 | local tmpStr, found; |
||
443 | |||
444 | --SI_AddMessage(line); |
||
445 | if (SuperInspect.name and SuperInspect.name == UnitName("player")) then |
||
446 | -- Check for "Set: " |
||
447 | if(string.sub(line,0,string.len(SI_IB_SET_PREFIX)) == SI_IB_SET_PREFIX and SuperInspect_ItemBonuses_currentset ~= "") then |
||
448 | local fnd = nil; |
||
449 | for i=1, table.getn( SuperInspect_ItemBonuses_sets ), 1 do |
||
450 | if (SuperInspect_ItemBonuses_sets[i].s == SuperInspect_ItemBonuses_currentset) then |
||
451 | if (SuperInspect_ItemBonuses_sets[i].n > 1) then |
||
452 | return; |
||
453 | end |
||
454 | end |
||
455 | end |
||
456 | tmpStr = string.sub(line,string.len(SI_IB_SET_PREFIX)+1); |
||
457 | SuperInspectItemBonuses_ScanPassive(tmpStr); |
||
458 | end |
||
459 | end |
||
460 | -- Check for "Equip: " |
||
461 | if(string.sub(line,0,string.len(SI_IB_EQUIP_PREFIX)) == SI_IB_EQUIP_PREFIX) then |
||
462 | |||
463 | tmpStr = string.sub(line,string.len(SI_IB_EQUIP_PREFIX)+1); |
||
464 | SI_AddMessage("equip? :"..tmpStr); |
||
465 | SuperInspectItemBonuses_ScanPassive(tmpStr); |
||
466 | |||
467 | -- Check for "Chance on Hit: " |
||
468 | --[[ |
||
469 | elseif(string.sub(line,0,string.len(SI_IB_COH_PREFIX)) == SI_IB_COH_PREFIX) then |
||
470 | |||
471 | tmpStr = string.sub(line,string.len(SI_IB_COH_PREFIX)+1); |
||
472 | SuperInspectItemBonuses_ScanPassive(tmpStr);]] |
||
473 | |||
474 | -- any other line (standard stats, enchantment, set name, etc.) |
||
475 | else |
||
476 | -- Check for set name |
||
477 | local max; |
||
478 | _, _, tmpStr, max = string.find(line, SI_IB_SETNAME_PATTERN); |
||
479 | if(tmpStr) then |
||
480 | SuperInspect_ItemBonuses_currentset = tmpStr; |
||
481 | if (SuperInspect_ItemBonuses_sets) then |
||
482 | local fnd = nil; |
||
483 | local j = 1; |
||
484 | for i=1, table.getn( SuperInspect_ItemBonuses_sets ), 1 do |
||
485 | if (SuperInspect_ItemBonuses_sets[i].s == tmpStr) then |
||
486 | SuperInspect_ItemBonuses_sets[i].n = SuperInspect_ItemBonuses_sets[i].n + 1; |
||
487 | fnd = 1; |
||
488 | return; |
||
489 | end |
||
490 | j = j + 1; |
||
491 | end |
||
492 | if (not fnd) then |
||
493 | tinsert(SuperInspect_ItemBonuses_sets, tmpStr); |
||
494 | SuperInspect_ItemBonuses_sets[j] = {}; |
||
495 | SuperInspect_ItemBonuses_sets[j].s = tmpStr; |
||
496 | SuperInspect_ItemBonuses_sets[j].n = 1; |
||
497 | SuperInspect_ItemBonuses_sets[j].m = max; |
||
498 | SuperInspect_ItemBonuses_sets[j].i = id; |
||
499 | end |
||
500 | else |
||
501 | --tinsert(SuperInspect_ItemBonuses_sets, tmpStr); |
||
502 | SuperInspect_ItemBonuses_sets[1] = {}; |
||
503 | SuperInspect_ItemBonuses_sets[1].s = tmpStr; |
||
504 | SuperInspect_ItemBonuses_sets[1].n = 1; |
||
505 | SuperInspect_ItemBonuses_sets[1].m = max; |
||
506 | SuperInspect_ItemBonuses_sets[1].i = id; |
||
507 | end |
||
508 | else |
||
509 | found = SuperInspectItemBonuses_ScanGeneric(line); |
||
510 | if(not found) then |
||
511 | SuperInspectItemBonuses_ScanOther(line); |
||
512 | end; |
||
513 | end |
||
514 | end |
||
515 | end |
||
516 | |||
517 | function SuperInspectItemBonuses_GetSetBonuses() |
||
518 | local id, cnum, nnum, tmpStr, line; |
||
519 | for i=1, table.getn( SuperInspect_ItemBonuses_sets ), 1 do |
||
520 | if (SuperInspect_ItemBonuses_sets[i].n > 1) then |
||
521 | id = SuperInspect_ItemBonuses_sets[i].i; |
||
522 | --cnum = SuperInspect_ItemBonuses_sets[i].n; |
||
523 | SuperInspect_TT:SetInventoryItem("target", id); |
||
524 | for j=2, (SuperInspect_ItemBonuses_sets[i].n), 1 do |
||
525 | for k=1, (SuperInspect_TT:NumLines()), 1 do |
||
526 | line = getglobal("SuperInspect_TTTextLeft"..k); |
||
527 | if (not line or not line:GetText()) then |
||
528 | else |
||
529 | if(string.find(line:GetText(), SI_IB_MULTISET_PREFIX)) then |
||
530 | _, _, nnum, tmpStr = string.find(line:GetText(), SI_IB_MULTISET_PREFIX.."(.*)"); |
||
531 | SI_AddMessage(RED_FONT_COLOR_CODE.."nnum = "..nnum.." cnum = "..j.." : "); |
||
532 | if (tmpStr and nnum and tonumber(nnum) == j) then |
||
533 | if (not SuperInspect_ItemBonuses_sets[i]["t"] or not SuperInspect_ItemBonuses_sets[i]["t"][nnum]) then |
||
534 | SuperInspectItemBonuses_ScanPassive(tmpStr); |
||
535 | if (not SuperInspect_ItemBonuses_sets[i]["t"]) then |
||
536 | SuperInspect_ItemBonuses_sets[i]["t"] = {}; |
||
537 | end |
||
538 | |||
539 | |||
540 | SuperInspect_ItemBonuses_sets[i]["t"][nnum] = tmpStr; |
||
541 | SI_AddMessage(RED_FONT_COLOR_CODE.."SET :"..(SuperInspect_ItemBonuses_sets[i].s).." ("..(SuperInspect_ItemBonuses_sets[i].n).."/"..(SuperInspect_ItemBonuses_sets[i].m)..") - "..tmpStr); |
||
542 | else |
||
543 | SI_AddMessage(RED_FONT_COLOR_CODE.."SET : tried adding set bonus, but already exists: ("..nnum..")"); |
||
544 | end |
||
545 | end |
||
546 | end |
||
547 | end |
||
548 | end |
||
549 | end |
||
550 | end |
||
551 | end |
||
552 | end |
||
553 | |||
554 | -- Scans passive bonuses like "Set: " and "Equip: " |
||
555 | function SuperInspectItemBonuses_ScanPassive(line) |
||
556 | local i, p, value, found; |
||
557 | |||
558 | found = nil; |
||
559 | for i,p in SI_IB_EQUIP_PATTERNS do |
||
560 | _, _, value = string.find(line, "^" .. p.pattern); |
||
561 | if(value) then |
||
562 | SuperInspectItemBonuses_AddValue(p.effect, value) |
||
563 | found = 1; |
||
564 | end |
||
565 | end |
||
566 | if(not found) then |
||
567 | SuperInspectItemBonuses_ScanGeneric(line); |
||
568 | end |
||
569 | end |
||
570 | |||
571 | |||
572 | -- Scans generic bonuses like "+3 Intellect" or "Arcane Resistance +4" |
||
573 | function SuperInspectItemBonuses_ScanGeneric(line) |
||
574 | local value, token, pos, tmpStr, found; |
||
575 | |||
576 | -- split line at "/" for enchants with multiple effects |
||
577 | found = false; |
||
578 | while(string.len(line) > 0) do |
||
579 | pos = string.find(line, "/", 1, true); |
||
580 | if(pos) then |
||
581 | tmpStr = string.sub(line,1,pos-1); |
||
582 | line = string.sub(line,pos+1); |
||
583 | else |
||
584 | tmpStr = line; |
||
585 | line = ""; |
||
586 | end |
||
587 | |||
588 | -- trim line |
||
589 | tmpStr = string.gsub( tmpStr, "^%s+", "" ); |
||
590 | tmpStr = string.gsub( tmpStr, "%s+$", "" ); |
||
591 | tmpStr = string.gsub( tmpStr, "%.$", "" ); |
||
592 | |||
593 | _, _, value, token = string.find(tmpStr, SI_IB_PREFIX_PATTERN); |
||
594 | if(not value) then |
||
595 | _, _, token, value = string.find(tmpStr, SI_IB_SUFFIX_PATTERN); |
||
596 | end |
||
597 | if(token and value) then |
||
598 | -- trim token |
||
599 | token = string.gsub( token, "^%s+", "" ); |
||
600 | token = string.gsub( token, "%s+$", "" ); |
||
601 | |||
602 | if(SuperInspectItemBonuses_ScanToken(token,value)) then |
||
603 | found = true; |
||
604 | end |
||
605 | end |
||
606 | end |
||
607 | return found; |
||
608 | end |
||
609 | |||
610 | -- Scans last fallback for not generic enchants, like "Mana Regen x per 5 sec." |
||
611 | function SuperInspectItemBonuses_ScanOther(line) |
||
612 | local i, p, value, start, found; |
||
613 | |||
614 | found = nil; |
||
615 | for i,p in SI_IB_OTHER_PATTERNS do |
||
616 | start, _, value = string.find(line, "^" .. p.pattern); |
||
617 | if(start) then |
||
618 | if(p.value) then |
||
619 | SuperInspectItemBonuses_AddValue(p.effect, p.value) |
||
620 | elseif(value) then |
||
621 | SuperInspectItemBonuses_AddValue(p.effect, value) |
||
622 | end |
||
623 | end |
||
624 | end |
||
625 | end |
||
626 | |||
627 | function SuperInspectItemBonuses_AddValue(effect, value) |
||
628 | local i,e; |
||
629 | if(type(effect) == "string") then |
||
630 | if(SuperInspect_ItemBonuses_bonuses[effect]) then |
||
631 | SuperInspect_ItemBonuses_bonuses[effect] = SuperInspect_ItemBonuses_bonuses[effect] + value; |
||
632 | else |
||
633 | SuperInspect_ItemBonuses_bonuses[effect] = value; |
||
634 | end |
||
635 | --SI_AddMessage(TEXT(effect).." - "..value); |
||
636 | else |
||
637 | -- list of effects |
||
638 | for i,e in effect do |
||
639 | if(SuperInspect_ItemBonuses_bonuses[e]) then |
||
640 | if(type(value) == "table") then |
||
641 | SuperInspect_ItemBonuses_bonuses[e] = SuperInspect_ItemBonuses_bonuses[e] + value[i]; |
||
642 | else |
||
643 | SuperInspect_ItemBonuses_bonuses[e] = SuperInspect_ItemBonuses_bonuses[e] + value; |
||
644 | end |
||
645 | else |
||
646 | if(type(value) == "table") then |
||
647 | SuperInspect_ItemBonuses_bonuses[e] = value[i]; |
||
648 | else |
||
649 | SuperInspect_ItemBonuses_bonuses[e] = value; |
||
650 | end |
||
651 | end |
||
652 | --SI_AddMessage(TEXT(e).." - "..value); |
||
653 | end |
||
654 | end |
||
655 | |||
656 | |||
657 | end |
||
658 | |||
659 | function SuperInspectItemBonuses_ScanToken(token, value) |
||
660 | local i,p,s1,s2; |
||
661 | if(SI_IB_TOKEN_EFFECT[token]) then |
||
662 | SuperInspectItemBonuses_AddValue(SI_IB_TOKEN_EFFECT[token], value); |
||
663 | else |
||
664 | for i,p in SI_IB_S1 do |
||
665 | if(string.find(token,p.pattern,1,1)) then |
||
666 | s1 = p.effect; |
||
667 | end |
||
668 | end |
||
669 | for i,p in SI_IB_S2 do |
||
670 | if(string.find(token,p.pattern,1,1)) then |
||
671 | s2 = p.effect; |
||
672 | end |
||
673 | end |
||
674 | if(s1 and s2) then |
||
675 | SuperInspectItemBonuses_AddValue(s1..s2, value); |
||
676 | end |
||
677 | end |
||
678 | end |
||
679 | |||
680 | |||
681 | function SuperInspect_BonusShow() |
||
682 | if (not SI_Save.bonus or SI_Save.bonus == 0) then |
||
683 | return; |
||
684 | else |
||
685 | SuperInspect_ItemBonusesFrame:Show(); |
||
686 | return 1; |
||
687 | end |
||
688 | end |
||
689 | |||
690 | function SuperInspectItemBonusesButton_BuildTooltip() |
||
691 | if (not SuperInspect_BonusShow()) then |
||
692 | return; |
||
693 | end |
||
694 | local text,textR,ret,name,cat,val = "","","","","",""; |
||
695 | local i; |
||
696 | for i=1, 5, 1 do |
||
697 | getglobal("SuperInspect_MagicResText"..i):Hide(); |
||
698 | end |
||
699 | |||
700 | for i,e in SI_IB_EFFECTS do |
||
701 | |||
702 | if(SuperInspect_ItemBonuses_bonuses[e.effect]) then |
||
703 | if(e.format) then |
||
704 | val = format(e.format,SuperInspect_ItemBonuses_bonuses[e.effect]); |
||
705 | else |
||
706 | val = SuperInspect_ItemBonuses_bonuses[e.effect]; |
||
707 | end |
||
708 | --DEFAULT_CHAT_FRAME:AddMessage(e.name); |
||
709 | --catch the resistances and put them in the res icons instead |
||
710 | if (e.name == RESISTANCE6_NAME) then |
||
711 | SuperInspect_MagicResText1:SetText(val); |
||
712 | SuperInspect_MagicResText1:Show(); |
||
713 | name = ""; |
||
714 | nameR = ""; |
||
715 | val = ""; |
||
716 | --return; |
||
717 | elseif (e.name == RESISTANCE2_NAME) then |
||
718 | SuperInspect_MagicResText2:SetText(val); |
||
719 | SuperInspect_MagicResText2:Show(); |
||
720 | name = ""; |
||
721 | nameR = ""; |
||
722 | val = ""; |
||
723 | elseif (e.name == RESISTANCE3_NAME) then |
||
724 | SuperInspect_MagicResText3:SetText(val); |
||
725 | SuperInspect_MagicResText3:Show(); |
||
726 | name = ""; |
||
727 | nameR = ""; |
||
728 | val = ""; |
||
729 | elseif (e.name == RESISTANCE4_NAME) then |
||
730 | SuperInspect_MagicResText4:SetText(val); |
||
731 | SuperInspect_MagicResText4:Show(); |
||
732 | name = ""; |
||
733 | nameR = ""; |
||
734 | val = ""; |
||
735 | elseif (e.name == RESISTANCE5_NAME) then |
||
736 | SuperInspect_MagicResText5:SetText(val); |
||
737 | SuperInspect_MagicResText5:Show(); |
||
738 | name = ""; |
||
739 | nameR = ""; |
||
740 | val = ""; |
||
741 | else |
||
742 | name = "\n".. HIGHLIGHT_FONT_COLOR_CODE.. " ".. e.name ..":\t"; |
||
743 | nameR = "\n"; |
||
744 | end |
||
745 | if(e.cat ~= cat and e.cat ~= "RES") then |
||
746 | cat = e.cat; |
||
747 | ret = ""; |
||
748 | if(text ~= "") then |
||
749 | text = text.."\n" |
||
750 | textR = textR.."\n" |
||
751 | elseif(text == "") then |
||
752 | ret = ""; |
||
753 | end |
||
754 | text = text .. ret .. "|cffffff00"..getglobal("SI_IB_CAT_"..cat) .. ":"; |
||
755 | textR = textR .. ret; |
||
756 | end |
||
757 | text = text ..name; |
||
758 | textR = textR ..nameR.. GREEN_FONT_COLOR_CODE..val; |
||
759 | end |
||
760 | end |
||
761 | if (text and text ~= "") then |
||
762 | local sntText = ""; |
||
763 | if (SuperInspect_ItemBonuses_sets and table.getn( SuperInspect_ItemBonuses_sets ) >= 1) then |
||
764 | text = text.."\n\n".. SI_IB_YELLOW..SI_SETS .. ":"; |
||
765 | for i=1, table.getn( SuperInspect_ItemBonuses_sets ), 1 do |
||
766 | text = text.."\n ".. HIGHLIGHT_FONT_COLOR_CODE..SuperInspect_ItemBonuses_sets[i].s .." (".. GREEN_FONT_COLOR_CODE..SuperInspect_ItemBonuses_sets[i].n .."/"..SuperInspect_ItemBonuses_sets[i].m.. HIGHLIGHT_FONT_COLOR_CODE..")"; |
||
767 | if (SuperInspect_ItemBonuses_sets[i]["t"]) then |
||
768 | sntText = sntText.."\n\n".. SI_IB_YELLOW..SuperInspect_ItemBonuses_sets[i].s ..HIGHLIGHT_FONT_COLOR_CODE.." (".. GREEN_FONT_COLOR_CODE..SuperInspect_ItemBonuses_sets[i].n .."/"..SuperInspect_ItemBonuses_sets[i].m.. HIGHLIGHT_FONT_COLOR_CODE..")"; |
||
769 | for index, value in SuperInspect_ItemBonuses_sets[i]["t"] do |
||
770 | --DEFAULT_CHAT_FRAME:AddMessage(index); |
||
771 | --if (SuperInspect_ItemBonuses_sets[i]["t"][set]) then |
||
772 | --DEFAULT_CHAT_FRAME:AddMessage(value); |
||
773 | sntText = sntText.."\n ".. GREEN_FONT_COLOR_CODE.."("..index..") "..HIGHLIGHT_FONT_COLOR_CODE..value; |
||
774 | --end |
||
775 | end |
||
776 | end |
||
777 | end |
||
778 | --text = text.."IMPORTANT: Bonuses awarded from multiple set pieces are not available for detection on your target. Please adjust your number manually."; |
||
779 | end |
||
780 | SuperInspect_ItemBonusesText:SetText(text, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
781 | SuperInspect_ItemBonusesTextR:SetText(textR, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
782 | SuperInspect_SnTBonusesText:SetText(sntText, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b); |
||
783 | --SI_AddMessage(" h= "..SuperInspect_ItemBonusesText:GetHeight()); |
||
784 | --SI_AddMessage(SuperInspect_ItemBonusesTextR:GetHeight()); |
||
785 | SuperInspect_Button_ShowBonuses:SetText(SI_BONUSESHIDE); |
||
786 | local iHeight = SuperInspect_ItemBonusesText:GetHeight() + 74; |
||
787 | if (iHeight < 284) then |
||
788 | SuperInspect_ItemBonusesFrame:SetHeight(284); |
||
789 | else |
||
790 | SuperInspect_ItemBonusesFrame:SetHeight(iHeight); |
||
791 | end |
||
792 | SuperInspect_ItemBonusesText:SetWidth(208); |
||
793 | else |
||
794 | SuperInspect_ItemBonusesFrame:Hide(); |
||
795 | end |
||
796 | end |
||
797 | |||
798 | function SuperInspect_UpdateModel(unit) |
||
799 | if (not unit) then |
||
800 | unit = "target"; |
||
801 | end |
||
802 | if (UnitExists(unit)) then |
||
803 | local x, y, z = SuperInspect_ModelFrame:GetPosition(); |
||
804 | SuperInspect_ModelFrame:SetModelScale(1); |
||
805 | SuperInspect_ModelFrame:ClearModel(); |
||
806 | SuperInspect_ModelFrame:SetUnit(unit); |
||
807 | |||
808 | SuperInspect_ModelFrame:SetPosition(x, y, z); |
||
809 | |||
810 | --DEFAULT_CHAT_FRAME:AddMessage(SuperInspect_ModelFrame:GetModelScale()); |
||
811 | SetPortraitTexture(SuperInspectFramePortrait, "target"); |
||
812 | |||
813 | SuperInspect_MoveFrame.panoffset = SuperInspect_ModelFrame.positionx * 100; |
||
814 | SuperInspect_MoveFrame.panoffsety = SuperInspect_ModelFrame.positiony * 100; |
||
815 | if ( SI_Save.default ) then |
||
816 | for key, val in UISpecialFrames do |
||
817 | if ( val == "SuperInspectFrame" ) then val = nil; end |
||
818 | end |
||
819 | UIPanelWindows["SuperInspectFrame"] = { area = "left", pushable = 0 }; |
||
820 | SuperInspectFrame:EnableMouse(0); |
||
821 | |||
822 | else |
||
823 | tinsert(UISpecialFrames, "SuperInspectFrame"); |
||
824 | UIPanelWindows["SuperInspectFrame"] = nil; |
||
825 | SuperInspectFrame:EnableMouse(1); |
||
826 | end |
||
827 | ShowUIPanel(SuperInspectFrame); |
||
828 | SuperInspect.isVisible = 1; |
||
829 | SuperInspect_InspectFrame_Show(unit); |
||
830 | SuperInspect_SetBackground(unit); |
||
831 | |||
832 | --SI_AddMessage(SuperInspect.name..UnitName(unit)); |
||
833 | if (SuperInspect.name and SuperInspect.name ~= UnitName(unit)) then |
||
834 | SuperInspect.honor = nil; |
||
835 | SuperInspect.bonus = nil; |
||
836 | --SI_AddMessage("CLEARING HONOR: OnEvent"); |
||
837 | --SI_AddMessage("|cffffd200PLAYER_TARGET_CHANGED: "..SuperInspect.name); |
||
838 | end |
||
839 | SuperInspect.name = UnitName(unit); |
||
840 | |||
841 | if (UnitRace(unit)) then |
||
842 | SuperInspectFrameHeader_Name:SetText(UnitPVPName(unit)); |
||
843 | local guildname = nil; |
||
844 | local guildtitle = nil; |
||
845 | local guildrank = nil; |
||
846 | guildname, guildtitle, guildrank = GetGuildInfo(unit); |
||
847 | local level = UnitLevel(unit); |
||
848 | if (level == -1) then |
||
849 | level = "??"; |
||
850 | end |
||
851 | if (guildname) then |
||
852 | SuperInspectFrameHeader_Guild:SetText(format(TEXT(GUILD_TITLE_TEMPLATE), guildtitle, "<"..guildname..">")); |
||
853 | SuperInspectFrameHeader_Info:SetText(SI_LEVEL.." "..level.." "..UnitRace(unit).." "..UnitClass(unit)); |
||
854 | else |
||
855 | SuperInspectFrameHeader_Guild:SetText(SI_LEVEL.." "..level.." "..UnitRace(unit).." "..UnitClass(unit)); |
||
856 | SuperInspectFrameHeader_Info:SetText(" "); |
||
857 | end |
||
858 | else |
||
859 | SuperInspectFrameHeader_Name:SetText(UnitName(unit)); |
||
860 | local level = UnitLevel(unit); |
||
861 | if (level == -1) then |
||
862 | level = "??"; |
||
863 | end |
||
864 | local classification = UnitClassification(unit); |
||
865 | if ( classification == "worldboss" ) then |
||
866 | classification = " ("..BOSS..")"; |
||
867 | elseif ( classification == "rareelite" ) then |
||
868 | classification = " ("..SI_RAREELITE..")"; |
||
869 | elseif ( classification == "elite" ) then |
||
870 | classification = " ("..ELITE..")"; |
||
871 | elseif ( classification == "rare" ) then |
||
872 | classification = " ("..ITEM_QUALITY3_DESC..")"; |
||
873 | else |
||
874 | classification = ""; |
||
875 | end |
||
876 | --BOSS |
||
877 | --ELITE |
||
878 | --ITEM_QUALITY3_DESC --rare |
||
879 | SuperInspectFrameHeader_Guild:SetText(SI_LEVEL.." "..level..classification); |
||
880 | SuperInspectFrameHeader_Info:SetText(" "); |
||
881 | end |
||
882 | else |
||
883 | --SuperInspect_InvFrame:Hide(); |
||
884 | --SuperInspect_Button_ShowItems:Disable(); |
||
885 | --SuperInspect_Button_ShowItems.isDisabled = 1; |
||
886 | end |
||
887 | end |
||
888 | |||
889 | function SuperInspect_GetBackgroundTexturePath(unit) |
||
890 | -- HACK!!! |
||
891 | local race, fileName = UnitRace(unit); |
||
892 | if ( fileName == "Gnome" or fileName == "GNOME" ) then |
||
893 | fileName = "Dwarf"; |
||
894 | elseif ( fileName == "Troll" or fileName == "TROLL" ) then |
||
895 | fileName = "Orc"; |
||
896 | end |
||
897 | if ( not fileName ) then |
||
898 | local num = random( 1, table.getn(SI_BG_Other) ); |
||
899 | fileName = SI_BG_Other[num]; |
||
900 | return "Interface\\TalentFrame\\"..fileName.."-"; |
||
901 | else |
||
902 | return "Interface\\DressUpFrame\\DressUpBackground-"..fileName, 1; |
||
903 | end |
||
904 | -- END HACK |
||
905 | end |
||
906 | |||
907 | function SuperInspect_SetBackground(unit) |
||
908 | local texture, type = SuperInspect_GetBackgroundTexturePath(unit); |
||
909 | if (type == 1) then |
||
910 | SuperInspect_BackgroundTopLeft:SetTexture(texture..1); |
||
911 | SuperInspect_BackgroundTopRight:SetTexture(texture..2); |
||
912 | SuperInspect_BackgroundBotLeft:SetTexture(texture..3); |
||
913 | SuperInspect_BackgroundBotRight:SetTexture(texture..4); |
||
914 | SuperInspect_BackgroundBotRight:SetWidth(64); |
||
915 | SuperInspect_BackgroundTopLeft:SetWidth(256); |
||
916 | SuperInspect_BackgroundTopRight:SetWidth(64); |
||
917 | SuperInspect_BackgroundBotLeft:SetWidth(256); |
||
918 | else |
||
919 | SuperInspect_BackgroundTopLeft:SetTexture(texture.."TopLeft"); |
||
920 | SuperInspect_BackgroundTopRight:SetTexture(texture.."TopRight"); |
||
921 | SuperInspect_BackgroundBotLeft:SetTexture(texture.."BottomLeft"); |
||
922 | SuperInspect_BackgroundBotRight:SetTexture(texture.."BottomRight"); |
||
923 | SuperInspect_BackgroundBotRight:SetWidth(74); |
||
924 | SuperInspect_BackgroundTopLeft:SetWidth(267); |
||
925 | SuperInspect_BackgroundTopRight:SetWidth(74); |
||
926 | SuperInspect_BackgroundBotLeft:SetWidth(267); |
||
927 | end |
||
928 | end |
||
929 | |||
930 | function SuperInspect_ShowItems_CheckChecked( button ) |
||
931 | if (not SI_Save.items or SI_Save.items == 0) then |
||
932 | SuperInspect_InvFrame:Show(); |
||
933 | --SI_AddMessage("SHOW INV: checkchecked"); |
||
934 | else |
||
935 | SuperInspect_InvFrame:Hide(); |
||
936 | SI_Save.items = 0; |
||
937 | --SI_AddMessage("HIDING INV: checkitycheck"); |
||
938 | end |
||
939 | end |
||
940 | |||
941 | function SuperInspect_ShowHonor_CheckChecked( button ) |
||
942 | if (not SuperInspect_HonorFrame.isShowing or SuperInspect_HonorFrame.isShowing == 0) then |
||
943 | SuperInspect_HonorFrame:Show(); |
||
944 | if (SuperInspect_ItemBonusesFrame:IsVisible()) then |
||
945 | SuperInspect_ShowBonuses_CheckChecked(); |
||
946 | end |
||
947 | else |
||
948 | SuperInspect_HonorFrame:Hide(); |
||
949 | end |
||
950 | end |
||
951 | |||
952 | function SuperInspect_ShowBonuses_CheckChecked( button ) |
||
953 | if (not SI_Save.bonus or SI_Save.bonus == 0) then |
||
954 | SI_Save.bonus = 1; |
||
955 | SuperInspectItemBonusesButton_BuildTooltip(); |
||
956 | --SI_AddMessage("SHOW BONUS: checkchecked"); |
||
957 | if (SuperInspect_HonorFrame:IsVisible()) then |
||
958 | SuperInspect_ShowHonor_CheckChecked(); |
||
959 | end |
||
960 | else |
||
961 | SuperInspect_ItemBonusesFrame:Hide(); |
||
962 | SI_Save.bonus = 0; |
||
963 | --SI_AddMessage("HIDING BONUS: checkitycheck"); |
||
964 | end |
||
965 | end |
||
966 | |||
967 | function SuperInspect_ShowMobInfo_CheckChecked( button ) |
||
968 | if (not SI_Save.mi or SI_Save.mi == 0) then |
||
969 | SuperInspect_MobInfoFrame:Show(); |
||
970 | else |
||
971 | SuperInspect_MobInfoFrame:Hide(); |
||
972 | SI_Save.mi = 0; |
||
973 | end |
||
974 | end |
||
975 | |||
976 | function SuperInspect_HonorFrame_OnLoad() |
||
977 | this:RegisterEvent("INSPECT_HONOR_UPDATE"); |
||
978 | end |
||
979 | |||
980 | function SuperInspect_HonorFrame_OnEvent() |
||
981 | if ( event == "INSPECT_HONOR_UPDATE" ) then |
||
982 | --SI_AddMessage("INSPECT_HONOR_UPDATE"); |
||
983 | SuperInspect_HonorFrame_Update(); |
||
984 | |||
985 | end |
||
986 | end |
||
987 | |||
988 | function SuperInspect_HonorFrame_OnShow() |
||
989 | |||
990 | SuperInspect_HonorFrame.isShowing = 1; |
||
991 | SuperInspect_Button_ShowHonor:SetText(SI_HONORHIDE); |
||
992 | |||
993 | if (SuperInspect.name) then |
||
994 | --SI_AddMessage(SuperInspect.name); |
||
995 | end |
||
996 | if (SuperInspect_ItemBonusesFrame:IsVisible()) then |
||
997 | SuperInspect_ShowBonuses_CheckChecked(); |
||
998 | end |
||
999 | |||
1000 | if (not UnitExists("target")) then |
||
1001 | if (not SuperInspect.honor and SuperInspect.name and SuperInspect.name ~= UnitName("target")) then |
||
1002 | SuperInspect_HonorFrameCurrentPVPTitle:SetText(SI_NOTARGET); |
||
1003 | SuperInspect_HonorFrameCurrentPVPTitle:Show(); |
||
1004 | SuperInspect_HonorFrameCurrentPVPRank:SetText(""); |
||
1005 | SuperInspect_HonorFrameHonorPercent:SetText(""); |
||
1006 | SuperInspect_HonorFrameCurrentPVPRank:Hide(); |
||
1007 | SuperInspect_HonorFrameCurrentPVPTitle:SetPoint("TOP", "$parent", "TOP", - SuperInspect_HonorFrameCurrentPVPRank:GetWidth()/2, -20); |
||
1008 | SuperInspect.honor = nil; |
||
1009 | --SI_AddMessage("CLEARING HONOR: OnShow 1"); |
||
1010 | return; |
||
1011 | else |
||
1012 | SuperInspect_HonorFrame_Update(); |
||
1013 | end |
||
1014 | else |
||
1015 | if (not SuperInspect.name or SuperInspect.name ~= UnitName("target") or not SuperInspect.honor or not HasInspectHonorData()) then |
||
1016 | --SuperInspect.name = UnitName("target") |
||
1017 | SuperInspect.honor = nil; |
||
1018 | --SI_AddMessage("CLEARING HONOR: OnShow 2"); |
||
1019 | SuperInspect_HonorFrame_Clear(); |
||
1020 | |||
1021 | SuperInspect_HonorFrameCurrentPVPTitle:SetText(SI_REQUESTHONOR); |
||
1022 | SuperInspect_HonorFrameCurrentPVPTitle:Show(); |
||
1023 | this.requesting = GetTime(); |
||
1024 | SuperInspect_HonorFrameCurrentPVPRank:SetText(""); |
||
1025 | SuperInspect_HonorFrameCurrentPVPRank:Hide(); |
||
1026 | SuperInspect_HonorFrameHonorPercent:SetText(""); |
||
1027 | SuperInspect_HonorFrameCurrentPVPTitle:SetPoint("TOP", "$parent", "TOP", - SuperInspect_HonorFrameCurrentPVPRank:GetWidth()/2, -18); |
||
1028 | |||
1029 | RequestInspectHonorData(); |
||
1030 | --SI_AddMessage("requesting honor update"); |
||
1031 | else |
||
1032 | SuperInspect_HonorFrame_Update(); |
||
1033 | end |
||
1034 | end |
||
1035 | end |
||
1036 | |||
1037 | --[[ |
||
1038 | SI_RANKNAME = {}; |
||
1039 | SI_RANKNAME.Alliance = { |
||
1040 | [1] = "Private", |
||
1041 | [2] = "Corporal", |
||
1042 | [3] = "Sergeant", |
||
1043 | [4] = "Master Sergeant", |
||
1044 | [5] = "Sergeant Major", |
||
1045 | [6] = "Knight", |
||
1046 | [7] = "Knight-Lieutenant", |
||
1047 | [8] = "Knight-Captain", |
||
1048 | [9] = "Knight-Champion", |
||
1049 | [10] = "Lieutenant Commander", |
||
1050 | [11] = "Commander", |
||
1051 | [12] = "Marshal", |
||
1052 | [13] = "Field Marshal", |
||
1053 | [14] = "Grand Marshal", |
||
1054 | }; |
||
1055 | SI_RANKNAME.Horde = { |
||
1056 | [1] = "Scout", |
||
1057 | [2] = "Grunt", |
||
1058 | [3] = "Sergeant", |
||
1059 | [4] = "Senior Sergeant", |
||
1060 | [5] = "First Sergeant", |
||
1061 | [6] = "Stone Guard", |
||
1062 | [7] = "Blood Guard", |
||
1063 | [8] = "Legionnare", |
||
1064 | [9] = "Centurion", |
||
1065 | [10] = "Champion", |
||
1066 | [11] = "Lieutenant General", |
||
1067 | [12] = "General", |
||
1068 | [13] = "Warlord", |
||
1069 | [14] = "High Warlord", |
||
1070 | }; |
||
1071 | ]] |
||
1072 | --[[ |
||
1073 | PVP_RANK_5_0 = "Scout"; |
||
1074 | PVP_RANK_5_1 = "Private"; |
||
1075 | PVP_RANK_6_0 = "Grunt"; |
||
1076 | PVP_RANK_6_1 = "Corporal"; |
||
1077 | PVP_RANK_7_0 = "Sergeant"; |
||
1078 | PVP_RANK_7_1 = "Sergeant"; |
||
1079 | PVP_RANK_8_0 = "Senior Sergeant"; |
||
1080 | PVP_RANK_8_1 = "Master Sergeant"; |
||
1081 | PVP_RANK_9_0 = "First Sergeant"; |
||
1082 | PVP_RANK_9_1 = "Sergeant Major"; |
||
1083 | PVP_RANK_10_0 = "Stone Guard"; |
||
1084 | PVP_RANK_10_1 = "Knight"; |
||
1085 | PVP_RANK_11_0 = "Blood Guard"; |
||
1086 | PVP_RANK_11_1 = "Knight-Lieutenant"; |
||
1087 | PVP_RANK_12_0 = "Legionnaire"; |
||
1088 | PVP_RANK_12_1 = "Knight-Captain"; |
||
1089 | PVP_RANK_13_0 = "Centurion"; |
||
1090 | PVP_RANK_13_1 = "Knight-Champion"; |
||
1091 | PVP_RANK_14_0 = "Champion"; |
||
1092 | PVP_RANK_14_1 = "Lieutenant Commander"; |
||
1093 | PVP_RANK_15_0 = "Lieutenant General"; |
||
1094 | PVP_RANK_15_1 = "Commander"; |
||
1095 | PVP_RANK_16_0 = "General"; |
||
1096 | PVP_RANK_16_1 = "Marshal"; |
||
1097 | PVP_RANK_17_0 = "Warlord"; |
||
1098 | PVP_RANK_17_1 = "Field Marshal"; |
||
1099 | PVP_RANK_18_0 = "High Warlord"; |
||
1100 | PVP_RANK_18_1 = "Grand Marshal"; |
||
1101 | PVP_RANK_19_0 = "Leader"; -- PvP Leader NPC |
||
1102 | PVP_RANK_19_1 = "Leader"; -- PvP Leader NPC |
||
1103 | ]] |
||
1104 | |||
1105 | function SuperInspect_HonorFrame_Update() |
||
1106 | if (SuperInspect.honor and not UnitExists("target")) then |
||
1107 | SuperInspect.honor = 1; |
||
1108 | return; |
||
1109 | end |
||
1110 | local sessionHK, sessionDK, yesterdayHK, yesterdayHonor, thisweekHK, thisweekHonor, lastweekHK, lastweekHonor, lastweekStanding, lifetimeHK, lifetimeDK, lifetimeRank = GetInspectHonorData(); |
||
1111 | this.requesting = nil; |
||
1112 | |||
1113 | -- Yesterday's values |
||
1114 | SuperInspect_HonorFrameYesterdayHKValue:SetText(yesterdayHK); |
||
1115 | SuperInspect_HonorFrameYesterdayContributionValue:SetText(yesterdayHonor); |
||
1116 | |||
1117 | -- This week's values |
||
1118 | SuperInspect_HonorFrameThisWeekHKValue:SetText(thisweekHK); |
||
1119 | SuperInspect_HonorFrameThisWeekContributionValue:SetText(thisweekHonor); |
||
1120 | |||
1121 | -- Last Week's values |
||
1122 | SuperInspect_HonorFrameLastWeekHKValue:SetText(lastweekHK); |
||
1123 | SuperInspect_HonorFrameLastWeekContributionValue:SetText(lastweekHonor); |
||
1124 | SuperInspect_HonorFrameLastWeekStandingValue:SetText(lastweekStanding); |
||
1125 | |||
1126 | -- This session's values |
||
1127 | SuperInspect_HonorFrameCurrentHKValue:SetText(sessionHK); |
||
1128 | SuperInspect_HonorFrameCurrentDKValue:SetText(sessionDK); |
||
1129 | |||
1130 | -- Lifetime stats |
||
1131 | SuperInspect_HonorFrameLifeTimeHKValue:SetText(lifetimeHK); |
||
1132 | SuperInspect_HonorFrameLifeTimeDKValue:SetText(lifetimeDK); |
||
1133 | local rankName, rankNumber = GetPVPRankInfo(lifetimeRank); |
||
1134 | SuperInspect_HonorFrameLifeTimeRankValue:SetText(rankName); |
||
1135 | |||
1136 | -- Set rank progress and bar color |
||
1137 | local factionGroup, factionName = UnitFactionGroup("target"); |
||
1138 | |||
1139 | -- Set rank name and number |
||
1140 | rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("target")); |
||
1141 | if ( not rankName ) then |
||
1142 | rankName = NONE; |
||
1143 | elseif (UnitFactionGroup("target") ~= UnitFactionGroup("player")) then |
||
1144 | local faction; |
||
1145 | if ( factionGroup == "Alliance" ) then |
||
1146 | faction = 1; |
||
1147 | else |
||
1148 | faction = 0; |
||
1149 | end |
||
1150 | rankName = getglobal("PVP_RANK_"..(tonumber(rankNumber)+4).."_"..faction); |
||
1151 | end |
||
1152 | |||
1153 | SuperInspect_HonorFrameCurrentPVPRank:SetText("("..RANK.." "..rankNumber..")"); |
||
1154 | SuperInspect_HonorFrameCurrentPVPRank:Show(); |
||
1155 | SuperInspect_HonorFrameCurrentPVPTitle:SetText(rankName); |
||
1156 | SuperInspect_HonorFrameCurrentPVPTitle:Show(); |
||
1157 | |||
1158 | if ( factionGroup == "Alliance" ) then |
||
1159 | SuperInspect_HonorFrameProgressBar:SetStatusBarColor(0.05, 0.15, 0.36); |
||
1160 | else |
||
1161 | SuperInspect_HonorFrameProgressBar:SetStatusBarColor(0.63, 0.09, 0.09); |
||
1162 | end |
||
1163 | local progress = GetInspectPVPRankProgress(); |
||
1164 | SuperInspect_HonorFrameProgressBar:SetValue(progress); |
||
1165 | SuperInspect_HonorFrameHonorPercent:SetText(format("%.2f", (progress*100) ).."%"); |
||
1166 | |||
1167 | -- Set icon |
||
1168 | if ( rankNumber > 0 ) then |
||
1169 | SuperInspect_HonorFramePvPIcon:SetTexture(format("%s%02d","Interface\\PvPRankBadges\\PvPRank",rankNumber)); |
||
1170 | SuperInspect_HonorFramePvPIcon:Show(); |
||
1171 | else |
||
1172 | SuperInspect_HonorFramePvPIcon:Hide(); |
||
1173 | end |
||
1174 | |||
1175 | -- Recenter rank text |
||
1176 | SuperInspect_HonorFrameCurrentPVPTitle:SetPoint("TOP", "$parent", "TOP", - (SuperInspect_HonorFrameCurrentPVPRank:GetWidth())/2, -18); |
||
1177 | |||
1178 | SuperInspect.honor = 1; |
||
1179 | --SI_AddMessage("ADDING HONOR: OnShow"); |
||
1180 | end |
||
1181 | |||
1182 | --/script DEFAULT_CHAT_FRAME:AddMessage(UnitFactionGroup("target")); |
||
1183 | |||
1184 | function SuperInspect_HonorFrame_Clear() |
||
1185 | if (SuperInspect.name and not UnitExists("target")) then |
||
1186 | return; |
||
1187 | end |
||
1188 | -- Yesterday's values |
||
1189 | SuperInspect_HonorFrameYesterdayHKValue:SetText(""); |
||
1190 | SuperInspect_HonorFrameYesterdayContributionValue:SetText(""); |
||
1191 | |||
1192 | -- This week's values |
||
1193 | SuperInspect_HonorFrameThisWeekHKValue:SetText(""); |
||
1194 | SuperInspect_HonorFrameThisWeekContributionValue:SetText(""); |
||
1195 | |||
1196 | -- Last Week's values |
||
1197 | SuperInspect_HonorFrameLastWeekHKValue:SetText(""); |
||
1198 | SuperInspect_HonorFrameLastWeekContributionValue:SetText(""); |
||
1199 | SuperInspect_HonorFrameLastWeekStandingValue:SetText(""); |
||
1200 | |||
1201 | -- This session's values |
||
1202 | SuperInspect_HonorFrameCurrentHKValue:SetText(""); |
||
1203 | SuperInspect_HonorFrameCurrentDKValue:SetText(""); |
||
1204 | |||
1205 | -- Lifetime stats |
||
1206 | SuperInspect_HonorFrameLifeTimeHKValue:SetText(""); |
||
1207 | SuperInspect_HonorFrameLifeTimeDKValue:SetText(""); |
||
1208 | |||
1209 | SuperInspect_HonorFrameLifeTimeRankValue:SetText(""); |
||
1210 | |||
1211 | SuperInspect_HonorFrameCurrentPVPRank:SetText(""); |
||
1212 | SuperInspect_HonorFrameCurrentPVPTitle:SetText(""); |
||
1213 | SuperInspect_HonorFrameCurrentPVPTitle:Hide(); |
||
1214 | SuperInspect_HonorFrameHonorPercent:SetText(""); |
||
1215 | |||
1216 | SuperInspect_HonorFramePvPIcon:Hide(); |
||
1217 | SuperInspect_HonorFrameProgressBar:SetValue(0); |
||
1218 | SuperInspect_HonorFrameHonorPercent:SetText(""); |
||
1219 | |||
1220 | end |
||
1221 | |||
1222 | function SuperInspect_HonorFrame_OnUpdate() |
||
1223 | if (this.requesting) then |
||
1224 | if ((GetTime() - this.requesting) >= 5) then |
||
1225 | this.requesting = nil; |
||
1226 | SuperInspect.honor = nil; |
||
1227 | --SI_AddMessage("CLEARING HONOR: OnUpdate"); |
||
1228 | SuperInspect_HonorFrameCurrentPVPTitle:SetText(SI_REQUESTHONORFAILED); |
||
1229 | SuperInspect_HonorFrameCurrentPVPTitle:Show(); |
||
1230 | SuperInspect_HonorFrameCurrentPVPRank:SetText(""); |
||
1231 | SuperInspect_HonorFrameCurrentPVPRank:Hide(); |
||
1232 | SuperInspect_HonorFrameHonorPercent:SetText(""); |
||
1233 | SuperInspect_HonorFrameCurrentPVPTitle:SetPoint("TOP", "$parent", "TOP", - SuperInspect_HonorFrameCurrentPVPRank:GetWidth()/2, -20); |
||
1234 | end |
||
1235 | end |
||
1236 | end |
||
1237 | |||
1238 | function SuperInspect_InspectPaperDollItemSlotButton_OnEnter() |
||
1239 | GameTooltip_SetDefaultAnchor(GameTooltip, this); |
||
1240 | SuperInspect.uiwidth = UIParent:GetWidth() / SuperInspect_GetUIScale(); |
||
1241 | if (SI_Save.default or (this:GetCenter(UIParent) / SuperInspect.uiwidth) < 0.7 ) then |
||
1242 | GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
1243 | else |
||
1244 | GameTooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
1245 | end |
||
1246 | local name = string.gsub(this:GetName(), "SuperInspect_", ""); |
||
1247 | --SI_AddMessage("setting TT"); |
||
1248 | --if we've lost our target, but gathered inv info when we had a target, ask the server for the item info |
||
1249 | if ( not GameTooltip:SetInventoryItem(SuperInspect_InvFrame.unit, this:GetID()) ) then |
||
1250 | if (this.link) then |
||
1251 | GameTooltip:SetHyperlink(this.link);--GetItemInfo(this.link) |
||
1252 | else |
||
1253 | GameTooltip:SetText(TEXT(getglobal(strupper(strsub(name, 8))))); |
||
1254 | end |
||
1255 | end |
||
1256 | CursorUpdate(); |
||
1257 | end |
||
1258 | |||
1259 | function SuperInspect_ModelFrame_OnLoad() |
||
1260 | this.rotation = 0.61; |
||
1261 | this.positionx = 0; |
||
1262 | this.positiony = 0; |
||
1263 | this.zoom = 0; |
||
1264 | SuperInspect_MoveFrame.panoffset = this.positionx; |
||
1265 | SuperInspect_MoveFrame.panoffsety = this.positiony; |
||
1266 | this:SetRotation(this.rotation); |
||
1267 | this:RefreshUnit(); |
||
1268 | --, this.left_right, this.up_down |
||
1269 | --/script SuperInspect_ModelFrame:SetModelScale(2); |
||
1270 | --/script SuperInspect_ModelFrame:SetCamera(1) |
||
1271 | end |
||
1272 | |||
1273 | function SuperInspect_Main_OnMouseDown(arg1) |
||
1274 | if (arg1 == "LeftButton") then |
||
1275 | this:StartMoving(); |
||
1276 | if (UnitPVPName("player") == SuperInspectFrameHeader_Name:GetText()) then |
||
1277 | AutoEquipCursorItem(); |
||
1278 | end |
||
1279 | end |
||
1280 | end |
||
1281 | |||
1282 | -- this function is called when the frame is stopped being dragged around |
||
1283 | function SuperInspect_Main_OnMouseUp(arg1) |
||
1284 | if (arg1 == "LeftButton") then |
||
1285 | this:StopMovingOrSizing(); |
||
1286 | |||
1287 | -- save the position |
||
1288 | SI_Save.framepos_L = SuperInspectFrame:GetLeft(); |
||
1289 | SI_Save.framepos_T = SuperInspectFrame:GetTop(); |
||
1290 | |||
1291 | end |
||
1292 | end |
||
1293 | |||
1294 | function SuperInspect_Move_OnMouseDown(arg1) |
||
1295 | if (arg1 == "LeftButton") then |
||
1296 | this:StartMoving(); |
||
1297 | this.ismoving = 1; |
||
1298 | --SI_AddMessage(this.offset); |
||
1299 | end |
||
1300 | if (arg1 == "RightButton") then |
||
1301 | this:StartMoving(); |
||
1302 | this.ispaning = 1; |
||
1303 | --SI_AddMessage(SuperInspect_ModelFrame.positionx); |
||
1304 | --SI_AddMessage(SuperInspect_ModelFrame.positiony); |
||
1305 | end |
||
1306 | end |
||
1307 | |||
1308 | -- this function is called when the frame is stopped being dragged around |
||
1309 | function SuperInspect_Move_OnMouseUp(arg1) |
||
1310 | if (arg1 == "LeftButton") then |
||
1311 | this:StopMovingOrSizing(); |
||
1312 | this.ismoving = nil; |
||
1313 | this.offset = SuperInspect_ModelFrame.rotation * 50; |
||
1314 | --SI_AddMessage(this.offset); |
||
1315 | this:ClearAllPoints(); |
||
1316 | this:SetPoint("TOP", "SuperInspect_ModelFrame", "TOP", 0, 0); |
||
1317 | |||
1318 | end |
||
1319 | if (arg1 == "RightButton") then |
||
1320 | this:StopMovingOrSizing(); |
||
1321 | this.ispaning = nil; |
||
1322 | this.panoffset = SuperInspect_ModelFrame.positionx * 100; |
||
1323 | this.panoffsety = SuperInspect_ModelFrame.positiony * 100; |
||
1324 | this:ClearAllPoints(); |
||
1325 | this:SetPoint("TOP", "SuperInspect_ModelFrame", "TOP", 0, 0); |
||
1326 | --/script SuperInspect_MoveFrame:SetPoint("CENTER", "SuperInspect_ModelFrame", "CENTER", 0, 0); |
||
1327 | |||
1328 | end |
||
1329 | end |
||
1330 | |||
1331 | function SuperInspect_Move_OnMouseWheel( value ) |
||
1332 | --local scrollBar = getglobal(this:GetName().."ScrollBar"); |
||
1333 | if ( value > 0 ) then |
||
1334 | SuperInspect_ModelFrame.zoom = SuperInspect_ModelFrame.zoom + 0.5; |
||
1335 | SuperInspect_ModelFrame:SetPosition(SuperInspect_ModelFrame.zoom, SuperInspect_ModelFrame.positionx, SuperInspect_ModelFrame.positiony); |
||
1336 | else |
||
1337 | SuperInspect_ModelFrame.zoom = SuperInspect_ModelFrame.zoom - 0.5; |
||
1338 | SuperInspect_ModelFrame:SetPosition(SuperInspect_ModelFrame.zoom, SuperInspect_ModelFrame.positionx, SuperInspect_ModelFrame.positiony); |
||
1339 | end |
||
1340 | end |
||
1341 | |||
1342 | function SuperInspect_Move_OnUpdate(elapsedTime) |
||
1343 | if ( this.ismoving ) then |
||
1344 | if (not this.offset) then |
||
1345 | this.offset = 0; |
||
1346 | end |
||
1347 | local move = this:GetCenter() + this.offset; |
||
1348 | local parent = this:GetParent():GetCenter(); |
||
1349 | SuperInspect_ModelFrame.rotation = (move - parent) * 0.02; |
||
1350 | SuperInspect_ModelFrame:SetRotation(SuperInspect_ModelFrame.rotation); |
||
1351 | end |
||
1352 | if ( this.ispaning ) then |
||
1353 | if (not this.panoffset) then |
||
1354 | this.panoffset = 0; |
||
1355 | end |
||
1356 | local move = this:GetCenter() + this.panoffset; |
||
1357 | local parent = this:GetParent():GetCenter(); |
||
1358 | local position = (move - parent) * 0.01; |
||
1359 | SuperInspect_ModelFrame.positionx = position; |
||
1360 | |||
1361 | if (not this.panoffsety) then |
||
1362 | this.panoffsety = -100; |
||
1363 | end |
||
1364 | local movey = this:GetTop() + this.panoffsety; |
||
1365 | local parenty = this:GetParent():GetTop(); |
||
1366 | local positiony = (movey - parenty) * 0.01; |
||
1367 | SuperInspect_ModelFrame.positiony = positiony; |
||
1368 | SuperInspect_ModelFrame:SetPosition(SuperInspect_ModelFrame.zoom, SuperInspect_ModelFrame.positionx, SuperInspect_ModelFrame.positiony); |
||
1369 | --/script SuperInspect_ModelFrame:SetPosition(1, 2, -100); |
||
1370 | end |
||
1371 | end |
||
1372 | |||
1373 | function SuperInspect_ResetFrame() |
||
1374 | SuperInspectFrame:ClearAllPoints(); |
||
1375 | if (not SI_Save.default) then |
||
1376 | SuperInspectFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
1377 | SI_Save.framepos_L = SuperInspectFrame:GetLeft(); |
||
1378 | SI_Save.framepos_T = SuperInspectFrame:GetTop(); |
||
1379 | end |
||
1380 | if (not UnitExists("target")) then |
||
1381 | TargetUnit("player"); |
||
1382 | end |
||
1383 | if (SI_Save.default) then |
||
1384 | HideUIPanel(SuperInspectFrame); |
||
1385 | SuperInspect.isVisible = nil; |
||
1386 | end |
||
1387 | SuperInspect_InspectTargetHooked(); |
||
1388 | end |
||
1389 | |||
1390 | --/script SuperInspect_MoveFrame:ClearAllPoints(); SuperInspect_MoveFrame:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
1391 | --SuperInspect_MoveFrame |
||
1392 | |||
1393 | |||
1394 | --/script TB_AddMessage(table.getn(SuperInspect)); |
||
1395 | --/script TB_AddMessage(table.getn(SuperInspect["Servers"][GetCVar("realmName")]["Mods"]["TipBuddy"]["Users"])); |
||
1396 | |||
1397 | function SuperInspect_SetDefaultStyleScale() |
||
1398 | if (SI_Save.default) then |
||
1399 | SuperInspectFrame:SetScale(3); |
||
1400 | local scale = UIParent:GetScale(); |
||
1401 | SuperInspect_SetEffectiveScale(SuperInspectFrame, scale, "UIParent"); |
||
1402 | --SuperInspect_ModelFrame:SetScale(SuperInspectFrame:GetEffectiveScale()); |
||
1403 | SuperInspect_ModelFrame:RefreshUnit(); |
||
1404 | SI_Save.scale = scale; |
||
1405 | end |
||
1406 | end |
||
1407 | |||
1408 | function SI_MI2_BuildMobInfoTooltip( mobName, mobLevel ) |
||
1409 | if (not MobInfoDB) then |
||
1410 | return; |
||
1411 | end |
||
1412 | SuperInspect_Button_ShowMobInfo:Show(); |
||
1413 | -- get mob data for targeted mob |
||
1414 | local simobData = MI2_GetMobData( mobName, mobLevel, "target" ) |
||
1415 | simobData.combinedStr = "" |
||
1416 | |||
1417 | MI2_MouseoverIndex = mobName..":"..mobLevel |
||
1418 | |||
1419 | -- handle combined Mob mode : try to find the other Mobs with same |
||
1420 | -- name but differing level, add their data to the tooltip data |
||
1421 | if (mobLevel > 0) then |
||
1422 | for levelToCombine = mobLevel-3, mobLevel+3, 1 do |
||
1423 | if levelToCombine ~= mobLevel then |
||
1424 | local dataToCombine = MI2_GetMobData( mobName, levelToCombine ) |
||
1425 | if dataToCombine.color then |
||
1426 | SI_MI2_AddTwoMobs( simobData, dataToCombine ) |
||
1427 | simobData.combinedStr = simobData.combinedStr.." L"..levelToCombine |
||
1428 | end |
||
1429 | else |
||
1430 | simobData.combinedStr = simobData.combinedStr.." L"..levelToCombine |
||
1431 | end |
||
1432 | end |
||
1433 | end |
||
1434 | |||
1435 | -- calculate number of mobs to next level based on mob experience |
||
1436 | if simobData.xp then |
||
1437 | local xpCurrent = UnitXP("player") + simobData.xp |
||
1438 | local xpToLevel = UnitXPMax("player") - xpCurrent |
||
1439 | simobData.mob2Level = ceil(abs(xpToLevel / simobData.xp))+1 |
||
1440 | end |
||
1441 | |||
1442 | -- display the Mob data to the game tooltip |
||
1443 | SI_MI2_BuildQualityString( simobData ) |
||
1444 | |||
1445 | SI_MI2_CreateNormalTooltip( simobData, MI2_MouseoverIndex ) |
||
1446 | end -- of MI2_BuildMobInfoTooltip() |
||
1447 | |||
1448 | function SI_MI2_BuildQualityString( simobData ) |
||
1449 | local rt = simobData.loots or 1 |
||
1450 | |||
1451 | simobData.qualityStr = "" |
||
1452 | |||
1453 | if simobData.r1 then |
||
1454 | simobData.qualityStr = simobData.qualityStr ..mifontGray..simobData.r1.."("..ceil((simobData.r1/rt)*100).."%) " |
||
1455 | end |
||
1456 | if simobData.r2 then |
||
1457 | simobData.qualityStr = simobData.qualityStr ..mifontWhite..simobData.r2.."("..ceil((simobData.r2/rt)*100).."%) " |
||
1458 | end |
||
1459 | if simobData.r3 then |
||
1460 | simobData.qualityStr = simobData.qualityStr ..mifontGreen..simobData.r3.."("..ceil((simobData.r3/rt)*100).."%) " |
||
1461 | end |
||
1462 | if simobData.r4 then |
||
1463 | simobData.qualityStr = simobData.qualityStr ..mifontBlue..simobData.r4.."("..ceil((simobData.r4/rt)*100).."%) " |
||
1464 | end |
||
1465 | if simobData.r5 then |
||
1466 | simobData.qualityStr = simobData.qualityStr ..mifontMageta..simobData.r5.."("..ceil((simobData.r5/rt)*100).."%) " |
||
1467 | end |
||
1468 | end -- MI2_CreateQualityString |
||
1469 | |||
1470 | ----------------------------------------------------------------------------- |
||
1471 | -- MI2_AddTwoMobs() |
||
1472 | -- |
||
1473 | -- add the data for two mobs, |
||
1474 | -- the data of the second mob (simobData2) is added to the data of the first |
||
1475 | -- mob (simobData1). The result is returned in "simobData1". |
||
1476 | ----------------------------------------------------------------------------- |
||
1477 | function SI_MI2_AddTwoMobs( simobData1, simobData2 ) |
||
1478 | simobData1.loots = (simobData1.loots or 0) + (simobData2.loots or 0) |
||
1479 | simobData1.kills = (simobData1.kills or 0) + (simobData2.kills or 0) |
||
1480 | simobData1.emptyLoots = (simobData1.emptyLoots or 0) + (simobData2.emptyLoots or 0) |
||
1481 | simobData1.clothCount = (simobData1.clothCount or 0) + (simobData2.clothCount or 0) |
||
1482 | simobData1.copper = (simobData1.copper or 0) + (simobData2.copper or 0) |
||
1483 | simobData1.itemValue = (simobData1.itemValue or 0) + (simobData2.itemValue or 0) |
||
1484 | simobData1.r1 = (simobData1.r1 or 0) + (simobData2.r1 or 0) |
||
1485 | simobData1.r2 = (simobData1.r2 or 0) + (simobData2.r2 or 0) |
||
1486 | simobData1.r3 = (simobData1.r3 or 0) + (simobData2.r3 or 0) |
||
1487 | simobData1.r4 = (simobData1.r4 or 0) + (simobData2.r4 or 0) |
||
1488 | simobData1.r5 = (simobData1.r5 or 0) + (simobData2.r5 or 0) |
||
1489 | if simobData2.mobType then simobData1.mobType = simobData2.mobType end |
||
1490 | if simobData2.xp then simobData1.xp = simobData2.xp end |
||
1491 | |||
1492 | -- combine DPS od two mobs |
||
1493 | if not simobData1.dps then |
||
1494 | simobData1.dps = simobData2.dps |
||
1495 | else |
||
1496 | if simobData2.dps then |
||
1497 | simobData1.dps = floor( ((2.0 * simobData1.dps) + simobData2.dps) / 3.0 ) |
||
1498 | end |
||
1499 | end |
||
1500 | |||
1501 | -- combine minimum and maximum damage |
||
1502 | if (simobData2.minDamage or 99999) < (simobData1.minDamage or 99999) then |
||
1503 | simobData1.minDamage = simobData2.minDamage |
||
1504 | end |
||
1505 | if (simobData2.maxDamage or 0) > (simobData1.maxDamage or 0) then |
||
1506 | simobData1.maxDamage = simobData2.maxDamage |
||
1507 | end |
||
1508 | |||
1509 | -- add loot item tables of the two mobs |
||
1510 | if simobData2.itemList then |
||
1511 | if not simobData1.itemList then simobData1.itemList = {} end |
||
1512 | for itemID, amount in simobData2.itemList do |
||
1513 | simobData1.itemList[itemID] = (simobData1.itemList[itemID] or 0) + simobData2.itemList[itemID] |
||
1514 | end |
||
1515 | end |
||
1516 | |||
1517 | if simobData1.loots == 0 then simobData1.loots = nil end |
||
1518 | if simobData1.kills == 0 then simobData1.kills = nil end |
||
1519 | if simobData1.emptyLoots == 0 then simobData1.emptyLoots = nil end |
||
1520 | if simobData1.clothCount == 0 then simobData1.clothCount = nil end |
||
1521 | if simobData1.copper == 0 then simobData1.copper = nil end |
||
1522 | if simobData1.itemValue == 0 then simobData1.itemValue = nil end |
||
1523 | if simobData1.dps == 0 then simobData1.dps = nil end |
||
1524 | if simobData1.r1 == 0 then simobData1.r1 = nil end |
||
1525 | if simobData1.r2 == 0 then simobData1.r2 = nil end |
||
1526 | if simobData1.r3 == 0 then simobData1.r3 = nil end |
||
1527 | if simobData1.r4 == 0 then simobData1.r4 = nil end |
||
1528 | if simobData1.r5 == 0 then simobData1.r5 = nil end |
||
1529 | end -- MI2_AddTwoMobs |
||
1530 | |||
1531 | function SI_MI2_CreateNormalTooltip( simobData, mobIndex ) |
||
1532 | local copperAvg, itemValueAvg |
||
1533 | local text, textR = "", ""; |
||
1534 | |||
1535 | if simobData.class then |
||
1536 | text = text..mifontGold..MI_TXT_CLASS.."\n"; |
||
1537 | textR = textR..mifontWhite..simobData.class.."\n"; |
||
1538 | end |
||
1539 | |||
1540 | if simobData.healthCur then |
||
1541 | text = text..mifontGold..MI_TXT_HEALTH.."\n"; |
||
1542 | textR = textR..mifontWhite..simobData.healthCur.." / "..simobData.healthMax.."\n"; |
||
1543 | end |
||
1544 | |||
1545 | if simobData.manaMax and simobData.manaMax > 0 then |
||
1546 | text = text..mifontGold..MI_TXT_MANA.."\n"; |
||
1547 | textR = textR..mifontWhite..simobData.manaCur.." / "..simobData.manaMax.."\n"; |
||
1548 | end |
||
1549 | |||
1550 | -- exit right here if mob does not exist in database |
||
1551 | if not simobData.color then |
||
1552 | SuperInspect_Button_ShowMobInfo:Hide(); |
||
1553 | return; |
||
1554 | end |
||
1555 | |||
1556 | local mobGivesXp = not (simobData.color.r == 0.5 and simobData.color.g == 0.5 and simobData.color.b == 0.5) |
||
1557 | if mobGivesXp and simobData.xp then |
||
1558 | text = text..mifontGold..MI_TXT_XP.."\n"; |
||
1559 | textR = textR..mifontWhite..simobData.xp.."\n"; |
||
1560 | |||
1561 | text = text..mifontGold..MI_TXT_TO_LEVEL.."\n"; |
||
1562 | textR = textR..mifontWhite..simobData.mob2Level.."\n"; |
||
1563 | end |
||
1564 | |||
1565 | if (simobData.minDamage or simobData.dps) then |
||
1566 | text = text..mifontGold..MI_TXT_DAMAGE.."\n"; |
||
1567 | textR = textR..mifontWhite..(simobData.minDamage or 0).."-"..(simobData.maxDamage or 0).." ["..(simobData.dps or 0).."]".."\n"; |
||
1568 | end |
||
1569 | |||
1570 | text = text.."\n"..mifontGray.."["..MI_TXT_COMBINED..simobData.combinedStr.."]".."\n"; |
||
1571 | textR = textR.."\n\n"; |
||
1572 | |||
1573 | |||
1574 | if simobData.kills then |
||
1575 | text = text..mifontGold..MI_TXT_KILLS.."\n"; |
||
1576 | textR = textR..mifontWhite..simobData.kills.."\n"; |
||
1577 | end |
||
1578 | |||
1579 | if simobData.loots then |
||
1580 | text = text..mifontGold..MI_TXT_TIMES_LOOTED.."\n"; |
||
1581 | textR = textR..mifontWhite..simobData.loots.."\n"; |
||
1582 | end |
||
1583 | |||
1584 | if simobData.emptyLoots then |
||
1585 | local emptyLootsStr = mifontWhite..simobData.emptyLoots |
||
1586 | if simobData.loots then |
||
1587 | emptyLootsStr = emptyLootsStr.." ("..ceil((simobData.emptyLoots/simobData.loots)*100).."%) " |
||
1588 | end |
||
1589 | text = text..mifontGold..MI_TXT_EMPTY_LOOTS.."\n"; |
||
1590 | textR = textR..emptyLootsStr.."\n"; |
||
1591 | end |
||
1592 | |||
1593 | if simobData.qualityStr ~= "" then |
||
1594 | text = text.."\n"..mifontGold..MI_TXT_QUALITY.."\n"; |
||
1595 | textR = textR.."\n"..simobData.qualityStr.."\n"; |
||
1596 | end |
||
1597 | |||
1598 | if simobData.clothCount then |
||
1599 | local clothStr = mifontWhite..simobData.clothCount |
||
1600 | if simobData.loots then |
||
1601 | clothStr = clothStr.." ("..ceil((simobData.clothCount/simobData.loots)*100).."%) " |
||
1602 | end |
||
1603 | text = text..mifontGold..MI_TXT_CLOTH_DROP.."\n"; |
||
1604 | textR = textR..clothStr.."\n"; |
||
1605 | end |
||
1606 | |||
1607 | if simobData.copper and simobData.loots then |
||
1608 | copperAvg = ceil( simobData.copper / simobData.loots ) |
||
1609 | text = text..mifontGold..MI_TXT_COIN_DROP.."\n"; |
||
1610 | textR = textR..mifontWhite..copper2text(copperAvg).."\n"; |
||
1611 | end |
||
1612 | |||
1613 | if simobData.itemValue and simobData.loots then |
||
1614 | itemValueAvg = ceil( simobData.itemValue / simobData.loots ) |
||
1615 | text = text..mifontGold..MI_TEXT_ITEM_VALUE.."\n"; |
||
1616 | textR = textR..mifontWhite..copper2text(itemValueAvg).."\n"; |
||
1617 | end |
||
1618 | |||
1619 | local totalValue = (copperAvg or 0) + (itemValueAvg or 0) |
||
1620 | if totalValue > 0 then |
||
1621 | text = text..mifontGold..MI_TXT_MOB_VALUE.."\n"; |
||
1622 | textR = textR..mifontWhite..copper2text(totalValue).."\n"; |
||
1623 | end |
||
1624 | |||
1625 | if simobData.itemList then |
||
1626 | text = text.."\n"; |
||
1627 | textR = textR.."\n"; |
||
1628 | text, textR = SI_MI2_AddItemsToTooltip( simobData, text, textR ) |
||
1629 | end |
||
1630 | |||
1631 | SuperInspect_MobInfoText:SetText(text); |
||
1632 | SuperInspect_MobInfoTextR:SetText(textR); |
||
1633 | if (SI_Save.mi and SI_Save.mi == 1) then |
||
1634 | SuperInspect_MobInfoFrame:Show(); |
||
1635 | local iHeight = SuperInspect_MobInfoText:GetHeight(); |
||
1636 | SuperInspect_MobInfoFrame:SetHeight(SuperInspect_MobInfoText:GetHeight() + 50); |
||
1637 | end |
||
1638 | end -- of MI2_CreateNormalTooltip() |
||
1639 | |||
1640 | function SI_MI2_AddItemsToTooltip( simobData, text, textR ) |
||
1641 | for itemID, amount in simobData.itemList do |
||
1642 | local itemText, itemColor = MI2_GetLootItemString(itemID) |
||
1643 | local itemText = itemText.." ("..amount..")" |
||
1644 | |||
1645 | if string.len(itemText) < 40 then |
||
1646 | text = text..itemColor..itemText.."\n"; |
||
1647 | textR = textR.."\n"; |
||
1648 | else |
||
1649 | local pos = string.find( itemText, " ", 26 ); |
||
1650 | text = text..itemColor..string.sub(itemText,1,pos-1).."\n"; |
||
1651 | textR = textR.."\n"; |
||
1652 | text = text..itemColor..string.sub(itemText,pos+1).."\n"; |
||
1653 | textR = textR.."\n"; |
||
1654 | end |
||
1655 | end |
||
1656 | return text, textR; |
||
1657 | end -- of MI2_AddItemsToTooltip |
||
1658 | |||
1659 | function SuperInspect_MobInfoFrame_OnShow() |
||
1660 | SI_Save.mi = 1; |
||
1661 | SuperInspect_Button_ShowMobInfo:SetText(SI_MOBINFOHIDE); |
||
1662 | --if (SuperInspect_MobInfoText:GetText() and SuperInspect_MobInfoText:GetText() ~= "") then |
||
1663 | local iHeight = SuperInspect_MobInfoText:GetHeight(); |
||
1664 | SuperInspect_MobInfoFrame:SetHeight(SuperInspect_MobInfoText:GetHeight() + 50); |
||
1665 | --end |
||
1666 | end |