Back to Home

ESO Lua File v101036

pregameandingame/optionspanels/gamepad/optionspanel_account_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
ZO_OptionsGamepad_EmailEditor = ZO_Object:Subclass()
function ZO_OptionsGamepad_EmailEditor:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_OptionsGamepad_EmailEditor:Initialize(control)
    local function ReleaseDialog()
        GAMEPAD_TOOLTIPS:Reset(GAMEPAD_LEFT_TOOLTIP)
        ZO_Dialogs_ReleaseDialogOnButtonPress("ZO_OPTIONS_GAMEPAD_EDIT_EMAIL_DIALOG")
    end
    ZO_Dialogs_RegisterCustomDialog("ZO_OPTIONS_GAMEPAD_EDIT_EMAIL_DIALOG",
    {
        blockDialogReleaseOnPress = true,
        canQueue = true,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
            allowRightStickPassThrough = true,
        },
        setup = function(dialog, data)
            self.enteredText = ""
            if ZO_IsPlaystationPlatform() then
                local params = {
                    "DIALOG_TERTIARY",
                }
                local keybindIndex = 1
                GAMEPAD_TOOLTIPS:LayoutKeybindTextBlockTooltip(GAMEPAD_LEFT_TOOLTIP, SI_GAMEPAD_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_TOOLTIP_PLAYSTATION, params, keybindIndex)
            else
                local params = {
                    "DIALOG_TERTIARY",
                    ZO_GetPlatformStoreName(),
                }
                local keybindIndex = 1
                GAMEPAD_TOOLTIPS:LayoutKeybindTextBlockTooltip(GAMEPAD_LEFT_TOOLTIP, SI_GAMEPAD_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_TOOLTIP, params, keybindIndex)
            end
            dialog.info.finishedCallback = data.finishedCallback
            dialog:setupFunc()
        end,
        title =
        {
            text = SI_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_TITLE,
        },
        mainText =
        {
            text = ""
        },
        parametricList =
        {
            -- Text Entry
            {
                template = "ZO_Gamepad_GenericDialog_Parametric_TextFieldItem",
                headerTemplate = "ZO_GamepadMenuEntryFullWidthHeaderTemplate",
                header = GetString(SI_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_ENTRY_TITLE),
                templateData =
                {
                    textChangedCallback = function(control)
                        local enteredText= control:GetText()
                        self.enteredText = enteredText
                    end,
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        control.highlight:SetHidden(not selected)
 
                        control.editBoxControl.textChangedCallback = data.textChangedCallback
                        data.control = control
 
                        control.editBoxControl:SetDefaultText(GetString(SI_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_ENTRY_DEFAULT))
                        control.editBoxControl:SetMaxInputChars(MAX_EMAIL_LENGTH)
                        if self.enteredText then
                            control.editBoxControl:SetText(self.enteredText)
                        end
                    end,
                    callback = function(dialog)
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.editBoxControl:TakeFocus()
                    end,
                    narrationText = ZO_GetDefaultParametricListEditBoxNarrationText,
                    narrationTooltip = GAMEPAD_LEFT_TOOLTIP,
                },
            },
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData =
                {
                    text = GetString(SI_GAMEPAD_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_ACTION),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    callback = function(dialog)
                        SetSecureSetting(SETTING_TYPE_ACCOUNT, ACCOUNT_SETTING_ACCOUNT_EMAIL, self.enteredText)
                        ReleaseDialog()
                    end,
                },
            },
        },
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback =  function(dialog)
                    local data = dialog.entryList:GetTargetData()
                    data.callback(dialog)
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
                callback = function(dialog)
                    ReleaseDialog()
                end,
            },
            {
                keybind = "DIALOG_TERTIARY",
                text = SI_GAMEPAD_INTERFACE_OPTIONS_ACCOUNT_EMAIL_DIALOG_AUTOFILL,
                visible = function(dialog)
                    local data = dialog.entryList:GetTargetData()
                    return data.control and data.control.editBoxControl or false
                end,
                callback = function(dialog)
                    local targetControl = dialog.entryList:GetTargetControl()
                    self.enteredText = GetUserEmailAddress()
                    targetControl.editBoxControl:SetText(self.enteredText)
                end,
            },
        },
    })
end
EMAIL_EDITOR_GAMEPAD = ZO_OptionsGamepad_EmailEditor:New()