Back to Home

ESO Lua File v101044

ingame/champion/championstar.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
--Star
----------------------
ZO_CHAMPION_STAR_DEPTH = 1.68
ZO_CHAMPION_CLUSTER_STAR_DEPTH = 2.68
ZO_ChampionStar = ZO_InitializingObject:Subclass()
local HANDLED = true
local NOT_HANDLED = false
local KEYBOARD_ALLOCATE_POINTS_BUTTON_TEMPLATES = 
{
    SIZE = 26,
    DECREASE = {
        NORMAL = "EsoUI/Art/Buttons/pointsMinus_up.dds",
        PRESSED = "EsoUI/Art/Buttons/pointsMinus_down.dds",
        MOUSEOVER = "EsoUI/Art/Buttons/pointsMinus_over.dds",
        DISABLED = "EsoUI/Art/Buttons/pointsMinus_disabled.dds",
    },
    INCREASE = {
        NORMAL = "EsoUI/Art/Buttons/pointsPlus_up.dds",
        PRESSED = "EsoUI/Art/Buttons/pointsPlus_down.dds",
        MOUSEOVER = "EsoUI/Art/Buttons/pointsPlus_over.dds",
        DISABLED = "EsoUI/Art/Buttons/pointsPlus_disabled.dds",
    },
}
local GAMEPAD_ALLOCATE_POINTS_BUTTON_TEMPLATES = 
{
    SIZE = 32,
    DECREASE = {
        NORMAL = "EsoUI/Art/Buttons/Gamepad/gp_minus_dim3.dds",
        PRESSED = "EsoUI/Art/Buttons/Gamepad/gp_minus_dim3.dds",
        MOUSEOVER = "EsoUI/Art/Buttons/Gamepad/gp_minus_dim3.dds",
        DISABLED = "EsoUI/Art/Buttons/Gamepad/gp_minus_dim2.dds",
    },
    INCREASE = {
        NORMAL = "EsoUI/Art/Buttons/Gamepad/gp_plus_dim3.dds",
        PRESSED = "EsoUI/Art/Buttons/Gamepad/gp_plus_dim3.dds",
        MOUSEOVER = "EsoUI/Art/Buttons/Gamepad/gp_plus_dim3.dds",
        DISABLED = "EsoUI/Art/Buttons/Gamepad/gp_plus_dim2.dds",
    },
}
function ZO_ChampionStar:Initialize(constellation, parentCluster)
    self.constellation = constellation
    self.parentCluster = parentCluster
    self.sceneNode = parentCluster.node
    self.hidden = false
    self.active = false
    self.depth = parentCluster:IsRootCluster() and ZO_CHAMPION_STAR_DEPTH or ZO_CHAMPION_CLUSTER_STAR_DEPTH
    self.state = nil
    self.starScaleInterpolator = ZO_LerpInterpolator:New(1)
        local currentAnimInfo = self.oneShotAnimationInfo
        self.oneShotAnimationTimeline = nil
        self.oneShotAnimationInfo = nil
        
        if currentAnimInfo.onComplete then
            currentAnimInfo.onComplete(self)
        end
        self.sceneNode:RemoveTexture(texture)
    end
end
function ZO_ChampionStar:AcquireTexture()
    local texture = CHAMPION_PERKS:AcquireStarTexture()
    texture.star = self
    self.texture = texture
    if not texture.mouseInputGroup then
        texture.mouseInputGroup = ZO_MouseInputGroup:New(texture)
    end
    self.visuals = ZO_ChampionStarVisuals:New(texture)
    self.sceneNode:AddTextureComposite(texture, 0, 0, 0)
    self.sceneNode:SetControlPosition(texture, self.x, self.y, self.depth)
    self.sceneNode:SetControlHidden(texture, self.hidden)
    self:RefreshState()
end
function ZO_ChampionStar:ReleaseTexture()
    if WINDOW_MANAGER:GetMouseOverControl() == self.texture then
        -- Protection against the case where a player hides a constellation
        -- while moused over it: by the time we call the mouse exit handler, the
        -- control has already been released to the pool, so we'll just do it now
        self:OnMouseExit()
    end
    CHAMPION_PERKS:ReleaseStarTexture(self.texture)
    self.texture.star = nil
    self.texture = nil
end
function ZO_ChampionStar:GetNormalizedCoordinates()
    return self.nx, self.ny
end
function ZO_ChampionStar:InitializeKeyboardTooltip(tooltip)
    local starCenterX, _ = self.texture:GetCenter()
    local screenCenterX, _ = GuiRoot:GetCenter()
    if starCenterX > screenCenterX then
        InitializeTooltip(tooltip, self.texture, RIGHT, -65, 0, CENTER)
    else
        InitializeTooltip(tooltip, self.texture, LEFT, 65, 0, CENTER)
    end
end
function ZO_ChampionStar:AnchorGamepadTooltipToStar(tooltipControl)
    local starCenterX, _ = self.texture:GetCenter()
    local screenCenterX, _ = GuiRoot:GetCenter()
    tooltipControl:ClearAnchors()
    if starCenterX > screenCenterX then
        tooltipControl:SetAnchor(RIGHT, self.texture, CENTER, -95)
    else
        tooltipControl:SetAnchor(LEFT, self.texture, CENTER, 95)
    end
end
function ZO_ChampionStar:SetNormalizedCoordinates(nx, ny)
    self.nx, self.ny = nx, ny
    if self.texture then
        self.sceneNode:SetControlPosition(self.texture, self.x, self.y, self.depth)
    end
end
function ZO_ChampionStar:GetWorldSpaceCoordinates()
    local worldX, worldY = self.sceneNode:GetWorldSpaceCoordinates(self.x, self.y, self.depth)
    return worldX, worldY
end
do
    -- the node coordinate system works like the UI coordinate system: +x is right, +y is down, units are arbitrary.
    -- normalized coordinates use +x is right, +y is up, units are also arbitrary. this makes more sense for the data; which will always be growing up from the origin.
    -- normalized coordinates also define an origin that would be a good place for the root node to be: it's positionX/Y should be 0, 0.
    ZO_CHAMPION_STAR_COORDINATE_SCALE = 0.5
    ZO_CHAMPION_STAR_ROOT_OFFSET_Y = -450
    function ZO_Champion_ConvertNormalizedCoordinatesToNodeOffset(normalizedX, normalizedY)
        local x = normalizedX * ZO_CHAMPION_STAR_COORDINATE_SCALE
        local y = -normalizedY * ZO_CHAMPION_STAR_COORDINATE_SCALE + ZO_CHAMPION_STAR_ROOT_OFFSET_Y
        return x, y
    end
        local normalizedX = x / ZO_CHAMPION_STAR_COORDINATE_SCALE
        local normalizedY = -(y - ZO_CHAMPION_STAR_ROOT_OFFSET_Y) / ZO_CHAMPION_STAR_COORDINATE_SCALE
        return normalizedX, normalizedY
    end
end
function ZO_ChampionStar:GetTexture()
    return self.texture
end
function ZO_ChampionStar:RefreshStateFromSkillData(championSkillData)
    local disciplineData = championSkillData:GetChampionDisciplineData()
    if championSkillData:WouldBePurchased() then
        self.state = ZO_CHAMPION_STAR_STATE.PURCHASED
    elseif championSkillData:GetNumPendingPoints() > 0 or ((disciplineData:HasAnySavedUnspentPoints() or CHAMPION_PERKS:IsInRespecMode()) and championSkillData:CanBePurchased()) then
        self.state = ZO_CHAMPION_STAR_STATE.AVAILABLE
    else
        self.state = ZO_CHAMPION_STAR_STATE.LOCKED
    end
    if not self.active then
        if self.state == ZO_CHAMPION_STAR_STATE.AVAILABLE then
            self.state = ZO_CHAMPION_STAR_STATE.LOCKED
        end
    end
    self:RefreshTexture()
    self:RefreshEditor()
end
function ZO_ChampionStar:RefreshTexture()
    -- to be overridden
end
function ZO_ChampionStar:RefreshEditor()
    local shouldShowEditor = self.active and self.state ~= ZO_CHAMPION_STAR_STATE.LOCKED
    if shouldShowEditor then
        self:ShowEditor()
    else
        self:HideEditor()
    end
end
function ZO_ChampionStar:GetEditor()
    return self.editor
end
function ZO_ChampionStar:HideEditor()
    local isShowingEditor = self.editor ~= nil
    if isShowingEditor then
        CHAMPION_PERKS:ReleaseStarEditor(self.editorKey)
        self.editor, self.editorKey = nil, nil
    end
end
function ZO_ChampionStar:ShowEditor()
    local isShowingEditor = self.editor ~= nil
    if not isShowingEditor then
        self.editor, self.editorKey = CHAMPION_PERKS:AcquireStarEditor()
        self.editor:AttachToStar(self)
    end
end
function ZO_ChampionStar:OnSelected()
    if self.editor then
        self.editor:OnSelected()
    end
end
function ZO_ChampionStar:OnDeselected()
    if self.editor then
        self.editor:OnDeselected()
    end
end
local STAR_SCALE_UNSELECTED = 1
local STAR_SCALE_SELECTED = 1.7
function ZO_ChampionStar:UpdateVisuals(timeSecs, newStarAlpha)
    self.visuals:Update(timeSecs)
    local isSelected = self == self.constellation:GetSelectedStar()
    if isSelected then
        self.starScaleInterpolator:SetTargetBase(STAR_SCALE_SELECTED)
    else
        self.starScaleInterpolator:SetTargetBase(STAR_SCALE_UNSELECTED)
    end
    local starScale = self.starScaleInterpolator:Update(timeSecs)
    self.sceneNode:SetControlScale(self.texture, starScale)
    self.texture:SetAlpha(newStarAlpha)
end
function ZO_ChampionStar:SetHidden(hidden)
    if self.hidden ~= hidden then
        self.sceneNode:SetControlHidden(self.texture, hidden)
        self.hidden = hidden
    end
end
function ZO_ChampionStar:SetActive(active)
    if self.active ~= active then
        self.active = active
        self:RefreshState()
    end
end
    
function ZO_ChampionStar:GetConstellation()
    return self.constellation
end
function ZO_ChampionStar:OnMouseEnter()
    self.constellation:SelectStar(self)
end
function ZO_ChampionStar:OnMouseExit()
    self.constellation:SelectStar(nil)
end
function ZO_ChampionStar:OnMouseWheel()
    -- to be overridden
end
function ZO_ChampionStar:GetConstellation()
    return self.constellation
end
function ZO_ChampionStar:IsSkillStar()
    return false
end
function ZO_ChampionStar:IsClusterPortalStar()
    return false
end
ZO_ChampionStar.OnClicked = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.OnDragStart = ZO_ChampionStar:MUST_IMPLEMENT()
function ZO_ChampionStar:ShowPlatformTooltip()
    if IsInGamepadPreferredMode() then
        self:ShowGamepadTooltip()
    elseif GetCursorContentType() == MOUSE_CONTENT_EMPTY then
        self:ShowKeyboardTooltip()
    end
end
ZO_ChampionStar.ShowKeyboardTooltip = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.ShowGamepadTooltip = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.ClearTooltip = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.HasPrimaryGamepadAction = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.CanPerformPrimaryGamepadAction = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.PerformPrimaryGamepadAction = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionStar.GetPrimaryGamepadActionText = ZO_ChampionStar:MUST_IMPLEMENT()
ZO_ChampionSkillStar = ZO_ChampionStar:Subclass()
function ZO_ChampionSkillStar:Initialize(championSkillData, constellation, parentCluster)
    ZO_ChampionStar.Initialize(self, constellation, parentCluster)
    self.championSkillData = championSkillData
    self:SetNormalizedCoordinates(self.championSkillData:GetPosition())
end
function ZO_ChampionSkillStar:IsSkillStar()
    return true
end
function ZO_ChampionSkillStar:GetChampionSkillData()
    return self.championSkillData
end
function ZO_ChampionSkillStar:RefreshState()
    self:RefreshStateFromSkillData(self.championSkillData)
end
-- these don't have a 1:1 relationship with UI units, the 3d space can zoom further into or away from these controls
local STAR_CONTROL_SIZES_FOR_STATE = {
    [ZO_CHAMPION_STAR_STATE.LOCKED] = 16,
    [ZO_CHAMPION_STAR_STATE.AVAILABLE] = 16,
    [ZO_CHAMPION_STAR_STATE.PURCHASED] = 26,
}
function ZO_ChampionSkillStar:RefreshTexture()
    if not self.texture then
        -- texture released, we will refresh the next time we acquire
        return
    end
    local state = self.state or ZO_CHAMPION_STAR_STATE.LOCKED
    local type = self.championSkillData:GetType()
    if type == CHAMPION_SKILL_TYPE_NORMAL then
        self.visuals:Setup(ZO_CHAMPION_STAR_VISUAL_TYPE.NORMAL, state)
    elseif type == CHAMPION_SKILL_TYPE_NORMAL_SLOTTABLE or type == CHAMPION_SKILL_TYPE_STAT_POOL_SLOTTABLE then
        local disciplineType = self.championSkillData:GetChampionDisciplineData():GetType()
        local isSlotted = CHAMPION_PERKS:IsChampionSkillDataSlotted(self.championSkillData)
        self.visuals:Setup(ZO_CHAMPION_STAR_VISUAL_TYPE.SLOTTABLE, state, disciplineType, isSlotted)
    else
        internalassert(false, "missing star visuals")
    end
    local size = STAR_CONTROL_SIZES_FOR_STATE[state]
    self.texture:SetDimensions(self.sceneNode:ComputeSizeForDepth(size, size, self.depth, ZO_CHAMPION_REFERENCE_CAMERA_Z))
    self.texture:SetMouseEnabled(self.active)
end
function ZO_ChampionSkillStar:ShowKeyboardTooltip()
    local championSkillData = self:GetChampionSkillData()
    self:InitializeKeyboardTooltip(ChampionSkillTooltip)
    local pendingPoints = championSkillData:GetNumPendingPoints()
    ChampionSkillTooltip:SetChampionSkill(championSkillData:GetId(), pendingPoints, championSkillData:GetNextJumpPoint(pendingPoints), CHAMPION_PERKS:IsChampionSkillDataSlotted(championSkillData))
end
function ZO_ChampionSkillStar:ShowGamepadTooltip()
    local starTooltip = CHAMPION_PERKS:GetGamepadStarTooltip()
    self:AnchorGamepadTooltipToStar(starTooltip)
    starTooltip.scrollTooltip:ClearLines()
    starTooltip.tip:LayoutChampionSkill(self:GetChampionSkillData())
    starTooltip:SetHidden(false)
end
function ZO_ChampionSkillStar:ClearTooltip()
    ClearTooltip(ChampionSkillTooltip)
    local gamepadStarTooltip = CHAMPION_PERKS:GetGamepadStarTooltip()
    gamepadStarTooltip:SetHidden(true)
    gamepadStarTooltip.scrollTooltip:ClearLines()
end
function ZO_ChampionSkillStar:OnMouseWheel(delta)
    if not IsInGamepadPreferredMode() and self.editor then
        self.editor:OnMouseWheel(delta)
    end
end
function ZO_ChampionSkillStar:OnClicked(button, upInside)
    if upInside and self.editor then
        local increment = IsShiftKeyDown() and ZO_SPINNER_LARGE_INCREMENT or ZO_SPINNER_SMALL_INCREMENT
        if button == MOUSE_BUTTON_INDEX_LEFT and self.editor:CanAddPoints() then
            self.editor:AddOrRemovePoints(increment)
            return HANDLED
        elseif button == MOUSE_BUTTON_INDEX_RIGHT and self.editor:CanRemovePoints() then
            self.editor:AddOrRemovePoints(-increment)
            return HANDLED
        end
    end
    return NOT_HANDLED
end
function ZO_ChampionSkillStar:OnDragStart()
    local result = GetChampionPurchaseAvailability()
    if result ~= CHAMPION_PURCHASE_SUCCESS then
        ZO_AlertEvent(EVENT_CHAMPION_PURCHASE_RESULT, result)
        return NOT_HANDLED
    end
    local championSkillData = self:GetChampionSkillData()
    if championSkillData:TryCursorPickup() then
        PlaySound(SOUNDS.CHAMPION_STAR_PICKED_UP)
        return HANDLED
    end
    return NOT_HANDLED
end
function ZO_ChampionSkillStar:HasPrimaryGamepadAction()
end
function ZO_ChampionSkillStar:CanPerformPrimaryGamepadAction()
    local result = GetChampionPurchaseAvailability()
    if result ~= CHAMPION_PURCHASE_SUCCESS then
        return false, GetString("SI_CHAMPIONPURCHASERESULT", result)
    end
end
function ZO_ChampionSkillStar:PerformPrimaryGamepadAction()
end
function ZO_ChampionSkillStar:GetPrimaryGamepadActionText()
    return GetString(SI_GAMEPAD_CHAMPION_SLOT_SKILL)
end
ZO_ChampionClusterPortalStar = ZO_ChampionStar:Subclass()
function ZO_ChampionClusterPortalStar:Initialize(championClusterData, constellation, parentCluster)
    ZO_ChampionStar.Initialize(self, constellation, parentCluster)
    self.championClusterData = championClusterData
end
function ZO_ChampionClusterPortalStar:IsClusterPortalStar()
    return true
end
function ZO_ChampionClusterPortalStar:GetChampionClusterData()
    return self.championClusterData
end
function ZO_ChampionClusterPortalStar:GetRootChampionSkillData()
    return self.championClusterData:GetRootChampionSkillData()
end
function ZO_ChampionClusterPortalStar:RefreshState()
end
function ZO_ChampionClusterPortalStar:RefreshTexture()
    if not self.texture then
        -- texture released, we will refresh the next time we acquire
        return
    end
    local state = self.state or ZO_CHAMPION_STAR_STATE.LOCKED
    self.visuals:Setup(ZO_CHAMPION_STAR_VISUAL_TYPE.CLUSTER, state)
    local size = STAR_CONTROL_SIZES_FOR_STATE[state]
    self.texture:SetDimensions(self.sceneNode:ComputeSizeForDepth(size, size, self.depth, ZO_CHAMPION_REFERENCE_CAMERA_Z))
    self.texture:SetMouseEnabled(self.active)
end
function ZO_ChampionClusterPortalStar:OnMouseEnter()
    ZO_ChampionStar.OnMouseEnter(self)
    WINDOW_MANAGER:SetMouseCursor(MOUSE_CURSOR_PREVIEW)
end
function ZO_ChampionClusterPortalStar:OnMouseExit()
    ZO_ChampionStar.OnMouseExit(self)
    WINDOW_MANAGER:SetMouseCursor(MOUSE_CURSOR_DO_NOT_CARE)
end
function ZO_ChampionClusterPortalStar:OnClicked(button, upInside)
    if button == MOUSE_BUTTON_INDEX_LEFT and upInside then
        CHAMPION_PERKS:ChooseClusterData(self.championClusterData)
        return HANDLED
    end
    return NOT_HANDLED
end
function ZO_ChampionClusterPortalStar:OnDragStart()
    return NOT_HANDLED
end
function ZO_ChampionClusterPortalStar:ShowGamepadTooltip()
    local starTooltip = CHAMPION_PERKS:GetGamepadStarTooltip()
    self:AnchorGamepadTooltipToStar(starTooltip)
    starTooltip.scrollTooltip:ClearLines()
    starTooltip.tip:LayoutChampionCluster(self.championClusterData)
    starTooltip:SetHidden(false)
end
function ZO_ChampionClusterPortalStar:ShowKeyboardTooltip()
    self:InitializeKeyboardTooltip(InformationTooltip)
    InformationTooltip:AddLine(self.championClusterData:GetFormattedName(), "ZoFontWinH2")
    ZO_Tooltip_AddDivider(InformationTooltip)
    for _, clusterChild in ipairs(self.championClusterData:GetClusterChildren()) do
        local formattedName = ZO_NORMAL_TEXT:Colorize(clusterChild:GetFormattedName())
        InformationTooltip:AddLine(zo_strformat(SI_CHAMPION_TOOLTIP_CLUSTER_CHILD_FORMAT, formattedName, clusterChild:GetNumPendingPoints(), clusterChild:GetMaxPossiblePoints()), "", ZO_SELECTED_TEXT:UnpackRGBA())
    end
end
function ZO_ChampionClusterPortalStar:ClearTooltip()
    ClearTooltip(InformationTooltip)
    local gamepadStarTooltip = CHAMPION_PERKS:GetGamepadStarTooltip()
    gamepadStarTooltip:SetHidden(true)
    gamepadStarTooltip.scrollTooltip:ClearLines()
end
function ZO_ChampionClusterPortalStar:HasPrimaryGamepadAction()
    return true
end
function ZO_ChampionClusterPortalStar:CanPerformPrimaryGamepadAction()
    return true
end
function ZO_ChampionClusterPortalStar:PerformPrimaryGamepadAction()
    CHAMPION_PERKS:ChooseClusterData(self.championClusterData)
end
function ZO_ChampionClusterPortalStar:GetPrimaryGamepadActionText()
    return GetString(SI_GAMEPAD_CHAMPION_CLUSTER_ZOOM_IN)
end
ZO_ChampionStarEditor = ZO_InitializingObject:Subclass()
function ZO_ChampionStarEditor:Initialize(pool)
    self.control = ZO_ObjectPool_CreateControl("ZO_ChampionStarEditor", pool, CHAMPION_PERKS:GetChampionCanvas())
    self.fadeIn = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_ChampionStarEditorFade", self.control)
    local DEFAULT_MIN = nil
    local DEFAULT_MAX = nil
    local DEFAULT_INPUT_MODE = nil
    local DEFAULT_SPINNER_MODE = nil
    local ACCELERATION_TIME_MS = 50
    self.pointsSpinner = ZO_SpinnerWithLabels:New(self.control, DEFAULT_MIN, DEFAULT_MAX, DEFAULT_INPUT_MODE, DEFAULT_SPINNER_MODE, ACCELERATION_TIME_MS)
    self.pointsSpinner:SetPlaySoundFunction(function(spinner, currentValue, oldValue)
        local championSkillData = self.star:GetChampionSkillData()
        local currentJumpPoint = championSkillData:GetJumpPointForValue(currentValue)
        local oldJumpPoint = championSkillData:GetJumpPointForValue(oldValue)
        local isUnlocked = championSkillData:WouldBeUnlockedNodeAtValue(currentValue)
        local wasUnlocked = championSkillData:WouldBeUnlockedNodeAtValue(oldValue)
        if currentValue > oldValue then
            if not wasUnlocked and isUnlocked then
                PlaySound(SOUNDS.CHAMPION_STAR_UNLOCKED)
            elseif championSkillData:HasJumpPoints() and currentJumpPoint > oldJumpPoint then
                PlaySound(SOUNDS.CHAMPION_STAR_STAGE_UP)
            else
                PlaySound(SOUNDS.CHAMPION_SPINNER_UP)
            end
        else
            if wasUnlocked and not isUnlocked then
                PlaySound(SOUNDS.CHAMPION_STAR_LOCKED)
            elseif championSkillData:HasJumpPoints() and currentJumpPoint < oldJumpPoint then
                PlaySound(SOUNDS.CHAMPION_STAR_STAGE_DOWN)
            else
                PlaySound(SOUNDS.CHAMPION_SPINNER_DOWN)
            end
        end
    end)
    self.pointsSpinner:RegisterCallback("OnValueChanged", function(newValue)
        if self:IsAttached() and self.star:IsSkillStar() then
            self.star:GetChampionSkillData():SetNumPendingPoints(newValue)
        end
    end)
    self.pointsSpinner:SetValidValuesFunction(function(oldValue, delta)
        if self.star:IsSkillStar() then
            local championSkillData = self.star:GetChampionSkillData()
            if championSkillData:HasJumpPoints() then
                if delta == ZO_SPINNER_LARGE_INCREMENT then
                    local nextJumpPoint = championSkillData:GetNextJumpPoint(oldValue)
                    return zo_min(championSkillData:GetMaxPendingPoints(), nextJumpPoint)
                elseif delta == -ZO_SPINNER_LARGE_INCREMENT then
                    local previousJumpPoint = championSkillData:GetPreviousJumpPoint(oldValue)
                    return zo_max(championSkillData:GetMinPendingPoints(), previousJumpPoint)
                end
            end
        end
        return oldValue + delta
    end)
end
function ZO_ChampionStarEditor:AttachToStar(selectedStar)
    self.star = selectedStar
    local spinnerControl = self.pointsSpinner:GetControl()
    if SCENE_MANAGER:IsCurrentSceneGamepad() then
        self.pointsSpinner:SetFont("ZoFontGamepad42")
        spinnerControl:SetDimensions(120, 55)
        self:ApplyButtonTemplatesToSpinner(GAMEPAD_ALLOCATE_POINTS_BUTTON_TEMPLATES)
    else
        self.pointsSpinner:SetFont("ZoFontWinH2")
        spinnerControl:SetDimensions(100, 36)
        self:ApplyButtonTemplatesToSpinner(KEYBOARD_ALLOCATE_POINTS_BUTTON_TEMPLATES)
    end
    if self.star:IsSkillStar() then
        self.pointsSpinner:SetMouseEnabled(not IsInGamepadPreferredMode())
        self.pointsSpinner:SetButtonsHidden(false)
    elseif self.star:IsClusterPortalStar() then
        self.pointsSpinner:SetMouseEnabled(false)
        self.pointsSpinner:SetButtonsHidden(true)
    end
    self.control:SetHidden(false)
    self.fadeIn:PlayFromStart()
    local parentControl = self.star:GetTexture()
    self.control:SetAnchor(TOP, parentControl, CENTER, 0, 15)
    self.pointsSpinner:AddToMouseInputGroup(parentControl.mouseInputGroup, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
end
function ZO_ChampionStarEditor:OnSelected()
    if IsInGamepadPreferredMode() then
        self.pointsSpinner.decreaseButton:SetHidden(true)
        self.pointsSpinner.increaseButton:SetHidden(true)
        if not self.star:IsClusterPortalStar() then
            self.pointsSpinner.decreaseKeyLabel:SetHidden(false)
            self.pointsSpinner.increaseKeyLabel:SetHidden(false)
        end
    end
end
function ZO_ChampionStarEditor:OnDeselected()
    if IsInGamepadPreferredMode() then
        if not self.star:IsClusterPortalStar() then
            self.pointsSpinner.decreaseButton:SetHidden(false)
            self.pointsSpinner.increaseButton:SetHidden(false)
        end
        self.pointsSpinner.decreaseKeyLabel:SetHidden(true)
        self.pointsSpinner.increaseKeyLabel:SetHidden(true)
    end
end
function ZO_ChampionStarEditor:Release()
    local starTexture = self.star:GetTexture()
    if starTexture then
        starTexture.mouseInputGroup:RemoveAll(ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    end
    self.control:SetHidden(true)
    self.pointsSpinner.decreaseKeyLabel:SetHidden(true)
    self.pointsSpinner.increaseKeyLabel:SetHidden(true)
    self.fadeIn:PlayInstantlyToStart()
    self.star = nil
end
function ZO_ChampionStarEditor:IsAttached()
    return self.star ~= nil
end
function ZO_ChampionStarEditor:CanRemovePoints()
    if self:IsAttached() and self:IsEnabled() then
        return self.pointsSpinner:GetValue() > self.pointsSpinner:GetMin()
    end
    return false
end
function ZO_ChampionStarEditor:StartRemovingPoints()
    if self:IsAttached() then
        self.pointsSpinner:OnButtonDown(-1)
    end
end
function ZO_ChampionStarEditor:CanAddPoints()
    if self:IsAttached() and self:IsEnabled() then
        return self.pointsSpinner:GetValue() < self.pointsSpinner:GetMax()
    end
    return false
end
function ZO_ChampionStarEditor:StartAddingPoints()
    if self:IsAttached() then
        self.pointsSpinner:OnButtonDown(1)
    end
end
function ZO_ChampionStarEditor:StopChangingPoints()
    if self:IsAttached() then
        self.pointsSpinner:OnButtonUp()
    end
end
function ZO_ChampionStarEditor:AddOrRemovePoints(points)
    self.pointsSpinner:ModifyValue(points)
end
function ZO_ChampionStarEditor:RefreshPointsMinMax()
    if self:IsAttached() then
        if self.star:IsSkillStar() then
            local championSkillData = self.star:GetChampionSkillData()
            local min = championSkillData:GetMinPendingPoints()
            local max = championSkillData:GetMaxPendingPoints()
            local currentPendingPoints = championSkillData:GetNumPendingPoints()
            self.pointsSpinner:SetValueMinAndMax(currentPendingPoints, min, max)
        else
            local totalPointsInCluster = self.star:GetChampionClusterData():CalculateTotalPendingPoints()
            self.pointsSpinner:SetValueMinAndMax(totalPointsInCluster, totalPointsInCluster, totalPointsInCluster)
        end
    end
end
function ZO_ChampionStarEditor:IsEnabled()
    return self.pointsSpinner:IsEnabled()
end
function ZO_ChampionStarEditor:RefreshEnabledState()
    if self:IsAttached() then
        local result = GetChampionPurchaseAvailability()
        self.pointsSpinner:SetEnabled(result == CHAMPION_PURCHASE_SUCCESS)
    end
end
do
    local function SetButtonTextures(btn, textures)
        if textures.KEY_CODE then
            btn:SetKeyCode(textures.KEY_CODE)
        else
            btn:SetKeyCode(nil)
            btn:SetNormalTexture(textures.NORMAL)
            btn:SetPressedTexture(textures.PRESSED)
            btn:SetMouseOverTexture(textures.MOUSEOVER)
            btn:SetDisabledTexture(textures.DISABLED)
        end
    end
    function ZO_ChampionStarEditor:ApplyButtonTemplatesToSpinner(template)
        local decreaseBtn = self.pointsSpinner.decreaseButton
        local increaseBtn = self.pointsSpinner.increaseButton
        
        decreaseBtn:SetDimensions(template.SIZE, template.SIZE)
        increaseBtn:SetDimensions(template.SIZE, template.SIZE)
        SetButtonTextures(decreaseBtn, template.DECREASE)
        SetButtonTextures(increaseBtn, template.INCREASE)
    end
end
function ZO_ChampionStarEditor:OnMouseWheel(delta)
    if not IsInGamepadPreferredMode() then
        self.pointsSpinner:OnMouseWheel(delta)
    end
end
function ZO_ChampionStar:PlayPurchaseConfirmAnimation()
    local STAR_ONE_SHOT_ANIMATION_SIZE = 30
    local confirmedTexture = CHAMPION_PERKS:AcquireStarConfirmedTexture()
    self.sceneNode:AddTexture(confirmedTexture, self.x, self.y, self.depth)
    confirmedTexture:SetDimensions(self.sceneNode:ComputeSizeForDepth(STAR_ONE_SHOT_ANIMATION_SIZE, STAR_ONE_SHOT_ANIMATION_SIZE, self.depth, ZO_CHAMPION_REFERENCE_CAMERA_Z))
    confirmedTexture.timeline:SetHandler("OnStop", function()
        self.sceneNode:RemoveTexture(confirmedTexture)
        CHAMPION_PERKS:ReleaseStarConfirmedTexture(confirmedTexture)
    end)
    confirmedTexture.timeline:PlayFromStart()
end
--Global XML Handlers
    if not IsInGamepadPreferredMode() then
        control.star:OnMouseEnter()
    end
end
    if not control.star or IsInGamepadPreferredMode() then
        -- Protection against the case where a player hides a constellation
        -- while moused over it: by the time we call the mouse exit handler, the
        -- control has already been released to the pool, so we'll call it in advance
        return
    end
    control.star:OnMouseExit()
end
    if not IsInGamepadPreferredMode() then
        control.star:OnMouseWheel(delta)
    end
end
function ZO_ChampionStar_OnMouseUp(control, button, upInside)
    if not control.star or IsInGamepadPreferredMode() or control.star:OnClicked(button, upInside) == HANDLED then
        return
    end
    CHAMPION_PERKS:OnCanvasMouseUp(button)
end
    if control.star and not IsInGamepadPreferredMode() and button == MOUSE_BUTTON_INDEX_LEFT and GetCursorContentType() == MOUSE_CONTENT_EMPTY then
        control.star:OnDragStart()
    end
end