-
Notifications
You must be signed in to change notification settings - Fork 1
/
MenuScreen.h
66 lines (54 loc) · 1.8 KB
/
MenuScreen.h
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
#ifndef _MENU_SCREEN_H_
#define _MENU_SCREEN_H_
#include <string>
#include <vector>
#include <memory>
#include <SDL2/SDL.h>
#include "MenuItem.h"
namespace typing
{
class MenuScreen
{
public:
// Ctors/Dtors
virtual ~MenuScreen()
{
}
// Constants
// NextAction enum contains values indicating what to do after this menu has updated,
// returned by MenuScreen::Update
// - ACTION_NONE : No action, update this menu again
// - ACTION_NEXT : Switch to the menu identified by this MenuScreen's NextMenu
// - ACTION_NEXT_AND_POP: Switch to the menu identified by this Menuscreen's NextMenu and pop this menu off the stack.
// - ACTION_PREV : Switch to the menu displayed before this one
// - ACTION_GAME : (Re)start the game
enum NextAction { ACTION_NONE, ACTION_NEXT, ACTION_NEXT_AND_POP, ACTION_PREV, ACTION_GAME };
// Methods
virtual void Init() = 0;
virtual const std::string NextMenu() const = 0;
virtual NextAction OnKeyDown(SDL_Keycode keycode);
virtual void Draw();
virtual void OnType(char c)
{
}
virtual NextAction Update()
{
return ACTION_NONE;
}
virtual NextAction OnMenuItemChoose(unsigned int)
{
return ACTION_NONE;
}
void AddMenuItem(const MenuItemPtr& item)
{
m_menuItems.push_back(item);
}
private:
// Typedefs
typedef std::vector<MenuItemPtr> MenuItems;
// Members
MenuItems m_menuItems;
};
typedef std::shared_ptr<MenuScreen> MenuScreenPtr;
}
#endif // _MENU_SCREEN_H_