diff --git a/source/ps/VideoMode.cpp b/source/ps/VideoMode.cpp index 6748bc72b3..bc2a73e883 100644 --- a/source/ps/VideoMode.cpp +++ b/source/ps/VideoMode.cpp @@ -963,6 +963,11 @@ SDL_Window* CVideoMode::GetWindow() return m_Window; } +bool CVideoMode::IsInitialized() const +{ + return m_IsInitialised; +} + void CVideoMode::SetWindowIcon() { // The window icon should be kept outside of art/textures/, or else it will be converted diff --git a/source/ps/VideoMode.h b/source/ps/VideoMode.h index 136350fc94..bec23f9da3 100644 --- a/source/ps/VideoMode.h +++ b/source/ps/VideoMode.h @@ -95,6 +95,7 @@ public: int GetBPP() const; bool IsVSyncEnabled() const; + bool IsInitialized() const; int GetDesktopXRes() const; int GetDesktopYRes() const; diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index ea01c8cb5b..1a28e2c32e 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -118,6 +118,9 @@ MESSAGEHANDLER(GuiSwitchPage) MESSAGEHANDLER(GuiMouseButtonEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; ev.button.button = msg->button; @@ -132,6 +135,9 @@ MESSAGEHANDLER(GuiMouseButtonEvent) MESSAGEHANDLER(GuiMouseMotionEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = SDL_MOUSEMOTION; float x, y; @@ -143,6 +149,9 @@ MESSAGEHANDLER(GuiMouseMotionEvent) MESSAGEHANDLER(GuiKeyEvent) { + if (!g_VideoMode.IsInitialized()) + return; + SDL_Event ev{}; ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; ev.key.keysym.sym = static_cast(static_cast(msg->sdlkey)); @@ -152,6 +161,9 @@ MESSAGEHANDLER(GuiKeyEvent) MESSAGEHANDLER(GuiCharEvent) { + if (!g_VideoMode.IsInitialized()) + return; + // Simulate special 'text input' events in the SDL // This isn't quite compatible with WXWidget's handling, // so to avoid trouble we only send 'letter-like' ASCII input.