Back to Home

ESO Lua File v101036

ingame/help/gamepad/help_root_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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
local GAMEPAD_UNSTUCK_CONFIRM_DIALOG = "GAMEPAD_UNSTUCK_CONFIRM_DIALOG"
local GAMEPAD_UNSTUCK_COOLDOWN_DIALOG = "GAMEPAD_UNSTUCK_COOLDOWN_DIALOG"
local GAMEPAD_UNSTUCK_LOADING_DIALOG = "GAMEPAD_UNSTUCK_LOADING_DIALOG"
local GAMEPAD_UNSTUCK_ERROR_ALREADY_IN_PROGRESS_DIALOG = "GAMEPAD_UNSTUCK_ERROR_ALREADY_IN_PROGRESS_DIALOG"
local GAMEPAD_UNSTUCK_ERROR_INVALID_LOCATION_DIALOG = "GAMEPAD_UNSTUCK_ERROR_INVALID_LOCATION_DIALOG"
local GAMEPAD_UNSTUCK_ERROR_IN_COMBAT_DIALOG = "GAMEPAD_UNSTUCK_ERROR_IN_COMBAT_DIALOG"
local GAMEPAD_CS_DISABLED_ON_PC_DIALOG = "GAMEPAD_CS_DISABLED_ON_PC_DIALOG"
local ZO_Help_Root_Gamepad = ZO_Object.MultiSubclass(ZO_Gamepad_ParametricList_Screen, ZO_Stuck_Base)
function ZO_Help_Root_Gamepad:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_Help_Root_Gamepad:Initialize(control)
    HELP_ROOT_GAMEPAD_SCENE = ZO_Scene:New("helpRootGamepad", SCENE_MANAGER)
    ZO_Gamepad_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, nil, HELP_ROOT_GAMEPAD_SCENE)
    ZO_Stuck_Base.Initialize(self)
    local helpRootFragment = ZO_FadeSceneFragment:New(control)
    HELP_ROOT_GAMEPAD_SCENE:AddFragment(helpRootFragment)
    self.headerData = {
        titleText = GetString(SI_MAIN_MENU_HELP),
        messageText = GetString(SI_GAMEPAD_HELP_ROOT_HEADER),
    }
    local headerMessageControl = control:GetNamedChild("Mask"):GetNamedChild("Container"):GetNamedChild("HeaderContainer"):GetNamedChild("Header"):GetNamedChild("Message")
    headerMessageControl:SetFont("ZoFontGamepadCondensed42")
    local websiteText = CreateControlFromVirtual("$(parent)HelpWebsite", control, "ZO_Gamepad_HelpWebsiteTemplate")
    websiteText:SetParent(self.header)
    local websiteAnchor = ZO_Anchor:New(TOP, headerMessageControl, BOTTOM, 0, 55)
    websiteAnchor:AddToControl(websiteText)
    
    local list = self:GetMainList()
    self.stuckComplete = false
end
function ZO_Help_Root_Gamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Select
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                    local targetData = self:GetMainList():GetTargetData()
                    local destination = targetData.destination
                    local destinationName = type(destination) == "function" and destination() or destination
                    if targetData.isDialog then
                        ZO_Dialogs_ShowGamepadDialog(destinationName)
                    else
                        SCENE_MANAGER:Push(destinationName)
                    end
                end,
        },
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.keybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
end
--Overridden from base
function ZO_Help_Root_Gamepad:GetHeaderNarration()
    local narration = ZO_Gamepad_ParametricList_Screen.GetHeaderNarration(self)
    --TODO XAR: Look into potentially giving this its own narratable object
    narration:AddNarrationText(GetString(SI_GAMEPAD_HELP_WEBSITE))
    return narration
end
-- stuck event handling
function ZO_Help_Root_Gamepad:OnPlayerActivated()
    if IsStuckFixPending() then
        ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_LOADING_DIALOG)
    end
end
function ZO_Help_Root_Gamepad:OnStuckBegin()
    ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_LOADING_DIALOG)
end
function ZO_Help_Root_Gamepad:OnStuckCanceled()
    self.stuckComplete = true
end
function ZO_Help_Root_Gamepad:OnStuckComplete()
    self.stuckComplete = true
end
function ZO_Help_Root_Gamepad:OnStuckErrorAlreadyInProgress()
    ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_ERROR_ALREADY_IN_PROGRESS_DIALOG)
end
function ZO_Help_Root_Gamepad:OnStuckErrorInvalidLocation()
    ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_ERROR_INVALID_LOCATION_DIALOG)
end
function ZO_Help_Root_Gamepad:OnStuckErrorInCombat()
    ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_ERROR_IN_COMBAT_DIALOG)
end
function ZO_Help_Root_Gamepad:OnStuckErrorOnCooldown()
    -- handled by dialogs
end
function ZO_Help_Root_Gamepad:OnShowing()
    ZO_Gamepad_ParametricList_Screen.OnShowing(self)
    self.stuckComplete = false
end
function ZO_Help_Root_Gamepad:InitializeDialogs()
    self:InitializeUnstuckErrorDialog(GAMEPAD_UNSTUCK_ERROR_ALREADY_IN_PROGRESS_DIALOG, SI_STUCK_ERROR_ALREADY_IN_PROGRESS)
    self:InitializeUnstuckErrorDialog(GAMEPAD_UNSTUCK_ERROR_INVALID_LOCATION_DIALOG, SI_GAMEPAD_HELP_UNSTUCK_ERROR_INVALID_STUCK_LOCATION)
    self:InitializeUnstuckErrorDialog(GAMEPAD_UNSTUCK_ERROR_IN_COMBAT_DIALOG, SI_GAMEPAD_HELP_UNSTUCK_ERROR_IN_COMBAT)
end
function ZO_Help_Root_Gamepad:InitializeUnstuckConfirmDialog()
    ZO_Dialogs_RegisterCustomDialog(GAMEPAD_UNSTUCK_CONFIRM_DIALOG,
    {
        canQueue = true,
        mustChoose = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.BASIC,
        },
        title =
        {
            text = SI_GAMEPAD_HELP_GET_ME_UNSTUCK,
        },
        mainText = 
        {
            text = function()
                local cost = zo_min(GetRecallCost(), GetCurrencyAmount(CURT_MONEY, CURRENCY_LOCATION_CHARACTER))
                local goldIcon = ZO_Currency_GetGamepadFormattedCurrencyIcon(CURT_MONEY)
                local primaryButtonMarkup = ZO_WHITE:Colorize(ZO_Keybindings_GetHighestPriorityBindingStringFromAction("UI_SHORTCUT_PRIMARY", KEYBIND_TEXT_OPTIONS_FULL_NAME, KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP))
                local text
                if DoesCurrentZoneHaveTelvarStoneBehavior() then
                    local telvarLossPercentage = zo_floor(GetTelvarStonePercentLossOnNonPvpDeath() * 100)
                    text = zo_strformat(SI_GAMEPAD_HELP_UNSTUCK_CONFIRM_STUCK_PROMPT_TELVAR, cost, goldIcon, primaryButtonMarkup, telvarLossPercentage)
                elseif IsActiveWorldBattleground() then
                    text = GetString(SI_CUSTOMER_SERVICE_UNSTUCK_COST_PROMPT_IN_BATTLEGROUND)
                else
                    text = zo_strformat(SI_GAMEPAD_HELP_UNSTUCK_CONFIRM_STUCK_PROMPT, cost, goldIcon, primaryButtonMarkup)
                end
                return text
            end,
        },
       
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_DIALOG_ACCEPT,
                callback = function()
                    SendPlayerStuck()
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
            },
        }
    })
end
function ZO_Help_Root_Gamepad:InitializeUnstuckCooldownDialog()
    ZO_Dialogs_RegisterCustomDialog(GAMEPAD_UNSTUCK_COOLDOWN_DIALOG,
    {
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.COOLDOWN,
        },
        setup = function(dialog)
            dialog:setupFunc()
        end,
        updateFn = function(dialog)
            local cooldownTime = GetTimeUntilStuckAvailable()
            if cooldownTime > 0 then
                dialog.cooldownLabelControl:SetText(ZO_FormatTimeMilliseconds(cooldownTime, TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT_SHOW_ZERO_SECS, TIME_FORMAT_PRECISION_SECONDS))
            elseif not ZO_Dialogs_IsDialogHiding(GAMEPAD_UNSTUCK_COOLDOWN_DIALOG) then
                ZO_Dialogs_ShowGamepadDialog(GAMEPAD_UNSTUCK_CONFIRM_DIALOG)
                ZO_Dialogs_ReleaseDialogOnButtonPress(GAMEPAD_UNSTUCK_COOLDOWN_DIALOG)
            end
        end,
        title =
        {
            text = GetString(SI_GAMEPAD_HELP_GET_ME_UNSTUCK),
        },
        mainText =
        {
            text = GetString(SI_GAMEPAD_HELP_UNSTUCK_COOLDOWN_HEADER),
        },
        loading =
        {
            text = function()
                return ZO_FormatTimeMilliseconds(GetTimeUntilStuckAvailable(), TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT_SHOW_ZERO_SECS, TIME_FORMAT_PRECISION_SECONDS)
            end,
        },
       
        buttons =
        {
            {
                keybind = "DIALOG_NEGATIVE",
                text = GetString(SI_DIALOG_EXIT),
            },
        }
    })
end
function ZO_Help_Root_Gamepad:InitializeUnstuckLoadingDialog()
    ZO_Dialogs_RegisterCustomDialog(GAMEPAD_UNSTUCK_LOADING_DIALOG,
    {
        canQueue = true,
        blockDialogReleaseOnPress = true, 
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.COOLDOWN,
        },
        setup = function(dialog)
            dialog:setupFunc()
        end,
        updateFn = function()
            if self.stuckComplete then
                ZO_Dialogs_ReleaseDialogOnButtonPress(GAMEPAD_UNSTUCK_LOADING_DIALOG)
                self.stuckComplete = false
                SCENE_MANAGER:ShowBaseScene()
            end
        end,
        title =
        {
            text = GetString(SI_GAMEPAD_HELP_GET_ME_UNSTUCK),
        },
        loading =
        {
           text = GetString(SI_FIXING_STUCK_TEXT),
        },
       
        buttons =
        {
        },
        mustChoose = true,
    })
end
function ZO_Help_Root_Gamepad:InitializeUnstuckErrorDialog(dialogName, dialogText)
    ZO_Dialogs_RegisterCustomDialog(dialogName,
    {
        canQueue = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.BASIC,
        },
        title =
        {
            text = SI_GAMEPAD_HELP_GET_ME_UNSTUCK,
        },
        mainText =
        {
            text = dialogText,
        },
       
        buttons =
        {
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_EXIT,
            },
        }
    })
end
function ZO_Help_Root_Gamepad:InitializeCSDisabledDialog()
    ZO_Dialogs_RegisterCustomDialog(GAMEPAD_CS_DISABLED_ON_PC_DIALOG,
    {
        canQueue = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.BASIC,
        },
        title =
        {
            text = GetString(SI_GAMEPAD_HELP_CS_DISABLED_TITLE),
        },
        mainText = 
        {
            text = GetString(SI_GAMEPAD_HELP_CS_DISABLED_TEXT),
        },
       
        buttons =
        {
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_EXIT,
            },
        }
    })
end
do
    local IS_DIALOG = true
    local IS_SCENE = false
    
    local function AddEntry(list, name, icon, destination, isDialog)
        local data = ZO_GamepadEntryData:New(GetString(name), icon)
        data:SetIconTintOnSelection(true)
        data.destination = destination
        data.isDialog = isDialog
        list:AddEntry("ZO_GamepadMenuEntryTemplate", data)
    end
    local function UnstuckDialogNameCallback()
        if GetTimeUntilStuckAvailable() > 0 then
            return GAMEPAD_UNSTUCK_COOLDOWN_DIALOG
        else
            return GAMEPAD_UNSTUCK_CONFIRM_DIALOG
        end
    end
    function ZO_Help_Root_Gamepad:PopulateList()
        local list = self:GetMainList()
        list:Clear()
        AddEntry(list, SI_GAMEPAD_HELP_CUSTOMER_SERVICE, "EsoUI/Art/Notifications/Gamepad/gp_notification_cs.dds", "helpCustomerServiceGamepad", IS_SCENE)
        AddEntry(list, SI_GAMEPAD_HELP_GET_ME_UNSTUCK, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_unstuck.dds", UnstuckDialogNameCallback, IS_DIALOG)
        AddEntry(list, SI_HELP_TUTORIALS, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_tutorial.dds", "helpTutorialsCategoriesGamepad", IS_SCENE)
        AddEntry(list, SI_GAMEPAD_HELP_LEGAL_MENU, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_terms.dds", "helpLegalDocsGamepad", IS_SCENE)
        if IsSubmitFeedbackSupported() then
            AddEntry(list, SI_CUSTOMER_SERVICE_SUBMIT_FEEDBACK, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_submitFeedback.dds", "helpSubmitFeedbackGamepad", IS_SCENE)
        end
        AddEntry(list, SI_CUSTOMER_SERVICE_QUEST_ASSISTANCE, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_quests.dds", "helpQuestAssistanceGamepad", IS_SCENE)
        AddEntry(list, SI_CUSTOMER_SERVICE_ITEM_ASSISTANCE, "EsoUI/Art/MenuBar/Gamepad/gp_playerMenu_icon_inventory.dds", "helpItemAssistanceGamepad", IS_SCENE)
        
        list:Commit()
    end
end
function ZO_Help_Root_Gamepad:PerformUpdate()
    self:PopulateList()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    self.headerData.titleText = GetString(SI_MAIN_MENU_HELP)
    self.headerData.messageText = GetString(SI_GAMEPAD_HELP_ROOT_HEADER)
    self.dirty = false
end
-- XML Functions
    HELP_ROOT_GAMEPAD = ZO_Help_Root_Gamepad:New(control)
    SYSTEMS:RegisterGamepadObject(ZO_STUCK_NAME, HELP_ROOT_GAMEPAD)
end