Back to Home

ESO Lua File v100032

ingame/guildfinder/gamepad/guildbrowser_guildinfo_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
------------------
-- Guild Finder --
------------------
ZO_GUILD_BROWSER_GUILD_INFO_ATTRIBUTE_OFFSET_Y = 20
ZO_GUILD_BROWSER_GUILD_INFO_ATTRIBUTE_OFFSET_X = 20
ZO_GuildBrowser_GuildInfo_Gamepad = ZO_Object.MultiSubclass(ZO_GuildBrowser_GuildInfo_Shared, ZO_Gamepad_ParametricList_Screen)
function ZO_GuildBrowser_GuildInfo_Gamepad:New(...)
    return ZO_Gamepad_ParametricList_Screen.New(self, ...)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:Initialize(control)
    local sceneName = "guildBrowserGuildInfoGamepad"
    GAMEPAD_GUILD_BROWSER_GUILD_INFO_SCENE = ZO_Scene:New(sceneName, SCENE_MANAGER)
    self.links = {}
    self.currentLinkIndex = 1
    local ACTIVATE_LIST_ON_SHOW = true
    ZO_Gamepad_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, ACTIVATE_LIST_ON_SHOW, GAMEPAD_GUILD_BROWSER_GUILD_INFO_SCENE)
    -- Initialize shared elements in info display area
    local rightPane = control:GetNamedChild("RightPane")
    self.rightPane = rightPane
    local rightPaneFragment = ZO_FadeSceneFragment:New(rightPane)
    GAMEPAD_GUILD_BROWSER_GUILD_INFO_SCENE:AddFragment(rightPaneFragment)
    self.refreshMessageLabel = control:GetNamedChild("RefreshMessage")
    ZO_GuildBrowser_GuildInfo_Shared.Initialize(self, rightPane)
    self.infoPanel = rightPane:GetNamedChild("InfoPanel")
    self.topSection = self.infoPanel:GetNamedChild("TopSection")
    self.scrollContainer = self.infoPanel:GetNamedChild("ScrollContainer")
    self.scrollChild = self.scrollContainer:GetNamedChild("ScrollChild")
    self.heraldry = self.topSection:GetNamedChild("Heraldry")
    self.allianceIcon = self.topSection:GetNamedChild("AllianceIcon")
    self.guildNameLabel = self.topSection:GetNamedChild("GuildName")
    self.guildTraderLabelPair = self.topSection:GetNamedChild("GuildTrader")
    self.guildTraderLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_KIOSK))
    self.playtimeLabelPair = self.topSection:GetNamedChild("Playtime")
    self.playtimeLabelPair.header:SetText(GetString(SI_GUILD_FINDER_GUILD_INFO_PLAYTIME_HEADER))
    self.foundedLabelPair = self.topSection:GetNamedChild("Founded")
    self.foundedLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_FOUNDED_DATE))
    self.sizeLabelPair = self.topSection:GetNamedChild("Size")
    self.sizeLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_SIZE))
    self.personalitiesLabelPair = self.topSection:GetNamedChild("Personalities")
    self.personalitiesLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_PERSONALITIES))
    self.languagesLabelPair = self.topSection:GetNamedChild("Languages")
    self.languagesLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_LANGUAGES))
    self.activitiesLabel = self.scrollChild:GetNamedChild("Activities")
    self.headerMessageLabel = self.scrollChild:GetNamedChild("HeaderMessage")
    self.recruitmentMessageLabel = self.scrollChild:GetNamedChild("RecruitmentMessage")
    local activitiesHeader = self.scrollChild:GetNamedChild("ActivitiesHeader")
    activitiesHeader:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_ACTIVITIES))
    self.rolesLabelPair = self.topSection:GetNamedChild("Roles")
    self.rolesLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_ROLES))
    self.minCPLabelPair = self.topSection:GetNamedChild("MinCP")
    self.minCPLabelPair.header:SetText(GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_MINIMUM_CP))
    GAMEPAD_GUILD_BROWSER_GUILD_INFO_FRAGMENT = ZO_SimpleSceneFragment:New(control)
    GAMEPAD_GUILD_BROWSER_GUILD_INFO_FRAGMENT:SetHideOnSceneHidden(true)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:IsShown()
    GAMEPAD_GUILD_BROWSER_GUILD_INFO_FRAGMENT:IsShowing()
end
function ZO_GuildBrowser_GuildInfo_Gamepad:BuildActionList()
    local list = self:GetMainList()
    list:Clear()
    if GetGuildRecruitmentStatusAttribute(self.currentGuildId) == GUILD_RECRUITMENT_STATUS_ATTRIBUTE_VALUE_LISTED then
        local applyEntry = ZO_GamepadEntryData:New(GetString(SI_GUILD_BROWSER_GUILD_INFO_APPLY_TO_GUILD))
        applyEntry.onSelectFunction = function()
            local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId)
            if guildData then
                ZO_Dialogs_ShowGamepadDialog("GAMEPAD_SUBMIT_GUILD_FINDER_APPLICATION")
            else
                local data =
                {
                    guildId = self.currentGuildId,
                    onCloseFunction = function() SCENE_MANAGER:HideCurrentScene() end,
                }
                ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_STALE", data, { mainTextParams = { GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_GUILD_DATA_OUT_OF_DATE) } })
            end
        end
        list:AddEntry("ZO_GamepadItemSubEntryTemplate", applyEntry)
    else
        local exitEntry = ZO_GamepadEntryData:New(GetString(SI_GUILD_BROWSER_GUILD_INFO_EXIT))
        exitEntry.onSelectFunction = function() SCENE_MANAGER:HideCurrentScene() end
        list:AddEntry("ZO_GamepadItemSubEntryTemplate", exitEntry)
    end
    list:Commit()
end
function ZO_GuildBrowser_GuildInfo_Gamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Select
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            enabled = function()
                if #GUILD_BROWSER_MANAGER:GetCurrentApplicationsList() >= MAX_GUILD_FINDER_APPLICATIONS_PER_ACCOUNT then
                    return false, GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_MAX_APPLICATIONS_PENDING)
                elseif GUILD_BROWSER_MANAGER:HasPendingApplicationToGuild(self.currentGuildId) then
                    return false, GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_OUTSTANDING_APPLICATION)
                elseif GetNumGuilds() >= MAX_GUILDS then
                    return false, GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_IN_MAX_GUILDS)
                elseif IsPlayerInGuild(self.currentGuildId) then
                    return false, GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_ALREADY_MEMBER)
                end
                return true
            end,
            callback = function()
                local selectedData = self:GetMainList():GetSelectedData()
                selectedData.onSelectFunction()
            end,
        },
        -- Back
        KEYBIND_STRIP:GetDefaultGamepadBackButtonDescriptor(),
        -- Report
        {
            name = GetString(SI_GUILD_BROWSER_REPORT_GUILD_KEYBIND),
            keybind = "UI_SHORTCUT_RIGHT_STICK",
            callback = function()
                local function ReportCallback()
                    GUILD_BROWSER_MANAGER:AddReportedGuild(self.currentGuildId)
                end
                GUILD_BROWSER_GAMEPAD:OnReportingGuild()
                local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId)
                ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:OpenReportGuildTicketScene(guildData.guildName, CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_SUBCATEGORY_INAPPROPRIATE_LISTING, ReportCallback)
            end,
        },
        -- Open Guild Link (super special keybind)
        {
            name = GetString(SI_GAMEPAD_GUILD_LINK_KEYBIND),
            keybind = "UI_SHORTCUT_SECONDARY",
            alignment = KEYBIND_STRIP_ALIGN_RIGHT,
            callback = function()
                if #self.links > 0 then
                    local currentLink = self.links[self.currentLinkIndex]
                    if currentLink then
                        local text, color, linkType, guildId = ZO_LinkHandler_ParseLink(currentLink.link)
                        self:SetGuildToShow(tonumber(guildId))
                        self:RefreshInfoPanel()
                    end
                end
            end,
            visible = function()
                if #self.links > 0 then
                    local currentLink = self.links[self.currentLinkIndex]
                    if currentLink then
                        return currentLink.linkType == GUILD_LINK_TYPE
                    end
                end
                return false
            end
        },
        -- cycle tooltip
        {
            alignment = KEYBIND_STRIP_ALIGN_RIGHT,
            name = GetString(SI_GAMEPAD_CHAT_MENU_CYCLE_TOOLTIP_BINDING),
            keybind = "UI_SHORTCUT_INPUT_RIGHT",
            callback = function()
                self.currentLinkIndex = self.currentLinkIndex + 1
                if self.currentLinkIndex > #self.links then
                    self.currentLinkIndex = 1
                end
                self:RefreshTooltip()
                KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
            end,
            visible = function() return #self.links > 1 end,
        },
    }
end
function ZO_GuildBrowser_GuildInfo_Gamepad:ShowWithGuild(guildId)
    self:SetGuildToShow(guildId)
    SCENE_MANAGER:Push("guildBrowserGuildInfoGamepad")
end
function ZO_GuildBrowser_GuildInfo_Gamepad:GetAllianceIcon(alliance)
    return GetLargeAllianceSymbolIcon(alliance)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:RefreshInfoPanel()
    ZO_GuildBrowser_GuildInfo_Shared.RefreshInfoPanel(self)
    self.headerData = 
    {
        titleText = GetGuildNameAttribute(self.currentGuildId)
    }
    local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId, self.guildDisplayType)
    if guildData then
        self.sizeLabelPair.value:SetText(guildData.size)
        self.personalitiesLabelPair.value:SetText(zo_strformat(SI_GAMEPAD_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString("SI_GUILDPERSONALITYATTRIBUTEVALUE", guildData.personality)))
        self.languagesLabelPair.value:SetText(zo_strformat(SI_GAMEPAD_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString("SI_GUILDLANGUAGEATTRIBUTEVALUE", guildData.language)))
        self.guildTraderLabelPair.value:SetText(zo_strformat(SI_GAMEPAD_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, guildData.guildTraderText))
        self.foundedLabelPair.value:SetText(guildData.foundedDateText)
        self.activitiesLabel:SetText(guildData.activitiesText)
        self.playtimeLabelPair.value:SetText(ZO_GuildFinder_Manager.CreatePlaytimeRangeText(guildData))
        self.rolesLabelPair.value:SetText(ZO_GuildFinder_Manager.GetRoleIconsText(guildData.roles))
        self.minCPLabelPair.value:SetText(guildData.minimumCP)
    
        ZO_ClearNumericallyIndexedTable(self.links)
        self.currentLinkIndex = 1
        ZO_ExtractLinksFromText(guildData.headerMessage, ZO_VALID_LINK_TYPES_CHAT, self.links)
        ZO_ExtractLinksFromText(guildData.recruitmentMessage, ZO_VALID_LINK_TYPES_CHAT, self.links)
    end
    self:RefreshTooltip()
end
function ZO_GuildBrowser_GuildInfo_Gamepad:RefreshTooltip()
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    local links = self.links
    if #links > 0 then
        local currentLinkData = links[self.currentLinkIndex]
        local linkType = currentLinkData.linkType
        local link = currentLinkData.link
        if linkType == COLLECTIBLE_LINK_TYPE then
            GAMEPAD_TOOLTIPS:LayoutCollectibleFromLink(GAMEPAD_RIGHT_TOOLTIP, link)
        elseif linkType == ACHIEVEMENT_LINK_TYPE then
            GAMEPAD_TOOLTIPS:LayoutAchievementFromLink(GAMEPAD_RIGHT_TOOLTIP, link)
        elseif linkType == ITEM_LINK_TYPE then
            GAMEPAD_TOOLTIPS:LayoutItem(GAMEPAD_RIGHT_TOOLTIP, link)
        elseif linkType == GUILD_LINK_TYPE then
            GAMEPAD_TOOLTIPS:LayoutGuildLink(GAMEPAD_RIGHT_TOOLTIP, link)
        end
        return
    end
end
function ZO_GuildBrowser_GuildInfo_Gamepad:SetInLoadingMode(shouldHide)
    self.infoPanel:SetHidden(shouldHide)
    self.refreshMessageLabel:SetHidden(not shouldHide)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:OnShowing()
    ZO_GuildBrowser_GuildInfo_Shared.OnShowing(self)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:OnHidden()
    ZO_GuildBrowser_GuildInfo_Shared.OnHidden(self)
end
function ZO_GuildBrowser_GuildInfo_Gamepad:InitializeSubmitDialog()
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_SUBMIT_GUILD_FINDER_APPLICATION",
    {
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        },
        setup = function(dialog)
            ZO_GenericGamepadDialog_RefreshText(dialog, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_TITLE))
            self.applicationSubmissionText = GUILD_BROWSER_MANAGER:GetSavedApplicationMessage()
            local ICON_SIZE = 32
            local displayData =
            {
                data1 =
                {
                    header = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_CHARACTER_LABEL),
                    value = zo_strformat(SI_GAMEPAD_GUILD_BROWSER_GUILD_LIST_CONTEXTUAL_INFO_FORMATTER, GetRawUnitName("player"))
                },
                data2 =
                {
                    header = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_LEVEL_LABEL),
                    value = zo_strformat(SI_GAMEPAD_GUILD_BROWSER_GUILD_LIST_CONTEXTUAL_INFO_FORMATTER, GetLevelOrChampionPointsString(GetUnitLevel("player"), GetUnitChampionPoints("player"), ICON_SIZE))
                },
                data3 =
                {
                    header = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_CLASS_LABEL),
                    value = zo_strformat(SI_GAMEPAD_GUILD_BROWSER_GUILD_LIST_CONTEXTUAL_INFO_FORMATTER, GetUnitClass("player"))
                },
                data4 =
                {
                    header = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_ACHIEVEMENT_POINTS_LABEL),
                    value = zo_strformat(SI_GAMEPAD_GUILD_BROWSER_GUILD_LIST_CONTEXTUAL_INFO_FORMATTER, GetEarnedAchievementPoints())
                },
            }
            local DONT_LIMIT_NUM_ENTRIES = nil
            dialog:setupFunc(DONT_LIMIT_NUM_ENTRIES, displayData)
        end,
        parametricList =
        {
            -- Application Message
            {
                template = "ZO_Gamepad_GenericDialog_Parametric_TextFieldItem_Multiline",
                header = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_MESSAGE_HEADER),
                templateData = 
                {
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        control.highlight:SetHidden(not selected)
                        local dialog = data.dialog
                        control.editBoxControl:SetMaxInputChars(MAX_GUILD_APPLICATION_MESSAGE_LENGTH)
                        control.editBoxControl.textChangedCallback = function(control)
                                                                        self.applicationSubmissionText = control:GetText()
                                                                     end
                        data.control = control
                        if self.applicationSubmissionText == "" then
                            local defaultEditString = GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_DEFAULT_EDIT_TEXT)
                            ZO_EditDefaultText_Initialize(control.editBoxControl, defaultEditString)
                            control.resetFunction = function()
                                control.editBoxControl.textChangedCallback = nil
                                control.editBoxControl:SetText("")
                            end
                        else
                            control.editBoxControl:SetText(self.applicationSubmissionText)
                        end
                    end,
                    callback = function(dialog)
                        local data = dialog.entryList:GetTargetData()
                        local edit = data.control.editBoxControl
                        edit:TakeFocus()
                    end,
                },
            },
            -- Apply To Guild
            {
                template = "ZO_GamepadTextFieldSubmitItem",
                templateData =
                {
                    text = GetString(SI_GUILD_BROWSER_GUILD_INFO_APPLY_TO_GUILD),
                    setup = ZO_SharedGamepadEntry_OnSetup,
                    callback = function(dialog)
                        local applicationResult = SubmitGuildFinderApplication(self.currentGuildId, self.applicationSubmissionText)
                        if applicationResult ~= GUILD_APP_RESPONSE_APPLICATION_SENT then
                            ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_FAILED", nil, { mainTextParams = { GetString("SI_GUILDAPPLICATIONRESPONSE", applicationResult) } })
                        end
                        ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_SUBMIT_GUILD_FINDER_APPLICATION")
                    end,
                }
            },
        },
        blockDialogReleaseOnPress = true,
        buttons = 
        {
            -- Select
            {
                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(dialog)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_SUBMIT_GUILD_FINDER_APPLICATION")
                end,
            },
        },
    })
end
-- XML functions
----------------
    GUILD_BROWSER_GUILD_INFO_GAMEPAD = ZO_GuildBrowser_GuildInfo_Gamepad:New(control)
end