From 77e3fe376b44faf3eb1e128597907dcb8f2564d3 Mon Sep 17 00:00:00 2001 From: Sri Sham Haran Date: Sun, 5 Mar 2023 21:24:16 +0800 Subject: [PATCH] Handle mouse center/visible when editor play/pause/stop --- SHADE_Engine/src/Editor/SHEditor.cpp | 8 ++++++++ SHADE_Engine/src/Editor/SHEditor.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 6d71f98d..a17e4b53 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -55,6 +55,7 @@ #include "Scene/SHSceneManager.h" #include "Serialization/SHSerialization.h" #include "Tools/SHDebugDraw.h" +#include "Input/SHInputManager.h" RTTR_REGISTRATION { @@ -618,6 +619,8 @@ namespace SHADE } else if (editorState == State::PAUSE) { + + SHWindow::SetMouseVisible(prevCursorVisibleState); editorState = State::PLAY; } } @@ -631,6 +634,8 @@ namespace SHADE .previousState = editorState }; editorState = State::PAUSE; + SHInputManager::SetMouseCentering(false); + prevCursorVisibleState = SHWindow::GetMouseVisible(); SHEventManager::BroadcastEvent(STATE_CHANGE_EVENT, SH_EDITOR_ON_PAUSE_EVENT); } @@ -642,6 +647,9 @@ namespace SHADE { .previousState = editorState }; + SHWindow::SetMouseVisible(true); + prevCursorVisibleState = true; + SHInputManager::SetMouseCentering(false); editorState = SHEditor::State::STOP; SHCommandManager::SwapStacks(); SHEventManager::BroadcastEvent(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT); diff --git a/SHADE_Engine/src/Editor/SHEditor.h b/SHADE_Engine/src/Editor/SHEditor.h index 1cbc4f9d..a85a9c33 100644 --- a/SHADE_Engine/src/Editor/SHEditor.h +++ b/SHADE_Engine/src/Editor/SHEditor.h @@ -154,7 +154,7 @@ namespace SHADE SHEventHandle onEditorStateChanged(SHEventPtr eventPtr); bool isUnsavedChangesPromptOpen = false; - + bool prevCursorVisibleState = true; static constexpr std::string_view sceneNamePromptName = "Save scene as..."; static constexpr std::string_view unsavedChangesPromptName = "Unsaved Changes";