-
Notifications
You must be signed in to change notification settings - Fork 3
/
ViragsSocialUI.lua
executable file
·1732 lines (1347 loc) · 64.4 KB
/
ViragsSocialUI.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
local ViragsSocial = Apollo.GetAddon("ViragsSocial")
local kSideBarTabsPosition = {
[ViragsSocial.TabGuild] = "Guild",
[ViragsSocial.TabFriends] = "Friends",
[ViragsSocial.TabIgnoreAndRivals] = "IgnoreAndRivals",
[ViragsSocial.TabNeighbors] = "Neighbors",
[ViragsSocial.TabCircle1] = "Circle1",
[ViragsSocial.TabCircle2] = "Circle2",
[ViragsSocial.TabCircle3] = "Circle3",
[ViragsSocial.TabCircle4] = "Circle4",
[ViragsSocial.TabCircle5] = "Circle5",
[ViragsSocial.Group] = "Group",
[ViragsSocial.Warplot] = "Warplot",
[ViragsSocial.Arena2v2] = "Arena2v2",
[ViragsSocial.Arena3v3] = "Arena3v3",
[ViragsSocial.Arena5v5] = "Arena5v5",
[ViragsSocial.ScannerMode] = "ScannerMode",
[ViragsSocial.Who] = "Who",
}
function ViragsSocial:InitUI(xmlDoc)
local bigWnd = Apollo.LoadForm(self.xmlDoc, "ViragsSocialMainForm", nil, self)
local smallWnd = Apollo.LoadForm(self.xmlDoc, "ViragsSocialMiniForm", nil, self)
self.tWndOptionsRefs.wndMain = Apollo.LoadForm(self.xmlDoc, "SettingsWnd", nil, self)
if bigWnd == nil or smallWnd == nil then
Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.")
return
end
self.tWndOptionsRefs.wndMain:Show(false, true)
self:InitWndFor(self.tWndRefsBig, bigWnd, "BigForm")
self:InitWndFor(self.tWndRefsSmall, smallWnd, "SmallForm")
self.tWndRefsSmall.wndMain:SetSizingMinimum(238, 250)
if self.ksSelectedWnd == "SmallForm" then
self:SetNewRefs(self.tWndRefsSmall)
else
self:SetNewRefs(self.tWndRefsBig)
end
end
function ViragsSocial:InitWndFor(tRef, mainWnd, strName)
if tRef == nil or mainWnd == nil or strName == nil then return end
tRef.strName = strName
-- Required
tRef.wndMain = mainWnd
self:DEBUG("tRef.wndGrid", tRef.wndGrid)
tRef.wndGridHeader = tRef.wndMain:FindChild("RosterHeaderContainer")
tRef.wndSideBar = tRef.wndMain:FindChild("SideBar")
--optional
tRef.wndAddonLogo = tRef.wndSideBar:FindChild("AddonLogo")
tRef.wndRandomHouse = tRef.wndMain:FindChild("RandomHouseForm")
tRef.wndScannerModeNav = tRef.wndMain:FindChild("ScannerModeNavigation")
tRef.wndPlayerNav = tRef.wndMain:FindChild("PlayerNavigation")
tRef.wndNeighborNav = tRef.wndMain:FindChild("NeighborNavigation")
tRef.wndGroupNav = tRef.wndMain:FindChild("GroupNavigation")
tRef.wndGuildNav = tRef.wndMain:FindChild("GuildNavigation")
tRef.wndGuildPerks = tRef.wndMain:FindChild("GuildPerksWnd")
tRef.wndGuildInfo = tRef.wndMain:FindChild("GuildInfoWnd")
tRef.friendAcceptDialog = tRef.wndMain:FindChild("Dialogs:FriendAcceptDialog")
tRef.editTextDialog = tRef.wndMain:FindChild("Dialogs:EditTextDialog")
tRef.editTextHelperDialog = tRef.wndMain:FindChild("Dialogs:EditTextHelperDialog")
tRef.confirmDialog = tRef.wndMain:FindChild("Dialogs:ConfirmDialog")
tRef.wndEditRankPopout = tRef.wndMain:FindChild("EditRankPopout")
tRef.wndUpdateButton = tRef.wndMain:FindChild("UpdateInformation")
tRef.wndMainGrid = tRef.wndMain:FindChild("RosterGrid")
tRef.wndTotalCount = tRef.wndMain:FindChild("TotalNumberText")
tRef.neighborPlugsGrid = tRef.wndMain:FindChild("NeighborPlugsGrid")
tRef.neighborFilter = tRef.wndMain:FindChild("NeighborFilterList")
tRef.wndGrid = tRef.wndMainGrid
tRef.wndMain:Show(false, true)
end
function ViragsSocial:IsMiniWnd()
return self.tWndRefs.strName == "SmallForm"
end
function ViragsSocial:IsVisible()
return self.tWndRefs ~= nil and self.tWndRefs.wndMain ~= nil and self.tWndRefs.wndMain:IsVisible()
end
function ViragsSocial:ToggleUI()
if self:IsVisible() then
self.tWndRefs.wndMain:Show(false)
else
self.tWndRefs.wndMain:Invoke()
end
end
function ViragsSocial:GridClear()
self.tWndRefs.wndGrid:DeleteAll() -- TODO remove this for better performance eventually
end
function ViragsSocial:GridSaveState()
self.GridScrollPosition = self.tWndRefs.wndGrid:GetVScrollPos()
self.GridFocusedPlayer = self:CurrentGridFocus()
end
function ViragsSocial:GridLoadState()
local wndGrid = self.tWndRefs.wndGrid
local player = self.GridFocusedPlayer
if player and player.strName and wndGrid then
local updateNav = true
for i = 1, wndGrid:GetRowCount() do
local cellData = wndGrid:GetCellData(i, 1)
if cellData and cellData.strName == player.strName then
wndGrid:SetCurrentRow(i)
updateNav = false
break
end
end
if updateNav then
-- we updating nav only if there is no more player with this name in the grid
-- Usually changed tab or something like that
-- no need to update if we still selecting the same name
self:HelperUpdateNavigationForSelection(nil)
end
end
wndGrid:SetVScrollPos(self.GridScrollPosition)
end
function ViragsSocial:OpenCircleRegistrationWnd()
self.tWndRefs.wndGrid:DeleteAll()
self.kCurrGuild = nil
Event_FireGenericEvent("EventGeneric_OpenCircleRegistrationPanel", self.tWndRefs.wndMain)
end
function ViragsSocial:SetupSideBarUIForTabs(tabsInfo)
if tabsInfo == nil then return end
local sideBar = self.tWndRefs.wndSideBar
for k, v in pairs(kSideBarTabsPosition) do
local tab = sideBar:FindChild(v)
if tab then tab:Show(false) end
end
if self.tWndRefs.wndAddonLogo then
self.tWndRefs.wndAddonLogo:Show(tabsInfo[1] == nil) -- No Guild check
end
for key, tabInfo in pairs(tabsInfo) do
local strBtnName = kSideBarTabsPosition[key]
if strBtnName then
self:SetupSideBarUIForTab(sideBar:FindChild(strBtnName), tabInfo)
end
end
end
function ViragsSocial:SetupSideBarUIForTab(wndTab, tabInfo)
if wndTab == nil then return end
local infoWnd = wndTab:FindChild("Info")
local textWnd = wndTab:FindChild("Online")
local nameWnd = wndTab:FindChild("SplashCirclesPickerBtnText")
wndTab:Show(true)
local showInfoTab
if not self:IsMiniWnd() then
showInfoTab = tabInfo.nOnline ~= nil
if nameWnd then nameWnd:SetText(tabInfo.sName) end
if infoWnd then infoWnd:Show(showInfoTab) end
else
textWnd = infoWnd
wndTab:SetTooltip(tabInfo.sName)
if infoWnd then infoWnd:Show(true) end
showInfoTab = tabInfo.nOnline ~= nil
end
if showInfoTab then
if textWnd then
tabInfo.tView = textWnd
textWnd:SetText(tabInfo.nOnline)
end
end
end
function ViragsSocial:CurrentGridFocus()
local data = nil
local focusRow = self.tWndRefs.wndGrid:GetCurrentRow()
if focusRow and focusRow > 0 and focusRow <= self.tWndRefs.wndGrid:GetRowCount() then
data = self.tWndRefs.wndGrid:GetCellData(focusRow, 1)
end
return data
end
function ViragsSocial:DefaultWildstarSocialFire(nTab)
if self.kSelectedTab == ViragsSocial.TabFriends then
Event_FireGenericEvent("GenericEvent_DestroyFriends")
elseif self.kSelectedTab == ViragsSocial.TabNeighbors then
Event_FireGenericEvent("GenericEvent_DestroyNeighbors")
elseif self.kSelectedTab == ViragsSocial.TabGuild then
Event_FireGenericEvent("GenericEvent_DestroyGuild")
end
self.kSelectedTab = nTab
if nTab == ViragsSocial.TabFriends then
Event_FireGenericEvent("GenericEvent_InitializeFriends", self.tWndRefs.wndMain)
elseif nTab == ViragsSocial.TabNeighbors then
Event_FireGenericEvent("GenericEvent_InitializeNeighbors", self.tWndRefs.wndMain)
elseif nTab == ViragsSocial.TabGuild then
Event_FireGenericEvent("GenericEvent_InitializeGuild", self.tWndRefs.wndMain)
end
end
function ViragsSocial:UpdateUIAfterTabSelection(nTab)
self:DefaultWildstarSocialFire(nTab);
self:CloseAllDialogs()
self.tWndRefs.wndSideBar:SetRadioSel("Tabs", nTab)
self.tWndRefs.wndGridHeader:FindChild("RosterSortBtnOnline:OnlineCheckBtn"):SetCheck(not self.kDisplayOffline[nTab] == false)
local btnMyNote = self.tWndRefs.wndGridHeader:FindChild("MyNoteCheckBtn")
if btnMyNote then
btnMyNote:SetCheck(not self.kShowMyNote[nTab] == false)
btnMyNote:Show(self:IsGuildTabSelected() or self:IsCircleTabSelected())
end
self:UpdateSelectedSortingTab()
if nTab == ViragsSocial.ScannerMode then
self:StartScannerMode()
else
self:StopScannerMode()
end
self:ReloadGridFromServer()
end
function ViragsSocial:UpdateSelectedSortingTab()
local currentSort = self:GetSortOrderForCurrentTab()
if currentSort and currentSort[1] and self.tWndRefs.wndGridHeader then
local sortingTabsWnds = self.tWndRefs.wndGridHeader:GetChildren()
for k,v in pairs(sortingTabsWnds)do
v:SetCheck(v:GetName() == currentSort[1])
end
end
end
function ViragsSocial:CloseAllGuildPopupsAndMenus()
self:CloseRanksForm()
if self.tWndRefs.wndGuildPerks
and self.tWndRefs.wndGuildPerks:IsShown() then
self:OnGuildPerksBntClick()
end
if self.tWndRefs.wndGuildInfo then
self.tWndRefs.wndGuildInfo:Show(false)
end
end
function ViragsSocial:AddRow(tData, eClass, ePath, nLvl, sName, fTime, sRank, sNote, strNameIcon, strRankIcon, strNoteIcon1, strNoteIcon2)
if fTime > 0 and not self.kDisplayOffline[self.kSelectedTab] then return end
if sName == nil or sName == "" then return end
local strTextColor = "UI_TextHoloBodyHighlight"
if fTime > 0 then -- offline
strTextColor = "darkgray" --"UI_BtnTextGrayNormal"
elseif fTime < 0 then --friendInvite
strTextColor = "UI_BtnTextRedNormal"
end
local location = self:LocationOfPlayer(tData.strName)
--Order: Class, Path, Lvl, Name, Online, Rank, Note
local grid = self.tWndRefs.wndGrid
local iCurrRow = grid:AddRow("")
grid:SetCellLuaData(iCurrRow, 1, tData)
local classIcon = self:ClassIcon(eClass)
if classIcon then
grid:SetCellImage(iCurrRow, 1, classIcon)
end
local pathIcon = self:PathIcon(ePath)
if pathIcon then
grid:SetCellImage(iCurrRow, 2, pathIcon)
end
if nLvl ~= nil and nLvl ~= ViragsSocial.kUNDEFINED then
grid:SetCellDoc(iCurrRow, 3, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. nLvl .. "</T>")
end
if strNameIcon then
grid:SetCellImage(iCurrRow, 4, strNameIcon)
end
grid:SetCellDoc(iCurrRow, 5, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. sName .. "</T>")
grid:SetCellDoc(iCurrRow, 6, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. self:HelperConvertToTime(fTime, location) .. "</T>")
if strRankIcon then
grid:SetCellImage(iCurrRow, 7, strRankIcon)
end
grid:SetCellDoc(iCurrRow, 8, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. sRank .. "</T>")
grid:SetCellDoc(iCurrRow, 9, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. FixXMLString(sNote) .. "</T>")
if strNoteIcon1 then
grid:SetCellImage(iCurrRow, 10, strNoteIcon1)
end
if strNoteIcon2 then
grid:SetCellImage(iCurrRow, 11, strNoteIcon2)
end
end
-- when the Cancel button is clicked
function ViragsSocial:OnCancel()
self:OnViragsSocialOn() --self.tWndRefs.wndMain:Close() -- hide the window
end
function ViragsSocial:OnToggleShowOfflineBtnClick(wndHandler, wndControl, eMouseButton)
self.kDisplayOffline[self.kSelectedTab] = not self.kDisplayOffline[self.kSelectedTab]
self:UpdateGrid(false, true)
end
function ViragsSocial:OnToggleShowMyNoteBtnClick(wndHandler, wndControl, eMouseButton)
self.kShowMyNote[self.kSelectedTab] = not self.kShowMyNote[self.kSelectedTab]
self:UpdateGrid(false, true)
end
function ViragsSocial:SetUITotalRosterSize(size)
local sizeWnd = self.tWndRefs.wndTotalCount
if sizeWnd and size then
sizeWnd:SetText(size)
end
end
function ViragsSocial:OnRosterSortToggle(wndHandler, wndControl)
self:SetNewSortOrderForCurrentTab(wndHandler:GetName())
wndHandler:SetCheck(true)
self:UpdateGrid(false, true)
end
-- Right click on player in list
function ViragsSocial:OnRosterGridItemClick(wndControl, wndHandler, iRow, iCol, eMouseButton)
local wndData = wndHandler:GetCellData(iRow, 1)
self:CloseAllDialogs()
self:HelperInviteRowCheck(wndData)
self:HelperUpdateNavigationForSelection(wndData)
if eMouseButton == GameLib.CodeEnumInputMouse.Right and wndData then
if self:IsGroupTabSelected() then -- Group
local playerUnit = GroupLib.GetUnitForGroupMember(wndData.nMemberIdx)
Event_FireGenericEvent("GenericEvent_NewContextMenuPlayerDetailed", self.tWndRefs.wndMain, wndData.strCharacterName, playerUnit)
end
if wndData.strName == self.kMyID then return end
if self:IsFriendTabSelected() or self:IsIgnoreTabSelected() then --Friendlist
self.FrInvContextMenuHelper = wndData
Event_FireGenericEvent("GenericEvent_NewContextMenuFriend", self.tWndRefs.wndMain, wndData.nId)
elseif self:IsNeghborTabSelected() then -- Neighbor
Event_FireGenericEvent("GenericEvent_NewContextMenuPlayer", self.tWndRefs.wndMain, wndData.strCharacterName)
elseif self:IsScannerMode() and self:IsValidUnit(wndData.unit) then -- can inspect
Event_FireGenericEvent("GenericEvent_NewContextMenuPlayerDetailed", self.tWndRefs.wndMain, wndData.unit:GetName(), wndData.unit)
else
Event_FireGenericEvent("GenericEvent_NewContextMenuPlayer", self.tWndRefs.wndMain, wndData.strName)
end
end
end
function ViragsSocial:FriendInviteDialogClose()
local dialog = self.tWndRefs.friendAcceptDialog
if dialog == nil then return end
dialog:Show(false)
end
function ViragsSocial:FriendInviteDialogOpen(tFriend)
self:CloseAllDialogs()
local dialog = self.tWndRefs.friendAcceptDialog
if dialog == nil then return end
local dialogTextWnd = dialog:FindChild("Text")
local acceptAndAddWnd = dialog:FindChild("AcceptAndAdd")
local justAcceptWnd = dialog:FindChild("JustAccept")
local ignoreWnd = dialog:FindChild("Ignore")
local rejectWnd = dialog:FindChild("Decline")
if tFriend.nRank == ViragsSocial.CharacterFriendshipType_Invite then
if dialogTextWnd and tFriend.strName then dialogTextWnd:SetText("Friend Invite from " .. tFriend.strName .. ":") end
self:SetBtnText(acceptAndAddWnd, Apollo.GetString("Friends_AcceptAndAdd"))
self:SetBtnText(justAcceptWnd, Apollo.GetString("Friends_JustAccept"))
if ignoreWnd then ignoreWnd:Show(true) end
if acceptAndAddWnd then acceptAndAddWnd:SetData(function() FriendshipLib.RespondToInvite(tFriend.nId, FriendshipLib.FriendshipResponse_Mutual) end) end
if justAcceptWnd then justAcceptWnd:SetData(function() FriendshipLib.RespondToInvite(tFriend.nId, FriendshipLib.FriendshipResponse_Accept) end) end
if ignoreWnd then ignoreWnd:SetData(function() FriendshipLib.RespondToInvite(tFriend.nId, FriendshipLib.FriendshipResponse_Ignore) end) end
if rejectWnd then rejectWnd:SetData(function() FriendshipLib.RespondToInvite(tFriend.nId, FriendshipLib.FriendshipResponse_Decline) end) end
dialog:Show(true)
elseif tFriend.nRank == ViragsSocial.CharacterFriendshipType_Account_Invite then
if dialogTextWnd and tFriend.strName then dialogTextWnd:SetText("Account Friend Invite from " .. tFriend.strName .. ":") end
self:SetBtnText(justAcceptWnd, Apollo.GetString("CRB_Accept"))
if acceptAndAddWnd then acceptAndAddWnd:Show(false) end
if ignoreWnd then ignoreWnd:Show(false) end
if rejectWnd then rejectWnd:SetData(function() FriendshipLib.AccountInviteRespond(tFriend.nId, false) end) end
if justAcceptWnd then justAcceptWnd:SetData(function() FriendshipLib.AccountInviteRespond(tFriend.nId, true) end) end
dialog:Show(true)
end
end
function ViragsSocial:SetBtnText(parent, text)
if parent and text then
local txtWnd = parent:FindChild("Text")
if txtWnd then txtWnd:SetText(text) end
parent:Show(true)
end
end
function ViragsSocial:HelperInviteRowCheck(data)
if self:IsFriendTabSelected() then --Friendlist
self:FriendInviteDialogOpen(data)
end
end
function ViragsSocial:HelperUpdateNavigationForSelection(data)
if self:IsFriendTabSelected() then --Friendlist
--todo
elseif self:IsNeghborTabSelected() and self.tWndRefs.wndNeighborNav then --Neighborlist
self.tWndRefs.wndNeighborNav:FindChild("ReturnBackWnd"):Show(HousingLib.IsHousingWorld())
if data then
local promoteWnd = self.tWndRefs.wndNeighborNav:FindChild("PromoteWnd")
local strStatus = "Set Roommate"
if data.nRank == HousingLib.NeighborPermissionLevel.Roommate then
strStatus = "Remove RM"
end
promoteWnd:FindChild("Text"):SetText(strStatus)
promoteWnd:Show(true)
self.tWndRefs.wndNeighborNav:FindChild("RemoveWnd"):Show(true)
self.tWndRefs.wndNeighborNav:FindChild("VisitWnd"):Show(HousingLib.IsHousingWorld())
self.tWndRefs.wndNeighborNav:FindChild("EditNotesWnd"):Show(true)
else
self.tWndRefs.wndNeighborNav:FindChild("PromoteWnd"):Show(false)
self.tWndRefs.wndNeighborNav:FindChild("RemoveWnd"):Show(false)
self.tWndRefs.wndNeighborNav:FindChild("VisitWnd"):Show(false)
self.tWndRefs.wndNeighborNav:FindChild("EditNotesWnd"):Show(false)
end
elseif self:IsCircleTabSelected() and self.tWndRefs.wndGuildNav then
local n = self.tWndRefs.wndGuildNav
local addNeighborBtn = n:FindChild("AddAsNeighborWnd")
if addNeighborBtn == nil then return end
addNeighborBtn:Show(false)
if data and data.strName and data.strName ~= self.kMyID then
local tCharacterData = GameLib.SearchRelationshipStatusByCharacterName(data.strName)
if tCharacterData ~= nil and tCharacterData.tNeighbor == nil then
addNeighborBtn:Show(true)
end
end
elseif (self:IsWarPartyTabSelected() or self:IsArenaTabSelected() or self:IsGuildTabSelected())
and self.tWndRefs.wndGuildNav then
local n = self.tWndRefs.wndGuildNav
local addNeighborBtn = n:FindChild("AddAsNeighborWnd")
if addNeighborBtn == nil then return end
addNeighborBtn:Show(false)
elseif self:IsGroupTabSelected() then
local n = self.tWndRefs.wndGroupNav
--todo
end
end
--Select sidebar tab
function ViragsSocial:OnSocialListSelected(wndHandler, wndControl, eMouseButton)
self:CloseAllGuildPopupsAndMenus()
local name = wndHandler:GetName()
for k, v in pairs(kSideBarTabsPosition) do
if name == v then
self:UpdateUIAfterTabSelection(k)
end
end
if wndHandler:FindChild("SplashCirclesPickerBtnText") and
wndHandler:FindChild("SplashCirclesPickerBtnText"):GetText() == self.kstrAddCircle then
self:OpenCircleRegistrationWnd()
end
end
function ViragsSocial:OnGenerateGridTooltip(wndHandler, wndControl, eType, iRow, iColumn)
local tData = wndHandler:GetCellData(iRow + 1, 1)
local text
if tData then
local playerInfo = self.ktPlayerInfoDB[tData.strName]
if iColumn == 0 then
text = self:ClassName(tData.eClass)
elseif iColumn == 1 then
text = self:PathName(tData.ePathType)
elseif iColumn == 3 then
text = self:NameIconTooltipFor(tData)
elseif iColumn == 9 and playerInfo and playerInfo.ts1 then
text = self:FullNameForTradeSkillShortName(playerInfo.ts1)
elseif iColumn == 10 and playerInfo and playerInfo.ts2 then
text = self:FullNameForTradeSkillShortName(playerInfo.ts2)
elseif iColumn == 6 and playerInfo then --attune
text = self:GetAttuneTooltipForPlayer(playerInfo.raidAttunStep)
end
end
if text == nil then text = "" end
wndHandler:SetTooltip(text)
end
function ViragsSocial:GetAttuneTooltipForPlayer(currPlayerKeyInfo)
if currPlayerKeyInfo == false then return "No Key in the Keyslot" end
if currPlayerKeyInfo and currPlayerKeyInfo.nId then
local key = Item.GetDataFromId(currPlayerKeyInfo.nId)
if key then
local keyInfo = key:GetDetailedInfo()
if keyInfo and keyInfo.tPrimary then
local keyData = keyInfo.tPrimary
if currPlayerKeyInfo.bCompleted and keyData.strName then return keyData.strName .. " DONE \n 13/13 Completed" end
if keyData and keyData.strName and keyData.arImbuements and currPlayerKeyInfo.step
and keyData.arImbuements[currPlayerKeyInfo.step] then
local step = keyData.arImbuements[currPlayerKeyInfo.step]
local progressDetaledInfo = ""
if step.queImbuement and currPlayerKeyInfo.currentProgress then
self:DEBUG("step.queImbuement", step.queImbuement)
local tasks = step.queImbuement:GetVisibleObjectiveData()
if tasks then
for k, v in pairs(currPlayerKeyInfo.currentProgress) do
local task = tasks[k]
if task and task.strDescription then
progressDetaledInfo = "\n"
if v.nCompleted ~= nil and v.nNeeded ~= nil then
progressDetaledInfo = progressDetaledInfo .. "(" .. v.nCompleted .. "/" .. v.nNeeded .. ") - "
end
progressDetaledInfo = progressDetaledInfo .. task.strDescription
end
end
end
end
return string.format("%s (%d) \n%s \n%s", keyData.strName or "", currPlayerKeyInfo.step, step.strName or "", progressDetaledInfo)
end
end
end
end
return nil
end
function ViragsSocial:NameIconTooltipFor(tPlayer)
if tPlayer and tPlayer.strName then
local rel = self.ktRelationsDB[tPlayer.strName]
local currTab = self.kSelectedTab
--self:DEBUG("self.ktRelationsDB", self.ktRelationsDB)
if rel then
local text = ""
for k, v in pairs(rel) do
if k ~= currTab and v then
text = text .. self:TabName(k) .. " \n"
end
end
return text
end
end
return nil
end
function ViragsSocial:OnGuildEditNotesBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild then
local id, data = self:HelperSelectedRosterData()
if data and data.strName and data.strName ~= self.kMyID then
self:PopupEnterTextDialog("Edit Private Note for " .. data.strName .. ":", self.ktGuildNotes[data.strName] or "",
function()
local strEditBoxText = self:GetTextFromEditBox(nil)
self:SaveGuildNote(data.strName, strEditBoxText, id)
local btnMyNote = self.tWndRefs.wndGridHeader:FindChild("MyNoteCheckBtn")
if btnMyNote then btnMyNote:SetCheck(true) end
end)
return
end
self:PopupEnterTextDialog("Edit My Note: ", self.kStrMyNote or "",
function()
if self.kCurrGuild == nil then return end
local strEditBoxText = self:GetTextFromEditBox(32)
if strEditBoxText and strEditBoxText ~= self.kStrMyNote then
self.kStrMyNote = strEditBoxText
self.kCurrGuild:SetMemberNoteSelf(strEditBoxText)
end
end)
end
end
function ViragsSocial:GetTextFromEditBox(nMax)
local strEditBoxText = nil
if self.tWndRefs.editTextDialog then
local editBox = self.tWndRefs.editTextDialog:FindChild("EditBox")
if editBox then
strEditBoxText = editBox:GetText()
if nMax and string.len(strEditBoxText) > nMax then
strEditBoxText = string.sub(strEditBoxText, 1, nMax)
end
end
end
return strEditBoxText
end
function ViragsSocial:OnGuildAddPlayerBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild then
self:PopupEnterTextDialog("Invite Player to " .. self.kCurrGuild:GetName() .. " :", "",
function()
if self.kCurrGuild == nil then return end
local strEditBoxText = self:GetTextFromEditBox(nil)
if strEditBoxText then
self.kCurrGuild:Invite(strEditBoxText)
end
end)
end
end
function ViragsSocial:OnGuildAddAsNeighborBntClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
local data = self:CurrentGridFocus()
if data and data.strName and data.strName ~= self.kMyID then
wndHandler:Show(false)
HousingLib.NeighborInviteByName(data.strName)
end
end
function ViragsSocial:OnGuildKickPlayerBtn(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild == nil then return end
local data = self:CurrentGridFocus()
if data and data.strName and data.strName ~= self.kMyID then
self:PopupConfirmDialog("Kick " .. data.strName .. " from " .. self.kCurrGuild:GetName() .. "?",
function()
if self.kCurrGuild == nil then return end
self.kCurrGuild:Kick(data.strName)
end)
else
self:PopupEnterTextDialog("Kick player from " .. self.kCurrGuild:GetName() .. " :", "",
function()
if self.kCurrGuild == nil then return end
if self:GetTextFromEditBox(nil) then self.kCurrGuild:Kick(self:GetTextFromEditBox(nil)) end
end)
end
end
function ViragsSocial:OnGuildPromoteBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild == nil then return end
local data = self:CurrentGridFocus()
if data and data.strName and data.strName ~= self.kMyID then
self:PopupConfirmDialog("Promote " .. data.strName .. " in " .. self.kCurrGuild:GetName() .. "?",
function()
if self.kCurrGuild == nil then return end
self.kCurrGuild:Promote(data.strName)
end)
else
self:PopupEnterTextDialog("Promote player in " .. self.kCurrGuild:GetName() .. " :", "",
function()
if self.kCurrGuild == nil then return end
local strEditBoxText = self:GetTextFromEditBox(nil)
if strEditBoxText then self.kCurrGuild:Promote(strEditBoxText) end
end)
end
end
function ViragsSocial:OnGuildDemoteBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild == nil then return end
local data = self:CurrentGridFocus()
if data and data.strName and data.strName ~= self.kMyID then
self:PopupConfirmDialog("Demote " .. data.strName .. " in " .. self.kCurrGuild:GetName() .. "?",
function()
if self.kCurrGuild == nil then return end
self.kCurrGuild:Demote(data.strName)
end)
else
self:PopupEnterTextDialog("Demote player in " .. self.kCurrGuild:GetName() .. " :", "",
function()
if self.kCurrGuild == nil then return end
local strEditBoxText = self:GetTextFromEditBox(nil)
if strEditBoxText then self.kCurrGuild:Demote(strEditBoxText) end
end)
end
end
function ViragsSocial:OnGuildLeaveBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild == nil then return end
local GuildName = self.kCurrGuild:GetName();
local GuildType = self.kCurrGuild:GetType();
local rank = self.kCurrGuild:GetMyRank()
local strMsg = "Leave " .. self:GuildFullName(self.kCurrGuild) .. "?"
local fn = function()
if self.kCurrGuild == nil then return end
self.kCurrGuild:Leave()
end
if rank == 1 then -- GM
strMsg = "Disband " .. self:GuildFullName(self.kCurrGuild) .. "?"
if (GuildType == GuildLib.GuildType_Guild) then
strMsg = self:GuildFullName(self.kCurrGuild) .. "WARNING: A YOU SURE YOU WANT TO DISBAND YOUR MAIN GUILD" .."?"
end
fn = function()
if self.kCurrGuild == nil then return end
if self.kCurrGuild:GetName() == GuildName and
self.kCurrGuild:GetType() == GuildType then
self.kCurrGuild:Disband()
end
end
end
self:PopupConfirmDialog(strMsg, fn)
end
function ViragsSocial:OnGuildRanksBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
local ranksForm = self.tWndRefs.ranksForm
if ranksForm and ranksForm:IsVisible() then
self:CloseRanksForm()
else
self:ShowRanksForGuild()
end
end
function ViragsSocial:OnGuildMoreInfoBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
local bVis = self.tWndRefs.wndGuildNav:FindChild("GuildHelperNavigation"):IsShown()
self.tWndRefs.wndGuildNav:FindChild("GuildHelperNavigation"):Show(not bVis)
end
function ViragsSocial:OnGuildPerksBntClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
if self.kCurrGuild == nil or self.kCurrGuild:GetType() ~= GuildLib.GuildType_Guild then return end
self.tWndRefs.wndGuildInfo:Show(false)
if self.tWndRefs.wndGuildPerks:IsShown() then
Event_FireGenericEvent("GuildWindowHasBeenClosed")
self.tWndRefs.wndMain:SetData(nil)
else
self.tWndRefs.wndMain:SetData(self.kCurrGuild)
Event_FireGenericEvent("GuildWindowHasBeenClosed")
Event_FireGenericEvent("Guild_TogglePerks", self.tWndRefs.wndGuildPerks)
local perksWnd = self.tWndRefs.wndMain:FindChild("GuildPerksForm")
--if perksWnd then --todo remove this and fix xml after patch
-- perksWnd:SetStyle("NoClip", true)
-- perksWnd:SetAnchorOffsets(45, 0, 800, 568)
--end
end
local bShowUI = self.tWndRefs.wndGuildPerks:IsShown()
self.tWndRefs.wndGrid:Show(bShowUI)
self.tWndRefs.wndSideBar:Show(bShowUI)
self.tWndRefs.wndGridHeader:FindChild("RosterHeaderContainer"):Show(bShowUI)
self.tWndRefs.wndGuildPerks:Show(not bShowUI)
end
function ViragsSocial:OnGuildInfoBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
local gInfoWnd = self.tWndRefs.wndGuildInfo
if gInfoWnd == nil then return end
local bVis = gInfoWnd:IsShown()
if not bVis then --setup
if self.kCurrGuild == nil then return end
local MotD = self.kCurrGuild:GetMessageOfTheDay()
local AddInfo = self.kCurrGuild:GetInfoMessage()
local logs = self.kCurrGuild:GetEventLogs()
gInfoWnd:FindChild("MsgOfTheDayWnd:Text"):SetText(MotD)
gInfoWnd:FindChild("DescriptionWnd:Text"):SetText(AddInfo)
self:SetupTaxBtn(self.kCurrGuild:GetFlags().bTax)
local logGrid = gInfoWnd:FindChild("EventsWnd:Grid")
if logs and logGrid then
logGrid:DeleteAll()
for k, v in pairs(logs) do self:AddGuildLogRecord(logGrid, v) end
end
gInfoWnd:FindChild("MsgOfTheDayWnd:Save"):Show(false)
gInfoWnd:FindChild("DescriptionWnd:Save"):Show(false)
local rank = self.kCurrGuild:GetMyRank()
if rank then
local myPermissions = self.kCurrGuild:GetRanks()[rank]
if myPermissions then
--
gInfoWnd:FindChild("MsgOfTheDayWnd:Text"):SetStyleEx("ReadOnly", not myPermissions.bMessageOfTheDay)
gInfoWnd:FindChild("DescriptionWnd:Text"):SetStyleEx("ReadOnly", not myPermissions.bMessageOfTheDay)
gInfoWnd:FindChild("MsgOfTheDayWnd:Save"):Show(myPermissions.bMessageOfTheDay)
gInfoWnd:FindChild("DescriptionWnd:Save"):Show(myPermissions.bMessageOfTheDay)
end
end
--if self.kCurrGuildthen return end
end
gInfoWnd:Show(not bVis)
end
function ViragsSocial:SetupTaxBtn(bTax)
local taxWnd = self.tWndRefs.wndGuildInfo:FindChild("TaxWnd")
taxWnd:FindChild("TaxInfoText"):SetText(String_GetWeaselString(Apollo.GetString("Guild_GuildTaxLabel"), bTax and Apollo.GetString("MatchMaker_FlagOn") or Apollo.GetString("MatchMaker_FlagOff")))
taxWnd:FindChild("ChangeBtn:Text"):SetText(bTax and Apollo.GetString("MatchMaker_FlagOff") or Apollo.GetString("MatchMaker_FlagOn"))
taxWnd:FindChild("ChangeBtn:BG"):SetBGColor(bTax and "AddonError" or "AddonOk")
taxWnd:FindChild("ChangeBtn"):Show(self.kCurrGuild:GetType() == GuildLib.GuildType_Guild and self.kCurrGuild:GetMyRank() == 1)
end
function ViragsSocial:AddGuildLogRecord(LogGrid, tEventLog)
local strName = tEventLog.strMemberName or ""
local strTime = self:HelperConvertToTime(math.abs(tEventLog.fCreationTime))
local strEvent = ""
local strTextColor = "UI_TextHoloBodyHighlight"
if tEventLog.eType == GuildLib.CodeEnumGuildEventType.Achievement and tEventLog.achEarned ~= nil then
strEvent = String_GetWeaselString(Apollo.GetString("Guild_AchievementEarned"), "", tEventLog.achEarned:GetName())
strName = self.kCurrGuild:GetName()
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.PerkUnlock and tEventLog.tGuildPerk ~= nil then
strEvent = String_GetWeaselString(Apollo.GetString("Guild_UnlockedPerk"), "", tEventLog.tGuildPerk.strTitle)
strName = self.kCurrGuild:GetName()
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.PerkActivate and tEventLog.tGuildPerk ~= nil then
strEvent = String_GetWeaselString(Apollo.GetString("Guild_AchievementEarned"), "", tEventLog.tGuildPerk.strTitle)
strName = self.kCurrGuild:GetName()
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.MemberAdded then
strEvent = String_GetWeaselString(Apollo.GetString("Guild_MemberJoined"), "")
strTextColor = "UI_BtnTextGreenNormal"
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.MemberRemoved then
strEvent = String_GetWeaselString(Apollo.GetString("Guild_MemberLeft"), "")
strTextColor = "UI_BtnTextRedNormal"
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.MemberRankChanged then
strEvent = " " .. Apollo.GetString("Guild_Promoted")
strTextColor = "AttributeDexterity"
if tEventLog.nOldRank < tEventLog.nNewRank then
strEvent = " " .. Apollo.GetString("Guild_Demoted")
strTextColor = "ItemQuality_Superb"
end
elseif tEventLog.eType == GuildLib.CodeEnumGuildEventType.MessageOfTheDay then
strEvent = Apollo.GetString("Guild_MOTDUpdated")
else
-- Error: Unhandled EventLog type
strName = "Error"
strEvent = "Error Event"
return
end
local iCurrRow = LogGrid:AddRow("")
LogGrid:SetCellLuaData(iCurrRow, 1, tEventLog)
LogGrid:SetCellDoc(iCurrRow, 1, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. strTime .. "</T>")
LogGrid:SetCellDoc(iCurrRow, 2, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. strName .. "</T>")
LogGrid:SetCellDoc(iCurrRow, 3, "<T Font=\"CRB_InterfaceSmall\" TextColor=\"" .. strTextColor .. "\">" .. strEvent .. "</T>")
end
function ViragsSocial:OnGuildSaveMessageOfTheDay(wndHandler, wndControl, eMouseButton)
if self.kCurrGuild == nil then return end
local txtWnd = self.tWndRefs.wndGuildInfo:FindChild("MsgOfTheDayWnd:Text")
local text = txtWnd:GetText()
txtWnd:ClearFocus()
self.kCurrGuild:SetMessageOfTheDay(text)
end
function ViragsSocial:OnGuildSaveInfo(wndHandler, wndControl, eMouseButton)
if self.kCurrGuild == nil then return end
local txtWnd = self.tWndRefs.wndGuildInfo:FindChild("DescriptionWnd:Text")
local text = txtWnd:GetText()
txtWnd:ClearFocus()
if text then
self.kCurrGuild:SetInfoMessage(text)
self:PRINT("New Guild Info: " .. text)
end
end
function ViragsSocial:GuildOnGMChangeBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
self:PopupEnterTextDialog("Enter new Guild Master name: ", self.kMyID or "", function()
if self.kCurrGuild == nil then return end
local strEditBoxText = self:GetTextFromEditBox(nil)
if strEditBoxText then self.kCurrGuild:PromoteMaster(strEditBoxText) end
end)
end
function ViragsSocial:OnGuildTaxToggle(wndHandler, wndControl)
local bNewTax = not self.kCurrGuild:GetFlags().bTax
self.kCurrGuild:SetFlags({ bTax = bNewTax })
self:SetupTaxBtn(bNewTax)
end
function ViragsSocial:OnFriendListEditStatusBtnClick(wndHandler, wndControl, eMouseButton, nLastRelativeMouseX, nLastRelativeMouseY)
self:PopupEnterTextDialog("My " .. Apollo.GetString("CRB_Status"), FriendshipLib.GetPersonalStatus().strPublicNote,
function()