From 58bb1383d0b11d357128ca2b0a7634f091c0fb5b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Feb 2014 23:17:57 -0500 Subject: MADS: Added skeleton files for the game and dialogs --- engines/mads/events.cpp | 9 ++++++ engines/mads/events.h | 2 +- engines/mads/game.cpp | 18 ++++++++++-- engines/mads/game.h | 14 +++++++-- engines/mads/mads.cpp | 13 +++++---- engines/mads/mads.h | 2 ++ engines/mads/module.mk | 2 ++ engines/mads/nebular/dialogs_nebular.cpp | 37 ++++++++++++++++++++++++ engines/mads/nebular/dialogs_nebular.h | 42 +++++++++++++++++++++++++++ engines/mads/nebular/game_nebular.cpp | 49 ++++++++++++++++++++++++++++++++ engines/mads/nebular/game_nebular.h | 45 +++++++++++++++++++++++++++++ 11 files changed, 222 insertions(+), 11 deletions(-) create mode 100644 engines/mads/nebular/dialogs_nebular.cpp create mode 100644 engines/mads/nebular/dialogs_nebular.h create mode 100644 engines/mads/nebular/game_nebular.cpp create mode 100644 engines/mads/nebular/game_nebular.h (limited to 'engines/mads') diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp index 8d6262aec3..0950ac02d2 100644 --- a/engines/mads/events.cpp +++ b/engines/mads/events.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "common/events.h" +#include "engines/util.h" #include "mads/mads.h" #include "mads/events.h" @@ -31,4 +32,12 @@ EventsManager::EventsManager(MADSEngine *vm) { _vm = vm; } +void EventsManager::handleEvents() { + Common::Event e; + while (!_vm->shouldQuit()) { + g_system->getEventManager()->pollEvent(e); + g_system->delayMillis(10); + } +} + } // End of namespace MADS diff --git a/engines/mads/events.h b/engines/mads/events.h index ea52c7ab9c..33d5c8e31b 100644 --- a/engines/mads/events.h +++ b/engines/mads/events.h @@ -35,7 +35,7 @@ private: public: EventsManager(MADSEngine *vm); - void handleEvents() { /* TODO */ } + void handleEvents(); }; } // End of namespace MADS diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 491117f977..0a04fda6cf 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -23,17 +23,29 @@ #include "common/scummsys.h" #include "mads/mads.h" #include "mads/game.h" +#include "mads/nebular/game_nebular.h" #include "mads/graphics.h" #include "mads/msurface.h" namespace MADS { Game *Game::init(MADSEngine *vm) { - return new Game(vm); + if (vm->getGameID() == GType_RexNebular) + return new Nebular::GameNebular(vm); + + return nullptr; +} + +Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) { +} + +Game::~Game() { + delete _surface; } -Game::Game(MADSEngine *vm): _vm(vm), _surface(MSurface::init( - MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT)) { +void Game::run() { + if (!checkCopyProtection()) + return; } } // End of namespace MADS diff --git a/engines/mads/game.h b/engines/mads/game.h index 190dc883d2..2f0dcf7d48 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -30,15 +30,25 @@ namespace MADS { class MADSEngine; class Game { -private: +protected: MADSEngine *_vm; MSurface *_surface; Game(MADSEngine *vm); + + /** + * Perform any copy protection check + */ + virtual bool checkCopyProtection() = 0; public: static Game *init(MADSEngine *vm); public: - ~Game(); + virtual ~Game(); + + /** + * Run the game + */ + void run(); }; } // End of namespace MADS diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index 36b5ec51f5..05c11409db 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -44,6 +44,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) : _events = nullptr; _font = nullptr; + _game = nullptr; _palette = nullptr; _resources = nullptr; _screen = nullptr; @@ -54,6 +55,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) : MADSEngine::~MADSEngine() { delete _events; delete _font; + delete _game; delete _palette; delete _resources; delete _screen; @@ -77,6 +79,7 @@ void MADSEngine::initialise() { _screen = MSurface::init(true); _sound = new SoundManager(this, _mixer); _userInterface = UserInterface::init(this); + _game = Game::init(this); _screen->empty(); } @@ -85,11 +88,11 @@ Common::Error MADSEngine::run() { initGraphics(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, false); initialise(); - Common::Event e; - while (!shouldQuit()) { - g_system->getEventManager()->pollEvent(e); - g_system->delayMillis(10); - } + // Run the game + _game->run(); + + // Dummy loop to keep application active + _events->handleEvents(); return Common::kNoError; } diff --git a/engines/mads/mads.h b/engines/mads/mads.h index 86a5499e62..a6ae776690 100644 --- a/engines/mads/mads.h +++ b/engines/mads/mads.h @@ -32,6 +32,7 @@ #include "graphics/surface.h" #include "mads/events.h" #include "mads/font.h" +#include "mads/game.h" #include "mads/msurface.h" #include "mads/resources.h" #include "mads/sound.h" @@ -91,6 +92,7 @@ protected: public: EventsManager *_events; Font *_font; + Game *_game; Palette *_palette; ResourcesManager *_resources; MSurface *_screen; diff --git a/engines/mads/module.mk b/engines/mads/module.mk index 401b909ac8..3f78103f6d 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -1,6 +1,8 @@ MODULE := engines/mads MODULE_OBJS := \ + nebular/dialogs_nebular.o \ + nebular/game_nebular.o \ compression.o \ detection.o \ events.o \ diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp new file mode 100644 index 0000000000..5aede49b90 --- /dev/null +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "mads/mads.h" +#include "mads/graphics.h" +#include "mads/msurface.h" +#include "mads/nebular/dialogs_nebular.h" + +namespace MADS { + +namespace Nebular { + + +} // End of namespace Nebular + +} // End of namespace MADS diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h new file mode 100644 index 0000000000..669ac1e775 --- /dev/null +++ b/engines/mads/nebular/dialogs_nebular.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef MADS_GAME_NEBULAR_H +#define MADS_GAME_NEBULAR_H + +#include "common/scummsys.h" +#include "mads/game.h" + +namespace MADS { + +namespace Nebular { + +class CopyProtectionDialog { +public: + static bool show() { return false; } +}; + +} // End of namespace Nebular + +} // End of namespace MADS + +#endif /* MADS_GAME_NEBULAR_H */ diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp new file mode 100644 index 0000000000..43d705fcf8 --- /dev/null +++ b/engines/mads/nebular/game_nebular.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "common/config-manager.h" +#include "mads/mads.h" +#include "mads/game.h" +#include "mads/graphics.h" +#include "mads/msurface.h" +#include "mads/nebular/game_nebular.h" + +namespace MADS { + +namespace Nebular { + +GameNebular::GameNebular(MADSEngine *vm): Game(vm) { + _surface =MSurface::init(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT); +} + +bool GameNebular::checkCopyProtection() { + if (!ConfMan.getBool("copy_protection") || (ConfMan.hasKey("passed_protection") && + ConfMan.getInt("passed_protection") == 1)) + return true; + + return false; +} + +} // End of namespace Nebular + +} // End of namespace MADS diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h new file mode 100644 index 0000000000..b0f088f891 --- /dev/null +++ b/engines/mads/nebular/game_nebular.h @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef MADS_GAME_NEBULAR_H +#define MADS_GAME_NEBULAR_H + +#include "common/scummsys.h" +#include "mads/game.h" + +namespace MADS { + +namespace Nebular { + +class GameNebular: public Game { + friend class Game; +protected: + GameNebular(MADSEngine *vm); + + virtual bool checkCopyProtection(); +}; + +} // End of namespace Nebular + +} // End of namespace MADS + +#endif /* MADS_GAME_NEBULAR_H */ -- cgit v1.2.3