~ubuntu-branches/ubuntu/trusty/plee-the-bear/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/ptb-signals-v2.diff/bear-engine/core/src/engine/game_local_client.hpp

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng, Evgeni Golov, Gonéri Le Bouder, Julien Jorge, Vincent Cheng
  • Date: 2014-01-23 13:20:52 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140123132052-r0kg74mh6egto11t
Tags: 0.6.0-2
* Team upload.

[ Evgeni Golov ]
* Correct Vcs-* URLs to point to anonscm.debian.org

[ Gonéri Le Bouder ]
* import patches by Julien Jorge to fix a FTBFS  with the current
  Boost.FileSystem (closes: #720819)
* Add myself in Uploaders
* Indent the B-D

[ Julien Jorge ]
* Add mipsn32el mips64 mips64el in the architecures (closes: #726176)
* Add a patch to use the full path to the icon in the menu files
  (closes: #726853)

[ Vincent Cheng ]
* Refresh patches.
* Update to Standards version 3.9.5.
* Update to source format "3.0 (quilt)".

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Bear Engine
 
3
 
 
4
  Copyright (C) 20052011 Julien Jorge, Sebastien Angibaud
 
5
 
 
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.
 
10
 
 
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
 
14
  more details.
 
15
 
 
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
 
19
 
 
20
  contact: plee-the-bear@gamned.org
 
21
 
 
22
  Please add the tag [Bear] in the subject of your mails.
 
23
*/
 
24
/**
 
25
 * \file game_local_client.hpp
 
26
 * \brief The class managing the levels and the development of the game.
 
27
 * \author Julien Jorge
 
28
 */
 
29
#ifndef __ENGINE_GAME_LOCAL_CLIENT_HPP__
 
30
#define __ENGINE_GAME_LOCAL_CLIENT_HPP__
 
31
 
 
32
#include <fstream>
 
33
#include <queue>
 
34
 
 
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"
 
43
 
 
44
#include <claw/arguments_table.hpp>
 
45
 
 
46
#include <boost/function.hpp>
 
47
 
 
48
namespace bear
 
49
{
 
50
  namespace engine
 
51
  {
 
52
    class base_variable;
 
53
    class game_action;
 
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;
 
59
    class level;
 
60
 
 
61
    /**
 
62
     * \brief The class managing the levels and the development of the game.
 
63
     * \author Julien Jorge
 
64
     */
 
65
    class ENGINE_EXPORT game_local_client
 
66
    {
 
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;
 
72
 
 
73
    private:
 
74
      /** \brief Type of the game specific initialisation procedure. */
 
75
      typedef void (*init_game_function_type)();
 
76
 
 
77
      /** \brief Type of the game specific ending procedure. */
 
78
      typedef void (*end_game_function_type)();
 
79
 
 
80
      /**
 
81
       * \brief Game status.
 
82
       */
 
83
      enum status
 
84
        {
 
85
          /** \brief The game is under initialization. */
 
86
          status_init,
 
87
 
 
88
          /** \brief The game is running. */
 
89
          status_run,
 
90
 
 
91
          /** \brief We're quiting. */
 
92
          status_quit
 
93
 
 
94
        }; // enum status
 
95
 
 
96
    public:
 
97
      static void print_help();
 
98
 
 
99
      game_local_client( int& argc, char** &argv );
 
100
      ~game_local_client();
 
101
 
 
102
      void run();
 
103
      systime::milliseconds_type get_time_step() const;
 
104
 
 
105
      void set_fullscreen( bool full );
 
106
      bool get_fullscreen() const;
 
107
 
 
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;
 
112
 
 
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;
 
117
 
 
118
      void screenshot( claw::graphic::image& img ) const;
 
119
      void levelshot( claw::graphic::image& img ) const;
 
120
 
 
121
      void end();
 
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 );
 
125
      void pop_level();
 
126
 
 
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;
 
130
 
 
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;
 
139
 
 
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 );
 
157
 
 
158
      const std::string& get_name() const;
 
159
 
 
160
    private:
 
161
      void init_stats();
 
162
 
 
163
      void init_game() const;
 
164
      void end_game() const;
 
165
 
 
166
      std::string get_game_name_as_filename() const;
 
167
 
 
168
      std::string get_game_directory() const;
 
169
      bool create_game_directory( const std::string& dir ) const;
 
170
 
 
171
      void run_level();
 
172
      void one_step_beyond();
 
173
 
 
174
      void progress( universe::time_type elapsed_time );
 
175
      void render();
 
176
 
 
177
      void update_inputs();
 
178
 
 
179
      void init_environment() const;
 
180
      void close_environment() const;
 
181
 
 
182
      void load_libraries( const std::list<std::string>& p );
 
183
      void init_resource_pool( const std::list<std::string>& p ) const;
 
184
 
 
185
      bool do_post_actions();
 
186
 
 
187
      void set_current_level( level* the_level );
 
188
      void load_level( const std::string& path );
 
189
      void close_level();
 
190
      void do_push_level( const std::string& path );
 
191
      void do_pop_level();
 
192
 
 
193
      void start_current_level();
 
194
 
 
195
      void clear();
 
196
 
 
197
      bool check_arguments( int& argc, char** &argv );
 
198
 
 
199
      template<typename T>
 
200
      bool set_game_variable_from_arg
 
201
        ( const std::list<std::string>& args, const char sep );
 
202
 
 
203
      template<typename T>
 
204
        boost::signals::connection
 
205
        listen_variable_change
 
206
        ( const std::string& name, boost::function<void (T)> f );
 
207
 
 
208
      static claw::arguments_table get_arguments_table();
 
209
 
 
210
    private:
 
211
      // must be declared before m_game_description
 
212
      /** \brief The libraries in which we take custom functions. */
 
213
      libraries_pool m_symbols;
 
214
 
 
215
      /** \brief The current status of the game. */
 
216
      status m_status;
 
217
 
 
218
      /** \brief Description of the game. */
 
219
      game_description m_game_description;
 
220
 
 
221
      /** \brief Global variables of the game. */
 
222
      var_map m_game_variables;
 
223
 
 
224
      /** \brief The screen. */
 
225
      visual::screen* m_screen;
 
226
 
 
227
      /** \brief Tell if we are fullscreen or not. */
 
228
      bool m_fullscreen;
 
229
 
 
230
      /** \brief The current level. */
 
231
      level* m_current_level;
 
232
 
 
233
      /** \brief A level in abeyance. */
 
234
      level* m_level_in_abeyance;
 
235
 
 
236
      /** \brief The name of the next level to load, if any. */
 
237
      std::string m_waiting_level;
 
238
 
 
239
      /** \brief Actions to do once an iteration is done. */
 
240
      std::queue<game_action*> m_post_actions;
 
241
 
 
242
      /** \brief Number of milliseconds between two iterations. */
 
243
      systime::milliseconds_type m_time_step;
 
244
 
 
245
      /** \brief The date of the last call to progress. */
 
246
      systime::milliseconds_type m_last_progress;
 
247
 
 
248
      /** \brief The statistics sent at the end of the game. */
 
249
      game_stats m_stats;
 
250
 
 
251
      /** \brief The prefix of the name of the game specific initialization
 
252
          procedure. */
 
253
      static const std::string s_init_game_function_prefix;
 
254
 
 
255
      /** \brief The prefix of the name of the game specific ending
 
256
          procedure. */
 
257
      static const std::string s_end_game_function_prefix;
 
258
 
 
259
    }; // class game_local_client
 
260
  } // namespace engine
 
261
} // namespace bear
 
262
 
 
263
#endif // __ENGINE_GAME_LOCAL_CLIENT_HPP__