[Scummvm-cvs-logs] CVS: scummvm/common gameDetector.cpp,1.13,1.14 gameDetector.h,1.4,1.5 main.cpp,1.11,1.12

Max Horn fingolfin at users.sourceforge.net
Sun Sep 29 17:56:02 CEST 2002


Update of /cvsroot/scummvm/scummvm/common
In directory usw-pr-cvs1:/tmp/cvs-serv18119/common

Modified Files:
	gameDetector.cpp gameDetector.h main.cpp 
Log Message:
played a bit with the launcher - it now is already somewhat usable <g>

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gameDetector.cpp	29 Sep 2002 23:09:01 -0000	1.13
+++ gameDetector.cpp	30 Sep 2002 00:55:47 -0000	1.14
@@ -70,6 +70,59 @@
 	"\t-y         - set text speed (default: 60)\n"
 ;
 
+
+GameDetector::GameDetector()
+{
+	_fullScreen = false;
+	_gameId = 0;
+
+	_use_adlib = false;
+
+	_music_volume = kDefaultMusicVolume;
+	_sfx_volume = kDefaultSFXVolume;
+	_amiga = false;
+
+	_talkSpeed = 60;
+	_debugMode = 0;
+	_noSubtitles = false;
+	_bootParam = 0;
+	_soundCardType = 3;
+
+	_gameDataPath = 0;
+	_gameTempo = 0;
+	_midi_driver = MD_AUTO;
+	_gameText = 0;
+	_features = 0;
+
+	_cdrom = 0;
+	_save_slot = 0;
+	
+	_saveconfig = false;
+	
+#ifndef _WIN32_WCE
+	_gfx_mode = GFX_DOUBLESIZE;
+#else
+	_gfx_mode = GFX_NORMAL;
+#endif
+
+#if defined(USE_NULL_DRIVER)
+	_gfx_driver = GD_NULL;
+#elif defined(__DC__)
+	_gfx_driver = GD_DC;
+#elif defined(X11_BACKEND)
+	_gfx_driver = GD_X;
+#elif defined(__MORPHOS__)
+	_gfx_driver = GD_MORPHOS;
+#elif defined(_WIN32_WCE)
+	_gfx_driver = GD_WINCE;
+#elif defined(MACOS_CARBON)
+	_gfx_driver = GD_MAC;
+#else
+	/* SDL is the default driver for now */
+	_gfx_driver = GD_SDL;
+#endif
+}
+
 void GameDetector::updateconfig()
 {
 	const char * val;
@@ -247,11 +300,7 @@
 			}
 		} else {
 			if (i == (argc - 1)) {
-				_exe_name = s;
-				g_config->set_domain(s);
-				g_config->rename_domain("game-specific");
-				g_config->rename_domain(s);
-				updateconfig();
+				setGame(s);
 			} else {
 				if (current_option == NULL)
 					current_option = s;
@@ -261,7 +310,7 @@
 		}
 	}
 	
-	if (_exe_name)
+	if (!_gameFileName.isEmpty())
 		g_config->flush();
 
 	return;
@@ -271,6 +320,15 @@
 	exit(1);
 }
 
+void GameDetector::setGame(const String &name)
+{
+	_gameFileName = name;
+	g_config->set_domain(name);
+	g_config->rename_domain("game-specific");
+	g_config->rename_domain(name);
+	updateconfig();
+}
+
 int GameDetector::parseGraphicsMode(const char *s) {
 	struct GraphicsModes {
 		const char *name;
@@ -429,7 +487,7 @@
 	_gameId = 0;
 	_gameText = NULL;
 	do {
-		if (!scumm_stricmp(_exe_name, gnl->filename)) {
+		if (!scumm_stricmp(_gameFileName.c_str(), gnl->filename)) {
 			_gameId = gnl->id;
 
 			_features = gnl->features;
@@ -449,73 +507,18 @@
 {
 	if (_gameText == NULL) {
 		char buf[256];
-		sprintf(buf, "Unknown game: \"%s\"", _exe_name);
+		sprintf(buf, "Unknown game: \"%s\"", _gameFileName.c_str());
 		_gameText = strdup(buf);
 	}
 	return _gameText;
 }
 
-int GameDetector::detectMain(int argc, char **argv)
+int GameDetector::detectMain()
 {
-	_debugMode = 0;								// off by default...
-
-	_noSubtitles = 0;							// use by default - should this depend on soundtrack?
-
-	_talkSpeed = 60;
-	
-#ifndef _WIN32_WCE
-	_gfx_mode = GFX_DOUBLESIZE;
-#else
-	_gfx_mode = GFX_NORMAL;
-#endif
-	_sfx_volume = kDefaultSFXVolume;
-	_music_volume = kDefaultMusicVolume;
-
-#if defined(USE_NULL_DRIVER)
-	_gfx_driver = GD_NULL;
-#elif defined(__DC__)
-	_gfx_driver = GD_DC;
-#elif defined(X11_BACKEND)
-	_gfx_driver = GD_X;
-#elif defined(__MORPHOS__)
-	_gfx_driver = GD_MORPHOS;
-#elif defined(_WIN32_WCE)
-	_gfx_driver = GD_WINCE;
-#elif defined(MACOS_CARBON)
-	_gfx_driver = GD_MAC;
-#else
-	/* SDL is the default driver for now */
-	_gfx_driver = GD_SDL;
-#endif
-
-	_gameDataPath = NULL;
-	_gameTempo = 0;
-	_soundCardType = 3;
-
-
-
-	_midi_driver = MD_AUTO;
-
-#if defined(__DC__)
-	extern int dc_setup(GameDetector &detector);
-	dc_setup(*this);
-#elif defined(MACOS_CARBON)
-	extern char* SelectGame();
-	char *game_name = SelectGame();
-	printf(game_name);
-#else
-	_saveconfig = false;
-	updateconfig();
-	parseCommandLine(argc, argv);	
-#endif
-
-	if (_exe_name == NULL) {
-		//launcherLoop();
-		//setWindowName(this);
+	if (_gameFileName.isEmpty()) {
 		warning("No game was specified...");
 		return (-1);
 	}
-
 
 	if (!detectGame()) {
 		warning("Game detection failed. Using default settings");

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gameDetector.h	29 Sep 2002 23:09:01 -0000	1.4
+++ gameDetector.h	30 Sep 2002 00:55:47 -0000	1.5
@@ -23,6 +23,8 @@
 #ifndef GAMEDETECTOR_H
 #define GAMEDETECTOR_H
 
+#include "common/str.h"
+
 class OSystem;
 class MidiDriver;
 
@@ -37,15 +39,20 @@
 
 
 class GameDetector {
+	typedef ScummVM::String String;
+protected:
+	bool detectGame(void);
+
 public:
-	int detectMain(int argc, char **argv);
+	GameDetector();
+	
 	void parseCommandLine(int argc, char **argv);
-	bool detectGame(void);
+	int detectMain();
+	void setGame(const String &name);
 	const char *getGameName(void);
 
 	bool _fullScreen;
 	byte _gameId;
-	bool _simon;
 
 	bool _use_adlib;
 
@@ -55,14 +62,14 @@
 
 	uint16 _talkSpeed;
 	uint16 _debugMode;
-	uint16 _noSubtitles;
+	bool _noSubtitles;
 	uint16 _bootParam;
 	uint16 _soundCardType;
 
 	char *_gameDataPath;
 	int _gameTempo;
 	int _midi_driver;
-	char *_exe_name;
+	String _gameFileName;
 	const char *_gameText;
 	uint32 _features;
 

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/main.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- main.cpp	29 Sep 2002 23:06:41 -0000	1.11
+++ main.cpp	30 Sep 2002 00:55:47 -0000	1.12
@@ -28,8 +28,6 @@
 #include "gui/launcher.h"
 #include "gui/message.h"
 
-GameDetector detector;
-
 Config *g_config = 0;
 NewGui *g_gui = 0;
 
@@ -97,9 +95,55 @@
 
 #endif
 
+static void launcherDialog(GameDetector &detector, OSystem *system)
+{
+	// FIXME - we need to call init_size() 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);
+	
+	// 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
+	// want to add a set_mouse_cursor_overlay() method to OSystem, which would serve
+	// two purposes:
+	// 1) allow for 16 bit mouse cursors in overlay mode
+	// 2) no need to backup & restore the mouse cursor before/after the overlay is shown
+	const byte dummy_palette[] = {
+		0, 0, 0, 0, 
+		0, 0, 171, 0, 
+		0, 171, 0, 0, 
+		0, 171, 171, 0, 
+		171, 0, 0, 0, 
+		171, 0, 171, 0, 
+		171, 87, 0, 0, 
+		171, 171, 171, 0, 
+		87, 87, 87, 0, 
+		87, 87, 255, 0, 
+		87, 255, 87, 0, 
+		87, 255, 255, 0, 
+		255, 87, 87, 0, 
+		255, 87, 255, 0, 
+		255, 255, 87, 0, 
+		255, 255, 255, 0, 
+	};
+
+	system->set_palette(dummy_palette, 0, 16);
+
+	// FIXME - hack we use because LauncherDialog accesses g_system
+	extern OSystem *g_system;
+	g_system = system;
+
+	Dialog *dlg = new LauncherDialog(g_gui, detector);
+	dlg->open();
+	g_gui->runLoop();
+	delete dlg;
+}
+
 int main(int argc, char *argv[])
 {
-	int result;
+	GameDetector detector;
 #ifdef __DC__
 	extern void dc_init_hardware();
 	dc_init_hardware();
@@ -129,78 +173,36 @@
 	g_config->set("versioninfo", SCUMMVM_VERSION);
 	
 	// Parse the command line information
-	result = detector.detectMain(argc, argv);
+#if defined(__DC__)
+	extern int dc_setup(GameDetector &detector);
+	dc_setup(detector);
+#else
+	detector._saveconfig = false;
+	detector.updateconfig();
+	detector.parseCommandLine(argc, argv);	
+#endif
 
 	// Create the system object
 	OSystem *system = detector.createSystem();
 
-	// TODO - if detectMain() returns an error, fire up the launcher dialog
-	// TODO - implement the launcher dialog; also implement some sort of generic
-	//        error dialog, to be used by the launcher if e.g. the game data can't
-	//        be found.
-	if (result) {
+	// Create the GUI manager
+	// TODO - move this up for the launcher dialog?
+	g_gui = new NewGui(system);
+
+	// Unless a game was specified, show the launcher dialog
+	if (detector._gameFileName.isEmpty())
+		launcherDialog(detector, system);
+
+	// Verify the given game name
+	if (detector.detectMain()) {
 		system->quit();
 		return (-1);
 	}
-
+	
 	// Set the window caption (for OSystems that support it)
 	OSystem::Property prop;
 	prop.caption = (char *)detector.getGameName();
 	system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
-
-	// Create the GUI manager
-	// TODO - move this up for the launcher dialog?
-	g_gui = new NewGui(system);
-
-#if 0
-	// FIXME - we need to call init_size() 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);
-	
-	// 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
-	// want to add a set_mouse_cursor_overlay() method to OSystem, which would serve
-	// two purposes:
-	// 1) allow for 16 bit mouse cursors in overlay mode
-	// 2) no need to backup & restore the mouse cursor before/after the overlay is shown
-	const byte dummy_palette[] = {
-		0, 0, 0, 0, 
-		0, 0, 171, 0, 
-		0, 171, 0, 0, 
-		0, 171, 171, 0, 
-		171, 0, 0, 0, 
-		171, 0, 171, 0, 
-		171, 87, 0, 0, 
-		171, 171, 171, 0, 
-		87, 87, 87, 0, 
-		87, 87, 255, 0, 
-		87, 255, 87, 0, 
-		87, 255, 255, 0, 
-		255, 87, 87, 0, 
-		255, 87, 255, 0, 
-		255, 255, 87, 0, 
-		255, 255, 255, 0, 
-	};
-
-	system->set_palette(dummy_palette, 0, 16);
-
-#if 1
-	extern OSystem *g_system;
-	g_system = system;
-	Dialog *dlg = new LauncherDialog(g_gui);
-#else
-	const char *message = "This dialog is shown before the\n"
-						  "Engine obejct is even created.\n"
-						  "Wow! Ain't we cool?\n";
-	Dialog *dlg = new MessageDialog(g_gui, message);
-#endif
-	dlg->open();
-	g_gui->runLoop();
-	delete dlg;
-#endif
 
 	// Create the game engine
 	Engine *engine = Engine::createFromDetector(&detector, system);





More information about the Scummvm-git-logs mailing list