ESO Lua File v100010

ingame/contacts/gamepad/sociallist_gamepad.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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
ZO_SOCIAL_LIST_Y_BOTTOM_OFFSET = -100
ZO_SOCIAL_LIST_FOOTER_Y_OFFSET = -50
-----------------
-- Social List
-----------------
ZO_GamepadSocialListPanel = ZO_PagedList:Subclass()
function ZO_GamepadSocialListPanel:New(control, movementContoller)
    local panel = ZO_PagedList.New(self, control, movementContoller)
    return panel
end
function ZO_GamepadSocialListPanel:Initialize(control)
    -- This will control moving "down" off of the options bar back to the lists
    self.vertMovementController = ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_VERTICAL)
    ZO_PagedList.Initialize(self, control, self.vertMovementController)
end
function ZO_GamepadSocialListPanel:InitializeOptionsBar(control)
    self.optionsBarActive = false
    self.currentPanelHeaderActive = false
    self.currentPanelActive = false
    self.searchTerm = ""
    local optionsBar = control:GetNamedChild("OptionsBar")
    self.optionsBar = ZO_GamepadSocialOptionsBar:New(optionsBar)
    local OnFilterChanged = function(text)
        self:SetSearchTerm(text)
        self:RefreshFilters()
    end
        PlaySound(SOUNDS.GAMEPAD_MENU_UP)
        self:ActivatePanelHeader()
    end)
end
function ZO_GamepadSocialListPanel:SetSearchTerm(searchTerm)
    self.searchTerm = searchTerm
end
function ZO_GamepadSocialListPanel:GetSearchTerm()
    return self.searchTerm
end
function ZO_GamepadSocialListPanel:SetHeader(header, headerData)
    self.header = header
    self.headerData = headerData
end
function ZO_GamepadSocialListPanel:ActivateOptionsBar()
    self:DeactivateAll()
    if not self.optionsBarActive then
        DIRECTIONAL_INPUT:Activate(self)
        self.optionsBar:Activate()
        self.optionsBarActive = true
        if self.optionsBarKeybindStripDescriptor then
            KEYBIND_STRIP:AddKeybindButtonGroup(self.optionsBarKeybindStripDescriptor)
        end
    end
end
function ZO_GamepadSocialListPanel:ActivatePanel()
    self:DeactivateAll()
    if not self.currentPanelActive then
        self:Activate()
        self.currentPanelActive = true
    end
   
end
function ZO_GamepadSocialListPanel:ActivatePanelHeader()
    self:DeactivateAll()
    if not self.currentPanelHeaderActive then
        DIRECTIONAL_INPUT:Activate(self)
        self:ActivateHeader()
        self.currentPanelHeaderActive = true
    end
end
function ZO_GamepadSocialListPanel:DeactivateAll()
    if self.optionsBarActive then
        self.optionsBar:Deactivate()
        DIRECTIONAL_INPUT:Deactivate(self)
        self.optionsBarActive = false
        if self.optionsBarKeybindStripDescriptor then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.optionsBarKeybindStripDescriptor)
        end
    end
    
    if self.currentPanelActive then
        self:Deactivate()
        self.currentPanelActive = false
    end
    if self.currentPanelHeaderActive then
        DIRECTIONAL_INPUT:Deactivate(self)
        self:DeactivateHeader()
        self.currentPanelHeaderActive = false
    end
end
function ZO_GamepadSocialListPanel:UpdateDirectionalInput()
    local vertResult = self.vertMovementController:CheckMovement()
    if vertResult == MOVEMENT_CONTROLLER_MOVE_NEXT then
        PlaySound(SOUNDS.GAMEPAD_MENU_DOWN)
        if self.currentPanelHeaderActive then
            self:ActivatePanel()
        else
            self:ActivatePanelHeader()
        end
    elseif vertResult == MOVEMENT_CONTROLLER_MOVE_PREVIOUS then
        if self.currentPanelHeaderActive then
            self:ActivateOptionsBar()
        end
    end
end
function ZO_GamepadSocialListPanel:Activate()
    ZO_PagedList.Activate(self)
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:RefreshTooltip()
end
function ZO_GamepadSocialListPanel:Deactivate()
    
    ZO_PagedList.Deactivate(self)
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:ClearTooltip()
end
function ZO_GamepadSocialListPanel:ActivateHeader()
    ZO_PagedList.ActivateHeader(self)
    if self.headerKeybindStripDescriptor then
        KEYBIND_STRIP:AddKeybindButtonGroup(self.headerKeybindStripDescriptor)
    end
end
function ZO_GamepadSocialListPanel:DeactivateHeader()
    ZO_PagedList.DeactivateHeader(self)
    if self.headerKeybindStripDescriptor then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.headerKeybindStripDescriptor)
    end
end
function ZO_GamepadSocialListPanel:ClearTooltip()
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    GAMEPAD_TOOLTIPS:HideBg(GAMEPAD_RIGHT_TOOLTIP)
end
function ZO_GamepadSocialListPanel:RefreshTooltip()
    local data = self:GetSelectedData()
    if data and data.characterName then
        GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
        GAMEPAD_TOOLTIPS:SetBottomRailHidden(GAMEPAD_RIGHT_TOOLTIP, true)
        self:LayoutTooltip(GAMEPAD_TOOLTIPS, GAMEPAD_RIGHT_TOOLTIP, data)
        GAMEPAD_TOOLTIPS:ShowBg(GAMEPAD_RIGHT_TOOLTIP)
    else
        self:ClearTooltip()
    end
end
function ZO_GamepadSocialListPanel:LayoutTooltip(tooltipManager, tooltip, data)
    -- This function is meant to be overridden in subclasses to display the appropriate toolip information
end
function ZO_GamepadSocialListPanel:OnSelectionChanged(data)
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:RefreshTooltip()
end
function ZO_GamepadSocialListPanel:OnListChanged()
end
function ZO_GamepadSocialListPanel:OnPageChanged()
     if self.keybindStripDescriptor then
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:RefreshTooltip()
end
function ZO_GamepadSocialListPanel:OnEnterRow(control, data)
    self:ColorRow(control, data, true)
end
function ZO_GamepadSocialListPanel:OnLeaveRow(control, data)
    self:ColorRow(control, data, false)
end
function ZO_GamepadSocialListPanel:ColorRow(control, data, selected)
    local textColor, iconColor, textColor2 = self:GetRowColors(data, selected)
    ZO_SocialList_ColorRow(control, data, textColor, iconColor, textColor2)
end
function ZO_GamepadSocialListPanel:GetRowColors(data, selected)
    local textColor = data.online and ZO_NORMAL_TEXT or ZO_DISABLED_TEXT
    local textColor2 = ZO_SELECTED_TEXT
    local iconColor = ZO_SELECTED_TEXT
    return textColor, iconColor, textColor2
end
-----------------
-- Overrides from ZO_PagedList
function ZO_GamepadSocialListPanel:SortList()
    ZO_PagedList.SortList(self)
    if self.options and self.options.socialData then
        self.options:Refresh()
    end
end
-----------------
-- Shared Keybinds
function ZO_GamepadSocialListPanel:InitializeKeybind()
    if self.keybindStripDescriptor ~= nil then return end
    -- Keybind Strip when a list item is selected
    local optionsKeybind = self:GetOptionsKeybind()
    local addKeybind = self:GetAddKeybind()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        optionsKeybind,
        addKeybind,
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.keybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
    -- Keybind Strip when a list column header is selected
    local sortKeybind = self:GetSortKeybind()
    addKeybind = self:GetAddKeybind()
    self.headerKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        sortKeybind,
        addKeybind,
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.headerKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
    -- Keybind Strip when an options bar item is selected
    local selectOptionKeybind = self.optionsBar:GetSelectKeybind()
    addKeybind = self:GetAddKeybind()
    self.optionsBarKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        selectOptionKeybind,
        addKeybind,
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.optionsBarKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
end
function ZO_GamepadSocialListPanel:GetSortKeybind()
    local keybind = {
        name = GetString(SI_GAMEPAD_SORT_OPTION),
        keybind = "UI_SHORTCUT_PRIMARY",
        callback = function()
            self.sortHeaderGroup:SortBySelected()
        end,
    }
    return keybind
end
function ZO_GamepadSocialListPanel:GetOptionsKeybind()
    local keybind = {
        name = GetString(SI_GAMEPAD_SELECT_OPTION),
        keybind = "UI_SHORTCUT_PRIMARY",
        callback = function()
            local data = self:GetSelectedData()
            self:SetupOptions(data)
            self:ShowOptionsDialog()
        end,
        visible = function()
            local data = self:GetSelectedData()
            return data ~= nil
        end,
    }
    return keybind
end
function ZO_GamepadSocialListPanel:GetAddKeybind()
    -- this function is meant be overridden in a subclass
end
-----------------
-- Options Dialog
function ZO_GamepadSocialListPanel:ShowOptionsDialog()
    local parametricList = {}
    self:BuildOptionsList(parametricList)
    local data = {
        parametricList = parametricList,
    }
    ZO_Dialogs_ShowGamepadDialog(GAMEPAD_SOCIAL_OPTIONS_DIALOG_NAME, data)
end
function ZO_GamepadSocialListPanel:BuildOptionsList(list)
    -- This function is meant to be overridden by a subclass
end
function ZO_GamepadSocialListPanel:BuildOptionEntry(header, label, callback, finishedCallback)    
    entry = {
        template = "ZO_GamepadMenuEntryTemplate",
        templateData = {
            text = GetString(label),
            setup = ZO_SharedGamepadEntry_OnSetup,
            callback = callback,
            finishedCallback = finishedCallback,
        },
    }
    return entry
end
function ZO_GamepadSocialListPanel:AddHeader(list, header)
    list.header = header
end
function ZO_GamepadSocialListPanel:AddOption(list, option)
    if option == nil then 
        return 
    end
    if list.header then
        option.header = list.header
        list.header = nil
    end
    table.insert(list, option)
end
function ZO_GamepadSocialListPanel:BuildEditNoteOption()
    local callback = function()
        local data = {
            displayName = self.socialData.displayName,
            note = self.socialData.note,
            noteChangedCallback = self.noteChangedCallback,
        }
        ZO_Dialogs_ShowGamepadDialog(GAMEPAD_SOCIAL_EDIT_NOTE_DIALOG_NAME, data)
    end
    return self:BuildOptionEntry(nil, SI_SOCIAL_MENU_EDIT_NOTE, callback)
end
function ZO_GamepadSocialListPanel:BuildSendMailOption()
    local callback = function() MAIL_MANAGER_GAMEPAD:GetSend():ComposeMailTo(self.socialData.displayName) end
    return self:BuildOptionEntry(nil, SI_SOCIAL_MENU_SEND_MAIL, nil, callback)
end
function ZO_GamepadSocialListPanel:BuildWhisperOption()
    local callback = function() StartChatInput("", CHAT_CHANNEL_WHISPER, self.socialData.displayName) end
    return self:BuildOptionEntry(nil, SI_SOCIAL_LIST_PANEL_WHISPER, callback)
end
function ZO_GamepadSocialListPanel:BuildInviteToGroupOption()
    local callback = function()
        local NOT_SENT_FROM_CHAT = false
        local DISPLAY_INVITED_MESSAGE = true
        TryGroupInviteByName(self.socialData.displayName, NOT_SENT_FROM_CHAT, DISPLAY_INVITED_MESSAGE)
    end
    return self:BuildOptionEntry(nil, SI_SOCIAL_MENU_INVITE, callback)
end
function ZO_GamepadSocialListPanel:BuildTravelToPlayerOption()
    local callback = function() 
        JumpToFriend(self.socialData.displayName) 
        SCENE_MANAGER:ShowBaseScene()
    end
    return self:BuildOptionEntry(nil, SI_SOCIAL_MENU_JUMP_TO_PLAYER, callback)
end
function ZO_GamepadSocialListPanel:BuildGamerCardOption()
    if IsConsoleUI() then
        local callback = function()
                local accountId = nil
                if(self.socialData.friendIndex) then
                    accountId = GetFriendAccountId(self.socialData.friendIndex)
                elseif(self.socialData.ignoreIndex) then
                    accountId = GetIgnoredAccountId(self.socialData.ignoreIndex)
                end
                if(accountId) then
                    ShowGamerCardFromAccountId(accountId)
                else
                    ZO_Dialogs_ShowGamepadDialog("GAMERCARD_UNAVAILABLE")
                end
            end
        return self:BuildOptionEntry(nil, GetGamerCardStringId(), callback)
    end
    return nil
end
function ZO_GamepadSocialListPanel:BuildIgnoreOption()
    local callback = function() ZO_Dialogs_ShowGamepadDialog("CONFIRM_IGNORE_FRIEND", self.socialData, {mainTextParams={self.socialData.displayName}}) end
    return self:BuildOptionEntry(nil, SI_FRIEND_MENU_IGNORE, callback)
end
function ZO_GamepadSocialListPanel:BuildRemoveFriendOption()
    local callback = function() 
        ZO_Dialogs_ShowGamepadDialog("CONFIRM_REMOVE_FRIEND", self.socialData, {mainTextParams={self.socialData.displayName}}) 
    end
    return self:BuildOptionEntry(nil, SI_FRIEND_MENU_REMOVE_FRIEND, callback)
end
function ZO_GamepadSocialListPanel:BuildRemoveIgnoreOption()
    local callback = function() 
        RemoveIgnore(self.socialData.displayName)
        PlaySounds(SOUNDS.DIALOG_ACCEPT)
    end
    return self:BuildOptionEntry(nil, SI_IGNORE_MENU_REMOVE_IGNORE, callback)
end
-----------------
-- XML Funcitons
local HEADER_ALIGNMENT_TO_HIGHLIGHT = {
    [TEXT_ALIGN_LEFT] = "ZO_Gamepad_Social_Highlight_Header_Left",
    [TEXT_ALIGN_CENTER] = "ZO_Gamepad_Social_Highlight_Header_Center",
    [TEXT_ALIGN_RIGHT] = "ZO_Gamepad_Social_Highlight_Header_Right",
}
    ZO_SortHeader_Initialize(control, GetString(text), sort, ZO_SORT_ORDER_UP, alignment, "ZoFontGamepad27", HEADER_ALIGNMENT_TO_HIGHLIGHT[alignment])
end