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).
This commit is contained in:
parent
afb06b51cc
commit
c847522422
16 changed files with 43 additions and 137 deletions
|
@ -52,40 +52,5 @@ void BaseBackend::fillScreen(uint32 col) {
|
||||||
unlockScreen();
|
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() {
|
void BaseBackend::resetGraphicsScale() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,10 @@
|
||||||
|
|
||||||
class BaseBackend : public OSystem, Common::EventSource {
|
class BaseBackend : public OSystem, Common::EventSource {
|
||||||
public:
|
public:
|
||||||
BaseBackend();
|
|
||||||
~BaseBackend();
|
|
||||||
|
|
||||||
virtual Common::EventManager *getEventManager();
|
virtual Common::EventManager *getEventManager();
|
||||||
virtual void displayMessageOnOSD(const char *msg);
|
virtual void displayMessageOnOSD(const char *msg);
|
||||||
virtual void fillScreen(uint32 col);
|
virtual void fillScreen(uint32 col);
|
||||||
|
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
|
||||||
virtual Common::WriteStream *createConfigWriteStream();
|
|
||||||
|
|
||||||
virtual void resetGraphicsScale();
|
virtual void resetGraphicsScale();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,6 @@ class MutexManager;
|
||||||
* A backend derivated from this class, will need to implement
|
* A backend derivated from this class, will need to implement
|
||||||
* these functions on its own:
|
* these functions on its own:
|
||||||
* OSystem::pollEvent()
|
* OSystem::pollEvent()
|
||||||
* OSystem::createConfigReadStream()
|
|
||||||
* OSystem::createConfigWriteStream()
|
|
||||||
* OSystem::getMillis()
|
* OSystem::getMillis()
|
||||||
* OSystem::delayMillis()
|
* OSystem::delayMillis()
|
||||||
* OSystem::getTimeAndDate()
|
* OSystem::getTimeAndDate()
|
||||||
|
|
|
@ -853,16 +853,8 @@ void OSystem_DS::setCharactersEntered(int count) {
|
||||||
DS::setCharactersEntered(count);
|
DS::setCharactersEntered(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::SeekableReadStream *OSystem_DS::createConfigReadStream() {
|
Common::String OSystem_DS::getDefaultConfigFileName() {
|
||||||
Common::FSNode file(DEFAULT_CONFIG_FILE);
|
return 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 OSystem_DS::applyGamma(u16 color) {
|
u16 OSystem_DS::applyGamma(u16 color) {
|
||||||
|
|
|
@ -176,8 +176,7 @@ public:
|
||||||
|
|
||||||
void refreshCursor();
|
void refreshCursor();
|
||||||
|
|
||||||
Common::WriteStream *createConfigWriteStream();
|
virtual Common::String getDefaultConfigFileName();
|
||||||
Common::SeekableReadStream *createConfigReadStream();
|
|
||||||
|
|
||||||
u16 applyGamma(u16 color);
|
u16 applyGamma(u16 color);
|
||||||
void setGammaValue(int gamma) { _gammaValue = gamma; }
|
void setGammaValue(int gamma) { _gammaValue = gamma; }
|
||||||
|
|
|
@ -229,29 +229,16 @@ OSystem *OSystem_IPHONE_create() {
|
||||||
return new OSystem_IPHONE();
|
return new OSystem_IPHONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::SeekableReadStream *OSystem_IPHONE::createConfigReadStream() {
|
CCommon::String OSystem_IPHONE::getDefaultConfigFileName() {
|
||||||
#ifdef IPHONE_OFFICIAL
|
#ifdef IPHONE_OFFICIAL
|
||||||
char buf[256];
|
Common::String path = iPhone_getDocumentsDir();
|
||||||
strncpy(buf, iPhone_getDocumentsDir(), 256);
|
path += "/Preferences";
|
||||||
strncat(buf, "/Preferences", 256 - strlen(buf) );
|
return path;
|
||||||
Common::FSNode file(buf);
|
|
||||||
#else
|
#else
|
||||||
Common::FSNode file(SCUMMVM_PREFS_PATH);
|
return SCUMMVM_PREFS_PATH;
|
||||||
#endif
|
#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) {
|
void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||||
// Get URL of the Resource directory of the .app bundle
|
// Get URL of the Resource directory of the .app bundle
|
||||||
|
|
|
@ -184,8 +184,7 @@ public:
|
||||||
void startSoundsystem();
|
void startSoundsystem();
|
||||||
void stopSoundsystem();
|
void stopSoundsystem();
|
||||||
|
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
virtual Common::String getDefaultConfigFileName();
|
||||||
virtual Common::WriteStream *createConfigWriteStream();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internUpdateScreen();
|
void internUpdateScreen();
|
||||||
|
|
|
@ -52,9 +52,6 @@ public:
|
||||||
virtual uint32 getMillis();
|
virtual uint32 getMillis();
|
||||||
virtual void delayMillis(uint msecs);
|
virtual void delayMillis(uint msecs);
|
||||||
virtual void getTimeAndDate(TimeDate &t) const {}
|
virtual void getTimeAndDate(TimeDate &t) const {}
|
||||||
|
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
|
||||||
virtual Common::WriteStream *createConfigWriteStream();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OSystem_NULL::OSystem_NULL() {
|
OSystem_NULL::OSystem_NULL() {
|
||||||
|
@ -100,18 +97,6 @@ uint32 OSystem_NULL::getMillis() {
|
||||||
void OSystem_NULL::delayMillis(uint msecs) {
|
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() {
|
OSystem *OSystem_NULL_create() {
|
||||||
return new OSystem_NULL();
|
return new OSystem_NULL();
|
||||||
}
|
}
|
||||||
|
|
|
@ -983,12 +983,6 @@ void OSystem_PS2::makeConfigPath() {
|
||||||
_configFile = strdup(path);
|
_configFile = strdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::SeekableReadStream *OSystem_PS2::createConfigReadStream() {
|
Common::String OSystem_PS2::getDefaultConfigFileName() {
|
||||||
Common::FSNode file(_configFile);
|
return _configFile
|
||||||
return file.createReadStream();
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::WriteStream *OSystem_PS2::createConfigWriteStream() {
|
|
||||||
Common::FSNode file(_configFile);
|
|
||||||
return file.createWriteStream();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,7 @@ public:
|
||||||
|
|
||||||
virtual void quit();
|
virtual void quit();
|
||||||
|
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
virtual Common::String getDefaultConfigFileName();
|
||||||
virtual Common::WriteStream *createConfigWriteStream();
|
|
||||||
|
|
||||||
virtual Graphics::PixelFormat getOverlayFormat() const;
|
virtual Graphics::PixelFormat getOverlayFormat() const;
|
||||||
virtual Common::SaveFileManager *getSavefileManager();
|
virtual Common::SaveFileManager *getSavefileManager();
|
||||||
|
|
|
@ -439,14 +439,6 @@ void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
|
||||||
td.tm_year = t.tm_year;
|
td.tm_year = t.tm_year;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
|
Common::String OSystem_PSP::getDefaultConfigFileName() {
|
||||||
|
return "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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,9 +156,7 @@ public:
|
||||||
|
|
||||||
void logMessage(LogMessageType::Type type, const char *message);
|
void logMessage(LogMessageType::Type type, const char *message);
|
||||||
|
|
||||||
Common::SeekableReadStream *createConfigReadStream();
|
virtual Common::String getDefaultConfigFileName();
|
||||||
Common::WriteStream *createConfigWriteStream();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* OSYS_PSP_H */
|
#endif /* OSYS_PSP_H */
|
||||||
|
|
|
@ -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) {
|
void OSystem_SDL::setWindowCaption(const char *caption) {
|
||||||
Common::String cap;
|
Common::String cap;
|
||||||
byte c;
|
byte c;
|
||||||
|
|
|
@ -65,8 +65,6 @@ public:
|
||||||
|
|
||||||
virtual void setWindowCaption(const char *caption);
|
virtual void setWindowCaption(const char *caption);
|
||||||
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
|
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream();
|
|
||||||
virtual Common::WriteStream *createConfigWriteStream();
|
|
||||||
virtual uint32 getMillis();
|
virtual uint32 getMillis();
|
||||||
virtual void delayMillis(uint msecs);
|
virtual void delayMillis(uint msecs);
|
||||||
virtual void getTimeAndDate(TimeDate &td) const;
|
virtual void getTimeAndDate(TimeDate &td) const;
|
||||||
|
@ -103,12 +101,6 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void setupIcon();
|
virtual void setupIcon();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the file path where the user configuration
|
|
||||||
* of ScummVM will be saved.
|
|
||||||
*/
|
|
||||||
virtual Common::String getDefaultConfigFileName();
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
virtual Common::WriteStream *createLogFile() { return 0; }
|
virtual Common::WriteStream *createLogFile() { return 0; }
|
||||||
Backends::Log::Log *_logger;
|
Backends::Log::Log *_logger;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
|
#include "common/fs.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
|
|
||||||
#include "backends/audiocd/default/default-audiocd.h"
|
#include "backends/audiocd/default/default-audiocd.h"
|
||||||
|
@ -90,6 +91,24 @@ void OSystem::fatalError() {
|
||||||
exit(1);
|
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) {
|
void OSystem::logMessage(LogMessageType::Type type, const char *message) {
|
||||||
FILE *output = 0;
|
FILE *output = 0;
|
||||||
|
|
||||||
|
|
|
@ -1015,7 +1015,7 @@ public:
|
||||||
* ReadStream instance. It is the callers responsiblity to delete
|
* ReadStream instance. It is the callers responsiblity to delete
|
||||||
* the stream after use.
|
* the stream after use.
|
||||||
*/
|
*/
|
||||||
virtual Common::SeekableReadStream *createConfigReadStream() = 0;
|
virtual Common::SeekableReadStream *createConfigReadStream();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the default config file for writing, by returning a suitable
|
* 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.
|
* 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.
|
* Logs a given message.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue