Backsp -> Backspace

This commit is contained in:
Chris Danford
2005-09-02 21:36:56 +00:00
parent bb6c216943
commit d120a36089
+48 -14
View File
@@ -21,7 +21,7 @@ static const char* g_szKeys[NUM_KEYBOARD_ROWS][KEYS_PER_ROW] =
{"0","1","2","3","4","5","6","7","8","9"}, {"0","1","2","3","4","5","6","7","8","9"},
{"!","@","#","$","%","^","&","(",")","[","]","{","}"}, {"!","@","#","$","%","^","&","(",")","[","]","{","}"},
{"+","-","=","_",",",".","'","\"",":"}, {"+","-","=","_",",",".","'","\"",":"},
{"","","Space","","","Backsp","","","Cancel","","","Done",""}, {"","","Space","","","Backspace","","","Cancel","","","Done",""},
}; };
static Preference<bool> g_bAllowOldKeyboardInput( "AllowOldKeyboardInput", true ); static Preference<bool> g_bAllowOldKeyboardInput( "AllowOldKeyboardInput", true );
@@ -94,19 +94,28 @@ void ScreenTextEntry::Init()
m_textAnswer.SetName( "Answer" ); m_textAnswer.SetName( "Answer" );
this->AddChild( &m_textAnswer ); this->AddChild( &m_textAnswer );
m_bShowAnswerCaret = false;
m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") ); m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") );
m_sprCursor->SetName( "Cursor" ); m_sprCursor->SetName( "Cursor" );
this->AddChild( m_sprCursor ); this->AddChild( m_sprCursor );
// Init keyboard // Init keyboard
{
BitmapText text;
text.LoadFromFont( THEME->GetPathF(m_sName,"keyboard") );
text.SetName( "Keys" );
ActorUtil::LoadAllCommands( text, m_sName );
text.PlayCommand( "Init" );
FOREACH_KeyboardRow( r ) FOREACH_KeyboardRow( r )
{ {
for( int x=0; x<KEYS_PER_ROW; ++x ) for( int x=0; x<KEYS_PER_ROW; ++x )
{ {
BitmapText &bt = m_textKeyboardChars[r][x]; BitmapText *&pbt = m_ptextKeys[r][x];
bt.LoadFromFont( THEME->GetPathF(m_sName,"keyboard") ); pbt = static_cast<BitmapText *>( text.Copy() );
this->AddChild( &bt ); this->AddChild( pbt );
}
} }
} }
@@ -117,6 +126,9 @@ void ScreenTextEntry::Init()
ScreenTextEntry::~ScreenTextEntry() ScreenTextEntry::~ScreenTextEntry()
{ {
FOREACH_KeyboardRow( r )
for( int x=0; x<KEYS_PER_ROW; ++x )
SAFE_DELETE( m_ptextKeys[r][x] );
} }
void ScreenTextEntry::BeginScreen() void ScreenTextEntry::BeginScreen()
@@ -140,7 +152,7 @@ void ScreenTextEntry::BeginScreen()
{ {
for( int x=0; x<KEYS_PER_ROW; ++x ) for( int x=0; x<KEYS_PER_ROW; ++x )
{ {
BitmapText &bt = m_textKeyboardChars[r][x]; BitmapText &bt = *m_ptextKeys[r][x];
float fX = roundf( SCALE( x, 0, KEYS_PER_ROW-1, SCREEN_LEFT+100, SCREEN_RIGHT-100 ) ); float fX = roundf( SCALE( x, 0, KEYS_PER_ROW-1, SCREEN_LEFT+100, SCREEN_RIGHT-100 ) );
float fY = roundf( SCALE( r, 0, NUM_KEYBOARD_ROWS-1, SCREEN_CENTER_Y-30, SCREEN_BOTTOM-80 ) ); float fY = roundf( SCALE( r, 0, NUM_KEYBOARD_ROWS-1, SCREEN_CENTER_Y-30, SCREEN_BOTTOM-80 ) );
bt.SetXY( fX, fY ); bt.SetXY( fX, fY );
@@ -158,8 +170,10 @@ void ScreenTextEntry::UpdateKeyboardText()
{ {
for( int x=0; x<KEYS_PER_ROW; ++x ) for( int x=0; x<KEYS_PER_ROW; ++x )
{ {
const char *s = g_szKeys[r][x]; CString s = g_szKeys[r][x];
BitmapText &bt = m_textKeyboardChars[r][x]; if( !s.empty() && r == KEYBOARD_ROW_SPECIAL )
s = THEME->GetMetric( "ScreenTextEntry", s );
BitmapText &bt = *m_ptextKeys[r][x];
bt.SetText( s ); bt.SetText( s );
} }
} }
@@ -167,22 +181,42 @@ void ScreenTextEntry::UpdateKeyboardText()
void ScreenTextEntry::UpdateAnswerText() void ScreenTextEntry::UpdateAnswerText()
{ {
CString txt = WStringToCString(m_sAnswer); CString s = WStringToCString(m_sAnswer);
if( g_bPassword ) if( g_bPassword )
{ {
int len = txt.GetLength(); int len = s.GetLength();
txt = ""; s = "";
for( int i=0; i<len; ++i ) for( int i=0; i<len; ++i )
txt += "*"; s += '*';
} }
FontCharAliases::ReplaceMarkers(txt);
m_textAnswer.SetText( txt ); bool bAnswerFull = s.length() >= g_iMaxInputLength;
if( m_bShowAnswerCaret && !bAnswerFull )
s += '_';
else
s += " "; // assumes that underscore is the width of two spaces
FontCharAliases::ReplaceMarkers( s );
m_textAnswer.SetText( s );
} }
void ScreenTextEntry::PositionCursor() void ScreenTextEntry::PositionCursor()
{ {
BitmapText &bt = m_textKeyboardChars[m_iFocusY][m_iFocusX]; BitmapText &bt = *m_ptextKeys[m_iFocusY][m_iFocusX];
m_sprCursor->SetXY( bt.GetX(), bt.GetY() ); m_sprCursor->SetXY( bt.GetX(), bt.GetY() );
m_sprCursor->PlayCommand( m_iFocusY == KEYBOARD_ROW_SPECIAL ? "SpecialKey" : "RegularKey" );
}
void ScreenTextEntry::Update( float fDelta )
{
ScreenWithMenuElements::Update( fDelta );
if( m_timerToggleCursor.PeekDeltaTime() > 0.25f )
{
m_timerToggleCursor.Touch();
m_bShowAnswerCaret = !m_bShowAnswerCaret;
UpdateAnswerText();
}
} }
void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )