Back to Home

ESO Lua File v100032

ingame/help/keyboard/helpaskforhelp_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
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
local HELP_ASK_FOR_HELP_CATEGORY_INFO =
{
    [CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_CHARACTER_ISSUE] =
    {
        ticketCategory = TICKET_CATEGORY_CHARACTER_ISSUE,
    },
    [CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_REPORT_PLAYER] =
    {
        detailsTitle = GetString(SI_CUSTOMER_SERVICE_ASK_FOR_HELP_PLAYER_NAME),
        subcategoryStringName = "SI_CUSTOMERSERVICEASKFORHELPREPORTPLAYERSUBCATEGORY",
        subcategories = 
        {
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_NONE,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_INAPPROPRIATE_NAME,
                ticketCategory = TICKET_CATEGORY_REPORT_BAD_NAME,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_HARASSMENT,
                ticketCategory = TICKET_CATEGORY_REPORT_HARASSMENT,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_CHEATING,
                ticketCategory = TICKET_CATEGORY_REPORT_CHEATING,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_OTHER,
                ticketCategory = TICKET_CATEGORY_REPORT_OTHER,
            },
        },
    },
    [CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_REPORT_GUILD] =
    {
        detailsTitle = GetString(SI_CUSTOMER_SERVICE_ASK_FOR_HELP_GUILD_NAME),
        subcategoryStringName = "SI_CUSTOMERSERVICEASKFORHELPREPORTGUILDSUBCATEGORY",
        subcategories =
        {
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_SUBCATEGORY_NONE,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_SUBCATEGORY_INAPPROPRIATE_NAME,
                ticketCategory = TICKET_CATEGORY_REPORT_GUILD_NAME,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_SUBCATEGORY_INAPPROPRIATE_LISTING,
                ticketCategory = TICKET_CATEGORY_REPORT_GUILD_LISTING,
            },
            {
                value = CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_GUILD_SUBCATEGORY_INAPPROPRIATE_DECLINE,
                ticketCategory = TICKET_CATEGORY_REPORT_GUILD_DECLINE_MESSAGE,
            },
        },
    },
}
local HelpAskForHelp_Keyboard = ZO_HelpScreenTemplate_Keyboard:Subclass()
function HelpAskForHelp_Keyboard:New(...)
    return ZO_HelpScreenTemplate_Keyboard.New(self, ...)
end
function HelpAskForHelp_Keyboard:Initialize(control)
    HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT = ZO_FadeSceneFragment:New(control)
    local iconData =
    {
        name = GetString(SI_CUSTOMER_SERVICE_ASK_FOR_HELP),
        categoryFragment = HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT,
        up = "EsoUI/Art/Help/help_tabIcon_CS_up.dds",
        down = "EsoUI/Art/Help/help_tabIcon_CS_down.dds",
        over = "EsoUI/Art/Help/help_tabIcon_CS_over.dds",
    }
    ZO_HelpScreenTemplate_Keyboard.Initialize(self, control, iconData)
    self.helpCategoryTitle = control:GetNamedChild("CategoryTitle")
    self.helpSubcategoryTitle = control:GetNamedChild("SubcategoryTitle")
    self.helpDetailsTitle = control:GetNamedChild("DetailsTitle")
    self.helpDescriptionTitle = control:GetNamedChild("DescriptionTitle")
    self.helpDetailsTextControl = control:GetNamedChild("DetailsTextLine")
    self.helpSubcategoryContainer = control:GetNamedChild("SubcategoryContainer")
    self.helpDetailsContainer = control:GetNamedChild("DetailsContainer")
    self.helpCategoryComboBoxControl = control:GetNamedChild("CategoryComboBox")
    self.helpSubcategoryComboBoxControl = control:GetNamedChild("SubcategoryComboBox")
    self.helpSubmitButton = control:GetNamedChild("SubmitButton")
    ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:RegisterCallback("CustomerServiceTicketSubmitted", function (...)
                                                                        if HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT:IsShowing() then
                                                                            self:OnCustomerServiceTicketSubmitted(...)
                                                                        end
                                                                    end)
end
function HelpAskForHelp_Keyboard:InitializeComboBoxes()
    local function CreateComboBox(childName)
        local combo = ZO_ComboBox_ObjectFromContainer(self.control:GetNamedChild(childName))
        combo:SetSortsItems(false)
        combo:SetFont("ZoFontWinT1")
        combo:SetSpacing(4)
        return combo
    end
    self.helpCategoryComboBox = CreateComboBox("CategoryComboBox")
    self.helpSubcategoryComboBox = CreateComboBox("SubcategoryComboBox")
    local function OnCategoryChanged(comboBox, entryText, entry)
        self:UpdateSubcategories()
        self:UpdateDetailsComponents()
        self:UpdateSubmitButton()
        ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:SetReportPlayerTicketSubmittedCallback(nil)
    end
    for i = CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_ITERATION_BEGIN, CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_ITERATION_END do
        -- Omit Submit Feeback since it's Gamepad only per CS (at least that's how it's been setup previously)
        if i ~= CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_SUBMIT_FEEDBACK then
            local name = GetString("SI_CUSTOMERSERVICEASKFORHELPCATEGORIES", i)
            if name ~= nil then
                local entry = ZO_ComboBox:CreateItemEntry(name, OnCategoryChanged)
                entry.index = i
                self.helpCategoryComboBox:AddItem(entry, ZO_COMBOBOX_SUPRESS_UPDATE)
            end
        end
    end
    self.helpCategoryComboBox:SelectItemByIndex(1)
end
function HelpAskForHelp_Keyboard:InitializeTextBoxes()
    self.details = self.control:GetNamedChild("DetailsTextLineField")
    self.details:SetMaxInputChars(MAX_HELP_DETAILS_TEXT)
    ZO_EditDefaultText_Initialize(self.details, GetString(SI_CUSTOMER_SERVICE_ENTER_NAME))
    --Storing the text field and adding handlers to the visibility events so the Submit Button can be enabled/disabled when the player has typed something in
    --The Submit Button is disabled when the details text is empty (and the details text is visible)
    self.detailsDefaultTextField = self.details:GetNamedChild("Text")
    self.detailsDefaultTextField:SetHandler("OnEffectivelyShown",function() self:UpdateSubmitButton() end)
    self.detailsDefaultTextField:SetHandler("OnEffectivelyHidden",function() self:UpdateSubmitButton() end)
    self.description = self.control:GetNamedChild("DescriptionBodyField")
    self.description:SetMaxInputChars(MAX_HELP_DESCRIPTION_BODY)
    ZO_EditDefaultText_Initialize(self.description, GetString(SI_CUSTOMER_SERVICE_DEFAULT_DESCRIPTION_TEXT_GENERIC))
    --The Submit Button is disabled if the description text is empty
    self.descriptionDefaultTextField = self.description:GetNamedChild("Text")
    self.descriptionDefaultTextField:SetHandler("OnEffectivelyShown",function() self:UpdateSubmitButton() end)
    self.descriptionDefaultTextField:SetHandler("OnEffectivelyHidden",function() self:UpdateSubmitButton() end)
    self.description:SetText("")
    self.details:SetText("")
end
function HelpAskForHelp_Keyboard:InitializeDialogs()
    ZO_Dialogs_RegisterCustomDialog("HELP_ASK_FOR_HELP_SUBMIT_TICKET_SUCCESSFUL_DIALOG",
    {
        canQueue = true,
        mustChoose = true,
        title =
        {
            text = GetString(SI_CUSTOMER_SERVICE_SUBMIT_CONFIRMATION),
        },
        mainText =
        {
            text = GetString(SI_CUSTOMER_SERVICE_ASK_FOR_HELP_SUBMIT_TICKET_CONFIRMATION),
        },
       
        buttons =
        {
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_EXIT,
            },
        },
    })
end
function HelpAskForHelp_Keyboard:UpdateSubcategories()
    self.helpSubcategoryComboBox:ClearItems()
    local categoryIndex = self.helpCategoryComboBox:GetSelectedItemData().index
    local mainArray = HELP_ASK_FOR_HELP_CATEGORY_INFO[categoryIndex]
    if mainArray == nil then
        self:SetSubcategoryContentHidden(true)
    else
        self.subcategoryArray = mainArray.subcategories
        if self.subcategoryArray == nil then
            self:SetSubcategoryContentHidden(true)
        else
            self:SetSubcategoryContentHidden(false)
            for i, subcategoryId in ipairs(self.subcategoryArray) do
                local entry = ZO_ComboBox:CreateItemEntry(GetString(mainArray.subcategoryStringName, subcategoryId.value), function() self:UpdateSubmitButton() end)
                entry.index = i
                self.helpSubcategoryComboBox:AddItem(entry, ZO_COMBOBOX_UPDATE_NOW)
            end
            self.helpSubcategoryComboBox:SelectItemByIndex(1)
        end
    end
end
function HelpAskForHelp_Keyboard:UpdateDetailsComponents()
    self.details:SetText("")
    local categoryIndex = self.helpCategoryComboBox:GetSelectedItemData().index
    local mainArray = HELP_ASK_FOR_HELP_CATEGORY_INFO[categoryIndex]
        
    if mainArray == nil then
        self:SetDetailsContentHidden(true)
    else
        ZO_DefaultEdit_SetEnabled(self.details, true)
        local title = mainArray.detailsTitle
        if title == nil then
            self:SetDetailsContentHidden(true)
        else
            self:SetDetailsContentHidden(false)
            self.helpDetailsTitle:SetText(title)
        end
    end
end
function HelpAskForHelp_Keyboard:SetSubcategoryContentHidden(shouldHide)
    self.helpSubcategoryComboBoxControl:SetHidden(shouldHide)
    self.helpSubcategoryTitle:SetHidden(shouldHide)
    local offsetY = 0
    if not shouldHide then
        offsetY = 20
    end
    self.helpSubcategoryContainer:SetAnchor(TOPLEFT, self.helpCategoryComboBoxControl, BOTTOMLEFT, 0, offsetY)
end
function HelpAskForHelp_Keyboard:SetDetailsContentHidden(shouldHide)
    self.helpDetailsTextControl:SetHidden(shouldHide)
    self.helpDetailsTitle:SetHidden(shouldHide)
    local offsetY = 0
    if not shouldHide then
        offsetY = 20
    end
    self.helpDetailsContainer:SetAnchor(TOPLEFT, self.helpSubcategoryContainer, BOTTOMLEFT, 0, offsetY)
end
function HelpAskForHelp_Keyboard:UpdateSubmitButton()
    local enableSubmitButton = true
    if self.helpCategoryComboBox == nil or self.helpSubcategoryComboBox == nil or self.descriptionDefaultTextField == nil or self.details == nil then
        enableSubmitButton = false
    elseif self.helpCategoryComboBox:GetSelectedItemData().index <= CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_NONE then
        enableSubmitButton = false
    elseif not self.helpSubcategoryComboBoxControl:IsHidden() and self.helpSubcategoryComboBox:GetSelectedItemData().index <= 0 then
        enableSubmitButton = false
    elseif not self.helpDetailsTextControl:IsHidden() and not self.detailsDefaultTextField:IsHidden() then
        enableSubmitButton = false
    elseif not self.descriptionDefaultTextField:IsHidden() then
        enableSubmitButton = false
    end
    
    self.helpSubmitButton:SetEnabled(enableSubmitButton)
end
function HelpAskForHelp_Keyboard:ClearFields()
    self.helpCategoryComboBox:SelectItemByIndex(1)
    self.description:SetText("")
    ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:SetReportPlayerTicketSubmittedCallback(nil)
end
function HelpAskForHelp_Keyboard:SelectCategory(category)
    local categories = self.helpCategoryComboBox:GetItems()
    for i, categoryId in ipairs(categories) do
        if categoryId.index == category then
            local PERFORM_CALLBACK = false
            self.helpCategoryComboBox:SelectItemByIndex(i, PERFORM_CALLBACK)
            break
        end
    end
end
function HelpAskForHelp_Keyboard:SelectSubcategory(subcategory)
    local categoryIndex = self.helpCategoryComboBox:GetSelectedItemData().index
    local mainArray = HELP_ASK_FOR_HELP_CATEGORY_INFO[categoryIndex]
    if mainArray and mainArray.subcategories then            
        for i, subcategoryId in ipairs(mainArray.subcategories) do
            if subcategoryId.value == subcategory then
                local PERFORM_CALLBACK = false
                self.helpSubcategoryComboBox:SelectItemByIndex(i, PERFORM_CALLBACK)
                break
            end
        end
    end
end
function HelpAskForHelp_Keyboard:SetDetailsText(text)
    self.details:SetText(text)
end
function HelpAskForHelp_Keyboard:OpenAskForHelp(category, subcategory, playerName)
    HELP_CUSTOMER_SUPPORT_KEYBOARD:OpenScreen(HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT)
    self:ClearFields()
    if category then
        self:SelectCategory(category)
        if subcategory then
            self:SelectSubcategory(subcategory)
        end
    end
    if playerName then
        self:SetDetailsText(playerName)
        ZO_DefaultEdit_SetEnabled(self.details, false)
    end
end
function HelpAskForHelp_Keyboard:AttemptToSendTicket()
    --Populate the ticket fields
    --Category and subcategory values must be valid as they enable the submit button to be clicked On
    local categoryIndex = self.helpCategoryComboBox:GetSelectedItemData().index
    local mainArray = HELP_ASK_FOR_HELP_CATEGORY_INFO[categoryIndex]
    local ticketCategory = TICKET_CATEGORY_OTHER
    if mainArray.subcategories then
        local subcategory = self.helpSubcategoryComboBox:GetSelectedItemData().index
        ticketCategory = mainArray.subcategories[subcategory].ticketCategory
    else
        ticketCategory = mainArray.ticketCategory
    end
    SetCustomerServiceTicketCategory(ticketCategory)
        
    if mainArray.detailsRegistrationFunction then
        local text = self.details:GetText()
        if mainArray.detailsFormatText then
            text = mainArray.detailsFormatText(text)
        end
        mainArray.detailsRegistrationFunction(text)
    end
    ZO_Dialogs_ShowDialog("HELP_CUSTOMER_SERVICE_SUBMITTING_TICKET_DIALOG")
    if categoryIndex == CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_REPORT_PLAYER then
        ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:MarkAttemptingToSubmitReportPlayerTicket()
    end
    ZO_DefaultEdit_SetEnabled(self.details, true)
end
function HelpAskForHelp_Keyboard:OnCustomerServiceTicketSubmitted(response, success)
    if success then
        self:ClearFields()
    end
end
--Global XML
    HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD = HelpAskForHelp_Keyboard:New(self)
end
    HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD:AttemptToSendTicket()
end
    ZO_PlatformOpenApprovedURL(APPROVED_URL_ESO_FORUMS, GetString(SI_CUSTOMER_SERVICE_ESO_FORUMS_LINK_TEXT), GetString(SI_URL_APPLICATION_WEB))
end