[Scummvm-cvs-logs] CVS: scummvm/base gameDetector.cpp,1.70,1.71 gameDetector.h,1.27,1.28 main.cpp,1.35,1.36

Max Horn fingolfin at users.sourceforge.net
Tue Feb 24 14:55:24 CET 2004


Update of /cvsroot/scummvm/scummvm/base
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12241/base

Modified Files:
	gameDetector.cpp gameDetector.h main.cpp 
Log Message:
the OSystem changes we discussed on the ML (note: renaming of the existing OSystem API is not yet finished); porters will have to fix their ports to get them to compile again

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- gameDetector.cpp	22 Feb 2004 21:01:39 -0000	1.70
+++ gameDetector.cpp	24 Feb 2004 22:39:38 -0000	1.71
@@ -96,46 +96,12 @@
 ;
 #endif
 
-/**
- * List of graphic 'modes' we potentially support. Potentially because not all
- * backends actually support all the filters listed here. At this point only
- * the SDL backend supports all (except for the PalmOS ones of course).
- * @todo Remove this explicit list of graphic modes and rather extend the
- * OSystem API to allow querying a backend for the modes it supports.
- */
-const GraphicsMode g_gfx_modes[] = {
-	{"normal", "Normal (no scaling)", GFX_NORMAL},
-	{"1x", "Normal (no scaling)", GFX_NORMAL},
-#ifndef __PALM_OS__     // reduce contant data size
-	{"2x", "2x", GFX_DOUBLESIZE},
-	{"3x", "3x", GFX_TRIPLESIZE},
-	{"2xsai", "2xSAI", GFX_2XSAI},
-	{"super2xsai", "Super2xSAI", GFX_SUPER2XSAI},
-	{"supereagle", "SuperEagle", GFX_SUPEREAGLE},
-	{"advmame2x", "AdvMAME2x", GFX_ADVMAME2X},
-	{"advmame3x", "AdvMAME3x", GFX_ADVMAME3X},
-	{"hq2x", "HQ2x", GFX_HQ2X},
-	{"hq3x", "HQ3x", GFX_HQ3X},
-	{"tv2x", "TV2x", GFX_TV2X},
-	{"dotmatrix", "DotMatrix", GFX_DOTMATRIX},
-#else
-	{"flipping", "Page Flipping", GFX_FLIPPING},
-	{"buffered", "Buffered", GFX_BUFFERED},
-	{"wide", "Wide (HiRes+ only)", GFX_WIDE},
-#endif
-	{0, 0, 0}
-};
-
 GameDetector::GameDetector() {
 
 	// Graphics
 	ConfMan.registerDefault("fullscreen", false);
 	ConfMan.registerDefault("aspect_ratio", false);
-#ifndef _WIN32_WCE
-	ConfMan.registerDefault("gfx_mode", "2x");
-#else
 	ConfMan.registerDefault("gfx_mode", "normal");
-#endif
 
 	// Sound & Music
 	ConfMan.registerDefault("master_volume", 192);
@@ -350,12 +316,22 @@
 			END_OPTION
 
 			DO_OPTION('g', "gfx-mode")
-				int gfx_mode = parseGraphicsMode(option);
+				// Check whether 'option' specifies a valid graphics mode.
+				bool isValid = false;
+				if (!scumm_stricmp(option, "normal") || !scumm_stricmp(option, "default"))
+					isValid = true;
+				if (!isValid) {
+					const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
+					while (gm->name && !isValid) {
+						isValid = !scumm_stricmp(gm->name, option);
+						gm++;
+					}
+				}
 				// TODO: Instead of just showing the generic help text,
 				// maybe print a message like:
 				// "'option' is not a supported graphic mode on this machine.
 				//  Available graphic modes: ..."
-				if (gfx_mode == -1)
+				if (!isValid)
 					goto ShowHelpAndExit;
 				ConfMan.set("gfx_mode", option, kTransientDomain);
 			END_OPTION
@@ -493,22 +469,6 @@
 	ConfMan.setActiveDomain(name);
 }
 
-int GameDetector::parseGraphicsMode(const String &str) {
-	if (str.isEmpty())
-		return -1;
-
-	const char *s = str.c_str();
-	const GraphicsMode *gm = g_gfx_modes;
-	while (gm->name) {
-		if (!scumm_stricmp(gm->name, s)) {
-			return gm->id;
-		}
-		gm++;
-	}
-
-	return -1;
-}
-
 bool GameDetector::detectGame() {
 	String realGame;
 

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- gameDetector.h	22 Feb 2004 21:01:39 -0000	1.27
+++ gameDetector.h	24 Feb 2004 22:39:38 -0000	1.28
@@ -54,14 +54,6 @@
 	uint32 features;
 };
 
-struct GraphicsMode {
-	const char *name;
-	const char *description;
-	int id;
-};
-
-extern const GraphicsMode g_gfx_modes[];
-
 class GameDetector {
 	typedef Common::String String;
 
@@ -85,7 +77,6 @@
 	static SoundMixer *createMixer();
 	static MidiDriver *createMidi(int midiDriver);
 
-	static int parseGraphicsMode(const String &s);	// Used in main()
 	static int detectMusicDriver(int midiFlags);
 
 	static GameSettings findGame(const String &gameName, const Plugin **plugin = NULL);

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- main.cpp	10 Feb 2004 13:15:46 -0000	1.35
+++ main.cpp	24 Feb 2004 22:39:38 -0000	1.36
@@ -176,12 +176,15 @@
 #endif
 
 static int launcherDialog(GameDetector &detector, OSystem *system) {
-	// FIXME - we need to call init_size() here so that we can display for example
+	// Set the user specified graphics mode (if any).
+	system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
+
+	// FIXME - we need to call initSize() here so that we can display for example
 	// the launcher dialog. But the Engine object will also call it again (possibly
 	// with a different widht/height!9 However, this method is not for all OSystem 
 	// implementations reentrant (it is so now for the SDL backend). Thus we need
 	// to fix all backends to support it, if they don't already.
-	system->init_size(320, 200);
+	system->initSize(320, 200);
 	
 	// FIXME - mouse cursors are currently always set via 8 bit data.
 	// Thus for now we need to setup a dummy palette. On the long run, we might
@@ -219,7 +222,6 @@
 }
 
 static void runGame(GameDetector &detector, OSystem *system) {
-	OSystem::Property prop;
 
 	// Set the window caption to the game name
 	Common::String caption(ConfMan.get("description", detector._targetName));
@@ -229,26 +231,22 @@
 	if (caption.isEmpty())	
 		caption = detector._targetName;
 	if (!caption.isEmpty())	{
-		prop.caption = caption.c_str();
-		system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
+		system->setWindowCaption(caption.c_str());
 	}
 
 	// See if the game should default to 1x scaler
 	if (!ConfMan.hasKey("gfx_mode", detector._targetName) && 
 		(detector._game.features & GF_DEFAULT_TO_1X_SCALER)) {
-		prop.gfx_mode = GFX_NORMAL;
-		system->property(OSystem::PROP_SET_GFX_MODE, &prop);
+		system->setGraphicsMode(GFX_NORMAL);
 	} else {
 	// Override global scaler with any game-specific define
 		if (ConfMan.hasKey("gfx_mode")) {
-			prop.gfx_mode = detector.parseGraphicsMode(ConfMan.get("gfx_mode"));
-			system->property(OSystem::PROP_SET_GFX_MODE, &prop);
+			system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
 		}
 	}
 
 	// (De)activate fullscreen mode as determined by the config settings 
-	if (ConfMan.getBool("fullscreen") != (system->property(OSystem::PROP_GET_FULLSCREEN, 0) != 0))
-		system->property(OSystem::PROP_TOGGLE_FULLSCREEN, 0);
+	system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
 	
 	// Create the game engine
 	Engine *engine = detector.createEngine(system);
@@ -258,18 +256,17 @@
 	engine->go();
 
 	// Stop all sound processing now (this prevents some race conditions later on)
-	system->clear_sound_proc();
+	system->clearSoundCallback();
 
 	// Free up memory
 	delete engine;
 };
 
 #ifndef _WIN32_WCE
-int main(int argc, char *argv[]) {
+extern "C" int main(int argc, char *argv[]) {
 #else
 extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
 #endif
-	OSystem::Property prop;
 	char *cfgFilename = NULL, *s=argv[1];
 
 #if defined(UNIX)
@@ -346,15 +343,15 @@
 #endif
 	detector.parseCommandLine(argc, argv);
 
-	// Create the system object
+	// Ensure the system object exists (it may have already been created 
+	// at an earlier point, though!)
 	OSystem *system = OSystem::instance();
 
 	// Create the timer services
 	g_timer = new Timer(system);
 
 	// Set initial window caption
-	prop.caption = gScummVMFullVersion;
-	system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
+	system->setWindowCaption(gScummVMFullVersion);
 
 	// Unless a game was specified, show the launcher dialog
 	if (detector._targetName.isEmpty())





More information about the Scummvm-git-logs mailing list