Back to Home

ESO Lua File v100022

ingame/skills/keyboard/zo_skills.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
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
local skillTypeToSound =
{
    [SKILL_TYPE_CLASS] = SOUNDS.SKILL_TYPE_CLASS,
    [SKILL_TYPE_WEAPON] = SOUNDS.SKILL_TYPE_WEAPON,
    [SKILL_TYPE_ARMOR] = SOUNDS.SKILL_TYPE_ARMOR,
    [SKILL_TYPE_WORLD] = SOUNDS.SKILL_TYPE_WORLD,
    [SKILL_TYPE_GUILD] = SOUNDS.SKILL_TYPE_GUILD,
    [SKILL_TYPE_AVA] = SOUNDS.SKILL_TYPE_AVA,
    [SKILL_TYPE_RACIAL] = SOUNDS.SKILL_TYPE_RACIAL,
    [SKILL_TYPE_TRADESKILL] = SOUNDS.SKILL_TYPE_TRADESKILL,
}
-- Skill Manager
--------------------
local SKILL_ABILITY_DATA = 1
local SKILL_HEADER_DATA = 2
ZO_SkillsManager = ZO_CallbackObject:Subclass()
function ZO_SkillsManager:New(...)
    local manager = ZO_CallbackObject.New(self)
    manager:Initialize(...)
    return manager
end
function ZO_SkillsManager:Initialize(container)
    SKILLS_FRAGMENT = ZO_FadeSceneFragment:New(container)
    self.displayedAbilityProgressions = {}
    self.container = container
    self.availablePoints = 0
    self.skyShards = 0
    self.availablePointsLabel = GetControl(container, "AvailablePoints")
    self.skyShardsLabel = GetControl(container, "SkyShards")
    self.abilityList = GetControl(container, "AbilityList")
    self.advisedOverlayControl = container:GetNamedChild("SkillLineAdvisedOverlay")
    self.skillLineUnlockTitleControl = self.advisedOverlayControl:GetNamedChild("SkillLineUnlockTitle")
    self.skillLineUnlockTextControl = self.advisedOverlayControl:GetNamedChild("SkillLineUnlockText")
    self.showAdvisorInAdvancedMode = false
    self.navigationContainer = GetControl(container, "NavigationContainer")
    self.navigationTree = ZO_Tree:New(self.navigationContainer:GetNamedChild("ScrollChild"), 74, -10, 300)
    self.skillTypeToNode = {}
    local function TreeHeaderSetup(node, control, skillType, open)
        control.skillType = skillType
        control.text:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        control.text:SetText(GetString("SI_SKILLTYPE", skillType))
        local down, up, over = ZO_Skills_GetIconsForSkillType(skillType)
        control.icon:SetTexture(open and down or up)
        control.iconHighlight:SetTexture(over)
        control.statusIcon:ClearIcons()
        if NEW_SKILL_CALLOUTS:AreAnySkillLinesInTypeNew(skillType) then
            control.statusIcon:AddIcon(ZO_KEYBOARD_NEW_ICON)
        end
        control.statusIcon:Show()
        
        ZO_IconHeader_Setup(control, open)
    end
    self.navigationTree:AddTemplate("ZO_SkillIconHeader", TreeHeaderSetup, nil, nil, nil, 0)
    local function TreeEntrySetup(node, control, data, open)
        local name, _, _, _, advised = GetSkillLineInfo(data.skillType, data.skillLineIndex)
        control:SetText(zo_strformat(SI_SKILLS_TREE_NAME_FORMAT, name))
        control.statusIcon:ClearIcons()
        if NEW_SKILL_CALLOUTS:IsSkillLineNew(data.skillType, data.skillLineIndex) or advised then
            control.statusIcon:AddIcon(ZO_KEYBOARD_NEW_ICON)
        end
        control.statusIcon:Show()
    end
    local function TreeEntryOnSelected(control, data, selected, reselectingDuringRebuild)
        control:SetSelected(selected)
        if selected and not reselectingDuringRebuild then
            self:RefreshSkillInfo()
            self:RefreshList()
            NEW_SKILL_CALLOUTS:ClearSkillLineNewStatus(data.skillType, data.skillLineIndex)
        end
    end
    local function TreeEntryEquality(left, right)
        return left.skillType == right.skillType and left.skillLineIndex == right.skillLineIndex
    end
    self.navigationTree:AddTemplate("ZO_SkillsNavigationEntry", TreeEntrySetup, TreeEntryOnSelected, TreeEntryEquality)
    self.navigationTree:SetExclusive(true)
    self.navigationTree:SetOpenAnimation("ZO_TreeOpenAnimation")
    self.skillInfo = GetControl(container, "SkillInfo")
    ZO_ScrollList_Initialize(self.abilityList)
    ZO_ScrollList_AddDataType(self.abilityList, SKILL_ABILITY_DATA, "ZO_Skills_Ability", 70, function(control, data) self:SetupAbilityEntry(control, data, ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE) end)
    ZO_ScrollList_AddDataType(self.abilityList, SKILL_HEADER_DATA, "ZO_Skills_AbilityTypeHeader", 32, function(control, data) self:SetupHeaderEntry(control, data) end)
    self.warning = GetControl(container, "Warning")
    -- initialize dialogs
    -- event registration
    local function Refresh()
        self:Refresh()
    end
    local function OnSkillLineUpdate(event, skillType, skillIndex)
        if self:GetSelectedSkillType() == skillType and skillIndex == self:GetSelectedSkillLineIndex() then
            self:RefreshSkillInfo()
            self:RefreshList()
        end
    end
    local function OnAbilityProgressionUpdate(event, progressionIndex)
        if self.displayedAbilityProgressions[progressionIndex] then
            self:RefreshList()
        end
    end
    local function OnSkillPointsChanged()
        self:RefreshSkillInfo()
        self:RefreshList()
    end
    local function OnSkillAbilityProgressionsUpdated()
        self:RefreshList()
    end
    container:RegisterForEvent(EVENT_SKILL_RANK_UPDATE, OnSkillLineUpdate)
    container:RegisterForEvent(EVENT_SKILL_XP_UPDATE, OnSkillLineUpdate)
    container:RegisterForEvent(EVENT_SKILLS_FULL_UPDATE, Refresh)
    container:RegisterForEvent(EVENT_SKILL_POINTS_CHANGED, OnSkillPointsChanged)
    container:RegisterForEvent(EVENT_SKILL_ABILITY_PROGRESSIONS_UPDATED, OnSkillAbilityProgressionsUpdated)
    container:RegisterForEvent(EVENT_PLAYER_ACTIVATED, Refresh)
    container:RegisterForEvent(EVENT_ABILITY_PROGRESSION_RANK_UPDATE, OnAbilityProgressionUpdate)
    container:RegisterForEvent(EVENT_ABILITY_PROGRESSION_XP_UPDATE, OnAbilityProgressionUpdate)
    container:RegisterForEvent(EVENT_SKILL_BUILD_SELECTION_UPDATED, function(eventId, ...) 
        self.showAdvisorInAdvancedMode = false
        self:UpdateSkillsAdvisorVisibility() 
    end)
    container:RegisterForEvent(EVENT_ACTIVE_WEAPON_PAIR_CHANGED, function()
        TUTORIAL_SYSTEM:RemoveTutorialByTrigger(TUTORIAL_TYPE_POINTER_BOX, TUTORIAL_TRIGGER_WEAPON_SWAP_SHOWN_IN_SKILLS_AFTER_UNLOCK)
    end)
    -- callbacks
    local function OnNewStatusChanged()
        self.navigationTree:RefreshVisible()
        MAIN_MENU_KEYBOARD:RefreshCategoryIndicators()
    end
    NEW_SKILL_CALLOUTS:RegisterCallback("OnSkillLineNewStatusChanged", OnNewStatusChanged)
    NEW_SKILL_CALLOUTS:RegisterCallback("OnAbilityUpdatedStatusChanged", OnNewStatusChanged)
    do
    --Weapon Swap Tutorial Setup
        local tutorialAnchor = ZO_Anchor:New(RIGHT, ZO_ActionBar1WeaponSwap, LEFT, -10, 0)
        TUTORIAL_SYSTEM:RegisterTriggerLayoutInfo(TUTORIAL_TYPE_POINTER_BOX, TUTORIAL_TRIGGER_WEAPON_SWAP_SHOWN_IN_SKILLS_AFTER_UNLOCK, self.container, SKILLS_FRAGMENT, tutorialAnchor)
    end
end
function ZO_SkillsManager:UpdateSkillsAdvisorVisibility()
    if not IsInGamepadPreferredMode() then
        if not ZO_SKILLS_ADVISOR_SINGLETON:IsAdvancedModeSelected() or self.showAdvisorInAdvancedMode then
            SCENE_MANAGER:RemoveFragment(FRAME_TARGET_STANDARD_RIGHT_PANEL_FRAGMENT)
            SCENE_MANAGER:RemoveFragment(FRAME_TARGET_BLUR_STANDARD_RIGHT_PANEL_FRAGMENT)
            SCENE_MANAGER:AddFragment(FRAME_TARGET_STANDARD_RIGHT_PANEL_MEDIUM_LEFT_PANEL_FRAGMENT)
            SCENE_MANAGER:AddFragment(FRAME_TARGET_BLUR_STANDARD_RIGHT_PANEL_MEDIUM_LEFT_PANEL_FRAGMENT)
            SCENE_MANAGER:AddFragment(SKILLS_ADVISOR_FRAGMENT)
        else
            SCENE_MANAGER:RemoveFragment(SKILLS_ADVISOR_FRAGMENT)
            SCENE_MANAGER:RemoveFragment(FRAME_TARGET_STANDARD_RIGHT_PANEL_MEDIUM_LEFT_PANEL_FRAGMENT)
            SCENE_MANAGER:RemoveFragment(FRAME_TARGET_BLUR_STANDARD_RIGHT_PANEL_MEDIUM_LEFT_PANEL_FRAGMENT)
            SCENE_MANAGER:AddFragment(FRAME_TARGET_STANDARD_RIGHT_PANEL_FRAGMENT)
            SCENE_MANAGER:AddFragment(FRAME_TARGET_BLUR_STANDARD_RIGHT_PANEL_FRAGMENT)
        end
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_SkillsManager:IsSkillsAdvisorShown()
    return not ZO_SKILLS_ADVISOR_SINGLETON:IsAdvancedModeSelected() or self.showAdvisorInAdvancedMode
end 
function ZO_SkillsManager:InitializeKeybindDescriptors()
    self.keybindStripDescriptor =
    {
          alignment = KEYBIND_STRIP_ALIGN_LEFT,
          {
               name = function()
                if self.showAdvisorInAdvancedMode then
                    return GetString(SI_CLOSE_SKILLS_ADVISOR_KEYBIND)
                else
                    return GetString(SI_OPEN_SKILLS_ADVISOR_KEYBIND)
                end
            end,
               keybind = "UI_SHORTCUT_QUATERNARY",
               callback = function()
                self.showAdvisorInAdvancedMode = not self.showAdvisorInAdvancedMode
                self:UpdateSkillsAdvisorVisibility()
               end,
               visible = function()
                    return ZO_SKILLS_ADVISOR_SINGLETON:IsAdvancedModeSelected()
               end
          },
    }
end
function ZO_SkillsManager:StopSelectedSkillBuildSkillAnimations()
    if self.selectedSkillBuildIconTimeline and self.selectedSkillBuildIconTimeline:IsPlaying() then
        self.selectedSkillBuildIconTimeline:Stop()
    end
    if self.selectedSkillBuildIconLoopTimeline and self.selectedSkillBuildIconLoopTimeline:IsPlaying() then
        self.selectedSkillBuildIconLoopTimeline:Stop()
    end
    if self.selectedSkillBuildAlertTimeline and self.selectedSkillBuildAlertTimeline:IsPlaying() then
        self.selectedSkillBuildAlertTimeline:Stop()
    end
    if self.selectedSkillBuildAlertLoopTimeline and self.selectedSkillBuildAlertLoopTimeline:IsPlaying() then
        self.selectedSkillBuildAlertLoopTimeline:Stop()
    end
end
function ZO_SkillsManager:PlaySelectedSkillBuildSkillAnimations(abilityControl)
    if abilityControl then
        -- If animation if currently playing then stop it before starting new animation
        if not self.selectedSkillBuildIconTimeline then 
            self.selectedSkillBuildIconTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("SkillBuildSelectionIconAnim")
        end
        if not self.selectedSkillBuildIconLoopTimeline then 
            self.selectedSkillBuildIconLoopTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("SkillBuildSelectionIconLoopAnim")
        end
        local abilitySlotControl = abilityControl:GetNamedChild("Slot")
        local abilitySlotAnimTexture = abilitySlotControl:GetNamedChild("SelectedSkillBuildIconAnim")
        local iconAnimationObject = self.selectedSkillBuildIconTimeline:GetFirstAnimation()
        local iconAnimationLoopObject = self.selectedSkillBuildIconLoopTimeline:GetFirstAnimation()
        local skillsObject = self
        local textureFile = ""
        local loopTextureFile = ""
        if abilityControl.passive then
            if ZO_SKILLS_ADVISOR_SINGLETON:IsAbilityInSelectedSkillBuild(abilityControl.skillType, abilityControl.lineIndex, abilityControl.index, abilityControl.skillBuildMorphChoice, abilityControl.skillBuildRankIndex) then
                textureFile = "EsoUI/Art/SkillsAdvisor/animation_circle_1024x64_FLASH.dds"
                loopTextureFile = "EsoUI/Art/SkillsAdvisor/animation_circle_4096x64.dds"
            else
                textureFile = "EsoUI/Art/SkillsAdvisor/animation_circleSingle_1024x64_FLASH.dds"
                loopTextureFile = "EsoUI/Art/SkillsAdvisor/animation_circleSingle_4096x64.dds"
            end
        else
            if ZO_SKILLS_ADVISOR_SINGLETON:IsAbilityInSelectedSkillBuild(abilityControl.skillType, abilityControl.lineIndex, abilityControl.index, abilityControl.skillBuildMorphChoice, abilityControl.skillBuildRankIndex) then
                textureFile = "EsoUI/Art/SkillsAdvisor/animation_square_1024x64_FLASH.dds"
                loopTextureFile = "EsoUI/Art/SkillsAdvisor/animation_square_4096x64.dds"
            else
                textureFile = "EsoUI/Art/SkillsAdvisor/animation_squareSingle_1024x64_FLASH.dds"
                loopTextureFile = "EsoUI/Art/SkillsAdvisor/animation_squareSingle_4096x64.dds"
            end
        end
        iconAnimationObject:SetAnimatedControl(abilitySlotAnimTexture)
        iconAnimationLoopObject:SetAnimatedControl(abilitySlotAnimTexture)
        local function OnStopIcon(timeline, completedPlaying)
            abilitySlotAnimTexture:SetTexture(loopTextureFile)
            if completedPlaying then 
                skillsObject.selectedSkillBuildIconLoopTimeline:PlayFromStart()
            else
                abilitySlotAnimTexture:SetHidden(true)
            end
        end
        self.selectedSkillBuildIconTimeline:SetHandler("OnStop", OnStopIcon)
        local function OnLoopStopIcon()
            abilitySlotAnimTexture:SetHidden(true)
        end
        self.selectedSkillBuildIconLoopTimeline:SetHandler("OnStop", OnLoopStopIcon)
        abilitySlotAnimTexture:SetTexture(textureFile)
        abilitySlotAnimTexture:SetHidden(false)
        self.selectedSkillBuildIconTimeline:PlayFromStart()
        -- Alert Animation Setup
        if abilityControl.alert.iconStatus ~= ZO_SKILL_ABILITY_ALERT_ICON_NONE then
            if not self.selectedSkillBuildAlertTimeline then 
                self.selectedSkillBuildAlertTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("SkillBuildSelectionAlertAnim")
            end
            if not self.selectedSkillBuildAlertLoopTimeline then 
                self.selectedSkillBuildAlertLoopTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("SkillBuildSelectionAlertLoopAnim")
            end
            local alertAnimationObject = self.selectedSkillBuildAlertTimeline:GetFirstAnimation()
            local alertAnimationLoopObject = self.selectedSkillBuildAlertLoopTimeline:GetFirstAnimation()
            local abilityAlertAnimTexture = abilityControl:GetNamedChild("SelectedSkillBuildAlertAnim")
            local showAlertAnimation = true
            local alertTexture = ""
            local alertTextureLoop = ""
            if abilityControl.alert.iconStatus == ZO_SKILL_ABILITY_ALERT_ICON_ADD then
                alertTexture = "EsoUI/Art/SkillsAdvisor/animation_add_1024x64_FLASH.dds"
                alertTextureLoop = "EsoUI/Art/SkillsAdvisor/animation_add_4096x64.dds"
            elseif abilityControl.alert.iconStatus == ZO_SKILL_ABILITY_ALERT_ICON_MORPH then
                alertTexture = "EsoUI/Art/SkillsAdvisor/animation_morph_1024x64_FLASH.dds"
                alertTextureLoop = "EsoUI/Art/SkillsAdvisor/animation_morph_4096x64.dds"
            else
                showAlertAnimation = false
            end
            alertAnimationObject:SetAnimatedControl(abilityAlertAnimTexture)
            alertAnimationLoopObject:SetAnimatedControl(abilityAlertAnimTexture)
                
            local function OnStopAlert(timeline, completedPlaying)
                abilityAlertAnimTexture:SetTexture(alertTextureLoop)
                if completedPlaying then
                    skillsObject.selectedSkillBuildAlertLoopTimeline:PlayFromStart()
                else
                    abilityAlertAnimTexture:SetHidden(true)
                end
            end
            self.selectedSkillBuildAlertTimeline:SetHandler("OnStop", OnStopAlert)
            local function OnLoopStopAlert()
                abilityAlertAnimTexture:SetHidden(true)
            end
            self.selectedSkillBuildAlertLoopTimeline:SetHandler("OnStop", OnLoopStopAlert)
            if showAlertAnimation then
                abilityAlertAnimTexture:SetTexture(alertTexture)
                abilityAlertAnimTexture:SetHidden(false)
                self.selectedSkillBuildAlertTimeline:PlayFromStart()
            end
        end
    end
end
function ZO_SkillsManager:OnSkillLineSet(skillType, skillIndex, abilityIndex)
    -- Set navigationTree to category containing skill and refresh abilityList
    local selectedData = self.navigationTree:GetSelectedData()
    if skillType ~= selectedData.skillType or skillIndex ~= selectedData.skillLineIndex then
        if self.skillTypeToNode[skillType] and self.skillTypeToNode[skillType][skillIndex] then
            self:StopSelectedSkillBuildSkillAnimations()
            self.navigationTree:SelectNode(self.skillTypeToNode[skillType][skillIndex])
        else
            -- SkillLine is not known or yet advised
            self.selectAbilityData = 
            {
                skillType = skillType,
                skillIndex = skillIndex,
                abilityIndex = abilityIndex,
            }
            local ADVISE_SKILL_LINE = true
            SetAdviseSkillLine(skillType, skillIndex, ADVISE_SKILL_LINE)
            return
        end
    end
    self:ScrollToSkillLineAbility(skillType, skillIndex, abilityIndex)
end
function ZO_SkillsManager:ScrollToSkillLineAbility(skillType, skillIndex, abilityIndex)
    -- Get DataIndex of set ability in abilityList and scroll that index into view
    local dataIndex = nil
    local dataValue = nil
    for index, data in ipairs(self.abilityList.data) do
        if data.data.skillType == skillType and data.data.lineIndex == skillIndex and data.data.abilityIndex == abilityIndex then
            dataIndex = index
            dataValue = data.data
            break
        end
    end
    local function PlaySkillBuildAnimation(successfulAnimateInView)
        if successfulAnimateInView then
            -- Play Glow Animation on selected skill
            local abilityControl = ZO_ScrollList_GetDataControl(self.abilityList, dataValue)
            self:PlaySelectedSkillBuildSkillAnimations(abilityControl)
            self:FireCallbacks("OnReadyToHandleClickAction")
        end
    end
    if dataIndex then
        ZO_ScrollList_ScrollDataToCenter(self.abilityList, dataIndex, PlaySkillBuildAnimation)
    end
    self:RefreshSkillLineDisplay(skillType, skillIndex)
end
function ZO_SkillsManager:SetupAbilityEntry(ability, data, displayView)
    if not displayView then
        displayView = ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE
    end
    ability.name = data.name
    ability.plainName = data.plainName
    ability.nameLabel:SetText(data.name)
    ability.skillType = data.skillType
    ability.lineIndex = data.lineIndex
    ability.index = data.abilityIndex
    ability.skillBuildRankIndex = data.skillBuildRankIndex
    ability.skillBuildMorphChoice = data.skillBuildMorphChoice
    ability.alert.skillType = data.skillType
    ability.alert.lineIndex = data.lineIndex
    ability.alert.index = data.abilityIndex
    ability.alert.iconStatus = ZO_SKILL_ABILITY_ALERT_ICON_NONE
    ability.purchased = data.purchased
    ability.passive = data.passive
    ability.ultimate = data.ultimate
    local isTheSame = ability.progressionIndex == data.progressionIndex
    ability.progressionIndex = data.progressionIndex
    ability.upgradeAvailable = data.nextUpgradeEarnedRank and data.lineRank >= data.nextUpgradeEarnedRank
    ability.atMorph = nil
    ability.morph = nil
    local slot = ability.slot
    slot.skillType = data.skillType
    slot.lineIndex = data.lineIndex
    slot.index = data.abilityIndex
    slot.abilityId = data.abilityId
    slot.skillBuildRankIndex = data.skillBuildRankIndex
    slot.skillBuildMorphChoice = data.skillBuildMorphChoice
    slot.icon:SetTexture(data.icon)
    slot.iconFile = data.icon
    ZO_Skills_SetKeyboardAbilityButtonTextures(ability.slot, data.passive)
    ability:ClearAnchors()
    if data.progressionIndex then
        local lastXP, nextXP, currentXP, atMorph = GetAbilityProgressionXPInfo(data.progressionIndex)
        local _, morph, rank = GetAbilityProgressionInfo(data.progressionIndex)
        ability.atMorph = atMorph
        ability.morph = morph
        if displayView == ZO_SKILL_ABILITY_DISPLAY_INTERACTIVE then
            ability.xpBar:SetHidden(false)
            local wasAbilityRespecced = ability.morph and ability.morph > morph or false
            ZO_SkillInfoXPBar_SetValue(ability.xpBar, rank, lastXP, nextXP, currentXP, not isTheSame or wasAbilityRespecced)
        else
            ZO_SkillInfoXPBar_SetValue(ability.xpBar, nil, 0, 1, 0, FORCE_INIT_SMOOTH_STATUS_BAR)
        end
    else
        ability.xpBar:SetHidden(true)
    end
    if displayView == ZO_SKILL_ABILITY_DISPLAY_VIEW then
        ability.xpBar:SetHidden(true)
        ability.nameLabel:SetAnchor(LEFT, ability.slot, RIGHT, 10, 0)
        ability.slot:SetMouseOverTexture(nil)
    else
        local offsetY = data.progressionIndex and -10 or 0
        ability.nameLabel:SetAnchor(LEFT, ability.slot, RIGHT, 10, offsetY)
    end
    local morphControl = ability:GetNamedChild("Morph")
    ZO_Skills_SetUpAbilityEntry(data.skillType, data.lineIndex, data.abilityIndex, data.skillBuildMorphChoice, data.skillBuildRankIndex, slot.icon, ability.nameLabel, ability.alert, ability.lock, morphControl, displayView, ZO_SKILLS_KEYBOARD)
end
function ZO_SkillsManager:SetupHeaderEntry(header, data)
    local label = GetControl(header, "Label")
    if data.passive then
        label:SetText(GetString(SI_SKILLS_PASSIVE_ABILITIES))
    elseif data.ultimate then
        label:SetText(GetString(SI_SKILLS_ULTIMATE_ABILITIES))
    else
        label:SetText(GetString(SI_SKILLS_ACTIVE_ABILITIES))
    end
end
function ZO_SkillsManager:UpdateSkyShards()
    self.skyShardsLabel:SetText(zo_strformat(SI_SKILLS_SKY_SHARDS_COLLECTED, self.skyShards))
end
function ZO_SkillsManager:RefreshSkillInfo()
    if self.container:IsHidden() then
        self.dirty = true
        return
    end
    local skillType = self:GetSelectedSkillType()
    local skillIndex = self:GetSelectedSkillLineIndex()
    local lineName, lineRank, _, _, advised = GetSkillLineInfo(skillType, skillIndex)
    local lastXP, nextXP, currentXP = GetSkillLineXPInfo(skillType, skillIndex)
    self.skillInfo.name:SetText(zo_strformat(SI_SKILLS_ENTRY_LINE_NAME_FORMAT, lineName))
    local isTheSame = self.skillInfo.xpBar:GetControl().skillType == skillType and self.skillInfo.xpBar:GetControl().skillIndex == skillIndex
    self.skillInfo.xpBar:GetControl().skillType = skillType
    self.skillInfo.xpBar:GetControl().skillIndex = skillIndex
    if advised then
        local RANK_NOT_SHOWN = 1
        local CURRENT_XP_NOT_SHOWN = 0  
        ZO_SkillInfoXPBar_SetValue(self.skillInfo.xpBar, RANK_NOT_SHOWN, lastXP, nextXP, CURRENT_XP_NOT_SHOWN, not isTheSame)
    else
        ZO_SkillInfoXPBar_SetValue(self.skillInfo.xpBar, lineRank, lastXP, nextXP, currentXP, not isTheSame)
    end
    self.availablePoints = GetAvailableSkillPoints()
    self.availablePointsLabel:SetText(zo_strformat(SI_SKILLS_POINTS_TO_SPEND, self.availablePoints))
    self.skyShards = GetNumSkyShards()
    if SkillTooltip:GetOwner() == self.skillInfo.xpBar:GetControl() then
        ZO_SkillInfoXPBar_OnMouseEnter(self.skillInfo.xpBar:GetControl())
    end
end
function ZO_SkillsManager:RefreshList()
    if self.container:IsHidden() then
        self.dirty = true
        return
    end
    if not IsActionBarSlottingAllowed() then
        self.abilityList:SetHidden(true)
        return
    else
        self.abilityList:SetHidden(false)
    end
    local skillType = self:GetSelectedSkillType()
    local skillIndex = self:GetSelectedSkillLineIndex()
    local _, lineRank = GetSkillLineInfo(skillType, skillIndex)
    local scrollData = ZO_ScrollList_GetDataList(self.abilityList)
    ZO_ScrollList_Clear(self.abilityList)
    self.displayedAbilityProgressions = {}
    local numAbilities = GetNumSkillAbilities(skillType, skillIndex)
    local foundFirstActive = false
    local foundFirstPassive = false
    local foundFirstUltimate = false
    for i = 1, numAbilities do
        local name, icon, earnedRank, passive, ultimate, purchased, progressionIndex = GetSkillAbilityInfo(skillType, skillIndex, i)
        local currentUpgradeLevel, maxUpgradeLevel = GetSkillAbilityUpgradeInfo(skillType, skillIndex, i)
        local _, _, nextUpgradeEarnedRank = GetSkillAbilityNextUpgradeInfo(skillType, skillIndex, i)
        local plainName = zo_strformat(SI_ABILITY_NAME, name)
        name = ZO_Skills_GenerateAbilityName(SI_ABILITY_NAME_AND_UPGRADE_LEVELS, name, currentUpgradeLevel, maxUpgradeLevel, progressionIndex)
        if not (currentUpgradeLevel and maxUpgradeLevel) and progressionIndex then
            self.displayedAbilityProgressions[progressionIndex] = true
        end
        local isActive = (not passive and not ultimate)
        local isUltimate = (not passive and ultimate)
        local addHeader = (isActive and not foundFirstActive) or (passive and not foundFirstPassive) or (isUltimate and not foundFirstUltimate)
        if addHeader then
            table.insert(scrollData, ZO_ScrollList_CreateDataEntry(SKILL_HEADER_DATA,  {
                                                                                            passive = passive,
                                                                                            ultimate = isUltimate
                                                                                        }))
        end
        foundFirstActive = foundFirstActive or isActive
        foundFirstPassive = foundFirstPassive or passive
        foundFirstUltimate = foundFirstUltimate or isUltimate
        table.insert(scrollData, ZO_ScrollList_CreateDataEntry(SKILL_ABILITY_DATA,  {
                                                                                        skillType = skillType,
                                                                                        lineIndex = skillIndex,
                                                                                        abilityIndex = i,
                                                                                        plainName = plainName,
                                                                                        name = name,
                                                                                        icon = icon,
                                                                                        earnedRank = earnedRank,
                                                                                        passive = passive,
                                                                                        ultimate = ultimate,
                                                                                        purchased = purchased,
                                                                                        progressionIndex = progressionIndex,
                                                                                        lineRank = lineRank,
                                                                                        nextUpgradeEarnedRank = nextUpgradeEarnedRank,
                                                                                    }))
    end
    ZO_ScrollList_Commit(self.abilityList)
    self:RefreshSkillLineDisplay(skillType, skillIndex)
end
function ZO_SkillsManager:RefreshSkillLineDisplay(skillType, skillIndex)
    local name, _, available, _, advised, unlockText = GetSkillLineInfo(skillType, skillIndex)
    if not available and advised then
        self.skillLineUnlockTitleControl:SetText(zo_strformat(SI_SKILLS_ADVISOR_SKILL_NOT_DISCOVERED_NAME, name))
        self.skillLineUnlockTextControl:SetText(zo_strformat(SI_SKILLS_ADVISOR_SKILL_NOT_DISCOVERED_DESCRIPTION, unlockText))
        self.advisedOverlayControl:SetHidden(false)
        self.abilityList:SetAlpha(0.1)
    else
        self.advisedOverlayControl:SetHidden(true)
        self.abilityList:SetAlpha(1)
    end 
end
function ZO_SkillsManager:GetSelectedSkillType()
    local selectedData = self.navigationTree:GetSelectedData()
    if selectedData then
        return selectedData.skillType
    end
end
function ZO_SkillsManager:GetSelectedSkillLineIndex()
    local selectedData = self.navigationTree:GetSelectedData()
    if selectedData then
        return selectedData.skillLineIndex
    end
end
function ZO_SkillsManager:Refresh()
    if self.container:IsHidden() then
        self.dirty = true
        return
    end
    if IsActionBarSlottingAllowed() then
        self.warning:SetHidden(true)
    else
        self.warning:SetText(GetString(SI_SKILLS_DISABLED_SPECIAL_ABILITIES))
        self.warning:SetHidden(false)
    end
    self.navigationTree:Reset()
    self.skillTypeToNode = {}
    for skillType = 1, GetNumSkillTypes() do
        local numSkillLines = GetNumSkillLines(skillType)
        local parent
        for skillLineIndex = 1, numSkillLines do
            local _, _, available, _, advised = GetSkillLineInfo(skillType, skillLineIndex)
            if available or advised then
                if not parent then
                    parent = self.navigationTree:AddNode("ZO_SkillIconHeader", skillType, nil, skillTypeToSound[skillType])
                end
                local node = self.navigationTree:AddNode("ZO_SkillsNavigationEntry", { skillType = skillType, skillLineIndex = skillLineIndex }, parent, SOUNDS.SKILL_LINE_SELECT)
            
                if not self.skillTypeToNode[skillType] then
                    self.skillTypeToNode[skillType] = {}
                end
                self.skillTypeToNode[skillType][skillLineIndex] = node
            end
        end
    end
    self.navigationTree:Commit()
    self:RefreshList()
    if self.selectAbilityData ~= nil then
        self.navigationTree:SelectNode(self.skillTypeToNode[self.selectAbilityData.skillType][self.selectAbilityData.skillIndex])
        self:ScrollToSkillLineAbility(self.selectAbilityData.skillType, self.selectAbilityData.skillIndex, self.selectAbilityData.abilityIndex)
        self.selectAbilityData = nil
    end
end
function ZO_SkillsManager:OnShown()
    if self.dirty then
        self:Refresh()
    end
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    
    local level = GetUnitLevel("player")
    if level >= GetWeaponSwapUnlockedLevel() then
        TriggerTutorial(TUTORIAL_TRIGGER_WEAPON_SWAP_SHOWN_IN_SKILLS_AFTER_UNLOCK)
    end
end
function ZO_SkillsManager:OnHidden()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
end
local function SetMorphButtonTextures(button, chosen)
    if chosen then
        ZO_ActionSlot_SetUnusable(button.icon, false)
        button.selectedCallout:SetHidden(false)
    else
        ZO_ActionSlot_SetUnusable(button.icon, true)
        button.selectedCallout:SetHidden(true)
    end
end
function ZO_SkillsManager:ChooseMorph(morphSlot)
    if morphSlot then
        local dialogControl = ZO_SkillsMorphDialog
        dialogControl.chosenMorphProgressionIndex = morphSlot.progressionIndex
        dialogControl.chosenMorph = morphSlot.morph
        if morphSlot == dialogControl.morphAbility1 then
            SetMorphButtonTextures(dialogControl.morphAbility1, true)
            SetMorphButtonTextures(dialogControl.morphAbility2, false)
        else
            SetMorphButtonTextures(dialogControl.morphAbility1, false)
            SetMorphButtonTextures(dialogControl.morphAbility2, true)
        end
        dialogControl.confirmButton:SetState(BSTATE_NORMAL)
    end
end
    SKILLS_WINDOW:StopSelectedSkillBuildSkillAnimations()
    InitializeTooltip(SkillTooltip, control, TOPLEFT, 5, -5, TOPRIGHT)
    local isBadMorph = control.ability and control.ability.alert and control.ability.alert.iconStatus == ZO_SKILL_ABILITY_ALERT_ICON_BAD_MORPH
    SkillTooltip:SetSkillAbility(control.skillType, control.lineIndex, control.index, isBadMorph)
end
    ClearTooltip(SkillTooltip)
end
    InitializeTooltip(SkillTooltip, control, TOPLEFT, 5, -5, TOPRIGHT)
    SkillTooltip:SetSkillUpgradeAbility(control.skillType, control.lineIndex, control.index)
end
    ClearTooltip(SkillTooltip)
end
    if(GetCursorContentType() == MOUSE_CONTENT_EMPTY) then
        if ZO_Skills_AbilityFailsWerewolfRequirement(control.skillType, control.lineIndex) then
        else
            PickupAbilityBySkillLine(control.skillType, control.lineIndex, control.index)
        end
    end
end
    local ability = control.ability
    if ability.purchased and not ability.passive then
        if ZO_Skills_AbilityFailsWerewolfRequirement(control.skillType, control.lineIndex) then
        else
            local slot = GetFirstFreeValidSlotForSkillAbility(control.skillType, control.lineIndex, control.index)
            if slot then
                SlotSkillAbilityInSlot(control.skillType, control.lineIndex, control.index, slot)
            end
        end
    end
end
    local ability = control.ability
    if ability.purchased and not ability.passive then
        ClearMenu()
        if not ZO_Skills_AbilityFailsWerewolfRequirement(control.skillType, control.lineIndex) then
            if ability.ultimate then
                AddMenuItem(GetString(SI_SKILL_ABILITY_ASSIGN_TO_ULTIMATE_SLOT), function() SelectSlotSkillAbility(control.skillType, control.lineIndex, control.index, ACTION_BAR_ULTIMATE_SLOT_INDEX + 1) end)
            else
                local slot = GetFirstFreeValidSlotForSkillAbility(control.skillType, control.lineIndex, control.index)
                if slot then
                    AddMenuItem(GetString(SI_SKILL_ABILITY_ASSIGN_TO_EMPTY_SLOT), function() SlotSkillAbilityInSlot(control.skillType, control.lineIndex, control.index, slot) end)
                end
                for i = ACTION_BAR_FIRST_NORMAL_SLOT_INDEX, ACTION_BAR_ULTIMATE_SLOT_INDEX - 1 do
                    AddMenuItem(zo_strformat(SI_SKILL_ABILITY_ASSIGN_TO_SLOT, i - 1), function() SelectSlotSkillAbility(control.skillType, control.lineIndex, control.index, i + 1) end)
                end
            end
        else
        end
        ShowMenu(control)
    end
end
    SKILLS_WINDOW:StopSelectedSkillBuildSkillAnimations()
    if not control.ability.purchased then
        ZO_Dialogs_ShowDialog("PURCHASE_ABILITY_CONFIRM", control)
    elseif control.ability.atMorph then
        ZO_Dialogs_ShowDialog("MORPH_ABILITY_CONFIRM", control)
    elseif control.ability.upgradeAvailable then
        ZO_Dialogs_ShowDialog("UPGRADE_ABILITY_CONFIRM", control)
    end
end
    InitializeTooltip(SkillTooltip, control, TOPLEFT, 5, -5, TOPRIGHT)
    SkillTooltip:SetProgressionAbility(control.progressionIndex, control.morph, control.rank, control.showAdvice, control.advised)
end
    SKILLS_WINDOW:ChooseMorph(control)
end
    SKILLS_WINDOW:StopSelectedSkillBuildSkillAnimations()
    InitializeTooltip(SkillTooltip, control, TOPLEFT, 15, 5, BOTTOMLEFT)
    SkillTooltip:SetSkillLine(control.skillType, control.skillIndex)
end
    ClearTooltip(SkillTooltip)
end
    SKILLS_WINDOW:OnShown()
end
    SKILLS_WINDOW:OnHidden()
end
    SKILLS_WINDOW = ZO_SkillsManager:New(control)
end
    self.statusIcon = self:GetNamedChild("StatusIcon")
end
    self.statusIcon = self:GetNamedChild("StatusIcon")
end