]> git.mxchange.org Git - flightgear.git/commitdiff
Window console changes
authorJames Turner <zakalawe@mac.com>
Sat, 26 Oct 2013 20:06:03 +0000 (21:06 +0100)
committerJames Turner <zakalawe@mac.com>
Sat, 26 Oct 2013 20:07:23 +0000 (21:07 +0100)
- default to SUBSYSTEM:WINDOWS (we can still AllocConsole if needed)
- add --console option to get a console on Windows
- ensure --show-aircraft and --help modes show the console automatically.

src/Main/CMakeLists.txt
src/Main/fg_init.cxx
src/Main/options.cxx

index 338a9f6d4fbaad94f3d0b81e36fc5071889d473b..07dd49ec2978f5d0dd0a1387ba4a3ecdf84edeb7 100644 (file)
@@ -67,7 +67,11 @@ endforeach()
 
 source_group("Main\\Headers" FILES ${HEADERS})
 source_group("Main\\Sources" FILES ${SOURCES})
-add_executable(fgfs ${SOURCES} ${FG_SOURCES} ${FG_HEADERS} ${HEADERS})
+
+# important we pass WIN32 here so the console is optional. Other
+# platforms ignore this option. If a console is needed we allocate
+# it manually via AllocConsole()
+add_executable(fgfs WIN32 ${SOURCES} ${FG_SOURCES} ${FG_HEADERS} ${HEADERS})
 
 get_property(FG_LIBS GLOBAL PROPERTY FG_LIBS)
 #message(STATUS "fg libs ${FG_LIBS}")
index 5353dca7c8c7fc22e03f23891fb60e041b3b37a7..1c39233f4fd75d45a79c100ed35742ce7792c14c 100644 (file)
@@ -919,8 +919,9 @@ public:
   {
     fgFindAircraftInDir(path, this, &ShowAircraft::processAircraft);
   
+       simgear::requestConsole(); // ensure console is shown on Windows
+
     std::sort(_aircraft.begin(), _aircraft.end(), ciLessLibC());
-    SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on Windows
     cout << "Available aircraft:" << endl;
     for ( unsigned int i = 0; i < _aircraft.size(); i++ ) {
         cout << _aircraft[i] << endl;
index cee21855ca5a922909fb88b1b4fe3910fbd3d0c0..9914e9e5ae61bfba0854434a68b1f3979c966fd0 100644 (file)
@@ -1305,6 +1305,7 @@ struct OptionDesc {
     } fgOptionArray[] = {
 
     {"language",                     true,  OPTION_IGNORE, "", false, "", 0 },
+       {"console",                      false, OPTION_IGNORE,   "", false, "", 0 },
     {"disable-rembrandt",            false, OPTION_BOOL,   "/sim/rendering/rembrandt/enabled", false, "", 0 },
     {"enable-rembrandt",             false, OPTION_BOOL,   "/sim/rendering/rembrandt/enabled", true, "", 0 },
     {"renderer",                     true,  OPTION_STRING, "/sim/rendering/rembrandt/renderer", false, "", 0 },
@@ -1896,6 +1897,9 @@ int Options::parseOption(const string& s)
   } else if ( (s == "--verbose") || (s == "-v") ) {
     // verbose help/usage request
     return FG_OPTIONS_VERBOSE_HELP;
+  } else if ((s == "--console") || (s == "-c")) {
+         simgear::requestConsole();
+         return FG_OPTIONS_OK;
   } else if (s.find("-psn") == 0) {
     // on Mac, when launched from the GUI, we are passed the ProcessSerialNumber
     // as an argument (and no others). Silently ignore the argument here.
@@ -2096,7 +2100,7 @@ void Options::showUsage() const
   FGLocale *locale = globals->get_locale();
   SGPropertyNode options_root;
   
-  SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on Windows
+  simgear::requestConsole(); // ensure console is shown on Windows
   cout << endl;
 
   try {
@@ -2288,7 +2292,8 @@ void Options::setupRoot()
   if ( !(base_version == required_version) ) {
     // tell the operator how to use this application
     
-    SG_LOG( SG_GENERAL, SG_ALERT, "" ); // To popup the console on windows
+    simgear::requestConsole(); // ensure console is shown on Windows
+
     cerr << endl << "Base package check failed:" << endl \
     << "  Version " << base_version << " found at: " \
     << globals->get_fg_root() << endl \