ESO Lua File v100012

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
-----------------
-- Social List
-----------------
ZO_GamepadSocialListPanel = ZO_Object.MultiSubclass(ZO_PagedList, ZO_SocialOptionsDialogGamepad)
function ZO_GamepadSocialListPanel:New(control, movementContoller)
    local panel = ZO_PagedList.New(self, control, movementContoller)
    return panel
end
function ZO_GamepadSocialListPanel:Initialize(control)
    self.control = control
    -- This will control moving "down" off of the options bar back to the lists
    self.vertMovementController = ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_VERTICAL)
    self.playerAlliance = GetUnitAlliance("player")
    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:SetTitle(title)
    self.optionsBar:SetTitle(title)
end
function ZO_GamepadSocialListPanel:SetSubtitle(subtitle)
    self.optionsBar:SetSubtitle(subtitle)
end
function ZO_GamepadSocialListPanel:ActivateOptionsBar()
    if not self.optionsBarActive then
        DIRECTIONAL_INPUT:Activate(self, self.control)
        self.optionsBar:Activate()
        self.optionsBarActive = true
        if self.optionsBarKeybindStripDescriptor then
            KEYBIND_STRIP:AddKeybindButtonGroup(self.optionsBarKeybindStripDescriptor)
        end
    end
end
function ZO_GamepadSocialListPanel:ActivatePanel()
    self:TakeFocus()
    if not self.currentPanelActive then
        self.currentPanelActive = true
        self:Activate()
    end
end
function ZO_GamepadSocialListPanel:ActivatePanelHeader()
    self:ClearFocus()
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:ClearTooltip()
    if not self.currentPanelHeaderActive then
        DIRECTIONAL_INPUT:Activate(self, self.control)
        self:ActivateHeader()
        self.currentPanelHeaderActive = true
    end
end
function ZO_GamepadSocialListPanel:DeactivateOptionBar()
    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
end
function ZO_GamepadSocialListPanel:DeactivatePanel()
    if self.currentPanelActive then
        self:Deactivate()
        self.currentPanelActive = false
    end
end
function ZO_GamepadSocialListPanel:DeactivatePanelHeader()
    if self.currentPanelHeaderActive then
        DIRECTIONAL_INPUT:Deactivate(self)
        self:DeactivateHeader()
        self.currentPanelHeaderActive = false
    end
end
function ZO_GamepadSocialListPanel:DeactivateAll()
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:Deactivate()
    ZO_PagedList.Deactivate(self)
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:ClearTooltip()
end
function ZO_GamepadSocialListPanel:TakeFocus()
    ZO_PagedList.TakeFocus(self)
    if self.keybindStripDescriptor then
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:RefreshTooltip()
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()
    if self.currentPanelActive then
        local data = self:GetSelectedData()
        if data and (zo_strlen(data.characterName) > 0) 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
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.currentPanelActive then
        if self.keybindStripDescriptor then
            KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
        end
        self:RefreshTooltip()
    end
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, self:GetBackKeybindCallback())
    -- 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, self:GetBackKeybindCallback())
    -- 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, self:GetBackKeybindCallback())
end
function ZO_GamepadSocialListPanel:GetSortKeybind()
    local keybind = {
        name = GetString(SI_GAMEPAD_SORT_OPTION),
        keybind = "UI_SHORTCUT_PRIMARY",
        callback = function()
            self.sortHeaderGroup:SortBySelected()
            self:SetPage(1)
        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
function ZO_GamepadSocialListPanel:GetBackKeybindCallback()
    -- this function can be overridden in a subclass
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, text, sort, ZO_SORT_ORDER_UP, alignment, "ZoFontGamepad27", HEADER_ALIGNMENT_TO_HIGHLIGHT[alignment])
end
end