Back to Home

ESO Lua File v101041

ingame/map/worldmapzonestory_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
107
108
109
110
111
112
113
114
115
ZO_WORLD_MAP_ZONE_STORY_HIDE_REASONS =
{
    NO_DATA = 1,
    MAP_INFO_SHOWN = 2,
    KEEP_INFO_SHOWN = 3,
}
ZO_WorldMapZoneStory_Shared = ZO_Object:Subclass()
function ZO_WorldMapZoneStory_Shared:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_WorldMapZoneStory_Shared:Initialize(control, fragmentClass)
    self.control = control
    self.currentZoneStoryZoneId = 0
    self:InitializeList()
    self.fragment = fragmentClass:New(control)
    self.fragment:RegisterCallback("StateChange", function(_, newState)
        if newState == SCENE_FRAGMENT_SHOWING then
            self:OnShowing()
        elseif newState == SCENE_FRAGMENT_HIDING then
            self:OnHiding()
        elseif newState == SCENE_FRAGMENT_HIDDEN then
            self:OnHidden()
        end
    end)
    -- make sure to have the fragment hidden at the start
    -- since our current zone id is 0, that means we have no data
    self.fragment:SetHiddenForReason(ZO_WORLD_MAP_ZONE_STORY_HIDE_REASONS.NO_DATA, true)
end
function ZO_WorldMapZoneStory_Shared:InitializeList()
    -- To be overridden
end
function ZO_WorldMapZoneStory_Shared:InitializeKeybindDescriptor()
    -- To be overridden
end
function ZO_WorldMapZoneStory_Shared:RegisterForEvents()
    CALLBACK_MANAGER:RegisterCallback("OnWorldMapChanged", function()
        self:RefreshZoneStoryZone()
    end)
end
function ZO_WorldMapZoneStory_Shared:GetFragment()
    return self.fragment
end
function ZO_WorldMapZoneStory_Shared:IsShowing()
    return self.fragment:IsShowing()
end
function ZO_WorldMapZoneStory_Shared:GetBackgroundFragment()
    assert(false) -- Must be overriden
end
function ZO_WorldMapZoneStory_Shared:GetCurrentZoneStoryZoneId()
    return self.currentZoneStoryZoneId
end
function ZO_WorldMapZoneStory_Shared:RefreshZoneStoryZone()
    local oldZoneStoryZoneId = self.currentZoneStoryZoneId
    local currentZoneIndex = GetCurrentMapZoneIndex()
    self.currentZoneStoryZoneId = ZO_ExplorationUtils_GetZoneStoryZoneIdByZoneIndex(currentZoneIndex)
    if oldZoneStoryZoneId ~= self.currentZoneStoryZoneId then
        local hasData = ZONE_STORIES_MANAGER:GetZoneData(self.currentZoneStoryZoneId) ~= nil
        self.fragment:SetHiddenForReason(ZO_WORLD_MAP_ZONE_STORY_HIDE_REASONS.NO_DATA, not hasData)
        self:RefreshInfo()
    end
end
function ZO_WorldMapZoneStory_Shared:HasZoneStoryData()
    -- So that we're not dependent on order of which system registered for world map callbacks when, this function should always be forced to be up to date
    return ZONE_STORIES_MANAGER:GetZoneData(self.currentZoneStoryZoneId) ~= nil
end
function ZO_WorldMapZoneStory_Shared:RefreshInfo()
    -- To be overridden
end
function ZO_WorldMapZoneStory_Shared:CanCycleTooltip()
    assert(false) -- Must be overriden, platform specific
end
function ZO_WorldMapZoneStory_Shared:OnShowing()
    local backgroundFragment = self:GetBackgroundFragment()
    if backgroundFragment then
        SCENE_MANAGER:AddFragment(backgroundFragment)
    end
    self:RefreshInfo()
end
function ZO_WorldMapZoneStory_Shared:OnHiding()
    local backgroundFragment = self:GetBackgroundFragment()
    if backgroundFragment then
        SCENE_MANAGER:RemoveFragment(self:GetBackgroundFragment())
    end
end
function ZO_WorldMapZoneStory_Shared:OnHidden()
    -- To be overridden
end