Back to Home

ESO Lua File v100023

ingame/restyle/gamepad/outfit_slots_panel_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
ZO_GAMEPAD_OUTFIT_GRID_ENTRY_DIMENSIONS = 87
ZO_GAMEPAD_OUTFIT_GRID_ENTRY_BORDER_EDGE_WIDTH = 128
ZO_GAMEPAD_OUTFIT_GRID_ENTRY_BORDER_EDGE_HEIGHT = 16
local REFRESH_PREVIEW_INSTANTLY = true
ZO_Outfit_Slots_Panel_Gamepad = ZO_Restyle_Station_Helper_Panel_Gamepad:Subclass()
function ZO_Outfit_Slots_Panel_Gamepad:New(...)
    local outfits = ZO_Restyle_Station_Helper_Panel_Gamepad.New(self, ...)
    return outfits
end
function ZO_Outfit_Slots_Panel_Gamepad:Initialize(control)
    self.control = control
    
    ZO_Restyle_Station_Helper_Panel_Gamepad.Initialize(self)
    self.pendingLoopAnimationPool = ZO_MetaPool:New(ZO_Pending_Outfit_LoopAnimation_Pool)
        if self:HasActiveFocus() then
            self:UpdateGridList()
        end
    end
    GAMEPAD_OUTFITS_GRID_LIST_PANEL_FRAGMENT = ZO_FadeSceneFragment:New(control)
    control:SetHandler("OnUpdate", function(_, currentFrameTimeSeconds) self:OnUpdate(currentFrameTimeSeconds) end)
    ZO_OUTFIT_MANAGER:RegisterCallback("ShowLockedChanged", function() self:RebuildList() end)
end
function ZO_Outfit_Slots_Panel_Gamepad:Activate()
    ZO_Restyle_Station_Helper_Panel_Gamepad.Activate(self)
    DIRECTIONAL_INPUT:Activate(self, self.control)
    self:RefreshTooltip(self.gridListPanelList:GetSelectedData())
end
function ZO_Outfit_Slots_Panel_Gamepad:Deactivate()
    ZO_Restyle_Station_Helper_Panel_Gamepad.Deactivate(self)
    GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_QUAD1_TOOLTIP)
    -- make sure we leave the preview as it was no matter how we leave this panel
    if self.slotManipulator then
        self.slotManipulator:UpdatePreview(REFRESH_PREVIEW_INSTANTLY)
    end
    DIRECTIONAL_INPUT:Deactivate(self)
end
function ZO_Outfit_Slots_Panel_Gamepad:OnShowing()
    COLLECTIONS_BOOK_SINGLETON:SetSearchString(self.searchEdit:GetText())
    COLLECTIONS_BOOK_SINGLETON:SetSearchCategorySpecializationFilters(COLLECTIBLE_CATEGORY_SPECIALIZATION_OUTFIT_STYLES)
    COLLECTIONS_BOOK_SINGLETON:SetSearchChecksHidden(true)
    COLLECTIONS_BOOK_SINGLETON:RegisterCallback("UpdateSearchResults", self.onUpdateCollectionsSearchResultsCallback)
end
function ZO_Outfit_Slots_Panel_Gamepad:OnHide()
    COLLECTIONS_BOOK_SINGLETON:UnregisterCallback("UpdateSearchResults", self.onUpdateCollectionsSearchResultsCallback)
    ZO_Restyle_Station_Helper_Panel_Gamepad.OnHide(self)
    self.searchEdit:SetText("")
end
function ZO_Outfit_Slots_Panel_Gamepad:OnUpdate(currentFrameTimeSeconds)
    if self.nextPreviewTimeS and self.nextPreviewTimeS <= currentFrameTimeSeconds then
        local previewCollectionId = SYSTEMS:GetObject("itemPreview"):GetPreviewCollectionId()
        if self:HasActiveFocus() and previewCollectionId ~= 0 then
            local currentlySelectedOutfitData = self.gridListPanelList:GetSelectedData()
            if currentlySelectedOutfitData then
                local slotManipulator = self.slotManipulator
                local primaryDye, secondaryDye, accentDye = slotManipulator:GetPendingDyeData()
                if currentlySelectedOutfitData.isEmptyCell then
                    self.nextPreviewTimeS = nil
                    return
                elseif currentlySelectedOutfitData.clearAction then
                    local NO_OUTFIT_COLLECTIBLE = 0
                    local NO_ITEM_MATERIAL = nil
                    AddOutfitSlotPreviewElementToPreviewCollection(previewCollectionId, slotManipulator:GetOutfitSlotIndex(), NO_OUTFIT_COLLECTIBLE, NO_ITEM_MATERIAL, primaryDye, secondaryDye, accentDye, REFRESH_PREVIEW_INSTANTLY)
                    self.nextPreviewTimeS = nil
                    return
                end
                local collectibleId = currentlySelectedOutfitData:GetId()
                local materialIndex = ZO_OUTFIT_STYLE_DEFAULT_ITEM_MATERIAL_INDEX
                
                if slotManipulator:GetPendingCollectibleId() == collectibleId then
                    materialIndex = slotManipulator:GetPendingItemMaterialIndex()
                elseif slotManipulator:GetCurrentCollectibleId() == collectibleId then
                    materialIndex = slotManipulator:GetCurrentItemMaterialIndex()
                end
                AddOutfitSlotPreviewElementToPreviewCollection(previewCollectionId, slotManipulator:GetOutfitSlotIndex(), collectibleId, materialIndex, primaryDye, secondaryDye, accentDye, REFRESH_PREVIEW_INSTANTLY)
            end
        end
        self.nextPreviewTimeS = nil
    end
end
function ZO_Outfit_Slots_Panel_Gamepad:InitializeKeybindDescriptors()
    -- Apply
    local apply = ZO_RESTYLE_STATION_GAMEPAD:CreateApplyKeybind(self)
    -- Options
    local options = ZO_RESTYLE_STATION_GAMEPAD:CreateOptionsKeybind()
    -- Undo All
    local undoAll = ZO_RESTYLE_STATION_GAMEPAD:CreateUndoKeybind(self)
    -- Randomize
    local randomize = ZO_RESTYLE_STATION_GAMEPAD:CreateRandomizeKeybind(self)
    -- Special exit button
    local specialExit = ZO_RESTYLE_STATION_GAMEPAD:CreateSpecialExitKeybind()
    local function HandleMultiFocusAreaBack()
        self.slotManipulator:UpdatePreview(REFRESH_PREVIEW_INSTANTLY)
        self:EndSelection()
        PlaySound(SOUNDS.OUTFIT_GAMEPAD_MENU_EXIT)
    end
    -- Grid List
    self.gridKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        -- Select
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                            self:HandleGridSelectAction()
                       end
        },
        apply,
        options,
        undoAll,
        specialExit,
    }
    -- Search Bar
    self.searchKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        -- Select
        {
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                            self:HandleSearchSelectAction()
                       end
        },
        apply,
        options,
        undoAll,
        specialExit,
    }
end
function ZO_Outfit_Slots_Panel_Gamepad:InitializeGridListPanel()
    local gridListPanel = self.control:GetNamedChild("GridListPanel")
    GAMEPAD_OUTFITS_GRID_LIST_FRAGMENT = ZO_FadeSceneFragment:New(gridListPanel)
    self.gridListPanelControl = gridListPanel
    self.gridListPanelList = ZO_GridScrollList_Gamepad:New(gridListPanel, FILL_ROW_WITH_EMPTY_CELLS)
    local function OutfitStyleGridEntrySetup(control, data, list)
        if data.iconDesaturation == 1 or data.isEmptyCell then
            control:SetAlpha(0.4)
        else
            control:SetAlpha(1)
        end
        ZO_Restyle_Station_Gamepad_SetOutfitEntryBorder(control, data, self.slotManipulator, self.pendingLoopAnimationPool)
    end
    local function OutfitStyleGridEntryReset(control)
        ZO_Restyle_Station_Gamepad_CleanupAnimationOnControl(control, self.pendingLoopAnimationPool)
    end
    local HIDE_CALLBACK = nil
    local SPACING_X = 6
    self.gridListPanelList:SetGridEntryTemplate("ZO_OutfitStyle_GridEntry_Template_Gamepad", ZO_GAMEPAD_OUTFIT_GRID_ENTRY_DIMENSIONS, ZO_GAMEPAD_OUTFIT_GRID_ENTRY_DIMENSIONS, OutfitStyleGridEntrySetup, HIDE_CALLBACK, OutfitStyleGridEntryReset, SPACING_X, ZO_GRID_SCROLL_LIST_DEFAULT_SPACING_GAMEPAD)
    self.gridListPanelList:SetHeaderTemplate(ZO_GRID_SCROLL_LIST_DEFAULT_HEADER_TEMPLATE_GAMEPAD, ZO_GRID_SCROLL_LIST_DEFAULT_HEADER_TEMPLATE_HEIGHT, ZO_DefaultGridHeaderSetup)
    self.gridListPanelList:SetLineBreakAmount(ZO_GAMEPAD_OUTFIT_GRID_ENTRY_DIMENSIONS + ZO_GRID_SCROLL_LIST_DEFAULT_SPACING_GAMEPAD)
    self.gridListPanelList:SetOnSelectedDataChangedCallback(function(previousData, newData) self:OnGridListSelectedDataChanged(previousData, newData) end)
end
function ZO_Outfit_Slots_Panel_Gamepad:InitializeSearchBar()
    self.contentHeader = self.control:GetNamedChild("ContentHeader")
    local searchControl = self.contentHeader:GetNamedChild("SearchFilter")
    local searchEdit = searchControl:GetNamedChild("SearchEdit")
    local function SearchEditFocusLost()
        ZO_GamepadEditBox_FocusLost(searchEdit)
    end
    local function SearchEditTextChanged()
        ZO_EditDefaultText_OnTextChanged(searchEdit)
        COLLECTIONS_BOOK_SINGLETON:SetSearchString(searchEdit:GetText())
    end
    searchEdit:SetHandler("OnFocusLost", SearchEditFocusLost)
    searchEdit:SetHandler("OnTextChanged", SearchEditTextChanged)
    ZO_EditDefaultText_Initialize(searchEdit, GetString(SI_GAMEPAD_OUTFITS_DEFAULT_SEARCH_TEXT))
    self.searchEdit = searchEdit
    self.filterSwitcher = ZO_GamepadFocus:New(self.searchEdit, ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_HORIZONTAL))
    local searchData = 
    {
        highlight = searchControl:GetNamedChild("Highlight"),
        canFocus = function() return not searchControl:IsHidden() and not searchEdit:IsHidden() end
    }
    self.filterSwitcher:AddEntry(searchData)
end
function ZO_Outfit_Slots_Panel_Gamepad:InitializeMultiFocusArea()
    local function SearchActivateCallback()
        self.filterSwitcher:Activate()
    end
    local function SearchDeactivateCallback()
        self.filterSwitcher:Deactivate()
        self.searchEdit:LoseFocus()
    end
    self.searchArea = ZO_GamepadMultiFocusArea_Base:New(self, SearchActivateCallback, SearchDeactivateCallback)
    self.searchArea:SetKeybindDescriptor(self.searchKeybindStripDescriptor)
    local FOREGO_DIRECTIONAL_INPUT = true
    local function GridActivateCallback()
        self.gridListPanelList:Activate(FOREGO_DIRECTIONAL_INPUT)
    end
    local function GridDeactivateCallback()
        self.gridListPanelList:Deactivate(FOREGO_DIRECTIONAL_INPUT)
    end
    self.gridArea = ZO_GamepadInteractiveSortFilterFocusArea_Grid:New(self, GridActivateCallback, GridDeactivateCallback)
    self.gridArea:SetKeybindDescriptor(self.gridKeybindStripDescriptor)
    self.gridArea.gridList = self.gridListPanelList
    self:AddNextFocusArea(self.searchArea)
    self:AddNextFocusArea(self.gridArea)
    local DONT_ACTIVATE_FOCUS_AREA = false
    self:SelectFocusArea(self.gridArea, DONT_ACTIVATE_FOCUS_AREA)
end
function ZO_Outfit_Slots_Panel_Gamepad:InitializeItemMaterialDialog()
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_OUTFIT_ITEM_MATERIAL_OPTIONS",
    {
        canQueue= true,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        },
        title =
        {
            text = GetString(SI_GAMEPAD_OUTFITS_SELECT_MATERIAL_DIALOG_TITLE)
        },
        setup = function(dialog)
            local parametricList = dialog.info.parametricList
            ZO_ClearNumericallyIndexedTable(parametricList)
            local data = dialog.data
            local targetOutfitData = data.selectedData
            local outfitStyleId = targetOutfitData:GetReferenceId()
            local numMaterials = GetNumOutfitStyleItemMaterials(outfitStyleId)
            for materialIndex = 1, numMaterials do
                local materialName = GetOutfitStyleItemMaterialName(outfitStyleId, materialIndex)
                local entryData = ZO_GamepadEntryData:New(materialName)
                entryData.materialIndex = materialIndex
                entryData.setup = ZO_SharedGamepadEntry_OnSetup
                local listItem =
                {
                    template = "ZO_GamepadItemEntryTemplate",
                    entryData = entryData,
                }
                table.insert(parametricList, listItem)
            end
            dialog:setupFunc()
        end,
        parametricList = {}, -- Generated Dynamically
        parametricListOnSelectionChangedCallback = function(dialog, list, newSelectedData, oldSelectedData)
                                                        local previewCollectionId = SYSTEMS:GetObject("itemPreview"):GetPreviewCollectionId()
                                                        if previewCollectionId ~= 0 then
                                                            local data = dialog.data
                                                            local slotManipulator = data.slotManipulator
                                                            local primaryDye, secondaryDye, accentDye = slotManipulator:GetPendingDyeData()
                                                            AddOutfitSlotPreviewElementToPreviewCollection(previewCollectionId, slotManipulator:GetOutfitSlotIndex(), data.selectedData:GetId(), newSelectedData.materialIndex, primaryDye, secondaryDye, accentDye, REFRESH_PREVIEW_INSTANTLY)
                                                        end
                                                   end,
        blockDialogReleaseOnPress = true,
        buttons = 
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData then
                        local slotManipulator = dialog.data.slotManipulator
                        slotManipulator:SetPendingCollectibleIdAndItemMaterialIndex(dialog.data.selectedData:GetId(), targetData.materialIndex)
                        self.gridListPanelList:RefreshGridList()
                        self:EndSelection()
                        slotManipulator:UpdatePreview(REFRESH_PREVIEW_INSTANTLY)
                        ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_OUTFIT_ITEM_MATERIAL_OPTIONS")
                    end
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_GAMEPAD_BACK_OPTION,
                callback =  function(dialog)
                    dialog.data.slotManipulator:UpdatePreview(REFRESH_PREVIEW_INSTANTLY)
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_OUTFIT_ITEM_MATERIAL_OPTIONS")
                end,
            },     
        } 
    })
end
function ZO_Outfit_Slots_Panel_Gamepad:UpdateGridList()
    local gridListPanelList = self.gridListPanelList
    gridListPanelList:ClearGridList()
    
    if not self.slotManipulator then
        gridListPanelList:CommitGridList()
        return
    end
    local slotManipulator = self.slotManipulator
    local outfitSlot = slotManipulator:GetOutfitSlotIndex()
    local categoryId = GetOutfitSlotDataCollectibleCategoryId(outfitSlot)
    local searchResults = COLLECTIONS_BOOK_SINGLETON:GetSearchResults()
    local tempTable = {}
    local relevantSearchResults = nil
    local hiddenStyleCollectibleId = GetOutfitSlotDataHiddenOutfitStyleCollectibleId(self.slotManipulator:GetOutfitSlotIndex())
    local function FilterCollectible(collectibleData)
        if relevantSearchResults and not relevantSearchResults[collectibleData:GetIndex()] then
            if not hiddenStyleCollectibleId or collectibleData:GetId() ~= hiddenStyleCollectibleId then
                return false
            end
        end
        if collectibleData:IsHiddenFromCollection() then
            return false
        end
        if not ZO_OUTFIT_MANAGER:GetShowLocked() and collectibleData:IsLocked() then
            return false
        end
        return true
    end
    local selectedData = nil
    local function FindSelectedData(collectibleData)
        local isCurrent, isPending = slotManipulator:GetCollectibleDataAssociations(collectibleData)
        if isPending then
            selectedData = collectibleData
        elseif isCurrent then
            if not selectedData then -- show Pending over Current
                selectedData = collectibleData
            end
        end
        return true
    end
    local function InsertEntryIntoTable(tempTable, data)
        local collectibleEntryData = ZO_GridSquareEntryData_Shared:New(data)
        ZO_UpdateCollectibleEntryDataIconVisuals(collectibleEntryData)
        FindSelectedData(collectibleEntryData)
        table.insert(tempTable, collectibleEntryData)
    end
    -- Clear
    local entryData = ZO_GridSquareEntryData_Shared:New()
    entryData.clearAction = true
    entryData.iconFile = ZO_Restyle_GetOutfitSlotClearTexture(outfitSlot)
    entryData.gridHeaderName = ""
    table.insert(tempTable, entryData)
    local categoryData = ZO_COLLECTIBLE_DATA_MANAGER:GetCategoryDataById(categoryId)
    if searchResults then
        local categoryIndex, subcategoryIndex = categoryData:GetCategoryIndicies()
        if searchResults[categoryIndex] and searchResults[categoryIndex][subcategoryIndex] then
            relevantSearchResults = searchResults[categoryIndex][subcategoryIndex]
        else
            relevantSearchResults = {}
        end
    end
    local dataByWeaponAndArmorType = categoryData:GetCollectibleDataBySpecializedSort()
    local NO_WEAPON_OR_ARMOR_TYPE = 0
    -- make sure to add the hide option first
    if dataByWeaponAndArmorType[NO_WEAPON_OR_ARMOR_TYPE] then
        local gearTypeNone = dataByWeaponAndArmorType[NO_WEAPON_OR_ARMOR_TYPE]:GetCollectibles()
        for _, collectibleData in ipairs(gearTypeNone) do
            InsertEntryIntoTable(tempTable, collectibleData)
        end
    end
    for type, weaponOrArmorSortedCollectibles in pairs(dataByWeaponAndArmorType) do
        if type > NO_WEAPON_OR_ARMOR_TYPE then
            local weaponOrArmorData = weaponOrArmorSortedCollectibles:GetCollectibles()
            for _, collectibleData in ipairs(weaponOrArmorData) do
                if FilterCollectible(collectibleData) then
                    InsertEntryIntoTable(tempTable, collectibleData)
                end
            end
        end
    end
    for i, entry in ipairs(tempTable) do
        gridListPanelList:AddEntry(entry)
    end
    gridListPanelList:CommitGridList()
    if selectedData then
        gridListPanelList:ScrollDataToCenter(selectedData)
    end
end
function ZO_Outfit_Slots_Panel_Gamepad:RebuildList()
    self:UpdateGridList()
end
function ZO_Outfit_Slots_Panel_Gamepad:RefreshList()
    self.gridListPanelList:RefreshGridList()
end
function ZO_Outfit_Slots_Panel_Gamepad:UpdateCurrentOutfitIndex()
    local currentEditingIndex = ZO_OUTFITS_SELECTOR_GAMEPAD:GetCurrentOutfitIndex()
    if not currentEditingIndex then
         self:SetOutfitManipulator(nil)
    else
        self:SetOutfitManipulator(ZO_OUTFIT_MANAGER:GetOutfitManipulator(currentEditingIndex))
    end
end
function ZO_Outfit_Slots_Panel_Gamepad:SetOutfitManipulator(newManipulator)
    if self.currentOutfitManipulator ~= newManipulator then
        self.currentOutfitManipulator = newManipulator
    end
end
function ZO_Outfit_Slots_Panel_Gamepad:HandleGridSelectAction()
    local currentlySelectedOutfitData = self.gridListPanelList:GetSelectedData()
    if not currentlySelectedOutfitData or currentlySelectedOutfitData.isEmptyCell then
        return
    end
    local slotManipulator = self.slotManipulator
    if currentlySelectedOutfitData.clearAction then
        slotManipulator:Clear()
    else
        local collectibleId = currentlySelectedOutfitData:GetId()
        local selectedCollectibleData = ZO_COLLECTIBLE_DATA_MANAGER:GetCollectibleDataById(collectibleId)
        if selectedCollectibleData:IsLocked() then
            ZO_Alert(ALERT, NO_SOUND, GetString(SI_GAMEPAD_OUTFITS_CANT_ADD_LOCKED_STYLE))
            return
        else
            if slotManipulator:GetPendingCollectibleId() == collectibleId then
                slotManipulator:ClearPendingChanges()
            else
                local outfitStyleId = currentlySelectedOutfitData:GetReferenceId()
                local numMaterials = GetNumOutfitStyleItemMaterials(outfitStyleId)
                local eligibleSlots = { GetEligibleOutfitSlotsForCollectible(collectibleId) }
                for i, eligibleSlot in ipairs(eligibleSlots) do
                    if slotManipulator:GetOutfitSlotIndex() == eligibleSlot then
                        if numMaterials <= 1 then
                            slotManipulator:SetPendingCollectibleIdAndItemMaterialIndex(collectibleId, ZO_OUTFIT_STYLE_DEFAULT_ITEM_MATERIAL_INDEX)
                            break
                        else
                            ZO_Dialogs_ShowGamepadDialog("GAMEPAD_OUTFIT_ITEM_MATERIAL_OPTIONS", { slotManipulator = slotManipulator, selectedData = currentlySelectedOutfitData })
                            return
                        end
                    end
                end
            end
        end
    end
    self.gridListPanelList:RefreshGridList()
    self:EndSelection()
end
function ZO_Outfit_Slots_Panel_Gamepad:HandleSearchSelectAction()
    self.searchEdit:TakeFocus()
end
function ZO_Outfit_Slots_Panel_Gamepad:RefreshTooltip(selectedData)
    GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_QUAD1_TOOLTIP)
    if selectedData then
        if selectedData.clearAction then
            local preferredOutfitSlot = ZO_OUTFIT_MANAGER:GetPreferredOutfitSlotForStyle(selectedData)
            GAMEPAD_TOOLTIPS:LayoutClearOutfitSlot(GAMEPAD_QUAD1_TOOLTIP, preferredOutfitSlot)
        elseif not selectedData.isEmptyCell then
            local SHOW_VISUAL_LAYER_INFO = true
            local SHOW_BLOCK_REASON = true
            local TIME_REMAINING_S = nil
            GAMEPAD_TOOLTIPS:LayoutCollectibleFromData(GAMEPAD_QUAD1_TOOLTIP, selectedData, SHOW_VISUAL_LAYER_INFO, TIME_REMAINING_S, SHOW_BLOCK_REASON)
        end
    end
end
do
    local NEXT_OUTFIT_PREVIEW_TIME_S = .25
    function ZO_Outfit_Slots_Panel_Gamepad:OnGridListSelectedDataChanged(previousData, newData)
        if self:IsActive() then
            self:RefreshTooltip(newData)
            if newData then
                self.nextPreviewTimeS = GetFrameTimeSeconds() + NEXT_OUTFIT_PREVIEW_TIME_S
            end
        end
    end
end
function ZO_Outfit_Slots_Panel_Gamepad:SetSlotManipulator(slotManipulator)
    if self.slotManipulator ~= slotManipulator then
        self.slotManipulator = slotManipulator
    end
    self:UpdateGridList()
end
function ZO_Outfit_Slots_Panel_Gamepad:UndoPendingChanges()
    self.currentOutfitManipulator:ClearPendingChanges()
    self:RefreshList()
end
-- Shared Functions --
do
    local PENDING_ANIMATION_INSET = -1
    function ZO_Restyle_Station_Gamepad_SetOutfitEntryBorder(control, data, slotManipulator, pendingPool)
        local edgeTexture
        local isCurrent
        local isPending
        if data.isEmptyCell or data.clearAction then
            edgeTexture = "EsoUI/Art/Tooltips/Gamepad/gp_toolTip_edge_16.dds"
        else
            isCurrent, isPending = slotManipulator:GetCollectibleDataAssociations(data)
            if isPending then
                if not control.icon.pendingLoopAnimationKey then
                    ZO_Restyle_ApplyPendingLoopAnimationToControl(control.icon, pendingPool, PENDING_ANIMATION_INSET, data:IsLocked())
                end
                edgeTexture = "EsoUI/Art/Restyle/Gamepad/gp_outfits_edge_bluePending_16.dds"
            elseif isCurrent then
                edgeTexture = "EsoUI/Art/Restyle/Gamepad/gp_outfits_edge_blueSaved_16.dds"
            else
                edgeTexture = "EsoUI/Art/Tooltips/Gamepad/gp_toolTip_edge_16.dds"
            end
        end
        if not isPending then
            ZO_Restyle_Station_Gamepad_CleanupAnimationOnControl(control, pendingPool)
        end
        control.borderBackground:SetEdgeTexture(edgeTexture, ZO_GAMEPAD_OUTFIT_GRID_ENTRY_BORDER_EDGE_WIDTH, ZO_GAMEPAD_OUTFIT_GRID_ENTRY_BORDER_EDGE_HEIGHT)
    end
end
    if control.icon.pendingLoopAnimationKey then
        pendingPool:ReleaseObject(control.icon.pendingLoopAnimationKey)
    end
end
-- XML Functions --
    ZO_OUTFITS_PANEL_GAMEPAD = ZO_Outfit_Slots_Panel_Gamepad:New(control)
end