Back to Home

ESO Lua File v101042

pregame/gamemenu_pregame/keyboard/gamemenu_pregame.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
ZO_GameMenu_PreGame_Keyboard = ZO_InitializingObject:Subclass()
function ZO_GameMenu_PreGame_Keyboard:Initialize(control)
    self.control = control
    local horizontalMenuControl = control:GetNamedChild("HorizontalMenu")
    self.horizontalMenu = ZO_Horizontal_Menu:New(horizontalMenuControl, ZO_HORIZONAL_MENU_ALIGN_LEFT)
    self.gameMenuPregameFragment = ZO_FadeSceneFragment:New(self.control)
    self.scene = ZO_Scene:New("gameMenuPregame", SCENE_MANAGER)
    self.scene:AddFragment(self.gameMenuPregameFragment)
    self.scene:AddFragment(PREGAME_BACKGROUND_FRAGMENT)
    self.scene:AddFragment(LOGIN_BG_FRAGMENT)
    local loginFragment = LOGIN_MANAGER_KEYBOARD:GetRelevantLoginFragment()
    self.scene:AddFragment(loginFragment)
    local function OnHorizontalMenuItemSetup(menuControl, data)
        local name = data.name
        if type(data.name) == "function" then
            name = data.name()
        end
        menuControl:SetText(name)
    end
    local HORIZONTAL_SPACING = 30
    self.horizontalMenu:AddTemplate("ZO_HorizontalMenu_LabelHeader", OnHorizontalMenuItemSetup, HORIZONTAL_SPACING)
    self:BuildMenu()
    -- Quit Option
    local quitOption = self.control:GetNamedChild("Quit")
    local data =
    {
        name = GetString(SI_GAME_MENU_QUIT),
        onSelectedCallback = PregameQuit,
    }
    quitOption.data = data
    OnHorizontalMenuItemSetup(quitOption, data)
end
function ZO_GameMenu_PreGame_Keyboard:GetScene()
    return self.scene
end
function ZO_GameMenu_PreGame_Keyboard:BuildMenu()
    self.horizontalMenu:Reset()
    -- Server Menu Option
     if DoesPlatformSelectServer() then
        local function OnHideServerSelect()
            self.horizontalMenu:Refresh()
        end
        local function OnShowServerSelect(control)
            ZO_Dialogs_ShowDialog("SERVER_SELECT_DIALOG", { onSelectedCallback = OnHideServerSelect })
        end
        local function GetServerMenuItemName()
            local currentServer = GetCVar("LastPlatform")
            currentServer = ZO_GetLocalizedServerName(currentServer)
            return zo_strformat(SI_GAME_MENU_SERVER, currentServer)
        end
        self.serverSelectControl = self.horizontalMenu:AddMenuItem("ServerSelect", GetServerMenuItemName, OnShowServerSelect, OnHideServerSelect)
    end
    -- Settings Menu Option
    local function OnShowSettings(control)
        PREGAME_SETTINGS_KEYBOARD:SetOnExitCallback(control.data.onUnselectedCallback)
        self.scene:AddFragment(SETTINGS_FRAGMENT)
        self.scene:RemoveFragment(self.gameMenuPregameFragment)
        self.scene:RemoveFragment(LOGIN_BG_FRAGMENT)
        local loginFragment = LOGIN_MANAGER_KEYBOARD:GetRelevantLoginFragment()
        self.scene:RemoveFragment(loginFragment)
    end
    local function OnHideSettings()
        if not IsInGamepadPreferredMode() then
            self.control:SetHidden(false)
        end
        self.scene:RemoveFragment(SETTINGS_FRAGMENT)
        self.scene:AddFragment(self.gameMenuPregameFragment)
        self.scene:AddFragment(LOGIN_BG_FRAGMENT)
        local loginFragment = LOGIN_MANAGER_KEYBOARD:GetRelevantLoginFragment()
        self.scene:AddFragment(loginFragment)
    end
    self.horizontalMenu:AddMenuItem("Settings", GetString(SI_GAME_MENU_SETTINGS), OnShowSettings, OnHideSettings)
    -- Credits Menu Option
    local function OnShowCredits(control)
        self.control:SetHidden(true)
        GAME_CREDITS_KEYBOARD:SetOnExitCallback(control.data.onUnselectedCallback)
        self.scene:AddFragment(GAME_CREDITS_KEYBOARD:GetFragment())
        self.scene:RemoveFragment(LOGIN_BG_FRAGMENT)
        local loginFragment = LOGIN_MANAGER_KEYBOARD:GetRelevantLoginFragment()
        self.scene:RemoveFragment(loginFragment)
    end
    local function OnHideCredits()
        self.control:SetHidden(false)
        self.scene:RemoveFragment(GAME_CREDITS_KEYBOARD:GetFragment())
        self.scene:AddFragment(LOGIN_BG_FRAGMENT)
        local loginFragment = LOGIN_MANAGER_KEYBOARD:GetRelevantLoginFragment()
        self.scene:AddFragment(loginFragment)
    end
    self.horizontalMenu:AddMenuItem("Credits", GetString(SI_GAME_MENU_CREDITS), OnShowCredits, OnHideCredits)
    -- Version Menu Option
    local function OnMouseClickVersion(label)
    end
    
    local function OnMouseEnterVersion(label)
        ZO_SelectableLabel_OnMouseEnter(label)
        InitializeTooltip(InformationTooltip, label, TOPLEFT, 0, -10, BOTTOMLEFT)
        SetTooltipText(InformationTooltip, zo_strformat(SI_VERSION, GetESOFullVersionString()))
    end
    local function OnMouseExitVersion(label)
        ZO_SelectableLabel_OnMouseExit(label)
        ClearTooltip(InformationTooltip)
    end
    local NO_ACTIVATE_FUNCTION = nil
    local NO_DEACTIVATE_FUNCTION = nil
    self.horizontalMenu:AddMenuItem("Version", GetString(SI_VERSION_MENU_ENTRY), OnMouseClickVersion, NO_DEACTIVATE_FUNCTION, OnMouseEnterVersion, OnMouseExitVersion)
end
function ZO_GameMenu_PreGame_Keyboard:IsLoginSceneShowing()
    return not self.control:IsHidden()
end
--Global XML
    GAME_MENU_PREGAME_KEYBOARD = ZO_GameMenu_PreGame_Keyboard:New(self)
end