Validation function for floating point values.
1 2.3 -4.5 -8.2e-10 are all valid.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "ActorUtil.h"
|
#include "ActorUtil.h"
|
||||||
#include "InputEventPlus.h"
|
#include "InputEventPlus.h"
|
||||||
#include "RageInput.h"
|
#include "RageInput.h"
|
||||||
|
#include "LocalizedString.h"
|
||||||
|
|
||||||
static const char* g_szKeys[NUM_KEYBOARD_ROWS][KEYS_PER_ROW] =
|
static const char* g_szKeys[NUM_KEYBOARD_ROWS][KEYS_PER_ROW] =
|
||||||
{
|
{
|
||||||
@@ -88,6 +89,16 @@ void ScreenTextEntry::TextEntry(
|
|||||||
SCREENMAN->AddNewScreenToTop( "ScreenTextEntry", smSendOnPop );
|
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;
|
bool ScreenTextEntry::s_bCancelledLast = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -313,7 +324,7 @@ void ScreenTextEntryVisual::Init()
|
|||||||
for( int x=0; x<KEYS_PER_ROW; ++x )
|
for( int x=0; x<KEYS_PER_ROW; ++x )
|
||||||
{
|
{
|
||||||
BitmapText *&pbt = m_ptextKeys[r][x];
|
BitmapText *&pbt = m_ptextKeys[r][x];
|
||||||
pbt = static_cast<BitmapText *>( text.Copy() ); // XXX: Copy() should be covariant
|
pbt = dynamic_cast<BitmapText *>( text.Copy() ); // XXX: Copy() should be covariant
|
||||||
this->AddChild( pbt );
|
this->AddChild( pbt );
|
||||||
|
|
||||||
RString s = g_szKeys[r][x];
|
RString s = g_szKeys[r][x];
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ public:
|
|||||||
TextEntry( smSendOnPop, sQuestion, "", 255, NULL, OnOK, OnCanel, true );
|
TextEntry( smSendOnPop, sQuestion, "", 255, NULL, OnOK, OnCanel, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool FloatValidate( const RString &sAnswer, RString &sErrorOut );
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void BeginScreen();
|
virtual void BeginScreen();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user