-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonManager.cpp
More file actions
52 lines (41 loc) · 1.15 KB
/
buttonManager.cpp
File metadata and controls
52 lines (41 loc) · 1.15 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
#include "buttonManager.h"
// Signal class encapsulates the signal for the map since maps can't take arrays as values.
Signal::Signal(void)
{
}
// Specifies the signal for each button in the button manager.
Signal::Signal(char _signal[64])
{
strcpy(signal, _signal);
}
Signal::~Signal(void)
{
}
//buttonManager class keeps track of all the buttons and their signals.
buttonManager::buttonManager(void)
{
strcpy(signal, "");
}
buttonManager::~buttonManager(void)
{
}
void buttonManager::createButton(int _x, int _y, int _width, int _height, Signal _signal) {
button _button(_x, _y, _width, _height);
buttonList[_button] = Signal(_signal);
}
void buttonManager::addButton(button _button, Signal _signal) {
buttonList[_button] = Signal(_signal);
}
void buttonManager::update(int mouse[2], bool lClicked) {
strcpy(signal, "");
std::map<button, Signal>::reverse_iterator it;
for ( it = buttonList.rbegin(); it != buttonList.rend(); ++it ) {
button but = it->first;
but.mouse[0] = mouse[0];
but.mouse[1] = mouse[1];
but.update(lClicked);
if (but.pressed) {
strcpy(signal, it->second.signal);
}
}
}