Back to Home

ESO Lua File v101043

ingame/restyle/gamepad/restylestation_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
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
local ACTION_NONE = 0
local ACTION_STYLES = 1
local ACTION_DYES = 2
local OUTFIT_SWATCH_SLOT_ANCHOR_PADDING = 2
local RESTYLE_MODE_OMITTED_SLOT_TYPES =
{
    [RESTYLE_MODE_COMPANION_OUTFIT] =
    {
        [EQUIP_SLOT_HEAD] = true,
    },
    [RESTYLE_MODE_COMPANION_COLLECTIBLE] =
    {
        [COLLECTIBLE_CATEGORY_TYPE_HAT] = true,
    },
}
ZO_RestyleStation_Gamepad = ZO_Gamepad_MultiFocus_ParametricList_Screen:Subclass()
function ZO_RestyleStation_Gamepad:New(...)
    return ZO_Gamepad_MultiFocus_ParametricList_Screen.New(self, ...)
end
function ZO_RestyleStation_Gamepad:Initialize(control)
    self.pendingLoopAnimationPool = ZO_MetaPool:New(ZO_Pending_Outfit_LoopAnimation_Pool)
    self.actionMode = ACTION_NONE
    GAMEPAD_RESTYLE_STATION_SCENE = ZO_InteractScene:New("gamepad_restyle_station", SCENE_MANAGER, ZO_DYEING_STATION_INTERACTION)
    GAMEPAD_RESTYLE_STATION_SCENE:SetInputPreferredMode(INPUT_PREFERRED_MODE_ALWAYS_GAMEPAD)
    SYSTEMS:RegisterGamepadRootScene("restyle_station", GAMEPAD_RESTYLE_STATION_SCENE)
    ZO_Gamepad_MultiFocus_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, nil, GAMEPAD_RESTYLE_STATION_SCENE)
    activeWeaponPair, self.weaponSwapDisabled = GetActiveWeaponPairInfo()
    GAMEPAD_RESTYLE_STATION_FRAGMENT = ZO_FadeSceneFragment:New(control)
    GAMEPAD_RESTYLE_STATION_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_FRAGMENT_SHOWING then
            self:OnFragmentShowing()
        elseif newState == SCENE_FRAGMENT_HIDDEN then
            self:OnFragmentHidden()
        end
    end)
    GAMEPAD_RESTYLE_STATION_SCENE:SetHideSceneConfirmationCallback(function(...) self:OnConfirmHideScene(...) end)
    self.parametricListArea.CanBeSelected = function()
        return RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COMPANION_EQUIPMENT
    end
    local function OnOutfitPendingDataChanged(actorCategory, outfitIndex, slotIndex)
        if not slotIndex and GAMEPAD_RESTYLE_STATION_SCENE:IsShowing() then
            self:Update()
        else
            self.dirty = true
        end
    end
    local function OnWeaponPairLockedChanged(event, disabled)
        self.weaponSwapDisabled = disabled
    end
    self:GetMainList():SetNoItemText(GetString(SI_OUTFIT_COMPANION_NO_OUTFIT_DESCRIPTION))
    ZO_OUTFIT_MANAGER:RegisterCallback("PendingDataChanged", OnOutfitPendingDataChanged)
    control:RegisterForEvent(EVENT_CURRENCY_UPDATE, function(eventId, ...) self:OnCurrencyChanged(...) end)
    control:RegisterForEvent(EVENT_WEAPON_PAIR_LOCK_CHANGED, OnWeaponPairLockedChanged)
    control:SetHandler("OnUpdate", function(_, currentFrameTimeSeconds) self:OnUpdate(currentFrameTimeSeconds) end)
end
do
    local NEXT_WEAPON_STATE_EVALUATE_TIME_S = 0.25
    function ZO_RestyleStation_Gamepad:OnUpdate(currentFrameTimeSeconds)
        local targetData = self.outfitSlotList:GetTargetData()
        if targetData then
            local outfitSlot = targetData.outfitSlot
            local areWeaponsSheathed = ArePlayerWeaponsSheathed()
            local restyleMode = RESTYLE_GAMEPAD:GetMode()
            local actorCategory = ZO_OUTFIT_MANAGER.GetActorCategoryByRestyleMode(restyleMode)
            if ZO_OUTFIT_MANAGER:IsOutfitSlotWeapon(outfitSlot) then
                if not ZO_OUTFIT_MANAGER:IsWeaponOutfitSlotActive(outfitSlot, actorCategory) then
                    if not self.weaponSwapDisabled and GetUnitLevel("player") >= GetWeaponSwapUnlockedLevel() then
                        OnWeaponSwap()
                        -- Weapon swapping automatically unsheathes
                        return
                    end
                end
                if areWeaponsSheathed then
                    TogglePlayerWield()
                end
            else
                if not areWeaponsSheathed then
                    TogglePlayerWield()
                end
            end
        end
        -- We do this on an update loop because sometimes when changing target you aren't in a state where you're allowed to swap or unsheath
        -- So you could get yourself stuck into the wrong state
        self.nextWeaponStateEvaluateTimeS = GetFrameTimeSeconds() + NEXT_WEAPON_STATE_EVALUATE_TIME_S
    end
end
function ZO_RestyleStation_Gamepad:OnConfirmHideScene(scene, nextSceneName, bypassHideSceneConfirmationReason)
    if bypassHideSceneConfirmationReason == nil then
        self:AttemptExit()
    else
        scene:AcceptHideScene()
    end
end
function ZO_RestyleStation_Gamepad:OnShowing()
    KEYBIND_STRIP:RemoveDefaultExit()
    -- Always start on the list if not companion equipment
    if not self:IsCurrentFocusArea(self.parametricListArea) and RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COMPANION_EQUIPMENT then
        self.currentFocalArea = self.parametricListArea
    end
    ZO_Gamepad_MultiFocus_ParametricList_Screen.OnShowing(self)
end
function ZO_RestyleStation_Gamepad:OnHide()
    ZO_Gamepad_MultiFocus_ParametricList_Screen.OnHide(self)
    local selectedControl = self.outfitSlotList:GetSelectedControl()
    if selectedControl then
        selectedControl.dyeSelectorFocus:Deactivate()
    end
    self.dyeAllFocus:Deactivate()
    self.outfitSlotList:Deactivate()
    local currentPanel = self:GetActionPanel(self.actionMode)
    if currentPanel:IsActive() then
        currentPanel:Deactivate()
    end
    self:SwitchToAction(ACTION_NONE)
    KEYBIND_STRIP:RestoreDefaultExit()
end
function ZO_RestyleStation_Gamepad:OnFragmentShowing()
    if self.currentOutfitManipulator then
        if self.currentOutfitManipulator:IsMarkedForPreservation() then
            self.currentOutfitManipulator:RestorePreservedDyeData()
            self.currentOutfitManipulator:UpdatePreviews()
        else
            self.currentOutfitManipulator:ClearPendingChanges()
        end
    end
    self.outfitsPanel:OnShowing()
    self.dyeingPanel:OnShowing()
    self:RefreshHeader()
    self:RefreshFooter()
    if self.actionMode == ACTION_STYLES then
        self:UpdateOutfitsPanel()
    end
end
function ZO_RestyleStation_Gamepad:OnFragmentHidden()
    self.outfitsPanel:OnHide()
    self.dyeingPanel:OnHide()
    if self.currentOutfitManipulator then
        self.currentOutfitManipulator:ClearPendingChanges()
    end
    if not ArePlayerWeaponsSheathed() then
        TogglePlayerWield()
    end
    ITEM_PREVIEW_GAMEPAD:ClearPreviewCollection()
end
function ZO_RestyleStation_Gamepad:OnDeferredInitialize()
    ZO_Gamepad_MultiFocus_ParametricList_Screen.OnDeferredInitialize(self)
    self:InitializeFoci()
    ZO_GamepadGenericHeader_Initialize(self.header, ZO_GAMEPAD_HEADER_TABBAR_CREATE)
    local stylesHeaderData =
    {
        text = GetString(SI_GAMEPAD_DYEING_EQUIPMENT_ACTION_STYLES),
        callback = function() self:SwitchToAction(ACTION_STYLES) end,
        canSelect = true
    }
    local dyesHeaderData =
    {
        text = GetString(SI_GAMEPAD_DYEING_EQUIPMENT_ACTION_DYES),
        callback = function() self:SwitchToAction(ACTION_DYES) end,
        canSelect = true,
        visible = function()
            return RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COMPANION_EQUIPMENT
        end,
    }
    self.outfitHeaderData =
    {
        tabBarEntries =
        {
            stylesHeaderData,
            dyesHeaderData
        },
    }
    self.defaultHeaderData =
    {
        tabBarEntries =
        {
            dyesHeaderData
        }
    }
    local function UpdateCarriedCurrencyControl(control)
        ZO_CurrencyControl_SetSimpleCurrency(control, CURT_MONEY, GetCurrencyAmount(CURT_MONEY, CURRENCY_LOCATION_CHARACTER), ZO_GAMEPAD_CURRENCY_OPTIONS_LONG_FORMAT)
        return true
    end
    local IS_PLURAL = false
    local IS_UPPER = false
    self.footerData =
    {
        data1HeaderText = GetCurrencyName(CURT_MONEY, IS_PLURAL, IS_UPPER),
    }
end
function ZO_RestyleStation_Gamepad:CreateApplyKeybind(multiFocusArea)
    return
    {
        name = function()
            if self.currentOutfitManipulator then
                local slotsCost, flatCost = self.currentOutfitManipulator:GetAllCostsForPendingChanges()
                if slotsCost > 0 then
                    local IS_GAMEPAD = true
                    local USE_SHORT_FORMAT = false
                    local formattedSlotsCurrency = ZO_CurrencyControl_FormatCurrencyAndAppendIcon(slotsCost, USE_SHORT_FORMAT, CURT_MONEY, IS_GAMEPAD)
                    local formattedFlatCurrency = ZO_CurrencyControl_FormatCurrencyAndAppendIcon(flatCost, USE_SHORT_FORMAT, CURT_STYLE_STONES, IS_GAMEPAD)
                    return zo_strformat(SI_OUTFIT_COMMIT_SELECTION, formattedSlotsCurrency, formattedFlatCurrency)
                end
            end
            return GetString(SI_DYEING_COMMIT)
        end,
        keybind = "UI_SHORTCUT_SECONDARY",
        callback = function()
            self:CommitSelection()
            multiFocusArea:UpdateActiveFocusKeybinds()
        end,
        visible = function()
            return self:DoesHaveChanges()
        end,
        enabled = function()
            return self:CanApplyChanges()
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateUndoKeybind(multiFocusArea)
    return
    {
        name = GetString(SI_DYEING_UNDO),
        keybind = "UI_SHORTCUT_LEFT_STICK",
        visible = function() return self:DoesHaveChanges() end,
        callback = function()
            self:ShowUndoPendingChangesDialog()
            multiFocusArea:UpdateActiveFocusKeybinds()
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateRandomizeKeybind(multiFocusArea)
    return
    {
        name = function()
            if self.actionMode == ACTION_STYLES then
                return GetString(SI_OUTFIT_STYLES_RANDOMIZE)
            else
                return GetString(SI_DYEING_RANDOMIZE)
            end
        end,
        keybind = "UI_SHORTCUT_RIGHT_STICK",
        visible = function()
            return not (self.actionMode == ACTION_STYLES and RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_EQUIPMENT and RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_COMPANION_EQUIPMENT)
        end,
        callback = function()
            self:RandomizeSelection() 
            multiFocusArea:UpdateActiveFocusKeybinds()
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateOptionsKeybind()
    return
    {
        name = GetString(SI_GAMEPAD_DYEING_OPTIONS),
        keybind = "UI_SHORTCUT_TERTIARY",
        visible = function() return not (self.actionMode == ACTION_STYLES and RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_EQUIPMENT) end,
        callback = function() ZO_Dialogs_ShowGamepadDialog("GAMEPAD_RESTYLE_STATION_OPTIONS", self:CreateOptionsDialogActions()) end,
    }
end
function ZO_RestyleStation_Gamepad:InitializeKeybindStripDescriptors()
    local function MultiFocusBack()
        if self.actionMode == ACTION_DYES then
            self:ActivateCurrentSelection()
        else
            SCENE_MANAGER:HideCurrentScene()
        end
    end
    -- Apply
    local apply = self:CreateApplyKeybind(self)
    -- Main list
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        KEYBIND_STRIP:GenerateGamepadBackButtonDescriptor(MultiFocusBack),
        -- Select
        {
            name = function()
                if self.actionMode == ACTION_DYES then
                    local activeTool = self.dyeingPanel:GetActiveDyeTool()
                    return GetString(activeTool:GetToolActionString())
                else
                    return GetString(SI_GAMEPAD_SELECT_OPTION)
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            visible = function()
                return not (self.actionMode == ACTION_STYLES and RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_EQUIPMENT)
            end,
            callback = function()
                self:HandleSelectAction()
            end,
        },
        
        apply,
        -- Options
        self:CreateOptionsKeybind(),
        -- Undo All
        self:CreateUndoKeybind(self),
        -- Randomize
        self:CreateRandomizeKeybind(self),
    }
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.keybindStripDescriptor, self.outfitSlotList)
    self.outfitKeybindDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        KEYBIND_STRIP:GenerateGamepadBackButtonDescriptor(MultiFocusBack),
        -- Select
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                self:ShowOutfitSelection()
            end
        },
        apply,
    }
    self.savedSetsKeybindDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        KEYBIND_STRIP:GenerateGamepadBackButtonDescriptor(MultiFocusBack),
        -- Select
        {
            name = function()
                if self.actionMode == ACTION_DYES then
                    if self:ShouldShowSelectedDyeSet() then
                        return GetString(SI_GAMEPAD_DYEING_USE_SAVED_SET)
                    else
                        local activeTool = self.dyeingPanel:GetActiveDyeTool()
                        return GetString(activeTool:GetToolActionString())
                    end
                else
                    return GetString(SI_GAMEPAD_SELECT_OPTION)
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                self:HandleSelectSavedSetAction()
            end
        },
        -- Use Set
        {
            name = GetString(SI_GAMEPAD_DYEING_USE_SAVED_SET),
            keybind = "UI_SHORTCUT_TERTIARY",
            callback = function()
                self:HandleUseSetAction()
            end,
            visible = function()
                return not self:ShouldShowAllDyeFoci() and not self:ShouldShowSelectedDyeSet()
            end,
        },
    }
end
function ZO_RestyleStation_Gamepad:InitializeOutfitsPanel()
    self.outfitsPanel = ZO_OUTFITS_PANEL_GAMEPAD
    self.outfitsPanelFragmentGroup = { GAMEPAD_OUTFITS_GRID_LIST_PANEL_FRAGMENT, GAMEPAD_OUTFITS_GRID_LIST_FRAGMENT, GAMEPAD_NAV_QUADRANT_2_3_BACKGROUND_FRAGMENT }
    self.outfitsPanel:RegisterCallback("PanelSelectionEnd", function(...) self:OnPanelSelectionEnd(...) end)
end
function ZO_RestyleStation_Gamepad:InitializeDyesPanel()
    self.dyeingPanel = ZO_DYEING_PANEL_GAMEPAD
    self.dyeingPanelFragmentGroup = { GAMEPAD_DYEING_SLOTS_PANEL_FRAGMENT, GAMEPAD_DYES_GRID_LIST_FRAGMENT, GAMEPAD_DYE_TOOLS_GRID_LIST_FRAGMENT, GAMEPAD_NAV_QUADRANT_2_3_BACKGROUND_FRAGMENT }
    self.dyeingPanel:RegisterCallback("PanelSelectionEnd", function(...) self:OnPanelSelectionEnd(...) end)
    self.dyeingPanel:RegisterCallback("DyeSelected", function(...) self:OnDyeSelected(...) end)
    self.dyeingPanel:RegisterCallback("ToolSelected", function(...) self:OnDyeToolSelected(...) end)
    self.dyeingPanel:RegisterCallback("PendingDyesChanged", function(...) self:OnPendingDyesChanged(...) end)
    self.dyeingPanel:RegisterCallback("SavedSetSlotChanged", function(...) self:OnSavedSetSlotChanged(...) end)
    local function HighlightAllSlots(entry)
        if entry then
            self:HighlightAllFociByChannel(entry.dyeChannel)
        else
            self:ResetHighlightAllFoci()
        end
    end
    self.dyeAllFocus = ZO_GamepadFocus:New(self.control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    for i = 1, 3 do 
        local entry = { dyeChannel = i }
        self.dyeAllFocus:AddEntry(entry)
    end
end
function ZO_RestyleStation_Gamepad:InitializeColorPresetControls()
    self.savedPresetsControl = self.header:GetNamedChild("SavedPresets")
    self.savedPresetsControl.highlight = self.savedPresetsControl:GetNamedChild("SharedHighlight")
    self.savedSets = {}
    self.savedSetFocus = ZO_GamepadFocus:New(self.control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    self.savedSetChannelFocus = ZO_GamepadFocus:New(self.control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    self.savedSetDyeAllChannelFocus = ZO_GamepadFocus:New(self.control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    local numSavedSets = GetNumSavedDyeSets()
    local padding
    for i = 1, numSavedSets do
        local newControl = CreateControlFromVirtual("$(parent)Preset", self.savedPresetsControl, "ZO_DyeingSwatchPreset_Gamepad", i)
        local controlWidth = newControl:GetDimensions()
        if not padding then
            local availableWidth = ZO_GAMEPAD_CONTENT_WIDTH - (controlWidth * numSavedSets)
            padding = availableWidth / (numSavedSets + 1) -- We want padding on left and right.
        end
        newControl:SetAnchor(TOPLEFT, self.savedPresetsControl, TOPLEFT, (padding + controlWidth) * (i - 1), 0)
        newControl.savedSetIndex = i
        table.insert(self.savedSets, newControl)
        self:RefreshSavedSet(i)
        local entry =
        {
            control = newControl,
            highlight = newControl:GetNamedChild("Highlight"),
        }
        self.savedSetFocus:AddEntry(entry)
        for _, dyeChannelControl in ipairs(newControl.dyeControls) do
            dyeChannelControl.channelHighlight = dyeChannelControl:GetNamedChild("Highlight")
            entry =
            {
                control = dyeChannelControl,
                highlight = dyeChannelControl.channelHighlight,
            }
            self.savedSetChannelFocus:AddEntry(entry)
        end
    end
    for i = 1, 3 do
        local dyeControlsForChannel = {}
        for j = 1, numSavedSets do
            local dyeChannelControl = self.savedSets[j].dyeControls[i]
            table.insert(dyeControlsForChannel, dyeChannelControl)
        end
        local entry = 
        {
            data = dyeControlsForChannel,
            activate = function(control, data)
                            for _, dyeChannelControl in ipairs(data) do
                                dyeChannelControl.channelHighlight:SetAlpha(1)
                            end
                       end,
            deactivate = function(control, data)
                            for _, dyeChannelControl in ipairs(data) do
                                dyeChannelControl.channelHighlight:SetAlpha(0)
                            end
                       end,
        }
        self.savedSetDyeAllChannelFocus:AddEntry(entry)
    end
end
local GamepadMultiFocusArea_SavedSets = ZO_GamepadMultiFocusArea_Base:Subclass()
function GamepadMultiFocusArea_SavedSets:CanBeSelected()
    return self.manager.actionMode == ACTION_DYES
end
local GamepadMultiFocusArea_OutfitSelector = ZO_GamepadMultiFocusArea_Base:Subclass()
function GamepadMultiFocusArea_OutfitSelector:CanBeSelected()
    return RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COLLECTIBLE and RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COMPANION_COLLECTIBLE
end
function ZO_RestyleStation_Gamepad:InitializeFoci()
    local function SetActivateCallback()
        if self:ShouldShowAllDyeFoci() then
            self.activeSavedSetsFocus = self.savedSetDyeAllChannelFocus
        elseif self:ShouldShowSelectedDyeSet() then
            self.activeSavedSetsFocus = self.savedSetFocus
        else
            self.activeSavedSetsFocus = self.savedSetChannelFocus
        end
        self.activeSavedSetsFocus:Activate()
    end
    local function SetDeactivateCallback()
        if self.activeSavedSetsFocus then
            self.activeSavedSetsFocus:Deactivate()
            self.activeSavedSetsFocus = nil
        end
    end
    self.savedSetsHeaderFocus = GamepadMultiFocusArea_SavedSets:New(self, SetActivateCallback, SetDeactivateCallback)
    self.savedSetsHeaderFocus:SetKeybindDescriptor(self.savedSetsKeybindDescriptor)
    self:AddPreviousFocusArea(self.savedSetsHeaderFocus)
    self.savedPresetsControl:SetHidden(true)
    self.outfitSelectorControl = self.header:GetNamedChild("OutfitSelector")
    self.outfitSelectorNameLabel = self.outfitSelectorControl:GetNamedChild("OutfitName")
    local function OutfitActivateCallback()
        GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_LEFT_TOOLTIP)
        self.outfitSelectorNameLabel:SetColor(ZO_SELECTED_TEXT:UnpackRGBA())
    end
    local function OutfitDeactivateCallback()
        self.outfitSelectorNameLabel:SetColor(ZO_DISABLED_TEXT:UnpackRGBA())
    end
    self.outfitSelectorHeaderFocus = GamepadMultiFocusArea_OutfitSelector:New(self, OutfitActivateCallback, OutfitDeactivateCallback)
    self.outfitSelectorHeaderFocus:SetKeybindDescriptor(self.outfitKeybindDescriptor)
    self:AddPreviousFocusArea(self.outfitSelectorHeaderFocus)
    self.outfitSelectorNameLabel:SetColor(ZO_DISABLED_TEXT:UnpackRGBA())
end
function ZO_RestyleStation_Gamepad:InitializeChangedDyeControlPool()
    self.dyeChangedControlPool = ZO_ControlPool:New("ZO_DyeingChangedHighlight_Gamepad", GuiRoot, "DyeSlotChanged_Gamepad")
    local function CustomResetFunction(control)
        control:SetColor(ZO_DEFAULT_ENABLED_COLOR:UnpackRGB())
    end
    self.dyeChangedControlPool:SetCustomResetBehavior(CustomResetFunction)
end
function ZO_RestyleStation_Gamepad:UpdateDyeSlotChangedOnControl(control, hasChanged)
    if control.dyeChangedControlKey and not hasChanged then
        self.dyeChangedControlPool:ReleaseObject(control.dyeChangedControlKey)
        control.dyeChangedControlKey = nil
        control.dyeChangedControl = nil
    elseif not control.dyeChangedControlKey and hasChanged then
        local dyeChangedControl, key = self.dyeChangedControlPool:AcquireObject()
        dyeChangedControl:SetAnchor(TOPLEFT, control, TOPLEFT, -OUTFIT_SWATCH_SLOT_ANCHOR_PADDING, -OUTFIT_SWATCH_SLOT_ANCHOR_PADDING)
        dyeChangedControl:SetAnchor(BOTTOMRIGHT, control, BOTTOMRIGHT, OUTFIT_SWATCH_SLOT_ANCHOR_PADDING, OUTFIT_SWATCH_SLOT_ANCHOR_PADDING)
        dyeChangedControl:SetParent(control)
        dyeChangedControl:SetHidden(false)
        dyeChangedControl:SetColor(ZO_DYEING_OUTFIT_SWATCH_CHANGED_COLOR:UnpackRGB())
        control.dyeChangedControlKey = key
        control.dyeChangedControl = dyeChangedControl
    end
end
function ZO_RestyleStation_Gamepad:SetupList(list)
    self.outfitSlotList = list
    local function SetupSlotEntry(control, data, selected, reselectingDuringRebuild, enabled, active)
        ZO_SharedGamepadEntry_OnSetup(control, data, selected, reselectingDuringRebuild, enabled, active)
        local isDyeable = IsRestyleSlotTypeDyeable(RESTYLE_GAMEPAD:GetMode(), data.restyleIndex)
        local showSlots = (selected and isDyeable) or self:ShouldShowAllDyeFoci()
        local changedDyeChannels = data.restyleSlotData:GetDyeChannelChangedStates()
        control.slotDyes:SetHidden(not showSlots)
        if showSlots then
            ZO_Dyeing_RefreshDyeableSlotControlDyes(control.dyeControls, data.restyleSlotData)
        end
        for i, hasChanged in ipairs(changedDyeChannels) do
            self:UpdateDyeSlotChangedOnControl(control.dyeControls[i], hasChanged and showSlots) -- if we are not showing Slots, hide all active dyeChangedControls
        end
        if data.restyleSlotData:IsDataDyeable() then
            if self:ShouldShowAllDyeFoci() then
                local dyeChannel = self.dyeAllFocus:GetFocus()
                if dyeChannel then
                    ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_Only(control, dyeChannel)
                end
            elseif self:ShouldShowSelectedDyeSet() then
                if selected then
                    ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_All(control)
                end
            else
                local dyeChannel = control.dyeSelectorFocus:GetFocus()
                if dyeChannel then
                    ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_Only(control, dyeChannel)
                end
            end
        end
    end
    local function SetupOutfitSlotEntry(control, data, selected, reselectingDuringRebuild, enabled, active)
        local slotManipulator = data.slotManipulator
        data:ClearIcons()
        data:AddIcon(slotManipulator:GetSlotAppropriateIcon())
        SetupSlotEntry(control, data, selected, reselectingDuringRebuild, enabled, active)
        if slotManipulator:IsAnyChangePending() then
            local individualCost = slotManipulator:GetPendingChangeCost()
            ZO_CurrencyControl_SetSimpleCurrency(control.priceLabel, CURT_MONEY, individualCost, ZO_GAMEPAD_CURRENCY_OPTIONS)
        else
            control.priceLabel:SetText("")
        end
        local appropriateCollectibleId = slotManipulator:GetPendingCollectibleId()
        if appropriateCollectibleId > 0 then
            local collectibleData = ZO_COLLECTIBLE_DATA_MANAGER:GetCollectibleDataById(appropriateCollectibleId)
            ZO_RestyleStation_Gamepad_SetOutfitEntryBorder(control, collectibleData, slotManipulator, self.pendingLoopAnimationPool)
            control.borderBackground:SetHidden(false)
        else
            ZO_RestyleStation_Gamepad_CleanupAnimationOnControl(control, self.pendingLoopAnimationPool)
            control.borderBackground:SetHidden(true)
        end
    end
    local function ResetSlotEntry(control)
        control.dyeSelectorFocus:Deactivate()
    end
    local function ResetOutfitSlotEntry(control)
        ResetSlotEntry(control)
        ZO_RestyleStation_Gamepad_CleanupAnimationOnControl(control, self.pendingLoopAnimationPool)
    end
    local EQUALITY_FUNCTION = nil
    local CONTROL_POOL_PREFIX = nil
    local NO_HEADER_SETUP_FUNCTION = nil
    list:AddDataTemplate("ZO_RestyleSlot_EntryTemplate_Gamepad", SetupSlotEntry, ZO_GamepadMenuEntryTemplateParametricListFunction, EQUALITY_FUNCTION, CONTROL_POOL_PREFIX, ResetSlotEntry)
    list:AddDataTemplate("ZO_OutfitSlot_EntryTemplate_Gamepad", SetupOutfitSlotEntry, ZO_GamepadMenuEntryTemplateParametricListFunction, EQUALITY_FUNCTION, CONTROL_POOL_PREFIX, ResetOutfitSlotEntry)
    list:AddDataTemplateWithHeader("ZO_OutfitSlot_EntryTemplate_Gamepad", SetupOutfitSlotEntry, ZO_GamepadMenuEntryTemplateParametricListFunction, EQUALITY_FUNCTION, "ZO_GamepadMenuEntryHeaderTemplate", NO_HEADER_SETUP_FUNCTION, CONTROL_POOL_PREFIX, ResetOutfitSlotEntry)
    list:SetOnSelectedDataChangedCallback(function(callbackList, selectedData, oldData) self:OnSlotChanged(oldData, selectedData) end)
end
function ZO_RestyleStation_Gamepad:InitializeOptionsDialog()
    local function OnReleaseDialog(dialog)
        if dialog.dropdowns then
            for _, dropdown in pairs(dialog.dropdowns) do
                dropdown:Deactivate()
            end
        end
        dialog.dropdowns = nil
    end
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_RESTYLE_STATION_OPTIONS",
    {
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        },
        title =
        {
            text = SI_GAMEPAD_OUTFITS_OPTIONS_HEADER
        },
        setup = function(dialog, allActions)
            local parametricList = dialog.info.parametricList
            ZO_ClearNumericallyIndexedTable(parametricList)
            dialog.dropdowns = {}
            for _, action in ipairs(allActions) do
                local entryData = ZO_GamepadEntryData:New(action.text)
                entryData.action = action
                entryData.setup = action.setup or ZO_SharedGamepadEntry_OnSetup
                entryData.callback = action.callback
                entryData.narrationText = action.narrationText
                local listItem =
                {
                    template = action.template or "ZO_GamepadItemEntryTemplate",
                    entryData = entryData,
                    header = action.header,
                }
                table.insert(parametricList, listItem)
            end
            dialog:setupFunc()
        end,
        parametricList = {}, -- Generated Dynamically
        
        blockDialogReleaseOnPress = true,
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData and targetData.callback then
                        targetData.callback(dialog)
                    end
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_GAMEPAD_BACK_OPTION,
                callback =  function(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_OPTIONS")
                end,
            },
        },
        noChoiceCallback = OnReleaseDialog,
    })
end
function ZO_RestyleStation_Gamepad:CreateOptionActionDataClear(slotManipulator)
    return
    {
        template = "ZO_GamepadItemEntryTemplate",
        text = GetString(SI_OUTFIT_SLOT_CLEAR_ACTION),
        callback = function(dialog)
            slotManipulator:Clear()
            self:GetMainList():RefreshVisible()
            self:UpdateOutfitsPanel()
            ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_OPTIONS")
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateOptionActionDataUndo(slotManipulator)
    return
    {
        template = "ZO_GamepadItemEntryTemplate",
        text = GetString(SI_OUTFIT_SLOT_UNDO_ACTION),
        callback = function(dialog)
            slotManipulator:ClearPendingChanges()
            self:GetMainList():RefreshVisible()
            self:UpdateOutfitsPanel()
            ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_OPTIONS")
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateOptionActionDataHide(slotManipulator, hiddenCollectibleId)
    return
    {
        template = "ZO_GamepadItemEntryTemplate",
        text = GetString(SI_OUTFIT_SLOT_HIDE_ACTION),
        callback = function(dialog)
            slotManipulator:SetPendingCollectibleIdAndItemMaterialIndex(hiddenCollectibleId, ZO_OUTFIT_STYLE_DEFAULT_ITEM_MATERIAL_INDEX)
            self:GetMainList():RefreshVisible()
            self:UpdateOutfitsPanel()
            ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_OPTIONS")
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateOptionActionDataChangeMaterial(slotManipulator, collectibleData)
    return
    {
        template = "ZO_GamepadItemEntryTemplate",
        text = GetString(SI_OUTFIT_SLOT_CHANGE_MATERIAL_ACTION),
        callback = function(dialog)
            ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_OPTIONS")
            ZO_Dialogs_ShowGamepadDialog("GAMEPAD_OUTFIT_ITEM_MATERIAL_OPTIONS", { slotManipulator = slotManipulator, selectedData = collectibleData })
        end,
    }
end
do
    local DYE_SORTING_DROPDOWN_ACTION_DATA
    function ZO_RestyleStation_Gamepad:CreateOptionActionDataDyeSortingDropdown()
        if not DYE_SORTING_DROPDOWN_ACTION_DATA then
            DYE_SORTING_DROPDOWN_ACTION_DATA = 
            {
                template = "ZO_Gamepad_Dropdown_Item_Indented",
                header = GetString(SI_GAMEPAD_DYEING_SORT_OPTION_HEADER),
                setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                    ZO_SharedGamepadEntry_OnSetup(control, data, selected, reselectingDuringRebuild, enabled, active)
                    control.dropdown:SetSortsItems(false)
                    table.insert(data.dialog.dropdowns, control.dropdown)
                    self:UpdateDyeSortingDropdownOptions(control.dropdown)
                    SCREEN_NARRATION_MANAGER:RegisterDialogDropdown(data.dialog, control.dropdown)
                end,
                callback = function(dialog)
                    local targetControl = dialog.entryList:GetTargetControl()
                    targetControl.dropdown:Activate()
                end,
                isDropdown = true,
            }
        end
        return DYE_SORTING_DROPDOWN_ACTION_DATA
    end
end
function ZO_RestyleStation_Gamepad:UpdateDyeSortingDropdownOptions(dropdown)
    dropdown:ClearItems()
    local function SelectNewSort(style)
        ZO_DYEING_MANAGER:SetSortStyle(style)
    end
    dropdown:AddItem(dropdown:CreateItemEntry(GetString(SI_DYEING_SORT_BY_RARITY), function() SelectNewSort(ZO_DYEING_SORT_STYLE_RARITY) end), ZO_COMBOBOX_SUPPRESS_UPDATE)
    dropdown:AddItem(dropdown:CreateItemEntry(GetString(SI_DYEING_SORT_BY_HUE), function() SelectNewSort(ZO_DYEING_SORT_STYLE_HUE) end), ZO_COMBOBOX_SUPPRESS_UPDATE)
    local currentSortingStyle = ZO_DYEING_MANAGER:GetSortStyle()
    if currentSortingStyle == ZO_DYEING_SORT_STYLE_RARITY then
        dropdown:SetSelectedItemText(GetString(SI_DYEING_SORT_BY_RARITY))
    elseif currentSortingStyle == ZO_DYEING_SORT_STYLE_HUE then
        dropdown:SetSelectedItemText(GetString(SI_DYEING_SORT_BY_HUE))
    end
end
function ZO_RestyleStation_Gamepad:CreateOptionActionDataDyeingShowLocked(optionalCallback)
    return
    {
        template = "ZO_CheckBoxTemplate_Gamepad",
        text = GetString(SI_RESTYLE_SHOW_LOCKED),
        setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
            ZO_GamepadCheckBoxTemplate_Setup(control, data, selected, reselectingDuringRebuild, enabled, active)
            if ZO_DYEING_MANAGER:GetShowLocked() then
                ZO_CheckButton_SetChecked(control.checkBox)
            else
                ZO_CheckButton_SetUnchecked(control.checkBox)
            end
        end,
        callback = function(dialog)
            local targetControl = dialog.entryList:GetTargetControl()
            ZO_GamepadCheckBoxTemplate_OnClicked(targetControl)
            ZO_DYEING_MANAGER:SetShowLocked(ZO_GamepadCheckBoxTemplate_IsChecked(targetControl))
            if optionalCallback then
                optionalCallback(dialog)
            end
            SCREEN_NARRATION_MANAGER:QueueDialog(dialog)
        end,
    }
end
    return
    {
        template = "ZO_CheckBoxTemplate_Gamepad",
        text = GetString(SI_RESTYLE_SHOW_LOCKED),
        setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
            ZO_GamepadCheckBoxTemplate_Setup(control, data, selected, reselectingDuringRebuild, enabled, active)
            if ZO_OUTFIT_MANAGER:GetShowLocked() then
                ZO_CheckButton_SetChecked(control.checkBox)
            else
                ZO_CheckButton_SetUnchecked(control.checkBox)
            end
        end,
        callback = function(dialog)
            local targetControl = dialog.entryList:GetTargetControl()
            ZO_GamepadCheckBoxTemplate_OnClicked(targetControl)
            ZO_OUTFIT_MANAGER:SetShowLocked(ZO_GamepadCheckBoxTemplate_IsChecked(targetControl))
            if optionalCallback then
                optionalCallback(dialog)
            end
            SCREEN_NARRATION_MANAGER:QueueDialog(dialog)
        end,
    }
end
function ZO_RestyleStation_Gamepad:CreateOptionsDialogActions()
    local actionsTable = {}
    if self.actionMode == ACTION_STYLES then
        -- Show Locked Styles
        table.insert(actionsTable, self:CreateOptionActionDataOutfitStylesShowLocked())
    elseif self.actionMode == ACTION_DYES then
        -- Dye Sorting Options
        table.insert(actionsTable, self:CreateOptionActionDataDyeSortingDropdown())
        -- Show Locked Dyes
        table.insert(actionsTable, self:CreateOptionActionDataDyeingShowLocked())
    end
    local numBaseActions = #actionsTable
    if self:HasActiveFocus() then
        local currentlySelectedData = self.outfitSlotList:GetTargetData()
        local slotManipulator = currentlySelectedData.slotManipulator
        if slotManipulator then
            -- Undo
            if slotManipulator:IsSlotDataChangePending() then 
                table.insert(actionsTable, self:CreateOptionActionDataUndo(slotManipulator))
            end
            if slotManipulator:GetPendingCollectibleId() > 0 then
                -- Clear
                table.insert(actionsTable, self:CreateOptionActionDataClear(slotManipulator))
            end
            -- Hide
            local hiddenCollectibleId = GetOutfitSlotDataHiddenOutfitStyleCollectibleId(slotManipulator:GetOutfitSlotIndex())
            if hiddenCollectibleId > 0 and slotManipulator:GetPendingCollectibleId() ~= hiddenCollectibleId then
                local hiddenCollectibleData = ZO_COLLECTIBLE_DATA_MANAGER:GetCollectibleDataById(hiddenCollectibleId)
                if hiddenCollectibleData:IsUnlocked() then
                    table.insert(actionsTable, self:CreateOptionActionDataHide(slotManipulator, hiddenCollectibleId))
                end
            end
        end
    end
    if #actionsTable > numBaseActions then
        actionsTable[numBaseActions + 1].header = GetString(SI_GAMEPAD_OUTFITS_SLOT_OPTIONS)
    end
    return actionsTable
end
function ZO_RestyleStation_Gamepad:UpdateOutfitsPanel()
    local currentlySelectedData = self.outfitSlotList:GetTargetData()
    if currentlySelectedData then
        local slotManipulator = currentlySelectedData.slotManipulator
        if slotManipulator then
            self.outfitsPanel:SetSlotManipulator(slotManipulator)
        else
            GAMEPAD_TOOLTIPS:LayoutTitleAndDescriptionTooltip(GAMEPAD_LEFT_TOOLTIP, GetString(SI_GAMEPAD_OUTFITS_NO_OUTFIT_EQUIPPED_TITLE), GetString(SI_GAMEPAD_OUTFITS_NO_OUTFIT_EQUIPPED_DESCRIPTION))
        end
    else
        self.outfitsPanel:SetSlotManipulator(nil)
    end
end
function ZO_RestyleStation_Gamepad:UpdateCurrentActionFragmentGroup()
    if self.actionMode == ACTION_STYLES and (self:IsCurrentFocusArea(self.outfitSelectorHeaderFocus) or RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_EQUIPMENT) then
        SCENE_MANAGER:RemoveFragmentGroup(self:GetActionFragmentGroup(self.actionMode))
    else
        SCENE_MANAGER:AddFragmentGroup(self:GetActionFragmentGroup(self.actionMode))
    end
end
function ZO_RestyleStation_Gamepad:PerformUpdate()
    self.outfitSlotList:Clear()
    local restyleMode = RESTYLE_GAMEPAD:GetMode()
    if restyleMode == RESTYLE_MODE_OUTFIT or restyleMode == RESTYLE_MODE_COMPANION_OUTFIT then
        local foundMainWeapons = false
        local foundBackupWeapons = false
        local actorCategory = ZO_OUTFIT_MANAGER.GetActorCategoryByRestyleMode(restyleMode)
        local mainHandOutfitSlot, offHandOutfitSlot, backupMainHandOutfitSlot, backupOffHandOutfitSlot = GetOutfitSlotsForEquippedWeapons(actorCategory)
        for outfitSlotIndex = OUTFIT_SLOT_ITERATION_BEGIN, OUTFIT_SLOT_ITERATION_END do
            local isArmor = ZO_OUTFIT_MANAGER:IsOutfitSlotArmor(outfitSlotIndex)
            local isEquippedWeapon = not isArmor and (mainHandOutfitSlot == outfitSlotIndex
                                     or offHandOutfitSlot == outfitSlotIndex
                                     or backupMainHandOutfitSlot == outfitSlotIndex
                                     or backupOffHandOutfitSlot == outfitSlotIndex)
            local isOmittedSlotType = RESTYLE_MODE_OMITTED_SLOT_TYPES[restyleMode] and RESTYLE_MODE_OMITTED_SLOT_TYPES[restyleMode][outfitSlotIndex]
            if (isArmor or isEquippedWeapon) and not isOmittedSlotType then
                local slotManipulator = self.currentOutfitManipulator:GetSlotManipulator(outfitSlotIndex)
                local appropriateCollectibleId = slotManipulator:GetPendingCollectibleId()
                local isWeaponSlotMain = ZO_OUTFIT_MANAGER:IsWeaponOutfitSlotMain(outfitSlotIndex)
                local isWeaponSlotBackup = ZO_OUTFIT_MANAGER:IsWeaponOutfitSlotBackup(outfitSlotIndex)
                local name = zo_strformat(SI_CHARACTER_EQUIP_SLOT_FORMAT, GetString("SI_OUTFITSLOT", outfitSlotIndex))
                local icon = slotManipulator:GetSlotAppropriateIcon()
                local data = ZO_GamepadEntryData:New(name, icon)
                data.collectibleId = appropriateCollectibleId
                data.outfitSlot = outfitSlotIndex
                data.slotManipulator = slotManipulator
                data.restyleIndex = slotManipulator:GetOutfitSlotIndex()
                data.restyleSlotData = slotManipulator:GetRestyleSlotData()
                if isWeaponSlotMain and not foundMainWeapons then
                    data:SetHeader(GetString(SI_RESTYLE_SHEET_EQUIPMENT_WEAPONS_SET_1))
                    foundMainWeapons = true
                    self.outfitSlotList:AddEntryWithHeader("ZO_OutfitSlot_EntryTemplate_Gamepad", data)
                elseif isWeaponSlotBackup and not foundBackupWeapons then
                    data:SetHeader(GetString(SI_RESTYLE_SHEET_EQUIPMENT_WEAPONS_SET_2))
                    foundBackupWeapons = true
                    self.outfitSlotList:AddEntryWithHeader("ZO_OutfitSlot_EntryTemplate_Gamepad", data)
                else
                    self.outfitSlotList:AddEntry("ZO_OutfitSlot_EntryTemplate_Gamepad", data)
                end
            end
        end
    else
        local slotsByMode = ZO_Dyeing_GetSlotsForRestyleSet(restyleMode, ZO_RESTYLE_DEFAULT_SET_INDEX)
        -- Companion Equipment mode is not allowed to dye so the dyeable slots may be nil
        if slotsByMode then
            for _, dyeableSlotData in ipairs(slotsByMode) do
                local isOmittedSlotType = RESTYLE_MODE_OMITTED_SLOT_TYPES[restyleMode] and RESTYLE_MODE_OMITTED_SLOT_TYPES[restyleMode][dyeableSlotData:GetRestyleSlotType()]
                if not dyeableSlotData:ShouldBeHidden() and not isOmittedSlotType then
                    local name = zo_strformat(SI_CHARACTER_EQUIP_SLOT_FORMAT, dyeableSlotData:GetDefaultDescriptor())
                    local data = ZO_GamepadEntryData:New(name, dyeableSlotData:GetIcon())
                    data.restyleIndex = dyeableSlotData:GetRestyleSlotType()
                    data.restyleSlotData = ZO_RestyleSlotData:Copy(dyeableSlotData)
                    self.outfitSlotList:AddEntry("ZO_RestyleSlot_EntryTemplate_Gamepad", data)
                end
            end
        end
    end
    self.outfitSlotList:Commit()
    self.dirty = false
end
function ZO_RestyleStation_Gamepad:UpdateCurrentOutfitIndex()
    if RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_COLLECTIBLE or RESTYLE_GAMEPAD:GetMode() == RESTYLE_MODE_COMPANION_COLLECTIBLE then
        self.currentOutfitManipulator = nil
        return
    end
    local currentEditingActorCategory, currentEditingIndex = ZO_OUTFITS_SELECTOR_GAMEPAD:GetCurrentActorCategoryAndIndex()
    if not currentEditingIndex then
        self:SetOutfitManipulator(nil, currentEditingActorCategory)
    else
        ZO_OUTFITS_SELECTOR_GAMEPAD:SetCurrentActorCategory(currentEditingActorCategory)
        self:SetOutfitManipulator(ZO_OUTFIT_MANAGER:GetOutfitManipulator(currentEditingActorCategory, currentEditingIndex), currentEditingActorCategory)
    end
end
function ZO_RestyleStation_Gamepad:UpdateOutfitPreview()
    local restyleMode = RESTYLE_GAMEPAD:GetMode()
    if restyleMode == RESTYLE_MODE_COLLECTIBLE or restyleMode == RESTYLE_MODE_COMPANION_COLLECTIBLE then
        return
    end
    ITEM_PREVIEW_GAMEPAD:ResetOutfitPreview()
    if self.currentOutfitManipulator then
        ITEM_PREVIEW_GAMEPAD:PreviewOutfit(self.currentOutfitManipulator:GetActorCategory(), self.currentOutfitManipulator:GetOutfitIndex())
    else
        ITEM_PREVIEW_GAMEPAD:PreviewUnequipOutfit(ZO_OUTFIT_MANAGER.GetActorCategoryByRestyleMode(restyleMode))
    end
end
function ZO_RestyleStation_Gamepad:RefreshHeader()
    local restyleMode = RESTYLE_GAMEPAD:GetMode()
    if restyleMode ~= RESTYLE_MODE_COLLECTIBLE and restyleMode ~= RESTYLE_MODE_COMPANION_COLLECTIBLE then
        ZO_GamepadGenericHeader_Refresh(self.header, self.outfitHeaderData)
        if self.outfitSlotList:GetNumItems() == 0 then
            self.outfitSlotList:Deactivate()
            self:ActivateFocusArea(self.outfitSelectorHeaderFocus)
        end
    else
        ZO_GamepadGenericHeader_Refresh(self.header, self.defaultHeaderData)
    end
    self.outfitSelectorControl:SetHidden(restyleMode == RESTYLE_MODE_COLLECTIBLE or restyleMode == RESTYLE_MODE_COMPANION_COLLECTIBLE)
    if self.currentOutfitManipulator then
        self.outfitSelectorNameLabel:SetText(self.currentOutfitManipulator:GetOutfitName())
    else
        self.outfitSelectorNameLabel:SetText(GetString(SI_NO_OUTFIT_EQUIP_ENTRY))
    end
end
function ZO_RestyleStation_Gamepad:RefreshFooter()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    if currentMode == RESTYLE_MODE_OUTFIT or currentMode == RESTYLE_MODE_COMPANION_OUTFIT then
        GAMEPAD_GENERIC_FOOTER:Refresh(self.footerData)
    else
        GAMEPAD_GENERIC_FOOTER:Refresh({})
    end
end
function ZO_RestyleStation_Gamepad:GetFooterNarration()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    if currentMode == RESTYLE_MODE_OUTFIT or currentMode == RESTYLE_MODE_COMPANION_OUTFIT then
        return GAMEPAD_GENERIC_FOOTER:GetNarrationText(self.footerData)
    end
end
function ZO_RestyleStation_Gamepad:RefreshSavedSet(dyeSetIndex)
    local savedSetSwatch = self.savedSets[dyeSetIndex]
    local savedSetDyes = { GetSavedDyeSetDyes(dyeSetIndex) }
    for dyeChannel, dyeControl in ipairs(savedSetSwatch.dyeControls) do
        local currentDyeId = savedSetDyes[dyeChannel]
        ZO_DyeingUtils_SetSlotDyeSwatchDyeId(dyeControl, currentDyeId)
    end
end
function ZO_RestyleStation_Gamepad:RefreshSavedSets()
    for dyeSetIndex = 1, GetNumSavedDyeSets() do
        self:RefreshSavedSet(dyeSetIndex)
    end
end
function ZO_RestyleStation_Gamepad:RefreshSavedSetHighlight()
    if self:ShouldShowSelectedDyeSet() then
        ZO_Dyeing_Gamepad_SavedSet_Highlight(self.savedPresetsControl, self.savedSets[self.dyeingPanel:GetSelectedSavedSetIndex()])
    else
        ZO_Dyeing_Gamepad_SavedSet_Highlight(self.savedPresetsControl, nil)
    end
end
function ZO_RestyleStation_Gamepad:GetSelectedSavedSetIndex()
    local INCLUDE_SAVED_FOCUS = true
    local selectedSavedSet = self.savedSetFocus:GetFocusItem(INCLUDE_SAVED_FOCUS)
    return selectedSavedSet and selectedSavedSet.control.savedSetIndex
end
function ZO_RestyleStation_Gamepad:SwitchToAction(action)
    if self.actionMode ~= action then
        local previousActionPanel = self:GetActionPanel(self.actionMode)
        if self.actionMode ~= ACTION_NONE then
            local previousActionFragmentGroup = self:GetActionFragmentGroup(self.actionMode)
            SCENE_MANAGER:RemoveFragmentGroup(previousActionFragmentGroup)
            if previousActionPanel:IsActive() then
                self:DeactivateCurrentSelection()
            end
            GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_LEFT_TOOLTIP)
            if self.actionMode == ACTION_DYES then
                self:DeactivateRelevantDyeFoci()
                self:ResetHighlightAllFoci()
            end
        end
        self.actionMode = action
        if action ~= ACTION_NONE then
            local nextActionPanel = self:GetActionPanel(action)
            self:UpdateCurrentActionFragmentGroup()
            self:GetMainList():RefreshVisible()
            if action == ACTION_DYES then
                self:RefreshSavedSets()
                self:ActivateCurrentSelection()
            elseif action == ACTION_STYLES then
                self:UpdateOutfitsPanel()
                if self:IsCurrentFocusArea(self.savedSetsHeaderFocus) then
                    self.savedSetsHeaderFocus:HandleMoveNext()
                end
                self:UpdateActiveFocusKeybinds()
                TriggerTutorial(TUTORIAL_TRIGGER_OUTFIT_STYLES_SHOWN)
            end
        end
        self.savedPresetsControl:SetHidden(action ~= ACTION_DYES)
    end
end
function ZO_RestyleStation_Gamepad:GetActionPanel(action)
    if action == ACTION_STYLES then
        return self.outfitsPanel
    elseif action == ACTION_DYES then
        return self.dyeingPanel
    end
end
function ZO_RestyleStation_Gamepad:GetActionFragmentGroup(action)
    if action == ACTION_STYLES then
        return self.outfitsPanelFragmentGroup
    elseif action == ACTION_DYES then
        return self.dyeingPanelFragmentGroup
    end
end
function ZO_RestyleStation_Gamepad:HandleSelectAction()
    if self.actionMode == ACTION_DYES then
        local selectedControl = self.outfitSlotList:GetSelectedControl()
        local dyeChannelIndex
        if self:ShouldShowAllDyeFoci() then
            dyeChannelIndex = self.dyeAllFocus:GetFocus()
        else
            dyeChannelIndex = selectedControl.dyeSelectorFocus:GetFocus()
        end
        local activeTool = self.dyeingPanel:GetActiveDyeTool()
        local targetData = self.outfitSlotList:GetTargetData()
        local restyleSlotData = targetData.restyleSlotData
        local isChannelDyeableTable = {restyleSlotData:AreDyeChannelsDyeable()}
        if isChannelDyeableTable[dyeChannelIndex] or self:ShouldShowAllDyeFoci() or self:CanApplySelectedDyeSet() then
            activeTool:OnLeftClicked(restyleSlotData, dyeChannelIndex)
            self:GetMainList():RefreshVisible()
            self:RefreshKeybinds()
        else
            ZO_Alert(ALERT, nil, zo_strformat(SI_GAMEPAD_DYEING_UNDYEABLE_CHANNEL))
        end
    else
        self:ActivateCurrentSelection()
        PlaySound(SOUNDS.OUTFIT_GAMEPAD_MENU_ENTER)
    end
end
do
    local function GetTrueSetIndex(index)
        return zo_floor((index - 1) / 3) + 1
    end
    function ZO_RestyleStation_Gamepad:HandleSelectSavedSetAction()
        if self:ShouldShowSelectedDyeSet() then
            self.dyeingPanel:SetSelectedSavedSetIndex(self.savedSetFocus:GetFocus(true))
            self:RefreshSavedSetHighlight()
            self.savedSetsHeaderFocus:HandleMoveNext()
        else
            local activeTool = self.dyeingPanel:GetActiveDyeTool()
            local savedSetChannelIndex = self.activeSavedSetsFocus:GetFocus(true)
            local trueSetIndex = GetTrueSetIndex(savedSetChannelIndex)
            local trueChannelIndex = zo_mod(savedSetChannelIndex - 1, 3) + 1
            activeTool:OnSavedSetLeftClicked(trueSetIndex, trueChannelIndex)
        end
    end
    function ZO_RestyleStation_Gamepad:HandleUseSetAction()
        local savedSetChannelIndex = self.activeSavedSetsFocus:GetFocus(true)
        local trueSetIndex = GetTrueSetIndex(savedSetChannelIndex)
        self.dyeingPanel:SwitchToSavedSet(trueSetIndex)
        self:RefreshSavedSetHighlight()
        self.savedSetsHeaderFocus:HandleMoveNext()
    end
end
function ZO_RestyleStation_Gamepad:OnSlotChanged(oldData, selectedData)
    if self.actionMode == ACTION_STYLES then
        self:UpdateOutfitsPanel()
    elseif self.actionMode == ACTION_DYES then
        local oldControl = self.outfitSlotList:GetControlFromData(oldData)
        local newControl = self.outfitSlotList:GetControlFromData(selectedData)
        if self:HasActiveFocus() then
            if self:ShouldShowAllDyeFoci() then
                self:HighlightAllFociByChannel(self.dyeAllFocus:GetFocus())
            elseif self:ShouldShowSelectedDyeSet() then
                if newControl and selectedData.restyleSlotData:IsDataDyeable() then
                    ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_All(newControl)
                end
                if oldControl and oldData.restyleSlotData:IsDataDyeable() then
                    ZO_Dyeing_Gamepad_OutfitSwatchSlot_Reset_Highlight(oldControl)
                end
            else
                local oldIndex = 1
                if oldControl then
                    oldIndex = oldControl.dyeSelectorFocus:GetFocus(true)
                    oldControl.dyeSelectorFocus:Deactivate()
                end
                newControl.dyeSelectorFocus:SetFocusByIndex(oldIndex)
                if selectedData.restyleSlotData:IsDataDyeable() then
                    newControl.dyeSelectorFocus:Activate()
                end
            end
        end
    end
end
function ZO_RestyleStation_Gamepad:OnListAreaDeactivate()
    if self.actionMode == ACTION_STYLES then
        self:UpdateOutfitsPanel()
    elseif self.actionMode == ACTION_DYES then
        self:DeactivateRelevantDyeFoci()
        if self:ShouldShowSelectedDyeSet() then
            local selectedControl = self.outfitSlotList:GetSelectedControl()
            ZO_Dyeing_Gamepad_OutfitSwatchSlot_Reset_Highlight(selectedControl)
        end
    end
end
function ZO_RestyleStation_Gamepad:OnListAreaActivate()
    if self.actionMode == ACTION_STYLES then
        self:UpdateOutfitsPanel()
    elseif self.actionMode == ACTION_DYES then
        self:ActivateRelevantDyeFoci()
        if self:CanApplySelectedDyeSet() then
            local selectedControl = self.outfitSlotList:GetSelectedControl()
            ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_All(selectedControl)
        end
    end
end
function ZO_RestyleStation_Gamepad:OnFocusChanged()
end
function ZO_RestyleStation_Gamepad:OnPanelSelectionEnd(helperPanel)
    if self.actionMode == ACTION_DYES then
        if RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COLLECTIBLE and RESTYLE_GAMEPAD:GetMode() ~= RESTYLE_MODE_COMPANION_COLLECTIBLE then
            self.header.tabBar:MovePrevious()
        else
            SCENE_MANAGER:HideCurrentScene()
        end
    else
        self:DeactivateCurrentSelection()
        self:GetMainList():RefreshVisible()
    end
end
function ZO_RestyleStation_Gamepad:OnDyeToolSelected()
    local activeTool = self.dyeingPanel:GetActiveDyeTool()
    if not activeTool:HasSwatchSelection() then
        self:DeactivateCurrentSelection()
    end
end
function ZO_RestyleStation_Gamepad:OnPendingDyesChanged(restyleSlotData)
    if not restyleSlotData then
        if self.currentOutfitManipulator then
            self.currentOutfitManipulator:UpdatePreviews()
        else
            ApplyChangesToPreviewCollectionShown()
        end
    elseif restyleSlotData:IsOutfitSlot() then
        local slotManipulator = ZO_OUTFIT_MANAGER:GetOutfitSlotManipulatorFromRestyleSlotData(restyleSlotData)
        local DONT_REFRESH_IMMEDIATELY = false
        slotManipulator:UpdatePreview(DONT_REFRESH_IMMEDIATELY)
    end
end
function ZO_RestyleStation_Gamepad:OnDyeSelected()
end
function ZO_RestyleStation_Gamepad:OnSavedSetSlotChanged(dyeSetIndex)
    if dyeSetIndex then
        self:RefreshSavedSet(dyeSetIndex)
    else
        self:RefreshSavedSets()
    end
end
function ZO_RestyleStation_Gamepad:ActivateRelevantDyeFoci()
    if self:ShouldShowAllDyeFoci() then
        self.dyeAllFocus:Activate()
    elseif not self:ShouldShowSelectedDyeSet() then
        local selectedControl = self.outfitSlotList:GetSelectedControl()
        local data = self.outfitSlotList:GetDataForDataIndex(selectedControl.dataIndex)
        if data.restyleSlotData:IsDataDyeable() then
            selectedControl.dyeSelectorFocus:Activate()
        end
    end
end
function ZO_RestyleStation_Gamepad:DeactivateRelevantDyeFoci()
    if self:ShouldShowAllDyeFoci() then
        self.dyeAllFocus:Deactivate()
    elseif not self:ShouldShowSelectedDyeSet() then
        local selectedControl = self.outfitSlotList:GetSelectedControl()
        selectedControl.dyeSelectorFocus:Deactivate()
    end
end
function ZO_RestyleStation_Gamepad:ShouldShowAllDyeFoci()
    local activeTool = self.dyeingPanel:GetActiveDyeTool()
    return activeTool:GetCursorType() == MOUSE_CURSOR_FILL and self.actionMode == ACTION_DYES
end
function ZO_RestyleStation_Gamepad:ShouldShowSelectedDyeSet()
    local activeTool = self.dyeingPanel:GetActiveDyeTool()
    return activeTool:GetCursorType() == MOUSE_CURSOR_FILL_MULTIPLE and self.actionMode == ACTION_DYES
end
function ZO_RestyleStation_Gamepad:CanApplySelectedDyeSet()
    if not self:ShouldShowSelectedDyeSet() then
        return false
    end
    local selectedControl = self.outfitSlotList:GetSelectedControl()
    local data = self.outfitSlotList:GetDataForDataIndex(selectedControl.dataIndex)
    local isPrimaryChannelDyeable, isSecondaryChannelDyeable, isAccentChannelDyeable = data.restyleSlotData:AreDyeChannelsDyeable()
    return isPrimaryChannelDyeable or isSecondaryChannelDyeable or isAccentChannelDyeable
end
function ZO_RestyleStation_Gamepad:HighlightAllFociByChannel(dyeChannel)
    for control, visible in pairs(self.outfitSlotList:GetAllVisibleControls()) do
        local data = self.outfitSlotList:GetDataForDataIndex(control.dataIndex)
        if data.restyleSlotData:IsDataDyeable() then
            ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_Only(control, dyeChannel)
        end
    end
end
function ZO_RestyleStation_Gamepad:ResetHighlightAllFoci()
    for control, visible in pairs(self.outfitSlotList:GetAllVisibleControls()) do
    end
end
function ZO_RestyleStation_Gamepad:OnCurrencyChanged(currencyType, currencyLocation, newAmount, oldAmount, reason)
    if currencyType == CURT_STYLE_STONES or currencyType == CURT_MONEY then
        if SCENE_MANAGER:IsShowing(self.scene.name) then
            self:RefreshFooter()
        else
            self.dirty = true
        end
    end
end
function ZO_RestyleStation_Gamepad:SetOutfitManipulator(newManipulator, actorCategory)
    if self.currentOutfitManipulator ~= newManipulator then
        self.currentOutfitManipulator = newManipulator
        if newManipulator then
            local restyleMode = ZO_OUTFIT_MANAGER.GetRestyleModeByActorCategory(actorCategory)
            RESTYLE_GAMEPAD:SetMode(restyleMode)
        else
            if actorCategory == GAMEPLAY_ACTOR_CATEGORY_PLAYER then
                RESTYLE_GAMEPAD:SetMode(RESTYLE_MODE_EQUIPMENT)
            elseif actorCategory == GAMEPLAY_ACTOR_CATEGORY_COMPANION then
                RESTYLE_GAMEPAD:SetMode(RESTYLE_MODE_COMPANION_EQUIPMENT)
            end
        end
        self:PerformUpdate()
    end
end
function ZO_RestyleStation_Gamepad:AttemptExit()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    local setIndex = ZO_RESTYLE_DEFAULT_SET_INDEX
    if self.currentOutfitManipulator then
        setIndex = self.currentOutfitManipulator:GetOutfitIndex()
    end
    if self:DoesCurrentOutfitHaveChanges() then
        local function OnConfirmExit()
            local restyleMode = RESTYLE_GAMEPAD:GetMode()
            local actoryCategory = ZO_OUTFIT_MANAGER.GetActorCategoryByRestyleMode(restyleMode)
            ZO_OUTFIT_MANAGER:EquipOutfit(actoryCategory, self.currentOutfitManipulator:GetOutfitIndex())
            self.currentOutfitManipulator:ClearPendingChanges()
            GAMEPAD_RESTYLE_STATION_SCENE:AcceptHideScene()
        end
        local function OnCancelExit()
            GAMEPAD_RESTYLE_STATION_SCENE:RejectHideScene()
        end
        ZO_Dialogs_ShowGamepadDialog("CONFIRM_REVERT_CHANGES",
        {
            confirmCallback = OnConfirmExit,
            declineCallback = OnCancelExit,
        })
        return
    end
    if ZO_Dyeing_AreTherePendingDyes(currentMode, setIndex) then
        local function OnConfirmExit()
            self:ExitWithoutSave()
            GAMEPAD_RESTYLE_STATION_SCENE:AcceptHideScene()
        end
        local function OnCancelExit()
            GAMEPAD_RESTYLE_STATION_SCENE:RejectHideScene()
        end
        ZO_Dialogs_ShowGamepadDialog("EXIT_DYE_UI_DISCARD_GAMEPAD",
        {
            confirmCallback = OnConfirmExit,
            declineCallback = OnCancelExit,
        })
        return
    end
    GAMEPAD_RESTYLE_STATION_SCENE:AcceptHideScene()
end
function ZO_RestyleStation_Gamepad:ExitWithoutSave()
    local restyleMode = RESTYLE_GAMEPAD:GetMode()
    if restyleMode ~= RESTYLE_MODE_COLLECTIBLE and restyleMode ~= RESTYLE_MODE_COMPANION_COLLECTIBLE  then
        local actoryCategory = ZO_OUTFIT_MANAGER.GetActorCategoryByRestyleMode(restyleMode)
        if self.currentOutfitManipulator then
            ZO_OUTFIT_MANAGER:EquipOutfit(actoryCategory, self.currentOutfitManipulator:GetOutfitIndex())
        else
            ZO_OUTFIT_MANAGER:UnequipOutfit(actoryCategory)
        end
    end
end
function ZO_RestyleStation_Gamepad:ActivateCurrentSelection()
    local selectedControl = self.outfitSlotList:GetSelectedControl()
    if selectedControl then
        selectedControl.dyeSelectorFocus:Deactivate()
    end
    ZO_GamepadOnDefaultActivatedChanged(self.savedPresetsControl, false)
    local currentPanel = self:GetActionPanel(self.actionMode)
    currentPanel:Activate()
end
function ZO_RestyleStation_Gamepad:DeactivateCurrentSelection()
    local currentPanel = self:GetActionPanel(self.actionMode)
    currentPanel:Deactivate()
    ZO_GamepadOnDefaultActivatedChanged(self.savedPresetsControl, true)
end
function ZO_RestyleStation_Gamepad:CommitSelection()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    if currentMode == RESTYLE_MODE_OUTFIT or currentMode == RESTYLE_MODE_COMPANION_OUTFIT then
        local slotCosts = self.currentOutfitManipulator:GetTotalSlotCostsForPendingChanges()
        if slotCosts > 0 then
            ZO_Dialogs_ShowGamepadDialog("GAMEPAD_RESTYLE_STATION_CONFIRM_APPLY", { outfitManipulator = self.currentOutfitManipulator })
        else
            ZO_Dialogs_ShowGamepadDialog("CONFIRM_APPLY_OUTFIT_STYLE", { outfitManipulator = self.currentOutfitManipulator })
        end
    else
        if ZO_Dyeing_AreAllItemsBound(currentMode, ZO_RESTYLE_DEFAULT_SET_INDEX) then
            self:CompleteDyeChanges()
        else
            ZO_Dialogs_ShowGamepadDialog("CONFIRM_APPLY_DYE")
        end
    end
end
function ZO_RestyleStation_Gamepad:CompleteDyeChanges()
    ApplyPendingDyes(RESTYLE_GAMEPAD:GetMode())
end
function ZO_RestyleStation_Gamepad:DoesHaveChanges()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    if currentMode == RESTYLE_MODE_OUTFIT or currentMode == RESTYLE_MODE_COMPANION_OUTFIT then
        return self:DoesCurrentOutfitHaveChanges()
    else
        return ZO_Dyeing_AreTherePendingDyes(RESTYLE_GAMEPAD:GetMode(), ZO_RESTYLE_DEFAULT_SET_INDEX)
    end
end
function ZO_RestyleStation_Gamepad:CanApplyChanges()
    local currentMode = RESTYLE_GAMEPAD:GetMode()
    if currentMode == RESTYLE_MODE_OUTFIT or currentMode == RESTYLE_MODE_COMPANION_OUTFIT then
        return self:CanCurrentOutfitApplyChanges()
    else
        return true
    end
end
function ZO_RestyleStation_Gamepad:DoesCurrentOutfitHaveChanges()
    return self.currentOutfitManipulator and self.currentOutfitManipulator:IsAnyChangePending()
end
function ZO_RestyleStation_Gamepad:CanCurrentOutfitApplyChanges()
    return self.currentOutfitManipulator and self.currentOutfitManipulator:CanApplyChanges()
end
function ZO_RestyleStation_Gamepad:ShowUndoPendingChangesDialog()
    ZO_Dialogs_ShowGamepadDialog("CONFIRM_REVERT_OUTFIT_CHANGES", { confirmCallback = function() self:UndoPendingChanges() end})
end
function ZO_RestyleStation_Gamepad:UndoPendingChanges()
    if self.currentOutfitManipulator then
        self.currentOutfitManipulator:ClearPendingChanges()
        self.currentOutfitManipulator:UpdatePreviews()
        if self.outfitsPanel:IsActive() then
            self:UpdateOutfitsPanel()
        end
        PlaySound(SOUNDS.OUTFIT_GAMEPAD_UNDO_CHANGES)
    else
        PlaySound(SOUNDS.DYEING_UNDO_CHANGES)
    end
end
function ZO_RestyleStation_Gamepad:RandomizeSelection()
    if self.actionMode == ACTION_STYLES then
        if self.currentOutfitManipulator then
            self.currentOutfitManipulator:RandomizeStyleData()
        end
    elseif self.actionMode == ACTION_DYES then
        local currentMode = RESTYLE_GAMEPAD:GetMode()
        local setIndex = ZO_RESTYLE_DEFAULT_SET_INDEX
        if self.currentOutfitManipulator then
            setIndex = self.currentOutfitManipulator:GetOutfitIndex()
        end
        ZO_Dyeing_UniformRandomize(currentMode, setIndex, function() return ZO_DYEING_MANAGER:GetRandomUnlockedDyeId() end)
        self:OnPendingDyesChanged()
    end
end
function ZO_RestyleStation_Gamepad:ShowOutfitSelection()
    if self:DoesCurrentOutfitHaveChanges() then
        ZO_Dialogs_ShowGamepadDialog("CONFIRM_REVERT_OUTFIT_ON_CHANGE", { confirmCallback = function() self.currentOutfitManipulator:ClearPendingChanges() SCENE_MANAGER:Push("gamepad_outfits_selection") end})
    else
        SCENE_MANAGER:Push("gamepad_outfits_selection")
    end
end
-- Confimation Dialog --
function ZO_RestyleStation_Gamepad:InitializeConfirmationDialog()
    local IS_SINGULAR = true
    local IS_UPPER = true
    local NORMAL_FONT_SELECTED = "ZoFontGamepad42"
    local NORMAL_FONT_UNSELECTED = "ZoFontGamepad34"
    local function SetupOutfitApplyOption(control, data, selected, selectedDuringRebuild, enabled, activated)
        ZO_SharedGamepadEntry_OnSetup(control, data, selected, selectedDuringRebuild, enabled, activated)
        local currentCurrency = GetCurrencyAmount(data.currencyType, data.currencyLocation)
        local slotCosts, flatCost = self.currentOutfitManipulator:GetAllCostsForPendingChanges()
        local costToUse = data.currencyType == CURT_MONEY and slotCosts or flatCost
        local priceControl = control:GetNamedChild("Price")
        ZO_CurrencyControl_SetSimpleCurrency(priceControl, data.currencyType, data.value, ZO_GAMEPAD_CURRENCY_OPTIONS, CURRENCY_SHOW_ALL, costToUse > currentCurrency)
        priceControl:SetFont(selected and NORMAL_FONT_SELECTED or NORMAL_FONT_UNSELECTED)
        if selected then
            priceControl:SetAlpha(1)
        else
            priceControl:SetAlpha(0.5)
        end
    end 
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_RESTYLE_STATION_CONFIRM_APPLY",
    {
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        },
        title =
        {
            text = SI_OUTFIT_CONFIRM_COMMIT_TITLE
        },
        setup = function(dialog, allActions)
            local parametricList = dialog.info.parametricList
            ZO_ClearNumericallyIndexedTable(parametricList)
            local slotCosts, flatCost = self.currentOutfitManipulator:GetAllCostsForPendingChanges()
            -- gold
            if slotCosts > 0 then
                local entryData = ZO_GamepadEntryData:New(GetCurrencyName(CURT_MONEY, IS_SINGULAR, IS_UPPER))
                entryData.currencyType = CURT_MONEY
                entryData.setup = SetupOutfitApplyOption
                entryData.currencyLocation = CURRENCY_LOCATION_CHARACTER
                entryData.value = slotCosts
                entryData.useFlatCurrency = false
                entryData.narrationText = function(entryData, entryControl)
                    return { SCREEN_NARRATION_MANAGER:CreateNarratableObject(entryData.text), SCREEN_NARRATION_MANAGER:CreateNarratableObject(entryData.value) }
                end
                local listItem =
                {
                    template = "ZO_Restyle_ApplyChanges_EntryTemplate_Gamepad",
                    entryData = entryData,
                    header = GetString(SI_GAMEPAD_OUTFITS_APPLY_CHANGES_LIST_HEADER),
                    headerTemplate = "ZO_GamepadMenuEntryFullWidthHeaderTemplate",
                }
                table.insert(parametricList, listItem)
            end
            -- outfit scraps
            if flatCost > 0 then
                local entryData = ZO_GamepadEntryData:New(zo_strformat(SI_CURRENCY_NAME_FORMAT, GetCurrencyName(CURT_STYLE_STONES, IS_SINGULAR, IS_UPPER)))
                entryData.currencyType = CURT_STYLE_STONES
                entryData.currencyLocation = CURRENCY_LOCATION_ACCOUNT
                entryData.setup = SetupOutfitApplyOption
                entryData.value = flatCost
                entryData.useFlatCurrency = true
                entryData.narrationText = function(entryData, entryControl)
                    return { SCREEN_NARRATION_MANAGER:CreateNarratableObject(entryData.text), SCREEN_NARRATION_MANAGER:CreateNarratableObject(entryData.value) }
                end
                local listItem =
                {
                    template = "ZO_Restyle_ApplyChanges_EntryTemplate_Gamepad",
                    entryData = entryData,
                }
                table.insert(parametricList, listItem)
            end
            dialog:setupFunc()
        end,
        parametricList = {}, -- Added Dynamically
        parametricListOnSelectionChangedCallback = function(dialog, list, newSelectedData, oldSelectedData)
                                                        if newSelectedData then
                                                            local IS_GAMEPAD = true
                                                            local USE_SHORT_FORMAT = false
                                                            local balanceData =
                                                            {
                                                                data1 = { header = GetString(SI_GAMEPAD_OUTFITS_APPLY_CHANGES_BALANCE), 
                                                                value = ZO_CurrencyControl_FormatCurrencyAndAppendIcon(GetCurrencyAmount(newSelectedData.currencyType, newSelectedData.currencyLocation), USE_SHORT_FORMAT, newSelectedData.currencyType, IS_GAMEPAD) },
                                                            }
                                                            ZO_GenericGamepadDialog_RefreshHeaderData(dialog, balanceData)
                                                        end
                                                    end,
        blockDialogReleaseOnPress = true,
        buttons =
        {
            {
                onShowCooldown = 2000,
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData then
                        self.currentOutfitManipulator:SendOutfitChangeRequest(targetData.useFlatCurrency)
                    end
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_CONFIRM_APPLY")
                end,
                enabled = function(dialog)
                                local targetData = dialog.entryList:GetTargetData()
                                if targetData then
                                    local slotCosts, flatCost = self.currentOutfitManipulator:GetAllCostsForPendingChanges()
                                    local costToUse = targetData.currencyType == CURT_MONEY and slotCosts or flatCost
                                    return costToUse <= GetCurrencyAmount(targetData.currencyType, targetData.currencyLocation)
                                end
                                return false
                            end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_GAMEPAD_BACK_OPTION,
                callback =  function(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_CONFIRM_APPLY")
                end,
            },     
            {
                keybind = "DIALOG_SECONDARY",
                text = zo_strformat(SI_BUY_CURRENCY, GetCurrencyName(CURT_STYLE_STONES, IS_SINGULAR, IS_UPPER)),
                callback =  function(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_RESTYLE_STATION_CONFIRM_APPLY")
                    self.currentOutfitManipulator:SetMarkedForPreservation(true)
                    ShowMarketAndSearch("", MARKET_OPEN_OPERATION_OUTFIT_CURRENCY)
                end,
            },     
        } 
    })
end
-- XML Functions --
    ZO_RESTYLE_STATION_GAMEPAD = ZO_RestyleStation_Gamepad:New(control)
    SYSTEMS:RegisterGamepadObject("restyle_station", ZO_RESTYLE_STATION_GAMEPAD)
end
    -- Height of these controls needs to account for the dye slots underneath the text
    control.GetHeight = function(heightControl)
        local height = heightControl.label:GetTextHeight()
        if not heightControl.slotDyes:IsHidden() then
            height = height + heightControl.slotDyes:GetHeight()
        end
        return height
    end
    control.sharedHighlight = control:GetNamedChild("SharedHighlight")
    control.slotDyes = control:GetNamedChild("Dyes")
    control.dyeControls = control.slotDyes.dyeControls
    control.dyeHighlightControls = control.slotDyes.dyeHighlightControls
    control.dyeSelectorFocus = ZO_GamepadFocus:New(control.slotDyes, ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL))
    for i, dyeControl in ipairs(control.dyeControls) do
        local entry = {
                        control = dyeControl,
                        dyeChannel = i,
                        iconScaleAnimation = ANIMATION_MANAGER:CreateTimelineFromVirtual("ZO_DyeingSlot_Gamepad_FocusScaleAnimation", dyeControl),
                    }
        control.dyeSelectorFocus:AddEntry(entry)
    end
    control.Activate = function(activateControl, ...)
        activateControl.dyeSelectorFocus:SetFocusByIndex(1)
        activateControl.dyeSelectorFocus:Activate(...)
    end
    control.Deactivate = function(deactivateControl, ...)
        deactivateControl.dyeSelectorFocus:Deactivate(...)
    end
    local function OnSelectionChanged(entry)
        if entry then
            ZO_Dyeing_Gamepad_OutfitSwatchSlot_Highlight_Only(control, entry.dyeChannel)
        else
        end
        if control.onSelectionChangedCallback then
            control.onSelectionChangedCallback()
        end
    end
end
    control.borderBackground = control:GetNamedChild("BorderedBackground")
    control.priceLabel = control:GetNamedChild("Price")
end