ScummVM API documentation
game.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
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 as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NUVIE_CORE_GAME_H
23 #define NUVIE_CORE_GAME_H
24 
25 #include "ultima/shared/std/containers.h"
26 #include "ultima/shared/std/string.h"
27 #include "ultima/nuvie/core/nuvie_defs.h"
28 
29 namespace Ultima {
30 namespace Nuvie {
31 
32 class Configuration;
33 class Script;
34 class Screen;
35 class Background;
36 class GamePalette;
37 class FontManager;
38 class Dither;
39 class TileManager;
40 class ObjManager;
41 class ActorManager;
42 class Magic;
43 class Map;
44 class MapWindow;
45 class MsgScroll;
46 class Player;
47 class Party;
48 class Converse;
49 class ConverseGump;
50 class Cursor;
51 class GameClock;
52 class ViewManager;
53 class Portrait;
54 class UseCode;
55 class Events;
56 class GUI;
57 class EffectManager;
58 class SoundManager;
59 class EggManager;
60 class CommandBar;
61 class Weather;
62 class Book;
63 class KeyBinder;
64 
65 typedef enum {
66  PAUSE_UNPAUSED = 0x00,
67  PAUSE_USER = 0x01, /* Don't allow user-input */
68  PAUSE_ANIMS = 0x02, /* TileManager & Palette */
69  PAUSE_WORLD = 0x04, /* game time doesn't pass, freeze actors */
70  PAUSE_ALL = 0xFF
71 } GamePauseState;
72 
73 class Game {
74 private:
75  nuvie_game_t game_type;
76  uint8 game_style; //new, original, orig_plus_cutoff_map, or orig_plus_full_map
77  static Game *game;
78  Configuration *config;
79  Script *script;
80  Screen *screen;
81  Background *background;
82  GamePalette *palette;
83  Dither *dither;
84  FontManager *font_manager;
85  TileManager *tile_manager;
86  ObjManager *obj_manager;
87  ActorManager *actor_manager;
88  Magic *magic;
89  Map *game_map;
90  MapWindow *map_window;
91  MsgScroll *scroll;
92  Player *player;
93  Party *party;
94  Converse *converse;
95  ConverseGump *conv_gump;
96  CommandBar *command_bar;
97  CommandBar *new_command_bar;
98 
99  ViewManager *view_manager;
100  EffectManager *effect_manager;
101  SoundManager *sound_manager;
102  EggManager *egg_manager;
103 
104  GameClock *_clock;
105  Portrait *portrait;
106  UseCode *usecode;
107 
108  Weather *weather;
109 
110  Cursor *cursor;
111 
112  Events *event;
113 
114  GUI *gui;
115 
116  Book *book;
117  KeyBinder *keybinder;
118 
119  GamePauseState pause_flags;
120  uint16 game_width;
121  uint16 game_height;
122  uint16 game_x_offset;
123  uint16 game_y_offset;
124  uint16 pause_user_count;
125  uint16 converse_gump_width;
126  uint16 min_converse_gump_width;
127  uint8 ignore_event_delay; // (stack) if non-zero, Events will not periodically wait for NUVIE_INTERVAL
128  bool is_using_hackmove;
129  bool dragging_enabled;
130  bool cheats_enabled;
131  bool unlimited_casting;
132  bool god_mode_enabled;
133  bool armageddon;
134  bool ethereal;
135  bool using_text_gumps;
136  bool open_containers; //doubleclick
137  ConverseGumpType converse_gump_type;
138  bool roof_mode;
139  bool free_balloon_movement;
140  bool force_solid_converse_bg;
141  bool _playing;
142 
143 public:
144  Game(Configuration *cfg, Events *evt, Screen *scr, GUI *g, nuvie_game_t type, SoundManager *sm);
145  ~Game();
146 
147  bool loadGame(Script *s);
148  void init_cursor();
149  void init_game_style();
150  void play();
151  void update_once(bool process_gui_input);
152 
153  void update_once_display();
154  void update_until_converse_finished();
155 
156  bool isLoaded() const {
157  return script != nullptr;
158  }
159  GamePauseState get_pause_flags() const {
160  return pause_flags;
161  }
162  void set_pause_flags(GamePauseState state);
163  void unpause_all();
164  void unpause_user();
165  void unpause_anims();
166  void unpause_world();
167  void pause_all();
168  void pause_user();
169  void pause_anims();
170  void pause_world();
171 
172  bool paused() const {
173  return pause_flags;
174  }
175  bool all_paused() const {
176  return (pause_flags & PAUSE_ALL);
177  }
178  bool user_paused() const {
179  return (pause_flags & PAUSE_USER);
180  }
181  bool anims_paused() const {
182  return (pause_flags & PAUSE_ANIMS);
183  }
184  bool world_paused() const{
185  return (pause_flags & PAUSE_WORLD);
186  }
187 
188  void quit() {
189  _playing = false;
190  }
191 
192  bool shouldQuit() const;
193 
194  bool set_mouse_pointer(uint8 ptr_num);
195  void dont_wait_for_interval();
196  void wait_for_interval();
197  void time_changed();
198  void stats_changed();
199 
200  void init_new_command_bar();
201  void delete_new_command_bar();
202  nuvie_game_t get_game_type() const {
203  return game_type;
204  }
205  uint8 get_game_style() const {
206  return game_style;
207  }
208  bool is_original_plus() const {
209  return (game_style == NUVIE_STYLE_ORIG_PLUS_CUTOFF_MAP || game_style == NUVIE_STYLE_ORIG_PLUS_FULL_MAP);
210  }
211  bool is_original_plus_cutoff_map() const {
212  return (game_style == NUVIE_STYLE_ORIG_PLUS_CUTOFF_MAP);
213  }
214  bool is_original_plus_full_map() const {
215  return (game_style == NUVIE_STYLE_ORIG_PLUS_FULL_MAP);
216  }
217  bool is_new_style() const {
218  return (game_style == NUVIE_STYLE_NEW);
219  }
220  bool is_orig_style() const {
221  return (game_style == NUVIE_STYLE_ORIG);
222  }
223  bool doubleclick_opens_containers();
224  void set_doubleclick_opens_containers(bool val) {
225  open_containers = val;
226  }
227  void set_using_text_gumps(bool val) {
228  using_text_gumps = val;
229  }
230  bool is_using_text_gumps() const {
231  return (using_text_gumps || is_new_style());
232  }
233  bool is_roof_mode() const {
234  return roof_mode;
235  }
236  void set_roof_mode(bool val) {
237  roof_mode = val;
238  }
239  bool using_hackmove();
240  void set_hackmove(bool hackmove);
241  uint8 is_dragging_enabled() {
242  return dragging_enabled;
243  }
244  void set_dragging_enabled(bool drag) {
245  dragging_enabled = drag;
246  }
247  bool is_god_mode_enabled() const {
248  return (god_mode_enabled && cheats_enabled);
249  }
250  bool toggle_god_mode() {
251  return (god_mode_enabled = !god_mode_enabled);
252  }
253  bool are_cheats_enabled() const {
254  return cheats_enabled;
255  }
256  void set_cheats_enabled(bool cheat) {
257  cheats_enabled = cheat;
258  }
259  bool has_unlimited_casting() const {
260  return (unlimited_casting && cheats_enabled);
261  }
262  void set_unlimited_casting(bool unlimited) {
263  unlimited_casting = unlimited;
264  }
265  bool is_armageddon() const {
266  return armageddon;
267  }
268  void set_armageddon(bool val) {
269  armageddon = val;
270  }
271  bool is_ethereal() const {
272  return ethereal;
273  }
274  void set_ethereal(bool val) {
275  ethereal = val;
276  }
277  ConverseGumpType get_converse_gump_type() const {
278  return converse_gump_type;
279  }
280  void set_converse_gump_type(ConverseGumpType new_type);
281  bool using_new_converse_gump();
282  void set_free_balloon_movement(bool val) {
283  free_balloon_movement = val;
284  }
285  bool has_free_balloon_movement() const {
286  return free_balloon_movement;
287  }
288  bool is_forcing_solid_converse_bg() const {
289  return force_solid_converse_bg;
290  }
291  uint16 get_converse_gump_width() const {
292  return converse_gump_width;
293  }
294  uint16 get_min_converse_gump_width() const {
295  return min_converse_gump_width;
296  }
297  uint16 get_game_width() const {
298  return game_width;
299  }
300  uint16 get_game_height() const {
301  return game_height;
302  }
303  uint16 get_game_x_offset() const {
304  return game_x_offset;
305  }
306  uint16 get_game_y_offset() const {
307  return game_y_offset;
308  }
309  Common::Path get_data_file_path(const Common::Path &datafile);
310 
311  /* Return instances of Game classes */
312  static Game *get_game() {
313  return game;
314  }
315  Configuration *get_config() {
316  return config;
317  }
318  Script *get_script() {
319  return script;
320  }
321  Screen *get_screen() {
322  return screen;
323  }
324  Background *get_background() {
325  return background;
326  }
327  GamePalette *get_palette() {
328  return palette;
329  }
330  Dither *get_dither() {
331  return dither;
332  }
333  FontManager *get_font_manager() {
334  return font_manager;
335  }
336  TileManager *get_tile_manager() {
337  return tile_manager;
338  }
339  ObjManager *get_obj_manager() {
340  return obj_manager;
341  }
342  ActorManager *get_actor_manager() {
343  return actor_manager;
344  }
345  EggManager *get_egg_manager() {
346  return egg_manager;
347  }
348  Magic *get_magic() {
349  return magic;
350  }
351  Map *get_game_map() {
352  return game_map;
353  }
354  MapWindow *get_map_window() {
355  return map_window;
356  }
357  MsgScroll *get_scroll() {
358  return scroll;
359  }
360  Player *get_player() {
361  return player;
362  }
363  Party *get_party() {
364  return party;
365  }
366  Converse *get_converse() {
367  return converse;
368  }
369  ConverseGump *get_converse_gump() {
370  return conv_gump;
371  }
372  ViewManager *get_view_manager() {
373  return view_manager;
374  }
375  GameClock *get_clock() {
376  return _clock;
377  }
378  Portrait *get_portrait() {
379  return portrait;
380  }
381  UseCode *get_usecode() {
382  return usecode;
383  }
384  Events *get_event() {
385  return event;
386  }
387  GUI *get_gui() {
388  return gui;
389  }
390  SoundManager *get_sound_manager() {
391  return sound_manager;
392  }
393 
394  Cursor *get_cursor() {
395  return cursor;
396  }
397  EffectManager *get_effect_manager() {
398  return effect_manager;
399  }
400  CommandBar *get_command_bar() {
401  return command_bar;
402  }
403  CommandBar *get_new_command_bar() {
404  return new_command_bar;
405  }
406  Weather *get_weather() {
407  return weather;
408  }
409 
410  Book *get_book() {
411  return book;
412  }
413  KeyBinder *get_keybinder() {
414  return keybinder;
415  }
416 protected:
417  void init_converse();
418  void init_converse_gump_settings();
419 
420 private:
421  void update_once(bool process_gui_input, bool run_converse);
422 };
423 
424 extern uint getRandom(uint maxVal);
425 
426 } // End of namespace Nuvie
427 } // End of namespace Ultima
428 
429 #endif
Definition: map_window.h:73
Definition: egg_manager.h:45
Definition: portrait.h:40
Definition: msg_scroll.h:93
Definition: background.h:33
Definition: magic.h:79
Definition: configuration.h:61
Definition: keys.h:60
Definition: usecode.h:151
Definition: effect_manager.h:34
Definition: game_clock.h:49
Definition: dither.h:41
Definition: font_manager.h:36
Definition: map.h:147
Definition: path.h:52
Definition: player.h:41
Definition: atari-screen.h:60
Definition: events.h:183
Definition: system.h:46
Definition: tile_manager.h:145
Definition: party.h:92
Definition: actor_manager.h:42
Definition: screen.h:41
Definition: converse_gump.h:41
Definition: detection.h:27
Definition: atari-cursor.h:38
Definition: cursor.h:46
Definition: sound_manager.h:62
Definition: weather.h:47
Definition: script.h:102
Definition: obj_manager.h:75
Definition: game_palette.h:32
Definition: command_bar.h:49
Definition: book.h:31
Definition: view_manager.h:57
Definition: game.h:73
Definition: converse.h:81