Back to Home

ESO Lua File v101042

ingame/companion/gamepad/companionskills_gamepad.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
-------------------------------
-- Gamepad Skills quick menu --
-------------------------------
-- This is used by the action bar to display and select from any current slottable skill, across multiple skill lines
ZO_GamepadAssignableActionBar_CompanionQuickMenu = ZO_GamepadAssignableActionBar_QuickMenu_Base:Subclass()
function ZO_GamepadAssignableActionBar_CompanionQuickMenu:SetupListTemplates()
    local function MenuAbilityEntryTemplateSetup(control, skillEntry, selected, reselectingDuringRebuild, enabled, activated)
        ZO_SharedGamepadEntry_OnSetup(control, skillEntry, selected, reselectingDuringRebuild, enabled, activated)
        ZO_GamepadCompanionSkillEntryTemplate_Setup(control, skillEntry, selected, activated, ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE)
    end
    local function MenuEntryHeaderTemplateSetup(control, skillEntry, selected, selectedDuringRebuild, enabled, activated)
        control.header:SetText(skillEntry:GetHeader())
        local skillData = skillEntry.skillData
        control.skillRankHeader:SetText(skillData:GetSkillLineData():GetCurrentRank())
    end
    local function IsSkillEqual(leftSkillEntry, rightSkillEntry)
        return leftSkillEntry.skillData == rightSkillEntry.skillData
    end
    self.list:AddDataTemplateWithHeader("ZO_GamepadSimpleAbilityEntryTemplate", MenuAbilityEntryTemplateSetup, ZO_GamepadMenuEntryTemplateParametricListFunction, IsSkillEqual, "ZO_GamepadSimpleAbilityEntryHeaderTemplate", MenuEntryHeaderTemplateSetup, "Skill")
end
do
    local function IsSkillPurchased(skillData)
        return skillData:GetPointAllocator():IsPurchased()
    end
    local function IsSkillNormalActive(skillData)
        return skillData:IsActive() and not skillData:IsUltimate()
    end
    local function IsSkillUltimate(skillData)
        return skillData:IsUltimate()
    end
    function ZO_GamepadAssignableActionBar_CompanionQuickMenu:ForEachSlottableSkill(visitor)
        local skillLineFilters = { ZO_CompanionSkillLineData.IsAvailableOrAdvised }
        local shouldShowUltimateSkills = self.assignableActionBar:IsUltimateSelected()
        local skillDataFilters = { IsSkillPurchased, shouldShowUltimateSkills and IsSkillUltimate or IsSkillNormalActive }
        for _, skillTypeData in COMPANION_SKILLS_DATA_MANAGER:SkillTypeIterator() do
            for _, skillLineData in skillTypeData:SkillLineIterator(skillLineFilters) do
                for _, skillData in skillLineData:SkillIterator(skillDataFilters) do
                    visitor(skillTypeData, skillLineData, skillData)
                end
            end
        end
    end
end
local function IsActionBarEditable()
    local lockedReason = GetActionBarLockedReason()
    if lockedReason == ACTION_BAR_LOCKED_REASON_COMBAT then
        return false, GetString("SI_RESPECRESULT", RESPEC_RESULT_IS_IN_COMBAT)
    elseif lockedReason == ACTION_BAR_LOCKED_REASON_NOT_RESPECCABLE then
        return false, GetString("SI_RESPECRESULT", RESPEC_RESULT_ACTIVE_HOTBAR_NOT_RESPECCABLE)
    end
    return true
end
-----------------------------
-- Companion Skills
-----------------------------
ZO_CompanionSkills_Gamepad = ZO_Gamepad_ParametricList_Screen:Subclass()
function ZO_CompanionSkills_Gamepad:Initialize(control)
    COMPANION_SKILLS_GAMEPAD_FRAGMENT = ZO_FadeSceneFragment:New(control)
    COMPANION_SKILLS_GAMEPAD_SCENE = ZO_InteractScene:New("companionSkillsGamepad", SCENE_MANAGER, ZO_COMPANION_MANAGER:GetInteraction())
    COMPANION_SKILLS_GAMEPAD_SCENE:AddFragment(COMPANION_SKILLS_GAMEPAD_FRAGMENT)
    local DONT_ACTIVATE_ON_SHOW = false
    ZO_Gamepad_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, DONT_ACTIVATE_ON_SHOW, COMPANION_SKILLS_GAMEPAD_SCENE)
end
function ZO_CompanionSkills_Gamepad:OnDeferredInitialize()
end
function ZO_CompanionSkills_Gamepad:InitializeHeader()
    local actionBarControl = self.header:GetNamedChild("AssignableActionBar")
    self.assignableActionBar = ZO_AssignableActionBar:New(actionBarControl)
    --Set override text used when narrating the header for the action bar entries.
    self.assignableActionBar:SetHeaderNarrationOverrideName(GetString(SI_COMPANION_BAR_ABILITY_PRIORITY))
    --Narration info for the action bar
    local narrationInfo =
    {
        canNarrate = function()
            return COMPANION_SKILLS_GAMEPAD_SCENE:IsShowing() and self.assignableActionBar:IsActive()
        end,
        selectedNarrationFunction = function()
            return self.assignableActionBar:GetNarrationText()
        end,
    }
    SCREEN_NARRATION_MANAGER:RegisterCustomObject("companionAssignableActionBar", narrationInfo)
    local actionBarBackground = self.control:GetNamedChild("ActionBarBackground")
    actionBarBackground:SetAnchor(TOPLEFT, actionBarControl, TOPLEFT, 0, 0)
    actionBarBackground:SetAnchor(BOTTOMRIGHT, actionBarControl, BOTTOMRIGHT, 0, 30)
    self.actionBarFocusAnimation = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_GamepadSkillsActionBarFocusAnimation")
    local ACTION_BAR_TRANSLATE_ANIMATION = 1
    self.actionBarFocusAnimation:GetAnimation(ACTION_BAR_TRANSLATE_ANIMATION):SetAnimatedControl(actionBarControl)
    local ACTION_BAR_BACKGROUND_FADE_ANIMATION = 2
    self.actionBarFocusAnimation:GetAnimation(ACTION_BAR_BACKGROUND_FADE_ANIMATION):SetAnimatedControl(actionBarBackground)
    self:SetupHeaderFocus(self.assignableActionBar)
    local headerKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = function()
                if self.assignableActionBar:IsAssigningTargetSkill() then
                    return GetString(SI_GAMEPAD_SKILLS_ASSIGN)
                else
                    return GetString(SI_GAMEPAD_SKILLS_BUILD_PLANNER)
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            enabled = function()
                local canEdit, lockText = IsActionBarEditable()
                if not canEdit then
                    return false, lockText
                end
                if self.assignableActionBar:IsActive() then
                    local slotIndex = self.assignableActionBar:GetSelectedSlotIndex()
                    local result = ACTION_BAR_ASSIGNMENT_MANAGER:GetCurrentHotbar():GetExpectedSlotEditResult(slotIndex)
                    if result ~= HOT_BAR_RESULT_SUCCESS then
                        return false, GetString("SI_HOTBARRESULT", result)
                    end
                end
                return true
            end,
            callback = function()
                if self.assignableActionBar:IsAssigningTargetSkill() then
                    self.assignableActionBar:AssignTargetSkill()
                    self:LeaveSkillAssignment()
                else
                    self.quickMenu:Show()
                    PlaySound(SOUNDS.GAMEPAD_MENU_FORWARD)
                end
            end,
        }
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(headerKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON, function()
        if self.assignableActionBar:IsAssigningTargetSkill() then
            self.assignableActionBar:ClearTargetSkill()
            self:LeaveSkillAssignment()
        else
            self.assignableActionBar:Deactivate()
            self:RequestLeaveCurrentList()
        end
    end)
    self.headerKeybindStripDescriptor = headerKeybindStripDescriptor
    self:RefreshHeader()
end
function ZO_CompanionSkills_Gamepad:RefreshHeader()
    local currentListDescriptor = self:GetCurrentListDescriptor()
    if currentListDescriptor and currentListDescriptor.headerData then
        ZO_GamepadGenericHeader_Refresh(self.header, currentListDescriptor.headerData)
    end
    self.assignableActionBar:Refresh()
end
function ZO_CompanionSkills_Gamepad:InitializeFooter()
    self.footerControl = ZO_CompanionSkills_Gamepad_Footer
    self.footerFragment = ZO_FadeSceneFragment:New(self.footerControl)
end
function ZO_CompanionSkills_Gamepad:RefreshFooter()
    local selectedSkillLineData = self:GetSelectedSkillLineData()
    if selectedSkillLineData then
        local NO_WRAP = true
        ZO_GamepadSkillLineXpBar_Setup(selectedSkillLineData, self.footerControl.xpBar, self.footerControl.name, NO_WRAP)
        SCENE_MANAGER:AddFragment(self.footerFragment)
    else
        SCENE_MANAGER:RemoveFragment(self.footerFragment)
    end
end
function ZO_CompanionSkills_Gamepad:TryClearSkillLineNewStatus()
    if self.clearSkillLineStatusOnSelectionChanged then
        self.clearSkillLineStatusOnSelectionChanged = false
        self.clearSkillLineNewStatusSkillLineData:ClearNew()
        self.skillLineListRefreshGroup:MarkDirty("Visible")
    end
end
function ZO_CompanionSkills_Gamepad:ResetSkillLineNewStatus()
    self.clearSkillLineNewStatusCallId = nil
    self.clearSkillLineNewStatusSkillLineData = nil
end
function ZO_CompanionSkills_Gamepad:TrySetClearNewSkillLineFlag(callId)
    if self.clearSkillLineNewStatusCallId == callId then
        self.clearSkillLineStatusOnSelectionChanged = true
    end
end
local TIME_NEW_PERSISTS_WHILE_SELECTED = 1000
function ZO_CompanionSkills_Gamepad:CheckSkillLineNewStatus()
    local selectedSkillLineData = self:GetSelectedSkillLineData()
    if selectedSkillLineData then
        if selectedSkillLineData:IsSkillLineOrAbilitiesNew() then
            -- mark the current skill line, so we can clear it after it clears the persist time
            self.clearSkillLineNewStatusSkillLineData = selectedSkillLineData
            local function MarkSkillLineReadyToClear(callId)
                if self.clearSkillLineNewStatusCallId == callId then
                    self.clearSkillLineStatusOnSelectionChanged = true
                end
            end
            self.clearSkillLineNewStatusCallId = zo_callLater(MarkSkillLineReadyToClear, TIME_NEW_PERSISTS_WHILE_SELECTED)
        else
            -- cancel last pending clear, if it has not yet fired
            self.clearSkillLineNewStatusCallId = nil
        end
    else
        -- cancel last pending clear, if it has not yet fired
        self.clearSkillLineNewStatusCallId = nil
    end
end
-- skill lines
function ZO_CompanionSkills_Gamepad:InitializeSkillLinesList()
    local function SkillLineEntryTemplateSetup(control, data, selected, reselectingDuringRebuild, enabled, activated)
        data:SetText(data.skillLineData:GetFormattedName())
        ZO_SharedGamepadEntry_OnSetup(control, data, selected, reselectingDuringRebuild, enabled, activated)
        ZO_GamepadSkillLineEntryTemplate_Setup(control, data, selected)
    end
    local function AreSkillLineEntriesEqual(left, right)
        return left.skillLineData == right.skillLineData
    end
    local function SetupSkillLineList(list)
        list:SetHandleDynamicViewProperties(true)
        local DEFAULT_HEADER_SETUP = nil
        list:AddDataTemplateWithHeader("ZO_GamepadSkillLineEntryTemplate", SkillLineEntryTemplateSetup, ZO_GamepadMenuEntryTemplateParametricListFunction, AreSkillLineEntriesEqual, "ZO_GamepadMenuEntryHeaderTemplate", DEFAULT_HEADER_SETUP, "SkillLine")
    end
    local skillLineList = self:AddList("SkillLine", SetupSkillLineList)
    local function OnSelectedSkillLineChanged()
        self.skillListRefreshGroup:MarkDirty("List")
        self:RefreshTooltip()
        self:RefreshKeybinds()
        self:RefreshFooter()
        self:CheckSkillLineNewStatus()
    end
    -- Keybind strip
    local skillLineKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                local targetData = skillLineList:GetTargetData()
                if targetData and not targetData.advised then 
                    self:ShowListDescriptor(self.skillListDescriptor)
                end
            end,
            visible = function()
                return skillLineList:GetTargetData() ~= nil
            end,
        }
    }
    local function RefreshTooltipCallback(list)
        if self.assignableActionBar:IsActive() then
            self.assignableActionBar:LayoutOrClearSlotTooltip(GAMEPAD_LEFT_TOOLTIP)
            return
        end
        local selectedData = list:GetTargetData()
        if selectedData then 
            local skillLineData = selectedData.skillLineData
            GAMEPAD_TOOLTIPS:LayoutCompanionSkillLinePreview(GAMEPAD_LEFT_TOOLTIP, skillLineData)
        end
    end
    local function LeaveListCallback()
        SCENE_MANAGER:HideCurrentScene()
    end
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(skillLineKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON, function()
        self:RequestLeaveCurrentList()
    end)
    self.skillLineListDescriptor =
    {
        list = skillLineList,
        keybindDescriptor = skillLineKeybindStripDescriptor,
        leaveListCallback = LeaveListCallback,
        headerData =
        {
            titleText = GetString(SI_COMPANION_MENU_SKILLS_TITLE),
        },
    }
    local skillLineListRefreshGroup = ZO_OrderedRefreshGroup:New(ZO_ORDERED_REFRESH_GROUP_AUTO_CLEAN_IMMEDIATELY)
    skillLineListRefreshGroup:AddDirtyState("List", function()
        self:BuildSkillLineList(skillLineList)
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillLineListRefreshGroup:AddDirtyState("Visible", function()
        skillLineList:RefreshVisible()
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillLineListRefreshGroup:AddDirtyState("Tooltip", function()
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillLineListRefreshGroup:SetActive(function()
        return self:IsCurrentListDescriptor(self.skillLineListDescriptor)
    end)
    self.skillLineListRefreshGroup = skillLineListRefreshGroup
end
local AVAILABLE_COMPANION_SKILLS_FILTER = { ZO_CompanionSkillLineData.IsAvailableOrAdvised }
function ZO_CompanionSkills_Gamepad:BuildSkillLineList(list)
    list:Clear()
    for _, skillTypeData in COMPANION_SKILLS_DATA_MANAGER:SkillTypeIterator() do
        local hasHeader = true
        for _, skillLineData in skillTypeData:SkillLineIterator(AVAILABLE_COMPANION_SKILLS_FILTER) do
            local function IsSkillLineNew()
                return skillLineData:IsSkillLineOrAbilitiesNew()
            end
            local data = ZO_GamepadEntryData:New()
            data:SetNew(IsSkillLineNew)
            data.skillLineData = skillLineData
            if hasHeader then
                data:SetHeader(skillTypeData:GetName())  
                list:AddEntry("ZO_GamepadSkillLineEntryTemplateWithHeader", data)
            else
                list:AddEntry("ZO_GamepadSkillLineEntryTemplate", data)
            end
            hasHeader = false
        end
    end
    list:Commit()
end
function ZO_CompanionSkills_Gamepad:GetSelectedSkillLineData()
    return self.skillLineListDescriptor.list:GetTargetData().skillLineData
end
-- skills
function ZO_CompanionSkills_Gamepad:InitializeSkillsList()
    local function MenuAbilityEntryTemplateSetup(control, skillEntry, selected, reselectingDuringRebuild, enabled, activated)
        ZO_SharedGamepadEntry_OnSetup(control, skillEntry, selected, reselectingDuringRebuild, enabled, activated)
        ZO_GamepadCompanionSkillEntryTemplate_Setup(control, skillEntry, selected, activated, ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE)
    end
    local function IsSkillEqual(leftSkillEntry, rightSkillEntry)
        return leftSkillEntry.skillData == rightSkillEntry.skillData
    end
    local function SetupSkillList(list)
        list:SetHandleDynamicViewProperties(true)
        local DEFAULT_HEADER_SETUP = nil
        list:AddDataTemplateWithHeader("ZO_GamepadAbilityEntryTemplate", MenuAbilityEntryTemplateSetup, ZO_GamepadMenuEntryTemplateParametricListFunction, IsSkillEqual, "ZO_GamepadMenuEntryHeaderTemplate", DEFAULT_HEADER_SETUP, "Skill")
    end
    local skillList = self:AddList("LineFilter", SetupSkillList)
    local function OnSelectedSkillChanged()
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end
    -- Keybind strip
    local skillListKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = GetString(SI_GAMEPAD_SKILLS_ASSIGN),
            keybind = "UI_SHORTCUT_SECONDARY",
            visible = function()
                local skillEntry = skillList:GetTargetData()
                if skillEntry then
                    local skillData = skillEntry.skillData
                    return skillData:IsActive() and skillData:GetPointAllocator():IsPurchased()
                end
                return false
            end,
            enabled = IsActionBarEditable,
            callback = function()
                local skillEntry = skillList:GetTargetData()
                self:StartAssigningSkill(skillEntry.skillData)
            end,
        }
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(skillListKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON, function()
        self:RequestLeaveCurrentList()
    end)
    local function LeaveListCallback()
        self:ShowListDescriptor(self.skillLineListDescriptor)
    end
    local function RefreshTooltipCallback(list)
        local skillEntry = list:GetTargetData()
        if skillEntry then
            local skillData = skillEntry.skillData
            local skillProgressionData = skillData:GetPointAllocatorProgressionData()
            if self.assignableActionBar:IsAssigningTargetSkill() then
                GAMEPAD_TOOLTIPS:LayoutCompanionSkillProgression(GAMEPAD_LEFT_TOOLTIP, skillProgressionData)
                self.assignableActionBar:LayoutOrClearSlotTooltip(GAMEPAD_RIGHT_TOOLTIP)
                -- show comparison between slot and list skills
            elseif self.assignableActionBar:IsActive() then
                -- show slotted skill only
                self.assignableActionBar:LayoutOrClearSlotTooltip(GAMEPAD_LEFT_TOOLTIP)
            else
                -- show target skill only
                GAMEPAD_TOOLTIPS:LayoutCompanionSkillProgression(GAMEPAD_LEFT_TOOLTIP, skillProgressionData)
            end
        end
    end
    self.skillListDescriptor =
    {
        list = skillList,
        keybindDescriptor = skillListKeybindStripDescriptor,
        leaveListCallback = LeaveListCallback,
        headerData =
        {
            titleText = function()
                return self:GetSelectedSkillLineData():GetFormattedName()
            end,
        },
    }
    local skillListRefreshGroup = ZO_OrderedRefreshGroup:New(ZO_ORDERED_REFRESH_GROUP_AUTO_CLEAN_IMMEDIATELY)
    skillListRefreshGroup:AddDirtyState("List", function()
        self:BuildSkillsList(skillList)
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillListRefreshGroup:AddDirtyState("Visible", function()
        skillList:RefreshVisible()
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillListRefreshGroup:AddDirtyState("Tooltip", function()
        self:RefreshTooltip()
        self:RefreshKeybinds()
    end)
    skillListRefreshGroup:SetActive(function()
        return self:IsCurrentListDescriptor(self.skillListDescriptor)
    end)
    self.skillListRefreshGroup = skillListRefreshGroup
end
function ZO_CompanionSkills_Gamepad:BuildSkillsList(list)
    list:Clear()
    local skillLineData = self:GetSelectedSkillLineData()
    local lastHeaderText = nil
    for _, skillData in skillLineData:SkillIterator() do
        local skillEntry = ZO_GamepadEntryData:New()
        skillEntry:SetFontScaleOnSelection(false)
        skillEntry.skillData = skillData
        local headerText = skillData:GetHeaderText()
        if lastHeaderText ~= headerText then
            skillEntry:SetHeader(headerText)
            list:AddEntry("ZO_GamepadAbilityEntryTemplateWithHeader", skillEntry)
        else
            list:AddEntry("ZO_GamepadAbilityEntryTemplate", skillEntry)
        end
        lastHeaderText = headerText
    end
    list:Commit()
end
function ZO_CompanionSkills_Gamepad:InitializeQuickMenu()
    local quickMenuControl = self.control:GetNamedChild("QuickMenu")
    self.quickMenu = ZO_GamepadAssignableActionBar_CompanionQuickMenu:New(quickMenuControl, self.assignableActionBar)
    local X_OFFSET = 30
    local Y_OFFSET = 15
    local quickMenuList = self.quickMenu:GetListControl()
    quickMenuList:ClearAnchors()
    quickMenuList:SetAnchor(TOPLEFT, self.header, BOTTOMLEFT, -X_OFFSET, Y_OFFSET)
    quickMenuList:SetAnchor(BOTTOMRIGHT, self.control, BOTTOMRIGHT, X_OFFSET, 0)
end
function ZO_CompanionSkills_Gamepad:RegisterForEvents()
    local function FullRebuild()
        self.skillLineListRefreshGroup:MarkDirty("List")
        self.skillListRefreshGroup:MarkDirty("List")
    end
    local function OnSkillLineUpdated(skillLineData)
        --For the skill line rank on each entry and the skill line XP bar on the selected entry
        self.skillLineListRefreshGroup:MarkDirty("Visible")
        --For the locked/unlocked display on a skill
        self.skillListRefreshGroup:MarkDirty("Visible")
    end
    local function OnSkillLineAdded(skillLineData)
        --To add the new skill line to the list
        self.skillLineListRefreshGroup:MarkDirty("List")
    end
    local function OnCurrentHotbarUpdated()
        --Refresh slotted indicator on skill
        self.skillListRefreshGroup:MarkDirty("Visible")
        --Refresh action bar tooltips if skill line visible
        self.skillLineListRefreshGroup:MarkDirty("Tooltip")
    end
    self.control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, FullRebuild)
    COMPANION_SKILLS_DATA_MANAGER:RegisterCallback("FullSystemUpdated", FullRebuild)
    COMPANION_SKILLS_DATA_MANAGER:RegisterCallback("SkillLineUpdated", OnSkillLineUpdated)
    COMPANION_SKILLS_DATA_MANAGER:RegisterCallback("SkillLineAdded", OnSkillLineAdded)
    ACTION_BAR_ASSIGNMENT_MANAGER:RegisterCallback("CurrentHotbarUpdated", OnCurrentHotbarUpdated)
    local function OnPurchaseLockStateChanged()
        self:RefreshKeybinds()
    end
    self.control:RegisterForEvent(EVENT_ACTION_BAR_LOCKED_REASON_CHANGED, OnPurchaseLockStateChanged)
    --action bar
    local function OnSelectedActionBarButtonChanged(selectedSlotIndex, didSlotTypeChange)
        -- refresh action bar tooltips and keybinds
        self:RefreshTooltip()
        self:RefreshKeybinds()
        --Re-narrate when the selection changes
        SCREEN_NARRATION_MANAGER:QueueCustomEntry("companionAssignableActionBar")
    end
    self.assignableActionBar:RegisterCallback("SelectedButtonChanged", OnSelectedActionBarButtonChanged)
    -- set initial state
    self.skillLineListRefreshGroup:MarkDirty("List")
    self.skillListRefreshGroup:MarkDirty("List")
    self.assignableActionBar:Refresh()
end
function ZO_CompanionSkills_Gamepad:TryClean()
    self.skillLineListRefreshGroup:TryClean()
    self.skillListRefreshGroup:TryClean()
end
-- Parametric scroll list overrides
function ZO_CompanionSkills_Gamepad:PerformUpdate()
    self.dirty = false
end
function ZO_CompanionSkills_Gamepad:RefreshTooltip()
    if not self:IsShowing() then
        return
    end
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_LEFT_TOOLTIP)
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    if self.quickMenu:IsShowing() then
        self.quickMenu:RefreshTooltip()
    elseif self.currentListDescriptor then
        self.currentListDescriptor.refreshTooltipCallback(self.currentListDescriptor.list)
    end
end
function ZO_CompanionSkills_Gamepad:IsShowing()
    return COMPANION_SKILLS_GAMEPAD_SCENE:IsShowing()
end
function ZO_CompanionSkills_Gamepad:OnShowing()
    ACTION_BAR_ASSIGNMENT_MANAGER:SetHotbarCycleOverride(HOTBAR_CATEGORY_COMPANION)
    self:ShowListDescriptor(self.skillLineListDescriptor)
    -- base class requires a list to setup the header
    ZO_Gamepad_ParametricList_Screen.OnShowing(self)
    self.actionBarFocusAnimation:PlayInstantlyToStart()
    self:TryClean()
    self:RefreshTooltip()
    self:RefreshFooter()
end
function ZO_CompanionSkills_Gamepad:OnHide()
    ZO_Gamepad_ParametricList_Screen.OnHide(self)
    if self.assignableActionBar:IsAssigningTargetSkill() then
        self.assignableActionBar:ClearTargetSkill()
        self:LeaveSkillAssignment()
    end
    ACTION_BAR_ASSIGNMENT_MANAGER:SetHotbarCycleOverride(nil)
end
function ZO_CompanionSkills_Gamepad:ShowListDescriptor(listDescriptor)
    if self.currentListDescriptor == listDescriptor then
        return
    end
    self.currentListDescriptor = listDescriptor
    if listDescriptor then
        self:SetCurrentList(listDescriptor.list)
        self:RefreshHeader()
        self:UpdateActiveKeybindStrip()
        self:TryClean()
        self:RefreshTooltip()
    end
end
function ZO_CompanionSkills_Gamepad:HideCurrentListDescriptor()
    if self.currentListDescriptor then
        self:DisableCurrentList()
        self.currentListDescriptor = nil
        self:UpdateActiveKeybindStrip()
    end
end
function ZO_CompanionSkills_Gamepad:ActivateCurrentListDescriptor()
    if self.currentListDescriptor then
        self:UpdateActiveKeybindStrip()
        self:RefreshTooltip()
    end
end
function ZO_CompanionSkills_Gamepad:DeactivateCurrentListDescriptor()
    if self.currentListDescriptor then
        self:UpdateActiveKeybindStrip()
        self:RefreshTooltip()
    end
end
function ZO_CompanionSkills_Gamepad:GetCurrentListDescriptor()
    return self.currentListDescriptor
end
function ZO_CompanionSkills_Gamepad:IsCurrentListDescriptor(listDescriptor)
    return self.currentListDescriptor == listDescriptor
end
function ZO_CompanionSkills_Gamepad:RefreshKeybinds()
    ZO_Gamepad_ParametricList_Screen.RefreshKeybinds(self)
    if self.currentKeybindStripDescriptor then
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.currentKeybindStripDescriptor)
    end
end
function ZO_CompanionSkills_Gamepad:UpdateActiveKeybindStrip()
    -- if no keybind strip should be active, then target will be nil
    local targetKeybindStripDescriptor = nil
    if self:IsHeaderActive() then
        targetKeybindStripDescriptor = self.headerKeybindStripDescriptor
    else
        local currentListDescriptor = self:GetCurrentListDescriptor()
        if currentListDescriptor and currentListDescriptor.keybindDescriptor then
            targetKeybindStripDescriptor = currentListDescriptor.keybindDescriptor
        end
    end
    if self.currentKeybindStripDescriptor ~= targetKeybindStripDescriptor then
        if self.currentKeybindStripDescriptor then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.currentKeybindStripDescriptor)
        end
        if targetKeybindStripDescriptor then
            KEYBIND_STRIP:AddKeybindButtonGroup(targetKeybindStripDescriptor)
        end
        self.currentKeybindStripDescriptor = targetKeybindStripDescriptor
    end
end
function ZO_CompanionSkills_Gamepad:RequestLeaveCurrentList()
    local currentListDescriptor = self:GetCurrentListDescriptor()
    if currentListDescriptor and currentListDescriptor.leaveListCallback then
        currentListDescriptor.leaveListCallback()
    end
end
function ZO_CompanionSkills_Gamepad:ActivateAssignableActionBarFromList()
    self.assignableActionBar:SelectMostRecentlySelectedButton()
    self.assignableActionBar:Activate()
end
function ZO_CompanionSkills_Gamepad:OnEnterHeader()
    PlaySound(SOUNDS.GAMEPAD_MENU_UP)
end
function ZO_CompanionSkills_Gamepad:OnLeaveHeader()
    self.assignableActionBar:Deactivate()
    PlaySound(SOUNDS.GAMEPAD_MENU_DOWN)
end
function ZO_CompanionSkills_Gamepad:StartAssigningSkill(skillData)
    self.assignableActionBar:SetTargetSkill(skillData)
    self.assignableActionBar:Activate()
    self.actionBarFocusAnimation:PlayFromStart()
end
function ZO_CompanionSkills_Gamepad:LeaveSkillAssignment()
    self.actionBarFocusAnimation:PlayFromEnd()
    self.assignableActionBar:Deactivate()
    self:ShowListDescriptor(self.skillListDescriptor)
end
-----------------------------
-- Global XML Functions
-----------------------------
    COMPANION_SKILLS_GAMEPAD = ZO_CompanionSkills_Gamepad:New(control)
end