Back to Home

ESO Lua File v101042

pregame/characterselect/characterselect_eventbanner_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
ZO_CharacterSelect_EventBanner_Shared = ZO_Object:Subclass()
function ZO_CharacterSelect_EventBanner_Shared:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_CharacterSelect_EventBanner_Shared:Initialize(control, fragmentConditionFunction)
    self.control = control
    local container = control:GetNamedChild("Container")
    self.carouselControl = container:GetNamedChild("Carousel")
    self.controlContainer = container
    local fragment = ZO_FadeSceneFragment:New(control)
    fragment:RegisterCallback("StateChange", function(...) self:OnStateChanged(...) end)
    if fragmentConditionFunction then
        fragment:SetConditional(fragmentConditionFunction)
    end
    self.fragment = fragment
    CHARACTER_SELECT_MANAGER:RegisterCallback("EventAnnouncementExpired", function() self:PopulateCarousel() end)
end
function ZO_CharacterSelect_EventBanner_Shared:GetFragment()
    return self.fragment
end
function ZO_CharacterSelect_EventBanner_Shared:OnStateChanged(oldState, newState)
    if newState == SCENE_SHOWING then
        self:OnShowing()
    elseif newState == SCENE_SHOWN then
        self:OnShown()
    elseif newState == SCENE_HIDING then
        self:OnHiding()
    elseif newState == SCENE_HIDDEN then
        self:OnHidden()
    end
end
function ZO_CharacterSelect_EventBanner_Shared:OnShowing()
    PlaySound(SOUNDS.DEFAULT_WINDOW_OPEN)
    self.carousel:Activate()
end
function ZO_CharacterSelect_EventBanner_Shared:OnShown()
    -- To be overridden
end
function ZO_CharacterSelect_EventBanner_Shared:OnHiding()
    PlaySound(SOUNDS.DEFAULT_WINDOW_CLOSE)
    self.carousel:Deactivate()
    CHARACTER_SELECT_MANAGER:UpdateLastSeenTimestamp()
end
function ZO_CharacterSelect_EventBanner_Shared:OnHidden()
    -- To be overridden
end
function ZO_CharacterSelect_EventBanner_Shared:GetPlatformEventTileTemplate()
    assert(false) -- To be overridden
end
function ZO_CharacterSelect_EventBanner_Shared:InitializeKeybinds()
    -- To be overridden
end
function ZO_CharacterSelect_EventBanner_Shared:PopulateCarousel()
    self.carousel:Clear()
    local numEvents = CHARACTER_SELECT_MANAGER:GetNumEventAnnouncements()
    for i = 1, numEvents do
        local data = CHARACTER_SELECT_MANAGER:GetEventAnnouncementDataByIndex(i)
        local entryData =
        {
            index = data.index,
            name = data.name,
            description = data.description,
            image = data.image,
            startTime = data.startTime,
            remainingTime = data.remainingTime,
            callback = function() self:OnSelectionChanged(i) end
        }
        self.carousel:AddEntry(entryData)
    end
    self.carousel:Commit()
    local ALLOW_IF_DISABLED = true
    local WITHOUT_ANIMATION = true
    self.carousel:SetSelectedIndex(self.autoSelectIndex or 0, ALLOW_IF_DISABLED, WITHOUT_ANIMATION)
end
function ZO_CharacterSelect_EventBanner_Shared:OnEventBannerCloseKeybind()
    PlaySound(SOUNDS.DIALOG_ACCEPT)
    SCENE_MANAGER:RemoveFragment(self:GetFragment())
end
function ZO_CharacterSelect_EventBanner_Shared:OnSelectionChanged(index)
    self.carousel:UpdateSelection(index)
end