mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Remove remaining access to SDL_Events
This commit is contained in:
		| @@ -24,7 +24,6 @@ | |||||||
| #include "../../lib/mapObjects/CArmedInstance.h" | #include "../../lib/mapObjects/CArmedInstance.h" | ||||||
|  |  | ||||||
| #include <SDL_timer.h> | #include <SDL_timer.h> | ||||||
| #include <SDL_events.h> |  | ||||||
|  |  | ||||||
| CInGameConsole::CInGameConsole() | CInGameConsole::CInGameConsole() | ||||||
| 	: CIntObject(KEYBOARD | TEXTINPUT), | 	: 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) | 	if(!captureAllKeys || enteredText.size() == 0) | ||||||
| 		return; | 		return; | ||||||
| 	enteredText.resize(enteredText.size()-1); | 	enteredText.resize(enteredText.size()-1); | ||||||
|  |  | ||||||
| 	enteredText += event.text; | 	enteredText += inputtedText; | ||||||
| 	enteredText += "_"; | 	enteredText += "_"; | ||||||
|  |  | ||||||
| 	refreshEnteredText(); | 	refreshEnteredText(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CInGameConsole::textEdited(const SDL_TextEditingEvent & event) | void CInGameConsole::textEdited(const std::string & inputtedText) | ||||||
| { | { | ||||||
|  //do nothing here |  //do nothing here | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,8 +28,8 @@ public: | |||||||
| 	void print(const std::string &txt); | 	void print(const std::string &txt); | ||||||
| 	void keyPressed(const SDL_Keycode & key) override; | 	void keyPressed(const SDL_Keycode & key) override; | ||||||
|  |  | ||||||
| 	void textInputed(const SDL_TextInputEvent & event) override; | 	void textInputed(const std::string & enteredText) override; | ||||||
| 	void textEdited(const SDL_TextEditingEvent & event) override; | 	void textEdited(const std::string & enteredText) override; | ||||||
|  |  | ||||||
| 	void startEnteringText(); | 	void startEnteringText(); | ||||||
| 	void endEnteringText(bool processEnteredText); | 	void endEnteringText(bool processEnteredText); | ||||||
|   | |||||||
| @@ -487,14 +487,14 @@ void CGuiHandler::handleCurrentEvent( SDL_Event & current ) | |||||||
| 	{ | 	{ | ||||||
| 		for(auto it : textInterested) | 		for(auto it : textInterested) | ||||||
| 		{ | 		{ | ||||||
| 			it->textInputed(current.text); | 			it->textInputed(current.text.text); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else if(current.type == SDL_TEXTEDITING) | 	else if(current.type == SDL_TEXTEDITING) | ||||||
| 	{ | 	{ | ||||||
| 		for(auto it : textInterested) | 		for(auto it : textInterested) | ||||||
| 		{ | 		{ | ||||||
| 			it->textEdited(current.edit); | 			it->textEdited(current.edit.text); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else if(current.type == SDL_MOUSEBUTTONUP) | 	else if(current.type == SDL_MOUSEBUTTONUP) | ||||||
|   | |||||||
| @@ -18,8 +18,6 @@ class CGuiHandler; | |||||||
| class CPicture; | class CPicture; | ||||||
|  |  | ||||||
| typedef int32_t SDL_Keycode; | typedef int32_t SDL_Keycode; | ||||||
| struct SDL_TextInputEvent; |  | ||||||
| struct SDL_TextEditingEvent; |  | ||||||
|  |  | ||||||
| using boost::logic::tribool; | using boost::logic::tribool; | ||||||
|  |  | ||||||
| @@ -123,8 +121,8 @@ public: | |||||||
| 	virtual void keyReleased(const SDL_Keycode & key){} | 	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 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 textInputed(const std::string & enteredText){}; | ||||||
| 	virtual void textEdited(const SDL_TextEditingEvent & event){}; | 	virtual void textEdited(const std::string & enteredText){}; | ||||||
|  |  | ||||||
| 	//mouse movement handling | 	//mouse movement handling | ||||||
| 	bool strongInterest; //if true - report all mouse movements, if not - only when hovered | 	bool strongInterest; //if true - report all mouse movements, if not - only when hovered | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ | |||||||
| #include "../../lib/CondSh.h" | #include "../../lib/CondSh.h" | ||||||
| #include "../../lib/mapping/CCampaignHandler.h" | #include "../../lib/mapping/CCampaignHandler.h" | ||||||
|  |  | ||||||
| #include <SDL_events.h> | #include <SDL_surface.h> | ||||||
|  |  | ||||||
| namespace fs = boost::filesystem; | namespace fs = boost::filesystem; | ||||||
|  |  | ||||||
| @@ -61,9 +61,7 @@ ISelectionScreenInfo * SEL; | |||||||
|  |  | ||||||
| static void do_quit() | static void do_quit() | ||||||
| { | { | ||||||
| 	SDL_Event event; | 	GH.pushUserEvent(EUserEvent::FORCE_QUIT); | ||||||
| 	event.quit.type = SDL_QUIT; |  | ||||||
| 	SDL_PushEvent(&event); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| CMenuScreen::CMenuScreen(const JsonNode & configNode) | CMenuScreen::CMenuScreen(const JsonNode & configNode) | ||||||
|   | |||||||
| @@ -23,8 +23,6 @@ | |||||||
| #include "lib/CAndroidVMHelper.h" | #include "lib/CAndroidVMHelper.h" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include <SDL_events.h> |  | ||||||
|  |  | ||||||
| std::list<CFocusable*> CFocusable::focusables; | std::list<CFocusable*> CFocusable::focusables; | ||||||
| CFocusable * CFocusable::inputWithFocus; | CFocusable * CFocusable::inputWithFocus; | ||||||
|  |  | ||||||
| @@ -610,13 +608,13 @@ bool CTextInput::captureThisKey(const SDL_Keycode & key) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| void CTextInput::textInputed(const SDL_TextInputEvent & event) | void CTextInput::textInputed(const std::string & enteredText) | ||||||
| { | { | ||||||
| 	if(!focus) | 	if(!focus) | ||||||
| 		return; | 		return; | ||||||
| 	std::string oldText = text; | 	std::string oldText = text; | ||||||
|  |  | ||||||
| 	text += event.text; | 	text += enteredText; | ||||||
|  |  | ||||||
| 	filters(text, oldText); | 	filters(text, oldText); | ||||||
| 	if(text != oldText) | 	if(text != oldText) | ||||||
| @@ -627,12 +625,12 @@ void CTextInput::textInputed(const SDL_TextInputEvent & event) | |||||||
| 	newText.clear(); | 	newText.clear(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void CTextInput::textEdited(const SDL_TextEditingEvent & event) | void CTextInput::textEdited(const std::string & enteredText) | ||||||
| { | { | ||||||
| 	if(!focus) | 	if(!focus) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	newText = event.text; | 	newText = enteredText; | ||||||
| 	redraw(); | 	redraw(); | ||||||
| 	cb(text + newText); | 	cb(text + newText); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -229,8 +229,8 @@ public: | |||||||
|  |  | ||||||
| 	bool captureThisKey(const SDL_Keycode & key) override; | 	bool captureThisKey(const SDL_Keycode & key) override; | ||||||
|  |  | ||||||
| 	void textInputed(const SDL_TextInputEvent & event) override; | 	void textInputed(const std::string & enteredText) override; | ||||||
| 	void textEdited(const SDL_TextEditingEvent & event) override; | 	void textEdited(const std::string & enteredText) override; | ||||||
|  |  | ||||||
| 	//Filter that will block all characters not allowed in filenames | 	//Filter that will block all characters not allowed in filenames | ||||||
| 	static void filenameFilter(std::string & text, const std::string & oldText); | 	static void filenameFilter(std::string & text, const std::string & oldText); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user