add input length cap

fix bogus s_bCancelled flag
This commit is contained in:
Chris Danford
2005-03-23 04:08:27 +00:00
parent ae57faa18d
commit ee4be22260
10 changed files with 106 additions and 51 deletions
+37 -11
View File
@@ -1805,7 +1805,12 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
} }
break; break;
case edit_bpm: case edit_bpm:
SCREENMAN->TextEntry( SM_BackFromBPMChange, "Enter new BPM value.", ssprintf( "%.4f", m_pSong->GetBPMAtBeat( GAMESTATE->m_fSongBeat ) ) ); SCREENMAN->TextEntry(
SM_BackFromBPMChange,
"Enter new BPM value.",
ssprintf( "%.4f", m_pSong->GetBPMAtBeat(GAMESTATE->m_fSongBeat) ),
10
);
break; break;
case edit_stop: case edit_stop:
{ {
@@ -1817,9 +1822,23 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
break; break;
} }
if ( i == m_pSong->m_Timing.m_StopSegments.size() ) if ( i == m_pSong->m_Timing.m_StopSegments.size() )
SCREENMAN->TextEntry( SM_BackFromStopChange, "Enter new Stop value.", "0.00" ); {
SCREENMAN->TextEntry(
SM_BackFromStopChange,
"Enter new Stop value.",
"0.00",
10
);
}
else else
SCREENMAN->TextEntry( SM_BackFromStopChange, "Enter new Stop value.", ssprintf( "%.4f", m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds ) ); {
SCREENMAN->TextEntry(
SM_BackFromStopChange,
"Enter new Stop value.",
ssprintf( "%.4f", m_pSong->m_Timing.m_StopSegments[i].m_fStopSeconds ),
10
);
}
break; break;
} }
case edit_bg_change: case edit_bg_change:
@@ -2297,7 +2316,14 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
switch( c ) switch( c )
{ {
case description: case description:
SCREENMAN->TextEntry( SM_None, "Enter a description.\nPress Enter to confirm,\nEscape to cancel.", m_pSteps->GetDescription(), ChangeDescription, NULL ); SCREENMAN->TextEntry(
SM_None,
"Enter a description.",
m_pSteps->GetDescription(),
MAX_DESCRIPTION_LENGTH,
ChangeDescription,
NULL
);
break; break;
} }
} }
@@ -2309,25 +2335,25 @@ void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vec
switch( c ) switch( c )
{ {
case main_title: case main_title:
SCREENMAN->TextEntry( SM_None, "Edit main title.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sMainTitle, ChangeMainTitle, NULL ); SCREENMAN->TextEntry( SM_None, "Edit main title.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sMainTitle, 100, ChangeMainTitle, NULL );
break; break;
case sub_title: case sub_title:
SCREENMAN->TextEntry( SM_None, "Edit sub title.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sSubTitle, ChangeSubTitle, NULL ); SCREENMAN->TextEntry( SM_None, "Edit sub title.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sSubTitle, 100, ChangeSubTitle, NULL );
break; break;
case artist: case artist:
SCREENMAN->TextEntry( SM_None, "Edit artist.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sArtist, ChangeArtist, NULL ); SCREENMAN->TextEntry( SM_None, "Edit artist.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sArtist, 100, ChangeArtist, NULL );
break; break;
case credit: case credit:
SCREENMAN->TextEntry( SM_None, "Edit credit.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sCredit, ChangeCredit, NULL ); SCREENMAN->TextEntry( SM_None, "Edit credit.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sCredit, 100, ChangeCredit, NULL );
break; break;
case main_title_transliteration: case main_title_transliteration:
SCREENMAN->TextEntry( SM_None, "Edit main title transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sMainTitleTranslit, ChangeMainTitleTranslit, NULL ); SCREENMAN->TextEntry( SM_None, "Edit main title transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sMainTitleTranslit, 100, ChangeMainTitleTranslit, NULL );
break; break;
case sub_title_transliteration: case sub_title_transliteration:
SCREENMAN->TextEntry( SM_None, "Edit sub title transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sSubTitleTranslit, ChangeSubTitleTranslit, NULL ); SCREENMAN->TextEntry( SM_None, "Edit sub title transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sSubTitleTranslit, 100, ChangeSubTitleTranslit, NULL );
break; break;
case artist_transliteration: case artist_transliteration:
SCREENMAN->TextEntry( SM_None, "Edit artist transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sArtistTranslit, ChangeArtistTranslit, NULL ); SCREENMAN->TextEntry( SM_None, "Edit artist transliteration.\nPress Enter to confirm,\nEscape to cancel.", pSong->m_sArtistTranslit, 100, ChangeArtistTranslit, NULL );
break; break;
default: default:
ASSERT(0); ASSERT(0);
+7 -1
View File
@@ -272,7 +272,13 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
bool bPromptToNameSteps = (action != EDIT_MENU_ACTION_EDIT && dc == DIFFICULTY_EDIT); bool bPromptToNameSteps = (action != EDIT_MENU_ACTION_EDIT && dc == DIFFICULTY_EDIT);
if( bPromptToNameSteps ) if( bPromptToNameSteps )
{ {
SCREENMAN->TextEntry( SM_BackFromEditDescription, "Name this new edit.", GAMESTATE->m_pCurSteps[0]->GetDescription(), SetCurrentStepsDescription, DeleteCurrentSteps ); SCREENMAN->TextEntry(
SM_BackFromEditDescription,
"Name the new edit.",
GAMESTATE->m_pCurSteps[0]->GetDescription(),
MAX_DESCRIPTION_LENGTH,
SetCurrentStepsDescription,
DeleteCurrentSteps );
} }
else else
{ {
+10 -16
View File
@@ -495,27 +495,21 @@ void ScreenManager::Prompt( ScreenMessage SM_SendWhenDone, const CString &sText,
m_MessageSendOnPop = SM_SendWhenDone; m_MessageSendOnPop = SM_SendWhenDone;
} }
void ScreenManager::TextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)() ) void ScreenManager::TextEntry(
ScreenMessage SM_SendWhenDone,
CString sQuestion,
CString sInitialAnswer,
int iMaxInputLength,
void(*OnOK)(CString sAnswer),
void(*OnCancel)(),
bool bPassword
)
{ {
if( m_ScreenStack.size() ) if( m_ScreenStack.size() )
m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus ); m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus );
// add the new state onto the back of the array // add the new state onto the back of the array
Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", sQuestion, sInitialAnswer, OnOK, OnCancel ); Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", sQuestion, sInitialAnswer, iMaxInputLength, OnOK, OnCancel, bPassword );
pNewScreen->Init();
this->ZeroNextUpdate();
SetFromNewScreen( pNewScreen, true );
m_MessageSendOnPop = SM_SendWhenDone;
}
void ScreenManager::Password( ScreenMessage SM_SendWhenDone, const CString &sText, void(*OnOK)(CString sPassword), void(*OnCancel)() )
{
if( m_ScreenStack.size() )
m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus );
// add the new state onto the back of the array
Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", sText, "", OnOK, OnCancel, true );
pNewScreen->Init(); pNewScreen->Init();
this->ZeroNextUpdate(); this->ZeroNextUpdate();
SetFromNewScreen( pNewScreen, true ); SetFromNewScreen( pNewScreen, true );
+13 -2
View File
@@ -57,8 +57,19 @@ public:
void SetNewScreen( const CString &sName ); void SetNewScreen( const CString &sName );
void AddNewScreenToTop( const CString &sName, ScreenMessage messageSendOnPop ); void AddNewScreenToTop( const CString &sName, ScreenMessage messageSendOnPop );
void Prompt( ScreenMessage SM_SendWhenDone, const CString &sText, PromptType type = PROMPT_OK, PromptAnswer defaultAnswer = ANSWER_NO, void(*OnYes)(void*) = NULL, void(*OnNo)(void*) = NULL, void* pCallbackData = NULL ); void Prompt( ScreenMessage SM_SendWhenDone, const CString &sText, PromptType type = PROMPT_OK, PromptAnswer defaultAnswer = ANSWER_NO, void(*OnYes)(void*) = NULL, void(*OnNo)(void*) = NULL, void* pCallbackData = NULL );
void Password( ScreenMessage SM_SendWhenDone, const CString &sText, void(*OnOK)(CString sPassword) = NULL, void(*OnCanel)() = NULL ); void TextEntry(
void TextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL ); ScreenMessage SM_SendWhenDone,
CString sQuestion,
CString sInitialAnswer,
int iMaxInputLength,
void(*OnOK)(CString sAnswer) = NULL,
void(*OnCanel)() = NULL,
bool bPassword = false
);
void Password( ScreenMessage SM_SendWhenDone, const CString &sQuestion, void(*OnOK)(CString sPassword) = NULL, void(*OnCanel)() = NULL )
{
TextEntry( SM_SendWhenDone, sQuestion, "", 255, OnOK, OnCanel, true );
}
void MiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel = SM_None ); void MiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel = SM_None );
void PopTopScreen( ScreenMessage SM = SM_None ); void PopTopScreen( ScreenMessage SM = SM_None );
void SystemMessage( const CString &sMessage ); void SystemMessage( const CString &sMessage );
+2 -2
View File
@@ -146,7 +146,7 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
if ( !ScreenTextEntry::s_bCancelledLast ) if ( !ScreenTextEntry::s_bCancelledLast )
{ {
m_newRoomName = ScreenTextEntry::s_sLastAnswer; m_newRoomName = ScreenTextEntry::s_sLastAnswer;
SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", ""); SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", "", 255 );
} }
break; break;
case SM_BackFromRoomDesc: case SM_BackFromRoomDesc:
@@ -192,7 +192,7 @@ void ScreenNetRoom::MenuStart( PlayerNumber pn )
} }
break; break;
case SelectMakeRoom: case SelectMakeRoom:
SCREENMAN->TextEntry( SM_BackFromRoomName, "Enter Room Name:", ""); SCREENMAN->TextEntry( SM_BackFromRoomName, "Enter Room Name:", "", 255 );
break; break;
}; };
} }
+1 -1
View File
@@ -122,7 +122,7 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
case PO_CONNECTION: case PO_CONNECTION:
if ( !NSMAN->useSMserver ) if ( !NSMAN->useSMserver )
{ {
SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", g_sLastServer ); SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", g_sLastServer, 15 );
} }
else else
{ {
+1 -1
View File
@@ -164,7 +164,7 @@ void ScreenPackages::MenuStart( PlayerNumber pn )
if ( m_iDLorLST == 1 ) if ( m_iDLorLST == 1 )
{ {
if ( m_iLinksPos == 0 ) if ( m_iLinksPos == 0 )
SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://" ); SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://", 255 );
else else
EnterURL( m_Links[m_iLinksPos] ); EnterURL( m_Links[m_iLinksPos] );
} }
+1 -1
View File
@@ -97,7 +97,7 @@ void ScreenTestFonts::Input( const DeviceInput& DeviceI, const InputEventType ty
case '`': if(curtext != CustomText) case '`': if(curtext != CustomText)
SetText(CustomText); SetText(CustomText);
else else
SCREENMAN->TextEntry( SM_ChangeText, "Edit text.", CustomText, ChangeText, NULL); SCREENMAN->TextEntry( SM_ChangeText, "Edit text.", CustomText, 100, ChangeText, NULL);
break; break;
case '1': SetText("Waaai"); break; case '1': SetText("Waaai"); break;
case '2': SetText("WAAI &#9769;"); break; case '2': SetText("WAAI &#9769;"); break;
+24 -13
View File
@@ -46,21 +46,25 @@ bool ScreenTextEntry::s_bCancelledLast = false;
*/ */
//REGISTER_SCREEN_CLASS( ScreenTextEntry ); //REGISTER_SCREEN_CLASS( ScreenTextEntry );
ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)(), bool bPassword ) : ScreenTextEntry::ScreenTextEntry(
Screen( sClassName ) CString sClassName,
CString sQuestion,
CString sInitialAnswer,
int iMaxInputLength,
void(*OnOK)(CString sAnswer),
void(*OnCancel)(),
bool bPassword ) :
Screen( sClassName )
{ {
m_sName = "ScreenTextEntry";
m_bIsTransparent = true; // draw screens below us m_bIsTransparent = true; // draw screens below us
m_bPassword = bPassword;
m_pOnOK = OnOK;
m_pOnCancel = OnCancel;
m_sAnswer = CStringToWstring( sInitialAnswer );
m_bCancelled = false; m_bCancelled = false;
m_sQuestion = sQuestion; m_sQuestion = sQuestion;
m_sAnswer = CStringToWstring( sInitialAnswer );
m_iMaxInputLength = iMaxInputLength;
m_pOnOK = OnOK;
m_pOnCancel = OnCancel;
m_bPassword = bPassword;
} }
void ScreenTextEntry::Init() void ScreenTextEntry::Init()
@@ -247,7 +251,14 @@ void ScreenTextEntry::MoveY( int iDir )
void ScreenTextEntry::AppendToAnswer( CString s ) void ScreenTextEntry::AppendToAnswer( CString s )
{ {
m_sAnswer += CStringToWstring( s ); wstring sNewAnswer = m_sAnswer+CStringToWstring(s);
if( (int)sNewAnswer.length() > m_iMaxInputLength )
{
SCREENMAN->PlayInvalidSound();
return;
}
m_sAnswer = sNewAnswer;
m_sndType.Play(); m_sndType.Play();
UpdateAnswerText(); UpdateAnswerText();
@@ -322,8 +333,8 @@ void ScreenTextEntry::End( bool bCancelled )
} }
} }
s_bCancelledLast = m_bCancelled; s_bCancelledLast = bCancelled;
s_sLastAnswer = m_bCancelled ? CString("") : WStringToCString(m_sAnswer); s_sLastAnswer = bCancelled ? CString("") : WStringToCString(m_sAnswer);
} }
void ScreenTextEntry::MenuBack( PlayerNumber pn ) void ScreenTextEntry::MenuBack( PlayerNumber pn )
+9 -2
View File
@@ -27,7 +27,14 @@ enum KeyboardRowSpecialKey
class ScreenTextEntry : public Screen class ScreenTextEntry : public Screen
{ {
public: public:
ScreenTextEntry( CString sName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL, bool bPassword = false ); ScreenTextEntry(
CString sName,
CString sQuestion,
CString sInitialAnswer,
int iMaxInputLength,
void(*OnOK)(CString sAnswer) = NULL,
void(*OnCanel)() = NULL,
bool bPassword = false );
~ScreenTextEntry(); ~ScreenTextEntry();
virtual void Init(); virtual void Init();
@@ -59,6 +66,7 @@ protected:
void UpdateAnswerText(); void UpdateAnswerText();
CString m_sQuestion; CString m_sQuestion;
int m_iMaxInputLength;
bool m_bPassword; bool m_bPassword;
AutoActor m_Background; AutoActor m_Background;
BitmapText m_textQuestion; BitmapText m_textQuestion;
@@ -67,7 +75,6 @@ protected:
BitmapText m_textAnswer; BitmapText m_textAnswer;
void(*m_pOnOK)( CString sAnswer ); void(*m_pOnOK)( CString sAnswer );
void(*m_pOnCancel)(); void(*m_pOnCancel)();
bool m_bCancelled;
AutoActor m_sprCursor; AutoActor m_sprCursor;