Back to Home

ESO Lua File v101036

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
394
395
396
397
398
399
400
401
402
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.helpCategoryContainer = control:GetNamedChild("CategoryContainer")
    self.helpSubcategoryContainer = control:GetNamedChild("SubcategoryContainer")
    self.helpDetailsContainer = control:GetNamedChild("DetailsContainer")
    self.helpImpactComboBoxControl = control:GetNamedChild("ImpactComboBox")
    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
local function OnComboBoxEntryMouseEnter(comboBox, entry)
    local description = ZO_GetAskForHelpListEntryDescription(entry.m_data.descriptionStringName, entry.m_data.data)
    if description then
        InitializeTooltip(InformationTooltip, comboBox.m_container, RIGHT, -10)
        InformationTooltip:AddLine(description, "", ZO_NORMAL_TEXT:UnpackRGBA())
    end
end
local function OnComboBoxEntryMouseExit(comboBox, entry)
    ClearTooltip(InformationTooltip)
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.helpImpactComboBox = CreateComboBox("ImpactComboBox")
    self.helpCategoryComboBox = CreateComboBox("CategoryComboBox")
    self.helpSubcategoryComboBox = CreateComboBox("SubcategoryComboBox")
    local function OnImpactChanged()
        self:UpdateCategories()
        self:UpdateDetailsComponents()
        self:UpdateSubmitButton()
        ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:SetReportPlayerTicketSubmittedCallback(nil)
    end
    local impactStringName = ZO_HELP_ASK_FOR_HELP_CATEGORY_INFO.impactStringName
    local impacts = ZO_HELP_ASK_FOR_HELP_CATEGORY_INFO.impacts
    for _, impactData in ipairs(impacts) do
        local entry = ZO_ComboBox:CreateItemEntry(GetListEntryName(impactStringName, impactData), OnImpactChanged)
        entry.data = impactData
        self.helpImpactComboBox:AddItem(entry, ZO_COMBOBOX_SUPPRESS_UPDATE)
    end
    self.helpImpactComboBox:SelectItemByIndex(1)
end
function HelpAskForHelp_Keyboard:InitializeTextBoxes()
    self.details = self.control:GetNamedChild("DetailsTextLineField")
    self.details:SetMaxInputChars(MAX_HELP_DETAILS_TEXT)
    self.details:SetDefaultText(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.details:SetHandler("OnTextChanged",function() self:UpdateSubmitButton() end)
    self.description = self.control:GetNamedChild("DescriptionBodyField")
    self.description:SetMaxInputChars(MAX_HELP_DESCRIPTION_BODY)
    self.description:SetDefaultText(GetString(SI_CUSTOMER_SERVICE_DEFAULT_DESCRIPTION_TEXT_GENERIC))
    --The Submit Button is disabled if the description text is empty
    self.description:SetHandler("OnTextChanged",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:UpdateCategories()
    self.helpCategoryComboBox:ClearItems()
    local selectedItemData = self.helpImpactComboBox:GetSelectedItemData()
    local impactData = selectedItemData and selectedItemData.data or nil
    local categories = impactData and impactData.categories or nil
    if categories then
        local function OnCategoryChanged()
            self:UpdateSubcategories()
            self:UpdateSubmitButton()
        end
        self:SetCategoryContentHidden(false)
        local categoryStringName = impactData.categoryStringName
        local categoryDescriptionStringName = impactData.categoryDescriptionStringName
        for _, categoryData in ipairs(categories) do
            local entry = ZO_ComboBox:CreateItemEntry(GetListEntryName(categoryStringName, categoryData), OnCategoryChanged)
            entry.data = categoryData
            entry.descriptionStringName = categoryDescriptionStringName
            self.helpCategoryComboBox:AddItem(entry, ZO_COMBOBOX_UPDATE_NOW)
        end
        self.helpCategoryComboBox:SelectItemByIndex(1)
    else
        self:SetCategoryContentHidden(true)
    end
    
end
function HelpAskForHelp_Keyboard:UpdateSubcategories()
    self.helpSubcategoryComboBox:ClearItems()
    local selectedItemData = self.helpCategoryComboBox:GetSelectedItemData()
    local categoryData = selectedItemData and selectedItemData.data or nil
    local subcategories = categoryData and categoryData.subcategories or nil
    if subcategories then
        local function OnCategoryChanged()
            self:UpdateSubmitButton()
        end
        self:SetSubcategoryContentHidden(false)
        local subcategoryStringName = categoryData.subcategoryStringName
        local subcategoryDescriptionStringName = categoryData.subcategoryDescriptionStringName
        for _, subcategoryData in ipairs(subcategories) do
            local entry = ZO_ComboBox:CreateItemEntry(GetListEntryName(subcategoryStringName, subcategoryData), OnCategoryChanged)
            entry.data = subcategoryData
            entry.descriptionStringName = subcategoryDescriptionStringName
            self.helpSubcategoryComboBox:AddItem(entry, ZO_COMBOBOX_UPDATE_NOW)
        end
        self.helpSubcategoryComboBox:SelectItemByIndex(1)
    else
        self:SetSubcategoryContentHidden(true)
    end
end
function HelpAskForHelp_Keyboard:UpdateDetailsComponents()
    self.details:SetText("")
    local selectedItemData = self.helpImpactComboBox:GetSelectedItemData()
    local impactData = selectedItemData and selectedItemData.data or nil
    local detailsTitle = impactData and impactData.detailsTitle or nil
        
    if detailsTitle then
        self:SetDetailsContentHidden(false)
        self.helpDetailsTitle:SetText(detailsTitle)
    else
        self:SetDetailsContentHidden(true)
    end
end
function HelpAskForHelp_Keyboard:SetCategoryContentHidden(shouldHide)
    self.helpCategoryComboBoxControl:SetHidden(shouldHide)
    self.helpCategoryTitle:SetHidden(shouldHide)
    local offsetY = 0
    if not shouldHide then
        offsetY = 20
    end
    self.helpCategoryContainer:SetAnchor(TOPLEFT, self.helpImpactComboBoxControl, BOTTOMLEFT, 0, offsetY)
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.helpCategoryContainer, BOTTOMLEFT, 0, offsetY)
end
function HelpAskForHelp_Keyboard:SetDetailsContentHidden(shouldHide)
    self.helpDetailsTextControl:SetHidden(shouldHide)
    self.helpDetailsTitle:SetHidden(shouldHide)
    ZO_DefaultEdit_SetEnabled(self.details, not 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.description:GetText() == ""  then
        enableSubmitButton = false
    elseif not self.helpDetailsTextControl:IsHidden() and self.details:GetText() == "" then
        enableSubmitButton = false
    elseif not self:GetSelectedTicketCategory() then
        enableSubmitButton = false
    end
    self.helpSubmitButton:SetEnabled(enableSubmitButton)
end
function HelpAskForHelp_Keyboard:ClearFields()
    self.helpImpactComboBox:SelectItemByIndex(1)
    self.description:SetText("")
    ZO_HELP_GENERIC_TICKET_SUBMISSION_MANAGER:SetReportPlayerTicketSubmittedCallback(nil)
end
function HelpAskForHelp_Keyboard:SelectImpact(impactId)
    local impacts = self.helpImpactComboBox:GetItems()
    for i, impactItem in ipairs(impacts) do
        if impactItem.data.id == impactId then
            local PERFORM_CALLBACK = false
            self.helpImpactComboBox:SelectItemByIndex(i, PERFORM_CALLBACK)
            break
        end
    end
end
function HelpAskForHelp_Keyboard:SelectCategory(categoryId)
    local categories = self.helpCategoryComboBox:GetItems()
    for i, categoryItem in ipairs(categories) do
        if categoryItem.data.id == categoryId then
            local PERFORM_CALLBACK = false
            self.helpCategoryComboBox:SelectItemByIndex(i, PERFORM_CALLBACK)
            break
        end
    end
end
function HelpAskForHelp_Keyboard:SelectSubcategory(subcategoryId)
    local subcategories = self.helpSubcategoryComboBox:GetItems()
    for i, subcategoryItem in ipairs(subcategories) do
        if subcategoryItem.data.id == subcategoryId then
            local PERFORM_CALLBACK = false
            self.helpSubcategoryComboBox:SelectItemByIndex(i, PERFORM_CALLBACK)
            break
        end
    end
end
function HelpAskForHelp_Keyboard:SetDetailsText(text)
    self.details:SetText(text)
end
function HelpAskForHelp_Keyboard:OpenAskForHelp(impactId, categoryId, subcategoryId, details)
    HELP_CUSTOMER_SUPPORT_KEYBOARD:OpenScreen(HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT)
    self:ClearFields()
    if impactId then
        self:SelectImpact(impactId)
        if categoryId then
            self:SelectCategory(categoryId)
            if subcategoryId then
                self:SelectSubcategory(subcategoryId)
            end
        end
    end
    if details then
        self:SetDetailsText(details)
        ZO_DefaultEdit_SetEnabled(self.details, false)
    end
end
function HelpAskForHelp_Keyboard:GetSelectedTicketCategory()
    local selectedItemData = self.helpImpactComboBox:GetSelectedItemData()
    local impactData = selectedItemData and selectedItemData.data
    if impactData then
        if impactData.ticketCategory then
            return impactData.ticketCategory
        else
            selectedItemData = self.helpCategoryComboBox:GetSelectedItemData()
            local categoryData = selectedItemData and selectedItemData.data
            if categoryData then
                if categoryData.ticketCategory then
                    return categoryData.ticketCategory
                else
                    selectedItemData = self.helpSubcategoryComboBox:GetSelectedItemData()
                    local subcategoryData = selectedItemData and selectedItemData.data
                    if subcategoryData then
                        return subcategoryData.ticketCategory
                    end
                end
            end
        end
    end
    return nil
end
function HelpAskForHelp_Keyboard:AttemptToSendTicket()
    --Populate the ticket fields. Impact data must be selected in order to get here.
    local impactData = self.helpImpactComboBox:GetSelectedItemData().data
    if impactData.detailsRegistrationFunction then
        local text = self.details:GetText()
        if impactData.detailsFormatText then
            text = impactData.detailsFormatText(text)
        end
        impactData.detailsRegistrationFunction(text)
    end
    ZO_Dialogs_ShowDialog("HELP_CUSTOMER_SERVICE_SUBMITTING_TICKET_DIALOG")
    if impactData.id == CUSTOMER_SERVICE_ASK_FOR_HELP_IMPACT_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