forked from vikinghug/VikingUnitFrames
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVikingTargetFrame.lua
1487 lines (1251 loc) · 63.1 KB
/
VikingTargetFrame.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require "Window"
require "Unit"
require "GameLib"
require "Apollo"
require "PathMission"
require "P2PTrading"
local VL, VColor
local VikingTargetFrame = {}
local UnitFrames = {}
local knMaxLevel = 50
local knIconicArchetype = 23
local knFrameWidthMax = 400
local knFrameWidthShield = 372
local knFrameWidthMin = 340
local knClusterFrameWidth = 150 -- MUST MATCH XML
local knClusterFrameHeight = 400 -- MUST MATCH XML
local knClusterFrameVertOffset = 100 -- how far down to move the cluster members
local knHealthRed = 0.3
local knHealthYellow = 0.5
local knWindowStayOnScreenWidthOffset = 200
local knWindowStayOnScreenHeightOffset = 200
local bAbsorb = false
local kstrScalingHex = "ffffbf80"
local kcrScalingCColor = CColor.new(1.0, 191/255, 128/255, 0.7)
-- let's create some member variables
local karDispositionColors =
{
[Unit.CodeEnumDisposition.Neutral] = "lightGrey",
[Unit.CodeEnumDisposition.Hostile] = "red",
[Unit.CodeEnumDisposition.Friendly] = "green",
}
local ktDispositionToTTooltip =
{
[Unit.CodeEnumDisposition.Neutral] = Apollo.GetString("TargetFrame_NeutralTooltip"),
[Unit.CodeEnumDisposition.Hostile] = Apollo.GetString("TargetFrame_HostileTooltip"),
[Unit.CodeEnumDisposition.Friendly] = Apollo.GetString("TargetFrame_FriendlyTooltip"),
}
local kstrRaidMarkerToSprite =
{
"Icon_Windows_UI_CRB_Marker_Bomb",
"Icon_Windows_UI_CRB_Marker_Ghost",
"Icon_Windows_UI_CRB_Marker_Mask",
"Icon_Windows_UI_CRB_Marker_Octopus",
"Icon_Windows_UI_CRB_Marker_Pig",
"Icon_Windows_UI_CRB_Marker_Chicken",
"Icon_Windows_UI_CRB_Marker_Toaster",
"Icon_Windows_UI_CRB_Marker_UFO",
}
local karFactionToString = --Used for the Attachment Frame Sprites
{
[Unit.CodeEnumFaction.ExilesPlayer] = "Exile",
[171] = "Exile", --Exile NPC's
[Unit.CodeEnumFaction.DominionPlayer] = "Dominion",
[170] = "Dominion", --Dominion NPC's
}
-- Todo: break these out onto options
local kcrGroupTextColor = "blue"
local kcrFlaggedFriendlyTextColor = karDispositionColors[Unit.CodeEnumDisposition.Friendly]
local kcrDefaultGuildmemberTextColor = karDispositionColors[Unit.CodeEnumDisposition.Friendly]
local kcrHostileEnemyTextColor = karDispositionColors[Unit.CodeEnumDisposition.Hostile]
local kcrAggressiveEnemyTextColor = karDispositionColors[Unit.CodeEnumDisposition.Neutral]
local kcrNeutralEnemyTextColor = "yellow"
local kcrDefaultUnflaggedAllyTextColor = karDispositionColors[Unit.CodeEnumDisposition.Friendly]
-- TODO:Localize all of these
-- differential value, color, title, description, title color (for tooltip)
local karConInfo =
{
{-4 , ApolloColor.new("ConTrivial") , Apollo.GetString("TargetFrame_Trivial") , Apollo.GetString("TargetFrame_NoXP") , "ff7d7d7d"},
{-3 , ApolloColor.new("ConInferior") , Apollo.GetString("TargetFrame_Inferior") , Apollo.GetString("TargetFrame_VeryReducedXP") , "ff01ff07"},
{-2 , ApolloColor.new("ConMinor") , Apollo.GetString("TargetFrame_Minor") , Apollo.GetString("TargetFrame_ReducedXP") , "ff01fcff"},
{-1 , ApolloColor.new("ConEasy") , Apollo.GetString("TargetFrame_Easy") , Apollo.GetString("TargetFrame_SlightlyReducedXP") , "ff597cff"},
{ 0 , ApolloColor.new("ConAverage") , Apollo.GetString("TargetFrame_Average") , Apollo.GetString("TargetFrame_StandardXP") , "ffffffff"},
{ 1 , ApolloColor.new("ConModerate") , Apollo.GetString("TargetFrame_Moderate") , Apollo.GetString("TargetFrame_SlightlyMoreXP") , "ffffff00"},
{ 2 , ApolloColor.new("ConTough") , Apollo.GetString("TargetFrame_Tough") , Apollo.GetString("TargetFrame_IncreasedXP") , "ffff8000"},
{ 3 , ApolloColor.new("ConHard") , Apollo.GetString("TargetFrame_Hard") , Apollo.GetString("TargetFrame_HighlyIncreasedXP") , "ffff0000"},
{ 4 , ApolloColor.new("ConImpossible") , Apollo.GetString("TargetFrame_Impossible") , Apollo.GetString("TargetFrame_GreatlyIncreasedXP") , "ffff00ff"}
}
-- Todo: Localize
local ktRankDescriptions =
{
[Unit.CodeEnumRank.Fodder] = {Apollo.GetString("TargetFrame_Fodder") , Apollo.GetString("TargetFrame_VeryWeak")},
[Unit.CodeEnumRank.Minion] = {Apollo.GetString("TargetFrame_Minion") , Apollo.GetString("TargetFrame_Weak")},
[Unit.CodeEnumRank.Standard] = {Apollo.GetString("TargetFrame_Grunt") , Apollo.GetString("TargetFrame_EasyAppend")},
[Unit.CodeEnumRank.Champion] = {Apollo.GetString("TargetFrame_Challenger") , Apollo.GetString("TargetFrame_AlmostEqual")},
[Unit.CodeEnumRank.Superior] = {Apollo.GetString("TargetFrame_Superior") , Apollo.GetString("TargetFrame_Strong")},
[Unit.CodeEnumRank.Elite] = {Apollo.GetString("TargetFrame_Prime") , Apollo.GetString("TargetFrame_VeryStrong")}
}
local karClassToIcon =
{
[GameLib.CodeEnumClass.Warrior] = "VikingSprites:ClassWarrior",
[GameLib.CodeEnumClass.Engineer] = "VikingSprites:ClassEngineer",
[GameLib.CodeEnumClass.Esper] = "VikingSprites:ClassEsper",
[GameLib.CodeEnumClass.Medic] = "VikingSprites:ClassMedic",
[GameLib.CodeEnumClass.Stalker] = "VikingSprites:ClassStalker",
[GameLib.CodeEnumClass.Spellslinger] = "VikingSprites:ClassSpellslinger",
}
local kstrTooltipBodyColor = "ffc0c0c0"
local kstrTooltipTitleColor = "ffdadada"
local kstrFriendSprite = "ClientSprites:Icon_Windows_UI_CRB_Friend"
local kstrAccountFriendSprite = "ClientSprites:Icon_Windows_UI_CRB_Friend"
local kstrRivalSprite = "ClientSprites:Icon_Windows_UI_CRB_Rival"
local settings = {
bEnableCastbar = true
}
function UnitFrames:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function UnitFrames:Init()
Apollo.RegisterAddon(self, false, "", {"VikingLibrary"})
end
function UnitFrames:OnLoad()
self.xmlDoc = XmlDoc.CreateFromFile("VikingTargetFrame.xml")
self.xmlDoc:RegisterCallback("OnDocumentReady", self)
end
-- Save User Settings
function UnitFrames:OnSave(eLevel)
Print("Saving Settings...")
if eLevel ~= GameLib.CodeEnumAddonSaveLevel.Character then return end
local tSave =
{
bEnableCastbar = settings.bEnableCastbar
}
return tSave
end
-- Restore Saved User Settings
function UnitFrames:OnRestore(eLevel, t)
Print("Loading Settings...")
if t.bEnableCastbar ~= nil then
settings.bEnableCastbar = t.bEnableCastbar
end
end
function UnitFrames:OnDocumentReady()
if self.xmlDoc == nil then
return
end
Apollo.RegisterSlashCommand("focus", "OnFocusSlashCommand", self)
Apollo.RegisterSlashCommand("vui", "OnVikingUISlashCommand", self)
Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self)
Apollo.RegisterEventHandler("WindowManagementUpdate", "OnWindowManagementUpdate", self)
Apollo.RegisterEventHandler("CharacterCreated", "OnCharacterLoaded", self)
Apollo.RegisterEventHandler("TargetUnitChanged", "OnTargetUnitChanged", self)
Apollo.RegisterEventHandler("AlternateTargetUnitChanged", "OnAlternateTargetUnitChanged", self)
Apollo.RegisterEventHandler("VarChange_FrameCount", "OnFrame", self)
self.luaVikingUnitFrame = VikingTargetFrame:new()
self.luaVikingTargetFrame = VikingTargetFrame:new()
self.luaVikingFocusFrame = VikingTargetFrame:new()
self.luaVikingFocusFrame:Init(self, {fScale=1.0, nConsoleVar="hud.focusTargetFrameDisplay", bDrawClusters=false, bDrawToT=false})
self.luaVikingTargetFrame:Init(self, {fScale=1.0, bFlipped=true, bDrawClusters=true, bDrawToT=true})
self.luaVikingUnitFrame:Init(self, {fScale=1.0, nConsoleVar="hud.myUnitFrameDisplay", bDrawClusters=true, bDrawToT=false})
-- setup default positions
self.luaVikingUnitFrame.locDefaultPosition = WindowLocation.new({fPoints = {0.5, 1, 0.5, 1}, nOffsets = {-350,-204,-100,-116}})
self.luaVikingTargetFrame.locDefaultPosition = WindowLocation.new({fPoints = {0.5, 1, 0.5, 1}, nOffsets = {100,-204,350,-116}})
self.luaVikingFocusFrame.locDefaultPosition = WindowLocation.new({fPoints = {0, 0.5, 0, 0.5}, nOffsets = {10,-44,260,44}})
self.luaVikingUnitFrame:SetPosition(self.luaVikingUnitFrame.locDefaultPosition)
self.luaVikingTargetFrame:SetPosition(self.luaVikingTargetFrame.locDefaultPosition)
self.luaVikingFocusFrame:SetPosition(self.luaVikingFocusFrame.locDefaultPosition)
if GameLib.GetPlayerUnit() ~= nil then
self:OnCharacterLoaded()
end
end
function UnitFrames:OnFrame()
self:OnCharacterLoaded()
end
function UnitFrames:OnCharacterLoaded()
local unitPlayer = GameLib.GetPlayerUnit()
VL = Apollo.GetAddon("VikingLibrary")
VColor = VL.color
if unitPlayer ~= nil then
local unitTarget = unitPlayer:GetTarget()
local altPlayerTarget = unitPlayer:GetAlternateTarget()
self.luaVikingUnitFrame:SetTarget(unitPlayer)
self.luaVikingTargetFrame:SetTarget(unitTarget)
self.luaVikingFocusFrame:SetTarget(altPlayerTarget)
end
end
function UnitFrames:OnTargetUnitChanged(unitTarget)
self.luaVikingTargetFrame:SetTarget(unitTarget)
end
function UnitFrames:OnAlternateTargetUnitChanged(unitTarget)
self.luaVikingFocusFrame:SetTarget(unitTarget)
end
function UnitFrames:OnFocusSlashCommand()
local unitTarget = GameLib.GetTargetUnit()
GameLib.GetPlayerUnit():SetAlternateTarget(unitTarget)
end
function UnitFrames:OnVikingUISlashCommand(strCmd, strParam)
if string.find(strParam, "castbar") == 1 then
if string.find(strParam, "1") == 9 then
settings.bEnableCastbar = true
Print("Castbar for UnitFrames enabled")
elseif string.find(strParam, "0") == 9 then
settings.bEnableCastbar = false
Print("Castbar for UnitFrames disabled")
end
end
end
function UnitFrames:OnWindowManagementReady()
Event_FireGenericEvent("WindowManagementAdd" , {wnd = self.luaVikingUnitFrame.wndMainClusterFrame , strName = Apollo.GetString("OptionsHUD_MyUnitFrameLabel")})
Event_FireGenericEvent("WindowManagementAdd" , {wnd = self.luaVikingTargetFrame.wndMainClusterFrame , strName = Apollo.GetString("OptionsHUD_TargetFrameLabel")})
Event_FireGenericEvent("WindowManagementAdd" , {wnd = self.luaVikingFocusFrame.wndMainClusterFrame , strName = Apollo.GetString("OptionsHUD_FocusTargetLabel")})
end
function UnitFrames:OnWindowManagementUpdate(tSettings)
if tSettings and tSettings.wnd and (tSettings.wnd == self.luaVikingUnitFrame.wndMainClusterFrame or tSettings.wnd == self.luaVikingTargetFrame.wndMainClusterFrame or tSettings.wnd == self.luaVikingFocusFrame.wndMainClusterFrame) then
local bMoveable = tSettings.wnd:IsStyleOn("Moveable")
tSettings.wnd:SetStyle("Sizable", bMoveable)
tSettings.wnd:SetStyle("RequireMetaKeyToMove", bMoveable)
tSettings.wnd:SetStyle("IgnoreMouse", not bMoveable)
end
end
function VikingTargetFrame:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function VikingTargetFrame:Init(luaUnitFrameSystem, tParams)
Apollo.LinkAddon(luaUnitFrameSystem, self)
self.luaVikingUnitFrameSystem = luaUnitFrameSystem
Apollo.RegisterEventHandler("Tutorial_RequestUIAnchor", "OnTutorial_RequestUIAnchor", self)
Apollo.RegisterEventHandler("KeyBindingKeyChanged", "OnKeyBindingUpdated", self)
self.tParams = {
fScale = tParams.fScale or 1,
nConsoleVar = tParams.nConsoleVar,
bDrawClusters = tParams.bDrawClusters == nil and false or tParams.bDrawClusters,
bDrawToT = tParams.bDrawToT == nil and false or tParams.bDrawToT,
bFlipped = tParams.bFlipped == nil and false or tParams.bFlipped
}
self.vikingSettings = Apollo.GetAddon("VikingSettings")
if self.vikingSettings then
self.db = self.vikingSettings.db.char.VikingTargetFrame
end
self.wndMainClusterFrame = Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, tParams.bFlipped and "ClusterTargetFlipped" or "ClusterTarget", "FixedHudStratumLow", self)
self.arClusterFrames =
{
self.wndMainClusterFrame,
Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "ClusterTargetMini", self.wndMainClusterFrame, self),
Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "ClusterTargetMini", self.wndMainClusterFrame, self),
Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "ClusterTargetMini", self.wndMainClusterFrame, self),
Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "ClusterTargetMini", self.wndMainClusterFrame, self)
}
self.arClusterFrames[1]:SetScale(self.tParams.fScale)
self.wndLargeFrame = self.arClusterFrames[1]:FindChild("LargeFrame")
self:ArrangeClusterMembers()
self.tPets = { }
self.wndPetFrame = self.arClusterFrames[1]:FindChild("PetContainerDespawnBtn")
self.wndToTFrame = self.arClusterFrames[1]:FindChild("TotFrame")
self.wndToTFrame:Show(false)
self.arClusterFrames[1]:ArrangeChildrenHorz(1)
self.wndAssistFrame = Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "AssistTarget", "", self)
self.wndAssistFrame:Show(false, true)
self.nAltHealthLeft, self.nAltHealthTop, self.nAltHealthRight, self.nAltHealthBottom = self.wndAssistFrame:FindChild("MaxHealth"):GetAnchorOffsets()
self.nAltHealthWidth = self.nAltHealthRight - self.nAltHealthLeft
self.wndSimpleFrame = Apollo.LoadForm(luaUnitFrameSystem.xmlDoc, "SimpleTargetFrame", "", self)
self.wndSimpleFrame:Show(false)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- We need to overwrite the position, because the position from the xml was reseted (no idea why)
self.wndLargeFrame:MoveToLocation(WindowLocation.new({fPoints = {0, 0, 1, 1}, nOffsets = {10,10,-10,-10}}))
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
self.nLFrameLeft, self.nLFrameTop, self.nLFrameRight, self.nLFrameBottom = self.wndLargeFrame:GetAnchorOffsets()
self.arShieldPos = self.wndLargeFrame:FindChild("MaxShield"):GetLocation()
self.arAbsorbPos = self.wndLargeFrame:FindChild("MaxAbsorb"):GetLocation()
-- We apparently resize bars rather than set progress
self:SetBarValue(self.wndLargeFrame:FindChild("ShieldCapacityTint"), 0, 100, 100)
self.strPathActionKeybind = GameLib.GetKeyBinding("PathAction")
self.bPathActionUsesIcon = false
if self.strPathActionKeybind == "Unbound" or #self.strPathActionKeybind > 1 then -- Don't show interact
self.bPathActionUsesIcon = true
end
self.strQuestActionKeybind = GameLib.GetKeyBinding("CastObjectiveAbility")
self.bQuestActionUsesIcon = false
if self.strQuestActionKeybind == "Unbound" or #self.strQuestActionKeybind > 1 then -- Don't show interact
self.bQuestActionUsesIcon = true
end
self.nRaidMarkerLeft, self.nRaidMarkerTop, self.nRaidMarkerRight, self.nRaidMarkerBottom = self.wndLargeFrame:FindChild("RaidMarker"):GetAnchorOffsets()
-- self.maxVuln = 0
self.nLastCCArmorValue = 0
self.unitLastTarget = nil
self.bTargetDead = false
end
function VikingTargetFrame:OnUpdate()
local bTargetChanged = false
local unitTarget = self.unitTarget
local unitPlayer = GameLib.GetPlayerUnit()
local bShowWindow = true
local tCluster = nil
self.arClusterFrames[1]:Show(self.arClusterFrames[1]:IsShown())
if self.unitLastTarget == nil then
if unitTarget == nil then
return
end
bTargetChanged = true
self:HelperResetTooltips() -- these get redrawn with the unitToT info
end
if unitTarget ~= nil and self.unitLastTarget ~= unitTarget then
self.unitLastTarget = unitTarget
bTargetChanged = true
self:HelperResetTooltips() -- these get redrawn with the unitToT info
end
if unitTarget ~= nil then
-- Cluster info
tCluster = unitTarget:GetClusterUnits()
if unitTarget == unitPlayer then
--Treat Mount as a Cluster Target
if unitPlayer:IsMounted() then
table.insert(tCluster, unitPlayer:GetUnitMount())
end
end
--Make the unit a cluster of a vehicle if they're in one.
if unitTarget:IsInVehicle() then
local uPlayer = unitTarget
unitTarget = uPlayer:GetVehicle()
table.insert(tCluster, uPlayer)
end
-- Treat Pets as Cluster Targets
self.wndPetFrame:FindChild("PetContainerDespawnBtn"):SetData(nil)
local tPlayerPets = GameLib.GetPlayerPets()
self.wndPetFrame:Show(false)
for k,v in ipairs(tPlayerPets) do
if k == 1 then
if v == unitTarget then
self.wndPetFrame:FindChild("PetContainerDespawnBtn"):SetData(v)
self.wndPetFrame:FindChild("PetContainerDespawnBtn"):SetContentId(GameLib.GetPetDismissCommand(v))
self.wndPetFrame:Show(true)
end
elseif k == 2 then
if v == unitTarget then
self.wndPetFrame:FindChild("PetContainerDespawnBtn"):SetData(v)
self.wndPetFrame:FindChild("PetContainerDespawnBtn"):SetContentId(GameLib.GetPetDismissCommand(v))
self.wndPetFrame:Show(true)
end
end
if k < 3 and unitTarget == unitPlayer then
table.insert(tCluster, v)
end
end
if self.tParams.bDrawClusters ~= true or tCluster == nil or #tCluster < 1 then
tCluster = nil
end
-- Primary frame
if unitTarget:GetHealth() ~= nil and unitTarget:GetMaxHealth() > 0 then
self:UpdatePrimaryFrame(unitTarget, bTargetChanged)
elseif string.len(unitTarget:GetName()) > 0 then
bShowWindow = false
end
else
bShowWindow = false
self.wndSimpleFrame:Show(false)
self:HideClusterFrames()
end
if bShowWindow and self.tParams.nConsoleVar ~= nil then
--Toggle Visibility based on ui preference
local unitPlayer = GameLib.GetPlayerUnit()
local nVisibility = Apollo.GetConsoleVariable(self.tParams.nConsoleVar)
local nCurrEffHP = unitTarget:GetHealth() + unitTarget:GetShieldCapacity()
local nMaxEffHP = unitTarget:GetMaxHealth() + unitTarget:GetShieldCapacityMax()
if nVisibility == 2 then --always off
bShowWindow = false
elseif nVisibility == 3 then --on in combat
bShowWindow = unitPlayer:IsInCombat() or nCurrEffHP < nMaxEffHP
elseif nVisibility == 4 then --on out of combat
bShowWindow = not unitPlayer:IsInCombat()
else
bShowWindow = true
end
end
if bShowWindow and tCluster ~= nil and #tCluster > 0 then
self:UpdateClusterFrame(tCluster)
else
self:HideClusterFrames()
end
self.arClusterFrames[1]:Show(bShowWindow)
end
function VikingTargetFrame:GetPosition()
return self.arClusterFrames[1]:GetLocation()
end
function VikingTargetFrame:SetPosition(locNewLocation)
if locNewLocation == nil then
return
end
self.arClusterFrames[1]:MoveToLocation(locNewLocation)
end
function VikingTargetFrame:SetTarget(unitTarget)
self.unitTarget = unitTarget
-- Adjust Position if Target has no Shield
if unitTarget then
if unitTarget:GetShieldCapacityMax() ~= nil and unitTarget:GetShieldCapacityMax() > 0 then
self.wndLargeFrame:FindChild("BackgroundContainer"):SetAnchorPoints(0, 0, 1, 1)
elseif unitTarget:GetAbsorptionMax() ~= nil and unitTarget:GetAbsorptionMax() > 0 then
self.wndLargeFrame:FindChild("BackgroundContainer"):SetAnchorPoints(0, 0, 1, 1)
else
self.wndLargeFrame:FindChild("BackgroundContainer"):SetAnchorPoints(0, 0, 1, 0.77)
end
end
self:OnUpdate()
end
-- todo: remove this, move functionality to draw or previous function, look about unhooking for movement
function VikingTargetFrame:UpdatePrimaryFrame(unitTarget, bTargetChanged) --called from the onFrame; eliteness is frame, diff is rank
self.wndSimpleFrame:Show(false)
if unitTarget == nil then
return
end
local strTooltipRank = ""
if unitTarget:GetType() == "Player" then
local strRank = Apollo.GetString("TargetFrame_IsPC")
strTooltipRank = self:HelperBuildTooltip(strRank, Apollo.GetString("Achievement_PlayerBtn"))
elseif ktRankDescriptions[unitTarget:GetRank()] ~= nil then
local strRank = String_GetWeaselString(Apollo.GetString("TargetFrame_CreatureRank"), ktRankDescriptions[unitTarget:GetRank()][2])
strTooltipRank = self:HelperBuildTooltip(strRank, ktRankDescriptions[unitTarget:GetRank()][1])
end
self:SetTargetForFrame(self.wndLargeFrame, unitTarget, bTargetChanged)
-- ToT
if self.tParams.bDrawToT and not self.wndToTFrame:IsShown() and unitTarget:GetTarget() ~= nil then
self.wndToTFrame:Show(true)
elseif self.wndToTFrame:IsShown() and unitTarget:GetTarget() == nil then
self.wndToTFrame:Show(false)
end
if self.wndToTFrame:IsShown() then
self:UpdateToTFrame(unitTarget:GetTarget())
end
if RewardIcons ~= nil and RewardIcons.GetUnitRewardIconsForm ~= nil then
RewardIcons.GetUnitRewardIconsForm(self.wndLargeFrame:FindChild("TargetGoalPanel"), unitTarget, {bVert = true})
end
-- Raid Marker
local wndRaidMarker = self.wndLargeFrame:FindChild("RaidMarker")
if wndRaidMarker then
wndRaidMarker:SetSprite("")
local nMarkerId = unitTarget and unitTarget:GetTargetMarker() or 0
if unitTarget and nMarkerId ~= 0 then
wndRaidMarker:SetSprite(kstrRaidMarkerToSprite[nMarkerId])
end
end
end
function VikingTargetFrame:UpdateAlternateFrame(unitToT)
if unitToT == nil then
return
end
local wndFrame = self.wndAssistFrame
local eDisposition = unitToT:GetDispositionTo(GameLib.GetPlayerUnit())
local crColorToUse = nil
if unitToT:IsDead() and (eDisposition ~= Unit.CodeEnumDisposition.Friendly or not unitToT:IsThePlayer()) then
local unitPlayer = GameLib.GetPlayerUnit()
unitPlayer:SetAlternateTarget(nil)
return
end
wndFrame:FindChild("TargetName"):SetTextColor(VColor(karDispositionColors[eDisposition]))
if unitToT:GetType() == "Player" then
if eDisposition == Unit.CodeEnumDisposition.Friendly or unitToT:IsThePlayer() then
if unitToT:IsPvpFlagged() then
crColorToUse = kcrFlaggedFriendlyTextColor
elseif unitToT:IsInYourGroup() then
crColorToUse = kcrGroupTextColor
else
crColorToUse = kcrDefaultUnflaggedAllyTextColor
end
else
local bIsUnitFlagged = unitToT:IsPvpFlagged()
local bAmIFlagged = GameLib.IsPvpFlagged()
if not bAmIFlagged and not bIsUnitFlagged then
crColorToUse = kcrNeutralEnemyTextColor
elseif (bAmIFlagged and not bIsUnitFlagged) or (not bAmIFlagged and bIsUnitFlagged) then
crColorToUse = kcrAggressiveEnemyTextColor
elseif bAmIFlagged and bIsUnitFlagged then
crColorToUse = kcrHostileEnemyTextColor
end
end
wndFrame:FindChild("TargetName"):SetTextColor(VColor(crColorToUse))
end
if wndFrame:FindChild("TargetModel") then
wndFrame:FindChild("TargetModel"):SetCostume(unitToT)
wndFrame:FindChild("TargetModel"):SetData(unitToT)
end
wndFrame:SetData(unitToT)
wndFrame:FindChild("TargetName"):SetText(unitToT:GetName())
if eDisposition == Unit.CodeEnumDisposition.Friendly or unitToT:IsThePlayer() then
wndFrame:FindChild("DispositionFrameFriendly"):Show(true)
wndFrame:FindChild("DispositionFrameHostile"):Show(false)
else
wndFrame:FindChild("DispositionFrameFriendly"):Show(false)
wndFrame:FindChild("DispositionFrameHostile"):Show(true)
end
local nHealthCurr = unitToT:GetHealth()
local nHealthMax = unitToT:GetMaxHealth()
local nShieldCurr = unitToT:GetShieldCapacity()
local nShieldMax = unitToT:GetShieldCapacityMax()
local nAbsorbCurr = 0
local nAbsorbMax = unitToT:GetAbsorptionMax()
if nAbsorbMax > 0 then
nAbsorbCurr = unitToT:GetAbsorptionValue() -- Since it doesn't clear when the buff drops off
end
local nTotalMax = nHealthMax + nShieldMax + nAbsorbMax
local nVulnerabilityTime = unitToT:GetCCStateTimeRemaining(Unit.CodeEnumCCState.Vulnerability)
local nPointHealthRight = self.nAltHealthLeft + (self.nAltHealthWidth * (nHealthCurr / nTotalMax)) -- applied to the difference between L and R
local nPointShieldRight = self.nAltHealthLeft + (self.nAltHealthWidth * ((nHealthCurr + nShieldMax) / nTotalMax))
local nPointAbsorbRight = self.nAltHealthLeft + (self.nAltHealthWidth * ((nHealthCurr + nShieldMax + nAbsorbMax) / nTotalMax))
if nShieldMax > 0 and nShieldMax / nTotalMax < 0.2 then
local nMinShieldSize = 0.2 -- HARDCODE: Minimum shield bar length is 20% of total for formatting
nPointHealthRight = self.nAltHealthLeft + (self.nAltHealthWidth * (math.min (1 - nMinShieldSize, nHealthCurr / nTotalMax)))
nPointShieldRight = self.nAltHealthLeft + (self.nAltHealthWidth * (math.min (1, (nHealthCurr / nTotalMax) + nMinShieldSize)))
end
-- Bars
wndFrame:FindChild("ShieldFill"):Show(nHealthCurr > 0 and bAbsorb == false)
wndFrame:FindChild("MaxHealth"):Show(nHealthCurr > 0)
wndFrame:FindChild("MaxShield"):Show(nHealthCurr > 0 and nShieldMax > 0 and bAbsorb == false)
wndFrame:FindChild("MaxAbsorb"):Show(nHealthCurr > 0 and nAbsorbMax > 0)
-- String
local strHealthMax = self:HelperFormatBigNumber(nHealthMax)
local strHealthCurr = self:HelperFormatBigNumber(nHealthCurr)
local strShieldMax = self:HelperFormatBigNumber(nShieldMax)
local strShieldCurr = self:HelperFormatBigNumber(nShieldCurr)
local strAbsorbMax = self:HelperFormatBigNumber(nAbsorbMax)
local strAbsorbCurr = self:HelperFormatBigNumber(nAbsorbCurr)
--Toggle Visibility based on ui preference
if nVisibility == 2 then -- show x/y
self.wndLargeFrame:FindChild("HealthText"):SetText(String_GetWeaselString(Apollo.GetString("TargetFrame_HealthText"), strHealthCurr, strHealthMax))
elseif nVisibility == 3 then --show %
self.wndLargeFrame:FindChild("HealthText"):SetText(String_GetWeaselString(Apollo.GetString("CRB_Percent"), nHealthCurr/nHealthMax*100))
else --on mouseover
self.wndLargeFrame:FindChild("HealthText"):SetText("")
end
self.wndLargeFrame:FindChild("HealthText"):SetTooltip(string.format("%s: %s / %s (%s)", Apollo.GetString("Innate_Health"), strHealthCurr, strHealthMax, String_GetWeaselString(Apollo.GetString("CRB_Percent"), nHealthCurr/nHealthMax*100)))
if nShieldCurr > 0 and nShieldMax > 0 then
if nVisibility == 2 and bAbsorb == false then -- show x/y
self.wndLargeFrame:FindChild("ShieldText"):SetText(String_GetWeaselString(Apollo.GetString("TargetFrame_HealthText"), strShieldCurr, strShieldMax))
elseif nVisibility == 3 and bAbsorb == false then --show %
self.wndLargeFrame:FindChild("ShieldText"):SetText(String_GetWeaselString(Apollo.GetString("CRB_Percent"), nShieldCurr/nShieldMax*100))
else --on mouseover
self.wndLargeFrame:FindChild("ShieldText"):SetText("")
end
self.wndLargeFrame:FindChild("ShieldText"):SetTooltip(string.format("%s: %s / %s (%s)", Apollo.GetString("Character_ShieldLabel"), strShieldCurr, strShieldMax, String_GetWeaselString(Apollo.GetString("CRB_Percent"), nShieldCurr/nShieldMax*100)))
end
if nAbsorbCurr > 0 and nAbsorbMax > 0 then
self.wndLargeFrame:FindChild("ShieldText"):SetText("")
if nVisibility == 2 then -- show x/y
--self.wndLargeFrame:FindChild("AbsorbText"):SetText(String_GetWeaselString(Apollo.GetString("FloatText_AbsorbTester"), strAbsorbCurr, strAbsorbMax))
self.wndLargeFrame:FindChild("AbsorbText"):SetText(string.format("%s: %s / %s (%s)", Apollo.GetString("FloatText_AbsorbTester"), strAbsorbCurr, strAbsorbMax, String_GetWeaselString(Apollo.GetString("CRB_Percent"), nAbsorbCurr/nAbsorbMax*100)))
elseif nVisibility == 3 then --show %
--self.wndLargeFrame:FindChild("AbsorbText"):SetText(String_GetWeaselString(Apollo.GetString("CRB_Percent"), nAbsorbCurr/nAbsorbMax*100))
self.wndLargeFrame:FindChild("AbsorbText"):SetText(string.format("%s: %s / %s (%s)", Apollo.GetString("FloatText_AbsorbTester"), strAbsorbCurr, strAbsorbMax, String_GetWeaselString(Apollo.GetString("CRB_Percent"), nAbsorbCurr/nAbsorbMax*100)))
else --on mouseover
self.wndLargeFrame:FindChild("AbsorbText"):SetText("")
end
self.wndLargeFrame:FindChild("AbsorbText"):SetTooltip(string.format("%s: %s / %s (%s)", Apollo.GetString("FloatText_AbsorbTester"), strAbsorbCurr, strAbsorbMax, String_GetWeaselString(Apollo.GetString("CRB_Percent"), nAbsorbCurr/nAbsorbMax*100)))
end
-- Sprite
local wndHealth = wndFrame:FindChild("MaxHealth")
if nVulnerabilityTime and nVulnerabilityTime > 0 then
wndHealth:SetSprite("sprNp_Health_FillPurple")
elseif nHealthCurr / nHealthMax < knHealthRed then
wndHealth:SetSprite("sprNp_Health_FillRed")
elseif nHealthCurr / nHealthMax < knHealthYellow then
wndHealth:SetSprite("sprNp_Health_FillOrange")
else
wndHealth:SetSprite("sprNp_Health_FillGreen")
end
-- Interrupt Armor
---------------------------------------------------------------------------
local nCCArmorValue = unitToT:GetInterruptArmorValue()
local nCCArmorMax = unitToT:GetInterruptArmorMax()
local wndCCArmor = wndFrame:FindChild("CCArmorContainer")
if nCCArmorMax == 0 or nCCArmorValue == nil then
wndCCArmor:Show(false)
else
wndCCArmor:Show(true)
if nCCArmorMax == -1 then -- impervious
wndCCArmor:FindChild("CCArmorValue"):SetText("")
wndCCArmor:FindChild("CCArmorSprite"):SetSprite("CRB_ActionBarSprites:sprAb_IntArm_Invulnerable")
elseif nCCArmorValue == 0 and nCCArmorMax > 0 then -- broken
wndCCArmor:FindChild("CCArmorValue"):SetText("")
wndCCArmor:FindChild("CCArmorSprite"):SetSprite("CRB_ActionBarSprites:sprAb_IntArm_Broken")
elseif nCCArmorMax > 0 then -- has armor, has value
wndCCArmor:FindChild("CCArmorValue"):SetText(nCCArmorValue)
wndCCArmor:FindChild("CCArmorSprite"):SetSprite("CRB_ActionBarSprites:sprAb_IntArm_Regular")
end
if nCCArmorValue < self.nLastCCArmorValue and nCCArmorValue ~= 0 and nCCArmorValue ~= -1 then
wndCCArmor:FindChild("CCArmorFlash"):SetSprite("CRB_ActionBarSprites:sprAb_IntArm_Flash")
end
end
self:UpdateCastingBar(wndFrame, unitToT)
end
function VikingTargetFrame:UpdateToTFrame(unitToT) -- called on frame
if unitToT == nil then
return
end
--Toggle Visibility based on ui preference
local unitPlayer = GameLib.GetPlayerUnit()
local nVisibility = Apollo.GetConsoleVariable("hud.TargetOfTargetFrameDisplay")
if nVisibility == 2 then --always off
self.wndToTFrame:Show(false)
elseif nVisibility == 3 then --on in combat
self.wndToTFrame:Show(unitPlayer:IsInCombat())
elseif nVisibility == 4 then --on out of combat
self.wndToTFrame:Show(not unitPlayer:IsInCombat())
else
self.wndToTFrame:Show(true)
end
if not self.wndToTFrame:IsShown() then
-- no point in updating something our ui preferences told us not to display...
return
end
self.wndToTFrame:SetData(unitToT)
self.wndToTFrame:FindChild("TargetModel"):SetCostume(unitToT)
end
function VikingTargetFrame:UpdateClusterFrame(tCluster) -- called on frame
if self.unitTarget:IsDead() then
self:HideClusterFrames()
return
end
self:ArrangeClusterMembers()
local nCount = 2
for idx = 1, #tCluster do
if nCount <= 5 then
if not tCluster[idx]:IsDead() then
self.arClusterFrames[nCount]:Show(true, true)
self:SetTargetForClusterFrame(self.arClusterFrames[nCount], tCluster[idx], true)
self.arClusterFrames[nCount]:FindChild("TargetModel"):SetCostume(tCluster[idx])
if RewardIcons ~= nil and RewardIcons.GetUnitRewardIconsForm ~= nil then
RewardIcons.GetUnitRewardIconsForm(self.arClusterFrames[nCount]:FindChild("TargetGoalPanel"), tCluster[idx], {bVert = true})
end
local nHealth = tCluster[idx]:GetHealth()
local nMaxHealth = tCluster[idx]:GetMaxHealth()
local nShield = tCluster[idx]:GetShieldCapacity()
local nMaxShield = tCluster[idx]:GetShieldCapacityMax()
if nHealth ~= nil then
if self.arClusterFrames[nCount]:FindChild("HealthTint") then
local wndCover = self.arClusterFrames[nCount]:FindChild("Cover")
local wndHealthBar = self.arClusterFrames[nCount]:FindChild("HealthTint")
local wndHealthShieldBar = self.arClusterFrames[nCount]:FindChild("HealthShieldTint")
local wndShieldBar = self.arClusterFrames[nCount]:FindChild("ShieldCapacityTint")
local wndHealth = nMaxShield > 0 and wndHealthShieldBar or wndHealthBar
wndHealthBar:Show(nMaxShield == 0)
wndHealthShieldBar:Show(nMaxShield > 0)
wndShieldBar:Show(nMaxShield > 0)
wndCover:SetSprite(nMaxShield > 0 and "spr_TargetFrame_ClusterCoverShield" or "spr_TargetFrame_ClusterCover")
wndHealth:SetMax(nMaxHealth)
wndHealth:SetProgress(nHealth)
wndShieldBar:SetMax(nMaxShield)
wndShieldBar:SetProgress(nShield)
if tCluster[idx]:IsInCCState(Unit.CodeEnumCCState.Vulnerability) then
wndHealth:SetFullSprite("spr_TargetFrame_ClusterHealthRed")
elseif (nHealth / nMaxHealth) <= knHealthRed then
wndHealth:SetFullSprite("spr_TargetFrame_ClusterHealthRed")
elseif (nHealth / nMaxHealth) <= knHealthYellow then
wndHealth:SetFullSprite("spr_TargetFrame_ClusterHealthYellow")
else
wndHealth:SetFullSprite("spr_TargetFrame_ClusterHealthGreen")
end
end
end
local nLevel = tCluster[idx]:GetLevel()
if nLevel == nil then
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetText("--")
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetTextColor(karConInfo[1][2])
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetTooltip("")
else
local nCon = self:HelperCalculateConValue(tCluster[idx])
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetText(tCluster[idx]:GetLevel())
if tCluster[idx]:IsScaled() then
self.arClusterFrames[nCount]:FindChild("TargetScalingMark"):Show(true)
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetTextColor(kcrScalingCColor)
if tCluster[idx] ~= GameLib.GetPlayerUnit() then
strRewardFormatted = String_GetWeaselString(Apollo.GetString("TargetFrame_CreatureScales"), tCluster[idx]:GetLevel())
local strLevelTooltip = self:HelperBuildTooltip(strRewardFormatted, Apollo.GetString("Adaptive"), kstrScalingHex)
self.arClusterFrames[nCount]:FindChild("TargetLevel"):FindChild("TargetLevel"):SetTooltip(strLevelTooltip)
end
else
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetTextColor(karConInfo[nCon][2])
if tCluster[idx] ~= GameLib.GetPlayerUnit() then
local strRewardFormatted = String_GetWeaselString(Apollo.GetString("TargetFrame_TargetXPReward"), karConInfo[nCon][4])
local strLevelTooltip = self:HelperBuildTooltip(strRewardFormatted, karConInfo[nCon][3], karConInfo[nCon][5])
self.arClusterFrames[nCount]:FindChild("TargetLevel"):SetTooltip(strLevelTooltip)
end
end
end
nCount = nCount + 1
end
end
end
for idx = nCount, 5 do
self.arClusterFrames[idx]:Show(false)
self.arClusterFrames[idx]:SetData(nil)
end
end
function VikingTargetFrame:HideClusterFrames()
for idx = 2, 5 do
self.arClusterFrames[idx]:Show(false)
self.arClusterFrames[idx]:SetData(nil)
end
end
function VikingTargetFrame:SetTargetForFrame(wndFrame, unitTarget, bTargetChanged)
wndFrame:SetData(unitTarget)
self:SetTargetHealthAndShields(wndFrame, unitTarget)
if unitTarget then
strName = unitTarget:GetName()
-- PvP
if unitTarget:IsPvpFlagged() then
strName = String_GetWeaselString(Apollo.GetString("BaseBar_PvPAppend"), strName)
end
wndFrame:FindChild("TargetName"):SetText(strName)
local eRank = unitTarget:GetRank()
local strClassIconSprite = ""
local strPlayerIconSprite = ""
-- Class Icon is based on player class or NPC rank
if unitTarget:GetType() == "Player" then
strPlayerIconSprite = karClassToIcon[unitTarget:GetClassId()]
elseif eRank == Unit.CodeEnumRank.Elite then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Elite"
elseif eRank == Unit.CodeEnumRank.Superior then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Superior"
elseif eRank == Unit.CodeEnumRank.Champion then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Champion"
elseif eRank == Unit.CodeEnumRank.Standard then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Standard"
elseif eRank == Unit.CodeEnumRank.Minion then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Minion"
elseif eRank == Unit.CodeEnumRank.Fodder then
strClassIconSprite = "spr_TargetFrame_ClassIcon_Fodder"
end
wndFrame:FindChild("PlayerClassIcon"):SetSprite(strPlayerIconSprite)
wndFrame:FindChild("TargetClassIcon"):SetSprite(strClassIconSprite)
--Disposition/flags
local strFlipped = self.tParams.bFlipped and "Flipped" or ""
local eDisposition = unitTarget:GetDispositionTo(GameLib.GetPlayerUnit())
local strDisposition = "Friendly"
local strAttachment = ""
wndFrame:FindChild("TargetName"):SetTextColor(VColor(karDispositionColors[eDisposition]))
if eDisposition == Unit.CodeEnumDisposition.Hostile then
strDisposition = "Hostile"
elseif eDisposition == Unit.CodeEnumDisposition.Neutral then
strDisposition = "Neutral"
end
--Rare and Elite NPCs
if unitTarget:GetDifficulty() == 3 then
strAttachment = strDisposition.."Rare"
elseif unitTarget:GetDifficulty() == 7 then
strAttachment = strDisposition.."Elite"
end
--Unit in Vehicle
if self.unitTarget:IsInVehicle() then
strAttachment = "Vehicle"
end
--Iconic and Max Level Players
local idArchetype = unitTarget:GetArchetype() and unitTarget:GetArchetype().idArchetype or 0
local strFaction = karFactionToString[unitTarget:GetFaction()] or ""
if (idArchetype == knIconicArchetype or (unitTarget:GetType() == "Player" and unitTarget:GetLevel() == knMaxLevel)) then
strAttachment = eDisposition == Unit.CodeEnumDisposition.Friendly and "FriendlyIconic" or "HostileIconic"
strAttachment = strAttachment .. strFaction
end
self.wndLargeFrame:FindChild("Attachment"):SetSprite("spr_TargetFrame_Frame"..strAttachment..strFlipped)
-- self.wndLargeFrame:FindChild("Backer"):SetSprite("spr_TargetFrame_Frame"..strDisposition..strFlipped)
if (unitTarget:IsDead() or (unitTarget:IsTagged() and not unitTarget:IsTaggedByMe())) then
-- self.wndLargeFrame:FindChild("Backer"):SetSprite("spr_TargetFrame_FrameTapped"..strFlipped)
end
local unitToT = unitTarget:GetTarget()
if unitToT ~= nil then
local eToTDisposition = unitToT:GetDispositionTo(GameLib.GetPlayerUnit())
if eToTDisposition == Unit.CodeEnumDisposition.Hostile then
-- self.wndToTFrame:FindChild("Backer"):SetSprite("spr_TargetFrame_ToTHostile")
self.wndToTFrame:FindChild("DispositionFrame"):SetBGColor(ApolloColor.new("ffff6d66"))
elseif eToTDisposition == Unit.CodeEnumDisposition.Neutral then
-- self.wndToTFrame:FindChild("Backer"):SetSprite("spr_TargetFrame_ToTNeutral")
self.wndToTFrame:FindChild("DispositionFrame"):SetBGColor(ApolloColor.new("fffaff66"))
else
-- self.wndToTFrame:FindChild("Backer"):SetSprite("spr_TargetFrame_ToTFriendly")
self.wndToTFrame:FindChild("DispositionFrame"):SetBGColor(ApolloColor.new("ff00f7de"))
end
self.wndToTFrame:FindChild("DispositionFrame"):SetTooltip(ktDispositionToTTooltip[eToTDisposition])
end
-- self.wndLargeFrame:FindChild("Backer"):SetBGColor(ApolloColor.new("992b273d"))
--todo: Tooltips
local bSameFaction = GameLib.GetPlayerUnit():GetFaction() == unitTarget:GetFaction()
local crColorToUse = karDispositionColors[eDisposition]
-- Level / Diff
local nLevel = unitTarget:GetLevel()
if nLevel == nil then
wndFrame:FindChild("TargetLevel"):SetText(Apollo.GetString("CRB__2"))
wndFrame:FindChild("TargetLevel"):SetTextColor(karConInfo[1][2])
wndFrame:FindChild("TargetLevel"):SetTooltip("")
else
wndFrame:FindChild("TargetLevel"):SetText(unitTarget:GetLevel())
if unitTarget:IsScaled() then
wndFrame:FindChild("TargetScalingMark"):Show(true)
wndFrame:FindChild("TargetLevel"):SetTextColor(kcrScalingCColor)
if unitTarget ~= GameLib.GetPlayerUnit() then
strRewardFormatted = String_GetWeaselString(Apollo.GetString("TargetFrame_CreatureScales"), unitTarget:GetLevel())
local strLevelTooltip = self:HelperBuildTooltip(strRewardFormatted, Apollo.GetString("Adaptive"), kcrScalingHex)
wndFrame:FindChild("TargetLevel"):FindChild("TargetLevel"):SetTooltip(strLevelTooltip)
end
else
wndFrame:FindChild("TargetScalingMark"):Show(false)
local nCon = self:HelperCalculateConValue(unitTarget)
wndFrame:FindChild("TargetLevel"):SetTextColor(karConInfo[nCon][2])
if unitTarget ~= GameLib.GetPlayerUnit() then
strRewardFormatted = String_GetWeaselString(Apollo.GetString("TargetFrame_TargetXPReward"), karConInfo[nCon][4])
local strLevelTooltip = self:HelperBuildTooltip(strRewardFormatted, karConInfo[nCon][3], karConInfo[nCon][5])
wndFrame:FindChild("TargetLevel"):FindChild("TargetLevel"):SetTooltip(strLevelTooltip)
end
end
end
local strUnitType = unitTarget:GetType()
if strUnitType == "Player" or strUnitType == "Pet" or strUnitType == "Esper Pet" then
local unitPlayer = unitTarget:GetUnitOwner() or unitTarget
if eDisposition == Unit.CodeEnumDisposition.Friendly or unitPlayer:IsThePlayer() then
if unitPlayer:IsPvpFlagged() then
crColorToUse = kcrFlaggedFriendlyTextColor
elseif unitPlayer:IsInYourGroup() then
crColorToUse = kcrGroupTextColor
else
crColorToUse = kcrDefaultUnflaggedAllyTextColor
end
else
local bIsUnitFlagged = unitPlayer:IsPvpFlagged()
local bAmIFlagged = GameLib.IsPvpFlagged()
if not bAmIFlagged and not bIsUnitFlagged then
crColorToUse = kcrNeutralEnemyTextColor
elseif (bAmIFlagged and not bIsUnitFlagged) or (not bAmIFlagged and bIsUnitFlagged) then
crColorToUse = kcrAggressiveEnemyTextColor
end
end
wndFrame:FindChild("GroupSizeMark"):Show(false)
wndFrame:FindChild("TargetName"):SetTextColor(VColor(crColorToUse))
else -- NPC
wndFrame:FindChild("GroupSizeMark"):Show(unitTarget:GetGroupValue() > 0)
wndFrame:FindChild("GroupSizeMark"):SetText(unitTarget:GetGroupValue())
local strGroupTooltip = self:HelperBuildTooltip(String_GetWeaselString(Apollo.GetString("TargetFrame_GroupSize"), unitTarget:GetGroupValue()), String_GetWeaselString(Apollo.GetString("TargetFrame_Man"), unitTarget:GetGroupValue()))
wndFrame:FindChild("GroupSizeMark"):SetTooltip(strGroupTooltip)
end
-- Interrupt Armor
---------------------------------------------------------------------------
local nCCArmorValue = unitTarget:GetInterruptArmorValue()
local nCCArmorMax = unitTarget:GetInterruptArmorMax()
local wndCCArmor = wndFrame:FindChild("CCArmor")