Back to Home

ESO Lua File v101037

ingame/campaign/campaignbrowser.lua

[◄ back to folders ]
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
local CampaignBrowser = ZO_SortFilterList:Subclass()
local ENTRY_SORT_KEYS =
{
    ["name"] = { },
    ["numFriends"] = { tiebreaker = "name", isNumeric = true },
    ["numGuildMembers"] = { tiebreaker = "name", isNumeric = true },
    ["numGroupMembers"] = { tiebreaker = "name", isNumeric = true },
    ["alliancePopulation1"] = { tiebreaker = "name", isNumeric = true },
    ["alliancePopulation2"] = { tiebreaker = "name", isNumeric = true },
    ["alliancePopulation3"] = { tiebreaker = "name", isNumeric = true },
}
function CampaignBrowser:New(...)
    return ZO_SortFilterList.New(self, ...)
end
function CampaignBrowser:Initialize(control)
    ZO_SortFilterList.Initialize(self, control)
    self.rules = control:GetNamedChild("Rules")
    self.numConfirmingQueues = 0
    
    ZO_ScrollList_AddDataType(self.list, ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN, "ZO_CampaignBrowserRow", 30, function(control, data) self:SetupCampaign(control, data) end)
    ZO_ScrollList_AddDataType(self.list, ZO_CAMPAIGN_DATA_TYPE_QUEUE, "ZO_CampaignBrowserQueueRow", 30, function(control, data) self:SetupCampaignQueue(control, data) end)
    ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
    self.sortFunction = function(listEntry1, listEntry2) return self:CompareCampaigns(listEntry1, listEntry2) end
    self.filteredList = {}
    self:InitializeTree()
    self:RefreshData()
    self.sortHeaderGroup:SelectHeaderByKey("name")
    CAMPAIGN_BROWSER_MANAGER:RegisterCallback("OnCampaignDataUpdated", function() self:OnCampaignSelectionDataChanged() end)
    CAMPAIGN_BROWSER_MANAGER:RegisterCallback("OnCampaignQueueStateUpdated", function(_, campaignData) self:OnCampaignQueueStateUpdated(campaignData) end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_ASSIGNED_CAMPAIGN_CHANGED, function() self:OnAssignedCampaignChanged() end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_CAMPAIGN_QUEUE_POSITION_CHANGED, function() self:OnCampaignQueuePositionChanged() end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_UNIT_CREATED, function(_, unitTag) self:OnUnitUpdated(unitTag) end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_UNIT_DESTROYED, function(_, unitTag) self:OnUnitUpdated(unitTag) end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_GROUP_MEMBER_CONNECTED_STATUS, function() self:RefreshVisible() end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_LEADER_UPDATE, function() self:OnGroupLeaderUpdate() end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_PLAYER_DEAD, function() self:OnPlayerDead() end)
    EVENT_MANAGER:RegisterForEvent("CampaignBrowser", EVENT_PLAYER_ALIVE, function() self:OnPlayerAlive() end)
    CAMPAIGN_BROWSER_SCENE = ZO_Scene:New("campaignBrowser", SCENE_MANAGER)
    CAMPAIGN_BROWSER_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            QueryCampaignSelectionData()
            self:SelectAssignedCampainRulesetNode()
            KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
        elseif newState == SCENE_HIDDEN then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
        end
    end)
end
function CampaignBrowser:InitializeTree()
    self.tree = ZO_Tree:New(GetControl(self.control, "CategoriesScrollChild"), 60, -10, 255)
    local function RulesetTypeSetup(control, rulesetType, down)
        control.text:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        control.text:SetText(GetString("SI_CAMPAIGNRULESETTYPE", rulesetType))
        control.rulesetType = rulesetType
        
        local icons = ZO_CampaignBrowser_GetKeyboardIconsForRulesetType(rulesetType)
        control.icon:SetTexture(down and icons.down or icons.up)
        control.iconHighlight:SetTexture(icons.over)
        
        ZO_IconHeader_Setup(control, down)
    end
    --Ruleset Type Header
    local function RulesetTypeHeaderSetup(node, control, rulesetType, open, userRequested)
        RulesetTypeSetup(control, rulesetType, open)
        if open and userRequested then
            self.tree:SelectFirstChild(node)
        end
    end
    self.tree:AddTemplate("ZO_RulesetTypeHeader", RulesetTypeHeaderSetup, nil, nil, nil, 0)
    --Ruleset Entry
    local function RulesetEntrySetup(node, control, data, open)
        local name = GetCampaignRulesetName(data.rulesetId)
        control:SetSelected(false)
        control.rulesetId = data.rulesetId
        control:SetText(name)
    end
    local function RulesetEntrySelected(control, data, selected, reselectingDuringRebuild)
        control:SetSelected(selected)
        if selected and not reselectingDuringRebuild then
            self:SetRulesetIdFilter(data.rulesetId)
        end
    end
    local function RulesetEntryEquality(left, right)
        return left.rulesetId == right.rulesetId
    end
    self.tree:SetExclusive(true)
    self.tree:SetOpenAnimation("ZO_TreeOpenAnimation")
end
function CampaignBrowser:SetRulesetIdFilter(rulesetId)
    self.rulesetIdFilter = rulesetId
    self.rules:SetText(GetCampaignRulesetDescription(rulesetId))
    self:RefreshFilters()
end
function CampaignBrowser:CanSetHomeCampaign()
    if self.mouseOverRow then
        return CAMPAIGN_BROWSER_MANAGER:CanSetHomeCampaign(ZO_ScrollList_GetData(self.mouseOverRow))
    end
end
function CampaignBrowser:DoSetHomeCampaign()
    if self.mouseOverRow then
        return CAMPAIGN_BROWSER_MANAGER:DoSetHomeCampaign(ZO_ScrollList_GetData(self.mouseOverRow))
    end
end
function CampaignBrowser:CanAbandon()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        local isQueued = IsQueuedForCampaign(data.id, data.isGroup)
        local isCurrentCampaign = data.id == GetAssignedCampaignId()
        if (isCurrentCampaign and not isQueued) then
            return true
        end
    end
end
function CampaignBrowser:DoAbandon()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        if (data.id == GetAssignedCampaignId()) then
            ABANDON_HOME_CAMPAIGN_DIALOG:Show(data)
        end
    end
end
function CampaignBrowser:CanEnter()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        if data.type == ZO_CAMPAIGN_DATA_TYPE_QUEUE then
            if data.state == CAMPAIGN_QUEUE_REQUEST_STATE_CONFIRMING then
                return true
            end
        end
    end
end
function CampaignBrowser:DoEnter()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        if data.type == ZO_CAMPAIGN_DATA_TYPE_QUEUE then
            if data.state == CAMPAIGN_QUEUE_REQUEST_STATE_CONFIRMING then
                ConfirmCampaignEntry(data.id, data.isGroup, true)
            end
        end
    end
end
function CampaignBrowser:CanQueueForCampaign()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        if data.type == ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN then
            local canQueueIndividual, canQueueGroup = CAMPAIGN_BROWSER_MANAGER:CanQueueForCampaign(data)
            return canQueueIndividual or canQueueGroup
        end
    end
end
function CampaignBrowser:DoQueueForCampaign()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        CAMPAIGN_BROWSER_MANAGER:DoQueueForCampaign(data)
    end
end
function CampaignBrowser:CanLeaveCampaignQueue()
    if self.mouseOverRow then
        return CAMPAIGN_BROWSER_MANAGER:CanLeaveCampaignQueue(ZO_ScrollList_GetData(self.mouseOverRow))
    end
    return false
end
function CampaignBrowser:DoLeaveCampaignQueue()
    if self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        CAMPAIGN_BROWSER_MANAGER:DoLeaveCampaignQueue(data)
    end
end
function CampaignBrowser:InitializeKeybindDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_RIGHT,
        
        --Leave/Abandon
        {
            name = function()
                if self.mouseOverRow then
                    if self:CanLeaveCampaignQueue() then
                        return GetString(SI_CAMPAIGN_BROWSER_LEAVE_QUEUE)
                    elseif self:CanAbandon() then
                        return GetString(SI_CAMPAIGN_BROWSER_ABANDON_CAMPAIGN)
                    end
                end
            end,
            keybind = "UI_SHORTCUT_NEGATIVE",
        
            callback = function()
                if self.mouseOverRow then
                    if self:CanLeaveCampaignQueue() then
                        self:DoLeaveCampaignQueue()
                    elseif self:CanAbandon() then
                        self:DoAbandon()
                    end
                end
            end,
            visible = function()
                return self:CanLeaveCampaignQueue() or self:CanAbandon()
            end
        },
        -- Home
        {
            name = GetString(SI_CAMPAIGN_BROWSER_CHOOSE_HOME_CAMPAIGN),
            keybind = "UI_SHORTCUT_SECONDARY",
        
            callback = function()
                self:DoSetHomeCampaign()
            end,
            visible = function()
                return self:CanSetHomeCampaign()
            end,
        },
        --Queue/Enter
        {
            name = function()
                if self.mouseOverRow then
                    local data = ZO_ScrollList_GetData(self.mouseOverRow)
                    if data.type == ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN then
                        return GetString(SI_CAMPAIGN_BROWSER_QUEUE_CAMPAIGN)
                    elseif data.type == ZO_CAMPAIGN_DATA_TYPE_QUEUE then
                        return GetString(SI_CAMPAIGN_BROWSER_ENTER_CAMPAIGN)
                    end
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
        
            callback = function()
                if self.mouseOverRow then
                    local data = ZO_ScrollList_GetData(self.mouseOverRow)
                    if data.type == ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN then
                        self:DoQueueForCampaign()
                    elseif data.type == ZO_CAMPAIGN_DATA_TYPE_QUEUE then
                        self:DoEnter()
                    end
                end
            end,
            visible = function()
                return self:CanQueueForCampaign() or self:CanEnter()
            end,
        },
    }
end
function CampaignBrowser:SetupAllianceControl(control, data)
    control.data = data
end
function CampaignBrowser:SetupCampaignQueue(control, queueData)
    ZO_SortFilterList.SetupRow(self, control, queueData)
    local icon = GetControl(control, "Icon")
    local loading = GetControl(control, "Loading")
    local description = GetControl(control, "Description")
    
    local isLoading, message, messageicon = CAMPAIGN_BROWSER_MANAGER:GetQueueMessage(queueData.id, queueData.isGroup, queueData.state)
    icon:SetHidden(isLoading)
    loading:SetHidden(not isLoading)
    if not isLoading then
        icon:SetTexture(messageicon)
    end
    description:SetText(message)
end
function CampaignBrowser:CheckForConfirmingQueues()
    for _, campaignData in ipairs(self.masterList) do
        if campaignData.queue.state == CAMPAIGN_QUEUE_REQUEST_STATE_CONFIRMING then
            hasConfirmingQueues = true
            break
        end
    end
    if hasConfirmingQueues then
        self.control:SetHandler("OnUpdate", function(control, seconds)
                -- Ensure that refresh only occurs on second boundaries
                if not self.nextUpdateTimeSeconds or seconds > self.nextUpdateTimeSeconds then
                    self.nextUpdateTimeSeconds  = zo_floor(seconds + 1)
                    self:RefreshVisible()
                end
            end)
    else
        self.control:SetHandler("OnUpdate", nil)
    end
end
function CampaignBrowser:BuildMasterList()
    self.control:SetHandler("OnUpdate", nil)
    self.numConfirmingQueues = 0
    -- get master list
    self.masterList = CAMPAIGN_BROWSER_MANAGER:GetCampaignDataList()
    -- build ruleset categories
    self.rulesetTypes = CAMPAIGN_BROWSER_MANAGER:GetActiveCampaignRulesetsByType()
    self.tree:Reset()
    
    for rulesetType, rulesetIds in pairs(self.rulesetTypes) do
        local parentCategory = self.tree:AddNode("ZO_RulesetTypeHeader", rulesetType)
        for _, rulesetId in pairs(rulesetIds) do
            self.tree:AddNode("ZO_RulesetEntry", {rulesetId = rulesetId}, parentCategory)
        end
    end
    self.tree:Commit()
end
function CampaignBrowser:SelectAssignedCampainRulesetNode()
    if self.tree then
        local assignedCampaignId = GetAssignedCampaignId()
        local assignedCampaignRulesetId = GetCampaignRulesetId(assignedCampaignId)
        if assignedCampaignRulesetId ~= 0 then
            local START_AT_ROOT = nil
            self.tree:ExecuteOnSubTree(START_AT_ROOT, function(node)
                if node:GetTemplate() == "ZO_RulesetEntry" then
                    local nodeData = node:GetData()
                    if nodeData.rulesetId == assignedCampaignRulesetId then
                        self.tree:SelectNode(node)
                        return true
                    end
                end
            end)
        end
    end
end
do
    internalassert(CAMPAIGN_RULESET_TYPE_MAX_VALUE == 4, "Update Campaign Rulesets")
    local HIDDEN_COLUMN_KEYS_BY_RULESET_TYPE =
    {
        [CAMPAIGN_RULESET_TYPE_CYRODIIL] = {},
        [CAMPAIGN_RULESET_TYPE_IMPERIAL_CITY] = {["numGroupMembers"] = true, ["numFriends"] = true, ["numGuildMembers"] = true},
    }
    function CampaignBrowser:FilterScrollList()
        -- Apply filter to list
        ZO_ClearNumericallyIndexedTable(self.filteredList)
        for _, campaignData in ipairs(self.masterList) do
            if self.rulesetIdFilter == campaignData.rulesetId then
                table.insert(self.filteredList, ZO_ScrollList_CreateDataEntry(ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN, campaignData))
            end
        end
        -- Apply filter to headers
        local rulesetType = GetCampaignRulesetType(self.rulesetIdFilter)
        -- ESO-808426: Speculative fix. Theoretically, if encountered during a load screen we can get an invalid value of 0
        if rulesetType ~= 0 then
            local hiddenColumns = HIDDEN_COLUMN_KEYS_BY_RULESET_TYPE[rulesetType]
            local HIDDEN = true
            self.sortHeaderGroup:SetHeadersHiddenFromKeyList(hiddenColumns, HIDDEN)
            if hiddenColumns[self.sortHeaderGroup:GetCurrentSortKey()] then
                -- Table was sorted by a column that is gone now: fallback to name
                self.sortHeaderGroup:SelectHeaderByKey("name")
            end
        end
    end
    function CampaignBrowser:SetupCampaign(control, data)
        ZO_SortFilterList.SetupRow(self, control, data)
     
        local name = GetControl(control, "Name")
        name:SetText(data.name)
        local icon = GetControl(control, "Icon")
        if data.id == GetAssignedCampaignId() then
            icon:SetHidden(false)
            icon:SetTexture("EsoUI/Art/Campaign/campaignBrowser_homeCampaign.dds")
        elseif not ZO_CampaignBrowser_DoesPlayerMatchAllianceLock(data) then
            icon:SetHidden(false)
            icon:SetTexture("EsoUI/Art/Miscellaneous/status_locked.dds")
        else
            icon:SetHidden(true)
        end
        local selectionIndex = data.selectionIndex
        local alliancePopulation1 = control:GetNamedChild("AlliancePopulation1")
        self:SetupAllianceControl(alliancePopulation1, {population = data.alliancePopulation1, selectionIndex = selectionIndex, alliance = ALLIANCE_ALDMERI_DOMINION})
        local alliancePopulation2 = control:GetNamedChild("AlliancePopulation2")
        self:SetupAllianceControl(alliancePopulation2, {population = data.alliancePopulation2, selectionIndex = selectionIndex, alliance = ALLIANCE_EBONHEART_PACT})
        local alliancePopulation3 = control:GetNamedChild("AlliancePopulation3")
        self:SetupAllianceControl(alliancePopulation3, {population = data.alliancePopulation3, selectionIndex = selectionIndex, alliance = ALLIANCE_DAGGERFALL_COVENANT})
        local rulesetType = GetCampaignRulesetType(self.rulesetIdFilter)
        -- ESO-774582: If encountered during a load screen we can get an invalid value of 0
        if rulesetType ~= 0 then
            local hiddenColumns = HIDDEN_COLUMN_KEYS_BY_RULESET_TYPE[rulesetType]
            control:GetNamedChild("GroupMembers"):SetHidden(hiddenColumns["numGroupMembers"] or data.numGroupMembers == 0)
            control:GetNamedChild("Friends"):SetHidden(hiddenColumns["numFriends"] or data.numFriends == 0)
            control:GetNamedChild("GuildMembers"):SetHidden(hiddenColumns["numGuildMembers"] or data.numGuildMembers == 0)
        end
    end
end
function CampaignBrowser:CompareCampaigns(listEntry1, listEntry2)
    return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, ENTRY_SORT_KEYS, self.currentSortOrder)
end
function CampaignBrowser:SortScrollList()
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    ZO_ClearNumericallyIndexedTable(scrollData)
    if self.currentSortKey ~= nil and self.currentSortOrder ~= nil then
        local scrollData = ZO_ScrollList_GetDataList(self.list)
        table.sort(self.filteredList, self.sortFunction)
        --add the queue rows under the campaign rows
        for _, campaignEntry in ipairs(self.filteredList) do
            table.insert(scrollData, campaignEntry)
            local data = campaignEntry.data
            if data.queue.isQueued then
                table.insert(scrollData, ZO_ScrollList_CreateDataEntry(ZO_CAMPAIGN_DATA_TYPE_QUEUE, data.queue))
            end
        end
    end
end
function CampaignBrowser:GetRowColors(data, mouseIsOver, control)
    local textColor
    if data.type == ZO_CAMPAIGN_DATA_TYPE_CAMPAIGN then
        textColor = ZO_SECOND_CONTRAST_TEXT
    else
        textColor = ZO_NORMAL_TEXT
    end
    if mouseIsOver then
        textColor = ZO_SELECTED_TEXT
    else
        if control.normalColor then
            textColor = control.normalColor
        end
    end
    return textColor, nil
end
function CampaignBrowser:GetDataByCampaignId(campaignId)
    return CAMPAIGN_BROWSER_MANAGER:GetDataByCampaignId(campaignId)
end
--Events
------------
function CampaignBrowser:OnCampaignSelectionDataChanged()
    self:RefreshData()
end
function CampaignBrowser:OnAssignedCampaignChanged()
    self:RefreshVisible()
end
function CampaignBrowser:OnCampaignQueueStateUpdated(campaignData)
    self:RefreshFilters()
end
function CampaignBrowser:OnCampaignQueuePositionChanged()
    self:RefreshVisible()
end
function CampaignBrowser:OnUnitUpdated(unitTag)
    if ZO_Group_IsGroupUnitTag(unitTag) then
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function CampaignBrowser:OnGroupLeaderUpdate()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function CampaignBrowser:OnPlayerDead()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function CampaignBrowser:OnPlayerAlive()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
--Local XML Handlers
---------------------
local g_nextTimeUpdate
local function UpdateWaitingTooltip(control, time)
    if not g_nextTimeUpdate or time > g_nextTimeUpdate then
        g_nextTimeUpdate = time + 1
        CAMPAIGN_BROWSER:QueueRowIcon_OnMouseEnter(control)
    end
end
function CampaignBrowser:QueueRowIcon_OnMouseEnter(control)
        
    if data.state == CAMPAIGN_QUEUE_REQUEST_STATE_WAITING then
        InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
        local timeElapsed = GetSecondsInCampaignQueue(data.id, data.isGroup)
        local text = zo_strformat(SI_CAMPAIGN_BROWSER_TOOLTIP_IN_QUEUE_FOR, ZO_FormatTime(timeElapsed, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_TWELVE_HOUR))
        SetTooltipText(InformationTooltip, text)
        control:SetHandler("OnUpdate", UpdateWaitingTooltip)
    end
    
end
function CampaignBrowser:QueueRowIcon_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
    control:SetHandler("OnUpdate", nil)
    g_nextTimeUpdate = nil
end
function CampaignBrowser:RowIcon_OnMouseEnter(control)
    local campaignData = ZO_ScrollList_GetData(control:GetParent())
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
    if campaignData.id == GetAssignedCampaignId() then
        SetTooltipText(InformationTooltip, GetString(SI_CAMPAIGN_BROWSER_TOOLTIP_HOME_CAMPAIGN))
    elseif not ZO_CampaignBrowser_DoesPlayerMatchAllianceLock(campaignData) then
        local lastSecondsUntilCampaignEnd = nil
        local function UpdateTooltipText()
            local _, secondsUntilCampaignEnd = GetSelectionCampaignTimes(campaignData.selectionIndex)
            if lastSecondsUntilCampaignEnd ~= secondsUntilCampaignEnd then
                InformationTooltip:ClearLines()
                SetTooltipText(InformationTooltip, CAMPAIGN_BROWSER_MANAGER:GenerateAllianceLockStatusMessage(campaignData))
            end
        end
        control:SetHandler("OnUpdate", UpdateTooltipText)
        UpdateTooltipText()
    end
    
end
function CampaignBrowser:RowIcon_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
    control:SetHandler("OnUpdate", nil)
end
function CampaignBrowser:RowGroupMembers_OnMouseEnter(control)
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
    SetTooltipText(InformationTooltip, zo_strformat(SI_CAMPAIGN_BROWSER_TOOLTIP_NUM_GROUP_MEMBERS, data.numGroupMembers))
end
function CampaignBrowser:RowGroupMembers_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function CampaignBrowser:RowFriends_OnMouseEnter(control)
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
    SetTooltipText(InformationTooltip, zo_strformat(SI_CAMPAIGN_BROWSER_TOOLTIP_NUM_FRIENDS, data.numFriends))
end
function CampaignBrowser:RowFriends_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function CampaignBrowser:RowGuildMembers_OnMouseEnter(control)
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
    SetTooltipText(InformationTooltip, zo_strformat(SI_CAMPAIGN_BROWSER_TOOLTIP_NUM_GUILD_MEMBERS, data.numGuildMembers))
end
function CampaignBrowser:RowGuildMembers_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function CampaignBrowser:RowAlliancePopulation_OnMouseEnter(control)
    InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
    local data = control.data
    
    local textPopulation = GetString("SI_CAMPAIGNPOPULATIONTYPE", data.population)
    InformationTooltip:AddLine(textPopulation, "", ZO_NORMAL_TEXT:UnpackRGB())
    if data.alliance == GetUnitAlliance("player") then
        local queueWaitSeconds = GetSelectionCampaignQueueWaitTime(data.selectionIndex)
        if queueWaitSeconds > 0 then
            --We don't want to show an estimate for seconds
            if queueWaitSeconds < 60 then
                queueWaitSeconds = 60
            end
            queueWaitMs = queueWaitSeconds * 1000
            local textEstimatedTime = ZO_GetSimplifiedTimeEstimateText(queueWaitMs, TIME_FORMAT_STYLE_SHOW_LARGEST_UNIT, nil, ZO_TIME_ESTIMATE_STYLE.ARITHMETIC)
            textEstimatedTime = zo_strformat(SI_CAMPAIGN_BROWSER_TOOLTIP_ESTIMATED_TIME, textEstimatedTime)
            InformationTooltip:AddLine(textEstimatedTime, "", ZO_NORMAL_TEXT:UnpackRGB())
        end
    end
end
function CampaignBrowser:RowAlliancePopulation_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function CampaignBrowser:Row_OnMouseUp(control, button, upInside)
    if button == MOUSE_BUTTON_INDEX_RIGHT and upInside then
        ClearMenu()
        if self:CanQueueForCampaign() then
            AddMenuItem(GetString(SI_CAMPAIGN_BROWSER_QUEUE_CAMPAIGN), function() self:DoQueueForCampaign() end)
        end
        if self:CanSetHomeCampaign() then
            AddMenuItem(GetString(SI_CAMPAIGN_BROWSER_CHOOSE_HOME_CAMPAIGN), function() self:DoSetHomeCampaign() end)
        end
        if self:CanAbandon() then
            AddMenuItem(GetString(SI_CAMPAIGN_BROWSER_ABANDON_CAMPAIGN), function() self:DoAbandon() end)
        end
        
        self:ShowMenu(control)
    end
end
function CampaignBrowser:Row_OnMouseDoubleClick(control)
    if self:CanQueueForCampaign() then
        self:DoQueueForCampaign()
    end
end
function CampaignBrowser:QueueRow_OnMouseUp(control, button, upInside)
    if button == MOUSE_BUTTON_INDEX_RIGHT and upInside then
        ClearMenu()
        if self:CanEnter() then
            AddMenuItem(GetString(SI_CAMPAIGN_BROWSER_ENTER_CAMPAIGN), function() self:DoEnter() end)
        end
        if self:CanLeaveCampaignQueue() then
            AddMenuItem(GetString(SI_CAMPAIGN_BROWSER_LEAVE_QUEUE), function() self:DoLeaveCampaignQueue() end)
        end
        
        self:ShowMenu(control)
    end
end
function CampaignBrowser:QueueRow_OnMouseDoubleClick(control)
    if self:CanEnter() then
        self:DoEnter()
    end
end
--Global XML Handlers
-----------------------
    CAMPAIGN_BROWSER:QueueRowIcon_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:QueueRowIcon_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:RowIcon_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:RowIcon_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:RowGroupMembers_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:RowGroupMembers_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:RowFriends_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:RowFriends_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:RowGuildMembers_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:RowGuildMembers_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:RowAlliancePopulation_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:RowAlliancePopulation_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:Row_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:Row_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:Row_OnMouseUp(control, button, upInside)
end
    CAMPAIGN_BROWSER:Row_OnMouseDoubleClick(control)
end
    CAMPAIGN_BROWSER:Row_OnMouseEnter(control)
end
    CAMPAIGN_BROWSER:Row_OnMouseExit(control)
end
    CAMPAIGN_BROWSER:QueueRow_OnMouseUp(control, button, upInside)
end
    CAMPAIGN_BROWSER:QueueRow_OnMouseDoubleClick(control)
end
    CAMPAIGN_BROWSER = CampaignBrowser:New(self)
end