ESO Lua File v100012

ingame/storewindow/keyboard/storewindow_keyboard.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
local ITEM_BUY_CURRENCY_OPTIONS =
{
    showTooltips = false,
    font = "ZoFontGameShadow",
    iconSide = RIGHT,
}
local MEET_BUY_REQS_FAIL_COLOR = ZO_ColorDef:New(1, 0, 0, 1)
local COMPUTE_HAS_ENOUGH = true
local DATA_TYPE_STORE_ITEM = 1
local STORE_ITEMS = false
-------------------
--Store Manager
-------------------
ZO_StoreManager = ZO_SharedStoreManager:Subclass()
function ZO_StoreManager:New(container)
    local manager = ZO_Object.New(self)
    
    STORE_FRAGMENT = ZO_FadeSceneFragment:New(container)
    
    manager.container = container
    manager:InitializeTabs()
    manager.currentMoney = 0
    manager.currencyAlliancePointsDisplay = GetControl(container, "InfoBarAlliancePoints")
    manager.currencyTelvarStonesDisplay = GetControl(container, "InfoBarTelvarStones")
    manager.currenyMoneyDisplay = GetControl(container, "InfoBarMoney")
    manager.freeSlotsLabel = GetControl(container, "InfoBarFreeSlots")
    ZO_CurrencyControl_InitializeDisplayTypes(manager.currencyAlliancePointsDisplay, CURT_ALLIANCE_POINTS)
    ZO_CurrencyControl_InitializeDisplayTypes(manager.currencyTelvarStonesDisplay, CURT_TELVAR_STONES)
    ZO_CurrencyControl_InitializeDisplayTypes(manager.currenyMoneyDisplay, CURT_MONEY)
    manager.activeTab = GetControl(container, "TabsActive")
    manager.multipleDialog = ZO_BuyMultipleDialog
    ZO_Dialogs_RegisterCustomDialog("BUY_MULTIPLE",
    {
        customControl = ZO_BuyMultipleDialog,
        title =
        {
            text = SI_PROMPT_TITLE_BUY_MULTIPLE,
        },
        buttons =
        {
            [1] =
            {
                control = GetControl(manager.multipleDialog, "Purchase"),
                text =  SI_DIALOG_PURCHASE,
                callback =  function(dialog)
                                STORE_WINDOW:BuyMultiplePurchase()
                            end,
            },
        
            [2] =
            {
                control =   GetControl(manager.multipleDialog, "Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
    local function GetBuyMultipleMaximum()
        local entryIndex = manager.multipleDialog.index
        return zo_max(GetStoreEntryMaxBuyable(entryIndex), 1) -- always attempt to let one item be bought, just to show the error
    end
    local spinnerControl = GetControl(ZO_BuyMultipleDialog, "Spinner")
    manager.buyMultipleSpinner = ZO_Spinner:New(spinnerControl, 1, GetBuyMultipleMaximum)
    manager.buyMultipleSpinner:RegisterCallback("OnValueChanged", function() manager:RefreshBuyMultiple() end)
    manager.list = GetControl(container, "List")
    ZO_ScrollList_AddDataType(manager.list, DATA_TYPE_STORE_ITEM, "ZO_PlayerInventorySlot", 52, function(control, data) manager:SetUpBuySlot(control, data) end, nil, nil, ZO_InventorySlot_OnPoolReset)
    manager.landingArea = GetControl(manager.list, "SellToVendorArea")
    manager.sortHeaders = ZO_SortHeaderGroup:New(container:GetNamedChild("SortBy"), true)
    manager.sortOrder = ZO_SORT_ORDER_UP
    manager.sortKey = "name"
    local function OnSortHeaderClicked(key, order)
        manager.sortKey = key
        manager.sortOrder = order
        manager:ApplySort()
    end
    manager.sortHeaders:RegisterCallback(ZO_SortHeaderGroup.HEADER_CLICKED, OnSortHeaderClicked)
    manager.sortHeaders:AddHeadersFromContainer()
    manager.sortHeaders:SelectHeaderByKey("name", ZO_SortHeaderGroup.SUPPRESS_CALLBACKS)
    manager.tabs = GetControl(container, "Tabs")
    local typicalHiddenColumns =
    {
        ["statValue"] = true,
    }
    local gearHiddenColumns =
    {
        -- Don't hide anything!
    }
    local function CreateNewTabFilterData(filterType, normal, pressed, highlight, hiddenColumns)
        local filterString = GetString("SI_ITEMFILTERTYPE", filterType)
        local tabData =
        {
            -- Custom data
            filterType = filterType,
            hiddenColumns = hiddenColumns,
            activeTabText = filterString,
            tooltipText = filterString,
            -- Menu bar data
            descriptor = filterType,
            normal = normal,
            pressed = pressed,
            highlight = highlight,
            callback = function(tabData) manager:ChangeFilter(tabData) end,
        }
        return tabData
    end
    manager.storeFilters =
    {
        CreateNewTabFilterData(ITEMFILTERTYPE_MISCELLANEOUS, "EsoUI/Art/Inventory/inventory_tabIcon_misc_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_misc_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_misc_over.dds", typicalHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_CRAFTING, "EsoUI/Art/Inventory/inventory_tabIcon_crafting_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_crafting_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_crafting_over.dds", typicalHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_CONSUMABLE, "EsoUI/Art/Inventory/inventory_tabIcon_consumables_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_consumables_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_consumables_over.dds", typicalHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_ARMOR, "EsoUI/Art/Inventory/inventory_tabIcon_armor_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_armor_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_armor_over.dds", gearHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_WEAPONS, "EsoUI/Art/Inventory/inventory_tabIcon_weapons_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_weapons_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_weapons_over.dds", gearHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_COLLECTIBLE, "EsoUI/Art/MainMenu/menuBar_collections_up.dds", "EsoUI/Art/MainMenu/menuBar_collections_down.dds", "EsoUI/Art/MainMenu/menuBar_collections_over.dds", typicalHiddenColumns),
        CreateNewTabFilterData(ITEMFILTERTYPE_ALL, "EsoUI/Art/Inventory/inventory_tabIcon_all_up.dds", "EsoUI/Art/Inventory/inventory_tabIcon_all_down.dds", "EsoUI/Art/Inventory/inventory_tabIcon_all_over.dds", typicalHiddenColumns),
    }
    local menuBarData =
    {
        initialButtonAnchorPoint = RIGHT,
        buttonTemplate = "ZO_StoreTab",
        normalSize = 51,
        downSize = 64,
        buttonPadding = -15,
        animationDuration = 180,
    }
    ZO_MenuBar_SetData(manager.tabs, menuBarData)
    manager.currentFilter = ITEMFILTERTYPE_ALL
    manager.hiddenColumns = typicalHiddenColumns
    local function ShowStoreWindow()
          if not IsInGamepadPreferredMode() then
               SCENE_MANAGER:Show("store")
          end
    end
    local function CloseStoreWindow()
        SCENE_MANAGER:Hide("store")
    end
    local function RefreshStoreWindow()
        if not manager.container:IsHidden() then
            manager:RefreshCurrency()
            manager:GetStoreItems()
            manager:UpdateList()
        end
    end
    local function OnInventoryUpdated()
        if not manager.container:IsHidden() then
            KEYBIND_STRIP:UpdateKeybindButtonGroup(manager.keybindStripDescriptor)
            manager:UpdateFreeSlots()
        end
    end
    local OnBuySuccess = function(...)
        if not container:IsControlHidden() then
            ZO_StoreManager_OnPurchased(...)
        end
    end
    local function HandleCursorPickup(eventCode, cursorType)
        if(cursorType == MOUSE_CONTENT_INVENTORY_ITEM) then
            ZO_InventoryLandingArea_SetHidden(manager.landingArea, false, SI_INVENTORY_LANDING_AREA_SELL_ITEM)
        end
    end
    local function HandleCursorCleared(eventCode, oldCursorType)
        ZO_InventoryLandingArea_SetHidden(manager.landingArea, true)
    end
    local storeScene = ZO_InteractScene:New("store", SCENE_MANAGER, STORE_INTERACTION)
    storeScene:RegisterCallback("StateChange",   function(oldState, newState)
                                                    if(newState == SCENE_SHOWING) then
                                                        manager:InitializeStore()
                                                    elseif(newState == SCENE_HIDDEN) then
                                                        ZO_InventorySlot_RemoveMouseOverKeybinds()
                                                        KEYBIND_STRIP:RemoveKeybindButtonGroup(manager.keybindStripDescriptor)
                                                        manager.modeBar:Clear()
                                                        if(GetCursorContentType() == MOUSE_CONTENT_STORE_ITEM) then
                                                            ClearCursor()
                                                        end
                                                    end
                                                end)
    container:RegisterForEvent(EVENT_OPEN_STORE, ShowStoreWindow)
    container:RegisterForEvent(EVENT_CLOSE_STORE, CloseStoreWindow)
    container:RegisterForEvent(EVENT_MONEY_UPDATE, RefreshStoreWindow)
    container:RegisterForEvent(EVENT_BUY_RECEIPT, OnBuySuccess)
    container:RegisterForEvent(EVENT_ALLIANCE_POINT_UPDATE, RefreshStoreWindow)
    container:RegisterForEvent(EVENT_TELVAR_STONE_UPDATE, RefreshStoreWindow)
    container:RegisterForEvent(EVENT_INVENTORY_FULL_UPDATE, OnInventoryUpdated)
    container:RegisterForEvent(EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnInventoryUpdated)
    container:RegisterForEvent(EVENT_CURSOR_PICKUP, HandleCursorPickup)
    container:RegisterForEvent(EVENT_CURSOR_DROPPED, HandleCursorCleared)
    container:RegisterForEvent(EVENT_COLLECTION_UPDATED, RefreshStoreWindow)
    container:RegisterForEvent(EVENT_COLLECTIBLE_UPDATED, RefreshStoreWindow)
    return manager
end
function ZO_StoreManager:InitializeStore(overrideMode)
     ZO_SharedStoreManager.InitializeStore(self)
    self.windowMode = overrideMode or ZO_STORE_WINDOW_MODE_NORMAL
    if self.windowMode == ZO_STORE_WINDOW_MODE_NORMAL then
        self.modeBar:SelectFragment(SI_STORE_MODE_BUY)
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    end
    self:GetStoreItems()
    self:UpdateFilters()
    self:UpdateList(STORE_ITEMS)
end
function ZO_StoreManager:InitializeTabs()
    local function CreateButtonData(normal, pressed, highlight)
        return {
            normal = normal,
            pressed = pressed,
            highlight = highlight,
        }
    end
    
    local stackAllButton =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        {
            name = GetString(SI_ITEM_ACTION_STACK_ALL),
            keybind = "UI_SHORTCUT_STACK_ALL",
            callback = function()
                StackBag(BAG_BACKPACK)
            end,
        }
    }
    self.modeBar = ZO_SceneFragmentBar:New(ZO_StoreWindowMenuBar)
    --Buy Button
    local buyButtonData = CreateButtonData("EsoUI/Art/Vendor/vendor_tabIcon_buy_up.dds",
                                            "EsoUI/Art/Vendor/vendor_tabIcon_buy_down.dds",
                                            "EsoUI/Art/Vendor/vendor_tabIcon_buy_over.dds")
    self.modeBar:Add(SI_STORE_MODE_BUY, { STORE_FRAGMENT }, buyButtonData)
    --Sell Button
    local sellButtonData = CreateButtonData("EsoUI/Art/Vendor/vendor_tabIcon_sell_up.dds",
                                            "EsoUI/Art/Vendor/vendor_tabIcon_sell_down.dds",
                                            "EsoUI/Art/Vendor/vendor_tabIcon_sell_over.dds")
    self.modeBar:Add(SI_STORE_MODE_SELL, { INVENTORY_FRAGMENT, BACKPACK_STORE_LAYOUT_FRAGMENT }, sellButtonData, stackAllButton)
    --Buy Back Button
    local buyBackButtonData = CreateButtonData("EsoUI/Art/Vendor/vendor_tabIcon_buyBack_up.dds",
                                               "EsoUI/Art/Vendor/vendor_tabIcon_buyBack_down.dds",
                                               "EsoUI/Art/Vendor/vendor_tabIcon_buyBack_over.dds")
    self.modeBar:Add(SI_STORE_MODE_BUY_BACK, { BUY_BACK_FRAGMENT }, buyBackButtonData)
    --Repair Button
    local repairButtonData = CreateButtonData("EsoUI/Art/Vendor/vendor_tabIcon_repair_up.dds",
                                               "EsoUI/Art/Vendor/vendor_tabIcon_repair_down.dds",
                                               "EsoUI/Art/Vendor/vendor_tabIcon_repair_over.dds")
    self.modeBar:Add(SI_STORE_MODE_REPAIR, { REPAIR_FRAGMENT }, repairButtonData)
end
do
    local DONT_COUNT_STOLEN_ITEMS = true
    function ZO_StoreManager:InitializeKeybindStripDescriptors()
        self.keybindStripDescriptor =
        {
            alignment = KEYBIND_STRIP_ALIGN_CENTER,
            -- Repair All
            {
                name = function()
                    local goldIcon = zo_iconFormat("EsoUI/Art/currency/currency_gold.dds", 24, 24)
                    local cost = GetRepairAllCost()
                    if GetCarriedCurrencyAmount(CURT_MONEY) >= cost then
                        return zo_strformat(SI_REPAIR_ALL_KEYBIND_TEXT, ZO_CurrencyControl_FormatCurrency(cost), goldIcon)
                    end
                    return zo_strformat(SI_REPAIR_ALL_KEYBIND_TEXT, ZO_ERROR_COLOR:Colorize(ZO_CurrencyControl_FormatCurrency(cost)), goldIcon)
                end,
                keybind = "UI_SHORTCUT_SECONDARY",
                visible = function() return GetRepairAllCost() > 0 end,
                callback = function()
                    ZO_Dialogs_ShowDialog("REPAIR_ALL", {cost = GetRepairAllCost()})
                end,
            },
            -- Sell All Junk
            {
                name = GetString(SI_SELL_ALL_JUNK_KEYBIND_TEXT),
                keybind = "UI_SHORTCUT_NEGATIVE",
                visible =   function()
                                return HasAnyJunk(BAG_BACKPACK, DONT_COUNT_STOLEN_ITEMS)
                            end,
                callback =  function()
                                ZO_Dialogs_ShowDialog("SELL_ALL_JUNK")
                            end,
            },
        }
    end
end
function ZO_StoreManager:UpdateFreeSlots()
    if self.windowMode ~= ZO_STORE_WINDOW_MODE_STABLE then
        local numUsedSlots, numSlots = PLAYER_INVENTORY:GetNumSlots(INVENTORY_BACKPACK)
        if self.numUsedSlots ~= numUsedSlots or self.numSlots ~= numSlots then
            self.numUsedSlots = numUsedSlots
            self.numSlots = numSlots
            if numUsedSlots < numSlots then
                self.freeSlotsLabel:SetText(zo_strformat(SI_INVENTORY_BACKPACK_REMAINING_SPACES, numUsedSlots, numSlots))
            else
                self.freeSlotsLabel:SetText(zo_strformat(SI_INVENTORY_BACKPACK_COMPLETELY_FULL, numUsedSlots, numSlots))
            end
        end
    end
end
local filterTypeToValueColumnName =
{
    [ITEMFILTERTYPE_ARMOR] = SI_INVENTORY_SORT_TYPE_ARMOR,
    [ITEMFILTERTYPE_WEAPONS] = SI_INVENTORY_SORT_TYPE_POWER,
}
function ZO_StoreManager:UpdateColumnText()
    self.sortHeaders:SetHeaderNameForKey("statValue", GetString(filterTypeToValueColumnName[self.currentFilter]))
end
function ZO_StoreManager:ChangeFilter(filterData)
    self.currentFilter = filterData.filterType
    self.hiddenColumns = filterData.hiddenColumns
    self.activeTab:SetText(filterData.activeTabText)
    -- Manage hiding columns that show/hide depending on the current filter. If the sort was on a column that becomes hidden
    -- then the sort needs to pick a new column. Currently this always falls back to the name key.
    if(self.sortHeaders) then
        self.sortHeaders:SetHeadersHiddenFromKeyList(self.hiddenColumns, true)
        if(self.hiddenColumns[self.sortKey]) then
            -- User wanted to sort by a column that's gone!
            -- Fallback to name.
            self.sortHeaders:SelectHeaderByKey("name")
        end
    end
    --Hide inventory capacity for collectibles since they don't take up space
    self.freeSlotsLabel:SetHidden(self.currentFilter == ITEMFILTERTYPE_COLLECTIBLE)
    self:UpdateList()
end
function ZO_StoreManager:ShouldAddItemToList(itemData)
    if(self.currentFilter == ITEMFILTERTYPE_ALL) then return true end
    for i = 1, #itemData.filterData do
        if(itemData.filterData[i] == self.currentFilter) then
            return true
        end
    end
    return false
end
local sortKeys =
{
    name = { },
    stackBuyPrice = { tiebreaker = "stackBuyPriceCurrency1", isNumeric = true },
    stackBuyPriceCurrency1 = { tiebreaker = "stackBuyPriceCurrency2", isNumeric = true },
    stackBuyPriceCurrency2 = { tiebreaker = "name", isNumeric = true },
    statValue = { tiebreaker = "name", isNumeric = true },
}
function ZO_StoreManager:SortData()
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    self.sortFunction = self.sortFunction or function(entry1, entry2)
        return ZO_TableOrderingFunction(entry1.data, entry2.data, self.sortKey, sortKeys, self.sortOrder)
    end
    table.sort(scrollData, self.sortFunction)
end
function ZO_StoreManager:ApplySort()
    self:SortData()
end
function ZO_StoreManager:RefreshCurrency()
     ZO_SharedStoreManager.RefreshCurrency(self)
    local repairAllCost = GetRepairAllCost()
    local gold = (self.storeUsesMoney or repairAllCost > 0) and self.currentMoney or 0
    local alliancePoints = self.storeUsesAP and self.currentAP or 0
    local telvarStones = self.storeUsesTelvarStones and self.currentTelvarStones or 0
    
    ZO_CurrencyControl_SetCurrencyData(self.currencyTelvarStonesDisplay, CURT_TELVAR_STONES, telvarStones, self.storeUsesTelvarStones)
    ZO_CurrencyControl_SetCurrency(self.currencyTelvarStonesDisplay, ZO_KEYBOARD_CARRIED_TELVAR_OPTIONS)
    ZO_CurrencyControl_SetCurrencyData(self.currencyAlliancePointsDisplay, CURT_ALLIANCE_POINTS, alliancePoints, self.storeUsesAP)
    ZO_CurrencyControl_SetCurrency(self.currencyAlliancePointsDisplay, ZO_ALTERNATE_CURRENCY_OPTIONS)
    ZO_CurrencyControl_SetCurrencyData(self.currenyMoneyDisplay, CURT_MONEY, gold, self.storeUsesMoney)
    ZO_CurrencyControl_SetCurrency(self.currenyMoneyDisplay, ZO_KEYBOARD_CARRIED_CURRENCY_OPTIONS)
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_StoreManager:UpdateFilters()
    --The last filter added is the farthest left, so to the player it should be "first"
    local lastFilter
    for _, data in ipairs(self.storeFilters) do
        if (data.filterType == ITEMFILTERTYPE_ALL and self.multipleFilters) or self.usedFilterTypes[data.filterType] then
            ZO_MenuBar_AddButton(self.tabs, data)
            lastFilter = data.filterType
        end
    end
    if lastFilter then
        ZO_MenuBar_SelectDescriptor(self.tabs, lastFilter)
    end
end
function ZO_StoreManager:GetStoreItems()
     self.items, self.usedFilterTypes = ZO_StoreManager_GetStoreItems()
    self.multipleFilters = NonContiguousCount(self.usedFilterTypes) > 1
end
function ZO_StoreManager:UpdateList()
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    
    for index = 1, #self.items do
        local itemData = self.items[index]
        if(self:ShouldAddItemToList(itemData))
        then
            scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(DATA_TYPE_STORE_ITEM, itemData)
        end
    end
    self:ApplySort()
end
function ZO_StoreManager:UpdateStatValueControl(control, data)
    local statControl = GetControl(control, "StatValue")
    if(statControl) then
        local showStatColumn = not self.hiddenColumns["statValue"]
        statControl:SetText((showStatColumn and (data.statValue ~= nil) and (data.statValue > 0)) and tostring(data.statValue) or "")
    end
end
function ZO_StoreManager:SetUpBuySlot(control, data)
    local newStatusControl = GetControl(control, "Status")
    local slotControl = GetControl(control, "Button")
    local iconControl = GetControl(control, "ButtonIcon")
    local quantityControl = GetControl(control, "ButtonStackCount")
    local nameControl = GetControl(control, "Name")
    local priceControl = GetControl(control, "SellPrice")
    newStatusControl:SetHidden(true)
    -- Set info about what slot this is, on the top level slot control
    ZO_InventorySlot_SetType(slotControl, SLOT_TYPE_STORE_BUY)
    local slotIndex = data.slotIndex
    slotControl.index = slotIndex
    slotControl.moneyCost = data.stackBuyPrice
    slotControl.specialCurrencyQuantity1 = data.currencyQuantity1
    slotControl.specialCurrencyQuantity2 = data.currencyQuantity2
    slotControl.specialCurrencyType1 = data.currencyType1
    slotControl.specialCurrencyType2 = data.currencyType2
    slotControl.isCollectible = data.filterData[1] == ITEMFILTERTYPE_COLLECTIBLE
    slotControl.isUnique = data.isUnique
    ZO_InventorySlot_SetType(control, SLOT_TYPE_STORE_BUY)
    control.index = slotIndex
    control.moneyCost = data.stackBuyPrice
    local meetsReqs = data.meetsRequirementsToBuy and data.meetsRequirementsToEquip
    local isLocked = false
    if slotControl.isCollectible then
        isLocked = select(2, GetStoreCollectibleInfo(slotIndex))
    end
    slotControl.locked = isLocked
    ZO_ItemSlot_SetupSlotBase(slotControl, data.stack, data.icon, meetsReqs)
    nameControl:SetText(zo_strformat(SI_TOOLTIP_ITEM_NAME, data.name))
    if data.meetsRequirementsToBuy then
        if data.questNameColor then
            nameControl:SetColor(GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_TOOLTIP, ITEM_TOOLTIP_COLOR_QUEST_ITEM_NAME))
        elseif slotControl.isCollectible then
            nameControl:SetColor(ZO_SELECTED_TEXT:UnpackRGBA())
        else
            nameControl:SetColor(GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, data.quality))
        end
    else
        nameControl:SetColor(MEET_BUY_REQS_FAIL_COLOR:UnpackRGBA())
    end
    ZO_CurrencyControl_InitializeDisplayTypes(priceControl, CURT_MONEY, CURT_ALLIANCE_POINTS, CURT_TELVAR_STONES)
    local currencyType1 = data.currencyType1
    local currencyType2 = data.currencyType2
    ZO_CurrencyControl_SetCurrencyData(priceControl, CURT_MONEY, data.stackBuyPrice, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(CURT_MONEY, data.stackBuyPrice))
    ZO_CurrencyControl_SetCurrencyData(priceControl, currencyType1, data.currencyQuantity1, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(currencyType1, data.stackBuyPriceCurrency1), data.slotIndex, 1)
    ZO_CurrencyControl_SetCurrencyData(priceControl, currencyType2, data.currencyQuantity2, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(currencyType2, data.stackBuyPriceCurrency2), data.slotIndex, 2)
    ZO_CurrencyControl_SetCurrency(priceControl, ITEM_BUY_CURRENCY_OPTIONS)
end
function ZO_StoreManager:HasEnoughCurrencyToBuyItem(currencyType, itemCost)
    if currencyType == CURT_MONEY then
        return self.currentMoney >= itemCost
    elseif currencyType == CURT_ALLIANCE_POINTS then
        return self.currentAP >= itemCost
    elseif currencyType == CURT_TELVAR_STONES then
        return self.currentTelvarStones >= itemCost
    end
    return false
end
function ZO_StoreManager:OpenBuyMultiple(entryIndex)
    self.multipleDialog.index = entryIndex
    self.buyMultipleSpinner:SetValue(1, true)
    
    ZO_Dialogs_ShowDialog("BUY_MULTIPLE")
end
function ZO_StoreManager:BuyMultiplePurchase()
    local storeItemId = self.multipleDialog.index
    local quantity = self.buyMultipleSpinner:GetValue()
    if quantity ~= 0 then
        BuyStoreItem(storeItemId, quantity)
    end
end
function ZO_StoreManager:RefreshBuyMultiple()
    local quantity = self.buyMultipleSpinner:GetValue()
    local entryIndex = self.multipleDialog.index
    local slotControl = GetControl(self.multipleDialog, "Slot")
    local iconControl = GetControl(self.multipleDialog, "SlotIcon")
    local quantityControl = GetControl(self.multipleDialog, "SlotStackCount")
    local textControl = GetControl(self.multipleDialog, "Text")
    local currencyControl = GetControl(self.multipleDialog, "Currency")
    local icon, name, stack, price, _, meetsRequirementsToBuy, meetsRequirementsToEquip, _, _, currencyType1, currencyQuantity1,
            currencyType2, currencyQuantity2 = GetStoreEntryInfo(entryIndex)
    textControl:SetText(zo_strformat(SI_DIALOG_BUY_MULTIPLE, name))
    -- Set info about what slot this is, on the top level slot control
    ZO_InventorySlot_SetType(slotControl, SLOT_TYPE_BUY_MULTIPLE)
    slotControl.index = entryIndex
    -- Fill in the rest of the controls.
    iconControl:SetTexture(icon)
    if stack ~= 1 then
        quantityControl:SetText(stack)
        quantityControl:SetHidden(false)
    else
        quantityControl:SetHidden(true)
    end
    ZO_ItemSlot_SetupUsableAndLockedColor(slotControl, meetsRequirementsToBuy and meetsRequirementsToEquip)
    ZO_CurrencyControl_InitializeDisplayTypes(currencyControl, CURT_MONEY, CURT_ALLIANCE_POINTS, CURT_TELVAR_STONES)
    local total = quantity * price
    local type1Total = quantity * currencyQuantity1
    local type2Total = quantity * currencyQuantity2
    ZO_CurrencyControl_SetCurrencyData(currencyControl, CURT_MONEY, total, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(CURT_MONEY, total))
    ZO_CurrencyControl_SetCurrencyData(currencyControl, currencyType1, type1Total, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(currencyType1, type1Total), entryIndex, 1)
    ZO_CurrencyControl_SetCurrencyData(currencyControl, currencyType2, type2Total, CURRENCY_DONT_SHOW_ALL, not self:HasEnoughCurrencyToBuyItem(currencyType2, type2Total), entryIndex, 2)
    ZO_CurrencyControl_SetCurrency(currencyControl, ITEM_BUY_CURRENCY_OPTIONS)
end
function ZO_StoreManager:GetWindowMode()
    return self.windowMode
end
-------------------
-- Global functions
-------------------
function ZO_BuyMultiple_OpenBuyMultiple(entryIndex)
    STORE_WINDOW:OpenBuyMultiple(entryIndex)
end
end
end
    InitializeTooltip(InformationTooltip, self, BOTTOM, 0, -10)
    SetTooltipText(InformationTooltip, ZO_MenuBarButtonTemplate_GetData(self).tooltipText)
end
    ClearTooltip(InformationTooltip)
end
function ZO_Store_OnMouseUp(upInside)
    if(upInside and GetCursorContentType() ~= MOUSE_CONTENT_EMPTY) then
        PlaceInStoreWindow()
    end
end
    if(GetCursorContentType() ~= MOUSE_CONTENT_EMPTY) then
        PlaceInStoreWindow()
    end
end
function ZO_Store_IsShopping()
    return GetInteractionType() == INTERACTION_VENDOR
end
    STORE_WINDOW = ZO_StoreManager:New(control)
end