~ubuntu-branches/ubuntu/natty/plee-the-bear/natty

« back to all changes in this revision

Viewing changes to bear-engine/core/src/engine/game_local_client.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Julien Jorge, Julien Jorge
  • Date: 2010-11-17 20:13:34 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20101117201334-o4dp7uq437to7oxb
Tags: 0.5.1-1
[ Julien Jorge ]
* New upstream release (Closes: #565062, #546514).
* Add armhf architecture (Closes: #604689).
* Remove patches integrated upstream: rpath-editors.diff, rpath-game.diff,
  editors-menu-section.diff.
* Bump the Standard-Version, no changes.
* Update my email address.
* Set build dependency of libclaw to 1.6.0.
* Add the missing ${misc:Depends} in debian/control.
* List gettext translations in bear-factory.install and plee-the-bear.install.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Bear Engine
 
3
 
 
4
  Copyright (C) 2005-2010 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/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"
 
42
 
 
43
#include <claw/arguments_table.hpp>
 
44
 
 
45
namespace bear
 
46
{
 
47
  namespace engine
 
48
  {
 
49
    class base_variable;
 
50
    class game_action;
 
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;
 
56
    class level;
 
57
 
 
58
    /**
 
59
     * \brief The class managing the levels and the development of the game.
 
60
     * \author Julien Jorge
 
61
     */
 
62
    class ENGINE_EXPORT game_local_client
 
63
    {
 
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;
 
69
 
 
70
    private:
 
71
      /** \brief Type of the game specific initialisation procedure. */
 
72
      typedef void (*init_game_function_type)();
 
73
 
 
74
      /** \brief Type of the game specific ending procedure. */
 
75
      typedef void (*end_game_function_type)();
 
76
 
 
77
      /**
 
78
       * \brief Game status.
 
79
       */
 
80
      enum status
 
81
        {
 
82
          /** \brief The game is under initialization. */
 
83
          status_init,
 
84
 
 
85
          /** \brief The game is running. */
 
86
          status_run,
 
87
 
 
88
          /** \brief We're quiting. */
 
89
          status_quit
 
90
 
 
91
        }; // enum status
 
92
 
 
93
    public:
 
94
      static void print_help();
 
95
 
 
96
      game_local_client( int& argc, char** &argv );
 
97
      ~game_local_client();
 
98
 
 
99
      void run();
 
100
      systime::milliseconds_type get_time_step() const;
 
101
 
 
102
      void set_fullscreen( bool full );
 
103
      bool get_fullscreen() const;
 
104
 
 
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;
 
109
 
 
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;
 
114
 
 
115
      void screenshot( claw::graphic::image& img ) const;
 
116
      void levelshot( claw::graphic::image& img ) const;
 
117
 
 
118
      void end();
 
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 );
 
122
      void pop_level();
 
123
 
 
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;
 
127
 
 
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;
 
131
 
 
132
      const std::string& get_name() const;
 
133
 
 
134
    private:
 
135
      void init_game() const;
 
136
      void end_game() const;
 
137
 
 
138
      std::string get_game_name_as_filename() const;
 
139
 
 
140
      std::string get_game_directory() const;
 
141
      bool create_game_directory( const std::string& dir ) const;
 
142
 
 
143
      void run_level();
 
144
      void one_step_beyond();
 
145
 
 
146
      void progress( universe::time_type elapsed_time );
 
147
      void render();
 
148
 
 
149
      void update_inputs();
 
150
 
 
151
      void init_environment() const;
 
152
      void close_environment() const;
 
153
 
 
154
      void load_libraries( const std::list<std::string>& p );
 
155
      void init_resource_pool( const std::list<std::string>& p ) const;
 
156
 
 
157
      bool do_post_actions();
 
158
 
 
159
      void set_current_level( level* the_level );
 
160
      void load_level( const std::string& path );
 
161
      void close_level();
 
162
      void do_push_level( const std::string& path );
 
163
      void do_pop_level();
 
164
 
 
165
      void start_current_level();
 
166
 
 
167
      void clear();
 
168
 
 
169
      bool check_arguments( int& argc, char** &argv );
 
170
      template<typename T>
 
171
      bool set_game_variable_from_arg
 
172
        ( const std::list<std::string>& args, const char sep );
 
173
 
 
174
      static claw::arguments_table get_arguments_table();
 
175
 
 
176
    private:
 
177
      // must be declared before m_game_description
 
178
      /** \brief The libraries in which we take custom functions. */
 
179
      libraries_pool m_symbols;
 
180
 
 
181
      /** \brief The current status of the game. */
 
182
      status m_status;
 
183
 
 
184
      /** \brief Description of the game. */
 
185
      game_description m_game_description;
 
186
 
 
187
      /** \brief Global variables of the game. */
 
188
      var_map m_game_variables;
 
189
 
 
190
      /** \brief The screen. */
 
191
      visual::screen* m_screen;
 
192
 
 
193
      /** \brief Tell if we are fullscreen or not. */
 
194
      bool m_fullscreen;
 
195
 
 
196
      /** \brief The current level. */
 
197
      level* m_current_level;
 
198
 
 
199
      /** \brief A level in abeyance. */
 
200
      level* m_level_in_abeyance;
 
201
 
 
202
      /** \brief The name of the next level to load, if any. */
 
203
      std::string m_waiting_level;
 
204
 
 
205
      /** \brief Actions to do once an iteration is done. */
 
206
      std::queue<game_action*> m_post_actions;
 
207
 
 
208
      /** \brief Number of milliseconds between two iterations. */
 
209
      systime::milliseconds_type m_time_step;
 
210
 
 
211
      /** \brief The date of the last call to progress. */
 
212
      systime::milliseconds_type m_last_progress;
 
213
 
 
214
      /** \brief The prefix of the name of the game specific initialization
 
215
          procedure. */
 
216
      static const std::string s_init_game_function_prefix;
 
217
 
 
218
      /** \brief The prefix of the name of the game specific ending
 
219
          procedure. */
 
220
      static const std::string s_end_game_function_prefix;
 
221
 
 
222
    }; // class game
 
223
  } // namespace engine
 
224
} // namespace bear
 
225
 
 
226
#endif // __ENGINE_GAME_HPP__