diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index f977d10707..3e011ae918 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -11,6 +11,7 @@ #include "ActorUtil.h" #include "InputEventPlus.h" #include "RageInput.h" +#include "LocalizedString.h" static const char* g_szKeys[NUM_KEYBOARD_ROWS][KEYS_PER_ROW] = { @@ -88,6 +89,16 @@ void ScreenTextEntry::TextEntry( SCREENMAN->AddNewScreenToTop( "ScreenTextEntry", smSendOnPop ); } +static LocalizedString INVALID_FLOAT( "ScreenTextEntry", "\"%s\" is an invalid floating point value." ); +bool ScreenTextEntry::FloatValidate( const RString &sAnswer, RString &sErrorOut ) +{ + float f; + if( StringToFloat(sAnswer, f) ) + return true; + sErrorOut = ssprintf( INVALID_FLOAT.GetValue(), sAnswer.c_str() ); + return false; +} + bool ScreenTextEntry::s_bCancelledLast = false; /* @@ -313,7 +324,7 @@ void ScreenTextEntryVisual::Init() for( int x=0; x( text.Copy() ); // XXX: Copy() should be covariant + pbt = dynamic_cast( text.Copy() ); // XXX: Copy() should be covariant this->AddChild( pbt ); RString s = g_szKeys[r][x]; diff --git a/stepmania/src/ScreenTextEntry.h b/stepmania/src/ScreenTextEntry.h index 2a523774ab..270b8d5b88 100644 --- a/stepmania/src/ScreenTextEntry.h +++ b/stepmania/src/ScreenTextEntry.h @@ -55,6 +55,8 @@ public: { TextEntry( smSendOnPop, sQuestion, "", 255, NULL, OnOK, OnCanel, true ); } + + static bool FloatValidate( const RString &sAnswer, RString &sErrorOut ); virtual void Init(); virtual void BeginScreen();