Back to Home

ESO Lua File v100035

ingame/crafting/gamepad/enchanting_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
ZO_GamepadEnchanting = ZO_SharedEnchanting:Subclass()
function ZO_GamepadEnchanting:New(...)
    return ZO_SharedEnchanting.New(self, ...)
end
function ZO_GamepadEnchanting:Initialize(control)
    self.slotCreationAnimationName = "gamepad_enchanting_creation"
    self.mainSceneName = "gamepad_enchanting_mode"
    self.containerControl = control:GetNamedChild("Container")
    self.modeList = ZO_GamepadVerticalItemParametricScrollList:New(self.containerControl:GetNamedChild("Mode"))
    self.modeList:SetAlignToScreenCenter(true)
    ZO_SharedEnchanting.Initialize(self, control)
    CALLBACK_MANAGER:RegisterCallback("CraftingAnimationsStarted", function() 
        if SCENE_MANAGER:IsShowing("gamepad_enchanting_creation") or SCENE_MANAGER:IsShowing("gamepad_enchanting_extraction") then
            self.inventory:Deactivate()
        end
    end)
    CALLBACK_MANAGER:RegisterCallback("CraftingAnimationsStopped", function() 
        if SCENE_MANAGER:IsShowing("gamepad_enchanting_creation") or SCENE_MANAGER:IsShowing("gamepad_enchanting_extraction") then
            self.inventory:Activate()
            self:UpdateSelection()
        end
    end)
    ZO_GamepadCraftingUtils_InitializeGenericHeader(self, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE)
end
function ZO_GamepadEnchanting:InitializeModes()
    self.modeList:Clear()
    local data = ZO_GamepadEntryData:New(GetString(SI_ENCHANTING_CREATION), "EsoUI/Art/Crafting/Gamepad/gp_crafting_menuIcon_create.dds")
    data.mode = ENCHANTING_MODE_CREATION
    self.modeList:AddEntry("ZO_GamepadItemEntryTemplate", data)
    
    data = ZO_GamepadEntryData:New(GetString(SI_ENCHANTING_EXTRACTION), "EsoUI/Art/Crafting/Gamepad/gp_crafting_menuIcon_deconstruct.dds")
    data.mode = ENCHANTING_MODE_EXTRACTION
    self.modeList:AddEntry("ZO_GamepadItemEntryTemplate", data)
    local recipeCraftingSystem = GetTradeskillRecipeCraftingSystem(CRAFTING_TYPE_ENCHANTING)
    local recipeCraftingSystemName = GetString("SI_RECIPECRAFTINGSYSTEM", recipeCraftingSystem)
    data = ZO_GamepadEntryData:New(recipeCraftingSystemName, GetGamepadRecipeCraftingSystemMenuTextures(CRAFTING_TYPE_ENCHANTING))
    data.mode = ENCHANTING_MODE_RECIPES
    self.modeList:AddEntry("ZO_GamepadItemEntryTemplate", data)
    self.modeList:Commit()
end
local GAMEPAD_CRAFTING_ENCHANTING_ITEM_SORT =
{
    customSortData = { tiebreaker = "bestItemCategoryName" },
    bestItemCategoryName = { tiebreaker = "text" },
    text = {},
}
function ZO_GamepadEnchanting:InitializeInventory()
    local inventory = self.containerControl:GetNamedChild("Inventory")
    self.inventory = ZO_GamepadEnchantingInventory:New(self, inventory)
    self.inventory:SetCustomExtraData(function(bagId, slotIndex, data)
            if self.enchantingMode == ENCHANTING_MODE_CREATION then
                local itemName = GetItemName(bagId, slotIndex)
                local itemLink = GetItemLink(bagId, slotIndex)
                local known, name = GetItemLinkEnchantingRuneName(itemLink)
                local _, _, runeType, rankRequirement, rarityRequirement = GetItemCraftingInfo(bagId, slotIndex)
                
                data.meetsUsageRequirement = DoesRunePassRequirements(runeType, rankRequirement, rarityRequirement)
                local requirementString = ""
                if known == true then
                    data.name = zo_strformat(SI_GAMEPAD_ENCHANTING_TRANSLATION_KNOWN, itemName, name)
                else
                    data.name = zo_strformat(SI_GAMEPAD_ENCHANTING_TRANSLATION_KNOWN, itemName, GetString(SI_ENCHANTING_TRANSLATION_UNKNOWN))
                end
                local traitSubLabel = name and zo_strformat(name) or zo_strformat(GetString(SI_ENCHANTING_TRANSLATION_UNKNOWN))
                data:AddSubLabel(traitSubLabel)
                if runeType == ENCHANTING_RUNE_POTENCY then
                    requirementString = zo_strformat(SI_ENCHANTING_REQUIRES_POTENCY_IMPROVEMENT, rankRequirement)
                elseif runeType == ENCHANTING_RUNE_ASPECT then
                    requirementString = zo_strformat(SI_ENCHANTING_REQUIRES_ASPECT_IMPROVEMENT, rarityRequirement)
                end
                if(requirementString ~= "") then
                    if data.meetsUsageRequirement then
                        data:AddSubLabel(ZO_SUCCEEDED_TEXT:Colorize(requirementString))
                    else
                        data:AddSubLabel(ZO_ERROR_COLOR:Colorize(requirementString))
                    end
                end
            end
        end
    )
    self.inventory:SetCustomSort(function(bagId, slotIndex)
            local itemType = GetItemType(bagId, slotIndex)
            if self.enchantingMode == ENCHANTING_MODE_CREATION then
                if itemType == ITEMTYPE_ENCHANTING_RUNE_POTENCY then
                    return 0
                elseif itemType == ITEMTYPE_ENCHANTING_RUNE_ESSENCE then
                    return 1
                else
                    return 2
                end
            else
                return itemType
            end
        end
    )
    self.inventory:SetOverrideItemSort(function(left, right)
        return ZO_TableOrderingFunction(left, right, "customSortData", GAMEPAD_CRAFTING_ENCHANTING_ITEM_SORT, ZO_SORT_ORDER_UP)
    end)
end
function ZO_GamepadEnchanting:InitializeEnchantingScenes()
    ZO_SharedEnchanting.InitializeEnchantingScenes(self)
    self.enchantingStationInteraction =
    {
        type = "Enchanting Station",
        OnInteractSwitch = function()
            internalassert(false, "OnInteractSwitch is being called.")
            SCENE_MANAGER:ShowBaseScene()
        end,
        interactTypes = { INTERACTION_CRAFT },
    }
    local skillLineXPBarFragment = ZO_FadeSceneFragment:New(ZO_GamepadEnchantingTopLevelSkillInfo)
    GAMEPAD_ENCHANTING_MODE_SCENE_ROOT = ZO_InteractScene:New(self.mainSceneName, SCENE_MANAGER, self.enchantingStationInteraction)
    GAMEPAD_ENCHANTING_MODE_SCENE_ROOT:SetInputPreferredMode(INPUT_PREFERRED_MODE_ALWAYS_GAMEPAD)
    GAMEPAD_ENCHANTING_MODE_SCENE_ROOT:AddFragment(skillLineXPBarFragment)
    GAMEPAD_ENCHANTING_MODE_SCENE_ROOT:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindModeStripDescriptor)
            self:SetEnchantingMode(ENCHANTING_MODE_NONE)
            self.modeList:Activate()
            local titleString = ZO_GamepadCraftingUtils_GetLineNameForCraftingType(CRAFTING_TYPE_ENCHANTING)
            ZO_GamepadCraftingUtils_SetupGenericHeader(self, titleString)
        elseif newState == SCENE_HIDDEN then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindModeStripDescriptor)
            GAMEPAD_CRAFTING_RESULTS:SetCraftingTooltip(nil)
            self.modeList:Deactivate()
            if self.enchantingMode ~= ENCHANTING_MODE_NONE then
                self.inventory:Deactivate()
            end
        end
    end)
    self.onSelectedDataChangedCallback = function(list, selectedData)
        self:DataSelectionCallback(list, selectedData) 
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindEnchantingStripDescriptor) 
    end
    local function ShowCraftingScene(mode, containerToShow)
        KEYBIND_STRIP:RemoveDefaultExit()
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
        self:SetEnchantingMode(mode)
        containerToShow:SetHidden(false)
        self.inventory:Activate()
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
    end
    local function HideCraftingScene()
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
        KEYBIND_STRIP:RestoreDefaultExit()
        self.inventory:Deactivate()
        GAMEPAD_CRAFTING_RESULTS:SetCraftingTooltip(nil)
    end
    GAMEPAD_ENCHANTING_CREATION_SCENE = ZO_InteractScene:New("gamepad_enchanting_creation", SCENE_MANAGER, self.enchantingStationInteraction)
    GAMEPAD_ENCHANTING_CREATION_SCENE:SetInputPreferredMode(INPUT_PREFERRED_MODE_ALWAYS_GAMEPAD)
    GAMEPAD_ENCHANTING_CREATION_SCENE:AddFragment(skillLineXPBarFragment)
    GAMEPAD_ENCHANTING_CREATION_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            ShowCraftingScene(ENCHANTING_MODE_CREATION, self.runeSlotContainer)
        elseif newState == SCENE_HIDDEN then
            HideCraftingScene()
            self.runeSlotContainer:SetHidden(true)
            GAMEPAD_CRAFTING_RESULTS:SetCraftingTooltip(nil)
        end
    end)
    GAMEPAD_ENCHANTING_EXTRACTION_SCENE = ZO_InteractScene:New("gamepad_enchanting_extraction", SCENE_MANAGER, self.enchantingStationInteraction)
    GAMEPAD_ENCHANTING_EXTRACTION_SCENE:SetInputPreferredMode(INPUT_PREFERRED_MODE_ALWAYS_GAMEPAD)
    GAMEPAD_ENCHANTING_EXTRACTION_SCENE:RegisterCallback("StateChange", function(oldState, newState)
    GAMEPAD_ENCHANTING_EXTRACTION_SCENE:AddFragment(skillLineXPBarFragment)
        if newState == SCENE_SHOWING then
            ShowCraftingScene(ENCHANTING_MODE_EXTRACTION, self.extractionSlotContainer)
        elseif newState == SCENE_HIDDEN then
            HideCraftingScene()
            self.extractionSlotContainer:SetHidden(true)
        end
    end)
end
function ZO_GamepadEnchanting:InitializeCreationSlots()
    self.runeSlotContainer = self.control:GetNamedChild("RuneSlotContainer")
    self.creationCraftingBar = ZO_GamepadCraftingIngredientBar:New(self.runeSlotContainer)
    self.creationCraftingBar:AddDataTemplate("ZO_GamepadEnchantingRuneCraftingSlot", ZO_GamepadEnchantingRuneCraftingSlotTemplateSetup)
    self.creationCraftingBar:Clear()
    self.runeSlots = {}
    local potencyData = {
        owner = self,
        slotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone01_slot.dds",
        slotIconDrag = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone01_drag.dds",
        slotIconNegative = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone01_negative.dds",
        soundPlaced = SOUNDS.ENCHANTING_POTENCY_RUNE_PLACED,
        soundRemoved = SOUNDS.ENCHANTING_POTENCY_RUNE_REMOVED,
        type = ENCHANTING_RUNE_POTENCY,
        inventory = self.inventory,
        emptySlotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone01_slot.dds",
    }
    self.creationCraftingBar:AddEntry("ZO_GamepadEnchantingRuneCraftingSlot", potencyData)
    self.runeSlots[ENCHANTING_RUNE_POTENCY] = potencyData.slot
    local essenceData = {
        owner = self,
        slotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone02_slot.dds",
        slotIconDrag = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone02_drag.dds",
        slotIconNegative = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone02_negative.dds",
        soundPlaced = SOUNDS.ENCHANTING_ESSENCE_RUNE_PLACED,
        soundRemoved = SOUNDS.ENCHANTING_ESSENCE_RUNE_REMOVED,
        type = ENCHANTING_RUNE_ESSENCE,
        inventory = self.inventory,
        emptySlotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone02_slot.dds",
    }
    self.creationCraftingBar:AddEntry("ZO_GamepadEnchantingRuneCraftingSlot", essenceData)
    self.runeSlots[ENCHANTING_RUNE_ESSENCE] = essenceData.slot
    local aspectData = {
        owner = self,
        slotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone03_slot.dds",
        slotIconDrag = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone03_drag.dds",
        slotIconNegative = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone03_negative.dds",
        soundPlaced = SOUNDS.ENCHANTING_ASPECT_RUNE_PLACED,
        soundRemoved = SOUNDS.ENCHANTING_ASPECT_RUNE_REMOVED,
        type = ENCHANTING_RUNE_ASPECT,
        inventory = self.inventory,
        emptySlotIcon = "EsoUI/Art/Crafting/Gamepad/gp_crafting_runestone03_slot.dds",
    }
    self.creationCraftingBar:AddEntry("ZO_GamepadEnchantingRuneCraftingSlot", aspectData)
    self.runeSlots[ENCHANTING_RUNE_ASPECT] = aspectData.slot
    self.control:RegisterForEvent(EVENT_NON_COMBAT_BONUS_CHANGED, function(eventCode, nonCombatBonusType)
        if nonCombatBonusType == NON_COMBAT_BONUS_ENCHANTING_LEVEL or nonCombatBonusType == NON_COMBAT_BONUS_ENCHANTING_RARITY_LEVEL then
            self.inventory:HandleDirtyEvent()
        elseif nonCombatBonusType == NON_COMBAT_BONUS_ENCHANTING_CRAFT_PERCENT_DISCOUNT then
            KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
        end
    end)
    self.resultTooltip = self.control:GetNamedChild("Tooltip")
    self.creationSlotAnimation = ZO_SharedEnchantingSlotAnimation:New(self.slotCreationAnimationName, function() return self.enchantingMode == ENCHANTING_MODE_CREATION end)
    self.creationSlotAnimation:AddSlot(self.runeSlots[ENCHANTING_RUNE_POTENCY])
    self.creationSlotAnimation:AddSlot(self.runeSlots[ENCHANTING_RUNE_ESSENCE])
    self.creationSlotAnimation:AddSlot(self.runeSlots[ENCHANTING_RUNE_ASPECT])
    self.creationCraftingBar:Commit()
    self.activeSlot = -1
end
function ZO_GamepadEnchanting:DataSelectionCallback(list, selectedData) 
    local bagId, slotIndex = self.inventory:CurrentSelectionBagAndSlot()
    local _, _, runeType, _, _ = GetItemCraftingInfo(bagId, slotIndex)
    if self.enchantingMode == ENCHANTING_MODE_CREATION then
        if self.activeSlot ~= runeType then
            if self.activeSlot > 0 then
                local slot = self.runeSlots[self.activeSlot]
            end
            if runeType ~= nil then
                self.activeSlot = runeType
            else
                self.activeSlot = -1
            end
        end
    elseif self.enchantingMode == ENCHANTING_MODE_EXTRACTION then
        if self.activeSlot > 0 then
            local slot = self.runeSlots[self.activeSlot]
            slot.control.animation:PlayBackward()
            self.activeSlot = -1
        end
    end
end
    data.slot = ZO_SharedEnchantRuneSlot:New(data.owner, control, data.slotIcon, data.slotIconDrag, data.slotIconNegative, data.soundPlaced, data.soundRemoved, data.type, data.inventory, data.emptySlotIcon)
    data.slot:RegisterCallback("ItemsChanged", function()
        data.owner:OnSlotChanged()
    end)
end
    local MULTIPLE_ITEMS_TEXTURE = "EsoUI/Art/Crafting/Gamepad/GP_smithing_multiple_enchantingSlot.dds"
    data.slot = ZO_EnchantExtractionSlot_Gamepad:New(data.owner, control, MULTIPLE_ITEMS_TEXTURE, data.inventory)
    data.slot:RegisterCallback("ItemsChanged", function()
        data.owner:OnSlotChanged()
    end)
end
function ZO_GamepadEnchanting:InitializeExtractionSlots()
    self.extractionSlotContainer = self.control:GetNamedChild("ExtractionSlotContainer")
    self.extractionCraftingBar = ZO_GamepadCraftingIngredientBar:New(self.extractionSlotContainer)
    self.extractionCraftingBar:AddDataTemplate("ZO_GamepadEnchantingRuneExtractionSlot", ZO_GamepadEnchantingRuneExtractionSlotTemplateSetup)
    self.slotAnimation = ZO_CraftingCreateSlotAnimation:New(self.sceneName)
    self.extractionCraftingBar:Clear()
    local newData = {
        inventory = self.inventory,
        owner = self,
    }
    self.extractionCraftingBar:AddEntry("ZO_GamepadEnchantingRuneExtractionSlot", newData)
    self.extractionSlot = newData.slot
    self.extractionSlotAnimation = ZO_CraftingEnchantExtractSlotAnimation_Gamepad:New("gamepad_enchanting_extraction", function() return self.enchantingMode == ENCHANTING_MODE_EXTRACTION end)
    self.extractionSlotAnimation:AddSlot(self.extractionSlot)
    self.extractionCraftingBar:Commit()
end
function ZO_GamepadEnchanting:InitializeKeybindStripDescriptors()
    self.keybindModeStripDescriptor = {}
    self.keybindEnchantingStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Slot/Unslot
        {
            name = function()
                self:UpdateExtractionSlotTexture()
                if self:IsCurrentSelected() then
                    return GetString(SI_ITEM_ACTION_REMOVE_FROM_CRAFT)
                else
                    return GetString(SI_ITEM_ACTION_ADD_TO_CRAFT)
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function() 
                if self:IsCurrentSelected() then
                    self:Remove()
                else
                    self:Select()
                end
                KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
            end,
            enabled = function() 
                if ZO_CraftingUtils_IsPerformingCraftProcess() then
                    return false
                end
                local selectedData = self.inventory:CurrentSelection() 
                local canSlotItem = (selectedData ~= nil) and selectedData.meetsUsageRequirement
                return canSlotItem
            end,
        },
        -- Craft/Deconstruct
        {
            name = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    local cost = GetCostToCraftEnchantingItem(self:GetAllCraftingBagAndSlots())
                    return ZO_CraftingUtils_GetCostToCraftString(cost)
                else
                    return GetString("SI_DECONSTRUCTACTIONNAME", DECONSTRUCT_ACTION_NAME_EXTRACT)
                end
            end,
            keybind = "UI_SHORTCUT_SECONDARY",
            gamepadOrder = 1000,
            callback = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    self:Create(1)
                else
                    self:ExtractSingle()
                end
            end,
            enabled = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    return self:ShouldCraftButtonBeEnabled()
                else
                    return self:ShouldDeconstructButtonBeEnabled() and self.extractionSlot:HasOneItem()
                end
            end,
        },
        -- Craft/Deconstruct multiple
        {
            name = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    return GetString(SI_GAMEPAD_CRAFT_MULTIPLE)
                else
                    return GetString("SI_DECONSTRUCTACTIONNAME_PERFORMMULTIPLE", DECONSTRUCT_ACTION_NAME_EXTRACT)
                end
            end,
            keybind = "UI_SHORTCUT_QUATERNARY",
            gamepadOrder = 1010,
            callback = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    local itemLink = GetEnchantingResultingItemLink(self:GetAllCraftingBagAndSlots())
                    ZO_GamepadCraftingUtils_ShowMultiCraftDialog(self, itemLink)
                else
                    if self.extractionSlot:HasOneItem() then
                        -- This is one virtual slot, but because enchanting glyphs do not stack it represents multiple real slots
                        -- Limit the max quantity to match the max number of real slots
                        local virtualBagId, virtualSlotIndex = self.extractionSlot:GetItemBagAndSlot(1)
                        local maxIterations = zo_min(self.inventory:GetStackCount(virtualBagId, virtualSlotIndex), MAX_ITEM_SLOTS_PER_DECONSTRUCTION)
                        local function PerformDeconstructPartial(iterations)
                            self:ExtractPartialStack(iterations)
                        end
                        ZO_GamepadCraftingUtils_ShowDeconstructPartialStackDialog(virtualBagId, virtualSlotIndex, maxIterations, PerformDeconstructPartial, DECONSTRUCT_ACTION_NAME_EXTRACT)
                    else
                        self:ConfirmExtractAll()
                    end
                end
            end,
            enabled = function()
                if self.enchantingMode == ENCHANTING_MODE_CREATION then
                    return self:ShouldMultiCraftButtonBeEnabled()
                else
                    return self:ShouldDeconstructButtonBeEnabled() and self.extractionSlot:GetStackCount() > 1
                end
            end,
        },
        -- Clear selections
        {
            name = GetString(SI_CRAFTING_CLEAR_SELECTIONS),
            keybind = "UI_SHORTCUT_TERTIARY",
            gamepadOrder = 1020,
            callback = function()
                self:ClearSelections()
                self:UpdateSelection()
                KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
            end,
            visible = function()
                return not ZO_CraftingUtils_IsPerformingCraftProcess()
            end,
            enabled = function()
                return self:HasSelections()
            end,
        },
        -- Toggle quest filter
        {
            name = function() return self.inventory:ShouldFilterQuests() and GetString(SI_SMITHING_IS_QUEST_ITEM) or GetString(SI_GAMEPAD_ENCHANTING_ALL_MATERIALS) end,
            keybind = "UI_SHORTCUT_RIGHT_STICK",
            gamepadOrder = 1030,
            callback = function()
                self.inventory:ToggleQuestFilter()
                self.inventory:PerformFullRefresh()
                KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindEnchantingStripDescriptor)
            end,
            visible = function()
                return self.enchantingMode == ENCHANTING_MODE_CREATION
            end,
            enabled = function()
                return not ZO_CraftingUtils_IsPerformingCraftProcess()
            end,
        },
    }
    ZO_Gamepad_AddForwardNavigationKeybindDescriptors(self.keybindModeStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON, function() self:SelectMode() end)
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.keybindModeStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
    ZO_CraftingUtils_ConnectKeybindButtonGroupToCraftingProcess(self.keybindEnchantingStripDescriptor)
    ZO_GamepadCraftingUtils_AddListTriggerKeybindDescriptors(self.keybindEnchantingStripDescriptor, self.inventory.list)
end
function ZO_GamepadEnchanting:UpdateExtractionSlotTexture()
    if self.enchantingMode == ENCHANTING_MODE_EXTRACTION and not self.extractionSlot:HasItems() then
        local bagId, slotIndex = self.inventory:CurrentSelectionBagAndSlot()
        self.extractionSlot:SetBackdrop(bagId, slotIndex)
    end
end
function ZO_GamepadEnchanting:SelectMode()
    local data = self.modeList:GetTargetData()
    if data then
        if data.mode == ENCHANTING_MODE_EXTRACTION then
            SCENE_MANAGER:Push("gamepad_enchanting_extraction")
        elseif data.mode == ENCHANTING_MODE_CREATION then
            SCENE_MANAGER:Push("gamepad_enchanting_creation")
        elseif data.mode == ENCHANTING_MODE_RECIPES then
            GAMEPAD_PROVISIONER:EmbedInCraftingScene(self.enchantingStationInteraction)
        end
    end
end
function ZO_GamepadEnchanting:CanShowScene()
    return IsInGamepadPreferredMode()
end
function ZO_GamepadEnchanting:IsSceneShowing()
    return SCENE_MANAGER:IsShowing(self.mainSceneName) or SCENE_MANAGER:IsShowing("gamepad_enchanting_creation") or SCENE_MANAGER:IsShowing("gamepad_enchanting_extraction")
end
function ZO_GamepadEnchanting:SetEnchantingMode(enchantingMode)
    if self.enchantingMode ~= enchantingMode then
        self.enchantingMode = enchantingMode
        if enchantingMode == ENCHANTING_MODE_CREATION then
            GAMEPAD_CRAFTING_RESULTS:SetCraftingTooltip(self.resultTooltip)
            self.inventory:SetNoItemLabelText(GetString(SI_ENCHANTING_NO_RUNES))
            GAMEPAD_CRAFTING_RESULTS:SetTooltipAnimationSounds(SOUNDS.ENCHANTING_CREATE_TOOLTIP_GLOW)
            TriggerTutorial(TUTORIAL_TRIGGER_ENCHANTING_CREATION_OPENED)
        elseif enchantingMode == ENCHANTING_MODE_EXTRACTION then
            self.inventory:SetNoItemLabelText(GetString(SI_ENCHANTING_NO_GLYPHS))
            self:ClearSelections()
            TriggerTutorial(TUTORIAL_TRIGGER_ENCHANTING_EXTRACTION_OPENED)
        end
        self.inventory:HandleDirtyEvent()
        ClearCursor()
        self:OnSlotChanged()
        self:UpdateSelection()
    end
end
function ZO_GamepadEnchanting:OnInventoryUpdate(validItemIds)
    -- Inventory updates can stomp over slotted determination, so we need to refresh that status
    -- However inventory updates can come in before the list has ever been commited, so we also don't want to RefreshVisible
    -- that will get called at a later appropriate time
    ZO_SharedEnchanting.OnInventoryUpdate(self, validItemIds)
end
function ZO_GamepadEnchanting:UpdateSelection()
    self.inventory.list:RefreshVisible()
end
function ZO_GamepadEnchanting:RefreshSlottedEntries()
    if self.enchantingMode == ENCHANTING_MODE_CREATION then
        local rune1BagId, rune1SlotIndex, rune2BagId, rune2SlotIndex, rune3BagId, rune3SlotIndex = self:GetAllCraftingBagAndSlots()
        for _, data in pairs(self.inventory.list.dataList) do
            local isSlotted = false
            if data.bagId == rune1BagId and data.slotIndex == rune1SlotIndex then
                isSlotted = true
            elseif data.bagId == rune2BagId and data.slotIndex == rune2SlotIndex then
                isSlotted = true
            elseif data.bagId == rune3BagId and data.slotIndex == rune3SlotIndex then
                isSlotted = true
            end
            ZO_GamepadCraftingUtils_SetEntryDataSlotted(data, isSlotted)
        end
    else
        for _, data in pairs(self.inventory.list.dataList) do
            ZO_GamepadCraftingUtils_SetEntryDataSlotted(data, self.extractionSlot:ContainsBagAndSlot(data.bagId, data.slotIndex))
        end
    end
end
function ZO_GamepadEnchanting:Select()
    local bagId, slotIndex = self.inventory:CurrentSelectionBagAndSlot()
    local changedSlot = self:AddItemToCraft(bagId, slotIndex)
    if changedSlot then
    end
end
function ZO_GamepadEnchanting:Remove()
    local bagId, slotIndex = self.inventory:CurrentSelectionBagAndSlot()
    self:RemoveItemFromCraft(bagId, slotIndex)
end
function ZO_GamepadEnchanting:UpdateTooltip()
    if self:IsCraftable() then
        self.resultTooltip:SetHidden(false)
        self.resultTooltip.tip:ClearLines()
        self.resultTooltip.tip:LayoutEnchantingPreview(self:GetAllCraftingBagAndSlots())
    elseif self:IsExtractable() and self.extractionSlot:HasOneItem() then
        self.resultTooltip:SetHidden(false)
        self.resultTooltip.tip:ClearLines()
        local bagId, slotIndex = self.extractionSlot:GetItemBagAndSlot(1)
        local icon = GetItemInfo(bagId, slotIndex)
        local itemLink = GetItemLink(bagId, slotIndex)
        self.resultTooltip.tip:LayoutEnchantingCraftingItem(itemLink, icon, GetItemCreatorName(bagId, slotIndex))
    else
        self.resultTooltip:SetHidden(true)
    end
end
ZO_GamepadEnchantingInventory = ZO_GamepadCraftingInventory:Subclass()
function ZO_GamepadEnchantingInventory:New(...)
    return ZO_GamepadCraftingInventory.New(self, ...)
end
function ZO_GamepadEnchantingInventory:Initialize(owner, control, ...)
    local inventory = ZO_GamepadCraftingInventory.Initialize(self, control, ...)
    self.owner = owner
    self.filterType = NO_FILTER
    self.runeSlots = self.owner.runeSlots
    local function OnAddOnLoaded(event, name)
        if name == "ZO_Ingame" then
            self:SetupSavedVars()
            self.control:UnregisterForEvent(EVENT_ADD_ON_LOADED)
        end
    end
    self.control:RegisterForEvent(EVENT_ADD_ON_LOADED, OnAddOnLoaded)
end
function ZO_GamepadEnchantingInventory:SetupSavedVars()
    local defaults = 
    {
        shouldFilterQuests = false,
    }
    self.savedVars = ZO_SavedVars:New("ZO_Ingame_SavedVariables", 1, "GamepadEnchantingCreation", defaults)
end
function ZO_GamepadEnchantingInventory:ToggleQuestFilter()
    self.savedVars.shouldFilterQuests = not self.savedVars.shouldFilterQuests
end
function ZO_GamepadEnchantingInventory:ShouldFilterQuests()
    return self.savedVars.shouldFilterQuests
end
function ZO_GamepadEnchantingInventory:AddListDataTypes()
    local function MenuEntryTemplateSetup(control, data, selected, reselectingDuringRebuild, enabled, active)
        --Determine whether or not we need to show the quest pin
        local itemId = GetItemId(data.bagId, data.slotIndex)
        if self.questRunes.potency == itemId or self.questRunes.essence == itemId or self.questRunes.aspect == itemId then
            data.hasCraftingQuestPin = DoesPlayerHaveRunesForEnchanting(self.questRunes.aspect, self.questRunes.essence, self.questRunes.potency)
            --If there is an override status indicator icon, we need to explicitly add the quest pin here
            if data.overrideStatusIndicatorIcons and data.hasCraftingQuestPin then
                data.overrideStatusIndicatorIcons =  {"EsoUI/Art/Inventory/Gamepad/gp_inventory_icon_equipped.dds", "EsoUI/Art/WritAdvisor/Gamepad/gp_advisor_trackedPin_icon.dds"}
            end
        else
            data.hasCraftingQuestPin = false
        end
        ZO_SharedGamepadEntry_OnSetup(control, data, selected, reselectingDuringRebuild, enabled, active)
    end
    self:AddVerticalScrollDataTypes("ZO_GamepadItemSubEntry", MenuEntryTemplateSetup)
end
function ZO_GamepadEnchantingInventory:IsLocked(bagId, slotIndex)
    return ZO_GamepadCraftingInventory.IsLocked(self, bagId, slotIndex) or self.owner:IsSlotted(bagId, slotIndex)
end
function ZO_GamepadEnchantingInventory:Refresh(data)
    local filterType
    local titleString = nil
    local enchantingMode = self.owner:GetEnchantingMode()
    if enchantingMode == ENCHANTING_MODE_CREATION then
        filterType = self.filterType
        titleString = GetString(SI_ENCHANTING_CREATION)
        if self.savedVars.shouldFilterQuests then
            --If any of the runes are nil, then they all will be, so just nil check any of them
            if self.questRunes.aspect == nil then
                --We need to differentiate between whether or not it is nil because we have fufilled the requirement, don't have a writ, or because we have unknown runes
                if self.questRunes.hasRequiredGlyph or not CRAFT_ADVISOR_MANAGER:HasActiveWrits() then
                    self:SetNoItemLabelText(GetString(SI_ENCHANTING_NO_RUNES))
                else
                    self:SetNoItemLabelText(GetString(SI_GAMEPAD_ENCHANTING_UNKNOWN_RUNES_MESSAGE))
                end
            elseif not DoesPlayerHaveRunesForEnchanting(self.questRunes.aspect, self.questRunes.essence, self.questRunes.potency) then
                --If we get here, that means we know the necessary translations, but do not have the required runes in our inventory
                self:SetNoItemLabelText(GetString(SI_GAMEPAD_ENCHANTING_MISSING_ITEMS_MESSAGE))
            else
                self:SetNoItemLabelText(GetString(SI_ENCHANTING_NO_RUNES))
            end
        else
            self:SetNoItemLabelText(GetString(SI_ENCHANTING_NO_RUNES))
        end
    elseif enchantingMode == ENCHANTING_MODE_EXTRACTION then
        filterType = EXTRACTION_FILTER
        titleString = GetString(SI_ENCHANTING_EXTRACTION)
    end
    self.owner:OnInventoryUpdate(validItemIds)
    if titleString then
        ZO_GamepadCraftingUtils_SetupGenericHeader(self.owner, titleString)
    end
end
function ZO_GamepadEnchantingInventory:EnumerateInventorySlotsAndAddToScrollData(predicate, filterFunction, filterType, data)
    local list = PLAYER_INVENTORY:GenerateListOfVirtualStackedItems(INVENTORY_BACKPACK, predicate)
    PLAYER_INVENTORY:GenerateListOfVirtualStackedItems(INVENTORY_BANK, predicate, list)
    PLAYER_INVENTORY:GenerateListOfVirtualStackedItems(INVENTORY_CRAFT_BAG, predicate, list)
    ZO_ClearTable(self.itemCounts)
    local filteredDataTable = {}
    for itemId, itemInfo in pairs(list) do
        if not filterFunction or filterFunction(itemInfo.bag, itemInfo.index, filterType, self.savedVars.shouldFilterQuests, self.questRunes) then
            filteredDataTable[#filteredDataTable + 1] = self:GenerateCraftingInventoryEntryData(itemInfo.bag, itemInfo.index, itemInfo.stack)
        end
        self.itemCounts[itemId] = itemInfo.stack
    end
    self:AddFilteredDataToList(filteredDataTable)
    return list
end
function ZO_GamepadEnchantingInventory:ShowAppropriateSlotDropCallouts(bagId, slotIndex)
    local _, craftingSubItemType, runeType, rankRequirement, rarityRequirement = GetItemCraftingInfo(bagId, slotIndex)
    self.owner:ShowAppropriateSlotDropCallouts(craftingSubItemType, runeType, rankRequirement, rarityRequirement)
end
function ZO_GamepadEnchantingInventory:HideAllSlotDropCallouts()
    self.owner:HideAllSlotDropCallouts()
end
    GAMEPAD_ENCHANTING = ZO_GamepadEnchanting:New(control)
end
ZO_EnchantExtractionSlot_Gamepad = ZO_SharedEnchantExtractionSlot:Subclass()
function ZO_EnchantExtractionSlot_Gamepad:New(...)
    return ZO_SharedEnchantExtractionSlot.New(self, ...)
end
function ZO_EnchantExtractionSlot_Gamepad:Initialize(owner, control, multipleItemsTexture, craftingInventory)
    ZO_SharedEnchantExtractionSlot.Initialize(self, owner, control, multipleItemsTexture, craftingInventory)
end
function ZO_EnchantExtractionSlot_Gamepad:ClearDropCalloutTexture()
    local NO_TEXTURE = ""
    self:SetEmptyTexture(NO_TEXTURE)
    self.previousGlyph = ITEMTYPE_NONE
end
function ZO_EnchantExtractionSlot_Gamepad:SetBackdrop(bagId, slotIndex)
    local usedInCraftingType, craftingSubItemType, runeType = GetItemCraftingInfo(bagId, slotIndex)
    if self.previousGlyph ~= craftingSubItemType then
        if craftingSubItemType == ITEMTYPE_GLYPH_WEAPON then
            self:SetEmptyTexture("EsoUI/Art/Crafting/Gamepad/gp_crafting_enchanting_glyphSlot_pentagon.dds")
        elseif craftingSubItemType == ITEMTYPE_GLYPH_ARMOR then
            self:SetEmptyTexture("EsoUI/Art/Crafting/Gamepad/gp_crafting_enchanting_glyphSlot_shield.dds")
        elseif craftingSubItemType == ITEMTYPE_GLYPH_JEWELRY then
            self:SetEmptyTexture("EsoUI/Art/Crafting/Gamepad/gp_crafting_enchanting_glyphSlot_round.dds")
        else
            craftingSubItemType = ITEMTYPE_NONE
        end
        self.previousGlyph = craftingSubItemType
    end
end