Moved ConfMan.registerDefault calls for savepath to DefaultSaveFileManager (eventually, should be pushed into backends/platform/ code)

svn-id: r33614
This commit is contained in:
Max Horn 2008-08-04 17:17:37 +00:00
parent 1ed65c1e2e
commit 92d6ee3d76
3 changed files with 46 additions and 41 deletions

View File

@ -41,6 +41,50 @@
#include <sys/stat.h>
#endif
#ifdef IPHONE
#include "backends/platform/iphone/osys_iphone.h"
#endif
#ifdef UNIX
#ifdef MACOSX
#define DEFAULT_SAVE_PATH "Documents/ScummVM Savegames"
#else
#define DEFAULT_SAVE_PATH ".scummvm"
#endif
#elif defined(__SYMBIAN32__)
#define DEFAULT_SAVE_PATH "Savegames"
#elif defined(PALMOS_MODE)
#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved"
#endif
DefaultSaveFileManager::DefaultSaveFileManager() {
// Register default savepath
// TODO: Remove this code here, and instead leave setting the
// default savepath to the ports using this class.
#ifdef DEFAULT_SAVE_PATH
char savePath[MAXPATHLEN];
#if defined(UNIX) && !defined(IPHONE)
const char *home = getenv("HOME");
if (home && *home && strlen(home) < MAXPATHLEN) {
snprintf(savePath, MAXPATHLEN, "%s/%s", home, DEFAULT_SAVE_PATH);
ConfMan.registerDefault("savepath", savePath);
}
#elif defined(__SYMBIAN32__)
strcpy(savePath, Symbian::GetExecutablePath());
strcat(savePath, DEFAULT_SAVE_PATH);
strcat(savePath, "\\");
ConfMan.registerDefault("savepath", savePath);
#elif defined (IPHONE)
ConfMan.registerDefault("savepath", OSystem_IPHONE::getSavePath());
#elif defined(PALMOS_MODE)
ConfMan.registerDefault("savepath", DEFAULT_SAVE_PATH);
#endif
#endif // #ifdef DEFAULT_SAVE_PATH
}
Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) {
FilesystemNode savePath(getSavePath());
FSList savefiles;

View File

@ -34,6 +34,8 @@
*/
class DefaultSaveFileManager : public Common::SaveFileManager {
public:
DefaultSaveFileManager();
virtual Common::StringList listSavefiles(const char *pattern);
virtual Common::InSaveFile *openForLoading(const char *filename);
virtual Common::OutSaveFile *openForSaving(const char *filename);

View File

@ -34,22 +34,6 @@
#include "sound/mididrv.h"
#ifdef IPHONE
#include "backends/platform/iphone/osys_iphone.h"
#endif
#ifdef UNIX
#ifdef MACOSX
#define DEFAULT_SAVE_PATH "Documents/ScummVM Savegames"
#else
#define DEFAULT_SAVE_PATH ".scummvm"
#endif
#elif defined(__SYMBIAN32__)
#define DEFAULT_SAVE_PATH "Savegames"
#elif defined(PALMOS_MODE)
#define DEFAULT_SAVE_PATH "/PALM/Programs/ScummVM/Saved"
#endif
#define DETECTOR_TESTING_HACK
namespace Base {
@ -181,9 +165,6 @@ void registerDefaults() {
// Game specific
ConfMan.registerDefault("path", "");
ConfMan.registerDefault("savepath", "");
// ConfMan.registerDefault("amiga", false);
ConfMan.registerDefault("platform", Common::kPlatformPC);
ConfMan.registerDefault("language", "en");
ConfMan.registerDefault("subtitles", false);
@ -216,28 +197,6 @@ void registerDefaults() {
ConfMan.registerDefault("alsa_port", "65:0");
#endif
// Register default savepath
#ifdef DEFAULT_SAVE_PATH
char savePath[MAXPATHLEN];
#if defined(UNIX) && !defined(IPHONE)
const char *home = getenv("HOME");
if (home && *home && strlen(home) < MAXPATHLEN) {
snprintf(savePath, MAXPATHLEN, "%s/%s", home, DEFAULT_SAVE_PATH);
ConfMan.registerDefault("savepath", savePath);
}
#elif defined(__SYMBIAN32__)
strcpy(savePath, Symbian::GetExecutablePath());
strcat(savePath, DEFAULT_SAVE_PATH);
strcat(savePath, "\\");
ConfMan.registerDefault("savepath", savePath);
#elif defined (IPHONE)
ConfMan.registerDefault("savepath", OSystem_IPHONE::getSavePath());
#elif defined(PALMOS_MODE)
ConfMan.registerDefault("savepath", DEFAULT_SAVE_PATH);
#endif
#endif // #ifdef DEFAULT_SAVE_PATH
ConfMan.registerDefault("record_mode", "none");
ConfMan.registerDefault("record_file_name", "record.bin");
ConfMan.registerDefault("record_temp_file_name", "record.tmp");