summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorLuka Dornhecker <luka.dornhecker@gmail.com>2018-12-18 14:17:43 +0100
committerRémi Verschelde <rverschelde@gmail.com>2019-06-20 16:55:52 +0200
commitad504b926f9a0cfabde78254f6a4b40901cb8592 (patch)
treed1b76baffd09ff75cd4edf75457de8bb1e5f8df0 /platform
parentd6f8a43b600cc5236c5860c8f266b6f8afc9c23c (diff)
Add option to toggle console window on Windows
This is an editor setting and its value can also be toggled using an entry in the Editor toolbar. The console will still appear briefly when starting the project manager or editor, as it's still compiled as console application. Does not impact exported games, which will still run without console in release and with console in debug mode. A project setting or export option could be added to disable it in debug mode if there's demand for it, but that would greatly reduce the usefulness of debug builds if Windows users can no longer report error and crash messages. Fixes #17889. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/windows/os_windows.cpp12
-rw-r--r--platform/windows/os_windows.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 6e6df08f02..5876a385c6 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1979,6 +1979,17 @@ bool OS_Windows::is_window_always_on_top() const {
return video_mode.always_on_top;
}
+void OS_Windows::set_console_visible(bool p_enabled) {
+ if (console_visible == p_enabled)
+ return;
+ ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE);
+ console_visible = p_enabled;
+}
+
+bool OS_Windows::is_console_visible() const {
+ return console_visible;
+}
+
bool OS_Windows::get_window_per_pixel_transparency_enabled() const {
if (!is_layered_allowed()) return false;
@@ -3231,6 +3242,7 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
control_mem = false;
meta_mem = false;
minimized = false;
+ console_visible = IsWindowVisible(GetConsoleWindow());
hInstance = _hInstance;
pressrc = 0;
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 4660c16b97..fc8ad1b188 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -210,6 +210,7 @@ protected:
bool maximized;
bool minimized;
bool borderless;
+ bool console_visible;
public:
LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -256,6 +257,8 @@ public:
virtual bool is_window_maximized() const;
virtual void set_window_always_on_top(bool p_enabled);
virtual bool is_window_always_on_top() const;
+ virtual void set_console_visible(bool p_enabled);
+ virtual bool is_console_visible() const;
virtual void request_attention();
virtual void set_borderless_window(bool p_borderless);