diff --git a/client/adventureMap/CInGameConsole.cpp b/client/adventureMap/CInGameConsole.cpp index 1f98ace1c..bf92d66c4 100644 --- a/client/adventureMap/CInGameConsole.cpp +++ b/client/adventureMap/CInGameConsole.cpp @@ -24,7 +24,6 @@ #include "../../lib/mapObjects/CArmedInstance.h" #include -#include CInGameConsole::CInGameConsole() : CIntObject(KEYBOARD | TEXTINPUT), @@ -176,19 +175,19 @@ void CInGameConsole::keyPressed (const SDL_Keycode & key) } } -void CInGameConsole::textInputed(const SDL_TextInputEvent & event) +void CInGameConsole::textInputed(const std::string & inputtedText) { if(!captureAllKeys || enteredText.size() == 0) return; enteredText.resize(enteredText.size()-1); - enteredText += event.text; + enteredText += inputtedText; enteredText += "_"; refreshEnteredText(); } -void CInGameConsole::textEdited(const SDL_TextEditingEvent & event) +void CInGameConsole::textEdited(const std::string & inputtedText) { //do nothing here } diff --git a/client/adventureMap/CInGameConsole.h b/client/adventureMap/CInGameConsole.h index c6c9f0802..5d52b4fd4 100644 --- a/client/adventureMap/CInGameConsole.h +++ b/client/adventureMap/CInGameConsole.h @@ -28,8 +28,8 @@ public: void print(const std::string &txt); void keyPressed(const SDL_Keycode & key) override; - void textInputed(const SDL_TextInputEvent & event) override; - void textEdited(const SDL_TextEditingEvent & event) override; + void textInputed(const std::string & enteredText) override; + void textEdited(const std::string & enteredText) override; void startEnteringText(); void endEnteringText(bool processEnteredText); diff --git a/client/gui/CGuiHandler.cpp b/client/gui/CGuiHandler.cpp index 9817cd3c6..23da35cbe 100644 --- a/client/gui/CGuiHandler.cpp +++ b/client/gui/CGuiHandler.cpp @@ -487,14 +487,14 @@ void CGuiHandler::handleCurrentEvent( SDL_Event & current ) { for(auto it : textInterested) { - it->textInputed(current.text); + it->textInputed(current.text.text); } } else if(current.type == SDL_TEXTEDITING) { for(auto it : textInterested) { - it->textEdited(current.edit); + it->textEdited(current.edit.text); } } else if(current.type == SDL_MOUSEBUTTONUP) diff --git a/client/gui/CIntObject.h b/client/gui/CIntObject.h index ea9589f4e..80017d32b 100644 --- a/client/gui/CIntObject.h +++ b/client/gui/CIntObject.h @@ -18,8 +18,6 @@ class CGuiHandler; class CPicture; typedef int32_t SDL_Keycode; -struct SDL_TextInputEvent; -struct SDL_TextEditingEvent; using boost::logic::tribool; @@ -123,8 +121,8 @@ public: virtual void keyReleased(const SDL_Keycode & key){} virtual bool captureThisKey(const SDL_Keycode & key); //allows refining captureAllKeys against specific events (eg. don't capture ENTER) - virtual void textInputed(const SDL_TextInputEvent & event){}; - virtual void textEdited(const SDL_TextEditingEvent & event){}; + virtual void textInputed(const std::string & enteredText){}; + virtual void textEdited(const std::string & enteredText){}; //mouse movement handling bool strongInterest; //if true - report all mouse movements, if not - only when hovered diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index a4e812347..e505256d7 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -52,7 +52,7 @@ #include "../../lib/CondSh.h" #include "../../lib/mapping/CCampaignHandler.h" -#include +#include namespace fs = boost::filesystem; @@ -61,9 +61,7 @@ ISelectionScreenInfo * SEL; static void do_quit() { - SDL_Event event; - event.quit.type = SDL_QUIT; - SDL_PushEvent(&event); + GH.pushUserEvent(EUserEvent::FORCE_QUIT); } CMenuScreen::CMenuScreen(const JsonNode & configNode) diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index 1defe586f..4d74e3649 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -23,8 +23,6 @@ #include "lib/CAndroidVMHelper.h" #endif -#include - std::list CFocusable::focusables; CFocusable * CFocusable::inputWithFocus; @@ -610,13 +608,13 @@ bool CTextInput::captureThisKey(const SDL_Keycode & key) return true; } -void CTextInput::textInputed(const SDL_TextInputEvent & event) +void CTextInput::textInputed(const std::string & enteredText) { if(!focus) return; std::string oldText = text; - text += event.text; + text += enteredText; filters(text, oldText); if(text != oldText) @@ -627,12 +625,12 @@ void CTextInput::textInputed(const SDL_TextInputEvent & event) newText.clear(); } -void CTextInput::textEdited(const SDL_TextEditingEvent & event) +void CTextInput::textEdited(const std::string & enteredText) { if(!focus) return; - newText = event.text; + newText = enteredText; redraw(); cb(text + newText); } diff --git a/client/widgets/TextControls.h b/client/widgets/TextControls.h index 405c350be..2de2453ed 100644 --- a/client/widgets/TextControls.h +++ b/client/widgets/TextControls.h @@ -229,8 +229,8 @@ public: bool captureThisKey(const SDL_Keycode & key) override; - void textInputed(const SDL_TextInputEvent & event) override; - void textEdited(const SDL_TextEditingEvent & event) override; + void textInputed(const std::string & enteredText) override; + void textEdited(const std::string & enteredText) override; //Filter that will block all characters not allowed in filenames static void filenameFilter(std::string & text, const std::string & oldText);