4
Copyright (C) 2005-2010 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/libraries_pool.hpp"
38
#include "engine/variable/var_map.hpp"
39
#include "time/time.hpp"
40
#include "visual/screen.hpp"
41
#include "universe/types.hpp"
43
#include <claw/arguments_table.hpp>
51
class game_action_load_level;
52
class game_action_pop_level;
53
class game_action_push_level;
54
class game_action_set_current_level;
55
class game_action_set_current_level;
59
* \brief The class managing the levels and the development of the game.
60
* \author Julien Jorge
62
class ENGINE_EXPORT game_local_client
64
friend class game_action;
65
friend class game_action_load_level;
66
friend class game_action_pop_level;
67
friend class game_action_push_level;
68
friend class game_action_set_current_level;
71
/** \brief Type of the game specific initialisation procedure. */
72
typedef void (*init_game_function_type)();
74
/** \brief Type of the game specific ending procedure. */
75
typedef void (*end_game_function_type)();
82
/** \brief The game is under initialization. */
85
/** \brief The game is running. */
88
/** \brief We're quiting. */
94
static void print_help();
96
game_local_client( int& argc, char** &argv );
100
systime::milliseconds_type get_time_step() const;
102
void set_fullscreen( bool full );
103
bool get_fullscreen() const;
105
void set_sound_muted( bool m );
106
bool get_sound_muted() const;
107
void set_sound_volume( double v );
108
double get_sound_volume() const;
110
void set_music_muted( bool m );
111
bool get_music_muted() const;
112
void set_music_volume( double v );
113
double get_music_volume() const;
115
void screenshot( claw::graphic::image& img ) const;
116
void levelshot( claw::graphic::image& img ) const;
119
void set_waiting_level( const std::string& path );
120
void set_waiting_level( level* the_level );
121
void push_level( const std::string& path );
124
const claw::math::coordinate_2d<unsigned int>& get_screen_size() const;
125
double get_active_area_margin() const;
126
std::string get_custom_game_file( const std::string& name ) const;
128
void get_game_variable( base_variable& val ) const;
129
void set_game_variable( const base_variable& val );
130
bool game_variable_exists( const base_variable& val ) const;
132
const std::string& get_name() const;
135
void init_game() const;
136
void end_game() const;
138
std::string get_game_name_as_filename() const;
140
std::string get_game_directory() const;
141
bool create_game_directory( const std::string& dir ) const;
144
void one_step_beyond();
146
void progress( universe::time_type elapsed_time );
149
void update_inputs();
151
void init_environment() const;
152
void close_environment() const;
154
void load_libraries( const std::list<std::string>& p );
155
void init_resource_pool( const std::list<std::string>& p ) const;
157
bool do_post_actions();
159
void set_current_level( level* the_level );
160
void load_level( const std::string& path );
162
void do_push_level( const std::string& path );
165
void start_current_level();
169
bool check_arguments( int& argc, char** &argv );
171
bool set_game_variable_from_arg
172
( const std::list<std::string>& args, const char sep );
174
static claw::arguments_table get_arguments_table();
177
// must be declared before m_game_description
178
/** \brief The libraries in which we take custom functions. */
179
libraries_pool m_symbols;
181
/** \brief The current status of the game. */
184
/** \brief Description of the game. */
185
game_description m_game_description;
187
/** \brief Global variables of the game. */
188
var_map m_game_variables;
190
/** \brief The screen. */
191
visual::screen* m_screen;
193
/** \brief Tell if we are fullscreen or not. */
196
/** \brief The current level. */
197
level* m_current_level;
199
/** \brief A level in abeyance. */
200
level* m_level_in_abeyance;
202
/** \brief The name of the next level to load, if any. */
203
std::string m_waiting_level;
205
/** \brief Actions to do once an iteration is done. */
206
std::queue<game_action*> m_post_actions;
208
/** \brief Number of milliseconds between two iterations. */
209
systime::milliseconds_type m_time_step;
211
/** \brief The date of the last call to progress. */
212
systime::milliseconds_type m_last_progress;
214
/** \brief The prefix of the name of the game specific initialization
216
static const std::string s_init_game_function_prefix;
218
/** \brief The prefix of the name of the game specific ending
220
static const std::string s_end_game_function_prefix;
223
} // namespace engine
226
#endif // __ENGINE_GAME_HPP__