From: James Turner Date: Sat, 26 Oct 2013 20:06:03 +0000 (+0100) Subject: Window console changes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6bd2acab78a7b3d497e64a91b5b9c922f2204ce6;p=flightgear.git Window console changes - 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. --- diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 338a9f6d4..07dd49ec2 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -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}") diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 5353dca7c..1c39233f4 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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; diff --git a/src/Main/options.cxx b/src/Main/options.cxx index cee21855c..9914e9e5a 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -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 \