From 85a985cd7fa6592ec09d34b858ed6c5a7ce16f3b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 30 Sep 2023 13:52:20 -0500 Subject: [PATCH 1/2] Expose Main Window to c# through Screen class. --- Source/Engine/Engine/Screen.cpp | 9 +++++++++ Source/Engine/Engine/Screen.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp index 2bc6e1f58..207d6a87c 100644 --- a/Source/Engine/Engine/Screen.cpp +++ b/Source/Engine/Engine/Screen.cpp @@ -181,6 +181,15 @@ void Screen::SetGameWindowMode(GameWindowMode windowMode) #endif } +Window* Screen::GetMainWindow() +{ + Window* win = nullptr; +#if !USE_EDITOR + win = Engine::MainWindow; +#endif + return win; +} + void ScreenService::Update() { #if USE_EDITOR diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index 42be20a38..7785ee7b3 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -96,4 +96,10 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen); /// /// The window mode. API_PROPERTY() static void SetGameWindowMode(GameWindowMode windowMode); + + /// + /// Gets the main window. Only during built game. + /// + /// The current window. Will be null if fails. + API_PROPERTY() static Window* GetMainWindow(); }; From 113307ddf9e52128added38793c74bd9784f0895 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 30 Sep 2023 21:36:41 -0500 Subject: [PATCH 2/2] Simplify to return main window even in editor. --- Source/Engine/Engine/Screen.cpp | 6 +----- Source/Engine/Engine/Screen.h | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp index 207d6a87c..fc7e8a022 100644 --- a/Source/Engine/Engine/Screen.cpp +++ b/Source/Engine/Engine/Screen.cpp @@ -183,11 +183,7 @@ void Screen::SetGameWindowMode(GameWindowMode windowMode) Window* Screen::GetMainWindow() { - Window* win = nullptr; -#if !USE_EDITOR - win = Engine::MainWindow; -#endif - return win; + return Engine::MainWindow; } void ScreenService::Update() diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index 7785ee7b3..b7bd89c38 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -98,7 +98,7 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen); API_PROPERTY() static void SetGameWindowMode(GameWindowMode windowMode); /// - /// Gets the main window. Only during built game. + /// Gets the main window. /// /// The current window. Will be null if fails. API_PROPERTY() static Window* GetMainWindow();