Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
event_handler.cc
Go to the documentation of this file.
1
/*
2
$Id: event_handler.cc,v 1.5 2003/02/23 23:14:34 ksterker Exp $
3
4
Copyright (C) 2000/2001/2002 Kai Sterker <kaisterker@linuxgames.com>
5
Part of the Adonthell Project http://adonthell.linuxgames.com
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
16
/**
17
* @file event_handler.cc
18
* @author Kai Sterker <kaisterker@linuxgames.com>
19
*
20
* @brief Implements the event_handler class.
21
*
22
*/
23
24
#include "
event_handler.h
"
25
#include "
map_event.h
"
26
#include "
map_event_handler.h
"
27
#include "
time_event.h
"
28
#include "
time_event_handler.h
"
29
30
// Array with registered event handlers
31
event_handler_base
* event_handler::Handler[MAX_EVENTS];
32
33
// functions that return newly instanciated events
34
// of a certain type
35
NEW_EVENT
(
time_event
)
36
NEW_EVENT
(
enter_event
);
37
NEW_EVENT
(
leave_event
);
38
NEW_EVENT
(
action_event
);
39
40
// Initialize the game event system
41
void
event_handler
::init ()
42
{
43
// register event handlers
44
Handler[ENTER_EVENT] =
new
map_event_handler
;
45
Handler[LEAVE_EVENT] =
new
map_event_handler
;
46
Handler[ACTION_EVENT] =
new
map_event_handler
;
47
Handler[TIME_EVENT] =
new
time_event_handler
;
48
49
// register events
50
REGISTER_EVENT
(TIME_EVENT,
time_event
)
51
REGISTER_EVENT
(ENTER_EVENT, enter_event)
52
REGISTER_EVENT
(LEAVE_EVENT, leave_event)
53
REGISTER_EVENT
(ACTION_EVENT, action_event)
54
}
55
56
// Clear the registered handlers
57
void
event_handler::cleanup
()
58
{
59
for
(
int
i = 0; i < MAX_EVENTS; i++)
60
if
(Handler[i] != NULL)
61
delete
Handler[i];
62
}
src
event_handler.cc
Generated by
1.8.1.1