Back to Home

ESO Lua File v100036

common/carousel/carousel_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--
-- ZO_Carousel_Shared
--
ZO_Carousel_Shared = ZO_HorizontalScrollList_Gamepad:Subclass()
function ZO_Carousel_Shared:New(...)
    return ZO_HorizontalScrollList_Gamepad.New(self, ...)
end
function ZO_Carousel_Shared:Initialize(control, template, autoScroll)
    local function OnSelectedCallback(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)
    if autoScroll then
        local MOVEMENT_DIRECTION = ZO_HORIZONTALSCROLLLIST_MOVEMENT_TYPES.MOVE_LEFT
        local AUTO_SCROLL_DURATION_SECONDS = 10
        local POST_INTERACTION_DURATION_SECONDS = 10
        self:SetAutoScroll(MOVEMENT_DIRECTION, AUTO_SCROLL_DURATION_SECONDS, POST_INTERACTION_DURATION_SECONDS)
    end
    local ENABLE_CAROUSEL_WRAP = true
    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)
    self.selectionIndicator:SetButtonControlName("Indicator")
end
function ZO_Carousel_Shared:ResetScrollToTop()
    -- To be overridden
end
function ZO_Carousel_Shared:SetSelectionIndicatorPipStateImages(pipSelectedImage, pipUnselectedImage, pipMouseOverImage)
    self.selectionIndicator:SetButtonSelectedImage(pipSelectedImage)
    self.selectionIndicator:SetButtonUnselectedImage(pipUnselectedImage)
    self.selectionIndicator:SetButtonMouseOverImage(pipMouseOverImage)
end
function ZO_Carousel_Shared:SetSelectionIndicatorPipDimensions(width, height)
    self.selectionIndicator:SetButtonWidth(width)
    self.selectionIndicator:SetButtonHeight(height)
end
function ZO_Carousel_Shared:UpdateSelection(index)
    self.selectionIndicator:SetSelectionByIndex(index)
end
function ZO_Carousel_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
    if data.setOnInteractCallback then
    end
end
function ZO_Carousel_Shared:Commit()
    self.selectionIndicator:SetCount(self:GetNumItems())
    self.selectionIndicatorControl:SetHidden(not self:CanScroll())
    ZO_HorizontalScrollList_Gamepad.Commit(self)
end