Back to Home

ESO Lua File v100019

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
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,
               },
          },          
     },
}
local ESO_FORUMS_URL_TYPE = {urlType = APPROVED_URL_ESO_FORUMS}
local ESO_FORUMS_FRONT_FACING_ADDRESS = {mainTextParams = {GetString(SI_CUSTOMER_SERVICE_ESO_FORUMS_LINK_TEXT), GetString(SI_URL_APPLICATION_WEB)}}
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")
     control:RegisterForEvent(EVENT_CUSTOMER_SERVICE_TICKET_SUBMITTED, function (...)
                                                                                          if HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD_FRAGMENT:IsShowing() then
                                                                                               self:OnCustomerServiceTicketSubmitted(...)
                                                                                          end
                                                                                     end)
     self:InitializeTextBoxes()
     self:InitializeComboBoxes()     
     self:InitializeDialogs()
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()
     end
     for i = CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_MIN_VALUE, CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_MAX_VALUE do
          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
     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_ASK_FOR_HELP))
     --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
          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_MIN_VALUE 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("")
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)
    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
     SetCustomerServiceTicketBody(self.description:GetText())
     ZO_Dialogs_ShowDialog("HELP_CUSTOMER_SERVICE_SUBMITTING_TICKET_DIALOG")
end
function HelpAskForHelp_Keyboard:OnCustomerServiceTicketSubmitted(eventCode, response, success)
     ZO_Dialogs_ReleaseDialog("HELP_CUSTOMER_SERVICE_SUBMITTING_TICKET_DIALOG")
     if success then
          ZO_Dialogs_ShowDialog("HELP_ASK_FOR_HELP_SUBMIT_TICKET_SUCCESSFUL_DIALOG", nil, {mainTextParams = {response}})
          self:ClearFields()
     else
          ZO_Dialogs_ShowDialog("HELP_CUSTOMER_SERVICE_SUBMIT_TICKET_ERROR_DIALOG", nil, {mainTextParams = {response}})
     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_Dialogs_ShowDialog("CONFIRM_OPEN_URL_BY_TYPE", ESO_FORUMS_URL_TYPE, ESO_FORUMS_FRONT_FACING_ADDRESS)
end