[Scummvm-cvs-logs] scummvm master -> 95164a8f249ef5f154d219237af2af4ad78e4bac
somaen
einarjohants at gmail.com
Wed Apr 17 20:18:51 CEST 2013
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
cbae39ab87 WINTERMUTE: Move settings from BaseGame to separate struct.
122279a10a WINTERMUTE: Privatize more members of BaseGame.
fd7c38f6d8 WINTERMUTE: Privatize thumbnail sizes in BaseGame.
769b1084ab WINTERMUTE: Privatize even more members in BaseGame.
95164a8f24 WINTERMUTE: Avoid including BaseGame in BaseRegion.
Commit: cbae39ab8773908fd5945c4f93468148fb5d76ea
https://github.com/scummvm/scummvm/commit/cbae39ab8773908fd5945c4f93468148fb5d76ea
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-04-17T10:42:05-07:00
Commit Message:
WINTERMUTE: Move settings from BaseGame to separate struct.
Changed paths:
A engines/wintermute/base/base_game_settings.cpp
A engines/wintermute/base/base_game_settings.h
engines/wintermute/ad/ad_game.cpp
engines/wintermute/ad/ad_node_state.cpp
engines/wintermute/ad/ad_object.cpp
engines/wintermute/base/base_game.cpp
engines/wintermute/base/base_game.h
engines/wintermute/base/base_object.cpp
engines/wintermute/module.mk
engines/wintermute/ui/ui_button.cpp
engines/wintermute/ui/ui_edit.cpp
engines/wintermute/ui/ui_text.cpp
engines/wintermute/ui/ui_window.cpp
engines/wintermute/wintermute.cpp
diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp
index b9775ba..3730b23 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 34e2205..c741dec 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 a41ed9f..f2cf90a 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 4f9df0e..3d821ca 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 5666fb8..4dfe455 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 0000000..55fbe39
--- /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 0000000..1dfb0b5
--- /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 898c049..75ba4fb 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 5c0406b..f14bf07 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 6ee577f..b638522 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 0a2e6f1..7fddf59 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 3b5adf0..98d70b7 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 39bc1bd..3089c79 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 b17ad99..dc79774 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;
Commit: 122279a10a44aa8d0286780d9549ec13ab523dd1
https://github.com/scummvm/scummvm/commit/122279a10a44aa8d0286780d9549ec13ab523dd1
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-04-17T10:51:57-07:00
Commit Message:
WINTERMUTE: Privatize more members of BaseGame.
Changed paths:
engines/wintermute/base/base_game.h
engines/wintermute/debugger.cpp
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index 4dfe455..5be1457 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -94,10 +94,10 @@ public:
bool _shuttingDown;
virtual bool displayDebugInfo();
- bool _debugShowFPS;
+
+ void setShowFPS(bool enabled) { _debugShowFPS = enabled; }
bool _suspendedRendering;
- int _soundBufferSizeSec;
TTextEncoding _textEncoding;
bool _textRTL;
@@ -152,11 +152,8 @@ public:
BaseGame(const Common::String &gameId);
virtual ~BaseGame();
- void DEBUG_DebugDisable();
- void DEBUG_DebugEnable(const char *filename = nullptr);
bool _debugDebugMode;
- void *_debugLogFile;
int _sequence;
virtual bool loadFile(const char *filename);
virtual bool loadBuffer(byte *buffer, bool complete = true);
@@ -268,13 +265,20 @@ protected:
VideoPlayer *_videoPlayer;
VideoTheoraPlayer *_theoraPlayer;
private:
+ bool _debugShowFPS;
+ void *_debugLogFile;
+ void DEBUG_DebugDisable();
+ void DEBUG_DebugEnable(const char *filename = nullptr);
+
BaseObject *_mainObject;
bool _mouseRightDown;
bool _mouseMidlleDown;
BaseGameSettings *_settings;
-
+
+ int _soundBufferSizeSec;
+
virtual bool invalidateDeviceObjects();
virtual bool restoreDeviceObjects();
diff --git a/engines/wintermute/debugger.cpp b/engines/wintermute/debugger.cpp
index 0dab753..92b8e62 100644
--- a/engines/wintermute/debugger.cpp
+++ b/engines/wintermute/debugger.cpp
@@ -40,9 +40,9 @@ Console::~Console(void) {
bool Console::Cmd_ShowFps(int argc, const char **argv) {
if (argc > 1) {
if (Common::String(argv[1]) == "true") {
- _engineRef->_game->_debugShowFPS = true;
+ _engineRef->_game->setShowFPS(true);
} else if (Common::String(argv[1]) == "false") {
- _engineRef->_game->_debugShowFPS = false;
+ _engineRef->_game->setShowFPS(false);;
}
}
return true;
Commit: fd7c38f6d8da83614e71a8a703f275f3ca251dbf
https://github.com/scummvm/scummvm/commit/fd7c38f6d8da83614e71a8a703f275f3ca251dbf
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-04-17T10:57:39-07:00
Commit Message:
WINTERMUTE: Privatize thumbnail sizes in BaseGame.
Changed paths:
engines/wintermute/base/base_game.h
engines/wintermute/base/base_save_thumb_helper.cpp
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index 5be1457..c1bf32b 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -107,8 +107,8 @@ public:
void DEBUG_DumpClassRegistry();
bool setWaitCursor(const char *filename);
- int _thumbnailWidth;
- int _thumbnailHeight;
+ int getSaveThumbWidth() const { return _thumbnailWidth; }
+ int getSaveThumbHeight() const { return _thumbnailHeight; }
bool _editorMode;
void getOffset(int *offsetX, int *offsetY);
@@ -303,6 +303,9 @@ private:
bool _personalizedSave;
+ int _thumbnailWidth;
+ int _thumbnailHeight;
+
void setWindowTitle();
BaseSprite *_cursorNoninteractive;
diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp
index 76d703a..9b68ed6 100644
--- a/engines/wintermute/base/base_save_thumb_helper.cpp
+++ b/engines/wintermute/base/base_save_thumb_helper.cpp
@@ -50,7 +50,7 @@ BaseSaveThumbHelper::~BaseSaveThumbHelper(void) {
BaseImage *BaseSaveThumbHelper::storeThumb(bool doFlip, int width, int height) {
BaseImage *thumbnail = nullptr;
- if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+ if (_gameRef->getSaveThumbWidth() > 0 && _gameRef->getSaveThumbHeight() > 0) {
if (doFlip) {
// when using opengl on windows it seems to be necessary to do this twice
// works normally for direct3d
@@ -67,7 +67,7 @@ BaseImage *BaseSaveThumbHelper::storeThumb(bool doFlip, int width, int height) {
}
// normal thumbnail
- if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+ if (_gameRef->getSaveThumbWidth() > 0 && _gameRef->getSaveThumbHeight() > 0) {
thumbnail = new BaseImage();
thumbnail->copyFrom(screenshot, width, height);
}
@@ -84,9 +84,9 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) {
delete _thumbnail;
_thumbnail = nullptr;
- if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
+ if (_gameRef->getSaveThumbWidth() > 0 && _gameRef->getSaveThumbHeight() > 0) {
- _thumbnail = storeThumb(doFlip, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
+ _thumbnail = storeThumb(doFlip, _gameRef->getSaveThumbWidth(), _gameRef->getSaveThumbHeight());
if (!_thumbnail) {
return STATUS_FAILED;
}
Commit: 769b1084ab9ec297f8cd6b1cff15fca3c3b3ebc9
https://github.com/scummvm/scummvm/commit/769b1084ab9ec297f8cd6b1cff15fca3c3b3ebc9
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-04-17T11:02:08-07:00
Commit Message:
WINTERMUTE: Privatize even more members in BaseGame.
Changed paths:
engines/wintermute/base/base_game.h
engines/wintermute/base/base_sub_frame.cpp
engines/wintermute/wintermute.cpp
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index c1bf32b..43deccf 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -97,7 +97,7 @@ public:
void setShowFPS(bool enabled) { _debugShowFPS = enabled; }
- bool _suspendedRendering;
+ bool getSuspendedRendering() const { return _suspendedRendering; }
TTextEncoding _textEncoding;
bool _textRTL;
@@ -179,7 +179,8 @@ public:
bool _subtitles; // RO
int _scheduledLoadSlot;
- bool _loading;
+
+ bool getIsLoading() const { return _loading; }
virtual bool handleMouseWheel(int delta);
bool _quitting;
@@ -286,6 +287,7 @@ private:
bool _saveDirChecked;
Common::String _localSaveDir;
+ bool _loading;
bool _reportTextureFormat;
@@ -308,6 +310,8 @@ private:
void setWindowTitle();
+ bool _suspendedRendering;
+
BaseSprite *_cursorNoninteractive;
BaseKeyboardState *_keyboardState;
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index a06d7f5..c8c0773 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -243,7 +243,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
_gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise));
}
}
- if (_gameRef->_suspendedRendering) {
+ if (_gameRef->getSuspendedRendering()) {
return STATUS_OK;
}
diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp
index dc79774..567b255 100644
--- a/engines/wintermute/wintermute.cpp
+++ b/engines/wintermute/wintermute.cpp
@@ -243,10 +243,10 @@ int WintermuteEngine::messageLoop() {
}
// ***** flip
- if (!_game->_suspendedRendering) {
+ if (!_game->getSuspendedRendering()) {
_game->_renderer->flip();
}
- if (_game->_loading) {
+ if (_game->getIsLoading()) {
_game->loadGame(_game->_scheduledLoadSlot);
}
prevTime = time;
Commit: 95164a8f249ef5f154d219237af2af4ad78e4bac
https://github.com/scummvm/scummvm/commit/95164a8f249ef5f154d219237af2af4ad78e4bac
Author: Einar Johan Trøan Sømåen (einarjohants at gmail.com)
Date: 2013-04-17T11:06:53-07:00
Commit Message:
WINTERMUTE: Avoid including BaseGame in BaseRegion.
Changed paths:
engines/wintermute/base/base_region.cpp
diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp
index a3a23f7..8bdb726 100644
--- a/engines/wintermute/base/base_region.cpp
+++ b/engines/wintermute/base/base_region.cpp
@@ -29,7 +29,7 @@
#include "engines/wintermute/base/base_region.h"
#include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_dynamic_buffer.h"
-#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/scriptables/script.h"
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_value.h"
@@ -104,7 +104,7 @@ bool BaseRegion::pointInRegion(int x, int y) {
bool BaseRegion::loadFile(const char *filename) {
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == nullptr) {
- _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename);
+ BaseEngine::LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
}
@@ -113,7 +113,7 @@ bool BaseRegion::loadFile(const char *filename) {
setFilename(filename);
if (DID_FAIL(ret = loadBuffer(buffer, true))) {
- _gameRef->LOG(0, "Error parsing REGION file '%s'", filename);
+ BaseEngine::LOG(0, "Error parsing REGION file '%s'", filename);
}
@@ -154,7 +154,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) {
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) {
- _gameRef->LOG(0, "'REGION' keyword expected.");
+ BaseEngine::LOG(0, "'REGION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
@@ -206,7 +206,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) {
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
- _gameRef->LOG(0, "Syntax error in REGION definition");
+ BaseEngine::LOG(0, "Syntax error in REGION definition");
return STATUS_FAILED;
}
More information about the Scummvm-git-logs
mailing list