[Scummvm-cvs-logs] SF.net SVN: scummvm:[41228] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sat Jun 6 18:47:21 CEST 2009


Revision: 41228
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41228&view=rev
Author:   drmccoy
Date:     2009-06-06 16:47:21 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Adding a pause mode

Modified Paths:
--------------
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/gob.h
    scummvm/trunk/engines/gob/util.cpp

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2009-06-06 16:43:13 UTC (rev 41227)
+++ scummvm/trunk/engines/gob/gob.cpp	2009-06-06 16:47:21 UTC (rev 41228)
@@ -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 @@
 	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 @@
 	_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;
 

Modified: scummvm/trunk/engines/gob/gob.h
===================================================================
--- scummvm/trunk/engines/gob/gob.h	2009-06-06 16:43:13 UTC (rev 41227)
+++ scummvm/trunk/engines/gob/gob.h	2009-06-06 16:47:21 UTC (rev 41228)
@@ -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 @@
 
 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 @@
 	void validateLanguage();
 	void validateVideoMode(int16 videoMode);
 
+	void pauseGame();
+
 	Endianness getEndianness() const;
 	Common::Platform getPlatform() const;
 	GameType getGameType() const;

Modified: scummvm/trunk/engines/gob/util.cpp
===================================================================
--- scummvm/trunk/engines/gob/util.cpp	2009-06-06 16:43:13 UTC (rev 41227)
+++ scummvm/trunk/engines/gob/util.cpp	2009-06-06 16:47:21 UTC (rev 41228)
@@ -120,6 +120,8 @@
 					_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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list