|
From: <cn...@us...> - 2009-08-22 20:21:27
|
Revision: 512
http://hgengine.svn.sourceforge.net/hgengine/?rev=512&view=rev
Author: cnlohr
Date: 2009-08-22 20:21:08 +0000 (Sat, 22 Aug 2009)
Log Message:
-----------
add command line parameters to Mercury
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-08-22 19:46:34 UTC (rev 511)
+++ Mercury2/src/Mercury2.cpp 2009-08-22 20:21:08 UTC (rev 512)
@@ -46,12 +46,59 @@
return 0; //Continue regular crash.
}
-int main()
+MString g_SceneGraphToLoad;
+void HandleCommandLineParameters( int argc, char ** argv )
{
+ bool bPrintHelp = false;
+ for( int i = 1; i < argc; i++ )
+ {
+ MString sParameter = argv[i];
+ if( sParameter == "--help" || sParameter == "-h" )
+ bPrintHelp = true;
+ else if( sParameter.find( "--scenegraph=" ) == 0 )
+ g_SceneGraphToLoad = sParameter.substr( 13 );
+ else if( sParameter == "-s" )
+ {
+ i++;
+ if( i >= argc )
+ {
+ fprintf( stderr, "No scene graph following -s. Type -h for help.\n" );
+ exit(-1);
+ }
+ g_SceneGraphToLoad = argv[i];
+ }
+ else
+ {
+ fprintf( stderr, "Unknown command-line parameter: \"%s\" Type -h for help.\n", argv[i] );
+ exit(-1);
+ }
+ }
+
+ if( bPrintHelp )
+ {
+ printf( "\nMercury Game Engine 2.0 Copyright 2009 Joshua Allen and\n" );
+ printf( " Charles Lohr under the NewBSD license. Code contributed\n" );
+ printf( " from other sources under the same license, contributers\n" );
+ printf( " and other sources may be found in accompanying documents.\n" );
+ printf( "\n Usage: [mercury] [command-line parameters]\n\n" );
+ printf( " [--scenegraph=x] | [-s x] Select scene graph to use.\n" );
+ printf( " By default Mercury uses FILE:scenegraph.xml. You may\n" );
+ printf( " specify another one here. This only changes the startup\n" );
+ printf( " scene graph for debugging purposes.\n\n" );
+ exit(0);
+ }
+}
+
+int main( int argc, char** argv)
+{
unsigned long m_count = 0;
+ g_SceneGraphToLoad = "FILE:scenegraph.xml";
+
cnset_execute_on_crash( SignalHandler );
+ HandleCommandLineParameters( argc, argv );
+
MercuryWindow* w = MercuryWindow::MakeWindow();
#ifdef WIN32
@@ -62,7 +109,7 @@
MercuryNode* root = new MercuryNode();
- XMLDocument* doc = XMLDocument::Load("FILE:scenegraph.xml");
+ XMLDocument* doc = XMLDocument::Load(g_SceneGraphToLoad);
XMLNode r = doc->GetRootNode();
root->LoadFromXML( r );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|