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