Back to Home

ESO Lua File v101038

ingame/guildfinder/keyboard/guildbrowser_guildinfo_keyboard.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
------------------
-- Guild Finder --
------------------
-- ZO_GuildBrowser_GuildInfo_Keyboard
--------------------------------------
ZO_GUILD_BROWSER_GUILD_INFO_RECRUITMENT_MESSAGE_BASE_OFFSET_Y = 20
ZO_GuildBrowser_GuildInfo_Keyboard = ZO_GuildBrowser_GuildInfo_Shared:Subclass()
function ZO_GuildBrowser_GuildInfo_Keyboard:New(...)
    return ZO_GuildBrowser_GuildInfo_Shared.New(self, ...)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:Initialize(control)
    ZO_GuildBrowser_GuildInfo_Shared.Initialize(self, control)
    self.topSection = control:GetNamedChild("TopSection")
    self.infoPanel = control:GetNamedChild("InfoPanel")
    self.refreshMessageLabel = control:GetNamedChild("RefreshMessage")
    self.heraldry = self.topSection:GetNamedChild("Heraldry")
    self.allianceIcon = self.topSection:GetNamedChild("AllianceIcon")
    self.guildNameLabel = self.topSection:GetNamedChild("GuildName")
    self.guildTraderLabel = self.topSection:GetNamedChild("GuildTrader")
    self.sizeLabel = self.topSection:GetNamedChild("Size")
    self.foundedLabel = self.topSection:GetNamedChild("Founded")
    self.personalitiesLabel = self.topSection:GetNamedChild("Personalities")
    self.languagesLabel = self.topSection:GetNamedChild("Languages")
    self.playtimeLabel = self.topSection:GetNamedChild("Playtime")
    self.rolesLabel = self.topSection:GetNamedChild("Roles")
    self.minCPLabel = self.topSection:GetNamedChild("MinCP")
    local infoContainerControl = control:GetNamedChild("InfoPanelScrollChild")
    self.activitiesLabel = infoContainerControl:GetNamedChild("Activities")
    self.headerMessageLabel = infoContainerControl:GetNamedChild("HeaderMessage")
    self.recruitmentMessageLabel = infoContainerControl:GetNamedChild("RecruitmentMessage")
    self.backButton = control:GetNamedChild("Back")
    self.backButton.OnMouseUp = function(control, upInside)
                                    if upInside then
                                        self:Close()
                                        PlaySound(SOUNDS.GUILD_FINDER_BACK_FROM_SELECTED_GUILD)
                                    end
                                end
    self.backButtonText = self.backButton:GetNamedChild("Text")
    
    local ALWAYS_ANIMATE = true
    KEYBOARD_GUILD_BROWSER_GUILD_INFO_FRAGMENT = ZO_FadeSceneFragment:New(self.control, ALWAYS_ANIMATE)
    KEYBOARD_GUILD_BROWSER_GUILD_INFO_FRAGMENT:RegisterCallback("StateChange", function(oldState, state)
                                                                if state == SCENE_FRAGMENT_SHOWING then
                                                                    self:OnShowing()
                                                                elseif state == SCENE_FRAGMENT_HIDING then
                                                                    self:OnHiding()
                                                                elseif state == SCENE_FRAGMENT_HIDDEN then
                                                                    self:OnHidden()
                                                                end
                                                            end)
    KEYBOARD_LINK_GUILD_INFO_SCENE = ZO_Scene:New("linkGuildInfoKeyboard", SCENE_MANAGER)
    KEYBOARD_LINK_GUILD_INFO_SCENE:RegisterCallback("StateChange", function(oldState, state)
                                                                if state == SCENE_SHOWING then
                                                                    self:OnInfoSceneShowing()
                                                                elseif state == SCENE_HIDDEN then
                                                                    self:OnInfoSceneHidden()
                                                                end
                                                            end)
    LINK_HANDLER:RegisterCallback(LINK_HANDLER.LINK_CLICKED_EVENT, self.OnLinkClicked, self)
    LINK_HANDLER:RegisterCallback(LINK_HANDLER.LINK_MOUSE_UP_EVENT, self.OnLinkClicked, self)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:IsShown()
    KEYBOARD_GUILD_BROWSER_GUILD_INFO_FRAGMENT:IsShowing()
end
function ZO_GuildBrowser_GuildInfo_Keyboard:InitializeKeybindStripDescriptor()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Apply To Guild
        {
            name = GetString(SI_GUILD_BROWSER_GUILD_INFO_APPLY_TO_GUILD),
            keybind = "UI_SHORTCUT_SECONDARY",
            callback = function()
                local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId)
                if guildData then
                    ZO_Dialogs_ShowDialog("SUBMIT_GUILD_FINDER_APPLICATION")
                else
                    local data =
                    {
                        guildId = self.currentGuildId,
                        onCloseFunction = function() self:Close() end,
                    }
                    ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_STALE", data, { mainTextParams = { GetString("SI_GUILDAPPLICATIONRESPONSE", GUILD_APP_RESPONSE_GUILD_DATA_OUT_OF_DATE) } })
                end
            end,
            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,
            visible = function()
                return GetGuildRecruitmentStatusAttribute(self.currentGuildId) == GUILD_RECRUITMENT_STATUS_ATTRIBUTE_VALUE_LISTED
            end,
        },
        -- Report
        {
            name = GetString(SI_GUILD_BROWSER_REPORT_GUILD_KEYBIND),
            keybind = "UI_SHORTCUT_REPORT_PLAYER",
            callback = function()
                local function ReportCallback()
                    GUILD_BROWSER_MANAGER:AddReportedGuild(self.currentGuildId)
                end
                local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId)
                ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:OpenReportGuildTicketScene(guildData.guildName, CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_CATEGORY_INAPPROPRIATE_LISTING, ReportCallback)
            end,
        },
    }
end
function ZO_GuildBrowser_GuildInfo_Keyboard:RefreshInfoPanel()
    ZO_GuildBrowser_GuildInfo_Shared.RefreshInfoPanel(self)
    local guildData = GUILD_BROWSER_MANAGER:GetGuildData(self.currentGuildId)
    if guildData then
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.sizeLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_SIZE)), guildData.size)
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.activitiesLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_ACTIVITIES)), guildData.activitiesText)
        ZO_GuildFinder_Manager.SetTextForMetaDataAttributeKeyboard(self.personalitiesLabel, GUILD_META_DATA_ATTRIBUTE_PERSONALITIES, "SI_GUILDPERSONALITYATTRIBUTEVALUE", guildData.personality)
        ZO_GuildFinder_Manager.SetTextForMetaDataAttributeKeyboard(self.languagesLabel, GUILD_META_DATA_ATTRIBUTE_LANGUAGES, "SI_GUILDLANGUAGEATTRIBUTEVALUE", guildData.language)
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.guildTraderLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_KIOSK)), guildData.guildTraderText)
        ZO_GuildFinder_Manager.SetTextForNoGrammarValuePairKeyboard(self.foundedLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_FOUNDED_DATE)), guildData.foundedDateText)
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.rolesLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_ROLES)), ZO_GuildFinder_Manager.GetRoleIconsText(guildData.roles))
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.minCPLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_MINIMUM_CP)), guildData.minimumCP)
        local formattedTimeRange = ZO_GuildFinder_Manager.CreatePlaytimeRangeText(guildData)
        ZO_GuildFinder_Manager.SetTextForValuePairKeyboard(self.playtimeLabel, zo_strformat(SI_GUILD_FINDER_GUILD_INFO_HEADER_FORMATTER, GetString(SI_GUILD_FINDER_GUILD_INFO_PLAYTIME_HEADER)), formattedTimeRange)
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_GuildBrowser_GuildInfo_Keyboard:GetAllianceIcon(alliance)
    return ZO_GetAllianceSymbolIcon(alliance)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:Close()
    SCENE_MANAGER:RemoveFragment(KEYBOARD_GUILD_BROWSER_GUILD_INFO_FRAGMENT)
    if self.closeCallback then
        self.closeCallback()
        self.closeCallback = nil
    end
end
function ZO_GuildBrowser_GuildInfo_Keyboard:SetInLoadingMode(shouldHide)
    self.topSection:SetHidden(shouldHide)
    self.infoPanel:SetHidden(shouldHide)
    self.refreshMessageLabel:SetHidden(not shouldHide)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:ShowWithGuild(guildId, closeCallback)
    self:SetGuildToShow(guildId)
    SCENE_MANAGER:AddFragment(KEYBOARD_GUILD_BROWSER_GUILD_INFO_FRAGMENT)
    -- showing the fragment will override the panel's visibility. Need to reset it properly here
    local shouldHidePanel = GUILD_BROWSER_MANAGER:GetGuildData(guildId) == nil
    self:SetInLoadingMode(shouldHidePanel)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnApplyToGuildSubmit(message)
    local applicationResult = SubmitGuildFinderApplication(self.currentGuildId, message)
    if applicationResult ~= GUILD_APP_RESPONSE_APPLICATION_SENT then
        ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_APPLICATION_FAILED", nil, { mainTextParams = { GetString("SI_GUILDAPPLICATIONRESPONSE", applicationResult) } })
    else
        GUILD_BROWSER_GUILD_INFO_KEYBOARD:Close()
    end
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnShowing()
    ZO_GuildBrowser_GuildInfo_Shared.OnShowing(self)
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnHiding()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnHidden()
    ZO_GuildBrowser_GuildInfo_Shared.OnHidden(self)
end
-- Link Guild Info Scene Functions
-----------------------------------
function ZO_GuildBrowser_GuildInfo_Keyboard:OnInfoSceneShowing()
    self.backButtonText:SetText(GetString(SI_GUILD_BROWSER_GUILD_INFO_EXIT_BUTTON))
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnInfoSceneHidden()
    local sceneGroup = SCENE_MANAGER:GetSceneGroup("guildsSceneGroup")
    if GetNumGuilds() == 0 then
        GUILD_SELECTOR:SelectGuildFinder()
        sceneGroup:SetActiveScene("guildBrowserKeyboard")
    else
        GUILD_SELECTOR:SelectGuildByIndex(1)
        sceneGroup:SetActiveScene("guildHome")
    end
    self.backButtonText:SetText(GetString(SI_GUILD_BROWSER_GUILD_INFO_BACK_BUTTON))
end
function ZO_GuildBrowser_GuildInfo_Keyboard:OnLinkClicked(link, button, text, color, linkType, ...)
    if linkType == GUILD_LINK_TYPE and button == MOUSE_BUTTON_INDEX_LEFT then
        local guildId = tonumber(select(1, ...))
        if IsInGamepadPreferredMode() then -- extreme edge case, since you can click links while in Gamepad Mode when on a PC
            GUILD_BROWSER_GUILD_INFO_GAMEPAD:ShowWithGuild(guildId)
        else
            self:SetGuildToShow(guildId)
            if KEYBOARD_LINK_GUILD_INFO_SCENE:IsShowing() then
                self:RefreshInfoPanel()
            else
                MAIN_MENU_KEYBOARD:ShowSceneGroup("guildsSceneGroup", "linkGuildInfoKeyboard")
            end
            self.closeCallback = function() SCENE_MANAGER:HideCurrentScene() end
        end
        return true
    end
end
-- XML functions
----------------
local function SubmitApplicationDialogSetup(dialog, data)
    dialog.guildId = GUILD_BROWSER_GUILD_INFO_KEYBOARD:GetCurrentGuildId()
    local guildData = GUILD_BROWSER_MANAGER:GetGuildData(dialog.guildId)
    local guildNameLabel = dialog:GetNamedChild("GuildName")
    guildNameLabel:SetText(zo_strformat(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_GUILD_NAME, ZO_WHITE:Colorize(guildData.guildName)))
    local characterNameLabel = dialog:GetNamedChild("CharacterName")
    characterNameLabel:SetText(zo_strformat(SI_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_CHARACTER_LABEL), ZO_WHITE:Colorize(GetRawUnitName("player"))))
    local ICON_SIZE = 24
    local levelNameLabel = dialog:GetNamedChild("Level")
    levelNameLabel:SetText(zo_strformat(SI_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_LEVEL_LABEL), ZO_WHITE:Colorize(ZO_GetLevelOrChampionPointsString(GetUnitLevel("player"), GetUnitChampionPoints("player"), ICON_SIZE))))
    local classPointsNameLabel = dialog:GetNamedChild("Class")
    classPointsNameLabel:SetText(zo_strformat(SI_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_CLASS_LABEL), ZO_WHITE:Colorize(GetUnitClass("player"))))
    local achievementPointsNameLabel = dialog:GetNamedChild("AchievementPoints")
    achievementPointsNameLabel:SetText(zo_strformat(SI_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_ACHIEVEMENT_POINTS_LABEL), ZO_WHITE:Colorize(GetEarnedAchievementPoints())))
    local editHeader = dialog:GetNamedChild("ApplicationHeader")
    editHeader:SetText(zo_strformat(SI_GUILD_FINDER_GUILD_INFO_ATTRIBUTE_FORMATTER, GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_MESSAGE_HEADER)))
    local editLabel = dialog:GetNamedChild("ApplicationMessageEdit")
    editLabel:SetMaxInputChars(MAX_GUILD_APPLICATION_MESSAGE_LENGTH)
    editLabel:SetText(GUILD_BROWSER_MANAGER:GetSavedApplicationMessage())
end
    ZO_Dialogs_RegisterCustomDialog("SUBMIT_GUILD_FINDER_APPLICATION",
    {
        customControl = control,
        setup = SubmitApplicationDialogSetup,
        title =
        {
            text = SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_TITLE,
        },
        buttons =
        {
            [1] =
            {
                control =   control:GetNamedChild("Submit"),
                text =      GetString(SI_GUILD_BROWSER_SUBMIT_APPLICATION_DIALOG_BUTTON_SUBMIT),
                callback =  function(dialog)
                                local message = dialog:GetNamedChild("ApplicationMessageEdit"):GetText()
                                GUILD_BROWSER_GUILD_INFO_KEYBOARD:OnApplyToGuildSubmit(message)
                            end,
            },
            [2] =
            {
                control =   control:GetNamedChild("Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
end
    GUILD_BROWSER_GUILD_INFO_KEYBOARD = ZO_GuildBrowser_GuildInfo_Keyboard:New(control)
end