Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
adonthell.h
Go to the documentation of this file.
1
/*
2
$Id: adonthell.h,v 1.6 2003/02/23 23:14:34 ksterker Exp $
3
4
Copyright (C) 1999/2000/2001 Alexandre Courbot
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
* @file adonthell.h
17
*
18
* @author Alexandre Courbot
19
* @author Kai Sterker
20
* @brief Declares the adonthell class.
21
*/
22
23
#ifndef __ADONTHELL_H__
24
#define __ADONTHELL_H__
25
26
#include "win_mapview.h"
27
28
/**
29
* This is the heart of the Adonthell engine. All activities,
30
* be it checking for user input, calculating a new %game state
31
* and finally rendering a scene are done in the
32
* \ref main_loop "main loop".
33
*
34
* This class works together closely with the
35
* \ref win_manager "window manager" which provides the basic
36
* GUI control methods and the \ref gametime class which is
37
* responsible for synchronising Adonthell to the machine it
38
* is running on.
39
*/
40
class
adonthell
41
{
42
public
:
43
/**
44
* Standard constructor
45
*/
46
adonthell
();
47
48
/**
49
* @name The engine's main loop
50
*
51
*/
52
//@{
53
/**
54
* Starts the main loop. Since having the mainloop running
55
* without a window to display seems to make no sense, you'll
56
* have to pass an inital window when starting the main loop.
57
* This method can be called multiple times. Only those windows
58
* belonging to the outermost main loop are updated and recieve
59
* user input. However, all windows are drawn in correct order,
60
* i.e. innermost first, outermost last.
61
*
62
* See the \ref win_manager "window manager" for more details.
63
*
64
* @param wnd The window to display initially
65
* @param name A name for that window (currently unused)
66
*/
67
void
main
(
win_base
*wnd = NULL,
const
string
name =
""
);
68
69
/**
70
* The actual main loop. First, any user %input is processed,
71
* then the new %game state is calculated and finally all
72
* open (and visible) windows are rendered and displayed on
73
* screen. This (currently) happens up to 50 times per second.
74
*/
75
void
main_loop
();
76
77
/**
78
* Quit the main loop. This stops the outermost main loop
79
* and closes all windows associated with that loop. It does
80
* not delete them however. For that you'll have to call
81
* win_manager::destroy ().
82
*/
83
void
main_quit
();
84
//@}
85
86
/**
87
* @name Fading
88
*
89
*/
90
//@{
91
/**
92
* Fades the screen to black
93
*/
94
void
fade_out
();
95
96
/**
97
* Fades in from a black screen
98
*/
99
void
fade_in
();
100
//@}
101
102
/**
103
* @name Saving and Loading
104
*
105
*/
106
//@{
107
/**
108
* Restore the engine's state. Loads the previously displayed map,
109
* it's state and the state of the mapview from mapengine.data.
110
*
111
* @param file The opened engine state file (mapengine.data).
112
*/
113
s_int8
get_state
(
igzstream
& file);
114
115
/**
116
* Save the engine's state. Writes the current map w/ it's state
117
* and the state of the mapview to mapengine.data.
118
*
119
* @param file The opened engine state file (mapengine.data).
120
*/
121
s_int8
put_state
(
ogzstream
& file);
122
//@}
123
124
/**
125
* @name Additional game control
126
*
127
*/
128
//@{
129
/**
130
* Returns whether the control script is active or not.
131
*
132
* @return
133
* @li true if that is the case.
134
* @li false otherwise.
135
*/
136
bool
control_active
()
137
{
138
return
control_active_;
139
}
140
141
/**
142
* Set whether the control script should be executed or
143
* not. This script provides functionality that is not
144
* directly related to contolling the main character,
145
* like opening the main menu, the load or save screen,
146
* etc.
147
*
148
* @param c Pass true to enable the control script, false
149
* to disable it.
150
*/
151
void
set_control_active
(
bool
c)
152
{
153
control_active_ = c;
154
}
155
//@}
156
157
/**
158
* @todo move landmap handling somewhere else
159
*/
160
landmap
*
get_landmap
()
161
{
162
return
&lmap;
163
}
164
165
/**
166
* @todo move landmap handling somewhere else
167
*/
168
bool
update_map
()
169
{
170
return
update_map_;
171
}
172
173
/**
174
* @todo move landmap handling somewhere else
175
*/
176
void
set_update_map
(
bool
u)
177
{
178
update_map_ = u;
179
}
180
181
/**
182
* @todo move mapview handling somewhere else
183
*/
184
mapview
*
get_mapview
()
185
{
186
return
(
mapview
*) &view;
187
}
188
189
/**
190
* @todo move mapview handling somewhere else
191
*/
192
void
draw
(
s_int16
x,
s_int16
y,
drawing_area
* da_opt = NULL,
193
surface
* target = NULL)
194
{
195
view.mapview::draw (x, y, da_opt, target);
196
}
197
198
/**
199
* @todo move mapview handling somewhere else
200
*/
201
void
set_mapview_schedule
(
string
s, PyObject * args = NULL)
202
{
203
view.mapview::set_schedule (s, args);
204
}
205
206
/**
207
* @todo move mapview handling somewhere else
208
*/
209
void
mapview_start
();
210
211
/**
212
* @todo move mapview handling somewhere else
213
*/
214
void
mapview_stop
();
215
216
private
:
217
py_object
control;
218
// flag to indicate whether the control script is active or not
219
bool
control_active_;
220
// flag to indicate whether to exit the main loop
221
bool
letsexit;
222
// indicates whether the map should be updated or not
223
bool
update_map_;
224
// the current map
225
landmap
lmap;
226
// the current mapview
227
win_mapview
view;
228
};
229
230
#ifndef SWIG
231
namespace
data
232
{
233
/**
234
* Engine used during the game.
235
*
236
*/
237
extern
adonthell
*engine;
238
}
239
#endif // SWIG
240
241
#endif // __ADONTHELL_H__
src
adonthell.h
Generated by
1.8.3.1