WINTERMUTE: Introduce a Singleton-class for holding registry/filemanager.

This commit is contained in:
Einar Johan Trøan Sømåen 2012-07-29 02:30:26 +02:00
parent b214041539
commit 9b5cf8f1ba
66 changed files with 366 additions and 190 deletions

View File

@ -119,7 +119,7 @@ AdActor::~AdActor() {
//////////////////////////////////////////////////////////////////////////
bool AdActor::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdActor::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -221,7 +221,7 @@ bool AdActor::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ACTOR) {
@ -1410,7 +1410,7 @@ bool AdActor::mergeAnims(const char *animsFilename) {
TOKEN_TABLE_END
byte *fileBuffer = _gameRef->_fileManager->readWholeFile(animsFilename);
byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename);
if (fileBuffer == NULL) {
_gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename);
return STATUS_FAILED;
@ -1419,7 +1419,7 @@ bool AdActor::mergeAnims(const char *animsFilename) {
byte *buffer = fileBuffer;
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
bool ret = STATUS_OK;

View File

@ -84,7 +84,7 @@ AdEntity::~AdEntity() {
//////////////////////////////////////////////////////////////////////////
bool AdEntity::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdEntity::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -198,7 +198,7 @@ bool AdEntity::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ENTITY) {

View File

@ -1241,7 +1241,7 @@ bool AdGame::showCursor() {
//////////////////////////////////////////////////////////////////////////
bool AdGame::loadFile(const char *filename) {
byte *buffer = _fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdGame::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -1294,7 +1294,7 @@ bool AdGame::loadBuffer(byte *buffer, bool complete) {
byte *params;
byte *params2;
int cmd = 1;
BaseParser parser(_gameRef);
BaseParser parser;
bool itemFound = false, itemsFound = false;
@ -1537,7 +1537,7 @@ bool AdGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex
//////////////////////////////////////////////////////////////////////////
bool AdGame::loadItemsFile(const char *filename, bool merge) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdGame::LoadItemsFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -1567,7 +1567,7 @@ bool AdGame::loadItemsBuffer(byte *buffer, bool merge) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (!merge) {
while (_items.getSize() > 0) {
@ -1650,7 +1650,7 @@ bool AdGame::windowLoadHook(UIWindow *win, char **buffer, char **params) {
TOKEN_TABLE_END
int cmd = PARSERR_GENERIC;
BaseParser parser(_gameRef);
BaseParser parser;
cmd = parser.getCommand(buffer, commands, params);
switch (cmd) {
@ -2130,12 +2130,12 @@ char *AdGame::findSpeechFile(char *stringID) {
for (int i = 0; i < _speechDirs.getSize(); i++) {
sprintf(ret, "%s%s.ogg", _speechDirs[i], stringID);
if (_fileManager->hasFile(ret)) {
if (BaseFileManager::getEngineInstance()->hasFile(ret)) {
return ret;
}
sprintf(ret, "%s%s.wav", _speechDirs[i], stringID);
if (_fileManager->hasFile(ret)) {
if (BaseFileManager::getEngineInstance()->hasFile(ret)) {
return ret;
}
}

View File

@ -164,7 +164,7 @@ bool AdInventoryBox::display() {
//////////////////////////////////////////////////////////////////////////
bool AdInventoryBox::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdInventoryBox::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -222,7 +222,7 @@ bool AdInventoryBox::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
bool alwaysVisible = false;
_exclusive = false;

View File

@ -84,7 +84,7 @@ AdItem::~AdItem() {
//////////////////////////////////////////////////////////////////////////
bool AdItem::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdItem::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -166,7 +166,7 @@ bool AdItem::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ITEM) {

View File

@ -62,7 +62,7 @@ AdLayer::~AdLayer() {
//////////////////////////////////////////////////////////////////////////
bool AdLayer::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdLayer::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -121,7 +121,7 @@ bool AdLayer::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_LAYER) {

View File

@ -54,7 +54,7 @@ AdRegion::~AdRegion() {
//////////////////////////////////////////////////////////////////////////
bool AdRegion::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -118,7 +118,7 @@ bool AdRegion::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_REGION) {

View File

@ -204,7 +204,7 @@ bool AdResponseBox::createButtons() {
//////////////////////////////////////////////////////////////////////////
bool AdResponseBox::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdResponseBox::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -259,7 +259,7 @@ bool AdResponseBox::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_RESPONSE_BOX) {

View File

@ -53,7 +53,7 @@ AdRotLevel::~AdRotLevel() {
//////////////////////////////////////////////////////////////////////////
bool AdRotLevel::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdRotLevel::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -93,7 +93,7 @@ bool AdRotLevel::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ROTATION_LEVEL) {

View File

@ -51,7 +51,7 @@ AdScaleLevel::~AdScaleLevel() {
//////////////////////////////////////////////////////////////////////////
bool AdScaleLevel::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdScaleLevel::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -91,7 +91,7 @@ bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SCALE_LEVEL) {

View File

@ -540,7 +540,7 @@ bool AdScene::initLoop() {
//////////////////////////////////////////////////////////////////////////
bool AdScene::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdScene::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -647,7 +647,7 @@ bool AdScene::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SCENE) {

View File

@ -287,7 +287,7 @@ bool AdSentence::setupTalkFile(const char *soundFilename) {
AnsiString talkDefFileName = PathUtil::combine(path, name + ".talk");
if (!_gameRef->_fileManager->hasFile(talkDefFileName)) {
if (!BaseFileManager::getEngineInstance()->hasFile(talkDefFileName)) {
return STATUS_OK; // no talk def file found
}

View File

@ -60,7 +60,7 @@ AdSpriteSet::~AdSpriteSet() {
//////////////////////////////////////////////////////////////////////////
bool AdSpriteSet::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdSpriteSet::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -111,7 +111,7 @@ bool AdSpriteSet::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteC
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SPRITESET) {

View File

@ -71,7 +71,7 @@ AdTalkDef::~AdTalkDef() {
//////////////////////////////////////////////////////////////////////////
bool AdTalkDef::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdTalkDef::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -114,7 +114,7 @@ bool AdTalkDef::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_TALK) {

View File

@ -94,7 +94,7 @@ bool AdTalkNode::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ACTION) {

View File

@ -66,7 +66,7 @@ void AdWaypointGroup::cleanup() {
//////////////////////////////////////////////////////////////////////////
bool AdWaypointGroup::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "AdWaypointGroup::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -112,7 +112,7 @@ bool AdWaypointGroup::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_WAYPOINTS) {

View File

@ -101,7 +101,7 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_EDITOR_PROPERTY) {

View File

@ -26,13 +26,13 @@
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_dynamic_buffer.h"
namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) {
BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) {
_buffer = NULL;
_size = 0;
_realSize = 0;
@ -80,7 +80,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) {
_buffer = (byte *)malloc(initSize);
if (!_buffer) {
_gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize);
BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize);
return STATUS_FAILED;
}
@ -101,7 +101,7 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) {
_realSize += _growBy;
_buffer = (byte *)realloc(_buffer, _realSize);
if (!_buffer) {
_gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize);
return STATUS_FAILED;
}
}
@ -121,7 +121,7 @@ bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) {
}
if (_offset + size > _size) {
_gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow");
BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow");
return STATUS_FAILED;
}

View File

@ -34,7 +34,7 @@
namespace WinterMute {
class BaseDynamicBuffer : public BaseClass {
class BaseDynamicBuffer {
public:
bool _initialized;
void putText(const char *fmt, ...);

View File

@ -0,0 +1,108 @@
/* 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_file_manager.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/wintermute.h"
#include "common/system.h"
namespace WinterMute {
BaseEngine *BaseEngine::_instance = 0;
/*
class BaseEngine {
static BaseEngine *_instance;
BaseEngine();
BaseFileManager *_fileManager;
BaseRegistry *_registry;
public:
~BaseEngine();
BaseEngine *getInstance();
BaseFileManager *getFileMan() { return _fileManager; }
BaseRegistry *getRegistry() { return _registry; }
};*/
BaseEngine::BaseEngine() {
}
void BaseEngine::init() {
_registry = new BaseRegistry();
// File-manager depends on registry.
_fileManager = new BaseFileManager();
}
BaseEngine::~BaseEngine() {
delete _fileManager;
delete _registry;
}
BaseEngine *BaseEngine::getInstance() {
if (!_instance)
assert(0);
return _instance;
}
void BaseEngine::createInstance(const Common::String &gameid) {
if (_instance) {
delete _instance;
_instance = NULL;
}
_instance = new BaseEngine();
_instance->_gameId = gameid;
_instance->init();
}
void BaseEngine::destroyInstance() {
delete _instance;
_instance = NULL;
}
void BaseEngine::LOG(bool res, const char *fmt, ...) {
uint32 secs = g_system->getMillis() / 1000;
uint32 hours = secs / 3600;
secs = secs % 3600;
uint32 mins = secs / 60;
secs = secs % 60;
char buff[512];
va_list va;
va_start(va, fmt);
vsprintf(buff, fmt, va);
va_end(va);
if (_instance && _instance->_gameRef) {
_instance->_gameRef->LOG("%s", buff);
} else {
debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff);
}
}
} // end of namespace WinterMute

View File

@ -0,0 +1,59 @@
/* 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 "common/str.h"
namespace WinterMute {
class BaseFileManager;
class BaseRegistry;
class BaseGame;
class BaseEngine {
static BaseEngine *_instance;
BaseEngine();
void init();
BaseFileManager *_fileManager;
BaseRegistry *_registry;
Common::String _gameId;
BaseGame *_gameRef;
public:
~BaseEngine();
static void createInstance(const Common::String &gameid);
static BaseEngine *getInstance();
static void destroyInstance();
void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; }
BaseGame *getGameRef() { return _gameRef; }
BaseFileManager *getFileManager() { return _fileManager; }
BaseRegistry *getRegistry() { return _registry; }
static void LOG(bool res, const char *fmt, ...);
const char *getGameId() { return _gameId.c_str(); }
};
} // end of namespace WinterMute

View File

@ -27,13 +27,15 @@
*/
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/file/base_disk_file.h"
#include "engines/wintermute/base/file/base_save_thumb_file.h"
#include "engines/wintermute/base/file/base_package.h"
#include "engines/wintermute/base/file/base_resources.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/wintermute.h"
#include "common/debug.h"
#include "common/str.h"
#include "common/tokenizer.h"
#include "common/textconsole.h"
@ -52,7 +54,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) {
BaseFileManager::BaseFileManager() {
initPaths();
registerPackages();
}
@ -145,14 +147,15 @@ bool BaseFileManager::reloadPaths() {
//////////////////////////////////////////////////////////////////////////
bool BaseFileManager::initPaths() {
if (!_gameRef) { // This function only works when the game-registry is loaded
BaseEngine *enginePtr = BaseEngine::getInstance();
if (!enginePtr) { // This function only works when the game-registry is loaded
return STATUS_FAILED;
}
AnsiString pathList;
// single files paths
pathList = _gameRef->_registry->readString("Resource", "CustomPaths", "");
pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", "");
Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";");
// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';');
while (!entries->empty()) {
@ -169,7 +172,7 @@ bool BaseFileManager::initPaths() {
const Common::FSNode gameData(ConfMan.get("path"));
addPath(PATH_PACKAGE, gameData);
pathList = _gameRef->_registry->readString("Resource", "PackagePaths", "");
pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", "");
entries = new Common::StringTokenizer(pathList, ";");
while (!entries->empty()) {
Common::String path = entries->nextToken();
@ -268,7 +271,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f
bool BaseFileManager::hasFile(const Common::String &filename) {
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
BasePersistenceManager pm(_gameRef);
BasePersistenceManager pm(BaseEngine::getInstance()->getGameId());
if (filename.size() <= 9) {
return false;
}
@ -320,10 +323,10 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f
Common::SeekableReadStream *ret = NULL;
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
if (!_gameRef) {
error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str());
if (!BaseEngine::getInstance()) {
error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str());
}
BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef);
BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile();
if (DID_SUCCEED(saveThumbFile->open(filename))) {
ret = saveThumbFile->getMemStream();
}
@ -350,4 +353,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f
return NULL;
}
BaseFileManager *BaseFileManager::getEngineInstance() {
if (BaseEngine::getInstance()) {
return BaseEngine::getInstance()->getFileManager();
}
return NULL;
}
} // end of namespace WinterMute

View File

@ -35,7 +35,6 @@
#include "common/file.h"
namespace WinterMute {
class BaseGame;
class BaseFileManager {
public:
bool cleanup();
@ -45,10 +44,11 @@ public:
Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true);
byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true);
BaseFileManager(BaseGame *inGame = NULL);
BaseFileManager();
virtual ~BaseFileManager();
// Used only for detection
bool registerPackages(const Common::FSList &fslist);
static BaseFileManager *getEngineInstance();
private:
typedef enum {
PATH_PACKAGE,
@ -67,7 +67,6 @@ private:
Common::Array<Common::SeekableReadStream *> _openFiles;
// This class is intentionally not a subclass of Base, as it needs to be used by
// the detector too, without launching the entire engine:
BaseGame *_gameRef;
};
} // end of namespace WinterMute

View File

@ -162,7 +162,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
char *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;

View File

@ -27,6 +27,7 @@
*/
#include "engines/wintermute/dcgf.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_fader.h"
#include "engines/wintermute/base/base_file_manager.h"
@ -94,7 +95,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam
_fontStorage = NULL;
_renderer = NULL;
_soundMgr = NULL;
_fileManager = NULL;
_transMgr = NULL;
_debugMgr = NULL;
_scEngine = NULL;
@ -144,7 +144,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam
_useD3D = false;
_registry = new BaseRegistry(this);
_stringTable = new BaseStringTable(this);
for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) {
@ -280,7 +279,7 @@ BaseGame::~BaseGame() {
getDebugMgr()->onGameShutdown();
_registry->writeBool("System", "LastRun", true);
BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true);
cleanup();
@ -304,8 +303,6 @@ BaseGame::~BaseGame() {
//SAFE_DELETE(_keyboardState);
delete _renderer;
delete _fileManager;
delete _registry;
delete _stringTable;
_localSaveDir = NULL;
@ -327,8 +324,6 @@ BaseGame::~BaseGame() {
_debugMgr = NULL;
_renderer = NULL;
_fileManager = NULL;
_registry = NULL;
_stringTable = NULL;
DEBUG_DebugDisable();
@ -429,11 +424,6 @@ bool BaseGame::initialize1() {
break;
}
_fileManager = new BaseFileManager(this);
if (_fileManager == NULL) {
break;
}
_soundMgr = new BaseSoundMgr(this);
if (_soundMgr == NULL) {
break;
@ -487,7 +477,6 @@ bool BaseGame::initialize1() {
delete _surfaceStorage;
delete _fontStorage;
delete _soundMgr;
delete _fileManager;
delete _scEngine;
delete _videoPlayer;
return STATUS_FAILED;
@ -701,7 +690,7 @@ void BaseGame::getOffset(int *offsetX, int *offsetY) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -809,7 +798,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_GAME) {
@ -1560,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
int val = stack->pop()->getInt();
_registry->writeInt("PrivateSettings", key, val);
BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val);
stack->pushNULL();
return STATUS_OK;
}
@ -1572,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
int initVal = stack->pop()->getInt();
stack->pushInt(_registry->readInt("PrivateSettings", key, initVal));
stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal));
return STATUS_OK;
}
@ -1583,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *val = stack->pop()->getString();
_registry->writeString("PrivateSettings", key, val);
BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val);
stack->pushNULL();
return STATUS_OK;
}
@ -1595,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(2);
const char *key = stack->pop()->getString();
const char *initVal = stack->pop()->getString();
AnsiString val = _registry->readString("PrivateSettings", key, initVal);
AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal);
stack->pushString(val.c_str());
return STATUS_OK;
}
@ -1818,7 +1807,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(1);
const char *filename = stack->pop()->getString();
bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false
bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false
stack->pushBool(exists);
return STATUS_OK;
}
@ -2190,7 +2179,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
const char *filename = stack->pop()->getString();
bool asHex = stack->pop()->getBool(false);
Common::SeekableReadStream *file = _fileManager->openFile(filename, false);
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false);
if (file) {
crc remainder = crc_initialize();
byte buf[1024];
@ -2214,7 +2203,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->pushInt(checksum);
}
_fileManager->closeFile(file);
BaseFileManager::getEngineInstance()->closeFile(file);
file = NULL;
} else {
stack->pushNULL();
@ -2653,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// MostRecentSaveSlot (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MostRecentSaveSlot") == 0) {
_scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1));
_scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1));
return _scValue;
}
@ -3342,7 +3331,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) {
_indicatorDisplay = true;
_indicatorProgress = 0;
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
if (DID_SUCCEED(ret = pm->initSave(desc))) {
if (!quickSave) {
delete _saveLoadImage;
@ -3360,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) {
if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) {
if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) {
if (DID_SUCCEED(ret = pm->saveFile(filename))) {
_registry->writeInt("System", "MostRecentSaveSlot", slot);
BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot);
}
}
}
@ -3412,7 +3401,7 @@ bool BaseGame::loadGame(const char *filename) {
_loadInProgress = true;
_indicatorDisplay = true;
_indicatorProgress = 0;
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
if (DID_SUCCEED(ret = pm->initLoad(filename))) {
//if (DID_SUCCEED(ret = cleanup())) {
if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) {
@ -3628,7 +3617,7 @@ bool BaseGame::loadSettings(const char *filename) {
TOKEN_TABLE_END
byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename);
byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (origBuffer == NULL) {
_gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename);
return STATUS_FAILED;
@ -3639,7 +3628,7 @@ bool BaseGame::loadSettings(const char *filename) {
byte *buffer = origBuffer;
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_SETTINGS) {
_gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file.");
@ -3699,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) {
break;
case TOKEN_REGISTRY_PATH:
_registry->setBasePath((char *)params);
BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params);
break;
case TOKEN_RICH_SAVED_GAMES:
@ -3723,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) {
ret = STATUS_FAILED;
}
_settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed);
_compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames);
_settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed);
_compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames);
//_compressedSavegames = false;
delete[] origBuffer;
@ -4004,7 +3993,7 @@ void BaseGame::setWindowTitle() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::getSaveSlotFilename(int slot, char *buffer) {
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
Common::String filename = pm->getFilenameForSlot(slot);
delete pm;
strcpy(buffer, filename.c_str());
@ -4018,7 +4007,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
if (!pm) {
return STATUS_FAILED;
}
@ -4039,7 +4028,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) {
bool BaseGame::isSaveSlotUsed(int slot) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
bool ret = pm->getSaveExists(slot);
delete pm;
return ret;
@ -4050,7 +4039,7 @@ bool BaseGame::isSaveSlotUsed(int slot) {
bool BaseGame::emptySaveSlot(int slot) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
BasePersistenceManager *pm = new BasePersistenceManager(this);
BasePersistenceManager *pm = new BasePersistenceManager();
g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot));
delete pm;
return STATUS_OK;
@ -4724,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) {
//////////////////////////////////////////////////////////////////////////
void BaseGame::autoSaveOnExit() {
_soundMgr->saveSettings();
_registry->saveValues();
BaseEngine::getInstance()->getRegistry()->saveValues();
if (!_autoSaveOnExit) {
return;

View File

@ -135,7 +135,6 @@ public:
bool initialize1();
bool initialize2();
bool initialize3();
BaseFileManager *_fileManager;
BaseTransitionMgr *_transMgr;
BaseDebugger *getDebugMgr();
@ -205,7 +204,6 @@ public:
bool loadSettings(const char *filename);
bool displayWindows(bool inGame = false);
BaseRegistry *_registry;
bool _useD3D;
virtual bool cleanup();
virtual bool loadGame(int slot);

View File

@ -28,6 +28,7 @@
#include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/platform_osystem.h"
#include "common/str.h"
#include "common/util.h"
@ -42,7 +43,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////
BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) {
BaseParser::BaseParser() {
_whiteSpace = new char [strlen(WHITESPACE) + 1];
strcpy(_whiteSpace, WHITESPACE);
}
@ -122,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) {
if (!*buf) {
return PARSERR_TOKENNOTFOUND;
}
_gameRef->miniUpdate();
BaseEngine::getInstance()->getGameRef()->miniUpdate();
char *name;
return getObject(buf, tokens, &name, params);
}

View File

@ -52,12 +52,11 @@
#define PARSERR_EOF -2
#define PARSERR_TOKENNOTFOUND -1
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/coll_templ.h"
namespace WinterMute {
class BaseParser : public BaseClass {
class BaseParser {
public:
struct TokenDesc {
int32 id;
@ -67,7 +66,7 @@ public:
public:
int scanStr(const char *in, const char *format, ...);
int32 getCommand(char **buf, TokenDesc *tokens, char **params);
BaseParser(BaseGame *inGame = NULL);
BaseParser();
virtual ~BaseParser();
private:
char *getLastOffender();

View File

@ -29,6 +29,7 @@
#include "engines/wintermute/dcgf.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/base_save_thumb_helper.h"
#include "engines/wintermute/platform_osystem.h"
@ -52,14 +53,18 @@ namespace WinterMute {
#define SAVE_MAGIC_2 0x32564153
//////////////////////////////////////////////////////////////////////////
BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) {
BasePersistenceManager::BasePersistenceManager(const char *savePrefix) {
_saving = false;
// _buffer = NULL;
// _bufferSize = 0;
_offset = 0;
_saveStream = NULL;
_loadStream = NULL;
_gameRef = inGame;
if (BaseEngine::getInstance()) {
_gameRef = BaseEngine::getInstance()->getGameRef();
} else {
_gameRef = NULL;
}
_richBuffer = NULL;
_richBufferSize = 0;
@ -263,7 +268,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) {
_saving = false;
_loadStream = g_system->getSavefileManager()->openForLoading(filename);
//_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize);
//_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize);
if (_loadStream) {
uint32 magic;
magic = getDWORD();

View File

@ -87,7 +87,7 @@ public:
bool transfer(const char *name, Common::String *val);
bool transfer(const char *name, Vector2 *val);
bool transfer(const char *name, AnsiStringArray &Val);
BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL);
BasePersistenceManager(const char *savePrefix = NULL);
virtual ~BasePersistenceManager();
bool checkVersion(byte verMajor, byte verMinor, byte verBuild);

View File

@ -102,7 +102,7 @@ bool BaseRegion::pointInRegion(int x, int y) {
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -150,7 +150,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_REGION) {

View File

@ -27,7 +27,7 @@
*/
#include "engines/wintermute/tinyxml/tinyxml.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/utils/path_util.h"
#include "engines/wintermute/utils/string_util.h"
@ -40,7 +40,7 @@
namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) {
BaseRegistry::BaseRegistry() {
_iniName = NULL;
setIniName("./wme.ini");
@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() {
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadValues(bool local) {
Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml";
loadXml(filename, _values);
}
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::saveValues() {
Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml";
saveXml(filename, _values);
}

View File

@ -29,11 +29,14 @@
#ifndef WINTERMUTE_BREGISTRY_H
#define WINTERMUTE_BREGISTRY_H
#include "engines/wintermute/base/base.h"
#include "engines/wintermute/dctypes.h"
#include "common/hashmap.h"
#include "common/hash-str.h"
#include "common/str.h"
namespace WinterMute {
class BaseRegistry : public BaseClass {
class BaseRegistry {
public:
void setIniName(const char *name);
char *getIniName();
@ -43,7 +46,7 @@ public:
int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0);
bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value);
AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = "");
BaseRegistry(BaseGame *inGame);
BaseRegistry();
virtual ~BaseRegistry();
void setBasePath(const char *basePath);

View File

@ -66,7 +66,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) {
// normal thumbnail
if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
_thumbnail = new BaseImage(_gameRef->_fileManager);
_thumbnail = new BaseImage();
_thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight);
}

View File

@ -380,7 +380,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_PROPERTY) {

View File

@ -125,7 +125,7 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa
//////////////////////////////////////////////////////////////////////
bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) {
Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename);
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename);
if (!file) {
_gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str());
if (_gameRef->_debugDebugMode) {
@ -134,7 +134,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC
return loadFile("invalid.bmp", lifeTime, cacheType);
}
} else {
_gameRef->_fileManager->closeFile(file);
BaseFileManager::getEngineInstance()->closeFile(file);
file = NULL;
}
@ -158,7 +158,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC
ret = STATUS_OK;
}
} else {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer) {
if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) {
_gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str());
@ -213,7 +213,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
cleanup();

View File

@ -193,7 +193,7 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
}
uint32 size;
byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;

View File

@ -110,7 +110,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
char *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
Rect32 rect;
int r = 255, g = 255, b = 255;
int ar = 255, ag = 255, ab = 255, alpha = 255;

View File

@ -108,7 +108,7 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool
}
}
if (!_gameRef->_fileManager->hasFile(filename)) {
if (!BaseFileManager::getEngineInstance()->hasFile(filename)) {
if (filename.size()) {
_gameRef->LOG(0, "Missing image: '%s'", filename.c_str());
}

View File

@ -37,7 +37,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) {
BaseFile::BaseFile() {
_pos = 0;
_size = 0;
}

View File

@ -40,7 +40,7 @@ class SeekableReadStream;
namespace WinterMute {
class BaseFile : public BaseClass {
class BaseFile {
protected:
uint32 _pos;
uint32 _size;
@ -56,7 +56,7 @@ public:
virtual bool close() = 0;
virtual bool open(const Common::String &filename) = 0;
virtual bool isEOF();
BaseFile(BaseGame *inGame);
BaseFile();
virtual ~BaseFile();
// Temporary solution to allow usage in ScummVM-code:
virtual Common::SeekableReadStream *getMemStream();

View File

@ -26,7 +26,7 @@
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/base/file/base_save_thumb_file.h"
#include "engines/wintermute/platform_osystem.h"
@ -38,7 +38,7 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) {
BaseSaveThumbFile::BaseSaveThumbFile() {
_data = NULL;
}
@ -70,7 +70,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) {
int slot = atoi(tempFilename);
delete[] tempFilename;
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
BasePersistenceManager *pm = new BasePersistenceManager();
Common::String slotFilename = pm->getFilenameForSlot(slot);
if (!pm) {
return STATUS_FAILED;

View File

@ -37,7 +37,7 @@ namespace WinterMute {
//TODO: Get rid of this
class BaseSaveThumbFile : public BaseFile {
public:
BaseSaveThumbFile(BaseGame *Game);
BaseSaveThumbFile();
virtual ~BaseSaveThumbFile();
virtual bool seek(uint32 pos, int whence = SEEK_SET);
virtual bool read(void *buffer, uint32 size);

View File

@ -31,7 +31,6 @@
#include "engines/wintermute/base/font/base_font_truetype.h"
#include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_file_manager.h"
#include "engines/wintermute/base/base_game.h"
namespace WinterMute {
@ -72,7 +71,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) {
//////////////////////////////////////////////////////////////////////
bool BaseFont::loadFile(const char * Filename)
{
BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename);
BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (Buffer==NULL){
_gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -103,7 +102,7 @@ bool BaseFont::loadBuffer(byte * Buffer)
char* params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (parser.GetCommand ((char**)&Buffer, commands, (char**)&params)!=TOKEN_FONT){
_gameRef->LOG(0, "'FONT' keyword expected.");
@ -186,7 +185,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) {
TOKEN_TABLE_END
byte *buffer = gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
return false;
}
@ -194,7 +193,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) {
byte *workBuffer = buffer;
char *params;
BaseParser parser(gameRef);
BaseParser parser;
bool ret = false;
if (parser.getCommand((char **)&workBuffer, commands, (char **)&params) == TOKEN_TTFONT) {

View File

@ -271,7 +271,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) {
//////////////////////////////////////////////////////////////////////
bool BaseFontBitmap::loadFile(const Common::String &filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
@ -332,7 +332,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) {
char *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_FONT) {
_gameRef->LOG(0, "'FONT' keyword expected.");

View File

@ -293,7 +293,7 @@ int BaseFontTT::getLetterHeight() {
//////////////////////////////////////////////////////////////////////
bool BaseFontTT::loadFile(const Common::String &filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str());
return STATUS_FAILED;
@ -348,7 +348,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) {
char *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_TTFONT) {
_gameRef->LOG(0, "'TTFONT' keyword expected.");
@ -451,7 +451,7 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) {
char *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
switch (cmd) {
@ -538,13 +538,13 @@ bool BaseFontTT::initFont() {
return STATUS_FAILED;
}
Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile);
Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile);
if (!file) {
//TODO: Try to fallback from Arial to FreeSans
/*
// the requested font file is not in wme file space; try loading a system font
AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile));
file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false);
file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false);
if (!file) {
_gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile);
//return STATUS_FAILED;

View File

@ -42,8 +42,8 @@
namespace WinterMute {
//////////////////////////////////////////////////////////////////////
BaseImage::BaseImage(BaseFileManager *fileManager) {
_fileManager = fileManager;
BaseImage::BaseImage() {
_fileManager = BaseFileManager::getEngineInstance();
_palette = NULL;
_surface = NULL;
_decoder = NULL;

View File

@ -42,7 +42,7 @@ class BaseFileManager;
class BaseImage {
public:
BaseImage(BaseFileManager *fileManager);
BaseImage();
~BaseImage();
bool loadFile(const Common::String &filename);

View File

@ -28,6 +28,7 @@
#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h"
#include "engines/wintermute/base/base_surface_storage.h"
#include "engines/wintermute/base/gfx/base_image.h"
@ -126,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
//TODO: Tiny resolution-displays might want to do some resolution-selection logic here
_realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width);
_realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height);
_realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width);
_realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height);
float origAspect = (float)_width / (float)_height;
float realAspect = (float)_realWidth / (float)_realHeight;
@ -152,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
_ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width;
_ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height;
//_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO
//_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO
Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
g_system->beginGFXTransaction();
@ -496,7 +497,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) {
BaseImage *BaseRenderOSystem::takeScreenshot() {
// TODO: Clip by viewport.
warning("BaseRenderOSystem::TakeScreenshot() - not ported yet");
BaseImage *screenshot = new BaseImage(_gameRef->_fileManager);
BaseImage *screenshot = new BaseImage();
screenshot->copyFrom(_renderSurface);
return screenshot;
}

View File

@ -119,7 +119,7 @@ bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK,
}
bool BaseSurfaceOSystem::finishLoad() {
BaseImage *image = new BaseImage(_gameRef->_fileManager);
BaseImage *image = new BaseImage();
if (!image->loadFile(_filename)) {
return false;
}

View File

@ -128,12 +128,12 @@ bool PartEmitter::addSprite(const char *filename) {
}
// check if file exists
Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename);
Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename);
if (!File) {
_gameRef->LOG(0, "Sprite '%s' not found", filename);
return STATUS_FAILED;
} else {
_gameRef->_fileManager->closeFile(File);
BaseFileManager::getEngineInstance()->closeFile(File);
}
char *str = new char[strlen(filename) + 1];

View File

@ -29,7 +29,6 @@
#include "engines/wintermute/base/particles/part_particle.h"
#include "engines/wintermute/base/particles/part_emitter.h"
#include "engines/wintermute/base/base_sprite.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/utils/utils.h"
#include "engines/wintermute/platform_osystem.h"
#include "common/str.h"
@ -80,7 +79,7 @@ bool PartParticle::setSprite(const Common::String &filename) {
_sprite = NULL;
SystemClassRegistry::getInstance()->_disabled = true;
_sprite = new BaseSprite(_gameRef, _gameRef);
_sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef);
if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) {
SystemClassRegistry::getInstance()->_disabled = false;
return STATUS_OK;

View File

@ -33,6 +33,7 @@
#include "engines/wintermute/base/scriptables/script_stack.h"
#include "engines/wintermute/base/scriptables/script_ext_math.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/sound/base_sound.h"
#include "engines/wintermute/base/base_file_manager.h"
@ -128,7 +129,7 @@ bool ScEngine::cleanup() {
//////////////////////////////////////////////////////////////////////////
byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) {
BaseGame *gameRef = (BaseGame *)data;
return gameRef->_fileManager->readWholeFile(filename, size);
return BaseFileManager::getEngineInstance()->readWholeFile(filename, size);
}
@ -200,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig
uint32 size;
byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size);
if (!buffer) {
_gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename);
return NULL;
@ -689,10 +690,10 @@ bool ScEngine::saveBreakpoints() {
sprintf(key, "Breakpoint%d", count);
sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]);
_gameRef->_registry->writeString("Debug", key, text);
BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text);
}
}
_gameRef->_registry->writeInt("Debug", "NumBreakpoints", count);
BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count);
return STATUS_OK;
}
@ -705,11 +706,11 @@ bool ScEngine::loadBreakpoints() {
char key[100];
int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0);
int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0);
for (int i = 1; i <= count; i++) {
/* uint32 bufSize = 512; */
sprintf(key, "Breakpoint%d", i);
AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, "");
AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, "");
char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':');
char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':');

View File

@ -82,7 +82,7 @@ void SXFile::cleanup() {
//////////////////////////////////////////////////////////////////////////
void SXFile::close() {
if (_readFile) {
_gameRef->_fileManager->closeFile(_readFile);
BaseFileManager::getEngineInstance()->closeFile(_readFile);
_readFile = NULL;
}
if (_writeFile) {
@ -130,7 +130,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
_mode = 1;
}
if (_mode == 1) {
_readFile = _gameRef->_fileManager->openFile(_filename);
_readFile = BaseFileManager::getEngineInstance()->openFile(_filename);
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
close();
@ -785,7 +785,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) {
if (_mode != 0) {
// open for reading
if (_mode == 1) {
_readFile = _gameRef->_fileManager->openFile(_filename);
_readFile = BaseFileManager::getEngineInstance()->openFile(_filename);
if (!_readFile) {
close();
}

View File

@ -96,7 +96,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel
debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload);
// Load a file, but avoid having the File-manager handle the disposal of it.
_file = _gameRef->_fileManager->openFile(filename, true, false);
_file = BaseFileManager::getEngineInstance()->openFile(filename, true, false);
if (!_file) {
_gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str());
return STATUS_FAILED;

View File

@ -28,6 +28,7 @@
#include "engines/wintermute/base/sound/base_sound_manager.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/utils/path_util.h"
#include "engines/wintermute/utils/string_util.h"
#include "engines/wintermute/base/base_game.h"
@ -71,7 +72,7 @@ bool BaseSoundMgr::cleanup() {
//////////////////////////////////////////////////////////////////////////
void BaseSoundMgr::saveSettings() {
if (_soundAvailable) {
_gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster);
BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster);
}
}
@ -82,7 +83,7 @@ bool BaseSoundMgr::initialize() {
if (!g_system->getMixer()->isReady()) {
return STATUS_FAILED;
}
_volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255);
_volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255);
_soundAvailable = true;
return STATUS_OK;
@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
AnsiString name = PathUtil::getFileNameWithoutExtension(filename);
AnsiString newFile = PathUtil::combine(path, name + "ogg");
if (_gameRef->_fileManager->hasFile(newFile)) {
if (BaseFileManager::getEngineInstance()->hasFile(newFile)) {
useFilename = newFile;
}
}

View File

@ -169,7 +169,7 @@ public:
SaveStateList listSaves(const char *target) const {
SaveStateList saves;
WinterMute::BasePersistenceManager pm(NULL, target);
WinterMute::BasePersistenceManager pm(target);
for (int i = 0; i < getMaximumSaveSlot(); i++) {
if (pm.getSaveExists(i)) {
SaveStateDescriptor desc;
@ -185,12 +185,12 @@ public:
}
void removeSaveState(const char *target, int slot) const {
WinterMute::BasePersistenceManager pm(NULL, target);
WinterMute::BasePersistenceManager pm(target);
pm.deleteSaveSlot(slot);
}
virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
WinterMute::BasePersistenceManager pm(NULL, target);
WinterMute::BasePersistenceManager pm(target);
SaveStateDescriptor retVal;
retVal.setDescription("Invalid savegame");
pm.getSaveStateDesc(slot, retVal);

View File

@ -63,10 +63,11 @@ MODULE_OBJS := \
base/base.o \
base/base_debugger.o \
base/base_dynamic_buffer.o \
base/base_engine.o \
base/base_fader.o \
base/base_file_manager.o \
base/base_game.o \
base/base_frame.o \
base/base_game.o \
base/base_keyboard_state.o \
base/base_named_object.o \
base/base_object.o \

View File

@ -102,7 +102,7 @@ UIButton::~UIButton() {
//////////////////////////////////////////////////////////////////////////
bool UIButton::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UIButton::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -203,7 +203,7 @@ bool UIButton::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_BUTTON) {

View File

@ -93,7 +93,7 @@ UIEdit::~UIEdit() {
//////////////////////////////////////////////////////////////////////////
bool UIEdit::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UIEdit::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -166,7 +166,7 @@ bool UIEdit::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_EDIT) {

View File

@ -58,7 +58,7 @@ UIEntity::~UIEntity() {
//////////////////////////////////////////////////////////////////////////
bool UIEntity::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UIEntity::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -108,7 +108,7 @@ bool UIEntity::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_ENTITY_CONTAINER) {

View File

@ -103,7 +103,7 @@ bool UIText::display(int offsetX, int offsetY) {
//////////////////////////////////////////////////////////////////////////
bool UIText::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UIText::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -172,7 +172,7 @@ bool UIText::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)&params) != TOKEN_STATIC) {

View File

@ -121,7 +121,7 @@ bool UITiledImage::display(int x, int y, int width, int height) {
//////////////////////////////////////////////////////////////////////////
bool UITiledImage::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UITiledImage::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -181,7 +181,7 @@ bool UITiledImage::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd;
BaseParser parser(_gameRef);
BaseParser parser;
bool hTiles = false, vTiles = false;
int h1 = 0, h2 = 0, h3 = 0;
int v1 = 0, v2 = 0, v3 = 0;

View File

@ -238,7 +238,7 @@ bool UIWindow::display(int offsetX, int offsetY) {
//////////////////////////////////////////////////////////////////////////
bool UIWindow::loadFile(const char *filename) {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (buffer == NULL) {
_gameRef->LOG(0, "UIWindow::LoadFile failed for file '%s'", filename);
return STATUS_FAILED;
@ -339,7 +339,7 @@ bool UIWindow::loadBuffer(byte *buffer, bool complete) {
byte *params;
int cmd = 2;
BaseParser parser(_gameRef);
BaseParser parser;
int fadeR = 0, fadeG = 0, fadeB = 0, fadeA = 0;
int ar = 0, ag = 0, ab = 0, alpha = 0;

View File

@ -103,7 +103,7 @@ VideoTheoraPlayer::~VideoTheoraPlayer(void) {
//////////////////////////////////////////////////////////////////////////
void VideoTheoraPlayer::cleanup() {
if (_file) {
_gameRef->_fileManager->closeFile(_file);
BaseFileManager::getEngineInstance()->closeFile(_file);
_file = NULL;
}
@ -121,7 +121,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common:
cleanup();
_filename = filename;
_file = _gameRef->_fileManager->openFile(filename, true, false);
_file = BaseFileManager::getEngineInstance()->openFile(filename, true, false);
if (!_file) {
return STATUS_FAILED;
}
@ -378,7 +378,7 @@ bool VideoTheoraPlayer::setAlphaImage(const Common::String &filename) {
warning("VideoTheoraPlayer::SetAlphaImage(%s) - Not implemented", filename.c_str());
delete _alphaImage;
_alphaImage = new BaseImage(_gameRef->_fileManager);
_alphaImage = new BaseImage();
if (!_alphaImage || DID_FAIL(_alphaImage->loadFile(filename))) {
delete _alphaImage;
_alphaImage = NULL;

View File

@ -35,6 +35,7 @@
#include "engines/wintermute/ad/ad_game.h"
#include "engines/wintermute/wintermute.h"
#include "engines/wintermute/platform_osystem.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/sound/base_sound_manager.h"
@ -88,7 +89,7 @@ WinterMuteEngine::~WinterMuteEngine() {
debug("WinterMuteEngine::~WinterMuteEngine");
// Dispose your resources here
delete _classReg;
deinit();
delete _rnd;
delete _game;
g_wintermute = NULL;
@ -157,9 +158,10 @@ Common::Error WinterMuteEngine::run() {
int WinterMuteEngine::init() {
_classReg = new SystemClassRegistry();
_classReg->registerClasses();
BaseEngine::createInstance(_targetName);
_game = new AdGame(_targetName);
if (!_game) return 1;
BaseEngine::getInstance()->setGameRef(_game);
BasePlatform::initialize(_game, 0, NULL);
bool windowedMode = !ConfMan.getBool("fullscreen");
@ -192,11 +194,11 @@ int WinterMuteEngine::init() {
}*/
if (_game->_registry->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log");
if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DebugMode")) _game->DEBUG_DebugEnable("./wme.log");
_game->_debugShowFPS = _game->_registry->readBool("Debug", "ShowFPS");
_game->_debugShowFPS = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "ShowFPS");
if (_game->_registry->readBool("Debug", "DisableSmartCache")) {
if (BaseEngine::getInstance()->getRegistry()->readBool("Debug", "DisableSmartCache")) {
_game->LOG(0, "Smart cache is DISABLED");
_game->_smartCache = false;
}
@ -335,6 +337,7 @@ int WinterMuteEngine::messageLoop() {
void WinterMuteEngine::deinit() {
delete _classReg;
_classReg = NULL;
BaseEngine::destroyInstance();
}
bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String &name, Common::String &caption) {