aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/ad/ad_game.cpp2
-rw-r--r--engines/wintermute/ad/ad_game.h2
-rw-r--r--engines/wintermute/base/base_game.cpp7
-rw-r--r--engines/wintermute/base/base_game.h2
-rw-r--r--engines/wintermute/base/base_registry.cpp31
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp25
-rw-r--r--engines/wintermute/platform_osystem.cpp42
-rw-r--r--engines/wintermute/platform_osystem.h2
-rw-r--r--engines/wintermute/system/sys_class_registry.cpp4
-rw-r--r--engines/wintermute/utils/path_util.cpp63
-rw-r--r--engines/wintermute/utils/path_util.h5
-rw-r--r--engines/wintermute/wintermute.cpp4
12 files changed, 38 insertions, 151 deletions
diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp
index 66ec582f21..b922123e38 100644
--- a/engines/wintermute/ad/ad_game.cpp
+++ b/engines/wintermute/ad/ad_game.cpp
@@ -66,7 +66,7 @@ namespace WinterMute {
IMPLEMENT_PERSISTENT(AdGame, true)
//////////////////////////////////////////////////////////////////////////
-AdGame::AdGame(): BaseGame() {
+AdGame::AdGame(const Common::String &gameId): BaseGame(gameId) {
_responseBox = NULL;
_inventoryBox = NULL;
diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h
index ef671b0a64..7f76b959d4 100644
--- a/engines/wintermute/ad/ad_game.h
+++ b/engines/wintermute/ad/ad_game.h
@@ -118,7 +118,7 @@ public:
bool addObject(AdObject *object);
AdScene *_scene;
bool initLoop();
- AdGame();
+ AdGame(const Common::String &gameId);
virtual ~AdGame();
BaseArray<AdObject *> _objects;
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index 8fd2b193b1..3e6cb6e043 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -80,7 +80,7 @@ IMPLEMENT_PERSISTENT(BaseGame, true)
//////////////////////////////////////////////////////////////////////
-BaseGame::BaseGame(): BaseObject(this) {
+BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) {
_shuttingDown = false;
_state = GAME_RUNNING;
@@ -259,6 +259,7 @@ BaseGame::BaseGame(): BaseObject(this) {
_autoSaveSlot = 999;
_cursorHidden = false;
+ // Block kept as a reminder that the engine CAN run in constrained/touch-mode
/*#ifdef __IPHONEOS__
_touchInterface = true;
_constrainedMemory = true; // TODO differentiate old and new iOS devices
@@ -331,7 +332,7 @@ BaseGame::~BaseGame() {
_stringTable = NULL;
DEBUG_DebugDisable();
- BasePlatform::outputDebugString("--- shutting down normally ---\n");
+ debugC(kWinterMuteDebugLog, "--- shutting down normally ---\n");
}
@@ -2249,6 +2250,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ShowStatusLine") == 0) {
stack->correctParams(0);
+ // Block kept to show intention of opcode.
/*#ifdef __IPHONEOS__
IOS_ShowStatusLine(TRUE);
#endif*/
@@ -2262,6 +2264,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "HideStatusLine") == 0) {
stack->correctParams(0);
+ // Block kept to show intention of opcode.
/*#ifdef __IPHONEOS__
IOS_ShowStatusLine(FALSE);
#endif*/
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index d4a4c0e682..76881eefd7 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -147,7 +147,7 @@ public:
SXMath *_mathClass;
BaseSurfaceStorage *_surfaceStorage;
BaseFontStorage *_fontStorage;
- BaseGame();
+ BaseGame(const Common::String &gameId);
virtual ~BaseGame();
void DEBUG_DebugDisable();
diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp
index 441d00c05b..02f1da7322 100644
--- a/engines/wintermute/base/base_registry.cpp
+++ b/engines/wintermute/base/base_registry.cpp
@@ -32,6 +32,8 @@
#include "engines/wintermute/utils/path_util.h"
#include "engines/wintermute/utils/string_util.h"
#include "engines/wintermute/utils/utils.h"
+#include "engines/wintermute/wintermute.h"
+#include "common/savefile.h"
#include "common/config-manager.h"
#include "common/file.h"
@@ -173,16 +175,14 @@ char *BaseRegistry::getIniName() {
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadValues(bool local) {
- if (local) {
- loadXml("settings.xml", _localValues);
- } else {
- loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
- }
+ Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
+ loadXml(filename, _values);
}
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::saveValues() {
- saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
+ Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml";
+ saveXml(filename, _values);
}
//////////////////////////////////////////////////////////////////////////
@@ -212,10 +212,15 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) {
- TiXmlDocument doc(fileName.c_str());
- if (!doc.LoadFile()) {
+ Common::SeekableReadStream *stream = g_wintermute->getSaveFileMan()->openForLoading(fileName);
+ if (!stream) {
return;
}
+ char *data = new char[stream->size()];
+ stream->read(data, stream->size());
+ TiXmlDocument doc;
+ doc.Parse(data);
+ delete data;
TiXmlElement *rootElem = doc.RootElement();
if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together)
@@ -260,14 +265,14 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) {
TiXmlPrinter printer;
doc.Accept(&printer);
- Common::DumpFile stream;
- stream.open(fileName.c_str());
+ Common::WriteStream *stream = g_wintermute->getSaveFileMan()->openForSaving(fileName);
- if (!stream.isOpen()) {
+ if (!stream) {
return;
} else {
- stream.write(printer.CStr(), printer.Size());
- stream.close();
+ stream->write(printer.CStr(), printer.Size());
+ stream->finalize();
+ delete stream;
}
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 90dda1af72..58839d5ffe 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -124,33 +124,10 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
_realWidth = width;
_realHeight = height;
+ //TODO: Tiny resolution-displays might want to do some resolution-selection logic here
- // find suitable resolution
- /*#ifdef __IPHONEOS__
- _realWidth = 480;
- _realHeight = 320;
-
- int numModes = SDL_GetNumDisplayModes(0);
- for (int i = 0; i < numModes; i++) {
- SDL_DisplayMode mode;
- SDL_GetDisplayMode(0, i, &mode);
-
- if (mode.w > mode.h) {
- _realWidth = mode.w;
- _realHeight = mode.h;
- break;
- }
- }
- #else*/
_realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width);
_realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height);
-//#endif
-
- /*
- _realWidth = 480;
- _realHeight = 320;
- */
-
float origAspect = (float)_width / (float)_height;
float realAspect = (float)_realWidth / (float)_realHeight;
diff --git a/engines/wintermute/platform_osystem.cpp b/engines/wintermute/platform_osystem.cpp
index 32d53e3a50..b2a0b976d4 100644
--- a/engines/wintermute/platform_osystem.cpp
+++ b/engines/wintermute/platform_osystem.cpp
@@ -81,21 +81,7 @@ void BasePlatform::handleEvent(Common::Event *event) {
case Common::EVENT_WHEELDOWN:
if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y);
break;
- /*#ifdef __IPHONEOS__
- {
- BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
- POINT p;
- GetCursorPos(&p);
- _gameRef->SetActiveObject(renderer->GetObjectAt(p.x, p.y));
-
- if (_gameRef->_activeObject != NULL && strcmp(_gameRef->_activeObject->getClassName(), "UIButton") == 0) {
- UIButton *btn = static_cast<UIButton *>(_gameRef->_activeObject);
- if (btn->_visible && !btn->_disable) btn->_press = true;
- }
- }
- #endif*/
-
-//TODO
+//TODO: Handle MouseWheel
/* case SDL_MOUSEWHEEL:
if (_gameRef) _gameRef->handleMouseWheel(event->wheel.y);
break;
@@ -114,10 +100,8 @@ void BasePlatform::handleEvent(Common::Event *event) {
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
case SDL_WINDOWEVENT_MINIMIZED:
- #ifndef __IPHONEOS__
if (_gameRef) _gameRef->OnActivate(false, false);
SDL_ShowCursor(SDL_ENABLE);
- #endif
break;
case SDL_WINDOWEVENT_CLOSE:
@@ -128,15 +112,15 @@ void BasePlatform::handleEvent(Common::Event *event) {
*/
case Common::EVENT_QUIT:
case Common::EVENT_RTL:
-/*#ifdef __IPHONEOS__
- if (_gameRef) {
- _gameRef->AutoSaveOnExit();
- _gameRef->_quitting = true;
- }
-#else*/
+// Block kept in case we want to support autoSaveOnExit.
+//#ifdef __IPHONEOS__
+// if (_gameRef) {
+// _gameRef->AutoSaveOnExit();
+// _gameRef->_quitting = true;
+// }
+//#else*/
if (_gameRef) _gameRef->onWindowClose();
//#endif
-
break;
default:
// TODO: Do we care about any other events?
@@ -149,16 +133,6 @@ void BasePlatform::handleEvent(Common::Event *event) {
//////////////////////////////////////////////////////////////////////////
// Win32 API bindings
//////////////////////////////////////////////////////////////////////////
-void BasePlatform::outputDebugString(const char *lpOutputString) {
-/*
-#ifdef __WIN32__
- ::OutputDebugString(lpOutputString);
-#endif
-*/
-}
-
-
-//////////////////////////////////////////////////////////////////////////
bool BasePlatform::getCursorPos(Point32 *lpPoint) {
BaseRenderOSystem *renderer = static_cast<BaseRenderOSystem *>(_gameRef->_renderer);
diff --git a/engines/wintermute/platform_osystem.h b/engines/wintermute/platform_osystem.h
index 14b8c959a8..53462724bd 100644
--- a/engines/wintermute/platform_osystem.h
+++ b/engines/wintermute/platform_osystem.h
@@ -45,8 +45,6 @@ public:
static AnsiString getPlatformName();
// Win32 API bindings
- static void outputDebugString(const char *lpOutputString);
- //static uint32 getTime();
static bool getCursorPos(Point32 *lpPoint);
static bool setCursorPos(int x, int y);
static bool showWindow(int nCmdShow);
diff --git a/engines/wintermute/system/sys_class_registry.cpp b/engines/wintermute/system/sys_class_registry.cpp
index 47910af4e8..09e43529e3 100644
--- a/engines/wintermute/system/sys_class_registry.cpp
+++ b/engines/wintermute/system/sys_class_registry.cpp
@@ -82,9 +82,7 @@ bool SystemClassRegistry::unregisterClass(SystemClass *classObj) {
}
if (classObj->getNumInstances() != 0) {
- char str[MAX_PATH_LENGTH];
- sprintf(str, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances());
- BasePlatform::outputDebugString(str);
+ debugC(WinterMute::kWinterMuteDebugSaveGame, "Memory leak@class %-20s: %d instance(s) left\n", classObj->getName().c_str(), classObj->getNumInstances());
}
_classes.erase(it);
diff --git a/engines/wintermute/utils/path_util.cpp b/engines/wintermute/utils/path_util.cpp
index 4e36c3e316..db1b479dab 100644
--- a/engines/wintermute/utils/path_util.cpp
+++ b/engines/wintermute/utils/path_util.cpp
@@ -67,101 +67,38 @@ AnsiString PathUtil::combine(const AnsiString &path1, const AnsiString &path2) {
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::getDirectoryName(const AnsiString &path) {
AnsiString newPath = unifySeparators(path);
-
- //size_t pos = newPath.find_last_of(L'/');
Common::String filename = getFileName(path);
return Common::String(path.c_str(), path.size() - filename.size());
- //if (pos == AnsiString::npos) return "";
- //else return newPath.substr(0, pos + 1);
}
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::getFileName(const AnsiString &path) {
AnsiString newPath = unifySeparators(path);
-
- //size_t pos = newPath.find_last_of(L'/'); TODO REMOVE.
Common::String lastPart = Common::lastPathComponent(newPath, '/');
if (lastPart[lastPart.size() - 1 ] != '/') {
return lastPart;
} else {
return path;
}
- //if (pos == AnsiString::npos) return path;
- //else return newPath.substr(pos + 1);
}
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::getFileNameWithoutExtension(const AnsiString &path) {
AnsiString fileName = getFileName(path);
-
- //size_t pos = fileName.find_last_of('.'); //TODO REMOVE!
// TODO: Prettify this.
AnsiString extension = Common::lastPathComponent(fileName, '.');
for (uint32 i = 0; i < extension.size() + 1; i++) {
fileName.deleteLastChar();
}
-// Common::String filename = Common::String(fileName.c_str(), fileName.size() - extension.size() + 1);
return fileName;
- //if (pos == AnsiString::npos) return fileName;
- //else return fileName.substr(0, pos);
}
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::getExtension(const AnsiString &path) {
AnsiString fileName = getFileName(path);
-
- //size_t pos = fileName.find_last_of('.');
return Common::lastPathComponent(path, '.');
- //if (pos == AnsiString::npos) return "";
- //else return fileName.substr(pos);
}
-
-//////////////////////////////////////////////////////////////////////////
-AnsiString PathUtil::getSafeLogFileName() {
- AnsiString logFileName = getUserDirectory();
-
- /*#ifdef __WIN32__
- char moduleName[MAX_PATH_LENGTH];
- ::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH);
-
- AnsiString fileName = GetFileNameWithoutExtension(moduleName) + ".log";
- fileName = Combine("/Wintermute Engine/Logs/", fileName);
- logFileName = Combine(logFileName, fileName);
-
- #else*/
- // !PORTME
- logFileName = combine(logFileName, "/Wintermute Engine/wme.log");
-//#endif
-
- createDirectory(getDirectoryName(logFileName));
- return logFileName;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool PathUtil::createDirectory(const AnsiString &path) {
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool PathUtil::matchesMask(const AnsiString &fileName, const AnsiString &mask) {
- return false;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool PathUtil::fileExists(const AnsiString &fileName) {
- warning("PathUtil::FileExists(%s)", fileName.c_str());
-
- Common::File stream;
-
- stream.open(fileName.c_str());
- bool ret = stream.isOpen();
- stream.close();
-
- return ret;
-}
-
-
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::getUserDirectory() { // TODO: Get rid of
warning("PathUtil::GetUserDirectory - stubbed");
diff --git a/engines/wintermute/utils/path_util.h b/engines/wintermute/utils/path_util.h
index a52b4baaf9..9b3e988805 100644
--- a/engines/wintermute/utils/path_util.h
+++ b/engines/wintermute/utils/path_util.h
@@ -42,12 +42,7 @@ public:
static AnsiString getFileName(const AnsiString &path);
static AnsiString getFileNameWithoutExtension(const AnsiString &path);
static AnsiString getExtension(const AnsiString &path);
- static bool createDirectory(const AnsiString &path);
- static bool matchesMask(const AnsiString &fileName, const AnsiString &mask);
- static bool fileExists(const AnsiString &fileName);
-
- static AnsiString getSafeLogFileName();
static AnsiString getUserDirectory();
};
diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp
index 8bf83cc0f6..8e782a2444 100644
--- a/engines/wintermute/wintermute.cpp
+++ b/engines/wintermute/wintermute.cpp
@@ -52,7 +52,7 @@ WinterMuteEngine::WinterMuteEngine() : Engine(g_system) {
_classReg = new SystemClassRegistry();
_classReg->registerClasses();
- _game = new AdGame();
+ _game = new AdGame("");
_rnd = NULL;
}
@@ -158,7 +158,7 @@ int WinterMuteEngine::init() {
_classReg = new SystemClassRegistry();
_classReg->registerClasses();
- _game = new AdGame;
+ _game = new AdGame(_targetName);
if (!_game) return 1;
BasePlatform::initialize(_game, 0, NULL);