Back to Home

ESO Lua File v101041

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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
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
    SCREEN_NARRATION_MANAGER:RegisterComboBox(self)
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)
    return self:GetItemNormalColor(item)
end
function ZO_ComboBox_Gamepad:GetHighlightColor(item)
    return self:GetItemHighlightColor(item)
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, self)
    if data and data.onEnter then
        data.onEnter(control, data)
    end
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)
    if data and data.onExit then
        data.onExit(control, data)
    end
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 not self.blockDeactivatedCallback then 
                if self.deactivatedCallback then
                    self.deactivatedCallback(self.deactivatedCallbackArgs)
                end
                self:FireCallbacks("OnDeactivated")
            end
        end
    end
end
--Sets the name used for screen narration
function ZO_ComboBox_Gamepad:SetName(name)
    self.name = name
end
--Sets the header used for screen narration
function ZO_ComboBox_Gamepad:SetHeader(header)
    self.header = header
end
function ZO_ComboBox_Gamepad:SetNarrationTooltipType(tooltipType)
end
function ZO_ComboBox_Gamepad:GetNarrationTooltipType()
    if type(self.tooltipType) == "function" then
        return self.tooltipType(self.m_currentData)
    else
        return self.tooltipType
    end
end
function ZO_ComboBox_Gamepad:ResetNarrationInfo()
    self.name = nil
    self.header = nil
    self.tooltipType = nil
end
function ZO_ComboBox_Gamepad:Reset()
    -- TODO: Investigate anything else we may need to reset here.
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
        if self:SelectItem(focusItem.data) then
            PlaySound(SOUNDS.DEFAULT_CLICK)
        end
    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:GetSelectItemKeybindText()
    return GetString(SI_GAMEPAD_SELECT_OPTION)
end
function ZO_ComboBox_Gamepad:SelectItemByIndex(index, ignoreCallback)
    self.m_highlightedIndex = index
    return ZO_ComboBox_Base.SelectItemByIndex(self, index, ignoreCallback)
end
function ZO_ComboBox_Gamepad:SetHighlightedItem(highlightIndex, reselectIndex)
    return 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
            return self:SelectItemByIndex(i, ignoreCallback)
        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 = function()
                return self:GetSelectItemKeybindText()
            end,
            callback = function()
                self:SelectHighlightedItem()
            end,
            enabled = function()
                return self:IsHighlightedItemEnabled()
            end,
            visible = function() return not ZO_Dialogs_IsShowingDialog() end,
        },
        {
            keybind = "DIALOG_PRIMARY",
            name = function()
                return self:GetSelectItemKeybindText()
            end,
            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
function ZO_ComboBox_Gamepad:GetNarrationText()
    if self:IsActive() then
        --If the dropdown is currently active, just give us the current selected value
        return SCREEN_NARRATION_MANAGER:CreateNarratableObject(self.m_currentData.name)
    else
        --If the dropdown is not currently active, indicate that this is a dropdown and include the current selected value
        local selectedItemName = self.m_selectedItemData and self.m_selectedItemData.name or self.currentSelectedItemText
        if self.name then
            if self.header then
                return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_DROPDOWN_NAMED_WITH_HEADER, self.name, selectedItemName, self.header))
            else
                return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_DROPDOWN_NAMED, self.name, selectedItemName))
            end
        else
            return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_DROPDOWN_UNNAMED, selectedItemName))
        end
    end
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 = {}
    self.m_maxNumSelections = nil
    -- Set default strings.
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:GetNarrationText()
    if self:IsActive() then
        --If the dropdown is currently active, just give us the current selected value
        --Multi-selection entries should be treated as toggles
        return ZO_FormatToggleNarrationText(self.m_currentData.name, self.currentItemData:IsItemSelected(self.m_currentData))
    else
        --If the dropdown is not currently active, indicate that this is a dropdown and include the current selected text
        --First, determine the current selected text
        local currentSelectedText = ""
        local numSelectedEntries = self:GetNumSelectedEntries()
        if numSelectedEntries > 0 then
            if self.multiSelectionTextFormatter then
                currentSelectedText = zo_strformat(self.multiSelectionTextFormatter, numSelectedEntries)
            end
        elseif self.noSelectionText then
            currentSelectedText = self.noSelectionText
        end
        
        --Once the current selected text is determined, format the rest of the narration
        if self.name then
            if self.header then
                return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_MULTI_SELECT_DROPDOWN_NAMED_WITH_HEADER, self.name, currentSelectedText, self.header))
            else
                return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_MULTI_SELECT_DROPDOWN_NAMED, self.name, currentSelectedText))
            end
        else
            return SCREEN_NARRATION_MANAGER:CreateNarratableObject(zo_strformat(SI_SCREEN_NARRATION_MULTI_SELECT_DROPDOWN_UNNAMED, currentSelectedText))
        end
    end
end
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
        if self:SelectItem(focusItem.data) then
            PlaySound(SOUNDS.DEFAULT_CLICK)
        end
    end
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:IsHighlightedItemEnabled()
    local isItemSelected = self:IsHighlightedItemSelected()
    if not isItemSelected and self.m_maxNumSelections ~= nil and self:GetNumSelectedEntries() >= self.m_maxNumSelections then
        if not self.isSelectionBlockedCallback or (self.m_currentData and self.isSelectionBlockedCallback(self.m_currentData) ~= true) then
            return false, self:GetSelectionBlockedErrorText()
        end
    end
    return ZO_ComboBox_Gamepad.IsHighlightedItemEnabled(self)
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:GetSelectItemKeybindText()
    if self.m_maxNumSelections then
        return zo_strformat(SI_COMBO_BOX_MAX_SELECTIONS_KEYBIND_FORMATTER, ZO_ComboBox_Gamepad.GetSelectItemKeybindText(self), self:GetNumSelectedEntries(), self.m_maxNumSelections)
    else
        return ZO_ComboBox_Gamepad.GetSelectItemKeybindText(self)
    end
end
function ZO_MultiSelection_ComboBox_Gamepad:SetIsSelectionBlockedCallback(callback)
end
function ZO_MultiSelection_ComboBox_Gamepad:SetOnSelectionBlockedCallback(callback)
end
function ZO_MultiSelection_ComboBox_Gamepad:IsItemSelected(item)
    return self.currentItemData:IsItemSelected(item)
end
-- Overridden function
function ZO_MultiSelection_ComboBox_Gamepad:SelectItem(item, ignoreCallback)
    if item.enabled == false then
        return false
    end
    local isItemSelected = self.currentItemData:IsItemSelected(item)
    if self.m_maxNumSelections == nil or self:GetNumSelectedEntries() < self.m_maxNumSelections or isItemSelected then
        self.currentItemData:ToggleItemSelected(item)
    else
        if not self.onSelectionBlockedCallback or self.onSelectionBlockedCallback(item) ~= true then
            return false
        end
    end
    isItemSelected = self.currentItemData:IsItemSelected(item)
    local control = self.itemDataToControl[item]
    if isItemSelected 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, isItemSelected)
    end
    if self.m_maxNumSelections then
        -- The combo box won't update the keybind text until we change which item is focused, so we need to
        -- manually update it here.
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor, self.m_keybindState)
    end
    SCREEN_NARRATION_MANAGER:QueueComboBox(self)
    return true
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_SUPPRESS_UPDATE)
    end
    self:UpdateItems()
end
function ZO_MultiSelection_ComboBox_Gamepad:SetNoSelectionText(text)
    self.noSelectionText = text or GetString(SI_COMBO_BOX_DEFAULT_NO_SELECTION_TEXT)
end
function ZO_MultiSelection_ComboBox_Gamepad:SetMultiSelectionTextFormatter(textFormatter)
    self.multiSelectionTextFormatter = textFormatter or SI_COMBO_BOX_DEFAULT_MULTISELECTION_TEXT_FORMATTER
end
-- a maxNumSelections of 0 or nil indicates no limit on selections
function ZO_MultiSelection_ComboBox_Gamepad:SetMaxSelections(maxNumSelections)
    if maxNumSelections == 0 then
        maxNumSelections = nil
    end
    -- if the new limit is less than the current limit, clear all the selections
    if maxNumSelections and (self.m_maxNumSelections == nil or maxNumSelections < self.m_maxNumSelections) and self.currentItemData then
        self.currentItemData:ClearAllSelections()
    end
    self.m_maxNumSelections = maxNumSelections
end
function ZO_MultiSelection_ComboBox_Gamepad:SetMaxSelectionsErrorText(errorText)
    self.m_overrideMaxSelectionsErrorText = errorText
end
function ZO_MultiSelection_ComboBox_Gamepad:GetSelectionBlockedErrorText()
    if self.m_overrideMaxSelectionsErrorText then
        return self.m_overrideMaxSelectionsErrorText
    end
    return GetString(SI_COMBO_BOX_MAX_SELECTIONS_REACHED_ALERT)
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
function ZO_MultiSelection_ComboBox_Gamepad:ClearAllSelections()
    self.currentItemData:ClearAllSelections()
end
function ZO_MultiSelection_ComboBox_Gamepad:SetItemIndexSelected(index)
    local IS_SELECTED = true
    self.currentItemData:SetItemIndexSelected(index, IS_SELECTED)
end
function ZO_MultiSelection_ComboBox_Gamepad:IsItemSelected(item)
    if self.currentItemData then
        return self.currentItemData:IsItemSelected(item)
    end
    return false
end
function ZO_MultiSelection_ComboBox_Gamepad:IsHighlightedItemSelected()
    if self.currentItemData then
        return self.currentItemData:IsItemSelected(self.m_currentData)
    end
end
function ZO_MultiSelection_ComboBox_Gamepad:RefreshSelections()
    self:UpdateItems()
end
function ZO_MultiSelection_ComboBox_Gamepad:Reset()
    ZO_ComboBox_Gamepad.Reset(self)
    self.m_maxNumSelections = nil
    self.m_overrideMaxSelectionsErrorText = nil
    -- Set default strings.
end
-- ZO_MultiSelection_ComboBox_Data_Gamepad
-------------------------------------------
ZO_MultiSelection_ComboBox_Data_Gamepad = ZO_InitializingObject:Subclass()
function ZO_MultiSelection_ComboBox_Data_Gamepad:Initialize()
    self.entryItems = {}
    self.selectedItems = {}
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:Clear()
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)
    return self:SetItemSelected(item, newSelectedState)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:SetItemSelected(item, isSelected)
    if isSelected ~= self:IsItemSelected(item) then
        if isSelected and item.enabled ~= false then
            self:AddItemToSelected(item)
        else
            self:RemoveItemFromSelected(item)
        end
    end
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:SetItemIndexSelected(itemIndex, isSelected)
    return self:SetItemSelected(self.entryItems[itemIndex], isSelected)
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:GetNumSelectedItems()
    return #self.selectedItems
end
function ZO_MultiSelection_ComboBox_Data_Gamepad:GetSelectedItems()
    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:ClearAllSelections()
    ZO_ClearNumericallyIndexedTable(self.selectedItems)
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
function ZO_MultiSelection_ComboBox_Data_Gamepad:SetItemEnabled(item, enabled)
    item.enabled = enabled ~= false
    if item.enabled == false then
        self:RemoveItemFromSelected(item)
    end
end