Back to Home

ESO Lua File v100036

ingame/guildfinder/keyboard/guildrecruitment_guildlisting_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
------------------
-- Guild Finder --
------------------
ZO_GuildRecruitment_GuildListing_Keyboard = ZO_GuildRecruitment_GuildListing_Shared:Subclass()
function ZO_GuildRecruitment_GuildListing_Keyboard:New(...)
    return ZO_GuildRecruitment_GuildListing_Shared.New(self, ...)
end
function ZO_GuildRecruitment_GuildListing_Keyboard:Initialize(control)
    local function OnTextEdited(control, data)
        local attribute = data.attribute
        local editBoxObject = control and control.object
        editBoxObject:SetControlHidden()
        if editBoxObject:IsEditing() then
            data.currentValue = editBoxObject:GetEditBoxText()
        end
    end
    local templateData =
    {
        gridListClass = ZO_GridScrollList_Keyboard,
        headerTemplate = "ZO_GuildRecruitment_GuildListing_Keyboard_Header_Template",
        headerHeight = 24,
        gridPaddingY = 10,
        textEditHideCallback = OnTextEdited,
        attributeSelection =
        {
            entryTemplate = "ZO_GuildRecruitment_AttributeSelectionTile_Keyboard_Control",
            dimensionsX = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COLUMN_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COMBOBOX_HEIGHT,
            statusEntryTemplate = "ZO_GuildRecruitment_StatusSelectionTile_Keyboard_Control",
            statusDimensionsX = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COLUMN_LONG_WIDTH,
            startTimeEntryTemplate = "ZO_GuildRecruitment_StartTimeSelectionTile_Keyboard_Control",
            endTimeEntryTemplate = "ZO_GuildRecruitment_EndTimeSelectionTile_Keyboard_Control",
            startTimeDimensionsX = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COLUMN_WIDTH,
            timeDimensionsY = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COMBOBOX_TALL_HEIGHT,
            recruitmentHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_RECRUITMENT_STATUS)),
            primaryFocusHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_PRIMARY_FOCUS)),
            secondaryFocusHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_SECONDARY_FOCUS)),
            personalityHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_PERSONALITIES)),
            languageHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_LANGUAGES)),
            timeRangeHeaderText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString(SI_GUILD_FINDER_CORE_HOURS_LABEL)),
            gridPaddingX = 0,
            gridPaddingY = 10,
        },
        activityCheckbox =
        {
            entryTemplate = "ZO_GuildRecruitment_ActivityCheckboxTile_Keyboard_Control",
            headerText = GetString(SI_GUILD_RECRUITMENT_ADDITIONAL_ACTIVITIES_HEADER),
            dimensionsX = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_COLUMN_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_CHECKBOX_HEIGHT,
            endEntryTemplate = "ZO_GuildRecruitment_ActivityCheckboxEndTile_Keyboard_Control",
            endDimensionsY = ZO_GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD_CHECKBOX_END_HEIGHT,
            gridPaddingX = 0,
            gridPaddingY = 0,
        },
        headlineEditBox =
        {
            entryTemplate = "ZO_GuildRecruitment_MultilineEditBoxTile_Keyboard_Control",
            dimensionsX = ZO_GUILD_RECRUITMENT_EDITBOX_KEYBOARD_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_EDITBOX_KEYBOARD_HEADLINE_ENTRY_HEIGHT,
            headerText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_HEADER_MESSAGE)),
            gridPaddingY = 10,
        },
        descriptionEditBox =
        {
            entryTemplate = "ZO_GuildRecruitment_MultilineEditBoxTile_Description_Keyboard_Control",
            dimensionsX = ZO_GUILD_RECRUITMENT_EDITBOX_KEYBOARD_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_EDITBOX_KEYBOARD_DESCRIPTION_ENTRY_HEIGHT,
            headerText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_RECRUITMENT_MESSAGE)),
            gridPaddingY = 10,
        },
        roleSelector =
        {
            entryTemplate = "ZO_GuildRecruitment_RoleSelectorTile_Keyboard_Control",
            endEntryTemplate = "ZO_GuildRecruitment_RoleSelectorEndTile_Keyboard_Control",
            headerText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_ROLES)),
            dimensionsX = ZO_GUILD_RECRUITMENT_ROLE_KEYBOARD_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_ROLESELECTOR_KEYBOARD_HEIGHT,
            endDimensionsX = ZO_GUILD_RECRUITMENT_ROLE_END_KEYBOARD_WIDTH,
            gridPaddingY = 10,
        },
        minimumCP =
        {
            entryTemplate = "ZO_GuildRecruitment_NumericEditBoxTile_Keyboard_Control",
            headerText = zo_strformat(SI_GUILD_RECRUITMENT_GUILD_LISTING_HEADER_FORMATTER, GetString("SI_GUILDMETADATAATTRIBUTE", GUILD_META_DATA_ATTRIBUTE_MINIMUM_CP)),
            dimensionsX = ZO_GUILD_RECRUITMENT_NUMERIC_EDITBOX_KEYBOARD_WIDTH,
            dimensionsY = ZO_GUILD_RECRUITMENT_NUMERIC_EDITBOX_KEYBOARD_ENTRY_HEIGHT,
            gridPaddingY = 10,
        },
    }
    ZO_GuildRecruitment_GuildListing_Shared.Initialize(self, control, templateData)
    self.alertControl = self.control:GetNamedChild("AlertContainerAlert")
end
function ZO_GuildRecruitment_GuildListing_Keyboard:InitializeKeybindDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Link in Chat
        {
            name = GetString(SI_GUILD_RECRUITMENT_LINK_IN_CHAT),
            keybind = "UI_SHORTCUT_SECONDARY",
            enabled = function()
                local numMembers, _, _, numInvitees = GetGuildInfo(self.guildId)
                if numMembers + numInvitees >= MAX_GUILD_MEMBERS then
                    return false, GetString(SI_GUILD_RECRUITMENT_MAX_GUILDS_CANT_LINK)
                end
                return true
            end,
            visible = function()
                return GetGuildRecruitmentStatus(self.guildId) == GUILD_RECRUITMENT_STATUS_ATTRIBUTE_VALUE_LISTED
            end,
            callback = function()
                local link = GetGuildRecruitmentLink(self.guildId, LINK_STYLE_BRACKETS)
                ZO_LinkHandler_InsertLink(link)
            end,
        },
    }
end
function ZO_GuildRecruitment_GuildListing_Shared:Save(onRecruitmentStatusChanged)
    if self:CanSave() then
        local desiredRecruitmentStatus = self.attributeSelectionData.recruitmentStatus.currentValue
        local remainingRequiredFields = { SaveGuildRecruitmentPendingChanges(self.guildId) }
        PlaySound(SOUNDS.GUILD_RANK_SAVED)
        if desiredRecruitmentStatus == GUILD_RECRUITMENT_STATUS_ATTRIBUTE_VALUE_LISTED and #remainingRequiredFields > 0 then
            self:RefreshData()
            if onRecruitmentStatusChanged then
                ZO_Dialogs_ShowPlatformDialog("GUILD_NOT_LISTED_KEYBOARD", remainingRequiredFields)
            else
                ZO_Dialogs_ShowPlatformDialog("GUILD_UNLISTED_KEYBOARD", remainingRequiredFields)
            end
        elseif onRecruitmentStatusChanged then
            local guildName = ZO_WHITE:Colorize(GetGuildName(self.guildId))
            local decoratedGuildName = ZO_AllianceIconNameFormatter(GetGuildAlliance(self.guildId), guildName)
            if desiredRecruitmentStatus == GUILD_RECRUITMENT_STATUS_ATTRIBUTE_VALUE_LISTED then
                ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_SAVE_FROM_RECRUITMENT_STATUS_LISTED", nil, { mainTextParams = { decoratedGuildName } })
            else
                ZO_Dialogs_ShowPlatformDialog("GUILD_FINDER_SAVE_FROM_RECRUITMENT_STATUS_UNLISTED", nil, { mainTextParams = { decoratedGuildName } })
            end
        end
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_GuildRecruitment_GuildListing_Keyboard:ChangeSelectedGuild(dialogCallback, dialogParams)
    if dialogCallback and self.guildId ~= dialogParams.entry.guildId then
        dialogCallback(dialogParams)
    end
end
function ZO_GuildRecruitment_GuildListing_Keyboard:UpdateAlert()
    local numMembers, _, _, numInvitees = GetGuildInfo(self.guildId)
    local hideAlert = true
    if numMembers + numInvitees >= MAX_GUILD_MEMBERS then
        self.alertControl:SetText(GetString(SI_GUILD_RECRUITMENT_GUILD_LISTING_FULL_GUILD_ALERT))
        hideAlert = false
    elseif GetGuildFinderNumGuildApplications(self.guildId) >= MAX_PENDING_APPLICATIONS_PER_GUILD then
        self.alertControl:SetText(GetString(SI_GUILD_RECRUITMENT_GUILD_LISTING_APPLICATIONS_FULL_GUILD_ALERT))
        hideAlert = false
    end
    self.alertControl:SetHidden(hideAlert)
end
function ZO_GuildRecruitment_GuildListing_Keyboard:OnHidden()
    ZO_GuildRecruitment_GuildListing_Shared.OnHidden(self)
    self:Save()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_GuildRecruitment_GuildListing_Keyboard:ShowCategory()
    ZO_GuildFinder_Panel_Shared.ShowCategory(self)
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_GuildRecruitment_GuildListing_Keyboard:HideCategory()
    ZO_GuildFinder_Panel_Shared.HideCategory(self)
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
end
-- XML functions
----------------
    GUILD_RECRUITMENT_GUILD_LISTING_KEYBOARD = ZO_GuildRecruitment_GuildListing_Keyboard:New(control)
end
    ZO_Dialogs_RegisterCustomDialog("GUILD_NOT_LISTED_KEYBOARD",
    {
        title =
        {
            text = SI_GUILD_RECRUITMENT_NOT_LISTED_DIALOG_TITLE,
        },
        mainText =
        {
            text = SI_GUILD_RECRUITMENT_NOT_LISTED_DIALOG_DESCRIPTION,
        },
        canQueue = true,
        customControl = self,
        setup = function(dialog)
            if not dialog.bulletList then
                dialog.bulletList = ZO_BulletList:New(dialog:GetNamedChild("BulletList"))
            end
            dialog.bulletList:Clear()
            for i, attribute in ipairs(dialog.data) do
                dialog.bulletList:AddLine(GetString("SI_GUILDMETADATAATTRIBUTE", attribute))
            end
        end,
        buttons =
        {
            -- Exit Button
            {
                control = self:GetNamedChild("Exit"),
                keybind = "DIALOG_NEGATIVE",
                text = SI_EXIT_BUTTON,
            },
        },
    })
end
    ZO_Dialogs_RegisterCustomDialog("GUILD_UNLISTED_KEYBOARD",
    {
        title =
        {
            text = SI_GUILD_RECRUITMENT_LISTING_FAILED_DIALOG_TITLE,
        },
        mainText =
        {
            text = SI_GUILD_RECRUITMENT_LISTING_FAILED_DIALOG_DESCRIPTION,
        },
        canQueue = true,
        customControl = self,
        setup = function(dialog)
            if not dialog.bulletList then
                dialog.bulletList = ZO_BulletList:New(dialog:GetNamedChild("BulletList"))
            end
            dialog.bulletList:Clear()
            for i, attribute in ipairs(dialog.data) do
                dialog.bulletList:AddLine(GetString("SI_GUILDMETADATAATTRIBUTE", attribute))
            end
        end,
        buttons =
        {
            -- Exit Button
            {
                control = self:GetNamedChild("Exit"),
                keybind = "DIALOG_NEGATIVE",
                text = SI_EXIT_BUTTON,
            },
        },
    })
end