From 450cbfa66bf9fcae228e0ac33123e29d75a97cd1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 12 Aug 2005 22:46:32 +0000 Subject: [PATCH] make STextEntry work more like other screens: single parameter ctor, move the special load stuff into a separate function (called any time before BeginScreen) --- stepmania/src/ScreenTextEntry.cpp | 92 ++++++++++++++++++------------- stepmania/src/ScreenTextEntry.h | 10 ++-- 2 files changed, 61 insertions(+), 41 deletions(-) diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index bbb0253f2b..6c880eaa39 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -50,8 +50,9 @@ void ScreenTextEntry::TextEntry( ) { // add the new state onto the back of the array - ScreenTextEntry *pNewScreen = new ScreenTextEntry( - "ScreenTextEntry", + ScreenTextEntry *pNewScreen = new ScreenTextEntry( "ScreenTextEntry" ); + pNewScreen->Init(); + pNewScreen->LoadMenu( sQuestion, sInitialAnswer, iMaxInputLength, @@ -59,7 +60,7 @@ void ScreenTextEntry::TextEntry( OnOK, OnCancel, bPassword ); - pNewScreen->Init(); + SCREENMAN->ZeroNextUpdate(); SCREENMAN->PushScreen( pNewScreen, true, smSendOnPop ); } @@ -75,16 +76,60 @@ bool ScreenTextEntry::s_bCancelledLast = false; */ //REGISTER_SCREEN_CLASS( ScreenTextEntry ); -ScreenTextEntry::ScreenTextEntry( - CString sClassName, +ScreenTextEntry::ScreenTextEntry( CString sClassName ) : + ScreenWithMenuElements( sClassName ) +{ +} + +void ScreenTextEntry::Init() +{ + ScreenWithMenuElements::Init(); + + m_textQuestion.LoadFromFont( THEME->GetPathF(m_sName,"question") ); + m_textQuestion.SetName( "Question" ); + this->AddChild( &m_textQuestion ); + + m_sprAnswerBox.Load( THEME->GetPathG(m_sName,"AnswerBox") ); + m_sprAnswerBox->SetName( "AnswerBox" ); + this->AddChild( m_sprAnswerBox ); + + m_textAnswer.LoadFromFont( THEME->GetPathF(m_sName,"answer") ); + m_textAnswer.SetName( "Answer" ); + this->AddChild( &m_textAnswer ); + + + m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") ); + m_sprCursor->SetName( "Cursor" ); + this->AddChild( m_sprCursor ); + + // Init keyboard + FOREACH_KeyboardRow( r ) + { + for( int x=0; xGetPathF(m_sName,"keyboard") ); + this->AddChild( &bt ); + } + } + + m_sndType.Load( THEME->GetPathS(m_sName,"type"), true ); + m_sndBackspace.Load( THEME->GetPathS(m_sName,"backspace"), true ); + m_sndChange.Load( THEME->GetPathS(m_sName,"change"), true ); +} + +ScreenTextEntry::~ScreenTextEntry() +{ +} + +void ScreenTextEntry::LoadMenu( CString sQuestion, CString sInitialAnswer, int iMaxInputLength, bool(*Validate)(const CString &sAnswer,CString &sErrorOut), void(*OnOK)(const CString &sAnswer), void(*OnCancel)(), - bool bPassword ) : - ScreenWithMenuElements( sClassName ) + bool bPassword ) { m_sQuestion = sQuestion; m_sAnswer = CStringToWstring( sInitialAnswer ); @@ -95,60 +140,33 @@ ScreenTextEntry::ScreenTextEntry( m_bPassword = bPassword; } -void ScreenTextEntry::Init() +void ScreenTextEntry::BeginScreen() { - ScreenWithMenuElements::Init(); + ScreenWithMenuElements::BeginScreen(); - m_textQuestion.LoadFromFont( THEME->GetPathF(m_sName,"question") ); - m_textQuestion.SetName( "Question" ); m_textQuestion.SetText( m_sQuestion ); SET_XY_AND_ON_COMMAND( m_textQuestion ); - this->AddChild( &m_textQuestion ); - - m_sprAnswerBox.Load( THEME->GetPathG(m_sName,"AnswerBox") ); - m_sprAnswerBox->SetName( "AnswerBox" ); SET_XY_AND_ON_COMMAND( m_sprAnswerBox ); - this->AddChild( m_sprAnswerBox ); - - m_textAnswer.LoadFromFont( THEME->GetPathF(m_sName,"answer") ); - m_textAnswer.SetName( "Answer" ); SET_XY_AND_ON_COMMAND( m_textAnswer ); + UpdateAnswerText(); - this->AddChild( &m_textAnswer ); - - m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") ); - m_sprCursor->SetName( "Cursor" ); ON_COMMAND( m_sprCursor ); - this->AddChild( m_sprCursor ); - m_iFocusX = 0; m_iFocusY = (KeyboardRow)0; - - // Init keyboard FOREACH_KeyboardRow( r ) { for( int x=0; xGetPathF(m_sName,"keyboard") ); bt.SetXY( GetButtonX(x), GetButtonY(r) ); - this->AddChild( &bt ); } } UpdateKeyboardText(); PositionCursor(); - - m_sndType.Load( THEME->GetPathS(m_sName,"type"), true ); - m_sndBackspace.Load( THEME->GetPathS(m_sName,"backspace"), true ); - m_sndChange.Load( THEME->GetPathS(m_sName,"change"), true ); -} - -ScreenTextEntry::~ScreenTextEntry() -{ } void ScreenTextEntry::UpdateKeyboardText() diff --git a/stepmania/src/ScreenTextEntry.h b/stepmania/src/ScreenTextEntry.h index 35b2152368..505bebbcd6 100644 --- a/stepmania/src/ScreenTextEntry.h +++ b/stepmania/src/ScreenTextEntry.h @@ -44,8 +44,12 @@ public: TextEntry( smSendOnPop, sQuestion, "", 255, NULL, OnOK, OnCanel, true ); } - ScreenTextEntry( - CString sName, + ScreenTextEntry( CString sName ); + ~ScreenTextEntry(); + virtual void Init(); + virtual void BeginScreen(); + + void LoadMenu( CString sQuestion, CString sInitialAnswer, int iMaxInputLength, @@ -53,8 +57,6 @@ public: void(*OnOK)(const CString &sAnswer) = NULL, void(*OnCanel)() = NULL, bool bPassword = false ); - ~ScreenTextEntry(); - virtual void Init(); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );