-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathVikingGroupDisplay.lua
1676 lines (1360 loc) · 68.3 KB
/
VikingGroupDisplay.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
-----------------------------------------------------------------------------------------------
-- Client Lua Script for VikingGroupDisplayOptions
-- Copyright (c) NCsoft. All rights reserved
-----------------------------------------------------------------------------------------------
require "Window"
require "Unit"
require "GroupLib"
require "GameLib"
require "Tooltip"
require "PlayerPathLib"
require "ChatSystemLib"
require "MatchingGame"
local VikingGroupDisplay = {}
-- let's create some member variables
local tColors = {
black = ApolloColor.new("ff201e2d"),
white = ApolloColor.new("ffffffff"),
lightGrey = ApolloColor.new("ffbcb7da"),
green = ApolloColor.new("cc06ff5e"),
yellow = ApolloColor.new("ffffd161"),
lightPurple = ApolloColor.new("ff645f7e"),
purple = ApolloColor.new("ff28253a"),
red = ApolloColor.new("ffe05757"),
blue = ApolloColor.new("cc49e8ee")
}
local knHealthRed = 0.3
local knHealthYellow = 0.5
local ktInvitePathIcons = -- NOTE: ID's are zero-indexed in CPP
{
[PlayerPathLib.PlayerPathType_Soldier] = "Icon_Windows_UI_CRB_Soldier",
[PlayerPathLib.PlayerPathType_Settler] = "Icon_Windows_UI_CRB_Colonist",
[PlayerPathLib.PlayerPathType_Scientist] = "Icon_Windows_UI_CRB_Scientist",
[PlayerPathLib.PlayerPathType_Explorer] = "Icon_Windows_UI_CRB_Explorer"
}
local ktSmallInvitePathIcons = -- NOTE: ID's are zero-indexed in CPP
{
[PlayerPathLib.PlayerPathType_Soldier] = "Icon_Windows_UI_CRB_Soldier_Small",
[PlayerPathLib.PlayerPathType_Settler] = "Icon_Windows_UI_CRB_Colonist_Small",
[PlayerPathLib.PlayerPathType_Scientist] = "Icon_Windows_UI_CRB_Scientist_Small",
[PlayerPathLib.PlayerPathType_Explorer] = "Icon_Windows_UI_CRB_Explorer_Small"
}
local ktInviteClassIcons =
{
[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 karMessageIconString =
{
"MessageIcon_Sent",
"MessageIcon_Deny",
"MessageIcon_Accept",
"MessageIcon_Joined",
"MessageIcon_Left",
"MessageIcon_Promoted",
"MessageIcon_Kicked",
"MessageIcon_Disbanded",
"MessageIcon_Error"
}
local ktMessageIcon =
{
Sent = 1,
Deny = 2,
Accept = 3,
Joined = 4,
Left = 5,
Promoted = 6,
Kicked = 7,
Disbanded = 8,
Error = 9
}
local ktActionResultStrings =
{
[GroupLib.ActionResult.LeaveFailed] = {strMsg = Apollo.GetString("Group_LeaveFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.DisbandFailed] = {strMsg = Apollo.GetString("Group_DisbandFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.KickFailed] = {strMsg = Apollo.GetString("Group_KickFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.PromoteFailed] = {strMsg = Apollo.GetString("Group_PromoteFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.FlagsFailed] = {strMsg = Apollo.GetString("Group_FlagsFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MemberFlagsFailed] = {strMsg = Apollo.GetString("Group_MemberFlagsFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.NotInGroup] = {strMsg = Apollo.GetString("Group_NotInGroup"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.ChangeSettingsFailed] = {strMsg = Apollo.GetString("Group_SettingsFailed"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MentoringInvalidMentor] = {strMsg = Apollo.GetString("Group_MentorInvalid"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MentoringInvalidMentee] = {strMsg = Apollo.GetString("Group_MenteeInvalid"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.InvalidGroup] = {strMsg = Apollo.GetString("Group_InvalidGroup"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MentoringSelf] = {strMsg = Apollo.GetString("Group_MentorSelf"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.ReadyCheckFailed] = {strMsg = Apollo.GetString("Group_ReadyCheckFailed"), strIcon = ktMessageIcon.Accept},
[GroupLib.ActionResult.MentoringNotAllowed] = {strMsg = Apollo.GetString("Group_MentorDisabled"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MarkingNotPermitted] = {strMsg = Apollo.GetString("Group_CantMark"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.InvalidMarkIndex] = {strMsg = Apollo.GetString("Group_InvalidMarkIndex"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.InvalidMarkTarget] = {strMsg = Apollo.GetString("Group_InvalidMarkTarget"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MentoringInCombat] = {strMsg = Apollo.GetString("Group_MentoringInCombat"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.MentoringLowestLevel] = {strMsg = Apollo.GetString("Group_LowestLevel"), strIcon = ktMessageIcon.Error},
[GroupLib.ActionResult.AlreadyInGroupInstance] = {strMsg = Apollo.GetString("AlreadyInGroupInstance"), strIcon = ktMessageIcon.Error},
}
local ktInviteResultStrings =
{
[GroupLib.Result.Sent] = {strMsg = Apollo.GetString("GroupInviteSent"), strIcon = ktMessageIcon.Sent},
[GroupLib.Result.NoPermissions] = {strMsg = Apollo.GetString("GroupInviteNoPermission"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.PlayerNotFound] = {strMsg = Apollo.GetString("GroupPlayerNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.RealmNotFound] = {strMsg = Apollo.GetString("GroupRealmNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Grouped] = {strMsg = Apollo.GetString("GroupPlayerAlreadyGrouped"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Pending] = {strMsg = Apollo.GetString("GroupInvitePending"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInviter] = {strMsg = Apollo.GetString("GroupInviteExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInvitee] = {strMsg = Apollo.GetString("GroupYourInviteExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.InvitedYou] = {strMsg = Apollo.GetString("CRB_GroupInviteAlreadyInvited"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.IsInvited] = {strMsg = Apollo.GetString("Group_AlreadyInvited"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.NoInvitingSelf] = {strMsg = Apollo.GetString("Group_NoSelfInvite"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Full] = {strMsg = Apollo.GetString("Group_GroupFull"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.RoleFull] = {strMsg = Apollo.GetString("Group_RoleFull"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Declined] = {strMsg = Apollo.GetString("GroupInviteDeclined"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Accepted] = {strMsg = Apollo.GetString("Group_InviteAccepted"), strIcon = ktMessageIcon.Accept},
[GroupLib.Result.NotAcceptingRequests] = {strMsg = Apollo.GetString("Group_NotAcceptingRequests"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Busy] = {strMsg = Apollo.GetString("Group_Busy"), strIcon = ktMessageIcon.Deny},
}
local ktJoinRequestResultStrings =
{
[GroupLib.Result.Sent] = {strMsg = Apollo.GetString("GroupJoinRequestSent"), strIcon = ktMessageIcon.Sent},
[GroupLib.Result.PlayerNotFound] = {strMsg = Apollo.GetString("GroupPlayerNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.RealmNotFound] = {strMsg = Apollo.GetString("GroupRealmNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Grouped] = {strMsg = Apollo.GetString("GroupJoinRequestGroup"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Pending] = {strMsg = Apollo.GetString("GroupJoinRequestPending"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInviter] = {strMsg = Apollo.GetString("GroupJoinRequestExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInvitee] = {strMsg = Apollo.GetString("GroupYourJoinRequestExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.InvitedYou] = {strMsg = Apollo.GetString("CRB_GroupJoinAlreadyRequested"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.NoInvitingSelf] = {strMsg = Apollo.GetString("Group_NoSelfJoinRequest"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Full] = {strMsg = Apollo.GetString("Group_GroupFull"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Declined] = {strMsg = Apollo.GetString("GroupJoinRequestDenied"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Accepted] = {strMsg = Apollo.GetString("Group_JoinRequestAccepted"), strIcon = ktMessageIcon.Accept},
[GroupLib.Result.ServerControlled] = {strMsg = Apollo.GetString("Group_JoinRequest_ServerControlled"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.GroupNotFound] = {strMsg = Apollo.GetString("Group_JoinRequest_GroupNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.NotAcceptingRequests] = {strMsg = Apollo.GetString("Group_NotAcceptingRequests"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Busy] = {strMsg = Apollo.GetString("Group_Busy"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.SentToLeader] = {strMsg = Apollo.GetString("Group_SentToLeader"), strIcon = ktMessageIcon.Sent},
[GroupLib.Result.LeaderOffline] = {strMsg = Apollo.GetString("Group_LeaderOffline"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.WrongFaction] = {strMsg = Apollo.GetString("GroupWrongFaction"), strIcon = ktMessageIcon.Deny},
}
local ktReferralStrings =
{
[GroupLib.Result.PlayerNotFound] = {strMsg = Apollo.GetString("GroupPlayerNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.RealmNotFound] = {strMsg = Apollo.GetString("GroupRealmNotFound"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Grouped] = {strMsg = Apollo.GetString("GroupPlayerAlreadyGrouped"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Pending] = {strMsg = Apollo.GetString("GroupInvitePending"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInviter] = {strMsg = Apollo.GetString("GroupJoinRequestExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.ExpiredInvitee] = {strMsg = Apollo.GetString("GroupYourJoinRequestExpired"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.InvitedYou] = {strMsg = Apollo.GetString("CRB_GroupJoinAlreadyRequested"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.NoInvitingSelf] = {strMsg = Apollo.GetString("Group_NoSelfInvite"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.Full] = {strMsg = Apollo.GetString("Group_GroupFull"), strIcon = ktMessageIcon.Error},
[GroupLib.Result.NotAcceptingRequests] = {strMsg = Apollo.GetString("Group_NotAcceptingRequests"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Busy] = {strMsg = Apollo.GetString("Group_Busy"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.SentToLeader] = {strMsg = Apollo.GetString("Group_SentToLeader"), strIcon = ktMessageIcon.Sent},
[GroupLib.Result.LeaderOffline] = {strMsg = Apollo.GetString("Group_LeaderOffline"), strIcon = ktMessageIcon.Deny},
[GroupLib.Result.Declined] = {strMsg = Apollo.GetString("GroupInviteRequestDeclined"), strIcon = ktMessageIcon.Deny},
}
local ktGroupLeftResultStrings =
{
[GroupLib.RemoveReason.Kicked] = {strMsg = Apollo.GetString("Group_Kicked"), strIcon = ktMessageIcon.Kicked},
[GroupLib.RemoveReason.VoteKicked] = {strMsg = Apollo.GetString("Group_Kicked"), strIcon = ktMessageIcon.Kicked},
[GroupLib.RemoveReason.Left] = {strMsg = Apollo.GetString("InstancePartyLeave"), strIcon = ktMessageIcon.Left},
[GroupLib.RemoveReason.Disband] = {strMsg = Apollo.GetString("GroupDisband"), strIcon = ktMessageIcon.Disbanded},
[GroupLib.RemoveReason.RemovedByServer] = {strMsg = Apollo.GetString("Group_KickedByServer"), strIcon = ktMessageIcon.Left},
}
local ktLootRules =
{
[GroupLib.LootRule.Master] = Apollo.GetString("Group_MasterLoot"),
[GroupLib.LootRule.RoundRobin] = Apollo.GetString("Group_RoundRobin"),
[GroupLib.LootRule.NeedBeforeGreed] = Apollo.GetString("Group_NeedBeforeGreed"),
[GroupLib.LootRule.FreeForAll] = Apollo.GetString("Group_FFA")
}
local ktHarvestLootRules =
{
[GroupLib.HarvestLootRule.FirstTagger] = Apollo.GetString("Group_FFA"),
[GroupLib.HarvestLootRule.RoundRobin] = Apollo.GetString("Group_RoundRobin"),
}
local ktLootThreshold =
{
[Item.CodeEnumItemQuality.Inferior] = Apollo.GetString("CRB_Inferior"),
[Item.CodeEnumItemQuality.Average] = Apollo.GetString("CRB_Average"),
[Item.CodeEnumItemQuality.Good] = Apollo.GetString("CRB_Good"),
[Item.CodeEnumItemQuality.Excellent] = Apollo.GetString("CRB_Excellent"),
[Item.CodeEnumItemQuality.Superb] = Apollo.GetString("CRB_Superb"),
[Item.CodeEnumItemQuality.Legendary] = Apollo.GetString("CRB_Legendary"),
[Item.CodeEnumItemQuality.Artifact] = Apollo.GetString("CRB_Artifact")
}
local ktDifficulty =
{
[GroupLib.Difficulty.Normal] = Apollo.GetString("CRB_Normal"),
[GroupLib.Difficulty.Veteran] = Apollo.GetString("CRB_Veteran")
}
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 kfMessageDuration = 3.000
local kfDelayDuration = 0.010
local knInviteTimeout = 29 -- how long until an invite times out (display only, minus one to give code time to start)
local knMentorTimeout = 29 -- how long until an invite times out (display only, minus one to give code time to start)
local knGroupMax = 5 -- max number of people in a group
local knInviteMax = knGroupMax - 1 -- how many people can be invited
local knSaveVersion = 1
---------------------------------------------------------------------------------------------------
-- VikingGroupDisplay initialization
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:new(o)
o = o or {}
setmetatable(o, self)
self.__index = self
o.GroupMemberCount = 0
o.nGroupMemberClicked = nil
o.tGroupUnits = {}
return o
end
function VikingGroupDisplay:Init()
local tDependencies = { "VikingLibrary" }
Apollo.RegisterAddon(self, false, "", tDependencies)
end
function VikingGroupDisplay:OnSave(eType)
if eType ~= GameLib.CodeEnumAddonSaveLevel.Character then
return
end
local locInviteLocation = self.wndGroupInviteDialog and self.wndGroupInviteDialog:GetLocation() or self.locSavedInviteLoc
local locMentorLocation = self.wndMentor and self.wndMentor:GetLocation() or self.locSavedMentorLoc
local tSave =
{
tInviteLocation = locInviteLocation and locInviteLocation:ToTable() or nil,
tMentorLocation = locMentorLocation and locMentorLocation:ToTable() or nil,
bNeverShowRaidConvertNotice = self.bNeverShowRaidConvertNotice or false,
fInviteTimerStart = self.fInviteTimerStartTime,
strInviterName = self.strInviterName,
fMentorTimerStart = self.fMentorTimerStartTime,
nSaveVersion = knSaveVersion,
}
return tSave
end
function VikingGroupDisplay:OnRestore(eType, tSavedData)
if not tSavedData or tSavedData.nSaveVersion ~= knSaveVersion then
return
end
self.bNeverShowRaidConvertNotice = tSavedData.bNeverShowRaidConvertNotice or false
if tSavedData.tInviteLocation then
self.locSavedInviteLoc = WindowLocation.new(tSavedData.tInviteLocation)
end
if tSavedData.tMentorLocation then
self.locSavedMentorLoc = WindowLocation.new(tSavedData.tMentorLocation)
end
if tSavedData.fInviteTimerStart then
local tInviteData = GroupLib.GetInvite()
if tInviteData and #tInviteData > 0 then
self.fInviteTimerStartTime = tSavedData.fInviteTimerStart
self.strInviterName = tSavedData.strInviterName or ""
end
end
if tSavedData.fMentorTimerStart then
local tMentorData = GroupLib.GetMentoringList()
if tMentorData and #tMentorData > 0 then
self.fMentorTimerStartTime = tSavedData.fMentorTimerStart
end
end
end
---------------------------------------------------------------------------------------------------
-- VikingGroupDisplay EventHandlers
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:OnLoad()
self.xmlOptionsDoc = XmlDoc.CreateFromFile("VikingGroupDisplayOptions.xml")
self.xmlDoc = XmlDoc.CreateFromFile("VikingGroupDisplay.xml")
self.xmlDoc:RegisterCallback("OnDocumentReady", self)
end
function VikingGroupDisplay:OnDocumentReady()
if self.xmlDoc == nil then
return
end
Apollo.RegisterEventHandler("WindowManagementReady" , "OnWindowManagementReady" , self)
Apollo.RegisterEventHandler("WindowManagementUpdate" , "OnWindowManagementUpdate" , self)
Apollo.RegisterEventHandler("Group_Invited", "OnGroupInvited", self) -- ( name )
Apollo.RegisterEventHandler("Group_Invite_Result", "OnGroupInviteResult", self) -- ( name, result )
Apollo.RegisterEventHandler("Group_JoinRequest", "OnGroupJoinRequest", self) -- ( name )
Apollo.RegisterEventHandler("Group_Referral", "OnGroupReferral", self) -- ( nMemberIndex, name )
Apollo.RegisterEventHandler("Group_Request_Result", "OnGroupRequestResult", self) -- ( name, result, bIsJoin )
Apollo.RegisterEventHandler("Group_Join", "OnGroupJoin", self) -- ()
Apollo.RegisterEventHandler("Group_Add", "OnGroupAdd", self) -- ( name )
Apollo.RegisterEventHandler("Group_Remove", "OnGroupRemove", self) -- ( name, reason )
Apollo.RegisterEventHandler("Group_Left", "OnGroupLeft", self) -- ( reason )
Apollo.RegisterEventHandler("Group_MemberFlagsChanged", "OnGroupMemberFlags", self) -- ( nMemberIndex, bIsFromPromotion, tChangedFlags)
Apollo.RegisterEventHandler("Group_MemberPromoted", "OnGroupMemberPromoted", self) -- ( name, bSelf )
Apollo.RegisterEventHandler("Group_Operation_Result", "OnGroupOperationResult", self) -- ( name, action )
Apollo.RegisterEventHandler("Group_Updated", "OnGroupUpdated", self) -- ()
Apollo.RegisterEventHandler("Group_FlagsChanged", "OnGroupUpdated", self) -- ()
Apollo.RegisterEventHandler("Group_LootRulesChanged", "OnGroupLootRulesChanged", self) -- ()
Apollo.RegisterEventHandler("Group_AcceptInvite", "OnGroupAcceptInvite", self) -- ()
Apollo.RegisterEventHandler("Group_DeclineInvite", "OnGroupDeclineInvite", self) -- ()
Apollo.RegisterEventHandler("Group_Mentor", "OnGroupMentor", self) -- ( tMemberList, bAlreadyMentoring )
Apollo.RegisterEventHandler("Group_MentorLeftAOI", "OnGroupMentorLeftAOI", self) -- ( nTimeUntilMentoringDisabled, bClearUI )
Apollo.RegisterEventHandler("LootRollUpdate", "OnLootRollUpdate", self) -- ()
Apollo.RegisterEventHandler("Group_ReadyCheck", "OnGroupReadyCheck", self) -- ( nMemberIndex, strMessage )
Apollo.RegisterEventHandler("RaidInfoResponse", "OnRaidInfoResponse", self) -- ( arRaidInfo )
Apollo.RegisterEventHandler("MasterLootUpdate", "OnMasterLootUpdate", self)
Apollo.RegisterTimerHandler("InviteTimer", "OnInviteTimer", self)
Apollo.RegisterTimerHandler("GroupMessageDelayTimer", "ProcessAlerts", self)
Apollo.RegisterTimerHandler("GroupMessageTimer", "OnGroupMessageTimer", self)
Apollo.RegisterTimerHandler("MentorTimer", "OnMentorTimer", self)
Apollo.RegisterTimerHandler("MentorAOITimer", "OnMentorAOITimer", self)
Apollo.RegisterTimerHandler("GroupUpdateTimer", "OnUpdateTimer", self)
Apollo.CreateTimer("GroupUpdateTimer", 0.050, true)
Apollo.StopTimer("GroupUpdateTimer")
Apollo.RegisterEventHandler("GenericEvent_AttachWindow_VikingGroupDisplayOptions", "AttachWindowVikingGroupDisplayOptions", self)
Apollo.RegisterEventHandler("GenericEvent_ShowConfirmLeaveDisband", "ShowConfirmLeaveDisband", self)
---------------------------------------------------------------------------------------------------
-- VikingGroupDisplay Member Variables
---------------------------------------------------------------------------------------------------
self.wndGroupHud = Apollo.LoadForm(self.xmlDoc, "GroupHud", "FixedHudStratum", self)
self.wndGroupHud:Show(false, true)
self.wndLeaveGroup = self.wndGroupHud:FindChild("GroupHudLeaveDialog")
self.wndLeaveGroup:Show(false,true)
self.wndGroupMessage = self.wndGroupHud:FindChild("GroupHudMessage")
self.bMessagesQueued = false
self.tMessageQueue = {nFirst = 0, nLast = -1}
self.wndGroupPortraitContainer = self.wndGroupHud:FindChild("GroupPortraitContainer")
Hide=1
function HidePortrait ()
if Hide==0 then
self.wndGroupPortraitContainer:Show (false, true)
end
if Hide==1 then
self.wndGroupPortraitContainer:Show (true, false)
end
end
self.wndGroupInviteDialog = Apollo.LoadForm(self.xmlDoc, "GroupInviteDialog", nil, self)
self.wndGroupInviteDialog:Show(false, true)
if self.locSavedInviteLoc then
self.wndGroupInviteDialog:MoveToLocation(self.locSavedInviteLoc)
end
self.wndInviteMemberList = self.wndGroupInviteDialog:FindChild("InviteMemberList")
self.nInviteTimer = knInviteTimeout
self.eChatChannel = ChatSystemLib.ChatChannel_Party
self.wndGroupInviteDialog:Show(false)
if self.fInviteTimerStartTime then
self:OnGroupInvited(self.strInviterName)
end
self.tGroupWndPortraits = {}
self.eInstanceDifficulty = GroupLib.GetInstanceDifficulty()
self.tLootRules = GroupLib.GetLootRules()
self.wndMentor = Apollo.LoadForm(self.xmlDoc, "GroupMentorDialog", nil, self)
self.wndMentor:Show(false, true)
if self.locSavedMentorLoc then
self.wndMentor:MoveToLocation(self.locSavedMentorLoc)
end
if self.fMentorTimerStartTime then
self:OnGroupMentor(GroupLib.GetMentoringList(), GameLib:GetPlayerUnit():IsMentoring(), false)
end
self.wndMentorAOI = Apollo.LoadForm(self.xmlDoc, "GroupMentorLeftAoIDialog", nil, self)
self.wndMentorAOI:Show(false, true)
self.wndRequest = Apollo.LoadForm(self.xmlDoc, "GroupRequestDialog", nil, self)
self.wndRequest:Show(false, true)
--self.unitGroupMemberClicked = nil
self:OnGroupUpdated()
---------------------------------------------------------------------------------------------------
-- VikingGroupDisplay Setup
---------------------------------------------------------------------------------------------------
for idx = 1, #karMessageIconString do
self.wndGroupMessage:FindChild(karMessageIconString[idx]):Show(false)
end
self.wndRequest:Show(false)
Event_FireGenericEvent("GenericEvent_InitializeGroupLeaderOptions", self.wndGroupHud:FindChild("GroupControlsBtn"))
-- TEMP HACK: Try again in case this loads first
Apollo.RegisterTimerHandler("VikingGroupDisplayOptions_TEMP", "VikingGroupDisplayOptions_TEMP", self)
Apollo.CreateTimer("VikingGroupDisplayOptions_TEMP", 3, false)
Apollo.StartTimer("VikingGroupDisplayOptions_TEMP")
if GroupLib.InGroup() then
if GroupLib.InRaid() then
self:OnUpdateTimer()
else
Apollo.StartTimer("GroupUpdateTimer")
end
end
end
function VikingGroupDisplay:OnWindowManagementReady()
Event_FireGenericEvent("WindowManagementAdd", { wnd = self.wndGroupHud, strName = "Viking Group Hud" })
end
function VikingGroupDisplay:OnWindowManagementUpdate(tWindow)
end
function VikingGroupDisplay:VikingGroupDisplayOptions_TEMP()
-- TEMP HACK: Try again in case this loads first
Event_FireGenericEvent("GenericEvent_InitializeGroupLeaderOptions", self.wndGroupHud:FindChild("GroupControlsBtn"))
end
---------------------------------------------------------------------------------------------------
-- Functions
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:LoadPortrait(idx)
local wndHud = Apollo.LoadForm(self.xmlDoc, "GroupPortraitHud", self.wndGroupPortraitContainer)
self.tGroupWndPortraits[idx] =
{
idx = idx,
wndHud = wndHud,
wndLeader = wndHud:FindChild("Leader"),
wndName = wndHud:FindChild("Name"),
wndClass = wndHud:FindChild("Class"),
wndHealth = wndHud:FindChild("Health"),
wndShields = wndHud:FindChild("Shields"),
wndMaxShields = wndHud:FindChild("MaxShields"),
wndMaxAbsorb = wndHud:FindChild("MaxAbsorbBar"),
wndLowHealthFlash = wndHud:FindChild("LowHealthFlash"),
wndPathIcon = wndHud:FindChild("PathIcon"),
wndOffline = wndHud:FindChild("Offline"),
wndMark = wndHud:FindChild("Mark")
}
self.tGroupWndPortraits[idx].wndHud:Show(false)
-- We apparently resize bars rather than set progress
self:SetBarValue(self.tGroupWndPortraits[idx].wndHealth, 0, 100, 100)
self:SetBarValue(self.tGroupWndPortraits[idx].wndShields, 0, 100, 100)
if self.nFrameLeft == nil then
self.nFrameLeft, self.nFrameTop, self.nFrameRight, self.nFrameBottom = self.tGroupWndPortraits[idx].wndHealth:GetAnchorOffsets()
self.nShieldFrameLeft, self.nShieldFrameTop, self.nShieldFrameRight, self.nShieldFrameBottom = self.tGroupWndPortraits[idx].wndShields:GetAnchorOffsets()
self.nMaxShieldFrameLeft, self.nMaxShieldFrameTop, self.nMaxShieldFrameRight, self.nMaxShieldFrameBottom = self.tGroupWndPortraits[idx].wndMaxShields:GetAnchorOffsets()
self.nMaxAbsorbFrameLeft, self.nMaxAbsorbFrameTop, self.nMaxAbsorbFrameRight, self.nMaxAbsorbFrameBottom = self.tGroupWndPortraits[idx].wndMaxAbsorb:GetAnchorOffsets()
end
self.tGroupWndPortraits[idx].wndHud:SetData(idx)
self.tGroupWndPortraits[idx].wndHud:FindChild("GroupPortraitBtn"):SetData(idx)
self:HelperResizeGroupContents()
end
---------------------------------------------------------------------------------------------------
-- Recieved an Invitation
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:OnGroupInvited(strInviterName) -- builds the invite when I recieve it
ChatSystemLib.PostOnChannel(self.eChatChannel, String_GetWeaselString(Apollo.GetString("GroupInvite"), strInviterName), "")
self.strInviterName = strInviterName
self.wndInviteMemberList:DestroyChildren()
local arInvite = GroupLib.GetInvite()
for idx, tMemberInfo in ipairs(arInvite) do-- display group members in an invite
if tMemberInfo ~= nil then
local wndEntry = ""
if tMemberInfo.bIsLeader then -- choose a frame
wndEntry = Apollo.LoadForm(self.xmlDoc, "GroupInviteLeader", self.wndInviteMemberList, self)
else
wndEntry = Apollo.LoadForm(self.xmlDoc, "GroupInviteMember", self.wndInviteMemberList, self)
end
wndEntry:FindChild("InviteMemberLevel"):SetText(tMemberInfo.nLevel)
wndEntry:FindChild("InviteMemberName"):SetText(tMemberInfo.strCharacterName)
wndEntry:FindChild("InviteMemberPathIcon"):SetSprite(ktInvitePathIcons[tMemberInfo.ePathType])
local strSpriteToUse = "CRB_GroupSprites:sprGrp_MFrameIcon_Axe"
if ktInviteClassIcons[tMemberInfo.eClassId] then
strSpriteToUse = ktInviteClassIcons[tMemberInfo.eClassId]
end
wndEntry:FindChild("InviteMemberClass"):SetSprite(strSpriteToUse)
end
end
local nOpenSlots = knInviteMax - table.getn(arInvite) -- how many slots are open
if nOpenSlots > 0 then -- make sure it's not running a negative
for nBlankEntry = 1, nOpenSlots do -- populate the interface
local wndBlankEntry = Apollo.LoadForm(self.xmlDoc, "GroupInviteBlank", self.wndInviteMemberList, self)
end
end
self.wndInviteMemberList:ArrangeChildrenVert()
if not self.fInviteTimerStartTime then
self.fInviteTimerStartTime = os.clock()
end
self.fInviteTimerDelta = os.clock() - self.fInviteTimerStartTime
self.wndGroupInviteDialog:FindChild("Timer"):SetText("")
local strTime = string.format("%d:%02d", math.floor(self.fInviteTimerDelta / 60), math.ceil(30 - (self.fInviteTimerDelta % 60)))
self.wndGroupInviteDialog:FindChild("Timer"):SetText(String_GetWeaselString(Apollo.GetString("Group_ExpiresTimer"), strTime))
Apollo.CreateTimer("InviteTimer", 1.000, true)
self.wndGroupInviteDialog:Invoke(true)
Sound.Play(Sound.PlayUISocialPartyInviteSent)
end
function VikingGroupDisplay:OnGroupJoinRequest(strInviterName) -- builds the invite when I recieve it
-- undone need token passed as context
--Apollo.DPF("VikingGroupDisplay:OnGroupJoinRequest")
-- a join message means that someone has requested to join our existing party
local str = String_GetWeaselString(Apollo.GetString("GroupJoinRequest"), strInviterName)
self.wndRequest:FindChild("Title"):SetText(str)
self.wndRequest:Show(true)
ChatSystemLib.PostOnChannel(self.eChatChannel, str, "")
end
function VikingGroupDisplay:OnGroupReferral(nMemberIndex, strTarget) -- builds the invite when I receive it
-- undone need token passed as context
--Apollo.DPF("VikingGroupDisplay:OnGroupReferral")
-- a join message means that someone has requested to join our existing party
local str = String_GetWeaselString(Apollo.GetString("GroupReferral"), strTarget)
self.wndRequest:FindChild("Title"):SetText(str)
self.wndRequest:Show(true)
ChatSystemLib.PostOnChannel(self.eChatChannel, str, "")
end
function VikingGroupDisplay:OnInviteTimer()
self.fInviteTimerDelta = self.fInviteTimerDelta + 1
if self.fInviteTimerDelta <= 31 then
local strTime = string.format("%d:%02d", math.floor(self.fInviteTimerDelta / 60), math.ceil(30 - (self.fInviteTimerDelta % 60)))
self.wndGroupInviteDialog:FindChild("Timer"):SetText(String_GetWeaselString(Apollo.GetString("Group_ExpiresTimer"), strTime))
else
self.wndGroupInviteDialog:FindChild("Timer"):SetText("X")
end
end
function VikingGroupDisplay:OnGroupInviteDialogAccept()
GroupLib.AcceptInvite()
self.wndGroupInviteDialog:Show(false)
self.fInviteTimerStartTime = nil
Apollo.StopTimer("InviteTimer")
Sound.Play(Sound.PlayUISocialPartyInviteAccept)
end
function VikingGroupDisplay:OnGroupInviteDialogDecline()
GroupLib.DeclineInvite()
self.wndGroupInviteDialog:Show(false)
self.fInviteTimerStartTime = nil
Apollo.StopTimer("InviteTimer")
Sound.Play(Sound.PlayUISocialPartyInviteDecline)
end
function VikingGroupDisplay:OnRaidInfoResponse(arRaidInfo)
if #arRaidInfo == 0 then
ChatSystemLib.PostOnChannel( ChatSystemLib.ChatChannel_System, Apollo.GetString("Command_UsageRaidInfoNone"), "" )
return
end
for _, tRaidInfo in ipairs(arRaidInfo) do
-- tRaidInfo.strWorldName can be nil
-- tRaidInfo.strSavedInstanceId is a string with a large number
-- tRaidInfo.nWorldId is the id of the instance
-- tRaidInfo.strDateExpireUTC is string of the full date the lock resets.
-- tRaidInfo.fDaysFromNow is relative time from now that the lock resets.
local strMessage = String_GetWeaselString(Apollo.GetString("Command_UsageRaidInfo"), tRaidInfo.strWorldName or "", tRaidInfo.strSavedInstanceId, tRaidInfo.strDateExpireUTC )
ChatSystemLib.PostOnChannel( ChatSystemLib.ChatChannel_System, strMessage, "" )
end
end
---------------------------------------------------------------------------------------------------
-- Group Formatting
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:DestroyGroup()
for idx, tMemberInfo in pairs(self.tGroupWndPortraits) do -- This is essentially self.wndGroupPortraitContainer:DestroyChildren()
if tMemberInfo.wndHud and tMemberInfo.wndHud:IsValid() then
tMemberInfo.wndHud:Destroy()
end
self.tGroupWndPortraits[idx] = nil
end
Apollo.StopTimer("GroupUpdateTimer")
local nMemberCount = GroupLib.GetMemberCount()
if nMemberCount <= 1 then
return
end
Apollo.StartTimer("GroupUpdateTimer")
self:OnGroupUpdated()
end
function VikingGroupDisplay:PostChangeToChannel(nPrevValue, nNextValue, tDescriptionTable, strChangeString, strUnknownChangeString)
if nPrevValue ~= nNextValue then
if tDescriptionTable[nNextValue] ~= nil then
ChatSystemLib.PostOnChannel(self.eChatChannel, String_GetWeaselString(strChangeString, tDescriptionTable[nNextValue]), "") --lua placeholder string
else
ChatSystemLib.PostOnChannel(self.eChatChannel, strUnknownChangeString, "") --lua placeholder string
end
end
end
function VikingGroupDisplay:OnGroupUpdated()
if GroupLib.InRaid() then
return
end
for idx, tPortrait in pairs(self.tGroupWndPortraits) do
tPortrait.wndHud:Show(false)
end
if GroupLib.InInstance() then
self.eChatChannel = ChatSystemLib.ChatChannel_Instance;
else
self.eChatChannel = ChatSystemLib.ChatChannel_Party;
end
if self.bDisplayedRaid == nil and GroupLib.InRaid() then
self.bDisplayedRaid = true
ChatSystemLib.PostOnChannel(self.eChatChannel, Apollo.GetString("Group_BecomeRaid"), "") --lua placeholder string
if self.wndRaidNotice and self.wndRaidNotice:IsValid() then
self.wndRaidNotice:Destroy()
self.wndRaidNotice = nil
end
if self.bNeverShowRaidConvertNotice == false then
self.wndRaidNotice = Apollo.LoadForm(self.xmlOptionsDoc, "RaidConvertedForm", nil, self)
self.wndRaidNotice:Show(true)
self.wndRaidNotice:ToFront()
end
end
self.eInstanceDifficulty = GroupLib.GetInstanceDifficulty()
self:PostChangeToChannel(self.eInstanceDifficulty, GroupLib.GetInstanceDifficulty(), ktDifficulty, Apollo.GetString("Group_DifficultyChangedTo"), Apollo.GetString("Group_DifficultyChangedDefault"))
-- Attach the portrait form to each hud slot.
if GroupLib.InGroup() and GroupLib.GetMemberCount() == 0 then
self.bDisplayedRaid = nil
self:HelperResizeGroupContents()
return
end
local unitMe = GameLib.GetPlayerUnit()
if unitMe == nil then
return
end
self.nGroupMemberCount = GroupLib.GetMemberCount()
local nCount = 0
if self.nGroupMemberCount > 0 then
for idx = 1, self.nGroupMemberCount do
local tMemberInfo = GroupLib.GetGroupMember(idx)
if tMemberInfo ~= nil then
if self.tGroupWndPortraits[idx] == nil then
self:LoadPortrait(idx)
end
self.tGroupWndPortraits[idx].wndHud:Show(true)
nCount = nCount + 1
end
end
end
if nCount == 0 then
self:CloseGroupHUD()
else
self.wndGroupHud:FindChild("GroupControlsBtn"):Show(true)
--self.wndGroupHud:FindChild("GroupBagBtn"):Show(true) -- TODO TEMP DISABLED
self.wndGroupHud:Show(true)
end
self:HelperResizeGroupContents()
end
function VikingGroupDisplay:OnGroupLootRulesChanged()
if GroupLib.InRaid() then
return
end
local tNewLootRules = GroupLib.GetLootRules()
self:PostChangeToChannel(self.tLootRules.eNormalRule, tNewLootRules.eNormalRule, ktLootRules, Apollo.GetString("Group_LootChangedTo"), Apollo.GetString("Group_LootChangedDefault"))
self:PostChangeToChannel(self.tLootRules.eThresholdRule, tNewLootRules.eThresholdRule, ktLootRules, Apollo.GetString("Group_ThresholdRuleChangedTo"), Apollo.GetString("Group_ThresholdRuleChangedDefault"))
self:PostChangeToChannel(self.tLootRules.eThresholdQuality, tNewLootRules.eThresholdQuality, ktLootThreshold, Apollo.GetString("Group_ThresholdQualityChangedTo"), Apollo.GetString("Group_ThresholdQualityChangedDefault"))
self:PostChangeToChannel(self.tLootRules.eHarvestRule, tNewLootRules.eHarvestRule, ktHarvestLootRules, Apollo.GetString("Group_HarvestLootChangedTo"), Apollo.GetString("Group_HarvestLootChangedDefault"))
self.tLootRules = tNewLootRules
end
function VikingGroupDisplay:OnGroupControlsCheck(wndHandler, wndControl)
Event_FireGenericEvent("GenericEvent_UpdateGroupLeaderOptions")
end
function VikingGroupDisplay:OnGroupPortraitClick(wndHandler, wndControl, eMouseButton)
local tInfo = wndHandler:GetData()
local nMemberIdx = tInfo[1]
local strName = tInfo[2] -- In case they run out of range and we lose the unitMember
local unitMember = GroupLib.GetUnitForGroupMember(nMemberIdx) --returns nil when the member is out of range among other reasons
if nMemberIdx and unitMember then
GameLib.SetTargetUnit(unitMember)
end
if eMouseButton == GameLib.CodeEnumInputMouse.Right then
Event_FireGenericEvent("GenericEvent_NewContextMenuPlayerDetailed", wndHandler, strName, unitMember) -- unitMember is optional
end
end
function VikingGroupDisplay:OnGroupBagBtn()
Event_FireGenericEvent("GenericEvent_ToggleGroupBag")
end
function VikingGroupDisplay:OnMasterLootUpdate()
local tMasterLoot = GameLib.GetMasterLoot()
if tMasterLoot and #tMasterLoot > 0 then
self.wndGroupHud:FindChild("GroupBagBtn"):Show(true)
self.wndGroupHud:FindChild("GroupBagBtn"):Enable(true)
else
self.wndGroupHud:FindChild("GroupBagBtn"):Show(false)
self.wndGroupHud:FindChild("GroupBagBtn"):Enable(false)
end
end
---------------------------------------------------------------------------------------------------
-- Per Player Options Menu (Promote/Kick/etc.)
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:OnKick()
if self.nGroupMemberClicked == nil then
return
end
GroupLib.Kick(self.nGroupMemberClicked, "")
end
function VikingGroupDisplay:OnLocate()
if self.nGroupMemberClicked == nil then
return
end
local unitMember = GroupLib.GetUnitForGroupMember(self.nGroupMemberClicked)
if unitMember then
unitMember:ShowHintArrow()
end
end
function VikingGroupDisplay:OnPromote()
if self.nGroupMemberClicked == nil then
return
end
GroupLib.Promote(self.nGroupMemberClicked, "")
end
function VikingGroupDisplay:ShowConfirmLeaveDisband(nType)
self.wndLeaveGroup:FindChild("ConfirmLeaveBtn"):Show(false)
self.wndLeaveGroup:FindChild("ConfirmDisbandBtn"):Show(false)
if nType == 0 then --disband
self.wndLeaveGroup:FindChild("LeaveText"):SetText(Apollo.GetString("CRB_Are_you_sure_you_want_to_disband_this_group"))
self.wndLeaveGroup:FindChild("ConfirmDisbandBtn"):Show(true)
else
self.wndLeaveGroup:FindChild("LeaveText"):SetText(Apollo.GetString("CRB_Are_you_sure_you_want_to_leave_this_group"))
self.wndLeaveGroup:FindChild("ConfirmLeaveBtn"):Show(true)
end
self.wndLeaveGroup:Show(true)
self:HelperResizeGroupContents()
end
function VikingGroupDisplay:OnLeaveGroup()
self:ShowConfirmLeaveDisband(1)
end
function VikingGroupDisplay:OnDisbandGroup()
self:ShowConfirmLeaveDisband(0)
end
function VikingGroupDisplay:OnConfirmLeave()
GroupLib.LeaveGroup()
self:DestroyGroup()
end
function VikingGroupDisplay:OnConfirmDisband()
if GroupLib.AmILeader() and not GroupLib.InInstance() then
GroupLib.DisbandGroup()
self:DestroyGroup()
end
end
function VikingGroupDisplay:OnCancelLeave()
self.wndLeaveGroup:Show(false)
self:HelperResizeGroupContents()
end
---------------------------------------------------------------------------------------------------
-- Format Members
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:DrawMemberPortrait(tPortrait, tMemberInfo)
if tPortrait == nil or tMemberInfo == nil then
return
end
local unitMember = GroupLib.GetUnitForGroupMember(tPortrait.idx)
local strName = tMemberInfo.strCharacterName
if not tMemberInfo.bIsOnline then
strName = String_GetWeaselString(Apollo.GetString("Group_OfflineMember"), strName)
elseif not unitMember then
strName = String_GetWeaselString(Apollo.GetString("Group_OutOfRangeMember"), strName)
end
if tMemberInfo.bTank then
strName = String_GetWeaselString(Apollo.GetString("Group_TankTag"), strName)
elseif tMemberInfo.bHealer then
strName = String_GetWeaselString(Apollo.GetString("Group_HealerTag"), strName)
elseif tMemberInfo.bDPS then
strName = String_GetWeaselString(Apollo.GetString("Group_DPSTag"), strName)
end
self.tGroupWndPortraits[tPortrait.idx].wndHud:FindChild("GroupPortraitBtn"):SetData({ tPortrait.idx, tMemberInfo.strCharacterName })
tPortrait.wndName:SetText(strName)
tPortrait.wndLeader:Show(tMemberInfo.bIsLeader)
tPortrait.wndClass:Show(tMemberInfo.bIsOnline)
tPortrait.wndPathIcon:Show(tMemberInfo.bIsOnline)
tPortrait.wndOffline:SetRotation(90)
tPortrait.wndOffline:Show(not tMemberInfo.bIsOnline)
tPortrait.wndHud:FindChild("DeadIndicator"):Show(bDead)
tPortrait.wndHud:FindChild("GroupPortraitHealthBG"):Show(tMemberInfo.nHealth > 0)
tPortrait.wndHud:FindChild("GroupDisabledFrame"):Show(false)
tPortrait.wndHud:FindChild("GroupPortraitBtn"):Show(true)
local unitTarget = GameLib.GetTargetUnit()
tPortrait.wndHud:FindChild("GroupPortraitBtn"):SetCheck(unitTarget and unitTarget == unitMember) --tPortrait.unitMember
local bDead = tMemberInfo.nHealth == 0 and tMemberInfo.nHealthMax ~= 0
if bDead or not tMemberInfo.bIsOnline then
tPortrait.wndName:SetTextColor(ApolloColor.new("ffb80000"))
else
tPortrait.wndName:SetTextColor(ApolloColor.new("ff7effb8"))
end
tPortrait.wndHud:FindChild("GroupPortraitArrangeVert"):ArrangeChildrenVert(1)
self:HelperUpdateHealth(tPortrait, tMemberInfo, unitMember)
-- Set the Path Icon
local strPathSprite = ""
if ktSmallInvitePathIcons[tMemberInfo.ePathType] then
strPathSprite = ktSmallInvitePathIcons[tMemberInfo.ePathType]
end
tPortrait.wndPathIcon:SetSprite(strPathSprite)
local strClassSprite = ""
if ktInviteClassIcons[tMemberInfo.eClassId] then
strClassSprite = ktInviteClassIcons[tMemberInfo.eClassId]
end
tPortrait.wndClass:SetSprite(strClassSprite)
tPortrait.wndMark:Show(tMemberInfo.nMarkerId ~= 0)
if tMemberInfo.nMarkerId ~= 0 then
tPortrait.wndMark:SetSprite(kstrRaidMarkerToSprite[tMemberInfo.nMarkerId])
end
end
function VikingGroupDisplay:HelperUpdateHealth(tPortrait, tMemberInfo, unitMember)
local nHealthCurr = tMemberInfo.nHealth
local nHealthMax = tMemberInfo.nHealthMax
local nShieldCurr = tMemberInfo.nShield
local nShieldMax = tMemberInfo.nShieldMax
local nAbsorbMax = tMemberInfo.nAbsorptionMax
local nAbsorbCurr = 0
if nAbsorbMax > 0 then
nAbsorbCurr = tMemberInfo.nAbsorption
end
local nTotalMax = nHealthMax + nShieldMax + nAbsorbMax
tPortrait.wndLowHealthFlash:Show(nHealthCurr ~= 0 and nHealthCurr / nHealthMax <= 0.25)
-- Scaling
local nPointHealthRight = self.nFrameRight * nHealthMax
local nPointShieldRight = self.nFrameRight * nShieldMax
local nPointAbsorbRight = self.nFrameRight * nAbsorbMax
-- Color
if unitMember and unitMember:IsInCCState(Unit.CodeEnumCCState.Vulnerability) then
tPortrait.wndHealth:SetBarColor(tColors.lightPurple)
elseif nHealthCurr / nHealthMax <= knHealthRed then
tPortrait.wndHealth:SetBarColor(tColors.red)
elseif nHealthCurr / nHealthMax <= knHealthYellow then
tPortrait.wndHealth:SetBarColor(tColors.yellow)
else
tPortrait.wndHealth:SetBarColor(tColors.green)
end
tPortrait.wndShields:SetBarColor(tColors.blue)
-- Resize
tPortrait.wndShields:EnableGlow(nShieldCurr > 0 and nShieldCurr ~= nShieldMax)
self:SetBarValue(tPortrait.wndHealth, 0, nHealthCurr, nHealthMax)
self:SetBarValue(tPortrait.wndShields, 0, nShieldCurr, nShieldMax) -- Only the Curr Shield really progress fills
self:SetBarValue(tPortrait.wndMaxAbsorb:FindChild("CurrAbsorbBar"), 0, nAbsorbCurr, nAbsorbMax)
tPortrait.wndHealth:SetAnchorOffsets(self.nFrameLeft, self.nFrameTop, nPointHealthRight, self.nFrameBottom)
tPortrait.wndMaxShields:SetAnchorOffsets(self.nFrameLeft, self.nMaxShieldFrameTop, nPointShieldRight, self.nMaxShieldFrameBottom)
tPortrait.wndMaxAbsorb:SetAnchorOffsets(self.nFrameLeft, self.nMaxAbsorbFrameTop, nPointAbsorbRight, self.nMaxAbsorbFrameBottom)
-- Bars
tPortrait.wndShields:Show(nHealthCurr > 0)
tPortrait.wndHealth:Show(nHealthCurr > 0) -- TODO: Temp The sprite draws poorly this low.
tPortrait.wndMaxShields:Show(nHealthCurr > 0 and nShieldMax > 0)
tPortrait.wndMaxAbsorb:Show(nHealthCurr > 0 and nAbsorbMax > 0)
end
function VikingGroupDisplay:SetBarValue(wndBar, fMin, fValue, fMax)
wndBar:SetMax(fMax)
wndBar:SetFloor(fMin)
wndBar:SetProgress(fValue)
end
---------------------------------------------------------------------------------------------------
-- OnUpdateTimer
---------------------------------------------------------------------------------------------------
function VikingGroupDisplay:OnUpdateTimer(strVar, nValue)
if GroupLib.InRaid() then -- TODO: Refactor, also free up memory
if self.wndGroupHud and self.wndGroupHud:IsValid() and self.wndGroupHud:IsShown() then
self.wndGroupHud:Show(false, true)
Apollo.StopTimer("GroupUpdateTimer")
end
return
end