Back to Home

ESO Lua File v100028

ingame/guildfinder/gamepad/guildrecruitment_applications_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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
------------------
-- Guild Finder --
------------------
ZO_GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD_NAME_COLUMN_SIZE = 405
ZO_GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD_CHAMPION_POINTS_COLUMN_SIZE = 150
ZO_GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD_EXPIRATION_COLUMN_SIZE = 150
ZO_GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD_ENTRY_HEIGHT = 64
ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_ACCEPT_DIALOG_NAME = "GAMEPAD_CONFIRM_ACCEPT_APPLICATION_PROMPT"
ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_DECLINE_DIALOG_NAME = "GAMEPAD_CONFIRM_DECLINE_APPLICATION_PROMPT"
ZO_GUILD_RECRUITMENT_GAMEPAD_OPTIONS_DIALOG_NAME = "GAMEPAD_APPLICATION_OPTIONS_PROMPT"
ZO_GuildRecruitment_Applications_Gamepad = ZO_Object.MultiSubclass(ZO_GuildRecruitment_ApplicationsList_Shared, ZO_GuildRecruitment_Panel_Shared, ZO_GuildFinder_ListPanel_GamepadBehavior)
function ZO_GuildRecruitment_Applications_Gamepad:New(...)
    return ZO_GuildFinder_ListPanel_GamepadBehavior.New(self, ...)
end
function ZO_GuildRecruitment_Applications_Gamepad:Initialize(control)
    ZO_GuildRecruitment_ApplicationsList_Shared.Initialize(self, control)
    ZO_GuildRecruitment_Panel_Shared.Initialize(self, control)
    ZO_GuildFinder_ListPanel_GamepadBehavior.Initialize(self, control)
    local function SetupRow(control, data)
        data.iconSize = 40
        self:SetupRow(control, data)
    end
    ZO_ScrollList_AddDataType(self.list, ZO_GUILD_FINDER_APPLICATION_ENTRY_TYPE, "ZO_GuildRecruitment_Applications_Row_Gamepad", ZO_GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD_ENTRY_HEIGHT, SetupRow)
    ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
    self:SetEmptyText(GetString(SI_GUILD_RECRUITMENT_APPLICATIONS_EMPTY_LIST_TEXT));
    self:SetupSort(ZO_GUILD_RECRUITMENT_APPLICATIONS_ENTRY_SORT_KEYS, "durationS", ZO_SORT_ORDER_DOWN)
    self.onGuildPermissionChangedCallback = nil
end
function ZO_GuildRecruitment_Applications_Gamepad:SetupRow(control, data)
    ZO_GuildRecruitment_ApplicationsList_Shared.SetupRow(self, control, data)
    local nameLabel = control:GetNamedChild("Name")
end
function ZO_GuildRecruitment_Applications_Gamepad:OnSelectionChanged(previousData, selectedData)
    GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_RIGHT_TOOLTIP)
    if selectedData then
        GAMEPAD_TOOLTIPS:LayoutGuildApplicationDetails(GAMEPAD_RIGHT_TOOLTIP, selectedData)
    end
end
function ZO_GuildRecruitment_Applications_Gamepad:InitializeKeybinds()
    ZO_GuildFinder_ListPanel_GamepadBehavior.InitializeKeybinds(self)
    table.insert(self.keybindStripDescriptor,
        -- Accept Application
        {
            name = GetString(SI_GUILD_RECRUITMENT_APPLICATION_ACCEPT),
            keybind = "UI_SHORTCUT_PRIMARY",
            enabled = function()
                local selectedData = self:GetSelectedData()
                if selectedData then
                    local numMembers, _, _, numInvitees = GetGuildInfo(selectedData.guildId)
                    local totalPlayers = numMembers + numInvitees
                    if totalPlayers >= MAX_GUILD_MEMBERS then
                        return false, GetString("SI_SOCIALACTIONRESULT", SOCIAL_RESULT_GUILD_IS_FULL)
                    end
                end
                return true
            end,
            callback = function()
                local selectedData = self:GetSelectedData()
                if selectedData then
                    ZO_Dialogs_ShowPlatformDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_ACCEPT_DIALOG_NAME, selectedData, {mainTextParams = { ZO_FormatUserFacingDisplayName(selectedData.name) }})
                end
            end,
        }
    )
    table.insert(self.keybindStripDescriptor,
        -- Decline Application
        {
            name = GetString(SI_GUILD_RECRUITMENT_APPLICATION_DECLINE),
            keybind = "UI_SHORTCUT_SECONDARY",
            callback = function()
                local selectedData = self:GetSelectedData()
                if selectedData then
                    ZO_Dialogs_ShowPlatformDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_DECLINE_DIALOG_NAME, selectedData, {mainTextParams = { ZO_FormatUserFacingDisplayName(selectedData.name) }})
                end
            end,
        }
    )
    table.insert(self.keybindStripDescriptor,
        -- Options
        {
            name = GetString(SI_GAMEPAD_OPTIONS_MENU),
            keybind = "UI_SHORTCUT_TERTIARY",
            callback = function()
                local selectedData = self:GetSelectedData()
                if selectedData then
                    ZO_Dialogs_ShowPlatformDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_OPTIONS_DIALOG_NAME, selectedData)
                end
            end,
        }
    )
end
function ZO_GuildRecruitment_Applications_Gamepad:OnCommitComplete()
    GUILD_RECRUITMENT_GAMEPAD:RefreshKeybinds()
end
function ZO_GuildRecruitment_Applications_Gamepad:OnShowing()
    ZO_GuildRecruitment_ApplicationsList_Shared.OnShowing(self)
end
-------------
-- Dialogs --
-------------
function ZO_GuildRecruitment_Applications_Gamepad:InitializeConfirmAcceptDialog()
    local function ReleaseDialog()
        ZO_Dialogs_ReleaseDialogOnButtonPress(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_ACCEPT_DIALOG_NAME)
    end
    ZO_Dialogs_RegisterCustomDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_ACCEPT_DIALOG_NAME,
    {
        blockDialogReleaseOnPress = true,
        canQueue = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.BASIC,
            allowRightStickPassThrough = true,
        },
        setup = function(dialog)
            self.acceptConfirmText = nil
            self:RegisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS, ReleaseDialog)
            dialog:setupFunc()
        end,
        finishedCallback = function(dialog)
            self:UnregisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS)
        end,
        title =
        {
            text = SI_GUILD_RECRUITMENT_APPLICATION_ACCEPT_TITLE,
        },
        mainText = 
        {
            text = SI_GUILD_RECRUITMENT_APPLICATION_ACCEPT_DESCRIPTION,
        },
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_DIALOG_CONFIRM,
                callback = function(dialog)
                    local acceptApplicationResult = AcceptGuildApplication(dialog.data.guildId, dialog.data.index)
                    if ZO_GuildFinder_Manager.IsFailedApplicationResult(acceptApplicationResult) then
                        ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_PROCESS_APPLICATION_FAILED", nil, { mainTextParams = { acceptApplicationResult } })
                    end
                    ReleaseDialog()
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
                callback = function()
                    ReleaseDialog()
                end,
            },
        }
    })
end
function ZO_GuildRecruitment_Applications_Gamepad:InitializeConfirmDeclineDialog()
    local function ReleaseDialog()
        GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_LEFT_TOOLTIP)
        ZO_Dialogs_ReleaseDialogOnButtonPress(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_DECLINE_DIALOG_NAME)
    end
    ZO_Dialogs_RegisterCustomDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_CONFIRM_DECLINE_DIALOG_NAME,
    {
        blockDialogReleaseOnPress = true,
        canQueue = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
            allowRightStickPassThrough = true,
        },
        setup = function(dialog)
            self.declineMessage = GUILD_RECRUITMENT_MANAGER:GetSavedApplicationsDefaultMessage(self.guildId)
            self.addToBlacklist = false
            self.blacklistNote = nil
            self:RegisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS, ReleaseDialog)
            dialog:setupFunc()
        end,
        finishedCallback = function(dialog)
            self:UnregisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS)
        end,
        title =
        {
            text = SI_GUILD_RECRUITMENT_APPLICATION_DECLINE_TITLE,
        },
        mainText = 
        {
            text = SI_GUILD_RECRUITMENT_APPLICATION_DECLINE_DESCRIPTION,
        },
        parametricList =
        {
            -- Text reply to applicant
            {
                template = "ZO_Gamepad_GenericDialog_Parametric_TextFieldItem_Multiline",
                templateData = {
                    textChangedCallback = function(control)
                        local declineMessage = control:GetText()
                        self.declineMessage = declineMessage
                    end,
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        control.highlight:SetHidden(not selected)
                        control.editBoxControl:SetMaxInputChars(MAX_GUILD_APPLICATION_DECLINE_MESSAGE_LENGTH)
                        control.editBoxControl.textChangedCallback = data.textChangedCallback
                        data.control = control
                        ZO_EditDefaultText_Initialize(control.editBoxControl, GetString(SI_GUILD_RECRUITMENT_APPLICATION_DECLINE_DEFAULT_RESPONSE))
                        control.editBoxControl:SetMaxInputChars(MAX_GUILD_APPLICATION_DECLINE_MESSAGE_LENGTH)
                        if self.declineMessage then
                            control.editBoxControl:SetText(self.declineMessage)
                        end
                    end,
                    callback = function(dialog)
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.editBoxControl:TakeFocus()
                    end,
                },
            },
            -- Backlist checkbox
            {
                template = "ZO_CheckBoxTemplate_WithoutIndent_Gamepad",
                templateData = {
                    text = GetString(SI_GUILD_RECRUITMENT_ADD_TO_BLACKLIST_ACTION),
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        local hasPermission = DoesPlayerHaveGuildPermission(self.guildId, GUILD_PERMISSION_MANAGE_BLACKLIST)
                        local blacklistFull = GetNumGuildBlacklistEntries(self.guildId) >= MAX_GUILD_BLACKLISTED_PLAYERS
                        enabled = hasPermission and not blacklistFull
                        data.enabled = enabled
                        ZO_SharedGamepadEntry_OnSetup(control, data, selected, reselectingDuringRebuild, enabled, active)
                        local checkboxControl = control.checkBox
                        if self.addToBlacklist then
                            ZO_CheckButton_SetChecked(checkboxControl)
                        else
                            ZO_CheckButton_SetUnchecked(checkboxControl)
                        end
                        if enabled then
                            ZO_CheckButton_Enable(checkboxControl)
                        else
                            ZO_CheckButton_Disable(checkboxControl)
                            if selected then
                                local NO_TOOLTIP_TITLE = nil
                                local tooltipText = ""
                                if not hasPermission then
                                    tooltipText = GetString(SI_GUILD_RECRUITMENT_NO_BLACKLIST_PERMISSION)
                                elseif blacklistFull then
                                    tooltipText = GetString("SI_GUILDBLACKLISTRESPONSE", GUILD_BLACKLIST_RESPONSE_BLACKLIST_FULL)
                                end
                                GAMEPAD_TOOLTIPS:LayoutTitleAndDescriptionTooltip(GAMEPAD_LEFT_TOOLTIP, NO_TOOLTIP_TITLE, tooltipText)
                            else
                                GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_LEFT_TOOLTIP)
                            end
                        end
                    end,
                    callback = function(dialog)
                        local targetData = dialog.entryList:GetTargetData()
                        local targetControl = dialog.entryList:GetTargetControl()
                        ZO_GamepadCheckBoxTemplate_OnClicked(targetControl)
                        self.addToBlacklist = ZO_GamepadCheckBoxTemplate_IsChecked(targetControl)
                        local RESELECT_ENTRY = true
                        ZO_GenericParametricListGamepadDialogTemplate_RebuildEntryList(dialog, nil, RESELECT_ENTRY)
                    end,
                },
            },
            -- Blacklist Note
            {
                template = "ZO_Gamepad_GenericDialog_Parametric_TextFieldItem_Multiline",
                templateData = {
                    textChangedCallback = function(control)
                        local blacklistNote = control:GetText()
                        self.blacklistNote = blacklistNote
                    end,
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        control.highlight:SetHidden(not selected)
                        control.editBoxControl.textChangedCallback = data.textChangedCallback
                        data.control = control
                        ZO_EditDefaultText_Initialize(control.editBoxControl, GetString(SI_GUILD_RECRUITMENT_BLACKLIST_NOTE_DEFAULT_TEXT))
                        control.editBoxControl:SetMaxInputChars(MAX_GUILD_BLACKLIST_MESSAGE_LENGTH)
                        if self.blacklistNote then
                            control.editBoxControl:SetText(self.blacklistNote)
                        end
                    end,
                    visible = function()
                        return self.addToBlacklist
                    end,
                    callback = function(dialog)
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.editBoxControl:TakeFocus()
                    end,
                },
            },
            -- Decline applicant
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData = {
                    text = GetString(SI_GUILD_RECRUITMENT_APPLICATION_DECLINE),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    callback = function(dialog)
                        local declineApplicationResult, blacklistResult = DeclineGuildApplication(dialog.data.guildId, dialog.data.index, self.declineMessage, self.addToBlacklist, self.blacklistNote)
                        ReleaseDialog()
                        if ZO_GuildFinder_Manager.IsFailedApplicationResult(declineApplicationResult) then
                            ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_DECLINED_FAILED", nil, { mainTextParams = { GetString("SI_GUILDPROCESSAPPLICATIONRESPONSE", declineApplicationResult) } })
                        elseif self.addToBlacklist and not ZO_GuildRecruitment_Manager.IsAddedToBlacklistSuccessful(blacklistResult) then
                            ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_BLACKLIST_FAILED", nil, { mainTextParams = { blacklistResult } })
                        end
                    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,
            },
        }
    })
end
function ZO_GuildRecruitment_Applications_Gamepad:InitializeOptionsDialog()
    local function ReleaseDialog()
        ZO_Dialogs_ReleaseDialogOnButtonPress(ZO_GUILD_RECRUITMENT_GAMEPAD_OPTIONS_DIALOG_NAME)
    end
    ZO_Dialogs_RegisterCustomDialog(ZO_GUILD_RECRUITMENT_GAMEPAD_OPTIONS_DIALOG_NAME,
    {
        blockDialogReleaseOnPress = true,
        canQueue = true,
        gamepadInfo = {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
            allowRightStickPassThrough = true,
        },
        setup = function(dialog)
            self:RegisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS, ReleaseDialog)
            dialog:setupFunc()
        end,
        finishedCallback = function(dialog)
            self:UnregisterPermissionRemovedDialogCallback(GUILD_PERMISSION_MANAGE_APPLICATIONS)
        end,
        title =
        {
            text = SI_GAMEPAD_OPTIONS_MENU,
        },
        parametricList =
        {
            -- Send Mail
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData =
                {
                    text = GetString(SI_SOCIAL_MENU_SEND_MAIL),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    callback = function(dialog)
                        MAIL_MANAGER_GAMEPAD:GetSend():ComposeMailTo(ZO_FormatUserFacingCharacterOrDisplayName(dialog.data.name))
                        ReleaseDialog()
                    end,
                },
            },
            -- Report
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData =
                {
                    text = GetString(SI_GUILD_FINDER_REPORT_ACTION),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    callback = function(dialog)
                        local selectedData = self:GetSelectedData()
                        if selectedData then
                            local function ReportCallback()
                                -- If the player was reported then decline their application
                                local NO_MESSAGE = ""
                                local BLACKLIST = true
                                local declineApplicationResult, blacklistResult = DeclineGuildApplication(selectedData.guildId, selectedData.index, NO_MESSAGE, BLACKLIST, NO_MESSAGE)
                                if ZO_GuildFinder_Manager.IsFailedApplicationResult(declineApplicationResult) then
                                    ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_DECLINED_FAILED", nil, { mainTextParams = { GetString("SI_GUILDPROCESSAPPLICATIONRESPONSE", declineApplicationResult) } })
                                elseif not ZO_GuildRecruitment_Manager.IsAddedToBlacklistSuccessful(blacklistResult) then
                                    ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_BLACKLIST_FAILED", nil, { mainTextParams = { blacklistResult } })
                                end
                            end
                            ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:OpenReportPlayerTicketScene(dialog.data.name, ReportCallback)
                        end
                        ReleaseDialog()
                    end,
                },
            },
            -- View Gamercard
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData =
                {
                    text = GetString(GetGamerCardStringId()),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    visible = IsConsoleUI,
                    callback = function()
                        local selectedData = self:GetSelectedData()
                        if selectedData then
                            ZO_ShowGamerCardFromDisplayNameOrFallback(selectedData.name, ZO_ID_REQUEST_TYPE_GUILD_APPLICATION_INFO, selectedData.guildId, selectedData.index)
                        end
                        ReleaseDialog()
                    end,
                }
            },
        },
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData and targetData.callback then
                        targetData.callback(dialog)
                    end
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
                callback = function()
                    ReleaseDialog()
                end,
            },
        }
    })
end
-- XML Functions
-----------------
    GUILD_RECRUITMENT_APPLICATIONS_GAMEPAD = ZO_GuildRecruitment_Applications_Gamepad:New(control)
end