wavelength 1.0.0
Loading...
Searching...
No Matches
uiscreen.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <vector>
5
6#include "app/msgsink.h"
8#include "os/prnstream.h"
9#include "os/strless.h"
10#include "script/dataarray.h"
11#include "ui/uicomponent.h"
13#include "ui/uipanel.h"
14
35class UIScreen : public MsgSink {
36public:
38 struct Transition {
39 const char *mScreen;
40 const char *mComponent;
41 int mButton;
42 };
43
51 explicit UIScreen(DataArray *pData);
52
59 ~UIScreen() override;
60
71 static UIScreen *New(DataArray *pData) {
72 return new UIScreen(pData);
73 }
74
87 bool Dispatch(Message *pMsg) override;
88
97 bool DispatchPriv(Message *pMsg) override;
98
106 virtual void Poll(float fTime);
107
114 virtual void Draw();
115
127 virtual void Exit(UIScreen *pNextScreen, float fTime);
128
137 virtual void Enter(UIScreen *pPrevScreen, float fTime);
138
146 virtual void Print(PrnStream &stream);
147
155
167 void AddTransition(const char *pszComponent, int nButton, const char *pszScreen);
168
176 void AddPanel(UIPanel *pPanel);
177
187
197
205 void SetFocus(UIPanel *pPanel);
206
217 UIComponent *FindComponent(const char *pszName);
218
228 Transition *FindTransition(UIComponent *pComponent, bool bFail);
229
239 Transition *FindTransition(int nButton, bool bFail);
240
247 void Load();
248
255 void Unload();
256
264 bool IsLoaded();
265
267 const char *GetName() const {
268 return mName;
269 }
270
272 const char *GetGroup() const {
273 return mGroup;
274 }
275
278 return mFocusPanel;
279 }
280
283 return mNextScreen;
284 }
285
288 return mPrevScreen;
289 }
290
292 const std::map<const char *, UIPanel *, StrLess> &GetPanels() const {
293 return mPanels;
294 }
295
296protected:
297 const char *mName;
298
299 const char *mGroup;
300
301 std::map<const char *, UIPanel *, StrLess> mPanels;
302
304
305 std::vector<Transition> mTransitions;
306
308
310
312};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Message the controller poll sends when a button is pressed or released.
Definition joypadinputmsg.h:23
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Receiver of engine messages.
Definition msgsink.h:21
Text output stream.
Definition prnstream.h:16
Message a component sends when the player chooses it.
Definition uicomponentselectmsg.h:28
One control of a front-end panel, such as a label, a button, or a list.
Definition uicomponent.h:21
Group of components drawn from one .rnd file, which a screen shows.
Definition uipanel.h:35
UIScreen * GetNextScreen() const
Definition uiscreen.h:282
UIPanel * mFocusPanel
Definition uiscreen.h:303
void Load()
Load the panels.
std::vector< Transition > mTransitions
Definition uiscreen.h:305
std::map< const char *, UIPanel *, StrLess > mPanels
Definition uiscreen.h:301
virtual void Exit(UIScreen *pNextScreen, float fTime)
Start the exit to another screen.
virtual void Enter(UIScreen *pPrevScreen, float fTime)
Become the current screen and start the entry animations of the panels.
void AddTransition(const char *pszComponent, int nButton, const char *pszScreen)
Append an entry to the transition table.
void Unload()
Unload the panels.
UIPanel * GetFocusPanel() const
Definition uiscreen.h:277
virtual void Draw()
Draw the panels.
bool DispatchPriv(Message *pMsg) override
Follow the transition of a pressed button or a chosen component.
bool Dispatch(Message *pMsg) override
Offer a message to the manager, then handle it here, then pass a navigation message on.
virtual void Poll(float fTime)
Advance the panels to a time, and finish the exit or the entry once their animations stop.
bool IsLoaded()
Report whether every panel has loaded.
Transition * FindTransition(UIComponent *pComponent, bool bFail)
Find the transition of a component.
~UIScreen() override
Destroy the screen.
UIComponent * FindComponent(const char *pszName)
Find a component on any of the screen's panels.
bool HandleSelect(UIComponentSelectMsg *pMsg)
Follow the transition of a component chosen with the cross button.
void AddPanel(UIPanel *pPanel)
Add a panel to the screen.
UIScreen * mNextScreen
Definition uiscreen.h:309
const char * mGroup
Definition uiscreen.h:299
const char * GetGroup() const
Definition uiscreen.h:272
static UIScreen * New(DataArray *pData)
Create a screen from its script description.
Definition uiscreen.h:71
int mForceEntryExit
Definition uiscreen.h:311
Transition * FindTransition(int nButton, bool bFail)
Find the transition of a controller button.
void ClearTransitions()
Empty the transition table.
UIScreen(DataArray *pData)
Construct a screen from its script description.
virtual void Print(PrnStream &stream)
Write a description of the screen, its panels, and its transitions.
UIScreen * mPrevScreen
Definition uiscreen.h:307
UIScreen * GetPrevScreen() const
Definition uiscreen.h:287
const std::map< const char *, UIPanel *, StrLess > & GetPanels() const
Definition uiscreen.h:292
const char * GetName() const
Definition uiscreen.h:267
bool HandleJoypad(JoypadInputMsg *pMsg)
Follow the transition of a pressed controller button.
void SetFocus(UIPanel *pPanel)
Move the focus to a panel.
const char * mName
Definition uiscreen.h:297
One entry of the screen's transition table.
Definition uiscreen.h:38
const char * mComponent
Definition uiscreen.h:40
int mButton
Definition uiscreen.h:41
const char * mScreen
Definition uiscreen.h:39