1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Extract startTextInput & stopTextInput

(*) these functions do nothing with SDL1 - this is by design - less ifdef`s
This commit is contained in:
AlexVinS
2014-07-02 19:41:30 +04:00
parent 9797372dbe
commit e57dbbde15
4 changed files with 30 additions and 26 deletions

View File

@ -4028,13 +4028,7 @@ void CInGameConsole::textEdited(const SDL_TextEditingEvent & event)
void CInGameConsole::startEnteringText() void CInGameConsole::startEnteringText()
{ {
#ifndef VCMI_SDL1 CSDL_Ext::startTextInput(&pos);
if (SDL_IsTextInputActive() == SDL_FALSE)
{
SDL_StartTextInput();
}
SDL_SetTextInputRect(&pos);
#endif
enteredText = "_"; enteredText = "_";
if(GH.topInt() == adventureInt) if(GH.topInt() == adventureInt)
@ -4053,12 +4047,7 @@ void CInGameConsole::startEnteringText()
void CInGameConsole::endEnteringText(bool printEnteredText) void CInGameConsole::endEnteringText(bool printEnteredText)
{ {
#ifndef VCMI_SDL1 CSDL_Ext::stopTextInput();
if (SDL_IsTextInputActive() == SDL_TRUE)
{
SDL_StopTextInput();
}
#endif
prevEntDisp = -1; prevEntDisp = -1;
if(printEnteredText) if(printEnteredText)

View File

@ -1583,23 +1583,12 @@ CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf)
void CTextInput::focusGot() void CTextInput::focusGot()
{ {
#ifndef VCMI_SDL1 CSDL_Ext::startTextInput(&pos);
if (SDL_IsTextInputActive() == SDL_FALSE)
{
SDL_StartTextInput();
}
SDL_SetTextInputRect(&pos);
#endif
} }
void CTextInput::focusLost() void CTextInput::focusLost()
{ {
#ifndef VCMI_SDL1 CSDL_Ext::stopTextInput();
if (SDL_IsTextInputActive() == SDL_TRUE)
{
SDL_StopTextInput();
}
#endif
} }

View File

@ -983,6 +983,29 @@ SDL_Color CSDL_Ext::makeColor(ui8 r, ui8 g, ui8 b, ui8 a)
return ret; return ret;
} }
void CSDL_Ext::startTextInput(SDL_Rect * where)
{
#ifndef VCMI_SDL1
if (SDL_IsTextInputActive() == SDL_FALSE)
{
SDL_StartTextInput();
}
SDL_SetTextInputRect(where);
#endif
}
void CSDL_Ext::stopTextInput()
{
#ifndef VCMI_SDL1
if (SDL_IsTextInputActive() == SDL_TRUE)
{
SDL_StopTextInput();
}
#endif
}
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<2>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<2>(int, int);
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<3>(int, int);
template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int); template SDL_Surface * CSDL_Ext::createSurfaceWithBpp<4>(int, int);

View File

@ -263,4 +263,7 @@ namespace CSDL_Ext
template<int bpp> template<int bpp>
void applyEffectBpp( SDL_Surface * surf, const SDL_Rect * rect, int mode ); void applyEffectBpp( SDL_Surface * surf, const SDL_Rect * rect, int mode );
void applyEffect(SDL_Surface * surf, const SDL_Rect * rect, int mode); //mode: 0 - sepia, 1 - grayscale void applyEffect(SDL_Surface * surf, const SDL_Rect * rect, int mode); //mode: 0 - sepia, 1 - grayscale
void startTextInput(SDL_Rect * where);
void stopTextInput();
} }