-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.h
More file actions
65 lines (54 loc) · 1.72 KB
/
Copy pathGUI.h
File metadata and controls
65 lines (54 loc) · 1.72 KB
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
/***********************************************************************//**
* Abstract class declare an array of "box" (or click zones).
* Each box has a distinct value.
* Has method to get user's click and return the value of the box clicked
* Derive this class to make different guis
***************************************************************************/
#ifndef GUI_H
#define GUI_H
#include <SDL2/SDL.h>
#include <vector>
class GUI
{
protected:
/**********************************************************//**
* A rectangular region with a specific value assigned to it.
* Used to create buttons in GUI.
**************************************************************/
class Box {
public:
int x1, y1, x2, y2;
int boxValue;
/**
* Create a box
* @param x1, y1, x2, y2 bounds of the box
* @param value the value of the box. Value of 0 will causes undefined behavior.
*/
Box(int x1, int y1, int x2, int y2, int value);
/**
* Check if a point is inside the box
* @param x, y coordinates of the given point
*/
bool contains(int x, int y);
};
std::vector<Box> boxes; /**< The array of boxes to get input from */
public:
GUI();
virtual ~GUI();
/**
* Quit flag
*/
static bool quit;
/**
* Get user's click.
* If user quits, set GUI::quit to true.
* @return value of the clicked box
* 0 if there's no click or if user quits
*/
int getInput();
/**
* Draw the GUI on the screen
*/
virtual void draw(SDL_Renderer* renderer) = 0;
};
#endif // GUI_H