ESO Lua File v100010

pregame/charactercreate/zo_charactercreate.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
local g_allianceRadioGroup
local g_raceRadioGroup
local g_classRadioGroup
local g_genderRadioGroup
local g_playingTransitionAnimations
local g_firstTimeInCharacterCreate = true
local g_characterCreateOption = CHARACTER_CREATE_DEFAULT_LOCATION
local g_manager
local SUBCATEGORY_PAD = 10
local CREATE_BUCKET_WINDOW_DATA =
{
    [CREATE_BUCKET_RACE] = 
    { 
        windowName = "RaceBucket", 
        title = GetString(SI_CREATE_CHARACTER_BUCKET_TITLE_RACE), 
        tabNormal = "EsoUI/Art/CharacterCreate/CharacterCreate_raceIcon_up.dds",
        tabPressed = "EsoUI/Art/CharacterCreate/CharacterCreate_raceIcon_down.dds",
        tabMouseOver = "EsoUI/Art/CharacterCreate/CharacterCreate_raceIcon_over.dds",
        nextTab = CREATE_BUCKET_CLASS,
        previousTab = CREATE_BUCKET_FACE,
        onExpandFn =    function()
                            if(not g_playingTransitionAnimations) then
                                CharacterCreateSetIdlePosture()
                            end
                        end,
    },
    [CREATE_BUCKET_CLASS] = 
    { 
        windowName = "ClassBucket", 
        title = GetString(SI_CREATE_CHARACTER_BUCKET_TITLE_CLASS), 
        tabNormal = "EsoUI/Art/CharacterCreate/CharacterCreate_classIcon_up.dds",
        tabPressed = "EsoUI/Art/CharacterCreate/CharacterCreate_classIcon_down.dds",
        tabMouseOver = "EsoUI/Art/CharacterCreate/CharacterCreate_classIcon_over.dds",
        nextTab = CREATE_BUCKET_BODY,
        previousTab = CREATE_BUCKET_RACE,
    },
    [CREATE_BUCKET_BODY] = 
    { 
        windowName = "BodyBucket", 
        title = GetString(SI_CREATE_CHARACTER_BUCKET_TITLE_BODY), 
        tabNormal = "EsoUI/Art/CharacterCreate/CharacterCreate_bodyIcon_up.dds",
        tabPressed = "EsoUI/Art/CharacterCreate/CharacterCreate_bodyIcon_down.dds",
        tabMouseOver = "EsoUI/Art/CharacterCreate/CharacterCreate_bodyIcon_over.dds",
        nextTab = CREATE_BUCKET_FACE,
        previousTab = CREATE_BUCKET_CLASS,
        onExpandFn = function() SetCharacterCameraZoomAmount(-1) end,
        subCategoryData =
        {
            { id = SLIDER_SUBCAT_BODY_TYPE, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_BODY_FEATURES, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_BODY_UPPER, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_BODY_LOWER, anchorYOffsetOverride = SUBCATEGORY_PAD, },
        },
    },
    [CREATE_BUCKET_FACE] = 
    { 
        windowName = "FaceBucket", 
        title = GetString(SI_CREATE_CHARACTER_BUCKET_TITLE_FACE), 
        tabNormal = "EsoUI/Art/CharacterCreate/CharacterCreate_faceIcon_up.dds",
        tabPressed = "EsoUI/Art/CharacterCreate/CharacterCreate_faceIcon_down.dds",
        tabMouseOver = "EsoUI/Art/CharacterCreate/CharacterCreate_faceIcon_over.dds",
        nextTab = CREATE_BUCKET_RACE,
        previousTab = CREATE_BUCKET_BODY,
        onExpandFn = function() SetCharacterCameraZoomAmount(1) end,
        subCategoryData =
        {
            { id = SLIDER_SUBCAT_FACE_TYPE, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_VOICE, anchorYOffsetOverride = -42, },
            { id = SLIDER_SUBCAT_FACE_HAIR, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_FEATURES, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_FACE, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_EYES, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_BROW, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_NOSE, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_MOUTH, anchorYOffsetOverride = SUBCATEGORY_PAD, },
            { id = SLIDER_SUBCAT_FACE_EARS, anchorYOffsetOverride = SUBCATEGORY_PAD, },
        },
    },
}
local SLIDER_CATEGORY_TO_CREATE_BUCKET =
{
    [SLIDER_CATEGORY_AGE] = CREATE_BUCKET_BODY,
    [SLIDER_CATEGORY_BODY] = CREATE_BUCKET_BODY,
    [SLIDER_CATEGORY_FACE] = CREATE_BUCKET_FACE,
}
local APPEARANCE_NAME_TO_CREATE_BUCKET =
{
    [APPEARANCE_NAME_HAIR_STYLE] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_HAIR_TINT] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_SKIN_TINT] = CREATE_BUCKET_BODY,
    [APPEARANCE_NAME_ACCESSORY] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_HEAD_MARKING] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_BODY_MARKING] = CREATE_BUCKET_BODY,
    [APPEARANCE_NAME_EYE_TINT] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_AGE] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_EYEBROW] = CREATE_BUCKET_FACE,
    [APPEARANCE_NAME_VOICE] = CREATE_BUCKET_FACE,
}
local SUBCATEGORY_FOR_SLIDER =
{
    [SLIDER_NAME_FOREHEAD_SLOPE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_CHEEK_BONE_SIZE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_CHEEK_BONE_HEIGHT] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_CHIN_HEIGHT] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_CHIN_SIZE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_JAW_SIZE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_NECK_SIZE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_TOOTH_SIZE] = SLIDER_SUBCAT_FACE_FACE,
    [SLIDER_NAME_NOSE_SHAPE] = SLIDER_SUBCAT_FACE_NOSE,
    [SLIDER_NAME_NOSE_LENGTH] = SLIDER_SUBCAT_FACE_NOSE,
    [SLIDER_NAME_NOSE_HEIGHT] = SLIDER_SUBCAT_FACE_NOSE,
    [SLIDER_NAME_NOSE_WIDTH] = SLIDER_SUBCAT_FACE_NOSE,
    [SLIDER_NAME_EYE_HEIGHT] = SLIDER_SUBCAT_FACE_EYES,
    [SLIDER_NAME_EYE_SIZE] = SLIDER_SUBCAT_FACE_EYES,
    [SLIDER_NAME_EYE_SEPARATION] = SLIDER_SUBCAT_FACE_EYES,
    [SLIDER_NAME_EYE_ANGLE] = SLIDER_SUBCAT_FACE_EYES,
    [SLIDER_NAME_EYE_SQUINT] = SLIDER_SUBCAT_FACE_EYES,
    [SLIDER_NAME_MOUTH_HEIGHT] = SLIDER_SUBCAT_FACE_MOUTH,
    [SLIDER_NAME_MOUTH_WIDTH] = SLIDER_SUBCAT_FACE_MOUTH,
    [SLIDER_NAME_LIP_FULLNESS] = SLIDER_SUBCAT_FACE_MOUTH,
    [SLIDER_NAME_MOUTH_CURVE] = SLIDER_SUBCAT_FACE_MOUTH,
    [SLIDER_NAME_EAR_HEIGHT] = SLIDER_SUBCAT_FACE_EARS,
    [SLIDER_NAME_EAR_SIZE] = SLIDER_SUBCAT_FACE_EARS,
    [SLIDER_NAME_EAR_TIP_FLARE] = SLIDER_SUBCAT_FACE_EARS,
    [SLIDER_NAME_EAR_ROTATION] = SLIDER_SUBCAT_FACE_EARS,
    [SLIDER_NAME_EYEBROW_HEIGHT] = SLIDER_SUBCAT_FACE_BROW,
    [SLIDER_NAME_EYEBROW_ANGLE] = SLIDER_SUBCAT_FACE_BROW,
    [SLIDER_NAME_EYEBROW_SKEW] = SLIDER_SUBCAT_FACE_BROW,
    [SLIDER_NAME_EYEBROW_DEPTH] = SLIDER_SUBCAT_FACE_BROW,
    [SLIDER_NAME_LEG_SIZE] = SLIDER_SUBCAT_BODY_LOWER,
    [SLIDER_NAME_HIP_SIZE] = SLIDER_SUBCAT_BODY_LOWER,
    
    [SLIDER_NAME_FOOT_SIZE] = SLIDER_SUBCAT_BODY_LOWER,
    [SLIDER_NAME_BUTTOCKS_SIZE] = SLIDER_SUBCAT_BODY_LOWER,
    [SLIDER_NAME_TAIL_SIZE] = SLIDER_SUBCAT_BODY_LOWER,
    [SLIDER_NAME_TORSO_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_HAND_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_GUT_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_ARM_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_CHEST_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_WAIST_SIZE] = SLIDER_SUBCAT_BODY_UPPER,
    [SLIDER_NAME_CHARACTER_HEIGHT] = SLIDER_SUBCAT_BODY_TYPE,
}
local SUBCATEGORY_FOR_APPEARANCE =
{
    [APPEARANCE_NAME_HAIR_STYLE] = SLIDER_SUBCAT_FACE_HAIR,
    [APPEARANCE_NAME_HAIR_TINT] = SLIDER_SUBCAT_FACE_HAIR,
    [APPEARANCE_NAME_ACCESSORY] = SLIDER_SUBCAT_FACE_FEATURES,
    [APPEARANCE_NAME_HEAD_MARKING] = SLIDER_SUBCAT_FACE_FEATURES,
    [APPEARANCE_NAME_AGE] = SLIDER_SUBCAT_FACE_FEATURES,
    [APPEARANCE_NAME_BODY_MARKING] = SLIDER_SUBCAT_BODY_FEATURES,
    [APPEARANCE_NAME_SKIN_TINT] = SLIDER_SUBCAT_BODY_FEATURES,
    [APPEARANCE_NAME_EYE_TINT] = SLIDER_SUBCAT_FACE_EYES,    
    [APPEARANCE_NAME_EYEBROW] = SLIDER_SUBCAT_FACE_BROW,
    [APPEARANCE_NAME_VOICE] = SLIDER_SUBCAT_VOICE,
}
-- This table defines how sliders should be ordered within their sub-categories.
-- It's not needed for sub-categories where all the controls are added manually,
-- but when sliders are added in loops (like characterSlider and appearanceSlider)
-- this is used to assist building the ordering table which will be passed over
-- to actually add the sliders.
local CONTROL_ORDERING =
{
    [SLIDER_SUBCAT_BODY_FEATURES] =
    {
        APPEARANCE_NAME_SKIN_TINT,
        APPEARANCE_NAME_BODY_MARKING,
        SLIDER_NAME_CHARACTER_HEIGHT,
    },
    [SLIDER_SUBCAT_BODY_UPPER] =
    {
        SLIDER_NAME_TORSO_SIZE,
        SLIDER_NAME_CHEST_SIZE,
        SLIDER_NAME_GUT_SIZE,
        SLIDER_NAME_WAIST_SIZE,
        SLIDER_NAME_ARM_SIZE, 
        SLIDER_NAME_HAND_SIZE,        
    },
    [SLIDER_SUBCAT_BODY_LOWER] =
    {
        SLIDER_NAME_TAIL_SIZE,
        SLIDER_NAME_HIP_SIZE,
        SLIDER_NAME_BUTTOCKS_SIZE,
        SLIDER_NAME_LEG_SIZE,
        SLIDER_NAME_FOOT_SIZE,        
    },
    [SLIDER_SUBCAT_VOICE] =
    {
        APPEARANCE_NAME_VOICE,
    },
    [SLIDER_SUBCAT_FACE_HAIR] =
    {
        APPEARANCE_NAME_HAIR_STYLE,
        APPEARANCE_NAME_HAIR_TINT,
    },
    [SLIDER_SUBCAT_FACE_FEATURES] =
    {
        APPEARANCE_NAME_AGE,
        APPEARANCE_NAME_ACCESSORY,
        APPEARANCE_NAME_HEAD_MARKING,
    },
    [SLIDER_SUBCAT_FACE_FACE] =
    {
        SLIDER_NAME_FOREHEAD_SLOPE,
        SLIDER_NAME_CHEEK_BONE_SIZE,
        SLIDER_NAME_CHEEK_BONE_HEIGHT,
        SLIDER_NAME_JAW_SIZE,
        SLIDER_NAME_CHIN_SIZE,
        SLIDER_NAME_CHIN_HEIGHT,
        SLIDER_NAME_NECK_SIZE,
        SLIDER_NAME_TOOTH_SIZE,
    },
    [SLIDER_SUBCAT_FACE_EYES] =
    {
        APPEARANCE_NAME_EYE_TINT,
        SLIDER_NAME_EYE_SIZE,
        SLIDER_NAME_EYE_ANGLE,
        SLIDER_NAME_EYE_SEPARATION,
        SLIDER_NAME_EYE_HEIGHT,        
        SLIDER_NAME_EYE_SQUINT,
    },
    [SLIDER_SUBCAT_FACE_BROW] =
    {
        APPEARANCE_NAME_EYEBROW,
        SLIDER_NAME_EYEBROW_HEIGHT,
        SLIDER_NAME_EYEBROW_ANGLE,
        SLIDER_NAME_EYEBROW_SKEW,
        SLIDER_NAME_EYEBROW_DEPTH,
    },
    [SLIDER_SUBCAT_FACE_NOSE] =
    {
        SLIDER_NAME_NOSE_SHAPE,
        SLIDER_NAME_NOSE_HEIGHT,
        SLIDER_NAME_NOSE_WIDTH,
        SLIDER_NAME_NOSE_LENGTH,
    },
    [SLIDER_SUBCAT_FACE_MOUTH] =
    {
        SLIDER_NAME_MOUTH_HEIGHT,
        SLIDER_NAME_MOUTH_WIDTH,
        SLIDER_NAME_MOUTH_CURVE,
        SLIDER_NAME_LIP_FULLNESS,        
    },
    [SLIDER_SUBCAT_FACE_EARS] =
    {
        SLIDER_NAME_EAR_SIZE,
        SLIDER_NAME_EAR_ROTATION,
        SLIDER_NAME_EAR_HEIGHT,        
        SLIDER_NAME_EAR_TIP_FLARE,        
    },
}
local function CreateTabControl(parent, windowData)
    local tabControl = CreateControlFromVirtual(windowData.windowName.."Tab", parent, "CCCategoryTab")
    tabControl:SetNormalTexture(windowData.tabNormal)
    tabControl:SetMouseOverTexture(windowData.tabMouseOver)
    tabControl:SetPressedTexture(windowData.tabPressed)
    tabControl.m_windowData = windowData
    return tabControl
end
--[[ Character Creation Bucket Instances ]]--
local CharacterCreateBucket = ZO_CharacterCreateBucket:Subclass()
function CharacterCreateBucket:New(parent, bucketCategory)
    local ccBucket = ZO_CharacterCreateBucket.New(self, parent, bucketCategory)
    local windowData = CREATE_BUCKET_WINDOW_DATA[bucketCategory]
    local container = CreateControlFromVirtual(windowData.windowName, parent, "CCCategoryBucket")
    local tabControl = CreateTabControl(parent, windowData)
    tabControl.m_bucket = ccBucket
    container.m_bucket = ccBucket
    ccBucket.m_windowData = windowData
    ccBucket.m_container = container
    ccBucket.m_tab = tabControl
    ccBucket.m_scrollChild = GetControl(container, "PaneScrollChild")
    ccBucket.m_subcategoryContainers = {}
    -- Create a spacer control to keep the contents of the scroll panel centered
    -- since scrolling operates by setting the topleft anchor of the scrollChild
    -- window.
    local widthSpacer = ccBucket.m_scrollChild:CreateControl("$(parent)WidthSpacer", CT_CONTROL)
    widthSpacer:SetWidth(360)
    widthSpacer:SetAnchor(TOP)
    -- Create another spacer to pad out the bottom so that the full contents of the pane
    -- can be scrolled into view. This will need to be reanchored to each control that gets
    -- added to the bucket.
    ccBucket.m_viewSpacer = ccBucket.m_scrollChild:CreateControl("$(parent)ViewSpacer", CT_CONTROL)
    ccBucket.m_viewSpacer:SetDimensions(360, 10)
    return ccBucket
end
function CharacterCreateBucket:GetTab()
    return self.m_tab
end
local BucketSubCategory = ZO_Object:Subclass()
function BucketSubCategory:New(bucketWindowData, subCategoryData, parent)
    local subCategory = ZO_Object.New(self)
    local subCategoryWindowName = string.format("%sSub%d", bucketWindowData.windowName, subCategoryData.id)
    local subCategoryControl = CreateControlFromVirtual(subCategoryWindowName, parent, "CCSubCategory")
    subCategory.m_control = subCategoryControl
    GetControl(subCategoryControl, "Name"):SetText(GetString("SI_CHARACTERSLIDERSUBCATEGORY", subCategoryData.id))
    return subCategory
end
function BucketSubCategory:GetControl()
    return self.m_control
end
function BucketSubCategory:AddControl(control)
    if(self.m_lastAnchored) then
        control:SetAnchor(TOP, self.m_lastAnchored, BOTTOM, 0, 20)
    else
        control:SetAnchor(TOP, GetControl(self.m_control, "TopSpacer"), BOTTOM)
    end 
        
    self.m_lastAnchored = control
end
function BucketSubCategory:Reset()
    self.m_lastAnchored = nil
end
function BucketSubCategory:IsEmpty()
    return self.m_lastAnchored == nil
end
function CharacterCreateBucket:AddSubCategories()
    local windowData = self.m_windowData
    if(windowData.subCategoryData) then
        if(not self.m_subCategories) then
            self.m_subCategories = {}
        end
        for subCatIndex, subCatData in ipairs(windowData.subCategoryData) do
            local subCategoryObj = self.m_subCategories[subCatData.id]
            if(not subCategoryObj) then
                subCategoryObj = BucketSubCategory:New(windowData, subCatData, self:GetScrollChild())
                self.m_subCategories[subCatData.id] = subCategoryObj
            end
            local subCategoryContainer = subCategoryObj:GetControl()
            subCategoryContainer:SetHidden(false)
            table.insert(self.m_subcategoryContainers, subCategoryContainer)
            self:AddControl(subCategoryContainer, nil, nil, nil, subCatData.anchorYOffsetOverride)
        end
    end
end
function CharacterCreateBucket:RemoveUnusedSubCategories()
    local windowData = self.m_windowData
    if(windowData.subCategoryData and self.m_subCategories) then
        for subCatIndex, subCatData in ipairs(windowData.subCategoryData) do
            local subCategoryObj = self.m_subCategories[subCatData.id]
            if(subCategoryObj and subCategoryObj:IsEmpty()) then
                local subCategoryContainer = subCategoryObj:GetControl()
                -- Grab the subcategory after this one and anchor it to the current
                local nextSubCatControl = self.m_subcategoryContainers[subCatIndex + 1]
                if(nextSubCatControl) then
                    local valid, point, relTo, relPoint, offsX, offsY = subCategoryContainer:GetAnchor(0)
                    if(valid) then
                        nextSubCatControl:ClearAnchors()
                        nextSubCatControl:SetAnchor(point, relTo, relPoint, offsX, offsY)
                    end
                end
                
                subCategoryContainer:SetHidden(true)
                subCategoryContainer:ClearAnchors()
                subCategoryContainer:SetAnchor(TOP, self:GetScrollChild(), TOP, 0, 0)
            end
        end
    end
end
function CharacterCreateBucket:AddControl(control, updateFn, randomizeFn, subCategoryId, anchorYOffsetOverride)
    control.m_bucket = self
    control:SetHidden(false)
    if(subCategoryId and self.m_subCategories and self.m_subCategories[subCategoryId]) then
        self.m_subCategories[subCategoryId]:AddControl(control)
    else
        control:SetParent(self:GetScrollChild())
        anchorYOffsetOverride = anchorYOffsetOverride or 0
        if(self.m_lastAnchored) then
            control:SetAnchor(TOP, self.m_lastAnchored, BOTTOM, 0, 20 + anchorYOffsetOverride)
        else
            -- using a little vertical padding so controls with backdrops don't overlap at the top
            -- NOTE: Do not use override here, if it were negative it could easily push this control out of the window
            control:SetAnchor(TOP, self:GetScrollChild(), TOP, 0, 5)
        end
        self.m_lastAnchored = control
        self.m_viewSpacer:ClearAnchors()
        self.m_viewSpacer:SetAnchor(TOP, self.m_lastAnchored, BOTTOM, 0, 0)
    end
    self.m_controlData[control] = { updateFn = updateFn, randomizeFn = randomizeFn }
end
function CharacterCreateBucket:RemoveControl(control)
    -- Once a control is removed from a bucket it's no longer safe to add controls
    -- unless the bucket is totally reset (this is because of how m_lastAnchored works)
    -- This just cleans up the control and removes any lingering update handlers
    -- All the controls will be re-added to the bucket at some point.
    self.m_lastAnchored = nil
    control.m_bucket = nil
    self.m_controlData[control] = nil
end
function CharacterCreateBucket:Reset()
    self.m_expanded = false
    self.m_controlData = {}
    self.m_lastAnchored = nil
    self.m_subcategoryContainers = {}
    if(self.m_subCategories) then
        for _, subCategoryObj in pairs(self.m_subCategories) do
            subCategoryObj:Reset()
        end
    end
end
function CharacterCreateBucket:Expand()
    local container = self:GetContainer()
    container:SetHidden(false)
    self:GetTab():SetState(BSTATE_PRESSED, true)
    self.m_expanded = true
    
    local expandFn = self.m_windowData.onExpandFn
    if(expandFn) then
        expandFn()
    end
end
function CharacterCreateBucket:Collapse()
    self:GetContainer():SetHidden(true)
    self:GetTab():SetState(BSTATE_NORMAL, false)
    self.m_expanded = false
    local collapseFn = self.m_windowData.onCollapseFn
    if(collapseFn) then
        collapseFn()
    end
end
function CharacterCreateBucket:IsExpanded()
    return self.m_expanded
end
function CharacterCreateBucket:MouseEnter()
    InitializeTooltip(InformationTooltip, self:GetTab(), TOPRIGHT, 0, 0, TOPLEFT)
    SetTooltipText(InformationTooltip, self.m_windowData.title)
end
function CharacterCreateBucket:MouseExit()
    ClearTooltip(InformationTooltip)
end
--[[ Character Create Manager ]]--
local CharacterCreateManager = ZO_CharacterCreateManager:Subclass()
function CharacterCreateManager:New(characterData)
    local object = ZO_CharacterCreateManager.New(self, characterData)
    return object
end
--[[ Character Creation Bucket Manager ]]--
local g_bucketManager
local CharacterCreateBucketManager = ZO_CharacterCreateBucketManager:Subclass()
function CharacterCreateBucketManager:New(container)
    local mgr = ZO_CharacterCreateBucketManager.New(self, container)
    mgr:Initialize()
    return mgr
end
function CharacterCreateBucketManager:Initialize()
    for i = 1,NUM_CREATE_BUCKETS do
        if CREATE_BUCKET_WINDOW_DATA[i] then
            self:AddBucket(i)
        end
    end
end
function CharacterCreateBucketManager:AddBucket(bucketCategory)
    local bucket = CharacterCreateBucket:New(self.m_container, bucketCategory)
    local bucketContainer = bucket:GetContainer()
    bucketContainer:SetAnchor(TOPLEFT, ZO_CharacterCreateBuckets, TOPLEFT, 13, 138)
    bucketContainer:SetAnchor(BOTTOMRIGHT, ZO_CharacterCreateBuckets, BOTTOMRIGHT, -14, -73)
    self.m_buckets[bucketCategory] = bucket
    local tabControl = bucket:GetTab()
    if(self.m_lastAnchoredTab) then
        tabControl:SetAnchor(TOPLEFT, self.m_lastAnchoredTab, TOPRIGHT, 12, 0)
    else
        tabControl:SetAnchor(TOPLEFT, self.m_container, TOPLEFT, 62, 20)
    end
    self.m_lastAnchoredTab = tabControl
end
function CharacterCreateBucketManager:SwitchBuckets(tabButtonOrCategory)
    -- collapse current bucket
    if(self.m_currentBucket) then
        self.m_currentBucket:Collapse()
    end
    -- expand desired bucket
    local bucket
    if(type(tabButtonOrCategory) == "number") then
        bucket = self:BucketForCategory(tabButtonOrCategory)
    else
        bucket = self:BucketForChildControl(tabButtonOrCategory)
    end
    if(bucket) then
        bucket:Expand()
        self.m_currentBucket = bucket
    end
end
function CharacterCreateBucketManager:GetCurrentTab()
    if(self.m_currentBucket) then
        return self.m_currentBucket:GetTab()
    end
end
function CharacterCreateBucketManager:EnableBucketTab(bucketCategory, enabled)
    local bucket = self.m_buckets[bucketCategory]
    local tabControl = bucket:GetTab()
    local saturation = 1
    if(enabled) then
        saturation = 0
    end
    tabControl:SetEnabled(enabled)
    tabControl:SetDesaturation(saturation)
end
function CharacterCreateBucketManager:MouseOverBucket(bucketTab)
    self:BucketForChildControl(bucketTab):MouseEnter()
end
function CharacterCreateBucketManager:MouseExitBucket(bucketTab)
    self:BucketForChildControl(bucketTab):MouseExit()
end
function CharacterCreateBucketManager:AddSubCategories()
    for _, bucket in pairs(self.m_buckets) do
        bucket:AddSubCategories()
    end
end
function CharacterCreateBucketManager:RemoveUnusedSubCategories()
    for _, bucket in pairs(self.m_buckets) do
        bucket:RemoveUnusedSubCategories()
    end
end
--[[ Slider Randomization Helper...all sliders share the m_sliderObject from the top control, so this just helps cut down on duplicate functions ]]--
local function RandomizeSlider(control, randomizeType)
    control.m_sliderObject:Randomize(randomizeType)
end
--[[ Character Create Slider ]]--
-- To use this, create a CCSlider, its OnInitialize handler will create this object and wire everything up.
-- Those controls are intended to be used from a pool, and after acquiring those controls from the pool
-- the caller will use CharacterCreateSlider:SetData to set up that specific instance.
local CharacterCreateSlider = ZO_CharacterCreateSlider:Subclass()
function CharacterCreateSlider:New(control)
    local slider = ZO_CharacterCreateSlider.New(self, control)
    slider.m_decrementButton = GetControl(control, "Decrement")
    slider.m_incrementButton = GetControl(control, "Increment")
    return slider
end
--[[ Character Create Appearance Slider ]]--
-- Similar construction details to the CharacterCreateSlider. Make the appropriate ui control from a template (color picker, icon picker, etc...)
-- and it will wire all the fields up.
local CharacterCreateAppearanceSlider = CharacterCreateSlider:Subclass()
function CharacterCreateAppearanceSlider:New(control)
    local slider = CharacterCreateSlider.New(self, control)
    zo_mixin(slider, ZO_CharacterCreateAppearanceSlider)
    return slider
end
--[[ Character Create Color Slider ]]--
-- Similar construction details to the CharacterCreateSlider. Make the appropriate ui control from a template (color picker, icon picker, etc...)
-- and it will wire all the fields up. The one main difference is that this comes from a common utility class, so it needs a little extra
-- for wiring up the subsystems. The internal object and control will be a ZO_ColorSwatchPicker, but this will wrap that in an interface
-- that makes it look like a CharCreate*Slider object.
local CharacterCreateColorSlider = CharacterCreateSlider:Subclass()
function CharacterCreateColorSlider:New(control)
    local slider = CharacterCreateSlider.New(self, control)
    local function OnClickedCallback(paletteIndex)
        SetAppearanceValue(slider.m_category, paletteIndex)
    end
    return slider
end
function CharacterCreateColorSlider:SetData(appearanceName, numValues, displayName)
    self.m_category = appearanceName
    self.m_numSteps = numValues
    self:SetName(displayName, "SI_CHARACTERAPPEARANCENAME", appearanceName)
    self.m_legalInitialSettings = {}
    for paletteIndex =  1, numValues do
        local r, g, b, legalInitialSetting = GetAppearanceValueInfo(appearanceName, paletteIndex)
        ZO_ColorSwatchPicker_AddColor(self.m_slider, paletteIndex, r, g, b)
        if(legalInitialSetting) then
            table.insert(self.m_legalInitialSettings, paletteIndex)
        end
    end
    self:Update()
end
function CharacterCreateColorSlider:Randomize(randomizeType)
    if(self.m_lockState == TOGGLE_BUTTON_OPEN) then
        local randomValue = 1
        if((randomizeType == "initial") and (#self.m_legalInitialSettings > 0)) then
            -- If this is the initial randomization and we have some legal initial values
            -- then only randomize over those values
            randomValue = self.m_legalInitialSettings[zo_random(1, #self.m_legalInitialSettings)]            
        else
            -- Otherwise, pick a random value from the valid values
            local maxValue = self.m_numSteps
            if(maxValue > 0) then
                randomValue = zo_random(1, maxValue)
            end
        end
        SetAppearanceValue(self.m_category, randomValue)
        self:Update()
    end
end
function CharacterCreateColorSlider:UpdateLockState()
    ZO_ColorSwatchPicker_SetEnabled(self.m_slider, self.m_lockState == TOGGLE_BUTTON_OPEN)
end
function CharacterCreateColorSlider:Update()
end
--[[ Character Create Dropdown Slider ]]--
-- Similar interface to the CharacterCreateSlider, completely different internals.
-- The drop down is used to choose named appearance types.
local CharacterCreateDropdownSlider = ZO_Object:Subclass()
function CharacterCreateDropdownSlider:New(control)
    local slider = ZO_Object.New(self)
    control.m_sliderObject = slider
    slider.m_control = control
    slider.m_padlock = GetControl(control, "Padlock")
    slider.m_lockState = TOGGLE_BUTTON_OPEN
    slider.m_dropdown = ZO_ComboBox_ObjectFromContainer(control:GetNamedChild("Dropdown"))
    slider.m_dropdown:SetSortsItems(false)
    slider.m_dropdown:SetFont("ZoFontGame")
    slider.m_dropdown:SetSpacing(4)
    
    return slider
end
function CharacterCreateDropdownSlider:SetName(displayName, enumNameFallback, enumValue)
    -- nothing to do for now, the only dropdown in use has its own section
end
-- Terrible first implementation
local voiceIdToNameId =
{
    SI_CREATE_CHARACTER_VOICE_A,
    SI_CREATE_CHARACTER_VOICE_B,
    SI_CREATE_CHARACTER_VOICE_C,
    SI_CREATE_CHARACTER_VOICE_D,
    SI_CREATE_CHARACTER_VOICE_E,
    SI_CREATE_CHARACTER_VOICE_F,
    SI_CREATE_CHARACTER_VOICE_G,
    SI_CREATE_CHARACTER_VOICE_H,
}
local function GetAppearanceItemName(appearanceName, value)
    local nameId = voiceIdToNameId[value]
    if(nameId) then
        return GetString(nameId)
    end
    return GetString(SI_CREATE_CHARACTER_VOICE_A)
end
function CharacterCreateDropdownSlider:SetData(appearanceName, numValues, displayName)
    self.m_category = appearanceName
    self.m_numSteps = numValues
    self:SetName(displayName, "SI_CHARACTERAPPEARANCENAME", appearanceName)
    self.m_legalInitialSettings = {}
    self.m_dropdown:ClearItems()
    local function OnAppearanceItemSelected(dropdown, itemName, entry)
        SetAppearanceValue(self.m_category, entry.value)
        self:Update()
    end
    for valueIndex = 1, numValues do
        local _, _, _, legalInitialSetting = GetAppearanceValueInfo(appearanceName, valueIndex)
        local itemName = GetAppearanceItemName(appearanceName, valueIndex)
        local entry = self.m_dropdown:CreateItemEntry(itemName, OnAppearanceItemSelected)
        entry.value = valueIndex
        self.m_dropdown:AddItem(entry)
        if(legalInitialSetting) then
            table.insert(self.m_legalInitialSettings, valueIndex)
        end
    end
    self:Update()
end
function CharacterCreateDropdownSlider:Randomize(randomizeType)
    if(self.m_lockState == TOGGLE_BUTTON_OPEN) then
        local randomValue = 1
        if((randomizeType == "initial") and (#self.m_legalInitialSettings > 0)) then
            -- If this is the initial randomization and we have some legal initial values
            -- then only randomize over those values
            randomValue = self.m_legalInitialSettings[zo_random(1, #self.m_legalInitialSettings)]            
        else
            -- Otherwise, pick a random value from the valid values
            local maxValue = self.m_numSteps
            if(maxValue > 0) then
                randomValue = zo_random(1, maxValue)
            end
        end
        SetAppearanceValue(self.m_category, randomValue)
        self:Update()
    end
end
function CharacterCreateDropdownSlider:ToggleLocked()
    self.m_lockState = not self.m_lockState
    ZO_ToggleButton_SetState(self.m_padlock, self.m_lockState)
end
function CharacterCreateDropdownSlider:UpdateLockState()
    self.m_dropdown:SetEnabled(self.m_lockState == TOGGLE_BUTTON_OPEN)
end
function CharacterCreateDropdownSlider:Update()
    local appearanceValue = GetAppearanceValue(self.m_category)
    local function SelectAppropriateAppearance(index, entry)
        if(entry.value == appearanceValue) then
            self.m_dropdown:SetSelectedItem(entry.name)
            return true
        end
    end
end
function CharacterCreateDropdownSlider:Preview()
    PreviewAppearanceValue(self.m_category)
end
--[[ Character Create Slider and Appearance Slider Managers ]]--
-- Manages a collection of sliders with a pool
local CharacterCreateSliderManager = ZO_Object:Subclass()
local g_sliderManager
function CharacterCreateSliderManager:New(parent)
    local manager = ZO_Object.New(self)
    local CreateSlider = function(pool) return ZO_ObjectPool_CreateNamedControl("CharacterCreateSlider", "CCSlider", pool, parent) end
    local CreateAppearanceSlider = function(pool) return ZO_ObjectPool_CreateNamedControl("CharacterCreateAppearanceSlider", "CCAppearanceSlider", pool, parent) end
    local CreateColorPicker = function(pool) return ZO_ObjectPool_CreateNamedControl("CharacterCreateColorPicker", "CCColorSlider", pool, parent) end
    local CreateDropdown = function(pool) return ZO_ObjectPool_CreateNamedControl("CharacterCreateDropdown", "CCDropDown", pool, parent) end
    local function ResetSlider(sliderControl)
        g_bucketManager:RemoveControl(sliderControl)
        sliderControl:SetHidden(true)
    end
    local function ResetColorPicker(sliderControl)
        g_bucketManager:RemoveControl(sliderControl)
        ZO_ColorSwatchPicker_Clear(GetControl(sliderControl, "Slider"))
        sliderControl:SetHidden(true)
    end
    manager.m_pools =
    {
        ["slider"] = ZO_ObjectPool:New(CreateSlider, ResetSlider),
        ["icon"] = ZO_ObjectPool:New(CreateAppearanceSlider, ResetSlider),
        ["color"] = ZO_ObjectPool:New(CreateColorPicker, ResetColorPicker),
        ["named"] = ZO_ObjectPool:New(CreateDropdown, ResetSlider),
    }
    return manager
end
function CharacterCreateSliderManager:AcquireObject(objectType)
    local pool = self.m_pools[objectType]
    if(pool) then
        return pool:AcquireObject()
    end
end
function CharacterCreateSliderManager:ReleaseAllObjects()
    for poolType, pool in pairs(self.m_pools) do
        pool:ReleaseAllObjects()
    end
end
--[[ Character Creation Triangle ]]--
-- Character Creation Triangle control. This is shared across gamepad and keyboard files
-- And uses a common subclass
local CharacterCreateTriangle = ZO_CharacterCreateTriangle:Subclass()
function CharacterCreateTriangle:New(triangleControl, setterFn, updaterFn, triangleStringId, topStringId, leftStringId, rightStringId)
    local triangle = ZO_CharacterCreateTriangle.New(self, triangleControl, setterFn, updaterFn, triangleStringId, topStringId, leftStringId, rightStringId)
    return triangle
end
function CharacterCreateTriangle:UpdateLockState()
    local enabled = self.m_lockState == TOGGLE_BUTTON_OPEN
    self.m_picker:SetEnabled(enabled)
    GetControl(self.m_thumb, "Glow"):SetHidden(not enabled)
    if(enabled) then
        GetControl(self.m_control, "BG"):SetTexture("EsoUI/Art/CharacterCreate/selectorTriangle.dds")
    else
        GetControl(self.m_control, "BG"):SetTexture("EsoUI/Art/CharacterCreate/selectorTriangle_disabled.dds")
    end
end
--[[ Character Creation CurrentData ]]--
-- The important stuff, data describing all the valid options you can choose from
local g_characterData
--[[ Creator Control Initialization ]]--
local g_characterStartLocation
local characterCreateTemplateRefCount = 0
local function GetCurrentAllianceData()
    local selectedAlliance = CharacterCreateGetAlliance()
    local alliance = g_characterData:GetAllianceForAllianceDef(selectedAlliance)
    if(alliance) then
        return alliance.name, alliance.backdropTop, alliance.backdropBottom
    end
    return "", "", ""
end
local function UpdateGenderSpecificText(currentGender)
    currentGender = currentGender or CharacterCreateGetGender()
    ZO_CharacterCreateRaceName:SetText(zo_strformat(SI_RACE_NAME, GetRaceName(currentGender, CharacterCreateGetRace())))
    ZO_CharacterCreateClassSelectionName:SetText(zo_strformat(SI_CLASS_NAME, GetClassName(currentGender, CharacterCreateGetClass())))
end
local function UpdateRaceControl()
    local currentRace = CharacterCreateGetRace()
    local function IsRaceClicked(button)
        return button.defId == currentRace
    end
    
    g_raceRadioGroup:UpdateFromData(IsRaceClicked)
    local currentAlliance = CharacterCreateGetAlliance()
    local function IsAllianceClicked(button)
        return button.defId == currentAlliance
    end
    g_allianceRadioGroup:UpdateFromData(IsAllianceClicked)
    local race = g_characterData:GetRaceForRaceDef(currentRace)
    if(race) then
        local allianceName, backdropTop, backdropBottom = GetCurrentAllianceData()
        UpdateGenderSpecificText()
        ZO_CharacterCreateRaceAlliance:SetText(zo_strformat(SI_ALLIANCE_NAME, allianceName))
        ZO_CharacterCreateRaceDescription:SetText(race.lore)
        ZO_CharacterCreateRaceAllianceBG:SetTexture(backdropTop)
        ZO_CharacterCreateRaceAllianceBGBottom:SetTexture(backdropBottom)
    end
end
local function UpdateGenderControl()
    local currentGender = CharacterCreateGetGender()
    local function IsGenderClicked(button)
        return button.gender == currentGender
    end
    
    g_genderRadioGroup:UpdateFromData(IsGenderClicked)
end
local function UpdateClassControl()
    local currentClass = CharacterCreateGetClass()
    local function IsClassClicked(button)
        return button.defId == currentClass
    end
    g_classRadioGroup:UpdateFromData(IsClassClicked)
    local class = g_characterData:GetClassForClassDef(currentClass)
    if(class) then
        UpdateGenderSpecificText()
        ZO_CharacterCreateClassSelectionDescription:SetText(class.lore)
    end
end
local function UpdateSlider(slider)
    slider.m_sliderObject:Update()
end
local function FindOrdering(orderingTable, name)
    for i = 1, #orderingTable do
        if(orderingTable[i] == name) then
            return i
        end
    end
    return 1
end
local function SliderComparator(data1, data2)
    local name1 = data1.name
    local name2 = data2.name
    local subCat1 = data1.subCat
    local subCat2 = data2.subCat
    if(subCat1 ~= subCat2) then
        return subCat1 < subCat2
    end
    return FindOrdering(CONTROL_ORDERING[subCat1], name1) < FindOrdering(CONTROL_ORDERING[subCat2], name2)
end
function CharacterCreateManager:InitializeControls()
    -- If this was being suppressed changes MUST be applied now or there will be no slider data to build
    g_sliderManager:ReleaseAllObjects()
    g_bucketManager:Reset()
    g_bucketManager:AddSubCategories()
    g_bucketManager:AddControl(ZO_CharacterCreateGenderSelection, CREATE_BUCKET_RACE, UpdateGenderControl)
    g_bucketManager:AddControl(ZO_CharacterCreateRace, CREATE_BUCKET_RACE, UpdateRaceControl)    
    g_bucketManager:AddControl(ZO_CharacterCreateClassSelection, CREATE_BUCKET_CLASS, UpdateClassControl)
    g_bucketManager:AddControl(ZO_CharacterCreatePhysiqueSelection, CREATE_BUCKET_BODY, UpdateSlider, RandomizeSlider, SLIDER_SUBCAT_BODY_TYPE)
    g_bucketManager:AddControl(ZO_CharacterCreateFaceSelection, CREATE_BUCKET_FACE, UpdateSlider, RandomizeSlider, SLIDER_SUBCAT_FACE_TYPE)
    -- TODO: this fixes a bug where the triangles don't reflect the correct data...there will be more fixes to pregameCharacterManager to address the real issue
    -- (where the triangle data needs to live on its own rather than being tied to the unit)
    UpdateSlider(ZO_CharacterCreatePhysiqueSelection)
    UpdateSlider(ZO_CharacterCreateFaceSelection)
    local sliderData = {}
    for i = 1, GetNumSliders() do
        local name, category, steps, value, defaultValue = GetSliderInfo(i)
        if(name) then
            local sliderControl = g_sliderManager:AcquireObject("slider")
            sliderControl.m_sliderObject:SetData(i, name, category, steps, value, defaultValue)
            local bucket = SLIDER_CATEGORY_TO_CREATE_BUCKET[category]
            local subCat = SUBCATEGORY_FOR_SLIDER[name]
            sliderData[#sliderData + 1] = { bucket = bucket, subCat = subCat, name = name, control = sliderControl, }
        end
    end
    for i = 1, GetNumAppearances() do
        local appearanceName, appearanceType, numValues, displayName = GetAppearanceInfo(i)
        if(numValues > 0) then
            local appearanceControl = g_sliderManager:AcquireObject(appearanceType)
            appearanceControl.m_sliderObject:SetData(appearanceName, numValues, displayName)
            
            local bucket = APPEARANCE_NAME_TO_CREATE_BUCKET[appearanceName]
            local subCat = SUBCATEGORY_FOR_APPEARANCE[appearanceName]
            
            sliderData[#sliderData + 1] = { bucket = bucket, subCat = subCat, name = appearanceName, control = appearanceControl, }
        end
    end
    table.sort(sliderData, SliderComparator)
    for _, orderingData in ipairs(sliderData) do
        g_bucketManager:AddControl(orderingData.control, orderingData.bucket, UpdateSlider, RandomizeSlider, orderingData.subCat)
    end
    g_bucketManager:RemoveUnusedSubCategories()
end
local function OnLogoutSuccessful()
    g_firstTimeInCharacterCreate = true
end
local function SetSelectorButtonEnabled(selectorButton, radioGroup, enabled)
    radioGroup:SetButtonIsValidOption(selectorButton, enabled)
    if(enabled) then
        selectorButton:SetDesaturation(0)
    else
        selectorButton:SetDesaturation(1)
    end
end
local function UpdateSelectorsForTemplate(isEnabledCallback, characterDataTable, templateData, radioGroup, optionalValidIndexTable)
    for dataIndex, data in ipairs(characterDataTable) do
        local enabled = isEnabledCallback(data, templateData)
        data.isRadioEnabled = enabled
        SetSelectorButtonEnabled(data.selectorButton, radioGroup, enabled)
        if(optionalValidIndexTable and enabled) then
            optionalValidIndexTable[#optionalValidIndexTable + 1] = dataIndex
        end
    end
end
local function PickRandomSelectableClass()
    -- UpdateSelectorsForTemplate() should be called prior to this function or unselectable classes might be set (which would result in no class being set).
    CharacterCreateSetClass(g_characterData:PickRandomClass())
end
local function PickRandomGender()
    CharacterCreateSetGender(g_characterData:PickRandomGender())
end
local function UpdateSelectedTemplateText(selectedText)
    if(not selectedText) then
        local templateData = g_characterData:GetTemplate(CharacterCreateGetTemplate())
        if(templateData) then
            selectedText = templateData.name
        end
    end
    if(selectedText) then
        ZO_CharacterCreateTemplateSelectedText:SetText(selectedText)
        ZO_CharacterCreateTemplateList:SetHidden(true)
        characterCreateTemplateRefCount = 0
    end
end
local function UpdateRaceSelectorsForTemplate(raceData, templateData)
    local enabled = raceData.isSelectable -- Only if the user is able to play the race in the first place do we even consider disabling it...
    if(enabled) then
        local templateRace = templateData.race
        local forcedRace = (templateRace ~= 0)
        if(forcedRace and templateRace ~= raceData.race) then
            enabled = false
        end
        if(not forcedRace) then
            local templateAlliance = templateData.alliance
            if(templateAlliance ~= 0) then
                if((templateAlliance ~= raceData.alliance) and not CanPlayAnyRaceAsAnyAlliance()) then
                    enabled = false
                end
            end
        end
        -- Exceptions to the rule, some races may still be enabled (Imperials is the only case now...)
        if(not forcedRace and raceData.alliance == ALLIANCE_NONE) then
            enabled = true
        end
    end 
    return enabled
end
local function UpdateClassSelectorsForTemplate(classData, templateData)
    return classData.isSelectable and ((templateData.class == 0) or (templateData.class == classData.class))
end
local function UpdateAllianceSelectorsForTemplate(allianceData, templateData)
    return allianceData.isSelectable and ((templateData.alliance == 0) or (templateData.alliance == allianceData.alliance))
end
local function SetTemplate(templateId)
    local templateData = g_characterData:GetTemplate(templateId)
    if(not templateData) then return false end
    UpdateSelectedTemplateText(templateData.name)
    if(not templateData.isSelectable or CharacterCreateGetTemplate() == templateId) then return false end
    CharacterCreateSetTemplate(templateId)
    g_bucketManager:SwitchBuckets(CREATE_BUCKET_RACE)
    -- Disable appearance related controls if the appearance is overridden in the template.
    local enabled = not templateData.overrideAppearance
    g_bucketManager:EnableBucketTab(CREATE_BUCKET_BODY, enabled)
    g_bucketManager:EnableBucketTab(CREATE_BUCKET_FACE, enabled)
    ZO_CharacterCreateRandomizeAppearance:SetEnabled(enabled)
    local validRaces = {}
    UpdateSelectorsForTemplate(UpdateRaceSelectorsForTemplate, g_characterData:GetRaceInfo(), templateData, g_raceRadioGroup, validRaces)
    UpdateSelectorsForTemplate(UpdateClassSelectorsForTemplate, g_characterData:GetClassInfo(), templateData, g_classRadioGroup)
    local validAlliances = {}
    g_characterData:UpdateAllianceSelectability()
    UpdateSelectorsForTemplate(UpdateAllianceSelectorsForTemplate, g_characterData:GetAllianceInfo(), templateData, g_allianceRadioGroup, validAlliances)
    g_genderRadioGroup:SetEnabled(templateData.gender == 0)
    
    -- Pick a race
    if(templateData.race ~= 0) then
        CharacterCreateSetRace(templateData.race)
    else     
        CharacterCreateSetRace(g_characterData:PickRandomRace(validRaces))
    end
    -- Pick an alliance
    if(templateData.alliance ~= 0) then
        CharacterCreateSetAlliance(templateData.alliance)
    else
        -- (never random unless a race without a fixed alliance is picked)
        local alliance = g_characterData:GetRaceForRaceDef(CharacterCreateGetRace()).alliance
        if(alliance ~= 0) then
            CharacterCreateSetAlliance(alliance)
        else
            CharacterCreateSetAlliance(g_characterData:PickRandomAlliance(validAlliances))
        end
    end
    -- Pick a class
    if(templateData.class ~= 0) then
        CharacterCreateSetClass(templateData.class)
    else
        PickRandomSelectableClass()
    end
    -- Pick a gender
    if(templateData.gender ~= 0) then
        CharacterCreateSetGender(templateData.gender)
    else
        PickRandomGender()
    end
    -- Make the controls match what you picked...
    g_manager:InitializeControls()
    if(not templateData.overrideAppearance) then
        ZO_CharacterCreate_RandomizeAppearance("initial")
    else
        InitializeAppearanceFromTemplate(templateId)
    end
    return true
end
local function GenerateRandomCharacter()
    if(g_firstTimeInCharacterCreate) then
        g_firstTimeInCharacterCreate = false
        CharacterCreateSetRace(g_characterData:PickRandomRace())
        CharacterCreateSetAlliance(g_characterData:PickRandomAlliance())
        CharacterCreateSetGender(g_characterData:PickRandomGender())
        CharacterCreateSetClass(g_characterData:PickRandomClass())
        g_manager:InitializeControls()
        ZO_CharacterCreate_RandomizeAppearance("initial")
        return true
    end
    return false
end
local function InitializeSelectorButton(buttonControl, data, radioGroup)
    if(data == nil) then return end
    buttonControl:SetHidden(false)
    buttonControl:SetNormalTexture(data.normalIcon)
    buttonControl:SetPressedTexture(data.pressedIcon)
    buttonControl:SetMouseOverTexture(data.mouseoverIcon)
    radioGroup:Add(buttonControl)
    SetSelectorButtonEnabled(buttonControl, radioGroup, data.isSelectable)
    -- There should be a single button that represents this piece of data
    -- So add the button control to the character data so that if it's needed
    -- later to update state, there are no insane hoops to jump through to get the button.
    -- For example, these buttons are now accessible by calling g_characterData:GetRaceInfo()[raceIndex].selectorButton
    data.selectorButton = buttonControl
end
local function InitializeAllianceSelector(allianceButton, allianceData)
    InitializeSelectorButton(allianceButton, allianceData, g_allianceRadioGroup)
    allianceButton.name = allianceData.name
    allianceButton.defId = allianceData.alliance
end
local function InitializeAllianceSelectors()
    local layoutTable =
    {
        ZO_CharacterCreateRaceAllianceSelector1,
        ZO_CharacterCreateRaceAllianceSelector2,
        ZO_CharacterCreateRaceAllianceSelector3,
    }
    local alliances = g_characterData:GetAllianceInfo()
    for _, alliance in ipairs(alliances) do
        local selector = layoutTable[alliance.position]
        InitializeAllianceSelector(selector, alliance)
    end
end
local function AddRaceSelectionDataToSelector(buttonControl, raceData)
    buttonControl.nameFn = GetRaceName
    buttonControl.defId = raceData.race
    buttonControl.alliance = raceData.alliance
end
local function InitializeRaceSelectors()
    local layoutTable =
    {
        ZO_CharacterCreateRaceColumn11,
        ZO_CharacterCreateRaceColumn21,
        ZO_CharacterCreateRaceColumn31,
        ZO_CharacterCreateRaceColumn12,
        ZO_CharacterCreateRaceColumn22,
        ZO_CharacterCreateRaceColumn32,
        ZO_CharacterCreateRaceColumn13,
        ZO_CharacterCreateRaceColumn23,
        ZO_CharacterCreateRaceColumn33,
        ZO_CharacterCreateRaceSingleButton,
    }
    local races = g_characterData:GetRaceInfo()
    for _, race in ipairs(races) do
        local raceButton = layoutTable[race.position]
        InitializeSelectorButton(raceButton, race, g_raceRadioGroup)
        AddRaceSelectionDataToSelector(raceButton, race)
    end
end
local function InitializeGenderSelector()
    ZO_CharacterCreateGenderSelectionMaleLabel:SetText(GetString("SI_GENDER", GENDER_MALE))
    ZO_CharacterCreateGenderSelectionFemaleLabel:SetText(GetString("SI_GENDER", GENDER_FEMALE))
    ZO_CharacterCreateGenderSelectionMaleButton.gender = GENDER_MALE
    ZO_CharacterCreateGenderSelectionFemaleButton.gender = GENDER_FEMALE
    g_genderRadioGroup:Add(ZO_CharacterCreateGenderSelectionMaleButton)
    g_genderRadioGroup:Add(ZO_CharacterCreateGenderSelectionFemaleButton)
end
local function InitializeClassSelectors()
    local classes = g_characterData:GetClassInfo()
    local parent = ZO_CharacterCreateClassSelectionButtonArea
    local stride = 3
    local padX = 0
    local padY = 0
    local controlWidth = 120
    local controlHeight = 80
    local initialX = 0
    local initialY = 0
    local anchor = ZO_Anchor:New(TOPLEFT, parent, TOPLEFT, initialX, initialY)
    for i = 1, #classes do
        local class = classes[i]
        local selectorName = "SelectClass"..class.class
        local selector = GetControl(selectorName)
        if(not selector) then
            selector = CreateControlFromVirtual(selectorName, parent, "ClassSelectorButton")
        end
        selector.nameFn = GetClassName
        selector.defId = class.class
        InitializeSelectorButton(selector, class, g_classRadioGroup)
        ZO_Anchor_BoxLayout(anchor, selector, i - 1, stride, padX, padY, controlWidth, controlHeight, initialX, initialY, GROW_DIRECTION_DOWN_RIGHT)
    end
end
local function InitializeTemplateList()
    local templateList = ZO_CharacterCreateTemplateList
    ZO_ScrollList_Clear(templateList)
    local templatesAllowed = GetTemplateStatus()
    if(templatesAllowed) then
        local templates = g_characterData:GetTemplateInfo()
        local scrollData = ZO_ScrollList_GetDataList(templateList)
    
        for _, template in ipairs(templates) do
              if(template.isSelectable) then 
                    scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(1, template)
              end
        end            
        
        ZO_CharacterCreateTemplateSelected:SetHidden(false)
    else
        ZO_CharacterCreateTemplateSelected:SetHidden(true)
    end
    ZO_ScrollList_Commit(templateList)
    ZO_CharacterCreateTemplateList:SetHidden(true)
    characterCreateTemplateRefCount = 0
end
function ZO_CharacterCreate_InitializeNameControl(nameEdit, linkedButton, linkedInstructions)
    nameEdit.linkedButton = linkedButton
    nameEdit.linkedInstructions = linkedInstructions
end
--[[ XML Handlers and global functions ]]--
    if ZO_CharacterCreateTemplateList:IsHidden() then
         characterCreateTemplateRefCount = 2
         ZO_CharacterCreateTemplateList:SetHidden(false)
    else
        characterCreateTemplateRefCount = 0
        ZO_CharacterCreateTemplateList:SetHidden(true)
    end
end
    if(SetTemplate(control.data.template)) then
        g_bucketManager:UpdateControlsFromData()
    end
end
function ZO_CharacterCreate_RandomizeAppearance(randomizeType)
    g_bucketManager:RandomizeAppearance(randomizeType)
end
local function OnCharacterCreated(eventCode, characterId)
    g_firstTimeInCharacterCreate = true -- the next time we enter character create, we want to generate a random character again.
    g_characterCreateOption = CHARACTER_CREATE_DEFAULT_LOCATION
    g_shouldBePromptedForTutorialSkip = true
    local startLocation = ZO_CharacterCreate_GetStartLocation()
    PregameStateManager_PlayCharacter(characterId, startLocation)
end
local reasonsThatDisableCreateButton =
{
    [CHARACTER_CREATE_ERROR_INVALIDNAME] = true,
    [CHARACTER_CREATE_ERROR_DUPLICATENAME] = true,
    [CHARACTER_CREATE_ERROR_NAMETOOSHORT] = true,
    [CHARACTER_CREATE_ERROR_NAMETOOLONG] = true,
}
local function OnCharacterCreateFailed(eventCode, reason)
    local errorReason = GetString("SI_CHARACTERCREATEERROR", reason)
    
    -- Show the fact that the character could not be created.
    ZO_Dialogs_ShowDialog("CHARACTER_CREATE_FAILED_REASON", nil, {mainTextParams = {errorReason}})
    if(reasonsThatDisableCreateButton[reason]) then
        ZO_CharacterCreateDoIt:SetEnabled(false)
    end
end
local function OnCharacterConstructionReady()
    g_characterData:PerformDeferredInitialization()
    -- Nightmare load-ordering dependency...there are probably other ways around this, and they're probably just as bad.
    -- Once game data is loaded, generate a random character for character create just to advance the
    -- load state. It won't necessarily do any extra work creating an actual character, since we're going
    -- to drop back into the current state, but we need to tell the system to load something
    if(GetNumCharacters() == 0) then
        ZO_CharacterCreate_Reset()
    end
end
local function OnCharacterCreateRequested()
    ZO_CharacterCreateDoIt:SetEnabled(false)
end
    ZO_CharacterCreate.fadeTimeline = ANIMATION_MANAGER:CreateTimelineFromVirtual("CharacterCreateMainControlsFade", ZO_CharacterCreate)
    g_allianceRadioGroup = ZO_RadioButtonGroup:New()
    g_raceRadioGroup = ZO_RadioButtonGroup:New()
    g_classRadioGroup = ZO_RadioButtonGroup:New()
    g_genderRadioGroup = ZO_RadioButtonGroup:New()
    g_characterData = ZO_CharacterCreateData:New()
    g_manager = CharacterCreateManager:New(g_characterData)
    g_bucketManager = CharacterCreateBucketManager:New(ZO_CharacterCreateBuckets)
    g_sliderManager = CharacterCreateSliderManager:New(ZO_CharacterCreateBuckets)
    ZO_CharacterCreateDoIt:SetEnabled(false)
    local nameInstructions = ZO_ValidNameInstructions:New(ZO_CharacterCreateNameInstructions)
    ZO_CharacterCreateCharacterNameInstructions:SetText(GetString(SI_CREATE_CHARACTER_TITLE_NAME))
    ZO_CharacterCreate_InitializeNameControl(ZO_CharacterCreateCharacterName, ZO_CharacterCreateDoIt, nameInstructions)
    
     local list = ZO_CharacterCreateTemplateList
    local function SetupData(control, data)
        control.data = data
        control:SetText(data.name)
    end
     
     ZO_ScrollList_SetHeight(list, 350)
     ZO_ScrollList_AddDataType(list, 1, "CharacterCreateTemplateRow", 20, SetupData)
     ZO_ScrollList_EnableHighlight(list, "ZO_ThinListHighlight")
    local downFromSlider = false
    local function OnGlobalMouseUp()
        local currentState = PregameStateManager_GetCurrentState()
        if(currentState == "CharacterSelect" or currentState == "CharacterCreate") then
            CharacterCreateStopMouseSpin()
        end
        if characterCreateTemplateRefCount > 0 and (not MouseIsOver(ZO_CharacterCreateTemplateList) or downFromSlider) then
            characterCreateTemplateRefCount = characterCreateTemplateRefCount - 1
            if characterCreateTemplateRefCount == 0 then
                ZO_CharacterCreateTemplateList:SetHidden(true)
            end
        end
        downFromSlider = false
    end
    ZO_CharacterCreateTemplateListScrollBar:SetHandler("OnMouseDown", function() 
        characterCreateTemplateRefCount = 2
        downFromSlider = true
    end)
    EVENT_MANAGER:RegisterForEvent("ZO_CharacterCreate", EVENT_GLOBAL_MOUSE_UP, OnGlobalMouseUp)
    EVENT_MANAGER:RegisterForEvent("ZO_CharacterCreate", EVENT_CHARACTER_CREATE_ZOOM_CHANGED, ZO_CharacterCreate_HandleZoomChanged)
    EVENT_MANAGER:RegisterForEvent("ZO_CharacterCreate", EVENT_LOGOUT_SUCCESSFUL, OnLogoutSuccessful)
    EVENT_MANAGER:RegisterForEvent("ZO_CharacterCreate", EVENT_CHARACTER_CREATED, OnCharacterCreated)          
    EVENT_MANAGER:RegisterForEvent("ZO_CharacterCreate", EVENT_CHARACTER_CREATE_FAILED, OnCharacterCreateFailed)
    CALLBACK_MANAGER:RegisterCallback("OnCharacterConstructionReady", OnCharacterConstructionReady)
    CALLBACK_MANAGER:RegisterCallback("CharacterCreateRequested", OnCharacterCreateRequested)
    CHARACTER_CREATE_FRAGMENT = ZO_FadeSceneFragment:New(ZO_CharacterCreate, 300)
end
function ZO_CharacterCreate_HandleZoomChanged(eventCode, zoomInAllowed, zoomOutAllowed)
    ZO_CharacterCreateZoomIn:SetEnabled(zoomInAllowed)
    ZO_CharacterCreateZoomOut:SetEnabled(zoomOutAllowed)
end
local function ResetNameEdit(nameEdit)
    nameEdit:TakeFocus() -- Fix an issue where the animated name text wouldn't display
    nameEdit:SetText("")
    nameEdit:LoseFocus()    
end
    if(not IsPregameCharacterConstructionReady()) then return end -- Sanity check
    SetSuppressCharacterChanges(true) -- this will be disabled later, right before controls are initialized
    SetCharacterManagerMode(CHARACTER_MODE_CREATION)
    ResetNameEdit(ZO_CharacterCreateCharacterName)    
    local defaultTemplate = GetDefaultTemplate()
    local controlsInitialized = false
    if(defaultTemplate > 0) then
        controlsInitialized = SetTemplate(defaultTemplate)
    else
        UpdateSelectedTemplateText()
        controlsInitialized = GenerateRandomCharacter()
    end
    if(not controlsInitialized) then    
        g_manager:InitializeControls()
    end
    g_bucketManager:SwitchBuckets(CREATE_BUCKET_RACE)
    g_bucketManager:UpdateControlsFromData()
    g_characterStartLocation = nil
    g_shouldBePromptedForTutorialSkip = true
    g_characterCreateOption = CHARACTER_CREATE_DEFAULT_LOCATION
    SetCharacterCameraZoomAmount(-1) -- zoom all the way out when a reset happens
end
function ZO_CharacterCreate_DoCreate(startLocation, createOption)
    local characterName = ZO_CharacterCreateCharacterName:GetText()
    local requestSkipTutorial = createOption == CHARACTER_CREATE_SKIP_TUTORIAL
    g_characterCreateOption = createOption
    CreateCharacter(characterName, requestSkipTutorial)
    g_characterStartLocation = startLocation or CHARACTER_OPTION_EXISTING_AREA
    CALLBACK_MANAGER:FireCallbacks("CharacterCreateRequested")
end
    local characterName = ZO_CharacterCreateCharacterName:GetText()
    
    if characterName and #characterName > 0 then
        if g_shouldBePromptedForTutorialSkip and CanSkipTutorialArea() and startLocation ~= CHARACTER_OPTION_CLEAN_TEST_AREA and startLocation ~= "CharacterSelect_FromIngame" then
            g_shouldBePromptedForTutorialSkip = false
            local genderDecoratedCharacterName = GetGrammarDecoratedName(characterName, CharacterCreateGetGender())
            ZO_Dialogs_ShowDialog("CHARACTER_CREATE_SKIP_TUTORIAL", { startLocation = startLocation }, {mainTextParams = { genderDecoratedCharacterName }})
        else
            ZO_CharacterCreate_DoCreate(startLocation, g_characterCreateOption)
        end
    end
end
local function ValidateNameText(editControl)
    local nameText = editControl:GetText()    
    local nameViolations = { IsValidCharacterName(nameText) }
    local nameIsValid = (#nameViolations == 0)
    if(nameIsValid) then
        editControl:SetColor(GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_NORMAL))
    else
        editControl:SetColor(GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_FAILED))
    end
    local oldPos = editControl:GetCursorPosition()
    editControl:SetText(CorrectCharacterNameCase(nameText))
    editControl:SetCursorPosition(oldPos)
    return nameIsValid, nameViolations
end
    -- Validation changes the text in the edit control, which causes this to be called again, bail if we're already validating to avoid recursion.
    if(editControl.validating) then return end
    editControl.validating = true
    local isValidName, nameViolations = ValidateNameText(editControl)
    if(isValidName) then
        editControl.linkedButton:SetState(BSTATE_NORMAL, false)
        editControl.linkedInstructions:Hide()
    else
        editControl.linkedButton:SetState(BSTATE_DISABLED, true)
        if(editControl:HasFocus()) then
            editControl.linkedInstructions:Show(editControl, nameViolations)
        else
            editControl.linkedInstructions:Hide()
        end
    end
    CALLBACK_MANAGER:FireCallbacks("OnCharacterCreateNameChanged", isValidName)
    editControl.validating = nil
end
    GetControl(editControl, "Instructions"):SetHidden(true)
end
    if(#editControl:GetText() == 0) then
        GetControl(editControl, "Instructions"):SetHidden(false)
    end
    editControl.linkedInstructions:Hide()
end
    return g_characterStartLocation
end
    g_bucketManager:MouseOverBucket(tabButton)
end
    g_bucketManager:MouseExitBucket(tabButton)
end
function ZO_CharacterCreate_BucketClicked(tabButton)
    g_bucketManager:SwitchBuckets(tabButton)
end
    local selectorClickHandlers =
    {
        ["race"] =  function(button)
                        g_manager:SetRace(button.defId)
                        UpdateRaceControl()
                    end,
        ["class"] = function(button)
                        CharacterCreateSetClass(button.defId)
                        UpdateClassControl()
                    end,
        ["alliance"] =  function(button)
                            g_manager:SetAlliance(button.defId)
                            UpdateRaceControl()
                        end,
    }
    local fn = selectorClickHandlers[button.selectorType]
    if(fn) then
        fn(button)
    end
end
    InitializeTooltip(InformationTooltip, button, TOPRIGHT, 0, 0, TOPLEFT)
    if(button.name) then
        SetTooltipText(InformationTooltip, zo_strformat(button.tooltipFormatter, button.name))
    elseif(button.nameFn) then
        SetTooltipText(InformationTooltip, zo_strformat(button.tooltipFormatter, button.nameFn(CharacterCreateGetGender(), button.defId)))
    end
end
    ClearTooltip(InformationTooltip)
end
    g_manager:SetGender(button.gender)
end
    button:GetParent().m_sliderObject:ToggleLocked()
end
function ZO_CharacterCreate_SetSlider(slider, value)
    slider:GetParent().m_sliderObject:SetValue(value)
end
function ZO_CharacterCreate_ChangeSlider(slider, changeAmount)
    slider:GetParent().m_sliderObject:ChangeValue(changeAmount)
end
function ZO_CharacterCreate_ChangePanel(direction)
    local currentTab = g_bucketManager:GetCurrentTab()
    if(currentTab) then
        g_bucketManager:SwitchBuckets(currentTab.m_windowData[direction])
    end
end
function ZO_CharacterCreate_CreateSlider(sliderControl, sliderType)
    if(sliderType == "slider") then
        CharacterCreateSlider:New(sliderControl)
    elseif(sliderType == "icon") then
        CharacterCreateAppearanceSlider:New(sliderControl)
    elseif(sliderType == "color") then
        CharacterCreateColorSlider:New(sliderControl)
    elseif(sliderType == "named") then
        CharacterCreateDropdownSlider:New(sliderControl)
    end
end
function ZO_CharacterCreate_CreateTriangle(control, setterFn, updaterFn, triangleStringId, topStringId, leftStringId, rightStringId)
    local triangle = CharacterCreateTriangle:New(control, setterFn, updaterFn, triangleStringId, topStringId, leftStringId, rightStringId)
end
function ZO_CharacterCreate_PreviewClicked(previewButton)
    local slider = previewButton:GetParent()
    slider.m_sliderObject:Preview()
end
    ZO_CharacterCreateOverlay.fadeTimeline:Stop()
    ZO_CharacterCreateOverlay:SetHidden(false)
    ZO_CharacterCreateOverlay:SetMouseEnabled(true)
    ZO_CharacterCreateOverlay:SetAlpha(1)
    g_playingTransitionAnimations = true
end
    ZO_CharacterCreateOverlay:SetHidden(true)
    ZO_CharacterCreateOverlay:SetMouseEnabled(false)
    g_playingTransitionAnimations = false
end
    ZO_CharacterCreateOverlay.fadeTimeline:PlayFromStart()
    g_playingTransitionAnimations = true
end
    ZO_CharacterCreate.fadeTimeline:PlayFromStart()
    g_playingTransitionAnimations = true
end
    ZO_CharacterCreateOverlay:SetMouseEnabled(false)
    g_playingTransitionAnimations = false
    PregameStateManager_SetState("CharacterCreate")
end