5--! \brief User Interfaces
module. This module is used to create user interfaces for the game.
6--! \class FrameworkZ.UserInterfaces
7FrameworkZ.UserInterfaces = {}
8FrameworkZ.UserInterfaces.__index = FrameworkZ.UserInterfaces
9FrameworkZ.UserInterfaces.List = {}
10FrameworkZ.UserInterfaces = FrameworkZ.Foundation:NewModule(FrameworkZ.UserInterfaces, "UserInterfaces")
15function UI:Initialize()
16 return FrameworkZ.UserInterfaces:Initialize(self.uniqueID, self)
19function UI:RegisterNextStep(fromMenuName, toMenuName, fromMenu, toMenu, enterToMenuCallback, exitToMenuCallback, toMenuParameters)
21 fromMenuName = fromMenuName,
22 toMenuName = toMenuName,
25 enterToMenuCallback = enterToMenuCallback,
26 exitToMenuCallback = exitToMenuCallback,
27 toMenuParameters = toMenuParameters
30 table.insert(self.steps, step)
35function UI:ShowNextStep()
36 if self.currentStep >= #self.steps then
37 local currentStepInfo = self.steps[self.currentStep]
38 local fromMenu = currentStepInfo.fromMenu
39 local enterToMenuCallback = currentStepInfo.enterToMenuCallback
41 if fromMenu.instance then
42 enterToMenuCallback(self.parent, fromMenu.instance)
43 fromMenu.instance:setVisible(false)
46 self.onEnterInitialMenu(self.parent)
52 -- Moving to current step's to menu
53 if self.currentStep == 1 then
54 local canGoForward = true
56 if self.onExitInitialMenu then
57 canGoForward = self.onExitInitialMenu(self.parent)
61 local currentStepInfo = self.steps[self.currentStep]
62 local toMenu = currentStepInfo.toMenu
63 local enterToMenuCallback = currentStepInfo.enterToMenuCallback
64 local toMenuParameters = currentStepInfo.toMenuParameters
66 if toMenu.instance then
67 if enterToMenuCallback then
68 enterToMenuCallback(self.parent, toMenu.instance)
71 toMenu.instance:setVisible(true)
73 local toMenuName = currentStepInfo.toMenuName
74 self.parent[toMenuName] = toMenu:new(toMenuParameters)
76 if enterToMenuCallback then
77 enterToMenuCallback(self.parent, self.parent[toMenuName])
80 self.parent[toMenuName]:initialise()
81 self.parent:addChild(self.parent[toMenuName])
84 self.currentStep = self.currentStep + 1
87 -- Move to next step's to menu
89 local previousStepInfo = self.steps[self.currentStep - 1]
90 local currentStepInfo = self.steps[self.currentStep]
91 local fromMenu = currentStepInfo.fromMenu
92 local toMenu = currentStepInfo.toMenu
93 local enterToMenuCallback = currentStepInfo.enterToMenuCallback
94 local exitToMenuCallback = previousStepInfo.exitToMenuCallback
95 local toMenuParameters = currentStepInfo.toMenuParameters
96 local canGoForward = true
98 if fromMenu.instance then
99 if exitToMenuCallback then
100 canGoForward = exitToMenuCallback(self.parent, fromMenu.instance, true)
104 fromMenu.instance:setVisible(false)
109 if toMenu.instance then
110 if enterToMenuCallback then
111 enterToMenuCallback(self.parent, toMenu)
114 toMenu.instance:setVisible(true)
116 local toMenuName = currentStepInfo.toMenuName
117 self.parent[toMenuName] = toMenu:new(toMenuParameters)
119 if enterToMenuCallback then
120 enterToMenuCallback(self.parent, self.parent[toMenuName])
123 self.parent[toMenuName]:initialise()
124 self.parent:addChild(self.parent[toMenuName])
127 self.currentStep = self.currentStep + 1
134function UI:ShowPreviousStep()
135 if self.currentStep <= 1 then
139 -- Moving from initial menu
140 if self.currentStep == 2 then
141 local previousStepInfo = self.steps[self.currentStep - 1]
142 local toMenu = previousStepInfo.toMenu
143 local exitToMenuCallback = previousStepInfo.exitToMenuCallback
145 if toMenu.instance then
146 if exitToMenuCallback then
147 exitToMenuCallback(self.parent, toMenu, false)
150 toMenu.instance:setVisible(false)
153 if self.onEnterInitialMenu then
154 self.onEnterInitialMenu(self.parent)
157 -- Move to previous step's menu
159 local currentStepInfo = self.steps[self.currentStep]
160 local previousStepInfo = self.steps[self.currentStep - 1]
161 local fromMenu = currentStepInfo.fromMenu
162 local toMenu = previousStepInfo.fromMenu
163 local enterToMenuCallback = self.steps[self.currentStep - 2].enterToMenuCallback
164 local exitFromMenuCallback = previousStepInfo.exitToMenuCallback
166 if fromMenu and fromMenu.instance then
167 if exitFromMenuCallback then
168 exitFromMenuCallback(self.parent, fromMenu)
171 fromMenu.instance:setVisible(false)
174 if toMenu and toMenu.instance then
175 if enterToMenuCallback then
176 enterToMenuCallback(self.parent, toMenu)
179 toMenu.instance:setVisible(true)
183 self.currentStep = self.currentStep - 1
188function FrameworkZ.UserInterfaces:New(uniqueID, parent)
196 setmetatable(object, UI)
201function FrameworkZ.UserInterfaces:Initialize(uniqueID, userInterface)
202 self.List[uniqueID] = userInterface
void local enterToMenuCallback()
void local canGoForward()
void local currentStepInfo()
void local previousStepInfo()
void local exitFromMenuCallback()
void local exitToMenuCallback()
void local toMenuParameters()
User Interfaces module. This module is used to create user interfaces for the game.
void New(uniqueID, parent)
void Initialize(uniqueID, userInterface)
FrameworkZ UserInterfaces List
FrameworkZ UserInterfaces __index
void RegisterNextStep(fromMenuName, toMenuName, fromMenu, toMenu, enterToMenuCallback, exitToMenuCallback, toMenuParameters)