-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.hpp
executable file
·68 lines (54 loc) · 1.51 KB
/
events.hpp
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
#ifndef EVENTS_HPP
#define EVENTS_HPP
bool evHandle(SDL_Event *ev);
void evRedraw(void);
bool evTimepass(void);
class EventHandler
{
public:
// Handle an event, if this handler can.
// Returns: true if the event was handled, false if the next event handler
// should be tried.
virtual bool handleEvent(SDL_Event *ev) {return false;}
virtual void redraw(void) {}
virtual bool timepass(void) {return false;}
virtual bool isOpaque(void) {return false;}
virtual void onEnable(void) {}
virtual void onDisable(void) {}
virtual int getDrawPriority(void) {return getPriority();}
virtual int getPriority(void) {return 0;}
EventHandler();
virtual ~EventHandler();
void enable(void);
void remove(void);
private:
bool enabled;
};
class MainGameHandler :public EventHandler
{
public:
bool handleEvent(SDL_Event *ev);
void redraw(void);
bool timepass(void);
int getPriority(void) {return 2;}
bool isOpaque(void) {return true;}
void onEnable(void);
};
extern MainGameHandler mainGameHandler;
class FadeHandler :public EventHandler
{
public:
FadeHandler(EventHandler *from, EventHandler *to);
bool handleEvent(SDL_Event *ev);
void redraw(void);
bool timepass(void);
int getPriority(void);
private:
bool switched;
float opacity;
EventHandler *from, *to;
};
void showMainMenu(void);
void showGameOver(void);
extern bool fadeInProgress;
#endif