From 93559db3a2cfd1ae15d53900b782022e8c23642b Mon Sep 17 00:00:00 2001 From: Samuel Nicholas Date: Wed, 20 Mar 2024 00:11:09 +1030 Subject: [PATCH] Properly skip printing version header with `--no-header` Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- core/config/engine.cpp | 6 ++++++ core/config/engine.h | 1 + main/main.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/config/engine.cpp b/core/config/engine.cpp index d714ec42c2c..9f4bff37796 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -266,6 +266,12 @@ void Engine::print_header(const String &p_string) const { } } +void Engine::print_header_rich(const String &p_string) const { + if (_print_header) { + print_line_rich(p_string); + } +} + void Engine::add_singleton(const Singleton &p_singleton) { ERR_FAIL_COND_MSG(singleton_ptrs.has(p_singleton.name), vformat("Can't register singleton '%s' because it already exists.", p_singleton.name)); singletons.push_back(p_singleton); diff --git a/core/config/engine.h b/core/config/engine.h index be7cd62f663..d1495b36c2d 100644 --- a/core/config/engine.h +++ b/core/config/engine.h @@ -126,6 +126,7 @@ public: void set_print_error_messages(bool p_enabled); bool is_printing_error_messages() const; void print_header(const String &p_string) const; + void print_header_rich(const String &p_string) const; void set_frame_delay(uint32_t p_msec); uint32_t get_frame_delay() const; diff --git a/main/main.cpp b/main/main.cpp index 41f82177bc6..cf40f764cff 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -398,15 +398,15 @@ void Main::print_header(bool p_rich) { if (VERSION_TIMESTAMP > 0) { // Version timestamp available. if (p_rich) { - print_line_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - \u001b[4m" + String(VERSION_WEBSITE)); + Engine::get_singleton()->print_header_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - \u001b[4m" + String(VERSION_WEBSITE)); } else { - print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - " + String(VERSION_WEBSITE)); + Engine::get_singleton()->print_header(String(VERSION_NAME) + " v" + get_full_version_string() + " (" + Time::get_singleton()->get_datetime_string_from_unix_time(VERSION_TIMESTAMP, true) + " UTC) - " + String(VERSION_WEBSITE)); } } else { if (p_rich) { - print_line_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " - \u001b[4m" + String(VERSION_WEBSITE)); + Engine::get_singleton()->print_header_rich("\u001b[38;5;39m" + String(VERSION_NAME) + "\u001b[0m v" + get_full_version_string() + " - \u001b[4m" + String(VERSION_WEBSITE)); } else { - print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE)); + Engine::get_singleton()->print_header(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE)); } } }