Back to Home

ESO Lua File v100028

internalingame/marketannouncement/marketproductcarousel_shared.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
--
-- ZO_MarketProductCarousel_Shared
--
ZO_MarketProductCarousel_Shared = ZO_HorizontalScrollList_Gamepad:Subclass()
function ZO_MarketProductCarousel_Shared:New(...)
    return ZO_HorizontalScrollList_Gamepad.New(self, ...)
end
function ZO_MarketProductCarousel_Shared:SetNumProductAnnouncements(numProducts)
    self.selectionIndicator:SetCount(numProducts)
end
function ZO_MarketProductCarousel_Shared:ResetScrollToTop()
    -- To be overridden
end
function ZO_MarketProductCarousel_Shared:UpdateSelection(index)
    self.selectionIndicator:SetSelectionByIndex(index)
    self.selectionIndicatorControl:SetHidden(not self:CanScroll())
end
function ZO_MarketProductCarousel_Shared:EntrySetup(control, data, selected, reselectingDuringRebuild, enabled, activated)
    if control.canSelect == nil then
        control.canSelect = true
    end
    data.isSelected = selected
    control.object:Layout(data)
    local function ResetAutoScroll()
        self:ResetAutoScrollTimer()
    end
end
function ZO_MarketProductCarousel_Shared:Initialize(control, template)
    local function OnSelectionChanged(newData)
        if newData and newData.callback then
            newData.callback(newData)
        end
    end
    local NUM_VISIBLE_CATEGORIES = 1
    
    ZO_HorizontalScrollList_Gamepad.Initialize(self, control, template, NUM_VISIBLE_CATEGORIES, function(...) self:EntrySetup(...) end, MenuEntryTemplateEquality)
    self:SetDisplayEntryType(ZO_HORIZONTAL_SCROLL_LIST_DISPLAY_FIXED_NUMBER_OF_ENTRIES)
    local MOVEMENT_DIRECTION = ZO_HORIZONTALSCROLLLIST_MOVEMENT_TYPES.MOVE_LEFT
    local AUTO_SCROLL_DURATION_SECONDS = 10
    local POST_INTERACTION_DURATION_SECONDS = 10
    local ENABLE_CAROUSEL_WRAP = true
    self:SetAutoScroll(MOVEMENT_DIRECTION, AUTO_SCROLL_DURATION_SECONDS, POST_INTERACTION_DURATION_SECONDS)
    self:SetAllowWrapping(ENABLE_CAROUSEL_WRAP)
    local function SelectionIndicatorClickedCallback()
        local selectedIndex = self.selectionIndicator:GetSelectionIndex()
        -- ZO_HorizontalScrollList:SetSelectedIndex expects indicies 0 through negative n - 1 for indices 1 through n
        local scrollListIndex = -(selectedIndex - 1)
        self:SetSelectedIndex(scrollListIndex)
    end
    self.selectionIndicatorControl = self.control:GetNamedChild("SelectionIndicator")
    self.selectionIndicator = self.selectionIndicatorControl.object
    self.selectionIndicator:SetGrowthPadding(10)
end