Back to Home

ESO Lua File v100030

libraries/zo_combobox/gamepad/zo_combobox_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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
ZO_GAMEPAD_COMBO_BOX_FONT = "ZoFontGamepad27"
ZO_GAMEPAD_COMBO_BOX_HIGHLIGHTED_FONT = "ZoFontGamepad36"
ZO_GAMEPAD_COMBO_BOX_PADDING = 16
-------------------------------------------------------------------------------
-- ZO_ComboBox_Gamepad
-------------------------------------------------------------------------------
ZO_ComboBox_Gamepad = ZO_Object.MultiSubclass(ZO_ComboBox_Base, ZO_CallbackObject)
function ZO_ComboBox_Gamepad:New(...)
    local object = ZO_CallbackObject.New(self)
    object:Initialize(...)
    return object
end
function ZO_ComboBox_Gamepad:Initialize(control)
    ZO_ComboBox_Base.Initialize(self, control)
    control.comboBoxObject = self
    self.m_active = false
    self.dropdownTemplate = ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD
    self.m_dropdown = GAMEPAD_COMBO_BOX_DROPDOWN
    self.m_focus = ZO_GamepadFocus:New(control)
    self.m_highlightedIndex = 1
    self.m_highlightColor = ZO_SELECTED_TEXT
    self.m_normalColor = ZO_DISABLED_TEXT
    
    self.m_font = ZO_GAMEPAD_COMBO_BOX_FONT
    self.m_highlightFont = ZO_GAMEPAD_COMBO_BOX_HIGHLIGHTED_FONT
    -- find the difference in font size to keep the width of text the same between them
    -- so line wrapping looks consistent between the two fonts
    local _, unselectedSize = _G[self.m_font]:GetFontInfo()
    local _, selectedSize = _G[self.m_highlightFont]:GetFontInfo()
    self.m_fontRatio = unselectedSize / selectedSize
end
function ZO_ComboBox_Gamepad:ShowDropdownInternal()
    self:ClearMenuItems()
    self.m_dropdown:SetTemplate(self.dropdownTemplate)
    self.m_dropdown:SetPadding(self.m_padding)
    self:AddMenuItems()
    self.m_container:SetHidden(true)
    self.m_dropdown:Show()
    self:SetVisible(true)
end
function ZO_ComboBox_Gamepad:HideDropdownInternal()
    self:ClearMenuItems()
    self:SetVisible(false)
    self.m_container:SetHidden(false)
    self.m_dropdown:Hide()
    self:SetActive(false)
    self:FireCallbacks("OnHideDropdown")
end
function ZO_ComboBox_Gamepad:OnClearItems()
    self.m_highlightedIndex = nil
    self.m_currentData = nil
end
function ZO_ComboBox_Gamepad:OnItemAdded()
    if not self.m_highlightedIndex then
        self.m_highlightedIndex = 1
    end
end
function ZO_ComboBox_Gamepad:GetNormalColor(item)
    local itemColor = item.m_normalColor or self.m_normalColor
    return itemColor
end
function ZO_ComboBox_Gamepad:GetHighlightColor(item)
    local itemColor = item.m_highlightColor or self.m_highlightColor
    return itemColor
end
function ZO_ComboBox_Gamepad:GetHeight()
    if(self.m_selectedItemText) then
        return self.m_selectedItemText:GetTextHeight()
    end
    return self.m_container:GetHeight()
end
function ZO_ComboBox_Gamepad:AddMenuItems()
    for i = 1, #self.m_sortedItems do
        -- The variable item must be defined locally here, otherwise it won't work as an upvalue to the selection helper
        local item = self.m_sortedItems[i]
        local control = self.m_dropdown:AddItem(item)
        
        self:SetupMenuItemControl(control, item)
        local focusEntry = {
            control = control,
            data = item,
            activate = function(control, data) self:OnItemSelected(control, data) end,
            deactivate = function(control, data) self:OnItemDeselected(control, data) end,
        }
        self.m_focus:AddEntry(focusEntry)
    end
    self.m_dropdown:AnchorToControl(self.m_container, 0)
end
function ZO_ComboBox_Gamepad:SetupMenuItemControl(control, item)
    control.nameControl = control:GetNamedChild("Name")
    control.nameControl:SetText(item.name)
    control.nameControl:SetColor(self:GetNormalColor(item):UnpackRGBA())
    control.nameControl:SetFont(self.m_highlightFont) -- Use the highlighted font for sizing purposes
    control.nameControl:SetWidth(self.m_container:GetWidth())
    local height = control.nameControl:GetTextHeight()
    control:SetHeight(height)
    self.m_dropdown:AddHeight(height)
    if self.m_font then
        control.nameControl:SetFont(self.m_font)
        control.nameControl:SetWidth(self.m_container:GetWidth() * self.m_fontRatio)
    end
end
function ZO_ComboBox_Gamepad:OnItemSelected(control, data)
    control.nameControl:SetWidth(self.m_container:GetWidth())
    control.nameControl:SetFont(self.m_highlightFont)
    self.m_currentData = data
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor, self.m_keybindState)
    self:FireCallbacks("OnItemSelected", control, data)
end
function ZO_ComboBox_Gamepad:OnItemDeselected(control, data)
    control.nameControl:SetWidth(self.m_container:GetWidth() * self.m_fontRatio)
    control.nameControl:SetFont(self.m_font)
    self:FireCallbacks("OnItemDeselected", control, data)
end
function ZO_ComboBox_Gamepad:ClearMenuItems()
   self.m_focus:RemoveAllEntries()
   self.m_dropdown:Clear()
end
function ZO_ComboBox_Gamepad:SetActive(active)
    if self.m_active ~= active then
        self.m_active = active
        if self.m_active then
            self.m_focus:Activate()
            self.m_keybindState = KEYBIND_STRIP:PushKeybindGroupState()
            KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor, self.m_keybindState)
        else
            self.m_focus:Deactivate()
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor, self.m_keybindState)
            KEYBIND_STRIP:PopKeybindGroupState()
            
            if self.deactivatedCallback and not self.blockDeactivatedCallback then
               self.deactivatedCallback(self.deactivatedCallbackArgs)
            end
        end
    end
end
function ZO_ComboBox_Gamepad:HighlightSelectedItem()
    self:SetHighlightedItem(self.m_highlightedIndex)
end
function ZO_ComboBox_Gamepad:SelectHighlightedItem()
    local focusItem = self.m_focus:GetFocusItem()
    local focusIndex = self.m_focus:GetFocus()
    if focusIndex then
        self.m_highlightedIndex = focusIndex -- This needs to come before self:SelectItem() otherwise self.m_focus:GetFocus() always returns nil
    end
    if focusItem then
        self:SelectItem(focusItem.data)
        PlaySound(SOUNDS.DEFAULT_CLICK)
    end
   
    self:Deactivate()
end
function ZO_ComboBox_Gamepad:IsHighlightedItemEnabled()
    if self.m_currentData then
        return self.m_currentData.enabled ~= false
    end
    return true
end
function ZO_ComboBox_Gamepad:SelectItemByIndex(index, ignoreCallback)
    self.m_highlightedIndex = index
    ZO_ComboBox_Base.SelectItemByIndex(self, index, ignoreCallback)
end
function ZO_ComboBox_Gamepad:SetHighlightedItem(highlightIndex, reselectIndex)
    self.m_focus:SetFocusByIndex(highlightIndex, reselectIndex)
end
function ZO_ComboBox_Gamepad:TrySelectItemByData(itemData, ignoreCallback)
    for i, data in ipairs(self.m_sortedItems) do
        if data.name == itemData.name then
            self:SelectItemByIndex(i, ignoreCallback)
            return true
        end
    end
    return false
end
do
    local INCLUDE_SAVED_INDEX = true
    function ZO_ComboBox_Gamepad:GetHighlightedIndex()
        return self.m_focus:GetFocus(INCLUDE_SAVED_INDEX)
    end
end
function ZO_ComboBox_Gamepad:Activate()
    self:SetActive(true)
    PlaySound(SOUNDS.COMBO_CLICK)
end
function ZO_ComboBox_Gamepad:Deactivate(blockCallback)
    self.blockDeactivatedCallback = blockCallback
    self.blockDeactivatedCallback = false
end
function ZO_ComboBox_Gamepad:IsActive()
    return self.m_active
end
function ZO_ComboBox_Gamepad:SetDeactivatedCallback(callback, args)
    self.deactivatedCallbackArgs = args
end
function ZO_ComboBox_Gamepad:SetKeybindAlignment(alignment)
    self.keybindStripDescriptor.alignment = alignment
end
function ZO_ComboBox_Gamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        
        -- since we can now have combo boxes in dialogs and in normal ui elements
        -- we want to make sure our combo box is listening for the proper keybinds
        -- based on whether or not a dialog is active
        {
            keybind = "UI_SHORTCUT_NEGATIVE",
            name = GetString(SI_GAMEPAD_BACK_OPTION),
            callback = function()
               PlaySound(SOUNDS.GAMEPAD_MENU_BACK)
               self:Deactivate()
            end,
            visible = function() return not ZO_Dialogs_IsShowingDialog() end,
        },
        {
            keybind = "DIALOG_NEGATIVE",
            name = GetString(SI_GAMEPAD_BACK_OPTION),
            callback = function()
               self:Deactivate()
            end,
            visible = ZO_Dialogs_IsShowingDialog,
        },
        {
            keybind = "UI_SHORTCUT_PRIMARY",
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            callback = function()
                self:SelectHighlightedItem()
            end,
            enabled = function()
                return self:IsHighlightedItemEnabled()
            end,
            visible = function() return not ZO_Dialogs_IsShowingDialog() end,
        },
        {
            keybind = "DIALOG_PRIMARY",
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            callback = function()
                self:SelectHighlightedItem()
            end,
            enabled = function()
                return self:IsHighlightedItemEnabled()
            end,
            visible = ZO_Dialogs_IsShowingDialog,
        },
    }
end
function ZO_ComboBox_Gamepad:UpdateAnchors(selectedControl)
    -- The control box will always be centered on the original dropdown location
    local topItem = self.m_focus:GetItem(1)
    local topControl = topItem.control
    local offset = topControl:GetTop() - selectedControl:GetTop()
    self.m_dropdown:AnchorToControl(self.m_container, offset)
end
-------------------------------------------------------------------------------
-- ZO_GamepadComboBoxDropdown
-------------------------------------------------------------------------------
-- ZO_ComboBox_Gamepad_Dropdown is a singleton that is used by the current dropdown to display a list
ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD = "ZO_ComboBox_Item_Gamepad"
ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_MULTISELECTION = "ZO_MultiSelection_ComboBox_Item_Gamepad"
ZO_GamepadComboBoxDropdown = ZO_Object:Subclass()
function ZO_GamepadComboBoxDropdown:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_GamepadComboBoxDropdown:Initialize(control)
    self.dropdownControl = control
    self.scrollControl = control:GetNamedChild("Scroll")
    self.backgroundControl = control:GetNamedChild("Background")
    self.templateName = ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD
    self.pools = 
    {
        [ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD] = ZO_ControlPool:New(ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD, self.scrollControl, ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_STANDARD),
        [ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_MULTISELECTION] = ZO_ControlPool:New(ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_MULTISELECTION, self.scrollControl, ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_MULTISELECTION)
    }
    self.lastControlAdded = nil
    self.height = 0
    self.padding = 0
    self.borderPadding = ZO_GAMEPAD_COMBO_BOX_PADDING
    self.minY = 70
    local function RefreshMaxY()
        self.maxY = GuiRoot:GetHeight() + ZO_GAMEPAD_QUADRANT_BOTTOM_OFFSET
    end
    RefreshMaxY()
    EVENT_MANAGER:RegisterForEvent("GamepadComboBoxDropdown", EVENT_SCREEN_RESIZED, RefreshMaxY)
end
function ZO_GamepadComboBoxDropdown:SetPadding(padding)
    self.padding = padding
end
function ZO_GamepadComboBoxDropdown:Show()
    self.dropdownControl:SetHidden(false)
end
function ZO_GamepadComboBoxDropdown:Hide()
    self.dropdownControl:SetHidden(true)
end
function ZO_GamepadComboBoxDropdown:AnchorToControl(control, offsetY)
    local controlTop = control:GetTop()
    local dropDownTop = controlTop + offsetY - self.borderPadding 
    local dropDownBottom = controlTop + offsetY + self.height + self.borderPadding
    local topYDelta = 0
    if dropDownTop < self.minY then
        topYDelta = (self.minY - dropDownTop)
    end
    local bottomYDelta = 0
    if dropDownBottom > self.maxY then
        bottomYDelta = (dropDownBottom - self.maxY)
    end
    self.dropdownControl:SetAnchor(TOPLEFT, control, TOPLEFT, 0, offsetY)
    self.dropdownControl:SetDimensions(control:GetWidth(), self.height)
    local backgroundOffsetYTop = -self.borderPadding + topYDelta
    local backgroundOffsetBottomTop = self.borderPadding - bottomYDelta
    self.scrollControl:SetAnchor(TOPLEFT, self.dropdownControl, TOPLEFT, -ZO_GAMEPAD_COMBO_BOX_PADDING, backgroundOffsetYTop)
    self.scrollControl:SetAnchor(BOTTOMRIGHT, self.dropdownControl, BOTTOMRIGHT, ZO_GAMEPAD_COMBO_BOX_PADDING, backgroundOffsetBottomTop)
    self.backgroundControl:SetAnchor(TOPLEFT, self.dropdownControl, TOPLEFT, -ZO_GAMEPAD_COMBO_BOX_PADDING, backgroundOffsetYTop)
    self.backgroundControl:SetAnchor(BOTTOMRIGHT, self.dropdownControl, BOTTOMRIGHT, ZO_GAMEPAD_COMBO_BOX_PADDING, backgroundOffsetBottomTop)
end
function ZO_GamepadComboBoxDropdown:AcquireControl(item, relativeControl)
    local padding = self.padding
    local controlPool = self:GetControlPoolFromTemplate(self.template)
    local control, key = controlPool:AcquireObject()
    control:SetAnchor(RIGHT, self.m_container, RIGHT, 0, padding, ANCHOR_CONSTRAINS_X)
    if relativeControl then
        control:SetAnchor(TOPLEFT, relativeControl, BOTTOMLEFT, 0, padding)
    else
        control:SetAnchor(TOPLEFT, self.dropdownControl, TOPLEFT, 0, padding)
    end
    control.key = key
    control.item = item
    return control
end
function ZO_GamepadComboBoxDropdown:AddHeight(height)
    self.height = self.height + height
end
function ZO_GamepadComboBoxDropdown:AddItem(data)
    local control = self:AcquireControl(data, self.lastControlAdded)
    self.lastControlAdded = control
    return control
end
function ZO_GamepadComboBoxDropdown:Clear()
    for _, pool in pairs(self.pools) do
        pool:ReleaseAllObjects()
    end
    self.lastControlAdded = nil
    self.height = 0
end
function ZO_GamepadComboBoxDropdown:SetTemplate(template)
    self.template = template
end
function ZO_GamepadComboBoxDropdown:GetControlPoolFromTemplate(template)
    return self.pools[template]
end
-- This is a control used by all gamepad combo boxes to display the dropdown
    GAMEPAD_COMBO_BOX_DROPDOWN = ZO_GamepadComboBoxDropdown:New(control)
end
-------------------------------------------------------------------------------
-- ZO_MultiSelection_ComboBox_Gamepad
-------------------------------------------------------------------------------
ZO_MultiSelection_ComboBox_Gamepad = ZO_ComboBox_Gamepad:Subclass()
function ZO_MultiSelection_ComboBox_Gamepad:New(...)
    return ZO_ComboBox_Gamepad.New(self, ...)
end
function ZO_MultiSelection_ComboBox_Gamepad:Initialize(control)
    ZO_ComboBox_Gamepad.Initialize(self, control)
    self.dropdownTemplate = ZO_GAMEPAD_COMBOBOX_DROPDOWN_TEMPLATE_MULTISELECTION
    self.itemDataToControl = {}
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:SelectHighlightedItem()
    local focusItem = self.m_focus:GetFocusItem()
    local focusIndex = self.m_focus:GetFocus()
    if focusIndex then
        self.m_highlightedIndex = focusIndex -- This needs to come before self:SelectItem() otherwise self.m_focus:GetFocus() always returns nil
    end
    if focusItem then
        self:SelectItem(focusItem.data)
        PlaySound(SOUNDS.DEFAULT_CLICK)
    end
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:SelectItem(item, ignoreCallback)
    self.currentItemData:ToggleItemSelected(item)
    local newSelectedState = self.currentItemData:IsItemSelected(item)
    local control = self.itemDataToControl[item]
    if self.currentItemData:IsItemSelected(item) then
        ZO_CheckButton_SetChecked(control.checkBox)
    else
        ZO_CheckButton_SetUnchecked(control.checkBox)
    end
    if item.callback and not ignoreCallback then
        item.callback(self, item.name, item, newSelectedState)
    end
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:SetupMenuItemControl(control, item)
    ZO_ComboBox_Gamepad.SetupMenuItemControl(self, control, item)
    control.checkBox = control:GetNamedChild("CheckBox")
    if self.currentItemData:IsItemSelected(item) then
        ZO_CheckButton_SetChecked(control.checkBox)
    else
        ZO_CheckButton_SetUnchecked(control.checkBox)
    end
    self.itemDataToControl[item] = control
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:ShowDropdownInternal()
    self.itemDataToControl = {}
    ZO_ComboBox_Gamepad.ShowDropdownInternal(self)
end
function ZO_MultiSelection_ComboBox_Gamepad:LoadData(data)
    self.currentItemData = data
    self:ClearItems()
    for i, item in ipairs(data.entryItems) do
        self:AddItem(item, ZO_COMBOBOX_SUPRESS_UPDATE)
    end
    self:UpdateItems()
end
function ZO_MultiSelection_ComboBox_Gamepad:SetNoSelectionText(text)
    self.noSelectionText = text
end
function ZO_MultiSelection_ComboBox_Gamepad:SetMultiSelectionTextFormatter(textFormatter)
    self.multiSelectionTextFormatter = textFormatter
end
function ZO_MultiSelection_ComboBox_Gamepad:RefreshSelectedItemText()
    local numSelectedEntries = self:GetNumSelectedEntries()
    if numSelectedEntries > 0 then
        if self.multiSelectionTextFormatter then
            self:SetSelectedItemText(zo_strformat(self.multiSelectionTextFormatter, numSelectedEntries))
        end
    elseif self.noSelectionText then
        self:SetSelectedItemText(self.noSelectionText)
    end
end
function ZO_MultiSelection_ComboBox_Gamepad:GetNumSelectedEntries()
    if self.currentItemData then
        return self.currentItemData:GetNumSelectedItems()
    end
    return 0
end
-- ZO_MultiSelection_ComboBox_Data_Gamepad
-------------------------------------------
ZO_MultiSelection_ComboBox_Data_Gamepad = ZO_Object:Subclass()
function ZO_MultiSelection_ComboBox_Data_Gamepad:New()
    local object = ZO_Object.New(self)
    object:Initialize()
    return object
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:Initialize()
    self.entryItems = {}
    self.selectedItems = {}
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:Clear()
    ZO_ClearNumericallyIndexedTable(self.selectedItems)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:AddItem(item)
    table.insert(self.entryItems, item)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:GetAllItems()
    return self.entryItems
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:ToggleItemSelected(item)
    local newSelectedState = not self:IsItemSelected(item)
    self:SetItemSelected(item, newSelectedState)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:SetItemSelected(item, isSelected)
    if isSelected ~= self:IsItemSelected(item) then
        if isSelected then
            self:AddItemToSelected(item)
        else
            self:RemoveItemFromSelected(item)
        end
    end
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:SetItemIndexSelected(itemIndex, isSelected)
    self:SetItemSelected(self.entryItems[itemIndex], isSelected)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:GetNumSelectedItems()
    return #self.selectedItems
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:AddItemToSelected(item)
    table.insert(self.selectedItems, item)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:RemoveItemFromSelected(item)
    for i, itemData in ipairs(self.selectedItems) do
        if itemData == item then
            table.remove(self.selectedItems, i)
            return
        end
    end
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:IsItemSelected(item)
    for i, itemData in ipairs(self.selectedItems) do
        if itemData == item then
            return true
        end
    end
    return false
end