[Scummvm-cvs-logs] SF.net SVN: scummvm: [22234] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Apr 29 16:24:01 CEST 2006


Revision: 22234
Author:   fingolfin
Date:     2006-04-29 16:23:32 -0700 (Sat, 29 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22234&view=rev

Log Message:
-----------
Moved queryResString from class ScummDialog to class InfoDialog; some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/dialogs.cpp
    scummvm/trunk/engines/scumm/dialogs.h
Modified: scummvm/trunk/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.cpp	2006-04-29 23:09:40 UTC (rev 22233)
+++ scummvm/trunk/engines/scumm/dialogs.cpp	2006-04-29 23:23:32 UTC (rev 22234)
@@ -212,51 +212,11 @@
 
 #pragma mark -
 
-ScummDialog::ScummDialog(ScummEngine *scumm, String name)
-	: GUI::Dialog(name), _vm(scumm) {
+ScummDialog::ScummDialog(String name)
+	: GUI::Dialog(name) {
 _drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
 }
 
-const Common::String ScummDialog::queryResString(int stringno) {
-	byte buf[256];
-	byte *result;
-
-	if (stringno == 0)
-		return String();
-
-	if (_vm->_game.version == 8)
-		result = (byte *)string_map_table_v8[stringno - 1].string;
-	else if (_vm->_game.version == 7)
-		result = _vm->getStringAddressVar(string_map_table_v7[stringno - 1].num);
-	else if (_vm->_game.version == 6)
-		result = _vm->getStringAddressVar(string_map_table_v6[stringno - 1].num);
-	else if (_vm->_game.version >= 3)
-		result = _vm->getStringAddress(string_map_table_v345[stringno - 1].num);
-	else
-		return string_map_table_v345[stringno - 1].string;
-
-	if (result && *result == '/') {
-		_vm->translateText(result, buf);
-		result = buf;
-	}
-
-	if (!result || *result == '\0') {	// Gracelessly degrade to english :)
-		return string_map_table_v345[stringno - 1].string;
-	}
-
-	// Convert to a proper string (take care of FF codes)
-	byte chr;
-	String tmp;
-	while ((chr = *result++)) {
-		if (chr == 0xFF) {
-			result += 3;
-		} else if (chr != '@') {
-			tmp += chr;
-		}
-	}
-	return tmp;
-}
-
 #pragma mark -
 
 Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode);
@@ -273,7 +233,7 @@
 };
 
 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine)
-	: Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _scumm(engine) {
+	: Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
 
 	_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
 
@@ -292,10 +252,10 @@
 		_gfxWidget = new GUI::GraphicsWidget(this,
 				thumbX, thumbY,
 				kThumbnailWidth + 8,
-				((_scumm->_system->getHeight() % 200 && _scumm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8);
+				((_vm->_system->getHeight() % 200 && _vm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8);
 		_gfxWidget->setFlags(GUI::WIDGET_BORDER);
 	
-		int height = thumbY + ((_scumm->_system->getHeight() % 200 && _scumm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8;
+		int height = thumbY + ((_vm->_system->getHeight() % 200 && _vm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8;
 	
 		_date = new StaticTextWidget(this,
 						thumbX,
@@ -405,9 +365,9 @@
 			_gfxWidget->setFlags(GUI::WIDGET_BORDER);
 		}
 		_gfxWidget->resize(thumbX, thumbY, kThumbnailWidth + 8,
-				((_scumm->_system->getHeight() % 200 && _scumm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8);
+				((_vm->_system->getHeight() % 200 && _vm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8);
 	
-		int height = thumbY + ((_scumm->_system->getHeight() % 200 && _scumm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8;
+		int height = thumbY + ((_vm->_system->getHeight() % 200 && _vm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1) + 8;
 
 		if (!_date)
 			_date = new StaticTextWidget(this, 0, 0, 0, 0, "", kTextAlignCenter);
@@ -462,7 +422,7 @@
 void SaveLoadChooser::updateInfos() {
 	int selItem = _list->getSelected();
 	Graphics::Surface *thumb;
-	thumb = _scumm->loadThumbnailFromSlot(_saveMode ? selItem + 1 : selItem);
+	thumb = _vm->loadThumbnailFromSlot(_saveMode ? selItem + 1 : selItem);
 	_gfxWidget->setGfx(thumb);
 	if (thumb)
 		thumb->free();
@@ -472,7 +432,7 @@
 	InfoStuff infos;
 	memset(&infos, 0, sizeof(InfoStuff));
 	char buffer[32];
-	if (_scumm->loadInfosFromSlot(_saveMode ? selItem + 1 : selItem, &infos)) {
+	if (_vm->loadInfosFromSlot(_saveMode ? selItem + 1 : selItem, &infos)) {
 		snprintf(buffer, 32, "Date: %.2d.%.2d.%.4d",
 			(infos.date >> 24) & 0xFF, (infos.date >> 16) & 0xFF,
 			infos.date & 0xFFFF);
@@ -529,7 +489,7 @@
 }
 
 MainMenuDialog::MainMenuDialog(ScummEngine *scumm)
-	: ScummDialog(scumm, "scummmain") {
+	: ScummDialog("scummmain"), _vm(scumm) {
 
 	new GUI::ButtonWidget(this, "scummmain_resume", "Resume", kPlayCmd, 'P');
 
@@ -548,9 +508,9 @@
 	// Create the sub dialog(s)
 	//
 	_aboutDialog = new GUI::AboutDialog();
-	_optionsDialog = new ConfigDialog(scumm);
+	_optionsDialog = new ConfigDialog();
 #ifndef DISABLE_HELP
-	_helpDialog = new HelpDialog(scumm);
+	_helpDialog = new HelpDialog(scumm->_game);
 #endif
 	_saveDialog = new SaveLoadChooser("Save game:", "Save", true, scumm);
 	_loadDialog = new SaveLoadChooser("Load game:", "Load", false, scumm);
@@ -680,8 +640,8 @@
 // These changes will achieve two things at once: Allow us to get rid of using
 //  "" as value for the domain, and in fact provide a somewhat better user 
 // experience at the same time.
-ConfigDialog::ConfigDialog(ScummEngine *scumm)
-	: GUI::OptionsDialog("", "scummconfig"), _vm(scumm) {
+ConfigDialog::ConfigDialog()
+	: GUI::OptionsDialog("", "scummconfig") {
 
 	//
 	// Sound controllers
@@ -760,8 +720,8 @@
 	kPrevCmd = 'PREV'
 };
 
-HelpDialog::HelpDialog(ScummEngine *scumm)
-	: ScummDialog(scumm, "scummhelp") {
+HelpDialog::HelpDialog(const GameSettings &game)
+	: ScummDialog("scummhelp"), _game(game) {
 	_drawingHints &= ~GUI::THEME_HINT_SPECIAL_COLOR;
 
 	int lineHeight = g_gui.getFontHeight();
@@ -782,7 +742,7 @@
 	}
 
 	_page = 1;
-	_numPages = ScummHelp::numPages(scumm->_game.id);
+	_numPages = ScummHelp::numPages(game.id);
 
 	_prevButton = new GUI::ButtonWidget(this, "scummhelp_prev", "Previous", kPrevCmd, 'P');
 	_nextButton = new GUI::ButtonWidget(this, "scummhelp_next", "Next", kNextCmd, 'N');
@@ -796,7 +756,7 @@
 
 	String titleStr, *keyStr, *dscStr;
 
-	ScummHelp::updateStrings(_vm->_game.id, _vm->_game.version, _vm->_game.platform, _page, titleStr, keyStr, dscStr);
+	ScummHelp::updateStrings(_game.id, _game.version, _game.platform, _page, titleStr, keyStr, dscStr);
 
 	_title->setLabel(titleStr);
 	for (int i = 0; i < HELP_NUM_LINES; i++) {
@@ -843,12 +803,12 @@
 #pragma mark -
 
 InfoDialog::InfoDialog(ScummEngine *scumm, int res)
-: ScummDialog(scumm, "scummDummyDialog") { // dummy x and w
-	setInfoText(queryResString (res));
+: ScummDialog("scummDummyDialog"), _vm(scumm) { // dummy x and w
+	setInfoText(queryResString(res));
 }
 
 InfoDialog::InfoDialog(ScummEngine *scumm, const String& message)
-: ScummDialog(scumm, "scummDummyDialog") { // dummy x and w
+: ScummDialog("scummDummyDialog"), _vm(scumm) { // dummy x and w
 	setInfoText(message);
 }
 
@@ -867,6 +827,46 @@
 	new StaticTextWidget(this, 4, 4, _w - 8, _h, message, kTextAlignCenter);
 }
 
+const Common::String InfoDialog::queryResString(int stringno) {
+	byte buf[256];
+	byte *result;
+
+	if (stringno == 0)
+		return String();
+
+	if (_vm->_game.version == 8)
+		result = (byte *)string_map_table_v8[stringno - 1].string;
+	else if (_vm->_game.version == 7)
+		result = _vm->getStringAddressVar(string_map_table_v7[stringno - 1].num);
+	else if (_vm->_game.version == 6)
+		result = _vm->getStringAddressVar(string_map_table_v6[stringno - 1].num);
+	else if (_vm->_game.version >= 3)
+		result = _vm->getStringAddress(string_map_table_v345[stringno - 1].num);
+	else
+		return string_map_table_v345[stringno - 1].string;
+
+	if (result && *result == '/') {
+		_vm->translateText(result, buf);
+		result = buf;
+	}
+
+	if (!result || *result == '\0') {	// Gracelessly degrade to english :)
+		return string_map_table_v345[stringno - 1].string;
+	}
+
+	// Convert to a proper string (take care of FF codes)
+	byte chr;
+	String tmp;
+	while ((chr = *result++)) {
+		if (chr == 0xFF) {
+			result += 3;
+		} else if (chr != '@') {
+			tmp += chr;
+		}
+	}
+	return tmp;
+}
+
 #pragma mark -
 
 PauseDialog::PauseDialog(ScummEngine *scumm, int res)

Modified: scummvm/trunk/engines/scumm/dialogs.h
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.h	2006-04-29 23:09:40 UTC (rev 22233)
+++ scummvm/trunk/engines/scumm/dialogs.h	2006-04-29 23:23:32 UTC (rev 22234)
@@ -27,6 +27,7 @@
 #include "gui/options.h"
 #include "gui/widget.h"
 
+#include "scumm/plugin.h"
 #ifndef DISABLE_HELP
 #include "scumm/help.h"
 #endif
@@ -43,15 +44,10 @@
 
 class ScummDialog : public GUI::Dialog {
 public:
-	ScummDialog(ScummEngine *scumm, Common::String name);
+	ScummDialog(Common::String name);
 
 protected:
 	typedef Common::String String;
-
-	ScummEngine *_vm;
-
-	// Query a string from the resources
-	const String queryResString(int stringno);
 };
 
 class SaveLoadChooser : public GUI::Dialog {
@@ -65,7 +61,7 @@
 	GUI::StaticTextWidget	*_date;
 	GUI::StaticTextWidget	*_time;
 	GUI::StaticTextWidget	*_playtime;
-	ScummEngine			*_scumm;
+	ScummEngine			*_vm;
 
 	void updateInfos();
 public:
@@ -89,6 +85,8 @@
 	virtual void handleScreenChanged();
 
 protected:
+	ScummEngine		*_vm;
+
 	GUI::Dialog		*_aboutDialog;
 	GUI::Dialog		*_optionsDialog;
 #ifndef DISABLE_HELP
@@ -106,7 +104,7 @@
 
 class HelpDialog : public ScummDialog {
 public:
-	HelpDialog(ScummEngine *scumm);
+	HelpDialog(const GameSettings &game);
 	virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
 
 protected:
@@ -121,6 +119,8 @@
 
 	int _page;
 	int _numPages;
+	
+	const GameSettings _game;
 
 	void displayKeyBindings();
 };
@@ -129,13 +129,12 @@
 
 class ConfigDialog : public GUI::OptionsDialog {
 protected:
-	ScummEngine *_vm;
 #ifdef SMALL_SCREEN_DEVICE
 	GUI::Dialog		*_keysDialog;
 #endif
 
 public:
-	ConfigDialog(ScummEngine *scumm);
+	ConfigDialog();
 	~ConfigDialog();
 
 	virtual void open();
@@ -154,6 +153,9 @@
  * click closed the dialog).
  */
 class InfoDialog : public ScummDialog {
+protected:
+	ScummEngine		*_vm;
+
 public:
 	// arbitrary message
 	InfoDialog(ScummEngine *scumm, const String& message);
@@ -171,6 +173,9 @@
 
 protected:
 	void setInfoText (const String& message);
+
+	// Query a string from the resources
+	const String queryResString(int stringno);
 };
 
 /**


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