Back to Home

ESO Lua File v101042

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
local GAME_MENU_CHARACTERSELECT
local gameEntries = {}
-- Characters
local function ShowCharacterSelect()
    if PregameIsFullyLoaded() then
        SCENE_MANAGER:AddFragment(CHARACTER_SELECT_FRAGMENT)
    else
        local function OnPregameFullyLoaded()
            SCENE_MANAGER:AddFragment(CHARACTER_SELECT_FRAGMENT)
            -- Make sure we unregister the callback, so we don't unintentially add the character select fragment in subsequent loads
            CALLBACK_MANAGER:UnregisterCallback("PregameFullyLoaded", OnPregameFullyLoaded)
        end
        CALLBACK_MANAGER:RegisterCallback("PregameFullyLoaded", OnPregameFullyLoaded)
    end
    local esoPlus = GAME_MENU_CHARACTERSELECT:GetControl():GetNamedChild("ESOPlus")
    esoPlus:SetHidden(IsESOPlusSubscriber())
end
local function HideCharacterSelect()
    SCENE_MANAGER:RemoveFragment(CHARACTER_SELECT_FRAGMENT)
    local esoPlus = GAME_MENU_CHARACTERSELECT:GetControl():GetNamedChild("ESOPlus")
    esoPlus:SetHidden(true)
end
local function AddCharactersEntry(entryTable)
    local data =
    {
        name = GetString(SI_GAME_MENU_CHARACTERS),
        callback = ShowCharacterSelect,
        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)
    if not AreUserAddOnsSupported() then
        return
    end
    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 AddCinematicEntry(entryTable)
    local data = {name = GetString(SI_GAME_MENU_PLAY_CINEMATIC), callback = ZO_PlayIntroCinematicAndReturn }
    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(control, OnShow)
    local gameMenuCharacterSelectFragment = ZO_FadeSceneFragment:New(control)
    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