-
Notifications
You must be signed in to change notification settings - Fork 0
/
CAbstractMenuScreen.h
91 lines (76 loc) · 2.09 KB
/
CAbstractMenuScreen.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef CABSTRACTCMENUSCREEN_H
#define CABSTRACTCMENUSCREEN_H
#include <iostream>
#define MAXITEMS 5 ///< maximum number of items in single menu
class CController;
using namespace std;
/**
*
* Abstract parent class for menu classes
*
*/
class CAbstractMenuScreen {
public:
/**
*Initializes menu
*
* @param Pointer to the previous menu
*/
CAbstractMenuScreen(CAbstractMenuScreen * prPar=NULL);
virtual ~CAbstractMenuScreen();
/**
* Reads input from user
*
*/
virtual int readInput();
/**
* Fisplays whole menu
*
*/
virtual void show() const;
/**
* Displays a single item from menu
*
*/
void printMenuItem(int i) const;
/**
* Sets pointer to next menu
*
*/
virtual void setNextMenu() = 0;
/**
* Sets whatever there is to be set from this menu that is needed for game initialization
*
*/
virtual void setStuff(CController * ctrler) = 0;
CAbstractMenuScreen * nextMenu; ///< pointer to the next menu(NULL if it is the last menu before entering the game)
CAbstractMenuScreen * prevMenu; ///< pointer to the previous menu
protected:
/**
* Returns index of the chosen option from this menu
* @return int index of the chosen option
*/
int getChoice() const;
/**
* Checks if the given index is withing range of options in this menu
* @param int index of the chosen option
*
*/
bool validChoice(int i) const;
/**
* Sets number of items in this menu
* Note: Number of items in each menu differs.
*
*/
void setNumMenuItems();
/**
* Shows title of the current menu
*
*/
void showTitle() const;
string menuItems[MAXITEMS]; ///< array of items in the menu
int numItems; ///< number of items in the menu
int chosenOption; ///<index of the option chosen by user
string title; ///< title of current menu
};
#endif /* CABSTRACTCMENUSCREEN_H */