diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index a34fd9204..e947a0157 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -60,8 +60,6 @@ #include #endif -#include - template class CApplyOnLobby; const std::string CServerHandler::localhostAddress{"127.0.0.1"}; @@ -655,14 +653,10 @@ void CServerHandler::endGameplay(bool closeConnection, bool restart) void CServerHandler::startCampaignScenario(std::shared_ptr cs) { - SDL_Event event; - event.type = SDL_USEREVENT; - event.user.code = static_cast(EUserEvent::CAMPAIGN_START_SCENARIO); if(cs) - event.user.data1 = CMemorySerializer::deepCopy(*cs.get()).release(); + GH.pushUserEvent(EUserEvent::CAMPAIGN_START_SCENARIO, CMemorySerializer::deepCopy(*cs.get()).release()); else - event.user.data1 = CMemorySerializer::deepCopy(*si->campState.get()).release(); - SDL_PushEvent(&event); + GH.pushUserEvent(EUserEvent::CAMPAIGN_START_SCENARIO, CMemorySerializer::deepCopy(*si->campState.get()).release()); } void CServerHandler::showServerError(std::string txt) diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index e98ebab85..77b1f1224 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -826,10 +826,16 @@ bool CGuiHandler::amIGuiThread() } void CGuiHandler::pushUserEvent(EUserEvent usercode) +{ + pushUserEvent(usercode, nullptr); +} + +void CGuiHandler::pushUserEvent(EUserEvent usercode, void * userdata) { SDL_Event event; event.type = SDL_USEREVENT; event.user.code = static_cast(usercode); + event.user.data1 = userdata; SDL_PushEvent(&event); } diff --git a/client/gui/CGuiHandler.h b/client/gui/CGuiHandler.h index d71d44e2a..b492378d5 100644 --- a/client/gui/CGuiHandler.h +++ b/client/gui/CGuiHandler.h @@ -177,6 +177,7 @@ public: static bool isArrowKey(SDL_Keycode key); static bool amIGuiThread(); static void pushUserEvent(EUserEvent usercode); + static void pushUserEvent(EUserEvent usercode, void * userdata); CondSh * terminate_cond; // confirm termination }; diff --git a/client/gui/CursorHandler.cpp b/client/gui/CursorHandler.cpp index 210e5aedf..ba340298d 100644 --- a/client/gui/CursorHandler.cpp +++ b/client/gui/CursorHandler.cpp @@ -21,13 +21,6 @@ #include "../../lib/CConfigHandler.h" -#include -#include - -#ifdef VCMI_APPLE -#include -#endif - std::unique_ptr CursorHandler::createCursor() { if (settings["video"]["cursor"].String() == "auto") @@ -254,18 +247,6 @@ std::shared_ptr CursorHandler::getCurrentImage() return cursors[static_cast(type)]->getImage(frame); } -void CursorHandler::centerCursor() -{ - Point screenSize {screen->w, screen->h}; - pos = screenSize / 2 - getPivotOffset(); - - SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); - GH.moveCursorToPosition(pos); - SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); - - cursor->setCursorPosition(pos); -} - void CursorHandler::updateSpellcastCursor() { static const float frameDisplayDuration = 0.1f; // H3 uses 100 ms per frame diff --git a/client/gui/CursorHandler.h b/client/gui/CursorHandler.h index 1b5cede0b..69c09275f 100644 --- a/client/gui/CursorHandler.h +++ b/client/gui/CursorHandler.h @@ -178,7 +178,4 @@ public: /// change cursor's positions to (x, y) void cursorMove(const int & x, const int & y); - /// Move cursor to screen center - void centerCursor(); - };