[Scummvm-cvs-logs] scummvm master -> 26a2a125ed178046dc8f0d09fe1831041c5a7b32

dreammaster dreammaster at scummvm.org
Fri Jun 6 01:29:00 CEST 2014


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:
26a2a125ed MADS: Added setup code for difficulty dialog


Commit: 26a2a125ed178046dc8f0d09fe1831041c5a7b32
    https://github.com/scummvm/scummvm/commit/26a2a125ed178046dc8f0d09fe1831041c5a7b32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-06-05T19:28:17-04:00

Commit Message:
MADS: Added setup code for difficulty dialog

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 83369f5..44935b8 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -28,6 +28,7 @@
 #include "mads/msurface.h"
 #include "mads/staticres.h"
 #include "mads/nebular/dialogs_nebular.h"
+#include "mads/nebular/game_nebular.h"
 
 namespace MADS {
 
@@ -461,6 +462,7 @@ void PictureDialog::restore() {
 /*------------------------------------------------------------------------*/
 
 ScreenDialog::DialogLine::DialogLine() {
+	_active = true;
 	_state = 0;
 	_textDisplayIndex = -1;
 	_font = nullptr;
@@ -559,6 +561,27 @@ void ScreenDialog::clearLines() {
 	scene._spriteSlots.fullRefresh(true);
 }
 
+void ScreenDialog::setClickableLines() {
+	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
+
+	for (uint idx = 0; idx < _lines.size(); ++idx) {
+		if (_lines[idx]._active) {
+			const Common::Point &pt = _lines[idx]._pos;
+			int strWidth = _lines[idx]._font->getWidth(_lines[idx]._msg);
+			int maxHeight = _lines[idx]._font->getHeight();
+
+			screenObjects.add(Common::Rect(pt.x, pt.y, pt.x + strWidth, pt.y + maxHeight - 1),
+				LAYER_GUI, CAT_COMMAND, idx);
+		}
+	}
+
+	if (_vm->_dialogs->_pendingDialog == DIALOG_SAVE ||
+			_vm->_dialogs->_pendingDialog == DIALOG_RESTORE) {
+		screenObjects.add(Common::Rect(293, 26, 312, 75), LAYER_GUI, CAT_INV_LIST, 50);
+		screenObjects.add(Common::Rect(293, 78, 312, 127), LAYER_GUI, CAT_INV_LIST, 51);
+	}
+}
+
 void ScreenDialog::addQuote(int id1, int id2, DialogTextAlign align,
 		const Common::Point &pt, Font *font) {
 	Common::String msg = _vm->_game->getQuote(id1);
@@ -576,6 +599,9 @@ void ScreenDialog::addLine(const Common::String &msg, DialogTextAlign align,
 	Scene &scene = _vm->_game->_scene;
 	DialogLine *line;
 
+	if (font == nullptr)
+		font = _vm->_font->getFont(FONT_CONVERSATION);
+
 	if (_lineIndex < (int)_lines.size()) {
 		if (_lines.size() >= 20) {
 			++_lineIndex;
@@ -680,10 +706,64 @@ void ScreenDialog::setFrame(int frameNumber, int depth) {
 
 }
 
+void ScreenDialog::show() {
+	while (_selectedLine < 1) {
+		bool continueFlag = handleEvents();
+		_vm->_events->waitForNextFrame();
+		_vm->_game->_fx = kTransitionNone;
+
+		if (!continueFlag)
+			break;
+	}
+}
+
+bool ScreenDialog::handleEvents() {
+	return true;
+}
+
+/*------------------------------------------------------------------------*/
+
+DifficultyDialog::DifficultyDialog(MADSEngine *vm) : ScreenDialog(vm) {
+	setFrame(8, 2);
+	setLines();
+	setClickableLines();
+}
+
+void DifficultyDialog::setLines() {
+	Font *font = _vm->_font->getFont(FONT_CONVERSATION);
+	int yp = 78 - ((font->getHeight() + 1) * 4 + 6) / 2;
+
+	addQuote(41, 0, ALIGN_CENTER, Common::Point(0, yp), font);
+	yp += 6;
+
+	for (int id = 42; id <= 44; ++id) {
+		yp += font->getHeight();
+		addQuote(id, 0, ALIGN_CENTER, Common::Point(0, yp));
+	}
+}
+
+void DifficultyDialog::show() {
+	ScreenDialog::show();
+	Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game;
+
+	switch (_selectedLine) {
+	case 1:
+		game._difficulty = Nebular::DIFFICULTY_HARD;
+		break;
+	case 2:
+		game._difficulty = Nebular::DIFFICULTY_MEDIUM;
+		break;
+	case 3:
+		game._difficulty = Nebular::DIFFICULTY_EASY;
+		break;
+	default:
+		_vm->quitGame();
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 GameMenuDialog::GameMenuDialog(MADSEngine *vm) : ScreenDialog(vm) {
-	clearLines();
 	setFrame(1, 2);
 }
 
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index f1cf0f2..4eec735 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -103,6 +103,7 @@ enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3
 
 class ScreenDialog {
 	struct DialogLine {
+		bool _active;
 		int _state;
 		Common::Point _pos;
 		int _textDisplayIndex;
@@ -131,14 +132,19 @@ protected:
 	void clearLines();
 
 	/**
+	 * Setup lines to be clickable
+	 */
+	void setClickableLines();
+
+	/**
 	 * Add a quote to the lines list
 	 */
-	void addQuote(int id1, int id2, DialogTextAlign align, const Common::Point &pt, Font *font);
+	void addQuote(int id1, int id2, DialogTextAlign align, const Common::Point &pt, Font *font = nullptr);
 
 	/**
 	 * Adds a line to the lines list
 	 */
-	void addLine(const Common::String &msg, DialogTextAlign align, const Common::Point &pt, Font *font);
+	void addLine(const Common::String &msg, DialogTextAlign align, const Common::Point &pt, Font *font = nullptr);
 
 	/**
 	 * Initializes variables
@@ -154,11 +160,36 @@ protected:
 	 * Choose the background to display for the dialog
 	 */
 	void chooseBackground();
+
+	/**
+	 * Handle events whilst the dialog is active
+	 */
+	bool handleEvents();
 public:
 	/**
 	 * Constructor
 	 */
 	ScreenDialog(MADSEngine *vm);
+
+	/**
+	 * Show the dialog
+	 */
+	virtual void show();
+};
+
+class DifficultyDialog : public ScreenDialog {
+private:
+	/**
+	 * Set the lines for the dialog 
+	 */
+	void setLines();
+public:
+	DifficultyDialog(MADSEngine *vm);
+
+	/**
+	* Show the dialog
+	*/
+	virtual void show();
 };
 
 class GameMenuDialog : public ScreenDialog {






More information about the Scummvm-git-logs mailing list