Handle mouse center/visible when editor play/pause/stop

This commit is contained in:
Sri Sham Haran 2023-03-05 21:24:16 +08:00
parent 9f57ed1ef1
commit 77e3fe376b
2 changed files with 9 additions and 1 deletions

View File

@ -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<SHEditorStateChangeEvent>(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<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);

View File

@ -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";