[Scummvm-cvs-logs] scummvm master -> c81e94b25214d258e0789f51b0ad0236ba1bf9c0
fingolfin
max at quendi.de
Mon Jun 6 16:31:11 CEST 2011
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c847522422 BACKENDS: Add OSystem::getDefaultConfigFileName
4878b2b27b PS2: Add logMessage() implementation
b0b5a1d802 DS: Add custom logMessage() implementation
0e20bc0086 COMMON: Remove PS2 / NDS hacks in system.cpp
848079b66d NULL: Fix null backend (untested)
c81e94b252 BACKENDS: Unify EventManager setup
Commit: c8475224221ed14590ad08929a1cadd6e8e3cc4e
https://github.com/scummvm/scummvm/commit/c8475224221ed14590ad08929a1cadd6e8e3cc4e
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:30:21-07:00
Commit Message:
BACKENDS: Add OSystem::getDefaultConfigFileName
This is used to provide default implementations for createConfigWriteStream
and createConfigReadStream, which can be used by most backends.
Note that backends can still override createConfigRead/WriteStream;
this could be useful if settings on some port are not stored in a
regular file (think 'Windows registry', for a hypothetical example).
Changed paths:
backends/base-backend.cpp
backends/base-backend.h
backends/modular-backend.h
backends/platform/ds/arm9/source/osystem_ds.cpp
backends/platform/ds/arm9/source/osystem_ds.h
backends/platform/iphone/osys_main.cpp
backends/platform/iphone/osys_main.h
backends/platform/null/null.cpp
backends/platform/ps2/systemps2.cpp
backends/platform/ps2/systemps2.h
backends/platform/psp/osys_psp.cpp
backends/platform/psp/osys_psp.h
backends/platform/sdl/sdl.cpp
backends/platform/sdl/sdl.h
common/system.cpp
common/system.h
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index ca46129..ecd22d5 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -52,40 +52,5 @@ void BaseBackend::fillScreen(uint32 col) {
unlockScreen();
}
-
-/*
- FIXME: Maybe we should push the default config file loading/saving code below
- out to all the backends?
-*/
-
-
-#if defined(POSIX)
-#define DEFAULT_CONFIG_FILE ".scummvmrc"
-#endif
-
-#if !defined(POSIX)
-#define DEFAULT_CONFIG_FILE "scummvm.ini"
-#endif
-
-BaseBackend::BaseBackend() {
-}
-
-BaseBackend::~BaseBackend() {
-}
-
-Common::SeekableReadStream *BaseBackend::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *BaseBackend::createConfigWriteStream() {
-#ifdef __DC__
- return 0;
-#else
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
-#endif
-}
-
void BaseBackend::resetGraphicsScale() {
}
diff --git a/backends/base-backend.h b/backends/base-backend.h
index b6ac8c4..c71b481 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -28,16 +28,10 @@
class BaseBackend : public OSystem, Common::EventSource {
public:
- BaseBackend();
- ~BaseBackend();
-
virtual Common::EventManager *getEventManager();
virtual void displayMessageOnOSD(const char *msg);
virtual void fillScreen(uint32 col);
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
-
virtual void resetGraphicsScale();
};
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index 8dbfd1c..a978f20 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -39,8 +39,6 @@ class MutexManager;
* A backend derivated from this class, will need to implement
* these functions on its own:
* OSystem::pollEvent()
- * OSystem::createConfigReadStream()
- * OSystem::createConfigWriteStream()
* OSystem::getMillis()
* OSystem::delayMillis()
* OSystem::getTimeAndDate()
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index e65402c..90af02f 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -853,16 +853,8 @@ void OSystem_DS::setCharactersEntered(int count) {
DS::setCharactersEntered(count);
}
-Common::SeekableReadStream *OSystem_DS::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
-// consolePrintf("R %s", DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_DS::createConfigWriteStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
-// consolePrintf("W %s", DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
+Common::String OSystem_DS::getDefaultConfigFileName() {
+ return DEFAULT_CONFIG_FILE;
}
u16 OSystem_DS::applyGamma(u16 color) {
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index ecb8011..d3e7fce 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -176,8 +176,7 @@ public:
void refreshCursor();
- Common::WriteStream *createConfigWriteStream();
- Common::SeekableReadStream *createConfigReadStream();
+ virtual Common::String getDefaultConfigFileName();
u16 applyGamma(u16 color);
void setGammaValue(int gamma) { _gammaValue = gamma; }
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 75156b9..d0a10d9 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -229,29 +229,16 @@ OSystem *OSystem_IPHONE_create() {
return new OSystem_IPHONE();
}
-Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
+CCommon::String OSystem_IPHONE::getDefaultConfigFileName() {
#ifdef IPHONE_OFFICIAL
- char buf[256];
- strncpy(buf, iPhone_getDocumentsDir(), 256);
- strncat(buf, "/Preferences", 256 - strlen(buf) );
- Common::FSNode file(buf);
+ Common::String path = iPhone_getDocumentsDir();
+ path += "/Preferences";
+ return path;
#else
- Common::FSNode file(SCUMMVM_PREFS_PATH);
+ return SCUMMVM_PREFS_PATH;
#endif
- return file.createReadStream();
}
-Common::WriteStream *OSystem_IPHONE::createConfigWriteStream() {
-#ifdef IPHONE_OFFICIAL
- char buf[256];
- strncpy(buf, iPhone_getDocumentsDir(), 256);
- strncat(buf, "/Preferences", 256 - strlen(buf) );
- Common::FSNode file(buf);
-#else
- Common::FSNode file(SCUMMVM_PREFS_PATH);
-#endif
- return file.createWriteStream();
-}
void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
// Get URL of the Resource directory of the .app bundle
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 1ff8796..36b4b73 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -184,8 +184,7 @@ public:
void startSoundsystem();
void stopSoundsystem();
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
+ virtual Common::String getDefaultConfigFileName();
protected:
void internUpdateScreen();
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 207453a..e46ff9c 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -52,9 +52,6 @@ public:
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &t) const {}
-
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
};
OSystem_NULL::OSystem_NULL() {
@@ -100,18 +97,6 @@ uint32 OSystem_NULL::getMillis() {
void OSystem_NULL::delayMillis(uint msecs) {
}
-#define DEFAULT_CONFIG_FILE "scummvm.ini"
-
-Common::SeekableReadStream *OSystem_NULL::createConfigReadStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_NULL::createConfigWriteStream() {
- Common::FSNode file(DEFAULT_CONFIG_FILE);
- return file.createWriteStream();
-}
-
OSystem *OSystem_NULL_create() {
return new OSystem_NULL();
}
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index aa1a9ad..9dc3f63 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -983,12 +983,6 @@ void OSystem_PS2::makeConfigPath() {
_configFile = strdup(path);
}
-Common::SeekableReadStream *OSystem_PS2::createConfigReadStream() {
- Common::FSNode file(_configFile);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_PS2::createConfigWriteStream() {
- Common::FSNode file(_configFile);
- return file.createWriteStream();
+Common::String OSystem_PS2::getDefaultConfigFileName() {
+ return _configFile
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index b21a56c..bbb8294 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -112,8 +112,7 @@ public:
virtual void quit();
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
+ virtual Common::String getDefaultConfigFileName();
virtual Graphics::PixelFormat getOverlayFormat() const;
virtual Common::SaveFileManager *getSavefileManager();
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 1668869..4408cbf 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -439,14 +439,6 @@ void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
td.tm_year = t.tm_year;
}
-#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
-
-Common::SeekableReadStream *OSystem_PSP::createConfigReadStream() {
- Common::FSNode file(PSP_CONFIG_FILE);
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_PSP::createConfigWriteStream() {
- Common::FSNode file(PSP_CONFIG_FILE);
- return file.createWriteStream();
+Common::String OSystem_PSP::getDefaultConfigFileName() {
+ return "ms0:/scummvm.ini";
}
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 8b7c960..4f1d6f2 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -156,9 +156,7 @@ public:
void logMessage(LogMessageType::Type type, const char *message);
- Common::SeekableReadStream *createConfigReadStream();
- Common::WriteStream *createConfigWriteStream();
-
+ virtual Common::String getDefaultConfigFileName();
};
#endif /* OSYS_PSP_H */
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 527520a..564dd83 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -246,20 +246,6 @@ void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority)
}
-Common::String OSystem_SDL::getDefaultConfigFileName() {
- return "scummvm.ini";
-}
-
-Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createReadStream();
-}
-
-Common::WriteStream *OSystem_SDL::createConfigWriteStream() {
- Common::FSNode file(getDefaultConfigFileName());
- return file.createWriteStream();
-}
-
void OSystem_SDL::setWindowCaption(const char *caption) {
Common::String cap;
byte c;
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index e9e9bc5..917fac5 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -65,8 +65,6 @@ public:
virtual void setWindowCaption(const char *caption);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
- virtual Common::SeekableReadStream *createConfigReadStream();
- virtual Common::WriteStream *createConfigWriteStream();
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual void getTimeAndDate(TimeDate &td) const;
@@ -103,12 +101,6 @@ protected:
*/
virtual void setupIcon();
- /**
- * Get the file path where the user configuration
- * of ScummVM will be saved.
- */
- virtual Common::String getDefaultConfigFileName();
-
// Logging
virtual Common::WriteStream *createLogFile() { return 0; }
Backends::Log::Log *_logger;
diff --git a/common/system.cpp b/common/system.cpp
index dcdc38c..307079d 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -26,6 +26,7 @@
#include "common/system.h"
#include "common/str.h"
+#include "common/fs.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -90,6 +91,24 @@ void OSystem::fatalError() {
exit(1);
}
+Common::SeekableReadStream *OSystem::createConfigReadStream() {
+ Common::FSNode file(getDefaultConfigFileName());
+ return file.createReadStream();
+}
+
+Common::WriteStream *OSystem::createConfigWriteStream() {
+#ifdef __DC__
+ return 0;
+#else
+ Common::FSNode file(getDefaultConfigFileName());
+ return file.createWriteStream();
+#endif
+}
+
+Common::String OSystem::getDefaultConfigFileName() {
+ return "scummvm.ini";
+}
+
void OSystem::logMessage(LogMessageType::Type type, const char *message) {
FILE *output = 0;
diff --git a/common/system.h b/common/system.h
index 4b85f14..85771cf 100644
--- a/common/system.h
+++ b/common/system.h
@@ -1015,7 +1015,7 @@ public:
* ReadStream instance. It is the callers responsiblity to delete
* the stream after use.
*/
- virtual Common::SeekableReadStream *createConfigReadStream() = 0;
+ virtual Common::SeekableReadStream *createConfigReadStream();
/**
* Open the default config file for writing, by returning a suitable
@@ -1024,7 +1024,14 @@ public:
*
* May return 0 to indicate that writing to config file is not possible.
*/
- virtual Common::WriteStream *createConfigWriteStream() = 0;
+ virtual Common::WriteStream *createConfigWriteStream();
+
+ /**
+ * Get the default file name (or even path) where the user configuration
+ * of ScummVM will be saved.
+ * Note that not all ports may use this.
+ */
+ virtual Common::String getDefaultConfigFileName();
/**
* Logs a given message.
Commit: 4878b2b27b8d56a660d9ec29c1557c8a0375c9f6
https://github.com/scummvm/scummvm/commit/4878b2b27b8d56a660d9ec29c1557c8a0375c9f6
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:35:50-07:00
Commit Message:
PS2: Add logMessage() implementation
Changed paths:
backends/platform/ps2/systemps2.cpp
backends/platform/ps2/systemps2.h
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index 9dc3f63..e3a2f77 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -986,3 +986,15 @@ void OSystem_PS2::makeConfigPath() {
Common::String OSystem_PS2::getDefaultConfigFileName() {
return _configFile
}
+
+void OSystem_PS2::logMessage(LogMessageType::Type type, const char *message) {
+ FILE *output = 0;
+
+ if (type == LogMessageType::kInfo || type == LogMessageType::kDebug)
+ output = stdout;
+ else
+ output = stderr;
+
+ ps2_fputs(message, output);
+ ps2_fflush(output);
+}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index bbb8294..5e59a4f 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -114,6 +114,8 @@ public:
virtual Common::String getDefaultConfigFileName();
+ virtual void logMessage(LogMessageType::Type type, const char *message);
+
virtual Graphics::PixelFormat getOverlayFormat() const;
virtual Common::SaveFileManager *getSavefileManager();
virtual FilesystemFactory *getFilesystemFactory();
Commit: b0b5a1d80298452b5eb431e3481850e850f79f52
https://github.com/scummvm/scummvm/commit/b0b5a1d80298452b5eb431e3481850e850f79f52
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:36:28-07:00
Commit Message:
DS: Add custom logMessage() implementation
Changed paths:
backends/fs/ds/ds-fs.cpp
backends/platform/ds/arm9/source/osystem_ds.cpp
backends/platform/ds/arm9/source/osystem_ds.h
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index 6c11ddc..a038889 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -607,8 +607,8 @@ size_t std_fwrite(const void *ptr, size_t size, size_t numItems, FILE *handle) {
if ((handle == stderr) || (handle == stdout)) {
#ifndef DISABLE_TEXT_CONSOLE
- nocashMessage((char *) ptr);
-// consolePrintf((char *) ptr);
+ nocashMessage((char *)ptr);
+// consolePrintf((char *)ptr);
#endif
return size;
}
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 90af02f..eab9fd6 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -857,6 +857,13 @@ Common::String OSystem_DS::getDefaultConfigFileName() {
return DEFAULT_CONFIG_FILE;
}
+void OSystem_DS::logMessage(LogMessageType::Type type, const char *message) {
+#ifndef DISABLE_TEXT_CONSOLE
+ nocashMessage((char *)message);
+// consolePrintf((char *)message);
+#endif
+}
+
u16 OSystem_DS::applyGamma(u16 color) {
// Attempt to do gamma correction (or something like it) to palette entries
// to improve the contrast of the image on the original DS screen.
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index d3e7fce..1e032ba 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -172,12 +172,14 @@ public:
virtual void setCursorPalette(const byte *colors, uint start, uint num);
- FilesystemFactory *getFilesystemFactory();
+ virtual FilesystemFactory *getFilesystemFactory();
void refreshCursor();
virtual Common::String getDefaultConfigFileName();
+ virtual void logMessage(LogMessageType::Type type, const char *message);
+
u16 applyGamma(u16 color);
void setGammaValue(int gamma) { _gammaValue = gamma; }
Commit: 0e20bc0086f9e65454334c7a8f647d796188c0cf
https://github.com/scummvm/scummvm/commit/0e20bc0086f9e65454334c7a8f647d796188c0cf
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:39:05-07:00
Commit Message:
COMMON: Remove PS2 / NDS hacks in system.cpp
Changed paths:
common/system.cpp
diff --git a/common/system.cpp b/common/system.cpp
index 307079d..298f1d7 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -20,9 +20,10 @@
*
*/
-// Disable symbol overrides so that we can use system headers.
-// FIXME: Necessary for the PS2 port, should get rid of this eventually.
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#define FORBIDDEN_SYMBOL_EXCEPTION_exit
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+#define FORBIDDEN_SYMBOL_EXCEPTION_fputs
+#define FORBIDDEN_SYMBOL_EXCEPTION_fflush
#include "common/system.h"
#include "common/str.h"
@@ -31,21 +32,6 @@
#include "backends/audiocd/default/default-audiocd.h"
-#ifdef __PLAYSTATION2__
- // for those replaced fopen/fread/etc functions
- #include "backends/platform/ps2/fileio.h"
-
- #define fputs(str, file) ps2_fputs(str, file)
- #define fflush(a) ps2_fflush(a)
-#endif
-
-#ifdef __DS__
- #include "backends/fs/ds/ds-fs.h"
-
- #define fputs(str, file) DS::std_fwrite(str, strlen(str), 1, file)
- #define fflush(file) DS::std_fflush(file)
-#endif
-
OSystem *g_system = 0;
OSystem::OSystem() {
@@ -110,6 +96,7 @@ Common::String OSystem::getDefaultConfigFileName() {
}
void OSystem::logMessage(LogMessageType::Type type, const char *message) {
+#if !defined(__PLAYSTATION2__) && !defined(__DS__)
FILE *output = 0;
if (type == LogMessageType::kInfo || type == LogMessageType::kDebug)
@@ -119,6 +106,7 @@ void OSystem::logMessage(LogMessageType::Type type, const char *message) {
fputs(message, output);
fflush(output);
+#endif
}
Common::String OSystem::getSystemLanguage() const {
Commit: 848079b66de84cec7559bfbd009d664098ea42ac
https://github.com/scummvm/scummvm/commit/848079b66de84cec7559bfbd009d664098ea42ac
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T06:48:40-07:00
Commit Message:
NULL: Fix null backend (untested)
Changed paths:
backends/platform/null/null.cpp
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index e46ff9c..106cde1 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -83,7 +83,7 @@ void OSystem_NULL::initBackend() {
// this way; they need to be hooked into the system somehow to
// be functional. Of course, can't do that in a NULL backend :).
- BaseBackend::initBackend();
+ ModularBackend::initBackend();
}
bool OSystem_NULL::pollEvent(Common::Event &event) {
Commit: c81e94b25214d258e0789f51b0ad0236ba1bf9c0
https://github.com/scummvm/scummvm/commit/c81e94b25214d258e0789f51b0ad0236ba1bf9c0
Author: Max Horn (max at quendi.de)
Date: 2011-06-06T07:13:57-07:00
Commit Message:
BACKENDS: Unify EventManager setup
Changed paths:
backends/base-backend.cpp
backends/base-backend.h
backends/modular-backend.cpp
backends/modular-backend.h
backends/platform/ps2/systemps2.cpp
backends/platform/ps2/systemps2.h
common/system.cpp
common/system.h
diff --git a/backends/base-backend.cpp b/backends/base-backend.cpp
index ecd22d5..156871e 100644
--- a/backends/base-backend.cpp
+++ b/backends/base-backend.cpp
@@ -24,7 +24,11 @@
*/
#include "backends/base-backend.h"
+
+#ifndef DISABLE_DEFAULT_EVENT_MANAGER
#include "backends/events/default/default-events.h"
+#endif
+
#include "gui/message.h"
void BaseBackend::displayMessageOnOSD(const char *msg) {
@@ -33,16 +37,12 @@ void BaseBackend::displayMessageOnOSD(const char *msg) {
dialog.runModal();
}
-
-static Common::EventManager *s_eventManager = 0;
-
-Common::EventManager *BaseBackend::getEventManager() {
- // FIXME/TODO: Eventually this method should be turned into an abstract one,
- // to force backends to implement this conciously (even if they
- // end up returning the default event manager anyway).
- if (!s_eventManager)
- s_eventManager = new DefaultEventManager(this);
- return s_eventManager;
+void BaseBackend::initBackend() {
+ // Init Event manager
+#ifndef DISABLE_DEFAULT_EVENT_MANAGER
+ if (!_eventManager)
+ _eventManager = new DefaultEventManager(this);
+#endif
}
void BaseBackend::fillScreen(uint32 col) {
diff --git a/backends/base-backend.h b/backends/base-backend.h
index c71b481..6b19b7a 100644
--- a/backends/base-backend.h
+++ b/backends/base-backend.h
@@ -28,7 +28,8 @@
class BaseBackend : public OSystem, Common::EventSource {
public:
- virtual Common::EventManager *getEventManager();
+ virtual void initBackend();
+
virtual void displayMessageOnOSD(const char *msg);
virtual void fillScreen(uint32 col);
diff --git a/backends/modular-backend.cpp b/backends/modular-backend.cpp
index d56c947..bbf6a6c 100644
--- a/backends/modular-backend.cpp
+++ b/backends/modular-backend.cpp
@@ -36,7 +36,6 @@
ModularBackend::ModularBackend()
:
_fsFactory(0),
- _eventManager(0),
_savefileManager(0),
_timerManager(0),
_mutexManager(0),
@@ -50,8 +49,6 @@ ModularBackend::~ModularBackend() {
_fsFactory = 0;
delete _graphicsManager;
_graphicsManager = 0;
- delete _eventManager;
- _eventManager = 0;
delete _mixer;
_mixer = 0;
delete _savefileManager;
@@ -223,11 +220,6 @@ Common::TimerManager *ModularBackend::getTimerManager() {
return _timerManager;
}
-Common::EventManager *ModularBackend::getEventManager() {
- assert(_eventManager);
- return _eventManager;
-}
-
OSystem::MutexRef ModularBackend::createMutex() {
assert(_mutexManager);
return _mutexManager->createMutex();
diff --git a/backends/modular-backend.h b/backends/modular-backend.h
index a978f20..42bd0ed 100644
--- a/backends/modular-backend.h
+++ b/backends/modular-backend.h
@@ -111,7 +111,6 @@ public:
//@{
virtual Common::TimerManager *getTimerManager();
- virtual Common::EventManager *getEventManager();
virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; }
//@}
@@ -148,7 +147,6 @@ protected:
//@{
FilesystemFactory *_fsFactory;
- Common::EventManager *_eventManager;
Common::SaveFileManager *_savefileManager;
Common::TimerManager *_timerManager;
MutexManager *_mutexManager;
diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp
index e3a2f77..9336468 100644
--- a/backends/platform/ps2/systemps2.cpp
+++ b/backends/platform/ps2/systemps2.cpp
@@ -603,11 +603,7 @@ void OSystem_PS2::delayMillis(uint msecs) {
Common::TimerManager *OSystem_PS2::getTimerManager() {
return _scummTimerManager;
}
-/*
-Common::EventManager *OSystem_PS2::getEventManager() {
- return getEventManager();
-}
-*/
+
Audio::Mixer *OSystem_PS2::getMixer() {
return _scummMixer;
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 5e59a4f..cc9c489 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -94,7 +94,6 @@ public:
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
virtual Common::TimerManager *getTimerManager();
-// virtual Common::EventManager *getEventManager();
virtual bool pollEvent(Common::Event &event);
virtual Audio::Mixer *getMixer();
diff --git a/common/system.cpp b/common/system.cpp
index 298f1d7..2a0dfd8 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -26,8 +26,9 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_fflush
#include "common/system.h"
-#include "common/str.h"
+#include "common/events.h"
#include "common/fs.h"
+#include "common/str.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -36,19 +37,29 @@ OSystem *g_system = 0;
OSystem::OSystem() {
_audiocdManager = 0;
+ _eventManager = 0;
}
OSystem::~OSystem() {
delete _audiocdManager;
+ _audiocdManager = 0;
+
+ delete _eventManager;
+ _eventManager = 0;
}
void OSystem::initBackend() {
+ // Init AudioCD manager
#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
if (!_audiocdManager)
_audiocdManager = new DefaultAudioCDManager();
#endif
if (!_audiocdManager)
error("Backend failed to instantiate AudioCD manager");
+
+ // Verify Event manager has been set
+ if (!_eventManager)
+ error("Backend failed to instantiate Event manager");
}
bool OSystem::setGraphicsMode(const char *name) {
diff --git a/common/system.h b/common/system.h
index 85771cf..87e74d9 100644
--- a/common/system.h
+++ b/common/system.h
@@ -113,6 +113,21 @@ protected:
*/
AudioCDManager *_audiocdManager;
+ /**
+ * For backend authors only, this pointer may be set by OSystem
+ * subclasses to an EventManager instance. This is only useful
+ * if your backend does not want to use the DefaultEventManager.
+ *
+ * This instance is returned by OSystem::getEventManager(),
+ * and it is deleted by the OSystem destructor.
+ *
+ * A backend may set this pointer in its initBackend() method,
+ * its constructor or somewhere in between; but it must
+ * set it no later than in its initBackend() implementation, because
+ * OSystem::initBackend() will by default create a DefaultEventManager
+ * instance if _eventManager has not yet been set.
+ */
+ Common::EventManager *_eventManager;
public:
/**
@@ -848,7 +863,9 @@ public:
* Return the event manager singleton. For more information, refer
* to the EventManager documentation.
*/
- virtual Common::EventManager *getEventManager() = 0;
+ inline Common::EventManager *getEventManager() {
+ return _eventManager;
+ }
/**
* Register hardware keys with keymapper
More information about the Scummvm-git-logs
mailing list