add name entry by typing on the keyboard
This commit is contained in:
@@ -296,7 +296,7 @@ void ScreenNameEntryTraditional::Init()
|
|||||||
m_sSelection[p].erase( MAX_RANKING_NAME_LENGTH );
|
m_sSelection[p].erase( MAX_RANKING_NAME_LENGTH );
|
||||||
ASSERT( (int) m_sSelection[p].size() <= MAX_RANKING_NAME_LENGTH );
|
ASSERT( (int) m_sSelection[p].size() <= MAX_RANKING_NAME_LENGTH );
|
||||||
if( m_sSelection[p].size() )
|
if( m_sSelection[p].size() )
|
||||||
SelectChar( p, CHAR_OK );
|
SelectChar( p, CHAR_OK, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSelectionText( p );
|
UpdateSelectionText( p );
|
||||||
@@ -508,7 +508,28 @@ void ScreenNameEntryTraditional::Input( const InputEventPlus &input )
|
|||||||
if( IsTransitioning() )
|
if( IsTransitioning() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScreenWithMenuElements::Input( input );
|
if( input.MenuI.IsValid() )
|
||||||
|
{
|
||||||
|
ScreenWithMenuElements::Input( input );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( input.DeviceI.device == DEVICE_KEYBOARD && input.type == IET_FIRST_PRESS )
|
||||||
|
{
|
||||||
|
char c = -1;
|
||||||
|
if( input.DeviceI.button == KEY_BACK )
|
||||||
|
c = CHAR_BACK;
|
||||||
|
else
|
||||||
|
c = toupper( input.DeviceI.ToChar() );
|
||||||
|
|
||||||
|
bool bChanged = SelectChar( GAMESTATE->m_MasterPlayerNumber, c, true );
|
||||||
|
if( bChanged )
|
||||||
|
{
|
||||||
|
m_soundChange.Play();
|
||||||
|
HandleStart( GAMESTATE->m_MasterPlayerNumber );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenNameEntryTraditional::ChangeDisplayedFeat()
|
void ScreenNameEntryTraditional::ChangeDisplayedFeat()
|
||||||
@@ -644,7 +665,7 @@ void ScreenNameEntryTraditional::HandleStart( PlayerNumber pn )
|
|||||||
if( (int) m_sSelection[pn].size() == MAX_RANKING_NAME_LENGTH )
|
if( (int) m_sSelection[pn].size() == MAX_RANKING_NAME_LENGTH )
|
||||||
{
|
{
|
||||||
m_soundInvalid.Play();
|
m_soundInvalid.Play();
|
||||||
SelectChar( pn, CHAR_BACK );
|
SelectChar( pn, CHAR_BACK, false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_sSelection[pn] += wchar_t(iSelectedLetter);
|
m_sSelection[pn] += wchar_t(iSelectedLetter);
|
||||||
@@ -653,7 +674,7 @@ void ScreenNameEntryTraditional::HandleStart( PlayerNumber pn )
|
|||||||
|
|
||||||
/* If that filled the string, set the cursor on OK. */
|
/* If that filled the string, set the cursor on OK. */
|
||||||
if( (int) m_sSelection[pn].size() == MAX_RANKING_NAME_LENGTH )
|
if( (int) m_sSelection[pn].size() == MAX_RANKING_NAME_LENGTH )
|
||||||
SelectChar( pn, CHAR_OK );
|
SelectChar( pn, CHAR_OK, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,7 +690,7 @@ void ScreenNameEntryTraditional::MenuSelect( const InputEventPlus &input )
|
|||||||
Backspace( pn );
|
Backspace( pn );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenNameEntryTraditional::SelectChar( PlayerNumber pn, int c )
|
bool ScreenNameEntryTraditional::SelectChar( PlayerNumber pn, int c, bool bOptional )
|
||||||
{
|
{
|
||||||
FOREACH( int, m_AlphabetLetter[pn], letter )
|
FOREACH( int, m_AlphabetLetter[pn], letter )
|
||||||
{
|
{
|
||||||
@@ -677,10 +698,12 @@ void ScreenNameEntryTraditional::SelectChar( PlayerNumber pn, int c )
|
|||||||
{
|
{
|
||||||
m_SelectedChar[pn] = letter - m_AlphabetLetter[pn].begin();
|
m_SelectedChar[pn] = letter - m_AlphabetLetter[pn].begin();
|
||||||
PositionCharsAndCursor( pn );
|
PositionCharsAndCursor( pn );
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT( false ); // character not found
|
if( !bOptional )
|
||||||
|
ASSERT( false ); // character not found
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenNameEntryTraditional::Backspace( PlayerNumber pn )
|
void ScreenNameEntryTraditional::Backspace( PlayerNumber pn )
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ private:
|
|||||||
void Finish( PlayerNumber pn );
|
void Finish( PlayerNumber pn );
|
||||||
void UpdateSelectionText( int pn );
|
void UpdateSelectionText( int pn );
|
||||||
void ChangeDisplayedFeat();
|
void ChangeDisplayedFeat();
|
||||||
void SelectChar( PlayerNumber pn, int c );
|
bool SelectChar( PlayerNumber pn, int c, bool bOptional );
|
||||||
void Backspace( PlayerNumber pn );
|
void Backspace( PlayerNumber pn );
|
||||||
void HandleStart( PlayerNumber pn );
|
void HandleStart( PlayerNumber pn );
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ private:
|
|||||||
Sprite m_sprCursor[NUM_PLAYERS];
|
Sprite m_sprCursor[NUM_PLAYERS];
|
||||||
vector<BitmapText*> m_textAlphabet[NUM_PLAYERS];
|
vector<BitmapText*> m_textAlphabet[NUM_PLAYERS];
|
||||||
vector<int> m_AlphabetLetter[NUM_PLAYERS];
|
vector<int> m_AlphabetLetter[NUM_PLAYERS];
|
||||||
int m_SelectedChar[NUM_PLAYERS];
|
int m_SelectedChar[NUM_PLAYERS];
|
||||||
AutoActor m_sprOutOfRanking[NUM_PLAYERS]; // shown if didn't make any high scores
|
AutoActor m_sprOutOfRanking[NUM_PLAYERS]; // shown if didn't make any high scores
|
||||||
Sprite m_sprNameFrame[NUM_PLAYERS];
|
Sprite m_sprNameFrame[NUM_PLAYERS];
|
||||||
BitmapText m_textSelection[NUM_PLAYERS];
|
BitmapText m_textSelection[NUM_PLAYERS];
|
||||||
|
|||||||
Reference in New Issue
Block a user