Back to Home

ESO Lua File v101043

pregame/accountlogin/gamepad/pegi_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
ZO_PEGIAgreement_Gamepad = ZO_InitializingObject:Subclass()
function ZO_PEGIAgreement_Gamepad:Initialize(control)
    ZO_Dialogs_RegisterCustomDialog("PEGI_COUNTRY_SELECT_GAMEPAD",
    {
        mustChoose = true,
        canQueue = true,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
            allowRightStickPassThrough = true,
        },
        title =
        {
            text = SI_PEGI_COUNTRY_SELECT_TITLE,
        },
        setup = function(dialog)
            local parametricListEntries = dialog.info.parametricList
            ZO_ClearNumericallyIndexedTable(parametricListEntries)
            dialog.dropdowns = {}
            local countrySelectDropdown =
            {
                template = "ZO_GamepadDropdownItem",
                entryData = self:GetOrCreateCountrySelectDropdownEntryData(),
            }
            table.insert(parametricListEntries, countrySelectDropdown)
            local submitButton =
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                entryData = self:AddSubmitEntry(),
            }
            table.insert(parametricListEntries, submitButton)
            SCENE_MANAGER:AddFragment(KEYBIND_STRIP_GAMEPAD_BACKDROP_FRAGMENT)
            SCENE_MANAGER:AddFragment(KEYBIND_STRIP_GAMEPAD_FRAGMENT)
            dialog:setupFunc()
        end,
        parametricList = {}, -- Generated dynamically
        blockDialogReleaseOnPress = true, -- We need to manually control when we release so we can use the select keybind to activate entries
        parametricListOnSelectionChangedCallback = function(dialog, list, newSelectedData, oldSelectedData)
            if not newSelectedData.isSubmit then
                ZO_GenericGamepadDialog_HideTooltip(dialog)
            end
        end,
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_DIALOG_CONFIRM,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData and targetData.callback then
                        targetData.callback(dialog)
                    end 
                end,
            },
            {
                keyind = "DIALOG_NEGATIVE",
                text = SI_PEGI_COUNTRY_SELECT_BACK,
                callback = function(dialog)
                    ZO_Disconnect()
                end,
            }
        }
    })
    self.countryToRatingsBoard = {}
    self.countriesPopulated = false
end
do
    local countrySelectDropdownEntryData
    function ZO_PEGIAgreement_Gamepad:GetOrCreateCountrySelectDropdownEntryData()
        if countrySelectDropdownEntryData == nil then
            countrySelectDropdownEntryData = ZO_GamepadEntryData:New()
            countrySelectDropdownEntryData.dropdownEntry = true
            countrySelectDropdownEntryData.setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                local dropdown = control.dropdown
                dropdown:SetSortsItems(false)
                dropdown:ClearItems()
                table.insert(data.dialog.dropdowns, dropdown)
                countrySelectDropdownEntryData.callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    local targetControl = dialog.entryList:GetTargetControl()
                    if targetData.dropdownEntry then
                        local dropdown = targetControl.dropdown
                        dropdown:Activate()
                    end
                end
                local entries = {}
                do
                    local function OnItemSelected()
                        self.currentSelectedCountry = nil
                        self.currentSelectedIndex = 0
                    end
                    entries[0] = dropdown:CreateItemEntry(GetString(SI_PEGI_COUNTRY_SELECT_TITLE), OnItemSelected)
                    dropdown:AddItem(entries[0])
                end
                for i = 1, GetNumCountries() do
                    local countryName, _, ratingsBoard = GetCountryDataForIndex(i)
                    local function OnItemSelected()
                        self.currentSelectedCountry = countryName
                        self.currentSelectedIndex = i
                    end
                    self.countryToRatingsBoard[countryName] = ratingsBoard
                    entries[i] = dropdown:CreateItemEntry(countryName or "", OnItemSelected)
                    dropdown:AddItem(entries[i])
                end
                SCREEN_NARRATION_MANAGER:RegisterDialogDropdown(data.dialog, dropdown)
                dropdown:UpdateItems()
                local IGNORE_CALLBACK = true
                dropdown:TrySelectItemByData(entries[self.currentSelectedIndex or 0], IGNORE_CALLBACK)
            end
            countrySelectDropdownEntryData.narrationText = ZO_GetDefaultParametricListDropdownNarrationText
        end
        return countrySelectDropdownEntryData
    end
end
function ZO_PEGIAgreement_Gamepad:AddSubmitEntry()
    local submitEntryData = ZO_GamepadEntryData:New(GetString(SI_PEGI_COUNTRY_SELECT_SUBMIT_GAMEPAD))
    submitEntryData.isSubmit = true
    submitEntryData.callback = function(dialog)
        if self.currentSelectedCountry then
            self:OnCountrySelectionConfirmed()
        else
            GAMEPAD_TOOLTIPS:LayoutTextBlockTooltip(GAMEPAD_LEFT_DIALOG_TOOLTIP, GetString(SI_PEGI_COUNTRY_SELECT_NO_SELECTION_GAMEPAD))
            ZO_GenericGamepadDialog_ShowTooltip(dialog)
            SCREEN_NARRATION_MANAGER:QueueDialog(dialog)
        end
    end
    submitEntryData.setup = ZO_SharedGamepadEntry_OnSetup
    submitEntryData.narrationTooltip = GAMEPAD_LEFT_DIALOG_TOOLTIP
    return submitEntryData
end
function ZO_PEGIAgreement_Gamepad:OnCountrySelectionConfirmed()
    local selectedCountry = self.currentSelectedCountry
    if self.countryToRatingsBoard[selectedCountry] == RATINGS_BOARD_PEGI then
        ZO_Dialogs_ShowGamepadDialog("PEGI_AGREEMENT_GAMEPAD")
        ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_COUNTRY_SELECT_GAMEPAD")
    else
        AgreeToPEGI()
        ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_COUNTRY_SELECT_GAMEPAD")
        if PregameStateManager_GetCurrentState() == "CharacterSelect" then
            Pregame_ShowScene("gamepadCharacterSelect")
        elseif PregameStateManager_GetCurrentState() == "CharacterCreate" then
            Pregame_ShowScene("gamepadCharacterCreate")
        end
    end
end
    ZO_Dialogs_RegisterCustomDialog("PEGI_AGREEMENT_GAMEPAD",
    {
        customControl = control,
        mustChoose = true,
        canQueue = true,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.CUSTOM,
        },
        title =
        {
            text = SI_PEGI_AGREEMENT_TITLE,
        },
        mainText =
        {
            text = SI_PEGI_AGREEMENT_TEXT,
        },
        buttons =
        {
            {
                text = SI_DIALOG_ACCEPT,
                callback = function(dialog)
                    AgreeToPEGI()
                    ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_AGREEMENT_GAMEPAD")
                    if PregameStateManager_GetCurrentState() == "CharacterSelect" then
                        Pregame_ShowScene("gamepadCharacterSelect")
                    elseif PregameStateManager_GetCurrentState() == "CharacterCreate" then
                        Pregame_ShowScene("gamepadCharacterCreate")
                    end
                end,
            },
            {
                text = SI_DIALOG_DECLINE,
                callback = function(dialog)
                    ZO_Dialogs_ShowGamepadDialog("PEGI_AGREEMENT_DECLINED_GAMEPAD")
                    ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_AGREEMENT_GAMEPAD")
                end,
            },
        },
    })
end
    ZO_Dialogs_RegisterCustomDialog("PEGI_AGREEMENT_DECLINED_GAMEPAD",
    {
        customControl = control,
        mustChoose = true,
        canQueue = true,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.CUSTOM,
        },
        title =
        {
            text = SI_PEGI_AGREEMENT_DECLINE_TITLE,
        },
        mainText =
        {
            text = SI_PEGI_AGREEMENT_DECLINE_TEXT_GAMEPAD,
        },
        baseNarrationTooltip = GAMEPAD_LEFT_DIALOG_TOOLTIP,
        OnShownCallback = function(dialog)
            local colorizedLinkText = ZO_URL_LINK_COLOR:Colorize(GetString("SI_APPROVEDURLTYPE", APPROVED_URL_ESO_HELP))
            GAMEPAD_TOOLTIPS:LayoutTitleAndDescriptionTooltip(GAMEPAD_LEFT_DIALOG_TOOLTIP, GetString(SI_PEGI_AGREEMENT_CUSTOMER_SERVICE), colorizedLinkText)
            ZO_GenericGamepadDialog_ShowTooltip(dialog)
        end,
        buttons =
        {
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_BACK_UP_ONE_MENU,
                callback = function(dialog)
                    ZO_Dialogs_ShowGamepadDialog("PEGI_AGREEMENT_GAMEPAD")
                    ZO_GenericGamepadDialog_HideTooltip(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_AGREEMENT_DECLINED_GAMEPAD")
                end,
            },
            {
                keybind = "DIALOG_SECONDARY",
                text = SI_PEGI_AGREEMENT_OPEN_URL,
                callback = function(dialog)
                    OpenURLByType(APPROVED_URL_ESO_HELP)
                    ZO_Dialogs_ShowGamepadDialog("PEGI_COUNTRY_SELECT_GAMEPAD")
                    ZO_GenericGamepadDialog_HideTooltip(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("PEGI_AGREEMENT_DECLINED_GAMEPAD")
                end,
            },
        },
    })
end
PEGI_AGREEMENT_GAMEPAD = ZO_PEGIAgreement_Gamepad:New()