diff --git a/doc/man/wesnoth.6 b/doc/man/wesnoth.6 index 38779ddc52cc..400b164ec4c1 100644 --- a/doc/man/wesnoth.6 +++ b/doc/man/wesnoth.6 @@ -226,6 +226,9 @@ or or .BR --plugin . .TP +.B --nobanner +suppress the startup banner. +.TP .B --nomusic runs the game without music. .TP diff --git a/src/commandline_options.cpp b/src/commandline_options.cpp index 14b6383cde38..44f74537089b 100644 --- a/src/commandline_options.cpp +++ b/src/commandline_options.cpp @@ -107,6 +107,7 @@ commandline_options::commandline_options(const std::vector& args) , nocache(false) , nodelay(false) , nogui(false) + , nobanner(false) , nomusic(false) , nosound(false) , new_widgets(false) @@ -280,6 +281,7 @@ commandline_options::commandline_options(const std::vector& args) ("unit,u", po::value>(), "runs a unit test scenario. The GUI is not shown and the exit code of the program reflects the victory / defeat conditions of the scenario.\n\t0 - PASS\n\t1 - FAIL\n\t3 - FAIL (INVALID REPLAY)\n\t4 - FAIL (ERRORED REPLAY)\n\t5 - FAIL (BROKE STRICT)\n\t6 - FAIL (WML EXCEPTION)\n\tMultiple tests can be run by giving this option multiple times, in this case the test run will stop immediately after any test which doesn't PASS and the return code will be the status of the test that caused the stop.") ("showgui", "don't run headlessly (for debugging a failing test)") ("log-strict", po::value(), "sets the strict level of the logger. any messages sent to log domains of this level or more severe will cause the unit test to fail regardless of the victory result.") + ("nobanner", "suppress startup banner.") ("noreplaycheck", "don't try to validate replay of unit test.") ("mp-test", "load the test mp scenarios.") ; @@ -422,6 +424,8 @@ commandline_options::commandline_options(const std::vector& args) nosound = true; if (vm.count("nogui")) nogui = true; + if (vm.count("nobanner")) + nobanner = true; if (vm.count("parm")) multiplayer_parm = parse_to_uint_string_string_tuples_(vm["parm"].as>()); if (vm.count("preprocess")) diff --git a/src/commandline_options.hpp b/src/commandline_options.hpp index 8654e3714682..c9072ea868a4 100644 --- a/src/commandline_options.hpp +++ b/src/commandline_options.hpp @@ -145,6 +145,8 @@ class commandline_options bool nodelay; /** True if --nogui was given on the command line. Disables GUI. */ bool nogui; + /** True if --nobanner was given on the command line. Disables startup banner. */ + bool nobanner; /** True if --nomusic was given on the command line. Disables music. */ bool nomusic; /** True if --nosound was given on the command line. Disables sound. */ diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index 25a397059701..6ad83bd2e5ce 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -261,13 +261,15 @@ game_launcher::game_launcher(const commandline_options& cmdline_opts) if(cmdline_opts_.translation_percent) set_min_translation_percent(*cmdline_opts_.translation_percent); - std::cerr - << "\nData directory: " << filesystem::sanitize_path(game_config::path) - << "\nUser configuration directory: " << filesystem::sanitize_path(filesystem::get_user_config_dir()) - << "\nUser data directory: " << filesystem::sanitize_path(filesystem::get_user_data_dir()) - << "\nCache directory: " << filesystem::sanitize_path(filesystem::get_cache_dir()) - << '\n'; - std::cerr << '\n'; + if(!cmdline_opts.nobanner) { + std::cerr + << "\nData directory: " << filesystem::sanitize_path(game_config::path) + << "\nUser configuration directory: " << filesystem::sanitize_path(filesystem::get_user_config_dir()) + << "\nUser data directory: " << filesystem::sanitize_path(filesystem::get_user_data_dir()) + << "\nCache directory: " << filesystem::sanitize_path(filesystem::get_cache_dir()) + << '\n'; + std::cerr << '\n'; + } // disable sound in nosound mode, or when sound engine failed to initialize if(no_sound || ((preferences::sound_on() || preferences::music_on() || @@ -341,7 +343,7 @@ bool game_launcher::init_lua_script() { bool error = false; - std::cerr << "Checking lua scripts... "; + if(!cmdline_opts_.nobanner) std::cerr << "Checking lua scripts... "; if(cmdline_opts_.script_unsafe_mode) { // load the "package" package, so that scripts can get what packages they want @@ -421,7 +423,7 @@ bool game_launcher::init_lua_script() } } - if(!error) { + if(!error && !cmdline_opts_.nobanner) { std::cerr << "ok\n"; } diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index 946f804cbb3b..4a7bd4220823 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -406,7 +406,7 @@ static int process_command_args(const commandline_options& cmdline_opts) } game_config::path = filesystem::normalize_path(game_config::path, true, true); - std::cerr << "Overriding data directory with " << game_config::path << std::endl; + if(!cmdline_opts.nobanner) std::cerr << "Overriding data directory with " << game_config::path << std::endl; if(!filesystem::is_directory(game_config::path)) { std::cerr << "Could not find directory '" << game_config::path << "'\n"; @@ -962,6 +962,15 @@ int main(int argc, char** argv) { auto args = read_argv(argc, argv); assert(!args.empty()); + + // --nobanner needs to be detected before the main command-line parsing happens + bool nobanner = false; + for(const auto& arg : args) { + if(arg == "--nobanner") { + nobanner = true; + break; + } + } #ifdef _WIN32 // Some switches force a Windows console to be attached to the process even @@ -1032,9 +1041,11 @@ int main(int argc, char** argv) SDL_StartTextInput(); try { - std::cerr << "Battle for Wesnoth v" << game_config::revision << " " << game_config::build_arch() << '\n'; - const std::time_t t = std::time(nullptr); - std::cerr << "Started on " << ctime(&t) << "\n"; + if(!nobanner) { + std::cerr << "Battle for Wesnoth v" << game_config::revision << " " << game_config::build_arch() << '\n'; + const std::time_t t = std::time(nullptr); + std::cerr << "Started on " << ctime(&t) << "\n"; + } const std::string& exe_dir = filesystem::get_exe_dir(); if(!exe_dir.empty()) { @@ -1060,7 +1071,7 @@ int main(int argc, char** argv) } if(!auto_dir.empty()) { - std::cerr << "Automatically found a possible data directory at " << filesystem::sanitize_path(auto_dir) << '\n'; + if(!nobanner) std::cerr << "Automatically found a possible data directory at " << filesystem::sanitize_path(auto_dir) << '\n'; game_config::path = auto_dir; } }