[Scummvm-cvs-logs] scummvm master -> aaa88e7f8aad55fc84f94ca9643df9d9a6e76813

dreammaster dreammaster at scummvm.org
Sun Dec 15 16:23:20 CET 2013


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
aaa88e7f8a TSAGE: Implemented R2R card game options dialog


Commit: aaa88e7f8aad55fc84f94ca9643df9d9a6e76813
    https://github.com/scummvm/scummvm/commit/aaa88e7f8aad55fc84f94ca9643df9d9a6e76813
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2013-12-15T07:22:40-08:00

Commit Message:
TSAGE: Implemented R2R card game options dialog

Changed paths:
    engines/tsage/ringworld2/ringworld2_scenes1.cpp
    engines/tsage/ringworld2/ringworld2_scenes1.h
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h



diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index f5a4cde..cb2938c 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -4490,6 +4490,7 @@ void Scene1337::remove() {
 	}
 
 	R2_GLOBALS._uiElements._active = true;
+	R2_GLOBALS._uiElements._visible = true;
 	SceneExt::remove();
 }
 
@@ -5418,9 +5419,10 @@ void Scene1337::dealCards() {
 	// Deal cards
 	_item1.setAction(&_action3);
 }
-void Scene1337::subCD193() {
+
+void Scene1337::showOptionsDialog() {
 	// Display menu with "Auto Play", "New Game", "Quit" and "Continue"
-	warning("STUBBED: subCD193()");
+	OptionsDialog::show();
 }
 
 void Scene1337::handleClick(int arg1, Common::Point pt) {
@@ -5674,7 +5676,7 @@ void Scene1337::handleClick(int arg1, Common::Point pt) {
 		return;
 
 	if (_helpIcon._bounds.contains(pt)) {
-		subCD193();
+		showOptionsDialog();
 		return;
 	}
 
@@ -6764,6 +6766,94 @@ void Scene1337::subD1975(int arg1, int arg2) {
 	warning("STUBBED lvl2 Scene1337::subD1975()");
 }
 
+void Scene1337::OptionsDialog::show() {
+	OptionsDialog *dlg = new OptionsDialog();
+	dlg->draw();
+
+	// Show the dialog
+	GfxButton *btn = dlg->execute(NULL);
+
+	// Figure out the new selected character
+	if (btn == &dlg->_quitGame)
+		R2_GLOBALS._sceneManager.changeScene(125);
+	else if (btn == &dlg->_restartGame)
+		R2_GLOBALS._sceneManager.changeScene(1330);
+	
+	// Remove the dialog
+	dlg->remove();
+	delete dlg;
+}
+
+Scene1337::OptionsDialog::OptionsDialog() {
+	// Set the elements text
+	Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+	_autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
+	_restartGame.setText(START_NEW_CARD_GAME);
+	_quitGame.setText(QUIT_CARD_GAME);
+	_continueGame.setText(CONTINUE_CARD_GAME);
+
+	// Set position of the elements
+	_autoplay._bounds.moveTo(5, 2);
+	_restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2);
+	_quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2);
+	_continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2);
+
+	// Add the items to the dialog
+	addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL);
+
+	// Set the dialog size and position
+	frame();
+	_bounds.collapse(-6, -6);
+	setCenter(160, 100);
+}
+
+GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) {
+	_gfxManager.activate();
+
+	// Event loop
+	GfxButton *selectedButton = NULL;
+
+	bool breakFlag = false;
+	while (!g_vm->shouldQuit() && !breakFlag) {
+		Event event;
+		while (g_globals->_events.getEvent(event) && !breakFlag) {
+			// Adjust mouse positions to be relative within the dialog
+			event.mousePos.x -= _gfxManager._bounds.left;
+			event.mousePos.y -= _gfxManager._bounds.top;
+
+			for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
+				if ((*i)->process(event))
+					selectedButton = static_cast<GfxButton *>(*i);
+			}
+
+			if (selectedButton == &_autoplay) {
+				// Toggle Autoplay
+				selectedButton = NULL;
+				Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
+				scene->_autoplay = !scene->_autoplay;
+
+				_autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
+				_autoplay.draw();
+			} else if (selectedButton) {
+				breakFlag = true;
+				break;
+			} else if (!event.handled) {
+				if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
+					selectedButton = NULL;
+					breakFlag = true;
+					break;
+				}
+			}
+		}
+
+		g_system->delayMillis(10);
+		GLOBALS._screenSurface.updateScreen();
+	}
+
+	_gfxManager.deactivate();
+	return selectedButton;
+}
+
 /*--------------------------------------------------------------------------
  * Scene 1500 - Cutscene: Ship landing
  *
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h
index f85a4bb..6820409 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.h
@@ -183,6 +183,20 @@ public:
 };
 
 class Scene1337 : public SceneExt {
+	class OptionsDialog: public GfxDialog {
+	private:
+		GfxButton _autoplay;
+		GfxButton _restartGame;
+		GfxButton _quitGame;
+		GfxButton _continueGame;
+
+		OptionsDialog();
+		virtual ~OptionsDialog() {}
+		virtual GfxButton *OptionsDialog::execute(GfxButton *defaultButton);
+	public:
+		static void show();
+	};
+
 	class Card: public SceneHotspot {
 	public:
 		SceneObject _card;
@@ -364,7 +378,7 @@ public:
 	void suggestInstructions();
 	void shuffleCards();
 	void dealCards();
-	void subCD193();
+	void showOptionsDialog();
 	void handleClick(int arg1, Common::Point pt);
 	void handlePlayer0();
 	void handlePlayer1();
diff --git a/engines/tsage/staticres.cpp b/engines/tsage/staticres.cpp
index 2749f2a..3c850cf 100644
--- a/engines/tsage/staticres.cpp
+++ b/engines/tsage/staticres.cpp
@@ -213,6 +213,14 @@ char const *const ACCESS_CODE_REQUIRED = "access code required";
 char const *const INVALID_ACCESS_CODE = "invalid access code";
 char const *const FOREIGN_OBJECT_EXTRACTED = "foreign object extracted";
 
+// Scene 1330/7 Options dialog messages
+char const *const AUTO_PLAY_ON = "Auto-Play is On";
+char const *const AUTO_PLAY_OFF = "Auto-Play is Off";
+char const *const START_NEW_CARD_GAME = "Start a new game";
+char const *const QUIT_CARD_GAME = "Quit Outpost Alpha";
+char const *const CONTINUE_CARD_GAME = "Continue Outpost Alpha";
+
+//
 char const *const HELP_MSG = "\x1\rRETURN TO\r RINGWORLD\x14";
 char const *const CHAR_TITLE = "\x01Select Character:";
 char const *const CHAR_QUINN_MSG = "  Quinn  ";
diff --git a/engines/tsage/staticres.h b/engines/tsage/staticres.h
index 587463a..c18f31f 100644
--- a/engines/tsage/staticres.h
+++ b/engines/tsage/staticres.h
@@ -165,6 +165,13 @@ extern char const *const ACCESS_CODE_REQUIRED;
 extern char const *const INVALID_ACCESS_CODE;
 extern char const *const FOREIGN_OBJECT_EXTRACTED;
 
+// Scene 1330/7 Options dialog messages
+extern char const *const AUTO_PLAY_ON;
+extern char const *const AUTO_PLAY_OFF;
+extern char const *const START_NEW_CARD_GAME;
+extern char const *const QUIT_CARD_GAME;
+extern char const *const CONTINUE_CARD_GAME;
+
 // Dialog messages
 extern char const *const HELP_MSG;
 extern char const *const CHAR_TITLE;






More information about the Scummvm-git-logs mailing list