diff options
| -rw-r--r-- | engines/wintermute/ad/ad_game.cpp | 3 | ||||
| -rw-r--r-- | engines/wintermute/ad/ad_node_state.cpp | 3 | ||||
| -rw-r--r-- | engines/wintermute/ad/ad_object.cpp | 5 | ||||
| -rw-r--r-- | engines/wintermute/base/base_game.cpp | 209 | ||||
| -rw-r--r-- | engines/wintermute/base/base_game.h | 29 | ||||
| -rw-r--r-- | engines/wintermute/base/base_game_settings.cpp | 222 | ||||
| -rw-r--r-- | engines/wintermute/base/base_game_settings.h | 71 | ||||
| -rw-r--r-- | engines/wintermute/base/base_object.cpp | 3 | ||||
| -rw-r--r-- | engines/wintermute/module.mk | 1 | ||||
| -rw-r--r-- | engines/wintermute/ui/ui_button.cpp | 2 | ||||
| -rw-r--r-- | engines/wintermute/ui/ui_edit.cpp | 2 | ||||
| -rw-r--r-- | engines/wintermute/ui/ui_text.cpp | 2 | ||||
| -rw-r--r-- | engines/wintermute/ui/ui_window.cpp | 2 | ||||
| -rw-r--r-- | engines/wintermute/wintermute.cpp | 30 | 
14 files changed, 376 insertions, 208 deletions
diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index b9775ba7d1..3730b23fc2 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -43,7 +43,6 @@  #include "engines/wintermute/base/base_object.h"  #include "engines/wintermute/base/base_parser.h"  #include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_string_table.h"  #include "engines/wintermute/base/base_surface_storage.h"  #include "engines/wintermute/base/base_transition_manager.h"  #include "engines/wintermute/base/base_sprite.h" @@ -522,7 +521,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,  			if (res) {  				res->_iD = id;  				res->setText(text); -				_stringTable->expand(&res->_text); +				expandStringByStringTable(&res->_text);  				if (!val1->isNULL()) {  					res->setIcon(val1->getString());  				} diff --git a/engines/wintermute/ad/ad_node_state.cpp b/engines/wintermute/ad/ad_node_state.cpp index 34e220569f..c741dec54f 100644 --- a/engines/wintermute/ad/ad_node_state.cpp +++ b/engines/wintermute/ad/ad_node_state.cpp @@ -29,7 +29,6 @@  #include "engines/wintermute/base/base_game.h"  #include "engines/wintermute/ad/ad_node_state.h"  #include "engines/wintermute/ad/ad_entity.h" -#include "engines/wintermute/base/base_string_table.h"  #include "engines/wintermute/base/base_sprite.h"  #include "engines/wintermute/utils/utils.h"  #include "engines/wintermute/platform_osystem.h" @@ -122,7 +121,7 @@ void AdNodeState::setCaption(const char *caption, int caseVal) {  	_caption[caseVal - 1] = new char[strlen(caption) + 1];  	if (_caption[caseVal - 1]) {  		strcpy(_caption[caseVal - 1], caption); -		_gameRef->_stringTable->expand(&_caption[caseVal - 1]); +		_gameRef->expandStringByStringTable(&_caption[caseVal - 1]);  	}  } diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index a41ed9fbc3..f2cf90a075 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -38,7 +38,6 @@  #include "engines/wintermute/base/base_game.h"  #include "engines/wintermute/base/base_frame.h"  #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_string_table.h"  #include "engines/wintermute/base/base_sub_frame.h"  #include "engines/wintermute/base/base_surface_storage.h"  #include "engines/wintermute/base/font/base_font.h" @@ -901,7 +900,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const  	_sentence->_sound = nullptr;  	_sentence->setText(text); -	_gameRef->_stringTable->expand(&_sentence->_text); +	_gameRef->expandStringByStringTable(&_sentence->_text);  	_sentence->setStances(stances);  	_sentence->_duration = duration;  	_sentence->_align = Align; @@ -913,7 +912,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const  	// try to locate speech file automatically  	bool deleteSound = false;  	if (!sound) { -		char *key = _gameRef->_stringTable->getKey(text); +		char *key = _gameRef->getKeyFromStringTable(text);  		if (key) {  			sound = ((AdGame *)_gameRef)->findSpeechFile(key);  			delete[] key; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 4f9df0e8e9..3d821ca5d2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -30,6 +30,7 @@  #include "engines/wintermute/base/base_engine.h"  #include "engines/wintermute/base/base_game.h"  #include "engines/wintermute/base/base_game_music.h" +#include "engines/wintermute/base/base_game_settings.h"  #include "engines/wintermute/base/base_fader.h"  #include "engines/wintermute/base/base_file_manager.h"  #include "engines/wintermute/base/font/base_font.h" @@ -43,7 +44,6 @@  #include "engines/wintermute/base/base_sub_frame.h"  #include "engines/wintermute/base/base_transition_manager.h"  #include "engines/wintermute/base/base_viewport.h" -#include "engines/wintermute/base/base_string_table.h"  #include "engines/wintermute/base/base_region.h"  #include "engines/wintermute/base/base_save_thumb_helper.h"  #include "engines/wintermute/base/base_surface_storage.h" @@ -143,22 +143,8 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam  	_useD3D = false; -	_stringTable = new BaseStringTable(this); -  	_musicSystem = new BaseGameMusic(this); -	_settingsResWidth = 800; -	_settingsResHeight = 600; -	_settingsRequireAcceleration = false; -	_settingsRequireSound = false; -	_settingsTLMode = 0; -	_settingsAllowWindowed = true; -	_settingsGameFile = nullptr; -	_settingsAllowAdvanced = false; -	_settingsAllowAccessTab = true; -	_settingsAllowAboutTab = true; -	_settingsAllowDesktopRes = false; -  	_editorForceScripts = false;  	_editorAlwaysRegister = false; @@ -171,7 +157,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam  	_scheduledLoadSlot = -1;  	_personalizedSave = false; -	_compressedSavegames = true;  	_editorMode = false;  	//_doNotExpandStrings = false; @@ -192,8 +177,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam  	_thumbnailWidth = _thumbnailHeight = 0; -	_richSavedGames = false; -	_savedGameExt = "dsv";  	_localSaveDir = "saves";  	_saveDirChecked = false; @@ -237,6 +220,8 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam  	#else*/  	_touchInterface = false;  	_constrainedMemory = false; +	 +	_settings = new BaseGameSettings(this);  //#endif  } @@ -253,8 +238,6 @@ BaseGame::~BaseGame() {  	cleanup(); -	delete[] _settingsGameFile; -  	delete _cachedThumbnail;  	delete _mathClass; @@ -269,10 +252,8 @@ BaseGame::~BaseGame() {  	//SAFE_DELETE(_keyboardState);  	delete _renderer; -	delete _stringTable;  	delete _musicSystem; - -	_settingsGameFile = nullptr; +	delete _settings;  	_cachedThumbnail = nullptr; @@ -287,8 +268,8 @@ BaseGame::~BaseGame() {  	_soundMgr = nullptr;  	_renderer = nullptr; -	_stringTable = nullptr;  	_musicSystem = nullptr; +	_settings = nullptr;  	DEBUG_DebugDisable();  	debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); @@ -364,6 +345,42 @@ bool BaseGame::cleanup() {  	return STATUS_OK;  } +////////////////////////////////////////////////////////////////////// +bool BaseGame::initConfManSettings() { +	if (ConfMan.hasKey("debug_mode")) { +		if (ConfMan.getBool("debug_mode")) { +			DEBUG_DebugEnable("./wme.log"); +		} +	} + +	if (ConfMan.hasKey("show_fps")) { +		_debugShowFPS = ConfMan.getBool("show_fps"); +	} else { +		_debugShowFPS = false; +	} + +	if (ConfMan.hasKey("disable_smartcache")) { +		_smartCache = ConfMan.getBool("disable_smartcache"); +	} else { +		_smartCache = true; +	} + +	if (!_smartCache) { +		LOG(0, "Smart cache is DISABLED"); +	} +	return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initRenderer() { +	bool windowedMode = !ConfMan.getBool("fullscreen"); +	return _renderer->initRenderer(_settings->getResWidth(), _settings->getResHeight(), windowedMode); +} + +////////////////////////////////////////////////////////////////////// +bool BaseGame::loadGameSettingsFile() { +	return loadFile(_settings->getGameFile()); +}  //////////////////////////////////////////////////////////////////////  bool BaseGame::initialize1() { @@ -992,7 +1009,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack  			clearOld = val->getBool();  		} -		if (DID_FAIL(_stringTable->loadFile(filename, clearOld))) { +		if (DID_FAIL(_settings->loadStringTable(filename, clearOld))) {  			stack->pushBool(false);  		} else {  			stack->pushBool(true); @@ -1070,7 +1087,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack  		ScValue *val = stack->pop();  		char *str = new char[strlen(val->getString()) + 1];  		strcpy(str, val->getString()); -		_stringTable->expand(&str); +		expandStringByStringTable(&str);  		stack->pushString(str);  		delete[] str;  		return STATUS_OK; @@ -3043,132 +3060,6 @@ bool BaseGame::displayWindows(bool inGame) {  }  ////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadSettings(const char *filename) { -	TOKEN_TABLE_START(commands) -	TOKEN_TABLE(SETTINGS) -	TOKEN_TABLE(GAME) -	TOKEN_TABLE(STRING_TABLE) -	TOKEN_TABLE(RESOLUTION) -	TOKEN_TABLE(REQUIRE_3D_ACCELERATION) -	TOKEN_TABLE(REQUIRE_SOUND) -	TOKEN_TABLE(HWTL_MODE) -	TOKEN_TABLE(ALLOW_WINDOWED_MODE) -	TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) -	TOKEN_TABLE(ALLOW_ABOUT_TAB) -	TOKEN_TABLE(ALLOW_ADVANCED) -	TOKEN_TABLE(ALLOW_DESKTOP_RES) -	TOKEN_TABLE(REGISTRY_PATH) -	TOKEN_TABLE(RICH_SAVED_GAMES) -	TOKEN_TABLE(SAVED_GAME_EXT) -	TOKEN_TABLE(GUID) -	TOKEN_TABLE_END - - -	byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); -	if (origBuffer == nullptr) { -		_gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); -		return STATUS_FAILED; -	} - -	bool ret = STATUS_OK; - -	byte *buffer = origBuffer; -	byte *params; -	int cmd; -	BaseParser parser; - -	if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { -		_gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); -		return STATUS_FAILED; -	} -	buffer = params; -	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { -		switch (cmd) { -		case TOKEN_GAME: -			delete[] _settingsGameFile; -			_settingsGameFile = new char[strlen((char *)params) + 1]; -			if (_settingsGameFile) { -				strcpy(_settingsGameFile, (char *)params); -			} -			break; - -		case TOKEN_STRING_TABLE: -			if (DID_FAIL(_stringTable->loadFile((char *)params))) { -				cmd = PARSERR_GENERIC; -			} -			break; - -		case TOKEN_RESOLUTION: -			parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); -			break; - -		case TOKEN_REQUIRE_3D_ACCELERATION: -			parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); -			break; - -		case TOKEN_REQUIRE_SOUND: -			parser.scanStr((char *)params, "%b", &_settingsRequireSound); -			break; - -		case TOKEN_HWTL_MODE: -			parser.scanStr((char *)params, "%d", &_settingsTLMode); -			break; - -		case TOKEN_ALLOW_WINDOWED_MODE: -			parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); -			break; - -		case TOKEN_ALLOW_DESKTOP_RES: -			parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); -			break; - -		case TOKEN_ALLOW_ADVANCED: -			parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); -			break; - -		case TOKEN_ALLOW_ACCESSIBILITY_TAB: -			parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); -			break; - -		case TOKEN_ALLOW_ABOUT_TAB: -			parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); -			break; - -		case TOKEN_REGISTRY_PATH: -			//BaseEngine::instance().getRegistry()->setBasePath((char *)params); -			break; - -		case TOKEN_RICH_SAVED_GAMES: -			parser.scanStr((char *)params, "%b", &_richSavedGames); -			break; - -		case TOKEN_SAVED_GAME_EXT: -			_savedGameExt = (char *)params; -			break; - -		case TOKEN_GUID: -			break; -		} -	} -	if (cmd == PARSERR_TOKENNOTFOUND) { -		_gameRef->LOG(0, "Syntax error in game settings '%s'", filename); -		ret = STATUS_FAILED; -	} -	if (cmd == PARSERR_GENERIC) { -		_gameRef->LOG(0, "Error loading game settings '%s'", filename); -		ret = STATUS_FAILED; -	} - -	_settingsAllowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. -	_compressedSavegames = true; - -	delete[] origBuffer; - -	return ret; -} - - -//////////////////////////////////////////////////////////////////////////  bool BaseGame::persist(BasePersistenceManager *persistMgr) {  	if (!persistMgr->getIsSaving()) {  		cleanup(); @@ -4014,4 +3905,18 @@ AnsiString BaseGame::getDeviceType() const {  	return "computer";  } +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadSettings(const char *filename) { +	return _settings->loadSettings(filename); +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::expandStringByStringTable(char **str) const { +	_settings->expandStringByStringTable(str); +} + +char *BaseGame::getKeyFromStringTable(const char *str) const { +	return _settings->getKeyFromStringTable(str); +} +  } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 5666fb818c..4dfe45592b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -47,7 +47,6 @@ class BaseTransitionMgr;  class ScEngine;  class BaseFontStorage;  class BaseGameMusic; -class BaseStringTable;  class BaseQuickMsg;  class UIWindow;  class BaseViewport; @@ -59,6 +58,7 @@ class SXMath;  class BaseKeyboardState;  class VideoPlayer;  class VideoTheoraPlayer; +class BaseGameSettings;  class BaseGame: public BaseObject {  public: @@ -128,10 +128,18 @@ public:  	uint32 _currentTime;  	uint32 _deltaTime; +	// Init-functions: +	bool initConfManSettings(); +	bool initRenderer(); +	bool loadGameSettingsFile();  	bool initialize1();  	bool initialize2();  	bool initialize3();  	BaseTransitionMgr *_transMgr; +	 +	// String Table +	void expandStringByStringTable(char **str) const; +	char *getKeyFromStringTable(const char *str) const;  	void LOG(bool res, const char *fmt, ...); @@ -155,10 +163,6 @@ public:  	int _viewportSP; -	BaseStringTable *_stringTable; -	int _settingsResWidth; -	int _settingsResHeight; -	char *_settingsGameFile;  	bool _suppressScriptErrors;  	bool _mouseLeftDown; // TODO: Hide @@ -268,22 +272,16 @@ private:  	bool _mouseRightDown;  	bool _mouseMidlleDown; -	bool _settingsRequireAcceleration; -	bool _settingsAllowWindowed; -	bool _settingsAllowAdvanced; -	bool _settingsAllowAccessTab; -	bool _settingsAllowAboutTab; -	bool _settingsRequireSound; -	bool _settingsAllowDesktopRes; -	int _settingsTLMode; +	 +	BaseGameSettings *_settings; +	  	virtual bool invalidateDeviceObjects();  	virtual bool restoreDeviceObjects();  	// TODO: This can probably be removed completely:  	bool _saveDirChecked; -	bool _richSavedGames; +  	Common::String _localSaveDir; -	Common::String _savedGameExt;  	bool _reportTextureFormat; @@ -298,7 +296,6 @@ private:  	void *_engineLogCallbackData;  	bool _videoSubtitles; -	bool _compressedSavegames;  	bool _personalizedSave; diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp new file mode 100644 index 0000000000..55fbe39fd2 --- /dev/null +++ b/engines/wintermute/base/base_game_settings.cpp @@ -0,0 +1,222 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. +  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. +  + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game_settings.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/wintypes.h" + +namespace Wintermute { + +BaseGameSettings::BaseGameSettings(BaseGame *gameRef) { +	_resWidth = 800; +	_resHeight = 600; +	_requireAcceleration = false; +	_requireSound = false; +	_TLMode = 0; +	_allowWindowed = true; +	_gameFile = nullptr; +	_allowAdvanced = false; +	_allowAccessTab = true; +	_allowAboutTab = true; +	_allowDesktopRes = false; +	 +	_compressedSavegames = true; +	_richSavedGames = false; +	_savedGameExt = "dsv"; + +	_stringTable = new BaseStringTable(gameRef); +} + +BaseGameSettings::~BaseGameSettings() { +	delete[] _gameFile; +	_gameFile = nullptr; +	delete _stringTable; +	_stringTable = nullptr; +} + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF_END + +////////////////////////////////////////////////////////////////////////// +bool BaseGameSettings::loadSettings(const char *filename) { +	TOKEN_TABLE_START(commands) +	TOKEN_TABLE(SETTINGS) +	TOKEN_TABLE(GAME) +	TOKEN_TABLE(STRING_TABLE) +	TOKEN_TABLE(RESOLUTION) +	TOKEN_TABLE(REQUIRE_3D_ACCELERATION) +	TOKEN_TABLE(REQUIRE_SOUND) +	TOKEN_TABLE(HWTL_MODE) +	TOKEN_TABLE(ALLOW_WINDOWED_MODE) +	TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) +	TOKEN_TABLE(ALLOW_ABOUT_TAB) +	TOKEN_TABLE(ALLOW_ADVANCED) +	TOKEN_TABLE(ALLOW_DESKTOP_RES) +	TOKEN_TABLE(REGISTRY_PATH) +	TOKEN_TABLE(RICH_SAVED_GAMES) +	TOKEN_TABLE(SAVED_GAME_EXT) +	TOKEN_TABLE(GUID) +	TOKEN_TABLE_END +	 +	 +	byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); +	if (origBuffer == nullptr) { +		BaseEngine::LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); +		return STATUS_FAILED; +	} +	 +	bool ret = STATUS_OK; +	 +	byte *buffer = origBuffer; +	byte *params; +	int cmd; +	BaseParser parser; +	 +	if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { +		BaseEngine::LOG(0, "'SETTINGS' keyword expected in game settings file."); +		return STATUS_FAILED; +	} +	buffer = params; +	while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { +		switch (cmd) { +			case TOKEN_GAME: +				delete[] _gameFile; +				_gameFile = new char[strlen((char *)params) + 1]; +				if (_gameFile) { +					strcpy(_gameFile, (char *)params); +				} +				break; +				 +			case TOKEN_STRING_TABLE: +				if (DID_FAIL(_stringTable->loadFile((char *)params))) { +					cmd = PARSERR_GENERIC; +				} +				break; +				 +			case TOKEN_RESOLUTION: +				parser.scanStr((char *)params, "%d,%d", &_resWidth, &_resHeight); +				break; +				 +			case TOKEN_REQUIRE_3D_ACCELERATION: +				parser.scanStr((char *)params, "%b", &_requireAcceleration); +				break; +				 +			case TOKEN_REQUIRE_SOUND: +				parser.scanStr((char *)params, "%b", &_requireSound); +				break; +				 +			case TOKEN_HWTL_MODE: +				parser.scanStr((char *)params, "%d", &_TLMode); +				break; +				 +			case TOKEN_ALLOW_WINDOWED_MODE: +				parser.scanStr((char *)params, "%b", &_allowWindowed); +				break; +				 +			case TOKEN_ALLOW_DESKTOP_RES: +				parser.scanStr((char *)params, "%b", &_allowDesktopRes); +				break; +				 +			case TOKEN_ALLOW_ADVANCED: +				parser.scanStr((char *)params, "%b", &_allowAdvanced); +				break; +				 +			case TOKEN_ALLOW_ACCESSIBILITY_TAB: +				parser.scanStr((char *)params, "%b", &_allowAccessTab); +				break; +				 +			case TOKEN_ALLOW_ABOUT_TAB: +				parser.scanStr((char *)params, "%b", &_allowAboutTab); +				break; +				 +			case TOKEN_REGISTRY_PATH: +				//BaseEngine::instance().getRegistry()->setBasePath((char *)params); +				break; +				 +			case TOKEN_RICH_SAVED_GAMES: +				parser.scanStr((char *)params, "%b", &_richSavedGames); +				break; +				 +			case TOKEN_SAVED_GAME_EXT: +				_savedGameExt = (char *)params; +				break; +				 +			case TOKEN_GUID: +				break; +		} +	} +	if (cmd == PARSERR_TOKENNOTFOUND) { +		BaseEngine::LOG(0, "Syntax error in game settings '%s'", filename); +		ret = STATUS_FAILED; +	} +	if (cmd == PARSERR_GENERIC) { +		BaseEngine::LOG(0, "Error loading game settings '%s'", filename); +		ret = STATUS_FAILED; +	} +	 +	_allowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. +	_compressedSavegames = true; +	 +	delete[] origBuffer; +	 +	return ret; +} + +bool BaseGameSettings::loadStringTable(const char *filename, bool clearOld) { +	return _stringTable->loadFile(filename, clearOld); +} + +////////////////////////////////////////////////////////////////////////// +void BaseGameSettings::expandStringByStringTable(char **str) const { +	_stringTable->expand(str); +} + +char *BaseGameSettings::getKeyFromStringTable(const char *str) const { +	return _stringTable->getKey(str); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h new file mode 100644 index 0000000000..1dfb0b50cc --- /dev/null +++ b/engines/wintermute/base/base_game_settings.h @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. +  + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. +  + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_GAME_SETTINGS_H +#define WINTERMUTE_BASE_GAME_SETTINGS_H + +#include "common/str.h" + +namespace Wintermute { +class BaseStringTable; +class BaseGame; +class BaseGameSettings { +public: +	const char *getGameFile() const { return (_gameFile ? _gameFile : "default.game"); } +	int getResWidth() const { return _resWidth; } +	int getResHeight() const { return _resHeight; } + +	BaseGameSettings(BaseGame *gameRef); +	~BaseGameSettings(); +	bool loadSettings(const char *filename); +	bool loadStringTable(const char *filename, bool clearOld); +	void expandStringByStringTable(char **str) const; +	char *getKeyFromStringTable(const char *str) const; +private: +	char *_gameFile; +	int _resWidth; +	int _resHeight; +	BaseStringTable *_stringTable; +// Not ever used: +	int _TLMode; +	bool _compressedSavegames; +	Common::String _savedGameExt; +	bool _requireAcceleration; +	bool _allowWindowed; +	bool _allowAdvanced; +	bool _allowAccessTab; +	bool _allowAboutTab; +	bool _requireSound; +	bool _allowDesktopRes; +// TODO: This can probably be removed completely: +	bool _richSavedGames; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 898c0497a2..75ba4fb50f 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -33,7 +33,6 @@  #include "engines/wintermute/base/sound/base_sound.h"  #include "engines/wintermute/base/sound/base_sound_manager.h"  #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_string_table.h"  #include "engines/wintermute/base/base_sprite.h"  #include "engines/wintermute/platform_osystem.h" @@ -150,7 +149,7 @@ void BaseObject::setCaption(const char *caption, int caseVal) {  	_caption[caseVal - 1] = new char[strlen(caption) + 1];  	if (_caption[caseVal - 1]) {  		strcpy(_caption[caseVal - 1], caption); -		_gameRef->_stringTable->expand(&_caption[caseVal - 1]); +		_gameRef->expandStringByStringTable(&_caption[caseVal - 1]);  	}  } diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 5c0406b353..f14bf078c6 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -68,6 +68,7 @@ MODULE_OBJS := \  	base/base_frame.o \  	base/base_game.o \  	base/base_game_music.o \ +	base/base_game_settings.o \  	base/base_keyboard_state.o \  	base/base_named_object.o \  	base/base_object.o \ diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index 6ee577f009..b638522f6e 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -382,7 +382,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) {  		case TOKEN_TEXT:  			setText((char *)params); -			_gameRef->_stringTable->expand(&_text); +			_gameRef->expandStringByStringTable(&_text);  			break;  		case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 0a2e6f13bc..7fddf59898 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -231,7 +231,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) {  		case TOKEN_TEXT:  			setText((char *)params); -			_gameRef->_stringTable->expand(&_text); +			_gameRef->expandStringByStringTable(&_text);  			break;  		case TOKEN_X: diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 3b5adf07b7..98d70b770e 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -230,7 +230,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) {  		case TOKEN_TEXT:  			setText((char *)params); -			_gameRef->_stringTable->expand(&_text); +			_gameRef->expandStringByStringTable(&_text);  			break;  		case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 39bc1bdcfe..3089c79d31 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -431,7 +431,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) {  		case TOKEN_TITLE:  			setText((char *)params); -			_gameRef->_stringTable->expand(&_text); +			_gameRef->expandStringByStringTable(&_text);  			break;  		case TOKEN_TITLE_ALIGN: diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index b17ad99423..dc797744ad 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -142,29 +142,7 @@ int WintermuteEngine::init() {  	BaseEngine::instance().setGameRef(_game);  	BasePlatform::initialize(this, _game, 0, nullptr); -	bool windowedMode = !ConfMan.getBool("fullscreen"); - -	if (ConfMan.hasKey("debug_mode")) { -		if (ConfMan.getBool("debug_mode")) { -			_game->DEBUG_DebugEnable("./wme.log"); -		} -	} - -	if (ConfMan.hasKey("show_fps")) { -		_game->_debugShowFPS = ConfMan.getBool("show_fps"); -	} else { -		_game->_debugShowFPS = false; -	} - -	if (ConfMan.hasKey("disable_smartcache")) { -		_game->_smartCache = ConfMan.getBool("disable_smartcache"); -	} else { -		_game->_smartCache = true; -	} - -	if (!_game->_smartCache) { -		_game->LOG(0, "Smart cache is DISABLED"); -	} +	_game->initConfManSettings();  	// load general game settings  	_game->initialize1(); @@ -183,10 +161,8 @@ int WintermuteEngine::init() {  	_game->initialize2(); -	bool ret; +	bool ret = _game->initRenderer(); -	// initialize the renderer -	ret = _game->_renderer->initRenderer(_game->_settingsResWidth, _game->_settingsResHeight, windowedMode);  	if (DID_FAIL(ret)) {  		_game->LOG(ret, "Error initializing renderer. Exiting."); @@ -207,7 +183,7 @@ int WintermuteEngine::init() {  	// load game  	uint32 dataInitStart = g_system->getMillis(); -	if (DID_FAIL(_game->loadFile(_game->_settingsGameFile ? _game->_settingsGameFile : "default.game"))) { +	if (DID_FAIL(_game->loadGameSettingsFile())) {  		_game->LOG(ret, "Error loading game file. Exiting.");  		delete _game;  		_game = nullptr;  | 
