Added --force-console option to force the creation of a console on Windows.

This is to make Godot logging visible when debugging C# script projects using Visual Studio.
This commit is contained in:
Neutrino-Sunset 2024-08-09 18:48:11 +01:00
parent 3978628c6c
commit 8acec39fb2
4 changed files with 12 additions and 0 deletions

View File

@ -341,6 +341,8 @@ public:
// This is invoked by the GDExtensionManager after loading GDExtensions specified by the project.
virtual void load_platform_gdextensions() const {}
virtual void alloc_console() {}
OS();
virtual ~OS();
};

View File

@ -583,6 +583,8 @@ void Main::print_help(const char *p_binary) {
print_help_option("", "--fixed-fps is forced when enabled, but it can be used to change movie FPS.\n");
print_help_option("", "--disable-vsync can speed up movie writing but makes interaction more difficult.\n");
print_help_option("", "--quit-after can be used to specify the number of frames to write.\n");
print_help_option("--force-console", "Force creation of console window on Windows.\n");
print_help_option("", "Enables viewing of Godot logging when debugging a C# project with Visual Studio.\n");
print_help_title("Display options");
print_help_option("-f, --fullscreen", "Request fullscreen mode.\n");
@ -1669,6 +1671,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing write-movie argument, aborting.\n");
goto error;
}
} else if (arg == "--force-console") {
OS::get_singleton()->alloc_console();
} else if (arg == "--disable-vsync") {
disable_vsync = true;
} else if (arg == "--print-fps") {

View File

@ -1898,6 +1898,10 @@ String OS_Windows::get_system_ca_certificates() {
return certs;
}
void OS_Windows::alloc_console() {
AllocConsole();
}
OS_Windows::OS_Windows(HINSTANCE _hInstance) {
hInstance = _hInstance;

View File

@ -238,6 +238,8 @@ public:
void set_main_window(HWND p_main_window) { main_window = p_main_window; }
virtual void alloc_console() override;
HINSTANCE get_hinstance() { return hInstance; }
OS_Windows(HINSTANCE _hInstance);
~OS_Windows();