Back to Home

ESO Lua File v101041

pregame/chapterupgrade/gamepad/chapterupgrade_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
local ChapterUpgrade_Gamepad = ZO_ChapterUpgrade_Shared:Subclass()
function ChapterUpgrade_Gamepad:New(...)
    return ZO_ChapterUpgrade_Shared.New(self, ...)
end
function ChapterUpgrade_Gamepad:Initialize(control)
    ZO_ChapterUpgrade_Shared.Initialize(self, control, "chapterUpgradeGamepad")
    self.focus = ZO_GamepadFocus:New(control, nil, MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL)
    self.headerNarrationFunction = function()
        local narrations = {}
        local _, registrationSummary, chapterSummaryHeader, chapterSummary = GetCurrentChapterRegistrationInfo()
        ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(chapterSummaryHeader))
        ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(chapterSummary))
        ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_CHAPTER_UPGRADE_REGISTRATION_SUMMARY_HEADER)))
        ZO_AppendNarration(narrations, SCREEN_NARRATION_MANAGER:CreateNarratableObject(registrationSummary))
        return narrations
    end
    
    local enterCodeButton = control:GetNamedChild("EnterCodeButton")
    if ZO_PLATFORM_ALLOWS_CHAPTER_CODE_ENTRY[GetPlatformServiceType()] then
        enterCodeButton:SetHidden(false)
        local enterCodeButtonFocusData = 
        {
            highlight = enterCodeButton:GetNamedChild("Highlight"),
            control = enterCodeButton,
            callback = function() self:EnterCodeButtonClicked() end,
            activate = function() SCREEN_NARRATION_MANAGER:QueueFocus(self.focus) end,
            narrationText = function() return SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_CHAPTER_UPGRADE_ENTER_CODE_BUTTON)) end,
        }
        self.focus:AddEntry(enterCodeButtonFocusData)
    else
        enterCodeButton:SetHidden(true)
    end
    local upgradeButton = control:GetNamedChild("UpgradeButton")
    local upgradeButtonFocusData = 
    {
        highlight = upgradeButton:GetNamedChild("Highlight"),
        control = upgradeButton,
        callback = function() self:UpgradeButtonClicked() end,
        activate = function() SCREEN_NARRATION_MANAGER:QueueFocus(self.focus) end,
        narrationText = function() return SCREEN_NARRATION_MANAGER:CreateNarratableObject(GetString(SI_CHAPTER_UPGRADE_PURCHASE_BUTTON)) end,
    }
    
    self.focus:AddEntry(upgradeButtonFocusData)
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            keybind = "UI_SHORTCUT_PRIMARY",
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            callback = function()
                local selection = self.focus:GetFocusItem()
                if selection and selection.callback then
                    selection.callback()
                end
            end,
        },
        {
            keybind = "UI_SHORTCUT_NEGATIVE",
            name = GetString(SI_CHAPTER_UPGRADE_CONTINUE),
            callback = function()
                self:ShowContinueDialog()
            end,
        },
    }
    --Re-narrate the current focus upon closing dialogs
    CALLBACK_MANAGER:RegisterCallback("AllDialogsHidden", function()
        if self.focus:IsActive() then
            local NARRATE_HEADER = true
            SCREEN_NARRATION_MANAGER:QueueFocus(self.focus, NARRATE_HEADER)
        end
    end)
end
function ChapterUpgrade_Gamepad:UpgradeButtonClicked()
    local IS_STANDARD_EDITION = false
    local serviceType = GetPlatformServiceType()
    local SHOW_LOGOUT_WARNING = serviceType ~= PLATFORM_SERVICE_TYPE_EPIC
    ZO_ShowChapterUpgradePlatformDialog(IS_STANDARD_EDITION, CHAPTER_UPGRADE_SOURCE_PREGAME, SHOW_LOGOUT_WARNING)
end
function ChapterUpgrade_Gamepad:EnterCodeButtonClicked()
    if IsConsoleUI() then
        ZO_Dialogs_ShowGamepadDialog("SHOW_REDEEM_CODE_CONSOLE")
    else
        ZO_Dialogs_ShowGamepadDialog("SHOW_REDEEM_CODE")
    end
end
function ChapterUpgrade_Gamepad:OnShowing()
    ZO_ChapterUpgrade_Shared.OnShowing(self)
    KEYBIND_STRIP:RemoveDefaultExit()
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    self.focus:Activate()
    local NARRATE_HEADER = true
    SCREEN_NARRATION_MANAGER:QueueFocus(self.focus, NARRATE_HEADER)
end
function ChapterUpgrade_Gamepad:OnHiding()
    ZO_ChapterUpgrade_Shared.OnHiding(self)
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    KEYBIND_STRIP:RestoreDefaultExit()
    self.focus:Deactivate()
end
    CHAPTER_UPGRADE_SCREEN_GAMEPAD = ChapterUpgrade_Gamepad:New(control)
end