Back to Home

ESO Lua File v101036

libraries/zo_systems/zo_systems.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
116
117
118
119
120
121
local ZO_Systems = ZO_Object:Subclass()
function ZO_Systems:New()
    local obj = ZO_Object.New(self)
    obj:Initialize()
    return obj
end
function ZO_Systems:Initialize()
    self.systems = {}
end
function ZO_Systems:GetSystem(systemName)
    local system = self.systems[systemName]
    if not system then
        system = {}
        self.systems[systemName] = system
    end
    return system
end
function ZO_Systems:RegisterKeyboardObject(systemName, object)
    self:GetSystem(systemName).keyboardObject = object
end
function ZO_Systems:RegisterGamepadObject(systemName, object)
    self:GetSystem(systemName).gamepadObject = object
end
function ZO_Systems:RegisterKeyboardRootScene(systemName, scene)
    self:GetSystem(systemName).keyboardRootScene = scene
end
function ZO_Systems:RegisterGamepadRootScene(systemName, scene)
    self:GetSystem(systemName).gamepadRootScene = scene
end
function ZO_Systems:GetKeyboardObject(systemName)
    return self:GetSystem(systemName).keyboardObject
end
function ZO_Systems:GetGamepadObject(systemName)
    return self:GetSystem(systemName).gamepadObject
end
function ZO_Systems:GetKeyboardRootScene(systemName)
    return self:GetSystem(systemName).keyboardRootScene
end
function ZO_Systems:GetGamepadRootScene(systemName)
    return self:GetSystem(systemName).gamepadRootScene
end
function ZO_Systems:GetObject(systemName)
    if IsInGamepadPreferredMode() then
        return self:GetGamepadObject(systemName)
    else
        return self:GetKeyboardObject(systemName)
    end
end
function ZO_Systems:GetObjectBasedOnCurrentScene(systemName)
    if SCENE_MANAGER:GetCurrentScene() then
        if SCENE_MANAGER:IsCurrentSceneGamepad() then
            return self:GetGamepadObject(systemName)
        else
            return self:GetKeyboardObject(systemName)
        end
    end
end
function ZO_Systems:GetRootScene(systemName)
    if IsInGamepadPreferredMode() then
        return self:GetGamepadRootScene(systemName)
    else
        return self:GetKeyboardRootScene(systemName)
    end
end
function ZO_Systems:GetRootSceneName(systemName)
    local rootScene = self:GetRootScene(systemName)
    if rootScene then
        return rootScene:GetName()
    else
        -- must be false, not nil, for some conditionals using this
        return false
    end
end
function ZO_Systems:ShowScene(systemName)
    local sceneName = self:GetRootSceneName(systemName)
    if sceneName then
        SCENE_MANAGER:Show(sceneName)
    end
end
function ZO_Systems:PushScene(systemName)
    local sceneName = self:GetRootSceneName(systemName)
    if sceneName then
        SCENE_MANAGER:Push(sceneName)
    end
end
function ZO_Systems:HideScene(systemName)
    local sceneName = self:GetRootSceneName(systemName)
    if sceneName then
        SCENE_MANAGER:Hide(sceneName)
    end
end
function ZO_Systems:IsShowing(systemName)
    local object = self:GetObject(systemName)
    if object and object.IsSystemShowing then
        return object:IsSystemShowing()
    end
    local sceneName = self:GetRootSceneName(systemName)
    return sceneName and SCENE_MANAGER:IsShowing(sceneName)
end
SYSTEMS = ZO_Systems:New()