Back to Home

ESO Lua File v100020

pregame/gamemenu_pregame/keyboard/gamemenu_characterselect.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
local GAME_MENU_CHARACTERSELECT
local gameEntries = {}
-- Characters
local function ShowCharacterSelect()
    if(IsConsoleUI()) then  -- TODO integrate this with PC gamepad
        if(IsInGamepadPreferredMode()) then
            if(CHARACTER_SELECT_GAMEPAD_FRAGMENT ~= nil) then
                SCENE_MANAGER:AddFragment(CHARACTER_SELECT_GAMEPAD_FRAGMENT)
                return
            end
        end
    end
    if(CHARACTER_SELECT_FRAGMENT ~= nil) then
        SCENE_MANAGER:AddFragment(CHARACTER_SELECT_FRAGMENT)
    end
end
local function HideCharacterSelect()
    if(IsConsoleUI()) then  -- TODO integrate this with PC gamepad
        if(IsInGamepadPreferredMode()) then
            if(CHARACTER_SELECT_GAMEPAD_FRAGMENT ~= nil) then
                SCENE_MANAGER:RemoveFragment(CHARACTER_SELECT_GAMEPAD_FRAGMENT)
                return
            end
        end
    end
    if(CHARACTER_SELECT_FRAGMENT ~= nil) then
        SCENE_MANAGER:RemoveFragment(CHARACTER_SELECT_FRAGMENT)
    end
end
local function AddCharactersEntry(entryTable)
    local data = {name = GetString(SI_GAME_MENU_CHARACTERS), callback = ShowCharacterSelect, unselectedCallback = HideCharacterSelect, hasSelectedState = true}
    table.insert(entryTable, data)
end
-- Settings
local function AddSettingsEntries(entryTable)
    local settingsHeaderData = {name = GetString(SI_GAME_MENU_SETTINGS)}
    table.insert(entryTable, settingsHeaderData)
end
-- Controls
local function AddControlsEntries(entryTable)
    -- Nothing for now
end
-- Addons
local function ShowAddons()
    SCENE_MANAGER:AddFragment(ADDONS_FRAGMENT)
end
local function HideAddons()
    SCENE_MANAGER:RemoveFragment(ADDONS_FRAGMENT)
end
local function AddAddonsEntry(entryTable)
    local function ShouldShowNewIcon()
        return not HasViewedEULA(EULA_TYPE_ADDON_EULA)
    end
    local data = {name = GetString(SI_GAME_MENU_ADDONS), callback = ShowAddons, unselectedCallback = HideAddons, showNewIconCallback = ShouldShowNewIcon, hasSelectedState = true}
    table.insert(entryTable, data)
end
-- Play Cinematic
local function PlayCinematic()
    PregameStateManager_SetState("CharacterSelect_PlayCinematic")
end
local function AddCinematicEntry(entryTable)
    local data = {name = GetString(SI_GAME_MENU_PLAY_CINEMATIC), callback = PlayCinematic }
    table.insert(entryTable, data)
end
-- Back
local function AddBackEntry(entryTable)
    local data = {name = GetString(SI_GAME_MENU_BACK), callback = ZO_Disconnect}
    table.insert(entryTable, data)
end
-- Setup
local function RebuildTree(gameMenu)
    gameEntries = {}
    AddCharactersEntry(gameEntries)
    AddSettingsEntries(gameEntries)
    AddControlsEntries(gameEntries)
    AddAddonsEntry(gameEntries)
    AddCinematicEntry(gameEntries)
    AddBackEntry(gameEntries)
    gameMenu:SubmitLists(gameEntries)
end
local function OnShow(gameMenu)
    RebuildTree(gameMenu)
end
    SCENE_MANAGER:Show("gameMenuCharacterSelect")
    RebuildTree(GAME_MENU_CHARACTERSELECT)
end
    GAME_MENU_CHARACTERSELECT = ZO_GameMenu_Initialize(self, OnShow)
    local gameMenuCharacterSelectFragment = ZO_FadeSceneFragment:New(self)
    local gameMenuCharacterSelectScene = ZO_Scene:New("gameMenuCharacterSelect", SCENE_MANAGER)
    gameMenuCharacterSelectScene:AddFragment(gameMenuCharacterSelectFragment)
 
    gameMenuCharacterSelectScene:RegisterCallback("StateChange",    function(oldState, newState)
                                                                        ZO_UpdatePaperDollManipulationForScene(ZO_CharacterSelectCharacterViewport, newState)
                                                                        if newState == SCENE_SHOWING then
                                                                            RebuildTree(GAME_MENU_CHARACTERSELECT)
                                                                        end
                                                                    end)
    local function UpdateNewStates()
        GAME_MENU_CHARACTERSELECT:RefreshNewStates()
    end
    CALLBACK_MANAGER:RegisterCallback("AddOnEULAHidden", UpdateNewStates)
end