Back to Home

ESO Lua File v101037

pregame/settings/keyboard/pregame_settings_keyboard.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
--------------------------------
-- ZO_Pregame_Settings_Keyboard
--------------------------------
ZO_Pregame_Settings_Keyboard = ZO_Object:Subclass()
function ZO_Pregame_Settings_Keyboard:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_Pregame_Settings_Keyboard:Initialize(control)
    self.control = control
    local subcategoriesMenuControl = control:GetNamedChild("Subcategory")
    self.subcategoriesMenu = ZO_Horizontal_Menu:New(subcategoriesMenuControl, ZO_HORIZONAL_MENU_ALIGN_CENTER)
    subcategoriesMenuControl:SetAnchor(BOTTOM, ZO_OptionsWindow:GetNamedChild("Divider"), TOP, -125)
    SETTINGS_FRAGMENT = ZO_FadeSceneFragment:New(control)
    SETTINGS_FRAGMENT:RegisterCallback("StateChange",   function(oldState, newState)
                                                            if newState == SCENE_FRAGMENT_SHOWING then
                                                                self:ShowSettings()
                                                            elseif newState == SCENE_FRAGMENT_HIDDEN then
                                                                self:HideSettings()
                                                            end
                                                        end)
    local function OnHorizontalMenuItemSetup(menuControl, data)
        menuControl:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
        local name = data.name
        if type(data.name) == "function" then
            name = data.name()
        end
        menuControl:SetText(name)
    end
    local HORIZONTAL_SPACING = 30
    self.subcategoriesMenu:AddTemplate("ZO_Pregame_Settings_Keyboard_Subcategory_Label", OnHorizontalMenuItemSetup, HORIZONTAL_SPACING)
end
function ZO_Pregame_Settings_Keyboard:UpdateSettingsDisplay(isShown)
    local optionsBackground = ZO_OptionsWindow:GetNamedChild("BGLeft")
    local optionsTitle = ZO_OptionsWindow:GetNamedChild("Title")
    optionsBackground:SetHidden(isShown)
    optionsTitle:SetHidden(isShown)
end
function ZO_Pregame_Settings_Keyboard:BuildSubcategoriesMenu()
    if not self.isSubcategoriesMenuBuilt then
        self.settingsCategories = ZO_GameMenuManager_GetVisibleSettingsEntries()
        for i, subcategory in ipairs(self.settingsCategories) do
            local function OnSelectionCallback(control)
                subcategory.callback(control, ZO_ReanchorControlTopHorizontalMenu)
            end
            self.subcategoriesMenu:AddMenuItem(subcategory.name, subcategory.name, OnSelectionCallback, subcategory.unselectedCallback)
        end
        self.isSubcategoriesMenuBuilt = true
    end
end
function ZO_Pregame_Settings_Keyboard:ShowSettings()
    -- Select first sub category by default when showing settings
    if #self.settingsCategories > 0 then
        self.subcategoriesMenu:SetSelectedByIndex(1)
    end
    local SHOW_SETTINGS = true
    self:UpdateSettingsDisplay(SHOW_SETTINGS)
end
function ZO_Pregame_Settings_Keyboard:SetOnExitCallback(onExitCallback)
end
function ZO_Pregame_Settings_Keyboard:HideSettings()
    self.subcategoriesMenu:SetSelectedByIndex(nil)
    local HIDE_SETTINGS = false
    self:UpdateSettingsDisplay(HIDE_SETTINGS)
    if self.onExitCallback then
        self.onExitCallback()
    end
end
-- Global XML
    PREGAME_SETTINGS_KEYBOARD = ZO_Pregame_Settings_Keyboard:New(control)
end
    if upInside then
        PREGAME_SETTINGS_KEYBOARD.subcategoriesMenu:SetSelectedByIndex(self.data.index)
    end
end
    if upInside then
        PREGAME_SETTINGS_KEYBOARD:HideSettings()
    end
end