ESO Lua File v100010

pregame/characterselect/zo_characterselect_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
local g_currentlySelectedCharacterData
local g_playerSelectedCharacterId
local g_lastSelectedData
local g_canCreateCharacter = true
--[[ Character Select Delete Screen ]]--
local EXPECTED_ICON_SIZE = 64
local BASE_PERCENT = 100
local CHARACTERSELECT_GAMEPAD_SLOTS = 8
local CHARACTER_DELETE_KEY_ICONS = {
    [true] = {    KEY_GAMEPAD_LEFT_SHOULDER_HOLD,
                KEY_GAMEPAD_RIGHT_SHOULDER_HOLD,
                KEY_GAMEPAD_LEFT_TRIGGER_HOLD,
                KEY_GAMEPAD_RIGHT_TRIGGER_HOLD },
    [false] = {   KEY_GAMEPAD_LEFT_SHOULDER,
                KEY_GAMEPAD_RIGHT_SHOULDER,
                KEY_GAMEPAD_LEFT_TRIGGER,
                KEY_GAMEPAD_RIGHT_TRIGGER },
}
local CHARACTER_DELETE_TEXT_ANIM = {
    ".",
    "..",
    "...",
}
local CHARACTER_DELETE_TEXT_ANIM_SPEED = 0.5
    local path, width, height = ZO_Keybindings_GetTexturePathForKey(key)
    if path then
        local widthPercent = (width / EXPECTED_ICON_SIZE) * BASE_PERCENT;
        local heightPercent = (height / EXPECTED_ICON_SIZE) * BASE_PERCENT;
        return ("|t%f%%:%f%%:%s|t"):format(widthPercent, heightPercent, path)
    end
    return ""
end
    local self = ZO_CharacterSelect_Gamepad
    ZO_CharacterSelect_GamepadCharacters:SetHidden(false)
    ZO_CharacterSelect_GamepadCharacterDetails:SetHidden(false)
    ZO_CharacterSelect_GamepadDelete:SetHidden(true)
    ZO_CharacterSelect_GamepadLogin:SetHidden(true)
    ZO_CharacterSelect_GamepadLoginError:SetHidden(true)
    ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorDefault)
    ZO_CharacterSelect_GamepadCharacterViewport.Activate()
end
    local keys = ZO_CharacterSelect_Gamepad.deleteKeys
    local keyText = ""
    for i, enabled in ipairs(keys) do
        if (keyText ~= "") then
            keyText = keyText .. " "   -- Space out the icons
        end
        local keyCode = CHARACTER_DELETE_KEY_ICONS[enabled][i]
        keyText = keyText .. ZO_CharacterSelect_Gamepad_GetKeyText(keyCode)
    end
    return keyText
end
    if (time - self.timer > 0) then
        self.timer = self.timer + CHARACTER_DELETE_TEXT_ANIM_SPEED
        -- Animate between "Deleting.", "Deleting.." and "Deleting..."
        self.textIndex = (self.textIndex % #CHARACTER_DELETE_TEXT_ANIM) + 1
        local text = GetString(SI_DELETE_CHARACTER_GAMEPAD_DELETING) .. CHARACTER_DELETE_TEXT_ANIM[self.textIndex]
        ZO_CharacterSelect_GamepadDelete:GetNamedChild("DeletingText"):SetText(text)
    end
end
local function ZO_CharacterSelectDelete_Gamepad_OnKeyChanged(key, onDown)
    local keys = ZO_CharacterSelect_Gamepad.deleteKeys
    -- Change key if we pressed it
    for i, deleteKey in ipairs(CHARACTER_DELETE_KEY_ICONS[false]) do
        if deleteKey == key then
            ZO_CharacterSelect_Gamepad.deleteKeys[i] = onDown
        end
    end
    if not ZO_CharacterSelect_Gamepad.deleting then
        -- Are all of them activated?
        local activated = 0
        for i, deleteKey in ipairs(CHARACTER_DELETE_KEY_ICONS[false]) do
            if ZO_CharacterSelect_Gamepad.deleteKeys[i] then
                activated = activated + 1
            end
        end
        if (activated == #CHARACTER_DELETE_KEY_ICONS[false]) then
            -- Delete character and exit dialog
            DeleteCharacter(g_currentlySelectedCharacterData.id)
            ZO_CharacterSelect_Gamepad.deleting = true
            ZO_CharacterSelect_GamepadDelete:GetNamedChild("DeletingText"):SetHidden(false)
            ZO_CharacterSelect_GamepadDelete:GetNamedChild("Keys"):SetHidden(true)
            ZO_CharacterSelect_GamepadDelete:GetNamedChild("Text"):SetHidden(true)
            ZO_CharacterSelect_GamepadDelete.timer = GetFrameTimeSeconds()
            ZO_CharacterSelect_GamepadDelete.textIndex = 1
            ZO_CharacterSelect_GamepadDelete:SetHandler("OnUpdate", ZO_CharacterSelectDelete_Gamepad_OnUpdate)
        end
    end
    ZO_CharacterSelect_GamepadDelete:GetNamedChild("Keys"):SetText(ZO_CharacterSelect_Gamepad_GetDeleteKeyText())
end
--[[ Character Select Screen ]]--
local function InitKeybindingDescriptor(self)
    self.charListKeybindStripDescriptorDefault =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_PLAY),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                ZO_CharacterSelect_Gamepad_Login(CHARACTER_OPTION_EXISTING_AREA)
            end,
        },
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_DELETE),
            keybind = "UI_SHORTCUT_TERTIARY",
            callback = function()
                ZO_CharacterSelect_GamepadCharacterViewport.Deactivate()
                ZO_CharacterSelect_GamepadCharacters:SetHidden(true)
                ZO_CharacterSelect_GamepadDelete:SetHidden(false)
                ZO_CharacterSelect_GamepadDelete:GetNamedChild("DeletingText"):SetHidden(true)
                ZO_CharacterSelect_GamepadDelete:GetNamedChild("Keys"):SetHidden(false)
                ZO_CharacterSelect_GamepadDelete:GetNamedChild("Text"):SetHidden(false)
                ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorDelete)
                ZO_CharacterSelect_GamepadDelete:GetNamedChild("Keys"):SetText(ZO_CharacterSelect_Gamepad_GetDeleteKeyText())
            end,
        },
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_OPTIONS),
            keybind = "UI_SHORTCUT_SECONDARY",
            callback = function()
                -- TODO Hook into options screen
            end,
        },
    }
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.charListKeybindStripDescriptorDefault, self.characterList)
    -- Different keybinding for Create New option
    self.charListKeybindStripDescriptorCreateNew =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_CREATE_NEW),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                PregameStateManager_SetState("CharacterCreate")
            end,
        },
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_OPTIONS),
            keybind = "UI_SHORTCUT_SECONDARY",
            callback = function()
                -- TODO Hook into options screen
            end,
        },
    }
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.charListKeybindStripDescriptorCreateNew, self.characterList)
    -- Keybinding for delete screen
    self.charListKeybindStripDescriptorDelete =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            name = GetString(SI_CHARACTER_SELECT_GAMEPAD_DELETE_CANCEL),
            keybind = "UI_SHORTCUT_EXIT",
        },
        {
            keybind = "UI_SHORTCUT_LEFT_SHOULDER",
            handlesKeyUp = true,
            ethereal = true,
            callback = function(onUp)
                ZO_CharacterSelectDelete_Gamepad_OnKeyChanged(KEY_GAMEPAD_LEFT_SHOULDER, not onUp)
            end,
        },
        {
            keybind = "UI_SHORTCUT_RIGHT_SHOULDER",
            handlesKeyUp = true,
            ethereal = true,
            callback = function(onUp)
                ZO_CharacterSelectDelete_Gamepad_OnKeyChanged(KEY_GAMEPAD_RIGHT_SHOULDER, not onUp)
            end,
        },
        {
            keybind = "UI_SHORTCUT_LEFT_TRIGGER",
            handlesKeyUp = true,
            ethereal = true,
            callback = function(onUp)
                ZO_CharacterSelectDelete_Gamepad_OnKeyChanged(KEY_GAMEPAD_LEFT_TRIGGER, not onUp)
            end,
        },
        {
            keybind = "UI_SHORTCUT_RIGHT_TRIGGER",
            handlesKeyUp = true,
            ethereal = true,
            callback = function(onUp)
                ZO_CharacterSelectDelete_Gamepad_OnKeyChanged(KEY_GAMEPAD_RIGHT_TRIGGER, not onUp)
            end,
        },
    }
    self.charListKeybindStripDescriptorLogin =
    {
    }
    self.charListKeybindStripDescriptorLoginError =
    {
        {
            keybind = "UI_SHORTCUT_EXIT",
            ethereal = true,
        },
    }
    self.charListKeybindStripDescriptor = self.charListKeybindStripDescriptorDefault
end
local function GetClassIconGamepad(classIdRequested)
    for i = 1, GetNumClasses() do
        local classId, _, icon, _, _, _, _ = GetClassInfo(i)
        if classId == classIdRequested then
            icon = string.gsub(icon, '/esoui/art/charactercreate/', '/esoui/art/charactercreate/gamepad/')
            icon = string.gsub(icon, '_up.dds', '_default.dds')
            return icon
        end
    end
    return nil
end
local function SetupCharacterEntry(control, data, selected, selectedDuringRebuild, enable, activated)
    local entryText = control:GetNamedChild("Text")
    local icon = control:GetNamedChild("Icon")
    local plusIcon = control:GetNamedChild("PlusIcon")
    if(selected) then
        -- Change the keybind strip if we have create new selected
        local self = ZO_CharacterSelect_Gamepad
        if data.createNew then
            ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorCreateNew)
        else
            ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorDefault)
        end
        control:SetAlpha(1.0)
        entryText:SetFont("ZoFontGamepad37")
        if icon then
            icon:SetDimensions(40, 40)
        end
        if plusIcon then
            plusIcon:SetDimensions(32, 32)
        end
    else
        control:SetAlpha(0.5)
        entryText:SetFont("ZoFontGamepad30")
        if icon then
            icon:SetDimensions(32, 32)
        end
        if plusIcon then
            plusIcon:SetDimensions(29, 29)
        end
    end
    if (data.name == nil) then
        return
    end
    entryText:SetText(zo_strformat(SI_CHARACTER_SELECT_NAME, data.name))
    if icon and data.class then
        local classTexture = GetClassIconGamepad(data.class)
        if classTexture then
            icon:SetHidden(false)
            icon:SetTexture(classTexture)
        else
            icon:SetHidden(true)
        end
    end
end
local function CreateList(self)
    self.characterList:Clear()
    self.characterList:AddDataTemplate("ZO_CharacterEntry_Gamepad", SetupCharacterEntry, ZO_GamepadMenuEntryTemplateParametricListFunction)        
    self.characterList:AddDataTemplate("ZO_CharacterEntryCreateNew_Gamepad", SetupCharacterEntry, ZO_GamepadMenuEntryTemplateParametricListFunction)        
    local characterDataList = ZO_CharacterSelect_GetCharacterDataList()
    if(#characterDataList > 0) then
        local createNew = true
        for i=1,CHARACTERSELECT_GAMEPAD_SLOTS do
            if (characterDataList[i] ~= nil) then
                self.characterList:AddEntry("ZO_CharacterEntry_Gamepad", characterDataList[i])
            elseif createNew then
                self.characterList:AddEntry("ZO_CharacterEntryCreateNew_Gamepad", { index=i, createNew=true })
                createNew = false
            else
                -- Do nothing for empty slots
            end
        end
    end
    self.characterList:Commit()
end
local function DoCharacterSelection(index)
    SetCharacterManagerMode(CHARACTER_MODE_SELECTION)
    SelectCharacterToView(index)
end
local function SelectCharacter(characterData)
    if characterData then
        if IsPregameCharacterConstructionReady() and (g_currentlySelectedCharacterData == nil or g_currentlySelectedCharacterData.index ~= characterData.index) then
            g_currentlySelectedCharacterData = characterData
            DoCharacterSelection(g_currentlySelectedCharacterData.index)
        end
    end
end
local function ZO_CharacterSelect_Gamepad_GetFormattedRace(characterData)
    local raceName = characterData.race and GetRaceName(characterData.gender, characterData.race) or GetString(SI_UNKNOWN_RACE)
    return zo_strformat(SI_CHARACTER_SELECT_RACE, raceName)
end
local function ZO_CharacterSelect_Gamepad_GetFormattedClass(characterData)
    local className = characterData.class and GetClassName(characterData.gender, characterData.class) or GetString(SI_UNKNOWN_CLASS)
    return zo_strformat(SI_CHARACTER_SELECT_CLASS, className)
end
local function ZO_CharacterSelect_Gamepad_GetFormattedAlliance(characterData)
    local allianceName = GetAllianceName(characterData.alliance) or GetString(SI_UNKNOWN_CLASS)
    return zo_strformat(SI_CHARACTER_SELECT_ALLIANCE, allianceName)
end
    return zo_iconFormat(GetAvARankIcon(rank), 32, 32)
end
local function ZO_CharacterSelect_Gamepad_GetFormattedLocation(characterData)
    local locationName = characterData.location ~= 0 and GetLocationName(characterData.location) or GetString(SI_UNKNOWN_LOCATION)
    return zo_strformat(SI_CHARACTER_SELECT_LOCATION, locationName)
end
do
    SetupCharacterList = function (self, eventCode, numCharacters, maxCharacters, mostRecentlyPlayedCharacterId, numCharacterDeletesRemaining)
        ZO_CharacterSelect_OnCharacterListReceivedCommon(eventCode, numCharacters, maxCharacters, mostRecentlyPlayedCharacterId, numCharacterDeletesRemaining, maxCharacterDeletes)
        g_canCreateCharacter = numCharacters < maxCharacters
        CreateList(self)
    end
    SelectedCharacterChanged = function(self, list, selectedData, oldSelectedData)
        local characterName = self.characterDetails:GetNamedChild("Name")
        local characterRace = self.characterDetails:GetNamedChild("Race")
        local characterLevel = self.characterDetails:GetNamedChild("Level")
        local characterClass = self.characterDetails:GetNamedChild("Class")
        local characterAlliance = self.characterDetails:GetNamedChild("Alliance")
        local characterRank = self.characterDetails:GetNamedChild("Rank")
        local characterGrade = self.characterDetails:GetNamedChild("Grade")
        local characterGradeLabel = self.characterDetails:GetNamedChild("GradeLabel")
        local characterLocation = self.characterDetails:GetNamedChild("Location")
        local locationName = ""
        if selectedData then
            characterName:SetText(zo_strformat(SI_CHARACTER_SELECT_NAME, selectedData.name))
            characterRace:SetText(ZO_CharacterSelect_Gamepad_GetFormattedRace(selectedData))
            characterLevel:SetText(ZO_CharacterSelect_GetFormattedLevel(selectedData))
            characterClass:SetText(ZO_CharacterSelect_Gamepad_GetFormattedClass(selectedData))
            characterAlliance:SetText(ZO_CharacterSelect_Gamepad_GetFormattedAlliance(selectedData))
            -- Location Name isn't always valid
            locationName = ZO_CharacterSelect_Gamepad_GetFormattedLocation(selectedData)
            characterLocation:SetText(locationName)
            g_playerSelectedCharacterId = selectedData.id
            SelectCharacter(selectedData)
        else
            g_playerSelectedCharacterId = nil
        end
        -- Only show the character details if the slot is valid
        ZO_CharacterSelect_GamepadCharacterDetails:SetHidden(not (selectedData and selectedData.name and locationName ~= ""))
        self.characterDetails:SetHidden(false)
        g_lastSelectedData = selectedData
    end
end
    local self = ZO_CharacterSelect_Gamepad
    SelectedCharacterChanged(self, nil, g_lastSelectedData, nil)
end
local function OnCharacterConstructionReady()
    if(GetNumCharacters() > 0) then
        g_currentlySelectedCharacterData = ZO_CharacterSelect_GetBestSelectionData()
        DoCharacterSelection(g_currentlySelectedCharacterData.index)
        local ALLOW_EVEN_IF_DISABLED = true
        local FORCE_ANIMATION = true
        ZO_CharacterSelect_Gamepad.characterList:SetSelectedIndex(g_currentlySelectedCharacterData.index, ALLOW_EVEN_IF_DISABLED, FORCE_ANIMATION)
    end
end
local function OnPregameFullyLoaded()
    local self = ZO_CharacterSelect_Gamepad
    if ZO_CharacterSelect_Gamepad.characterList:IsActive() then
        ZO_CharacterSelect_Gamepad.characterList:RefreshVisible()
    end
end
    local self = ZO_CharacterSelect_Gamepad
    if (keybindStrip) then
        self.charListKeybindStripDescriptor = keybindStrip
    end
    if self.active and self.currentKeystrip ~= self.charListKeybindStripDescriptor then
        if self.currentKeystrip then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.currentKeystrip)
            self.currentKeystrip = nil
        end
        self.currentKeystrip = self.charListKeybindStripDescriptor
        KEYBIND_STRIP:RemoveDefaultExit()
        KEYBIND_STRIP:AddKeybindButtonGroup(self.charListKeybindStripDescriptor)
    end
end
local function ZO_CharacterSelect_Gamepad_StateChanged(oldState, newState)
    local self = ZO_CharacterSelect_Gamepad
    if newState == SCENE_SHOWING then
        self.active = true
        self.control:AddFragment(KEYBIND_STRIP_GAMEPAD_FRAGMENT)
        ZO_CharacterSelect_GamepadCharacterViewport.Activate()
        self.characterList:Activate()
        if IsPregameCharacterConstructionReady() then
            OnCharacterConstructionReady()  -- So that if we come to this screen from Character Create, it will load a different scene.
        end
    elseif newState == SCENE_HIDDEN then
        self.active = false
        self.control:RemoveFragment(KEYBIND_STRIP_GAMEPAD_FRAGMENT)
        ZO_CharacterSelect_GamepadCharacterViewport.Deactivate()
        self.characterList:Deactivate()
        if self.currentKeystrip then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.charListKeybindStripDescriptor)
            self.currentKeystrip = nil
        end
    end
end
local function CharacterDeleted(eventCode, charId)
    -- Destroy the existing character list...then request a new one and the server will tell us which state to drop into.
    -- NOTE: This is actually passed the character id, but we're going to let the server handle the empty list case for now.
    ZO_CharacterSelect_Gamepad.deleting = false
    ZO_CharacterSelect_GamepadDelete:SetHandler("OnUpdate", nil)
    ZO_CharacterSelect_Gamepad.characterList:Clear()
end
    self.deleteKeys = {false, false, false, false}
    self.characterList = ZO_GamepadVerticalParametricScrollList:New(self:GetNamedChild("Characters"):GetNamedChild("List"))
    self.characterDetails = self:GetNamedChild("CharacterDetails"):GetNamedChild("Container")
    InitKeybindingDescriptor(self) -- Depends on self.characterList since we bind to it.
    local function OnCharacterSelectionChanged(list, selectedData, oldSelectedData)
        SelectedCharacterChanged(self, list, selectedData, oldSelectedData)
    end
    local function OnCharacterListReceived(eventCode, numCharacters, maxCharacters, mostRecentlyPlayedCharacterId, numCharacterDeletesRemaining, maxCharacterDeletes)
        SetupCharacterList(self, eventCode, numCharacters, maxCharacters, mostRecentlyPlayedCharacterId, numCharacterDeletesRemaining, maxCharacterDeletes)
    end
    self:RegisterForEvent(EVENT_CHARACTER_LIST_RECEIVED, OnCharacterListReceived)
    
    local GamepadCharacterSelectFragment = ZO_FadeSceneFragment:New(self)
    local GamepadCharacterSelectScene = ZO_Scene:New("gamepadCharacterSelect", SCENE_MANAGER)
    GamepadCharacterSelectScene:AddFragment(GamepadCharacterSelectFragment)
    GamepadCharacterSelectScene:AddFragment(KEYBIND_STRIP_GAMEPAD_FRAGMENT)
    self.control = GamepadCharacterSelectScene
    GamepadCharacterSelectScene:RegisterCallback("StateChange", ZO_CharacterSelect_Gamepad_StateChanged)
    CALLBACK_MANAGER:RegisterCallback("OnCharacterConstructionReady", OnCharacterConstructionReady)
    CALLBACK_MANAGER:RegisterCallback("PregameFullyLoaded", OnPregameFullyLoaded)
    self:RegisterForEvent(EVENT_CHARACTER_DELETED, CharacterDeleted)
    CHARACTER_SELECT_GAMEPAD_FRAGMENT = ZO_FadeSceneFragment:New(self, 300)
    self.control:AddFragment(KEYBIND_STRIP_GAMEPAD_BACKDROP_FRAGMENT)
end
    if(PregameStateManager_GetCurrentState() == "CharacterSelect") then
        -- TODO need to handle renaming case (selectedData.needsRename)
        if(g_currentlySelectedCharacterData) then
            PregameStateManager_PlayCharacter(g_currentlySelectedCharacterData.id, option)
        end
    end
end
    local self = ZO_CharacterSelect_Gamepad
    ZO_CharacterSelect_GamepadCharacterViewport.Deactivate()
    ZO_CharacterSelect_GamepadCharacters:SetHidden(true)
    ZO_CharacterSelect_GamepadCharacterDetails:SetHidden(true)
    ZO_CharacterSelect_GamepadLoginError:SetHidden(false)
    local text = ZO_CharacterSelect_Gamepad_GetKeyText(KEY_GAMEPAD_BUTTON_2) .. " " .. GetString(SI_CHARACTER_SELECT_GAMEPAD_LOGIN_ERROR_EXIT)
    ZO_CharacterSelect_GamepadLoginErrorButton:SetText(text)
    ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorLoginError)
end
    local self = ZO_CharacterSelect_Gamepad
    ZO_CharacterSelect_GamepadCharacterViewport.Deactivate()
    ZO_CharacterSelect_GamepadCharacters:SetHidden(true)
    ZO_CharacterSelect_GamepadLogin:SetHidden(false)
    ZO_CharacterSelect_Gamepad_RefreshKeybindStrip(self.charListKeybindStripDescriptorLogin)
end