add input length cap
fix bogus s_bCancelled flag
This commit is contained in:
@@ -1805,7 +1805,12 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
|
||||
}
|
||||
break;
|
||||
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;
|
||||
case edit_stop:
|
||||
{
|
||||
@@ -1817,9 +1822,23 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
|
||||
break;
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
case edit_bg_change:
|
||||
@@ -2297,7 +2316,14 @@ void ScreenEdit::HandleStepsInformationChoice( StepsInformationChoice c, const v
|
||||
switch( c )
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2309,25 +2335,25 @@ void ScreenEdit::HandleSongInformationChoice( SongInformationChoice c, const vec
|
||||
switch( c )
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
default:
|
||||
ASSERT(0);
|
||||
|
||||
@@ -272,7 +272,13 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
||||
bool bPromptToNameSteps = (action != EDIT_MENU_ACTION_EDIT && dc == DIFFICULTY_EDIT);
|
||||
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
|
||||
{
|
||||
|
||||
@@ -495,27 +495,21 @@ void ScreenManager::Prompt( ScreenMessage SM_SendWhenDone, const CString &sText,
|
||||
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() )
|
||||
m_ScreenStack.back()->HandleScreenMessage( SM_LoseFocus );
|
||||
|
||||
// add the new state onto the back of the array
|
||||
Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", sQuestion, sInitialAnswer, OnOK, OnCancel );
|
||||
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 );
|
||||
Screen *pNewScreen = new ScreenTextEntry( "ScreenTextEntry", sQuestion, sInitialAnswer, iMaxInputLength, OnOK, OnCancel, bPassword );
|
||||
pNewScreen->Init();
|
||||
this->ZeroNextUpdate();
|
||||
SetFromNewScreen( pNewScreen, true );
|
||||
|
||||
@@ -57,8 +57,19 @@ public:
|
||||
void SetNewScreen( const CString &sName );
|
||||
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 Password( ScreenMessage SM_SendWhenDone, const CString &sText, void(*OnOK)(CString sPassword) = NULL, void(*OnCanel)() = NULL );
|
||||
void TextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL );
|
||||
void TextEntry(
|
||||
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 PopTopScreen( ScreenMessage SM = SM_None );
|
||||
void SystemMessage( const CString &sMessage );
|
||||
|
||||
@@ -146,7 +146,7 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM )
|
||||
if ( !ScreenTextEntry::s_bCancelledLast )
|
||||
{
|
||||
m_newRoomName = ScreenTextEntry::s_sLastAnswer;
|
||||
SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", "");
|
||||
SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", "", 255 );
|
||||
}
|
||||
break;
|
||||
case SM_BackFromRoomDesc:
|
||||
@@ -192,7 +192,7 @@ void ScreenNetRoom::MenuStart( PlayerNumber pn )
|
||||
}
|
||||
break;
|
||||
case SelectMakeRoom:
|
||||
SCREENMAN->TextEntry( SM_BackFromRoomName, "Enter Room Name:", "");
|
||||
SCREENMAN->TextEntry( SM_BackFromRoomName, "Enter Room Name:", "", 255 );
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type
|
||||
case PO_CONNECTION:
|
||||
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
|
||||
{
|
||||
|
||||
@@ -164,7 +164,7 @@ void ScreenPackages::MenuStart( PlayerNumber pn )
|
||||
if ( m_iDLorLST == 1 )
|
||||
{
|
||||
if ( m_iLinksPos == 0 )
|
||||
SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://" );
|
||||
SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://", 255 );
|
||||
else
|
||||
EnterURL( m_Links[m_iLinksPos] );
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ void ScreenTestFonts::Input( const DeviceInput& DeviceI, const InputEventType ty
|
||||
case '`': if(curtext != CustomText)
|
||||
SetText(CustomText);
|
||||
else
|
||||
SCREENMAN->TextEntry( SM_ChangeText, "Edit text.", CustomText, ChangeText, NULL);
|
||||
SCREENMAN->TextEntry( SM_ChangeText, "Edit text.", CustomText, 100, ChangeText, NULL);
|
||||
break;
|
||||
case '1': SetText("Waaai"); break;
|
||||
case '2': SetText("WAAI ☩"); break;
|
||||
|
||||
@@ -46,21 +46,25 @@ bool ScreenTextEntry::s_bCancelledLast = false;
|
||||
*/
|
||||
//REGISTER_SCREEN_CLASS( ScreenTextEntry );
|
||||
|
||||
ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)(), bool bPassword ) :
|
||||
Screen( sClassName )
|
||||
ScreenTextEntry::ScreenTextEntry(
|
||||
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_bPassword = bPassword;
|
||||
|
||||
m_pOnOK = OnOK;
|
||||
m_pOnCancel = OnCancel;
|
||||
|
||||
m_sAnswer = CStringToWstring( sInitialAnswer );
|
||||
m_bCancelled = false;
|
||||
|
||||
m_sQuestion = sQuestion;
|
||||
m_sAnswer = CStringToWstring( sInitialAnswer );
|
||||
m_iMaxInputLength = iMaxInputLength;
|
||||
m_pOnOK = OnOK;
|
||||
m_pOnCancel = OnCancel;
|
||||
m_bPassword = bPassword;
|
||||
}
|
||||
|
||||
void ScreenTextEntry::Init()
|
||||
@@ -247,7 +251,14 @@ void ScreenTextEntry::MoveY( int iDir )
|
||||
|
||||
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();
|
||||
UpdateAnswerText();
|
||||
|
||||
@@ -322,8 +333,8 @@ void ScreenTextEntry::End( bool bCancelled )
|
||||
}
|
||||
}
|
||||
|
||||
s_bCancelledLast = m_bCancelled;
|
||||
s_sLastAnswer = m_bCancelled ? CString("") : WStringToCString(m_sAnswer);
|
||||
s_bCancelledLast = bCancelled;
|
||||
s_sLastAnswer = bCancelled ? CString("") : WStringToCString(m_sAnswer);
|
||||
}
|
||||
|
||||
void ScreenTextEntry::MenuBack( PlayerNumber pn )
|
||||
|
||||
@@ -27,7 +27,14 @@ enum KeyboardRowSpecialKey
|
||||
class ScreenTextEntry : public Screen
|
||||
{
|
||||
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();
|
||||
virtual void Init();
|
||||
|
||||
@@ -59,6 +66,7 @@ protected:
|
||||
void UpdateAnswerText();
|
||||
|
||||
CString m_sQuestion;
|
||||
int m_iMaxInputLength;
|
||||
bool m_bPassword;
|
||||
AutoActor m_Background;
|
||||
BitmapText m_textQuestion;
|
||||
@@ -67,8 +75,7 @@ protected:
|
||||
BitmapText m_textAnswer;
|
||||
void(*m_pOnOK)( CString sAnswer );
|
||||
void(*m_pOnCancel)();
|
||||
bool m_bCancelled;
|
||||
|
||||
|
||||
AutoActor m_sprCursor;
|
||||
|
||||
int m_iFocusX;
|
||||
|
||||
Reference in New Issue
Block a user