Back to Home

ESO Lua File v101036

ingame/banking/gamepad/bankingcommon_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
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
BANKING_GAMEPAD_MODE_WITHDRAW = 1
BANKING_GAMEPAD_MODE_DEPOSIT = 2
local BANK_SEARCH_SORT_PRIMARY_KEY =
{
    [ITEM_LIST_SORT_TYPE_CATEGORY] = "bestGamepadItemCategoryName",
    [ITEM_LIST_SORT_TYPE_ITEM_NAME] = "name",
    [ITEM_LIST_SORT_TYPE_ITEM_QUALITY] = "displayQuality",
    [ITEM_LIST_SORT_TYPE_STACK_COUNT] = "stackCount",
    [ITEM_LIST_SORT_TYPE_VALUE] = "sellPrice",
}
local BANK_SEARCH_FILTERS =
{
    ITEMFILTERTYPE_WEAPONS,
    ITEMFILTERTYPE_ARMOR,
    ITEMFILTERTYPE_JEWELRY,
    ITEMFILTERTYPE_CONSUMABLE,
    ITEMFILTERTYPE_CRAFTING,
    ITEMFILTERTYPE_FURNISHING,
    ITEMFILTERTYPE_MISCELLANEOUS,
}
ZO_ICON_SORT_ARROW_UP = "EsoUI/Art/Miscellaneous/list_sortUp.dds"
ZO_ICON_SORT_ARROW_DOWN = "EsoUI/Art/Miscellaneous/list_sortDown.dds"
-------------------------------------
-- Gamepad Guild Bank Inventory List
-------------------------------------
ZO_GamepadBankCommonInventoryList = ZO_InitializingObject:MultiSubclass(ZO_GamepadInventoryList)
function ZO_GamepadBankCommonInventoryList:Initialize(control, bankMode, ...)
    self:SetBankMode(bankMode)
    ZO_GamepadInventoryList.Initialize(self, control, ...)
end
function ZO_GamepadBankCommonInventoryList:SetBankMode(mode)
    self.mode = mode
end
function ZO_GamepadBankCommonInventoryList:GetBankMode()
    return self.mode
end
function ZO_GamepadBankCommonInventoryList:IsInWithdrawMode()
    return self.mode == BANKING_GAMEPAD_MODE_WITHDRAW
end
function ZO_GamepadBankCommonInventoryList:IsInDepositMode()
    return self.mode == BANKING_GAMEPAD_MODE_DEPOSIT
end
function ZO_GamepadBankCommonInventoryList:GetTargetControl()
    return self.list:GetTargetControl()
end
--[[
-- ZO_BankingCommon_Gamepad
--]]
ZO_BankingCommon_Gamepad = ZO_Gamepad_ParametricList_BagsSearch_Screen:Subclass()
function ZO_BankingCommon_Gamepad:Initialize(control, bankScene)
    self.isInitialized = false
    self.mode = BANKING_GAMEPAD_MODE_WITHDRAW
    self:SetCurrencyType(CURT_MONEY) --default to gold until list is initialized
    local DONT_ACTIVATE_LIST_ON_SHOW = false
    ZO_Gamepad_ParametricList_BagsSearch_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_CREATE, DONT_ACTIVATE_LIST_ON_SHOW, bankScene)
end
local SORT_OPTIONS =
{
    bestGamepadItemCategoryName = { tiebreaker = "name" },
    displayQuality = { tiebreaker = "name", tieBreakerSortOrder = ZO_SORT_ORDER_UP },
    stackCount = { tiebreaker = "name", tieBreakerSortOrder = ZO_SORT_ORDER_UP },
    sellPrice = { tiebreaker = "name", tieBreakerSortOrder = ZO_SORT_ORDER_UP },
    name = { tiebreaker = "requiredLevel" },
    requiredLevel = { tiebreaker = "requiredChampionPoints", isNumeric = true },
    requiredChampionPoints = { tiebreaker = "iconFile", isNumeric = true },
    iconFile = { tiebreaker = "uniqueId" },
    uniqueId = { isId64 = true },
}
function ZO_BankingCommon_Gamepad:GetCurrentSortParams()
    return BANK_SEARCH_SORT_PRIMARY_KEY[self.withdrawList.currentSortType], SORT_OPTIONS, self.withdrawList.currentSortOrder
end
function ZO_BankingCommon_Gamepad:InitializeFiltersDialog()
    local function OnReleaseDialog(dialog)
        if dialog.dropdowns then
            for _, dropdown in ipairs(dialog.dropdowns) do
                dropdown:Deactivate()
            end
        end
        dialog.dropdowns = nil
    end
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_BANK_SEARCH_FILTERS",
    {
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        },
        setup =  function(dialog, data)
            ZO_GenericGamepadDialog_RefreshText(dialog, GetString(SI_GAMEPAD_GUILD_BROWSER_FILTERS_DIALOG_HEADER))
            dialog.dropdowns = {}
            dialog.selectedSortType = dialog.selectedSortType or ITEM_LIST_SORT_TYPE_ITERATION_BEGIN
            local DONT_LIMIT_NUM_ENTRIES = nil
            dialog:setupFunc(DONT_LIMIT_NUM_ENTRIES, data)
        end,
        parametricList =
        {
            {
                header = GetString(SI_GAMEPAD_BANK_SORT_TYPE_HEADER),
                template = "ZO_GamepadDropdownItem",
                templateData =
                {
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        local dialogData = data and data.dialog and data.dialog.data
                        local withdrawList = dialogData.bankObject and dialogData.bankObject.withdrawList
                        local dropdown = control.dropdown
                        table.insert(data.dialog.dropdowns, dropdown)
                        dropdown:SetNormalColor(ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_INACTIVE:UnpackRGB())
                        dropdown:SetHighlightedColor(ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_ACTIVE:UnpackRGB())
                        dropdown:SetSelectedItemTextColor(selected)
                        dropdown:SetSortsItems(false)
                        dropdown:ClearItems()
                        local function OnSelectedCallback(dropdown, entryText, entry)
                            withdrawList.currentSortType = entry.sortType
                        end
                        for i = ITEM_LIST_SORT_TYPE_ITERATION_BEGIN, ITEM_LIST_SORT_TYPE_ITERATION_END do
                            local entryText = ZO_CachedStrFormat(SI_GAMEPAD_BANK_FILTER_ENTRY_FORMATTER, GetString("SI_ITEMLISTSORTTYPE", i))
                            local newEntry = control.dropdown:CreateItemEntry(entryText, OnSelectedCallback)
                            newEntry.sortType = i
                            control.dropdown:AddItem(newEntry)
                        end
                        dropdown:UpdateItems()
                        SCREEN_NARRATION_MANAGER:RegisterDialogDropdown(data.dialog, dropdown)
                        control.dropdown:SelectItemByIndex(withdrawList.currentSortType)
                    end,
                    callback = function(dialog)
                        local targetData = dialog.entryList:GetTargetData()
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.dropdown:Activate()
                    end,
                    narrationText = ZO_GetDefaultParametricListDropdownNarrationText,
                },
            },
            {
                header = GetString(SI_GAMEPAD_BANK_SORT_ORDER_HEADER),
                template = "ZO_GamepadDropdownItem",
                templateData =
                {
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        local dialog = data.dialog
                        local dialogData = dialog and dialog.data
                        local withdrawList = dialogData.bankObject and dialogData.bankObject.withdrawList
                        local dropdown = control.dropdown
                        table.insert(dialog.dropdowns, dropdown)
                        dropdown:SetNormalColor(ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_INACTIVE:UnpackRGB())
                        dropdown:SetHighlightedColor(ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_ACTIVE:UnpackRGB())
                        dropdown:SetSelectedItemTextColor(selected)
                        dropdown:SetSortsItems(false)
                        dropdown:ClearItems()
                        local function OnSelectedCallback(dropdown, entryText, entry)
                            withdrawList.currentSortOrder = entry.sortOrder
                            withdrawList.currentSortOrderIndex = entry.index
                        end
                        local sortUpEntry = control.dropdown:CreateItemEntry(GetString(SI_GAMEPAD_BANK_SORT_ORDER_UP_TEXT), OnSelectedCallback)
                        sortUpEntry.sortOrder = ZO_SORT_ORDER_UP
                        sortUpEntry.index = 1
                        control.dropdown:AddItem(sortUpEntry)
                        local sortDownEntry = control.dropdown:CreateItemEntry(GetString(SI_GAMEPAD_BANK_SORT_ORDER_DOWN_TEXT), OnSelectedCallback)
                        sortDownEntry.sortOrder = ZO_SORT_ORDER_DOWN
                        sortDownEntry.index = 2
                        control.dropdown:AddItem(sortDownEntry)
                        dropdown:UpdateItems()
                        SCREEN_NARRATION_MANAGER:RegisterDialogDropdown(data.dialog, dropdown)
                        control.dropdown:SelectItemByIndex(withdrawList.currentSortOrderIndex)
                    end,
                    callback = function(dialog)
                        local targetData = dialog.entryList:GetTargetData()
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.dropdown:Activate()
                    end,
                    narrationText = ZO_GetDefaultParametricListDropdownNarrationText,
                },
            },
            {
                header = GetString(SI_GAMEPAD_BANK_FILTER_HEADER),
                template = "ZO_GamepadMultiSelectionDropdownItem",
                templateData =
                {
                    setup = function(control, data, selected, reselectingDuringRebuild, enabled, active)
                        local dialog = data.dialog
                        local dialogData = dialog and dialog.data
                        local withdrawList = dialogData.bankObject and dialogData.bankObject.withdrawList
                        local dropdown = control.dropdown
                        table.insert(dialog.dropdowns, dropdown)
                        dropdown:SetNormalColor(ZO_GAMEPAD_COMPONENT_COLORS.UNSELECTED_INACTIVE:UnpackRGB())
                        dropdown:SetHighlightedColor(ZO_GAMEPAD_COMPONENT_COLORS.SELECTED_ACTIVE:UnpackRGB())
                        dropdown:SetSelectedItemTextColor(selected)
                        dropdown:SetSortsItems(false)
                        dropdown:SetNoSelectionText(GetString(SI_GAMEPAD_BANK_FILTER_DEFAULT_TEXT))
                        dropdown:SetMultiSelectionTextFormatter(GetString(SI_GAMEPAD_BANK_FILTER_DROPDOWN_TEXT))
                        SCREEN_NARRATION_MANAGER:RegisterDialogDropdown(data.dialog, dropdown)
                        local dropdownData = ZO_MultiSelection_ComboBox_Data_Gamepad:New()
                        dropdownData:Clear()
                        for _, filterType in ipairs(BANK_SEARCH_FILTERS) do
                            local newEntry = ZO_ComboBox_Base:CreateItemEntry(ZO_CachedStrFormat(SI_GAMEPAD_BANK_FILTER_ENTRY_FORMATTER, GetString("SI_ITEMFILTERTYPE", filterType)))
                            newEntry.category = filterType
                            newEntry.callback = function(control, name, item, isSelected)
                                if isSelected then
                                    withdrawList.filterCategories[item.category] = item.category
                                else
                                    withdrawList.filterCategories[item.category] = nil
                                end
                            end
                            dropdownData:AddItem(newEntry)
                            if withdrawList.filterCategories[filterType] then
                                dropdownData:ToggleItemSelected(newEntry)
                            end
                        end
                        dropdown:LoadData(dropdownData)
                    end,
                    callback = function(dialog)
                        local targetData = dialog.entryList:GetTargetData()
                        local targetControl = dialog.entryList:GetTargetControl()
                        targetControl.dropdown:Activate()
                    end,
                    narrationText = ZO_GetDefaultParametricListDropdownNarrationText,
                },
            },
        },
        blockDialogReleaseOnPress = true,
        buttons =
        {
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_GAMEPAD_SELECT_OPTION,
                callback = function(dialog)
                    local targetData = dialog.entryList:GetTargetData()
                    if targetData and targetData.callback then
                        targetData.callback(dialog)
                    end
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
                callback =  function(dialog)
                    local dialogData = dialog.data
                    local withdrawList = dialogData.bankObject and dialogData.bankObject.withdrawList
                    ZO_Dialogs_ReleaseDialogOnButtonPress("GAMEPAD_BANK_SEARCH_FILTERS")
                    withdrawList:RefreshList()
                end,
            },
            {
                keybind = "DIALOG_RESET",
                text = SI_GUILD_BROWSER_RESET_FILTERS_KEYBIND,
                enabled = function(dialog)
                    local dialogData = dialog.data
                    return not dialogData.bankObject:AreFiltersSetToDefault()
                end,
                callback = function(dialog)
                    local dialogData = dialog and dialog.data
                    dialogData.bankObject:ResetFilters()
                    dialog.info.setup(dialog)
                end,
            },
        },
        onHidingCallback = OnReleaseDialog,
        noChoiceCallback = OnReleaseDialog,
    })
end
function ZO_BankingCommon_Gamepad:ResetFilters()
    self.withdrawList.filterCategories = {}
    self.withdrawList.currentSortType = ITEM_LIST_SORT_TYPE_CATEGORY
    self.withdrawList.currentSortOrder = ZO_SORT_ORDER_UP
    self.withdrawList.currentSortOrderIndex = 1
end
function ZO_BankingCommon_Gamepad:AreFiltersSetToDefault()
    return ZO_IsTableEmpty(self.withdrawList.filterCategories) and
        self.withdrawList.currentSortType == ITEM_LIST_SORT_TYPE_CATEGORY and
        self.withdrawList.currentSortOrder == ZO_SORT_ORDER_UP and
        self.withdrawList.currentSortOrderIndex == 1
end
function ZO_BankingCommon_Gamepad:OnStateChanged(oldState, newState)
    ZO_Gamepad_ParametricList_BagsSearch_Screen.OnStateChanged(self, oldState, newState)
    if newState == SCENE_SHOWING then
        self:PerformDeferredInitialize()
        self:RegisterForEvents()
        self:RefreshHeaderData()
        self.header:SetHidden(false)
        local currentList = self:GetMainListForMode()
        self:SetCurrentList(currentList)
        self:RefreshKeybinds()
        self:OnSceneShowing()
    elseif newState == SCENE_SHOWN then
        self:OnSceneShown()
    elseif newState == SCENE_HIDING then
        self:HideSelector()
        self:OnTargetChanged(nil)
        self:OnSceneHiding()
    elseif newState == SCENE_HIDDEN then
        self:UnregisterForEvents()
        self:DisableCurrentList()
        self.header:SetHidden(true)
        self:RemoveKeybinds()
        self:OnSceneHidden()
    end
end
do
    local ENTRY_ORDER_CURRENCY = 1
    local ENTRY_ORDER_OTHER = 2
    function ZO_BankingCommon_Gamepad:OnDeferredInitialize()
        self:InitializeLists()
        self:ResetFilters()
        self.withdrawList.list:SetSortFunction(function(left, right)
            local leftOrder = ENTRY_ORDER_OTHER
            if left.isCurrenciesMenuEntry or left.currencyType then
                leftOrder = ENTRY_ORDER_CURRENCY
            end
            local rightOrder = ENTRY_ORDER_OTHER
            if right.isCurrenciesMenuEntry or right.currencyType then
                rightOrder = ENTRY_ORDER_CURRENCY
            end
            if leftOrder < rightOrder then
                return true
            elseif leftOrder > rightOrder then
                return false
            elseif leftOrder == ENTRY_ORDER_OTHER then
                return ZO_TableOrderingFunction(left, right, self:GetCurrentSortParams())
            else
                return false
            end
        end)
        self:InitializeHeader()
        self:OnDeferredInitialization()
        self:SetMode(self.mode)
    end
end
function ZO_BankingCommon_Gamepad:InitializeHeader()
    -- create tabs
    local withdrawTabData = self:CreateModeData(SI_BANK_WITHDRAW, BANKING_GAMEPAD_MODE_WITHDRAW, self.withdrawList, self.withdrawKeybindStripDescriptor)
    local depositTabData = self:CreateModeData(SI_BANK_DEPOSIT, BANKING_GAMEPAD_MODE_DEPOSIT, self.depositList, self.depositKeybindStripDescriptor)
    self.tabsTable =
    {
        {
            text = GetString(SI_BANK_WITHDRAW),
            callback = function() self:OnCategoryChanged(withdrawTabData) end,
        },
        {
            text = GetString(SI_BANK_DEPOSIT),
            callback = function() self:OnCategoryChanged(depositTabData) end,
        },
    }
    -- create header
    self.headerData =
    {
        data1HeaderText = GetString(SI_GAMEPAD_BANK_BANK_FUNDS_LABEL),
        data1Text = function(...) return self:SetCurrentBankedAmount(...) end,
        data1TextNarration = function(...) return self:GetCurrentBankedAmountNarration(...) end,
        data2HeaderText = GetString(SI_GAMEPAD_BANK_PLAYER_FUNDS_LABEL),
        data2Text = function(...) return self:SetCurrentCarriedAmount(...) end,
        data2TextNarration = function(...) return self:GetCurrentCarriedAmountNarration(...) end,
        tabBarEntries = self.tabsTable
    }
end
function ZO_BankingCommon_Gamepad:InitializeWithdrawDepositSelector()
    local function OnUpdateEvent()
        if not self.selectorContainer:IsControlHidden() then
            self:UpdateInput()
        end
    end
    local selectorContainer = self.control:GetNamedChild("SelectorContainer")
    self.selector = ZO_CurrencySelector_Gamepad:New(selectorContainer:GetNamedChild("Selector"))
    self.selector:SetClampValues(true)
    self.selectorCurrency = selectorContainer:GetNamedChild("CurrencyTexture")
    selectorContainer:RegisterForEvent(EVENT_CARRIED_CURRENCY_UPDATE, OnUpdateEvent)
    selectorContainer:RegisterForEvent(EVENT_BANKED_CURRENCY_UPDATE, OnUpdateEvent)
    selectorContainer:RegisterForEvent(EVENT_GUILD_BANKED_MONEY_UPDATE, OnUpdateEvent)
    selectorContainer:RegisterForEvent(EVENT_GUILD_BANK_ITEMS_READY, OnUpdateEvent)
    self.selector:RegisterCallback("OnValueChanged", function() self:UpdateInput(self.selector:GetValue()) end)
    self.selectorContainer = selectorContainer
end
function ZO_BankingCommon_Gamepad:InitializeWithdrawDepositKeybindDescriptor()
    self.selectorKeybindStripDescriptor =
    {
        {
            alignment = KEYBIND_STRIP_ALIGN_LEFT,
            name = function()
                if self:IsInWithdrawMode() then
                    return GetString(SI_BANK_WITHDRAW_BIND)
                elseif self:IsInDepositMode() then
                    return GetString(SI_BANK_DEPOSIT_BIND)
                end
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            enabled = function()
                return self.hasEnough
            end,
            callback = function()
                local amount = self.selector:GetValue()
                local data = self:GetTargetData()
                if self:IsInWithdrawMode() then
                    self:WithdrawFunds(data.currencyType, amount)
                elseif self:IsInDepositMode() then
                    self:DepositFunds(data.currencyType, amount)
                end
                self:HideSelector()
            end,
        },
        {
            alignment = KEYBIND_STRIP_ALIGN_LEFT,
            name = GetString(SI_GAMEPAD_BACK_OPTION),
            keybind = "UI_SHORTCUT_NEGATIVE",
            callback = function()
                self:HideSelector()
            end,
        },
    }
end
function ZO_BankingCommon_Gamepad:SetSelectorCurrency(currencyType)
    self.selectorCurrency:SetTexture(ZO_Currency_GetGamepadCurrencyIcon(currencyType))
end
function ZO_BankingCommon_Gamepad:UpdateInput()
    local currentFunds = self.maxInputFunction(self.currencyType)
    self.selector:SetMaxValue(currentFunds)
    self:SetSelectorCurrency(self.currencyType)
    local hasEnough = currentFunds >= self.selector:GetValue()
    self.hasEnough = hasEnough
    self.selector:SetTextColor(hasEnough and ZO_SELECTED_TEXT or ZO_ERROR_COLOR)
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.selectorKeybindStripDescriptor) -- The keybindings need visible to check for self.hasEnough
end
local function OnSelectedDataChanged(list, selectedData)
    local selector = selectedData.selectorContainer
    if selector then
        list:GetTargetControl():SetHidden(true)
        selectedData.selectorContainer = nil
    end
end
function ZO_BankingCommon_Gamepad:ShowSelector()
    self:UpdateInput()
    self.selectorContainer:SetHidden(false)
    local currentList = self:GetCurrentList()
    currentList:Deactivate()
    
    local targetControl = currentList:GetTargetControl()
    if targetControl then
        targetControl:SetHidden(true)
    else
        --if the targetControl doesn't exist because of trigger scrolling, wait til selection changed to hide control
        local targetData = currentList:GetTargetData()
        if targetData then
            targetData.selectorContainer = self.selectorContainer
        end
    end
    
    self.selector:Activate()
    self:RemoveKeybinds()
    KEYBIND_STRIP:AddKeybindButtonGroup(self.selectorKeybindStripDescriptor)
    self.selectorActive = true
end
function ZO_BankingCommon_Gamepad:SetMaxInputFunction(maxInputFunction)
end
function ZO_BankingCommon_Gamepad:HideSelector()
    if self.selectorActive then
        self.selectorContainer:SetHidden(true)
        self.selector:Clear()
        self.selector:Deactivate()
        local currentList = self:GetCurrentList()
        currentList:Activate()
        currentList:GetTargetControl():SetHidden(false)
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.selectorKeybindStripDescriptor)
        self:AddKeybinds()
        self.selectorActive = false
    end
end
function ZO_BankingCommon_Gamepad:RegisterForEvents()
    local control = self.control
    for event, callback in pairs(self.eventTable) do
        control:RegisterForEvent(event, callback)
    end
end
function ZO_BankingCommon_Gamepad:UnregisterForEvents()
    local control = self.control
    for event, callback in pairs(self.eventTable) do
        control:UnregisterForEvent(event)
    end
end
function ZO_BankingCommon_Gamepad:SetWithdrawList(list)
    self.withdrawList = list
end
function ZO_BankingCommon_Gamepad:SetDepositList(list)
    self.depositList = list
end
function ZO_BankingCommon_Gamepad:ClearBankedBags()
    self.bankedBags = {}
end
-- set the bag(s) that will be banked from, banked is a word.
function ZO_BankingCommon_Gamepad:AddBankedBag(bag)
    if self.bankedBags then
        table.insert(self.bankedBags, bag)
    else
        self.bankedBags = {bag}
    end
end
-- set the bag that the player is carrying, probably always backpack
function ZO_BankingCommon_Gamepad:SetCarriedBag(bag)
    self.carriedBag = bag
end
function ZO_BankingCommon_Gamepad:SetCurrencyType(type)
    self.currencyType = type
end
function ZO_BankingCommon_Gamepad:SetDepositKeybindDescriptor(descriptor)
    self.depositKeybindStripDescriptor = descriptor
end
function ZO_BankingCommon_Gamepad:SetWithdrawKeybindDescriptor(descriptor)
    self.withdrawKeybindStripDescriptor = descriptor
end
function ZO_BankingCommon_Gamepad:SetCurrentKeybindDescriptor(descriptor)
    self.currentKeybindStripDescriptor = descriptor
end
function ZO_BankingCommon_Gamepad:SetMode(mode)
    self.mode = mode
end
function ZO_BankingCommon_Gamepad:CreateModeData(name, mode, itemList, keybind)
    return {
        text = GetString(name),
        mode = mode,
        itemList = itemList,
        keybind = keybind,
    }
end
function ZO_BankingCommon_Gamepad:RefreshHeaderData()
    local headerData = self.headerData
    if self.currencyType then
        headerData.data1HeaderText = GetString(SI_GAMEPAD_BANK_BANK_FUNDS_LABEL)
        headerData.data1Text = function(...) return self:SetCurrentBankedAmount(...) end
        headerData.data1TextNarration = function(...) return self:GetCurrentBankedAmountNarration(...) end
        headerData.data2HeaderText = GetString(SI_GAMEPAD_BANK_PLAYER_FUNDS_LABEL)
        headerData.data2Text = function(...) return self:SetCurrentCarriedAmount(...) end
        headerData.data2TextNarration = function(...) return self:GetCurrentCarriedAmountNarration(...) end
    else
        if GetBankingBag() == BAG_BANK then
            headerData.data1HeaderText = GetString(SI_GAMEPAD_BANK_BANK_CAPACITY_LABEL)
        else
            headerData.data1HeaderText = GetString(SI_GAMEPAD_BANK_HOUSE_BANK_CAPACITY_LABEL)
        end
        headerData.data1Text = function(...) return self:SetBankCapacityHeaderText(...) end
        headerData.data1TextNarration = nil
        headerData.data2HeaderText = GetString(SI_GAMEPAD_BANK_PLAYER_CAPACITY_LABEL)
        headerData.data2Text = function(...) return self:SetPlayerCapacityHeaderText(...) end
        headerData.data2TextNarration = nil
    end
end
function ZO_BankingCommon_Gamepad:OnCategoryChanged(selectedData)
    self.mode = selectedData.mode
    self:HideSelector()
    self:SetCurrentList(selectedData.itemList)
    self:OnCategoryChangedCallback(selectedData)
end
function ZO_BankingCommon_Gamepad:SetCurrentCarriedAmount(control)
    local moneyAmount = self:GetDepositMoneyAmount()
    self:SetSimpleCurrency(control, moneyAmount, self.currencyType, BANKING_GAMEPAD_MODE_DEPOSIT, ZO_BANKING_CURRENCY_LABEL_OPTIONS)
    -- must return a non-nil value so that the control isn't auto-hidden
    return true
end
function ZO_BankingCommon_Gamepad:GetCurrentCarriedAmountNarration(control)
    return ZO_Currency_FormatGamepad(self.currencyType, self:GetDepositMoneyAmount(), ZO_CURRENCY_FORMAT_AMOUNT_ICON)
end
function ZO_BankingCommon_Gamepad:SetCurrentBankedAmount(control)
    local moneyAmount = self:GetWithdrawMoneyAmount()
    local currencyOptions = self:GetWithdrawMoneyOptions()
    local obfuscateAmount = self:DoesObfuscateWithdrawAmount()
    self:SetSimpleCurrency(control, moneyAmount, self.currencyType, BANKING_GAMEPAD_MODE_WITHDRAW, currencyOptions, obfuscateAmount)
    -- must return a non-nil value so that the control isn't auto-hidden
    return true
end
function ZO_BankingCommon_Gamepad:GetCurrentBankedAmountNarration(control)
    local displayOptions =
    {
        obfuscateAmount = self:DoesObfuscateWithdrawAmount(),
    }
    return ZO_Currency_FormatGamepad(self.currencyType, self:GetWithdrawMoneyAmount(), ZO_CURRENCY_FORMAT_AMOUNT_ICON, displayOptions)
end
function ZO_BankingCommon_Gamepad:GetCurrencyType()
    return self.currencyType
end 
-- private functions
function ZO_BankingCommon_Gamepad:SetSimpleCurrency(control, amount, currencyType, colorMinValueForMode, options, obfuscateAmount)
    options.color = nil -- Reset the color
    if self:IsInWithdrawMode() then
        if (colorMinValueForMode == self.mode and amount == 0) or (colorMinValueForMode ~= self.mode and amount == self:GetMaxBankedFunds(currencyType)) then
            options.color = ZO_ERROR_COLOR
        end
    elseif self:IsInDepositMode() then
        if (colorMinValueForMode == self.mode and amount == 0) or (colorMinValueForMode ~= self.mode and amount == GetMaxPossibleCurrency(currencyType, CURRENCY_LOCATION_CHARACTER)) then
            options.color = ZO_ERROR_COLOR
        end
    end
    local displayOptions =
    {
        obfuscateAmount = obfuscateAmount,
    }
    ZO_CurrencyControl_SetSimpleCurrency(control, currencyType, amount, options, CURRENCY_SHOW_ALL, CURRENCY_IGNORE_HAS_ENOUGH, displayOptions)
end
function ZO_BankingCommon_Gamepad:RecolorCapacityHeader(control, usedSlots, bagSize, recolorMode)
    local color = ZO_SELECTED_TEXT
    if recolorMode == self.mode and usedSlots >= bagSize then
        color = ZO_ERROR_COLOR
    end
end
function ZO_BankingCommon_Gamepad:SetBankCapacityHeaderText(control)
    local usedSlots = 0
    local bagSize = 0
    if self.bankedBags then
        for index, bagId in ipairs(self.bankedBags) do  
            usedSlots = usedSlots + GetNumBagUsedSlots(bagId)
            bagSize = bagSize + GetBagUseableSize(bagId)
        end
    end
    self:RecolorCapacityHeader(control, usedSlots, bagSize, BANKING_GAMEPAD_MODE_DEPOSIT)
    return zo_strformat(SI_GAMEPAD_INVENTORY_CAPACITY_FORMAT, usedSlots, bagSize)
end
function ZO_BankingCommon_Gamepad:SetPlayerCapacityHeaderText(control)
    local usedSlots = GetNumBagUsedSlots(self.carriedBag)
    local bagSize = GetBagSize(self.carriedBag)
    self:RecolorCapacityHeader(control, usedSlots, bagSize, BANKING_GAMEPAD_MODE_WITHDRAW)
    return zo_strformat(SI_GAMEPAD_INVENTORY_CAPACITY_FORMAT, usedSlots, bagSize)
end
function ZO_BankingCommon_Gamepad:OnTargetChanged(list, targetData, oldTargetData)
    self:SetCurrencyType(targetData and targetData.currencyType or nil)
    self:LayoutBankingEntryTooltip(targetData)
    self:OnTargetChangedCallback(targetData, oldTargetData)
end
function ZO_BankingCommon_Gamepad:LayoutBankingEntryTooltip(inventoryData)
    GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_LEFT_TOOLTIP)
    GAMEPAD_TOOLTIPS:ClearLines(GAMEPAD_RIGHT_TOOLTIP)
    if inventoryData and inventoryData.bagId then
        GAMEPAD_TOOLTIPS:LayoutBagItem(GAMEPAD_LEFT_TOOLTIP, inventoryData.bagId, inventoryData.slotIndex)
        ZO_LayoutBagItemEquippedComparison(GAMEPAD_RIGHT_TOOLTIP, inventoryData.bagId, inventoryData.slotIndex)
    end
end
function ZO_BankingCommon_Gamepad:GetTargetData()
    local currentList = self:GetCurrentList()
    if currentList then
        return currentList:GetTargetData()
    end
end
function ZO_BankingCommon_Gamepad:GetMode()
    return self.mode
end
function ZO_BankingCommon_Gamepad:IsInWithdrawMode()
    return self.mode == BANKING_GAMEPAD_MODE_WITHDRAW
end
function ZO_BankingCommon_Gamepad:IsInDepositMode()
    return self.mode == BANKING_GAMEPAD_MODE_DEPOSIT
end
function ZO_BankingCommon_Gamepad:GetMainListForMode()
    return self:IsInWithdrawMode() and self.withdrawList or self.depositList
end
-- functions that must be overwritten
function ZO_BankingCommon_Gamepad:GetWithdrawMoneyAmount()
    assert(false)
end
function ZO_BankingCommon_Gamepad:GetWithdrawMoneyOptions()
    assert(false)
end
function ZO_BankingCommon_Gamepad:DoesObfuscateWithdrawAmount()
    assert(false)
end
function ZO_BankingCommon_Gamepad:GetMaxedBankedFunds(currencyType)
    assert(false)
end
function ZO_BankingCommon_Gamepad:GetDepositMoneyAmount()
    assert(false)
end
function ZO_BankingCommon_Gamepad:DepositFunds(currencyType, amount)
    assert(false)
end
function ZO_BankingCommon_Gamepad:WithdrawFunds(currencyType, amount)
    assert(false)
end
function ZO_BankingCommon_Gamepad:AddKeybinds()
    assert(false)
end
function ZO_BankingCommon_Gamepad:RemoveKeybinds()
    assert(false)
end
function ZO_BankingCommon_Gamepad:UpdateKeybinds()
    assert(false)
end
-- optional functions for subclasses
function ZO_BankingCommon_Gamepad:OnSceneShowing()
end
function ZO_BankingCommon_Gamepad:OnSceneShown()
end
function ZO_BankingCommon_Gamepad:OnSceneHiding()
end
function ZO_BankingCommon_Gamepad:OnSceneHidden()
end
function ZO_BankingCommon_Gamepad:OnCategoryChangedCallback(selectedData)
    local list = self:GetCurrentList()
    if list then
        local TRIGGER_CALLBACK = true
        list:RefreshList(TRIGGER_CALLBACK)
    end
end
function ZO_BankingCommon_Gamepad:OnTargetChangedCallback(targetData, oldTargetData)
    self:UpdateKeybinds()
end
function ZO_BankingCommon_Gamepad:OnDeferredInitialization()
end
function ZO_BankingCommon_Gamepad:CreateEventTable()
    self.eventTable = {}
end
function ZO_BankingCommon_Gamepad:InitializeLists()
end
function ZO_BankingCommon_Gamepad:OnRefreshHeaderData()
end