Back to Home

ESO Lua File v101044

libraries/zo_scene/zo_scenegroup.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
-- Alias
SCENE_GROUP_SHOWING = ZO_STATE.SHOWING
SCENE_GROUP_SHOWN = ZO_STATE.SHOWN
SCENE_GROUP_HIDING = ZO_STATE.HIDING
SCENE_GROUP_HIDDEN = ZO_STATE.HIDDEN
ZO_SceneGroup = ZO_InitializingCallbackObject:Subclass()
function ZO_SceneGroup:Initialize(...)
    self.state = SCENE_GROUP_HIDDEN
    self.scenes = {}
    for i = 1, select("#", ...) do
        self:AddScene(select(i, ...))
    end
    self.activeScene = 1
end
function ZO_SceneGroup:AddScene(sceneName)
    table.insert(self.scenes, sceneName)
    SCENE_MANAGER:GetScene(sceneName):SetSceneGroup(self)
end
function ZO_SceneGroup:GetNumScenes()
    return #self.scenes
end
function ZO_SceneGroup:GetSceneName(index)
    return self.scenes[index]
end
function ZO_SceneGroup:GetActiveScene()
    return self.scenes[self.activeScene]
end
function ZO_SceneGroup:SetActiveScene(sceneName)
    self.activeScene = self:GetSceneIndexFromScene(sceneName) or 1
end
function ZO_SceneGroup:GetSceneIndexFromScene(sceneName)
    for i=1, #self.scenes do
        if self.scenes[i] == sceneName then
            return i
        end
    end
end
function ZO_SceneGroup:HasScene(sceneName)
    return self:GetSceneIndexFromScene(sceneName) ~= nil
end
function ZO_SceneGroup:SetState(newState)
    if self.state ~= newState then
        local oldState = self.state
        self.state = newState
        self:FireCallbacks("StateChange", oldState, newState)
    end
end
function ZO_SceneGroup:GetState()
    return self.state
end
function ZO_SceneGroup:IsShowing()
    return (self.state == SCENE_GROUP_SHOWING) or (self.state == SCENE_GROUP_SHOWN)
end