4
Copyright (C) 20052011 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [Bear] in the subject of your mails.
25
* \file game_local_client.hpp
26
* \brief The class managing the levels and the development of the game.
27
* \author Julien Jorge
29
#ifndef __ENGINE_GAME_LOCAL_CLIENT_HPP__
30
#define __ENGINE_GAME_LOCAL_CLIENT_HPP__
35
#include "engine/class_export.hpp"
36
#include "engine/game_description.hpp"
37
#include "engine/game_stats.hpp"
38
#include "engine/libraries_pool.hpp"
39
#include "engine/variable/var_map.hpp"
40
#include "time/time.hpp"
41
#include "visual/screen.hpp"
42
#include "universe/types.hpp"
44
#include <claw/arguments_table.hpp>
46
#include <boost/function.hpp>
54
class game_action_load_level;
55
class game_action_pop_level;
56
class game_action_push_level;
57
class game_action_set_current_level;
58
class game_action_set_current_level;
62
* \brief The class managing the levels and the development of the game.
63
* \author Julien Jorge
65
class ENGINE_EXPORT game_local_client
67
friend class game_action;
68
friend class game_action_load_level;
69
friend class game_action_pop_level;
70
friend class game_action_push_level;
71
friend class game_action_set_current_level;
74
/** \brief Type of the game specific initialisation procedure. */
75
typedef void (*init_game_function_type)();
77
/** \brief Type of the game specific ending procedure. */
78
typedef void (*end_game_function_type)();
85
/** \brief The game is under initialization. */
88
/** \brief The game is running. */
91
/** \brief We're quiting. */
97
static void print_help();
99
game_local_client( int& argc, char** &argv );
100
~game_local_client();
103
systime::milliseconds_type get_time_step() const;
105
void set_fullscreen( bool full );
106
bool get_fullscreen() const;
108
void set_sound_muted( bool m );
109
bool get_sound_muted() const;
110
void set_sound_volume( double v );
111
double get_sound_volume() const;
113
void set_music_muted( bool m );
114
bool get_music_muted() const;
115
void set_music_volume( double v );
116
double get_music_volume() const;
118
void screenshot( claw::graphic::image& img ) const;
119
void levelshot( claw::graphic::image& img ) const;
122
void set_waiting_level( const std::string& path );
123
void set_waiting_level( level* the_level );
124
void push_level( const std::string& path );
127
const claw::math::coordinate_2d<unsigned int>& get_screen_size() const;
128
double get_active_area_margin() const;
129
std::string get_custom_game_file( const std::string& name ) const;
131
void get_game_variable( base_variable& val ) const;
132
void get_game_variables
133
( var_map& vars, const std::string& pattern = ".*");
134
void set_game_variable( const base_variable& val );
135
void set_game_variables( const var_map& vars );
136
void erase_game_variables( const std::string& pattern );
137
bool game_variable_exists( const base_variable& val ) const;
138
void get_all_game_variables( var_map& vars ) const;
140
boost::signals::connection
141
listen_int_variable_change
142
( const std::string& name, const boost::function<void (int)>& f );
143
boost::signals::connection
144
listen_uint_variable_change
145
( const std::string& name,
146
const boost::function<void (unsigned int)>& f );
147
boost::signals::connection
148
listen_bool_variable_change
149
( const std::string& name, const boost::function<void (bool)>& f );
150
boost::signals::connection
151
listen_double_variable_change
152
( const std::string& name, const boost::function<void (double)>& f );
153
boost::signals::connection
154
listen_string_variable_change
155
( const std::string& name,
156
const boost::function<void (std::string)>& f );
158
const std::string& get_name() const;
163
void init_game() const;
164
void end_game() const;
166
std::string get_game_name_as_filename() const;
168
std::string get_game_directory() const;
169
bool create_game_directory( const std::string& dir ) const;
172
void one_step_beyond();
174
void progress( universe::time_type elapsed_time );
177
void update_inputs();
179
void init_environment() const;
180
void close_environment() const;
182
void load_libraries( const std::list<std::string>& p );
183
void init_resource_pool( const std::list<std::string>& p ) const;
185
bool do_post_actions();
187
void set_current_level( level* the_level );
188
void load_level( const std::string& path );
190
void do_push_level( const std::string& path );
193
void start_current_level();
197
bool check_arguments( int& argc, char** &argv );
200
bool set_game_variable_from_arg
201
( const std::list<std::string>& args, const char sep );
204
boost::signals::connection
205
listen_variable_change
206
( const std::string& name, boost::function<void (T)> f );
208
static claw::arguments_table get_arguments_table();
211
// must be declared before m_game_description
212
/** \brief The libraries in which we take custom functions. */
213
libraries_pool m_symbols;
215
/** \brief The current status of the game. */
218
/** \brief Description of the game. */
219
game_description m_game_description;
221
/** \brief Global variables of the game. */
222
var_map m_game_variables;
224
/** \brief The screen. */
225
visual::screen* m_screen;
227
/** \brief Tell if we are fullscreen or not. */
230
/** \brief The current level. */
231
level* m_current_level;
233
/** \brief A level in abeyance. */
234
level* m_level_in_abeyance;
236
/** \brief The name of the next level to load, if any. */
237
std::string m_waiting_level;
239
/** \brief Actions to do once an iteration is done. */
240
std::queue<game_action*> m_post_actions;
242
/** \brief Number of milliseconds between two iterations. */
243
systime::milliseconds_type m_time_step;
245
/** \brief The date of the last call to progress. */
246
systime::milliseconds_type m_last_progress;
248
/** \brief The statistics sent at the end of the game. */
251
/** \brief The prefix of the name of the game specific initialization
253
static const std::string s_init_game_function_prefix;
255
/** \brief The prefix of the name of the game specific ending
257
static const std::string s_end_game_function_prefix;
259
}; // class game_local_client
260
} // namespace engine
263
#endif // __ENGINE_GAME_LOCAL_CLIENT_HPP__