[Scummvm-cvs-logs] SF.net SVN: scummvm:[50364] scummvm/branches/gsoc2010-opengl/backends/ platform

vgvgf at users.sourceforge.net vgvgf at users.sourceforge.net
Sun Jun 27 07:12:38 CEST 2010


Revision: 50364
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50364&view=rev
Author:   vgvgf
Date:     2010-06-27 05:12:37 +0000 (Sun, 27 Jun 2010)

Log Message:
-----------
Improved getDefaultConfigFileName(). Code cleanup.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.h
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.h
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.h
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.cpp
    scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.h

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.cpp	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.cpp	2010-06-27 05:12:37 UTC (rev 50364)
@@ -25,7 +25,10 @@
 
 #include "backends/platform/samsungtv/samsungtv.h"
 
-#if defined(SAMSUNGTV)
+OSystem_SDL_SamsungTV::OSystem_SDL_SamsungTV()
+	:
+	OSystem_POSIX("/dtv/usb/sda1/.scummvmrc") {
+}
 
 bool OSystem_SDL_SamsungTV::hasFeature(Feature f) {
 	return
@@ -55,9 +58,3 @@
 void OSystem_SDL_SamsungTV::quit() {
 	deinit();
 }
-
-const char *OSystem_SDL_SamsungTV::getConfigFileNameString() {
-	return "/dtv/usb/sda1/.scummvmrc";
-}
-
-#endif

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.h	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/samsungtv/samsungtv.h	2010-06-27 05:12:37 UTC (rev 50364)
@@ -26,22 +26,17 @@
 #ifndef SDL_SAMSUNGTV_COMMON_H
 #define SDL_SAMSUNGTV_COMMON_H
 
-#if defined(SAMSUNGTV)
-
 #include "backends/platform/sdl/posix/posix.h"
 
 class OSystem_SDL_SamsungTV : public OSystem_POSIX {
 public:
+	OSystem_SDL_SamsungTV();
+
 	bool hasFeature(Feature f);
 	void setFeatureState(Feature f, bool enable);
 	bool getFeatureState(Feature f);
 
 	void quit();
-
-protected:
-	const char *getConfigFileNameString();
 };
 
 #endif
-
-#endif

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.cpp	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.cpp	2010-06-27 05:12:37 UTC (rev 50364)
@@ -33,7 +33,9 @@
 
 #include "CoreFoundation/CoreFoundation.h"
 
-OSystem_MacOSX::OSystem_MacOSX() {
+OSystem_MacOSX::OSystem_MacOSX()
+	:
+	OSystem_POSIX("Library/Preferences/ScummVM Preferences") {
 }
 
 void OSystem_MacOSX::initBackend() {
@@ -49,10 +51,6 @@
 	OSystem_POSIX::initBackend();
 }
 
-const char *OSystem_MacOSX::getConfigFileNameString() {
-	return "Library/Preferences/ScummVM Preferences";
-}
-
 void OSystem_MacOSX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
 	// Invoke parent implementation of this method
 	OSystem_POSIX::addSysArchivesToSearchSet(s, priority);

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.h	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/macosx/macosx.h	2010-06-27 05:12:37 UTC (rev 50364)
@@ -34,11 +34,7 @@
 	~OSystem_MacOSX() {}
 
 	void initBackend();
-
 	void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
-
-protected:
-	const char *getConfigFileNameString();
 };
 
 #endif

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.cpp	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.cpp	2010-06-27 05:12:37 UTC (rev 50364)
@@ -26,22 +26,12 @@
 #ifdef UNIX
 
 #include "backends/platform/sdl/posix/posix.h"
-#include "common/archive.h"
-#include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/util.h"
-#include "common/EventRecorder.h"
-
 #include "backends/saves/posix/posix-saves.h"
-#include "backends/audiocd/sdl/sdl-audiocd.h"
-#include "backends/events/sdl/sdl-events.h"
-#include "backends/mutex/sdl/sdl-mutex.h"
-#include "backends/mixer/sdl/sdl-mixer.h"
-#include "backends/timer/sdl/sdl-timer.h"
-
 #include "backends/fs/posix/posix-fs-factory.h"
 
-OSystem_POSIX::OSystem_POSIX() {
+OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName)
+	:
+	_baseConfigName(baseConfigName) {
 }
 
 void OSystem_POSIX::init() {
@@ -61,26 +51,16 @@
 	OSystem_SDL::initBackend();
 }
 
-const char *OSystem_POSIX::getConfigFileNameString() {
-	return ".scummvmrc";
-}
-
 Common::String OSystem_POSIX::getDefaultConfigFileName() {
 	char configFile[MAXPATHLEN];
 
 	// On UNIX type systems, by default we store the config file inside
 	// to the HOME directory of the user.
-	//
-	// GP2X is Linux based but Home dir can be read only so do not use
-	// it and put the config in the executable dir.
-	//
-	// On the iPhone, the home dir of the user when you launch the app
-	// from the Springboard, is /. Which we don't want.
 	const char *home = getenv("HOME");
 	if (home != NULL && strlen(home) < MAXPATHLEN)
-		snprintf(configFile, MAXPATHLEN, "%s/%s", home, getConfigFileNameString());
+		snprintf(configFile, MAXPATHLEN, "%s/%s", home, _baseConfigName);
 	else
-		strcpy(configFile, getConfigFileNameString());
+		strcpy(configFile, _baseConfigName);
 
 	return configFile;
 }

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.h	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/posix/posix.h	2010-06-27 05:12:37 UTC (rev 50364)
@@ -30,15 +30,18 @@
 
 class OSystem_POSIX : public OSystem_SDL {
 public:
-	OSystem_POSIX();
+	// Let the subclasses be able to change _baseConfigName in the constructor
+	OSystem_POSIX(Common::String baseConfigName = ".scummvmrc");
 	virtual ~OSystem_POSIX() {}
 
 	virtual void init();
-
 	virtual void initBackend();
 
 protected:
-	virtual const char *getConfigFileNameString();
+	// Base string for creating the default path and filename
+	// for the configuration file
+	Common::String _baseConfigName;
+
 	virtual Common::String getDefaultConfigFileName();
 };
 

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.cpp	2010-06-27 05:12:37 UTC (rev 50364)
@@ -24,10 +24,7 @@
  */
 
 #include "backends/platform/sdl/sdl.h"
-#include "common/archive.h"
 #include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/util.h"
 #include "common/EventRecorder.h"
 
 #include "backends/saves/default/default-saves.h"
@@ -127,16 +124,10 @@
 
 }
 
-const char *OSystem_SDL::getConfigFileNameString() {
+Common::String OSystem_SDL::getDefaultConfigFileName() {
 	return "scummvm.ini";
 }
 
-Common::String OSystem_SDL::getDefaultConfigFileName() {
-	char configFile[MAXPATHLEN];
-	strcpy(configFile, getConfigFileNameString());
-	return configFile;
-}
-
 Common::SeekableReadStream *OSystem_SDL::createConfigReadStream() {
 	Common::FSNode file(getDefaultConfigFileName());
 	return file.createReadStream();

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/sdl.h	2010-06-27 05:12:37 UTC (rev 50364)
@@ -60,8 +60,6 @@
 	virtual Common::SeekableReadStream *createConfigReadStream();
 	virtual Common::WriteStream *createConfigWriteStream();
 
-	virtual SdlGraphicsManager *getGraphicsManager();
-
 	virtual bool pollEvent(Common::Event &event);
 
 	virtual uint32 getMillis();
@@ -70,16 +68,24 @@
 
 	virtual Audio::Mixer *getMixer();
 
+	// Get the Graphics Manager instance, used by other managers
+	virtual SdlGraphicsManager *getGraphicsManager();
+
 protected:
 	bool _inited;
 	bool _initedSDL;
+
+	// Mixer manager that encapsulates the actual Audio::Mixer
 	SdlMixerManager *_mixerManager;
 
+	// Initialze SDL library
 	virtual void initSDL();
 
+	// Setup the window icon
 	virtual void setupIcon();
 
-	virtual const char *getConfigFileNameString();
+	// Get the file path where the user configuration
+	// of ScummVM will be saved
 	virtual Common::String getDefaultConfigFileName();
 };
 

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.cpp
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.cpp	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.cpp	2010-06-27 05:12:37 UTC (rev 50364)
@@ -30,22 +30,9 @@
 #undef ARRAYSIZE
 
 #include "backends/platform/sdl/win32/win32.h"
-#include "common/archive.h"
-#include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/util.h"
-
-#include "backends/saves/default/default-saves.h"
-#include "backends/audiocd/sdl/sdl-audiocd.h"
-#include "backends/events/sdl/sdl-events.h"
-#include "backends/mutex/sdl/sdl-mutex.h"
-#include "backends/mixer/sdl/sdl-mixer.h"
-#include "backends/timer/sdl/sdl-timer.h"
-
 #include "backends/fs/windows/windows-fs-factory.h"
 
-OSystem_Win32::OSystem_Win32() {
-}
+#define DEFAULT_CONFIG_FILE "scummvm.ini"
 
 void OSystem_Win32::init() {
 	// Initialze File System Factory
@@ -55,10 +42,6 @@
 	OSystem_SDL::init();
 }
 
-const char *OSystem_Win32::getConfigFileNameString() {
-	return "\\scummvm.ini";
-}
-
 Common::String OSystem_Win32::getDefaultConfigFileName() {
 	char configFile[MAXPATHLEN];
 
@@ -82,14 +65,14 @@
 
 		strcat(configFile, "\\ScummVM");
 		CreateDirectory(configFile, NULL);
-		strcat(configFile, getConfigFileNameString());
+		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
 
 		FILE *tmp = NULL;
 		if ((tmp = fopen(configFile, "r")) == NULL) {
 			// Check windows directory
 			char oldConfigFile[MAXPATHLEN];
 			GetWindowsDirectory(oldConfigFile, MAXPATHLEN);
-			strcat(oldConfigFile, getConfigFileNameString());
+			strcat(oldConfigFile, "\\" DEFAULT_CONFIG_FILE);
 			if ((tmp = fopen(oldConfigFile, "r"))) {
 				strcpy(configFile, oldConfigFile);
 
@@ -101,7 +84,7 @@
 	} else {
 		// Check windows directory
 		GetWindowsDirectory(configFile, MAXPATHLEN);
-		strcat(configFile, getConfigFileNameString());
+		strcat(configFile, "\\" DEFAULT_CONFIG_FILE);
 	}
 
 	return configFile;

Modified: scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.h
===================================================================
--- scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.h	2010-06-27 04:58:48 UTC (rev 50363)
+++ scummvm/branches/gsoc2010-opengl/backends/platform/sdl/win32/win32.h	2010-06-27 05:12:37 UTC (rev 50364)
@@ -30,13 +30,9 @@
 
 class OSystem_Win32 : public OSystem_SDL {
 public:
-	OSystem_Win32();
-	~OSystem_Win32() {}
-
 	void init();
 
 protected:
-	const char *getConfigFileNameString();
 	Common::String getDefaultConfigFileName();
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list