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