diff options
author | Sven Hesse | 2009-06-06 16:47:21 +0000 |
---|---|---|
committer | Sven Hesse | 2009-06-06 16:47:21 +0000 |
commit | 18941738526113c9153e05d455926b357cdfa7d3 (patch) | |
tree | 19bdf097cf2ab04a966d11d5ae00a87eb991f5fe | |
parent | e572811aedc5141189d4c1db9069a9ad564f21dd (diff) | |
download | scummvm-rg350-18941738526113c9153e05d455926b357cdfa7d3.tar.gz scummvm-rg350-18941738526113c9153e05d455926b357cdfa7d3.tar.bz2 scummvm-rg350-18941738526113c9153e05d455926b357cdfa7d3.zip |
Adding a pause mode
svn-id: r41228
-rw-r--r-- | engines/gob/gob.cpp | 44 | ||||
-rw-r--r-- | engines/gob/gob.h | 20 | ||||
-rw-r--r-- | engines/gob/util.cpp | 2 |
3 files changed, 66 insertions, 0 deletions
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 436a1bf1f3..71d89912ba 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -31,6 +31,9 @@ #include "common/md5.h" #include "sound/mididrv.h" +#include "gui/GuiManager.h" +#include "gui/widget.h" + #include "gob/gob.h" #include "gob/global.h" #include "gob/util.h" @@ -67,6 +70,37 @@ const Common::Language GobEngine::_gobToScummVMLang[] = { Common::JA_JPN }; + +PauseDialog::PauseDialog() : GUI::Dialog("PauseDialog") { + _backgroundType = GUI::ThemeEngine::kDialogBackgroundSpecial; + + _message = "Game paused. Press Ctrl+p again to continue."; + _text = new GUI::StaticTextWidget(this, 4, 0, 10, 10, + _message, Graphics::kTextAlignCenter); +} + +void PauseDialog::reflowLayout() { + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + int width = g_gui.getStringWidth(_message) + 16; + int height = g_gui.getFontHeight() + 8; + + _w = width; + _h = height; + _x = (screenW - width) / 2; + _y = (screenH - height) / 2; + + _text->setSize(_w - 8, _h); +} + +void PauseDialog::handleKeyDown(Common::KeyState state) { + // Close on CTRL+p + if ((state.flags == Common::KBD_CTRL) && (state.keycode == Common::KEYCODE_p)) + close(); +} + + GobEngine::GobEngine(OSystem *syst) : Engine(syst) { _sound = 0; _mult = 0; _game = 0; _global = 0; _dataIO = 0; _goblin = 0; @@ -277,6 +311,16 @@ void GobEngine::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); } +void GobEngine::pauseGame() { + pauseEngineIntern(true); + + PauseDialog pauseDialog; + + pauseDialog.runModal(); + + pauseEngineIntern(false); +} + bool GobEngine::initGameParts() { _noMusic = MidiDriver::parseMusicDriver(ConfMan.get("music_driver")) == MD_NULL; diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 65d6ffeced..43e2270354 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -29,8 +29,14 @@ #include "common/system.h" #include "common/savefile.h" +#include "gui/dialog.h" + #include "engines/engine.h" +namespace GUI { + class StaticTextWidget; +} + namespace Gob { class Game; @@ -134,6 +140,18 @@ enum { struct GOBGameDescription; +class PauseDialog : public GUI::Dialog { +public: + PauseDialog(); + + virtual void reflowLayout(); + virtual void handleKeyDown(Common::KeyState state); + +private: + Common::String _message; + GUI::StaticTextWidget *_text; +}; + class GobEngine : public Engine { private: GameType _gameType; @@ -189,6 +207,8 @@ public: void validateLanguage(); void validateVideoMode(int16 videoMode); + void pauseGame(); + Endianness getEndianness() const; Common::Platform getPlatform() const; GameType getGameType() const; diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index 2916caa340..d89368b898 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -120,6 +120,8 @@ void Util::processInput(bool scroll) { _fastMode ^= 1; else if (event.kbd.keycode == Common::KEYCODE_g) _fastMode ^= 2; + else if (event.kbd.keycode == Common::KEYCODE_p) + _vm->pauseGame(); break; } addKeyToBuffer(event.kbd); |