2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-08-23 20:18:29 +00:00
|
|
|
#include "ScreenTextEntry.h"
|
2005-07-14 03:36:07 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "Preference.h"
|
2002-08-23 20:18:29 +00:00
|
|
|
#include "ScreenManager.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2002-08-23 20:18:29 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2003-01-16 20:21:07 +00:00
|
|
|
#include "FontCharAliases.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2005-07-03 04:34:53 +00:00
|
|
|
#include "ScreenPrompt.h"
|
2005-03-22 20:15:24 +00:00
|
|
|
#include "ActorUtil.h"
|
2004-10-25 12:40:05 +00:00
|
|
|
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-03-22 23:58:16 +00:00
|
|
|
static const char* g_szKeys[NUM_KEYBOARD_ROWS][KEYS_PER_ROW] =
|
|
|
|
|
{
|
|
|
|
|
{"A","B","C","D","E","F","G","H","I","J","K","L","M"},
|
|
|
|
|
{"N","O","P","Q","R","S","T","U","V","W","X","Y","Z"},
|
|
|
|
|
{"a","b","c","d","e","f","g","h","i","j","k","l","m"},
|
|
|
|
|
{"n","o","p","q","r","s","t","u","v","w","x","y","z"},
|
|
|
|
|
{"0","1","2","3","4","5","6","7","8","9"},
|
|
|
|
|
{"!","@","#","$","%","^","&","(",")","[","]","{","}"},
|
2005-03-28 08:05:14 +00:00
|
|
|
{"+","-","=","_",",",".","'","\"",":"},
|
2005-09-02 21:36:56 +00:00
|
|
|
{"","","Space","","","Backspace","","","Cancel","","","Done",""},
|
2005-03-22 23:58:16 +00:00
|
|
|
};
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-05-19 01:25:38 +00:00
|
|
|
static Preference<bool> g_bAllowOldKeyboardInput( "AllowOldKeyboardInput", true );
|
2005-03-22 20:15:24 +00:00
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
CString ScreenTextEntry::s_sLastAnswer = "";
|
2005-07-03 04:42:47 +00:00
|
|
|
|
2005-08-14 00:47:04 +00:00
|
|
|
/* Settings: */
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
CString g_sQuestion;
|
|
|
|
|
CString g_sInitialAnswer;
|
|
|
|
|
int g_iMaxInputLength;
|
|
|
|
|
bool(*g_pValidate)(const CString &sAnswer,CString &sErrorOut);
|
|
|
|
|
void(*g_pOnOK)(const CString &sAnswer);
|
|
|
|
|
void(*g_pOnCancel)();
|
|
|
|
|
bool g_bPassword;
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-03 04:42:47 +00:00
|
|
|
void ScreenTextEntry::TextEntry(
|
|
|
|
|
ScreenMessage smSendOnPop,
|
|
|
|
|
CString sQuestion,
|
|
|
|
|
CString sInitialAnswer,
|
|
|
|
|
int iMaxInputLength,
|
2005-07-05 23:13:49 +00:00
|
|
|
bool(*Validate)(const CString &sAnswer,CString &sErrorOut),
|
|
|
|
|
void(*OnOK)(const CString &sAnswer),
|
2005-07-03 04:42:47 +00:00
|
|
|
void(*OnCancel)(),
|
|
|
|
|
bool bPassword
|
|
|
|
|
)
|
|
|
|
|
{
|
2005-08-14 00:47:04 +00:00
|
|
|
g_sQuestion = sQuestion;
|
|
|
|
|
g_sInitialAnswer = sInitialAnswer;
|
|
|
|
|
g_iMaxInputLength = iMaxInputLength;
|
|
|
|
|
g_pValidate = Validate;
|
|
|
|
|
g_pOnOK = OnOK;
|
|
|
|
|
g_pOnCancel = OnCancel;
|
|
|
|
|
g_bPassword = bPassword;
|
|
|
|
|
|
|
|
|
|
SCREENMAN->AddNewScreenToTop( "ScreenTextEntry", smSendOnPop );
|
2005-07-03 04:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
bool ScreenTextEntry::s_bCancelledLast = false;
|
|
|
|
|
|
2005-08-13 00:03:56 +00:00
|
|
|
/*
|
2003-01-06 07:43:14 +00:00
|
|
|
* Handle UTF-8. Right now, we need to at least be able to backspace
|
2005-08-13 00:03:56 +00:00
|
|
|
* a whole UTF-8 character. Better would be to operate in wchar_t.
|
|
|
|
|
*
|
|
|
|
|
* XXX: Don't allow internal-use codepoints (above 0xFFFF); those are
|
|
|
|
|
* subject to change and shouldn't be written to disk.
|
2003-01-06 07:43:14 +00:00
|
|
|
*/
|
2005-08-14 00:47:04 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenTextEntry );
|
2005-01-26 08:50:09 +00:00
|
|
|
|
2005-08-12 22:46:32 +00:00
|
|
|
ScreenTextEntry::ScreenTextEntry( CString sClassName ) :
|
2005-07-15 01:51:32 +00:00
|
|
|
ScreenWithMenuElements( sClassName )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
2005-02-23 06:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::Init()
|
|
|
|
|
{
|
2005-07-15 01:51:32 +00:00
|
|
|
ScreenWithMenuElements::Init();
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
m_textQuestion.LoadFromFont( THEME->GetPathF(m_sName,"question") );
|
|
|
|
|
m_textQuestion.SetName( "Question" );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textQuestion );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
m_sprAnswerBox.Load( THEME->GetPathG(m_sName,"AnswerBox") );
|
|
|
|
|
m_sprAnswerBox->SetName( "AnswerBox" );
|
|
|
|
|
this->AddChild( m_sprAnswerBox );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
m_textAnswer.LoadFromFont( THEME->GetPathF(m_sName,"answer") );
|
|
|
|
|
m_textAnswer.SetName( "Answer" );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textAnswer );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-09-02 21:36:56 +00:00
|
|
|
m_bShowAnswerCaret = false;
|
2005-03-22 20:15:24 +00:00
|
|
|
|
|
|
|
|
m_sprCursor.Load( THEME->GetPathG(m_sName,"cursor") );
|
|
|
|
|
m_sprCursor->SetName( "Cursor" );
|
|
|
|
|
this->AddChild( m_sprCursor );
|
|
|
|
|
|
|
|
|
|
// Init keyboard
|
|
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
BitmapText text;
|
|
|
|
|
text.LoadFromFont( THEME->GetPathF(m_sName,"keyboard") );
|
|
|
|
|
text.SetName( "Keys" );
|
|
|
|
|
ActorUtil::LoadAllCommands( text, m_sName );
|
|
|
|
|
text.PlayCommand( "Init" );
|
|
|
|
|
|
|
|
|
|
FOREACH_KeyboardRow( r )
|
2005-03-22 20:15:24 +00:00
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
for( int x=0; x<KEYS_PER_ROW; ++x )
|
|
|
|
|
{
|
|
|
|
|
BitmapText *&pbt = m_ptextKeys[r][x];
|
|
|
|
|
pbt = static_cast<BitmapText *>( text.Copy() );
|
|
|
|
|
this->AddChild( pbt );
|
|
|
|
|
}
|
2005-03-22 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:26:06 +00:00
|
|
|
m_sndType.Load( THEME->GetPathS(m_sName,"type"), true );
|
|
|
|
|
m_sndBackspace.Load( THEME->GetPathS(m_sName,"backspace"), true );
|
2005-03-23 03:41:40 +00:00
|
|
|
m_sndChange.Load( THEME->GetPathS(m_sName,"change"), true );
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
ScreenTextEntry::~ScreenTextEntry()
|
|
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
FOREACH_KeyboardRow( r )
|
|
|
|
|
for( int x=0; x<KEYS_PER_ROW; ++x )
|
|
|
|
|
SAFE_DELETE( m_ptextKeys[r][x] );
|
2005-03-22 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-12 22:46:32 +00:00
|
|
|
void ScreenTextEntry::BeginScreen()
|
|
|
|
|
{
|
2005-08-14 00:47:04 +00:00
|
|
|
m_sAnswer = CStringToWstring( g_sInitialAnswer );
|
|
|
|
|
|
2005-08-12 22:46:32 +00:00
|
|
|
ScreenWithMenuElements::BeginScreen();
|
|
|
|
|
|
2005-08-14 00:47:04 +00:00
|
|
|
m_textQuestion.SetText( g_sQuestion );
|
2005-08-12 22:46:32 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_textQuestion );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_sprAnswerBox );
|
|
|
|
|
SET_XY_AND_ON_COMMAND( m_textAnswer );
|
|
|
|
|
|
|
|
|
|
UpdateAnswerText();
|
|
|
|
|
|
|
|
|
|
ON_COMMAND( m_sprCursor );
|
|
|
|
|
m_iFocusX = 0;
|
|
|
|
|
m_iFocusY = (KeyboardRow)0;
|
|
|
|
|
|
|
|
|
|
FOREACH_KeyboardRow( r )
|
|
|
|
|
{
|
|
|
|
|
for( int x=0; x<KEYS_PER_ROW; ++x )
|
|
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
BitmapText &bt = *m_ptextKeys[r][x];
|
2005-08-12 23:39:26 +00:00
|
|
|
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 ) );
|
|
|
|
|
bt.SetXY( fX, fY );
|
2005-08-12 22:46:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateKeyboardText();
|
|
|
|
|
|
|
|
|
|
PositionCursor();
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
void ScreenTextEntry::UpdateKeyboardText()
|
|
|
|
|
{
|
|
|
|
|
FOREACH_KeyboardRow( r )
|
|
|
|
|
{
|
2005-03-23 21:04:40 +00:00
|
|
|
for( int x=0; x<KEYS_PER_ROW; ++x )
|
2005-03-22 20:15:24 +00:00
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
CString s = g_szKeys[r][x];
|
|
|
|
|
if( !s.empty() && r == KEYBOARD_ROW_SPECIAL )
|
|
|
|
|
s = THEME->GetMetric( "ScreenTextEntry", s );
|
|
|
|
|
BitmapText &bt = *m_ptextKeys[r][x];
|
2005-03-22 23:58:16 +00:00
|
|
|
bt.SetText( s );
|
2005-03-22 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::UpdateAnswerText()
|
2003-01-18 09:18:30 +00:00
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
CString s = WStringToCString(m_sAnswer);
|
2005-08-14 00:47:04 +00:00
|
|
|
if( g_bPassword )
|
2005-03-22 20:15:24 +00:00
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
int len = s.GetLength();
|
|
|
|
|
s = "";
|
2005-03-22 20:15:24 +00:00
|
|
|
for( int i=0; i<len; ++i )
|
2005-09-02 21:36:56 +00:00
|
|
|
s += '*';
|
2005-01-26 08:50:09 +00:00
|
|
|
}
|
2005-09-02 21:36:56 +00:00
|
|
|
|
|
|
|
|
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 );
|
2003-01-18 09:18:30 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
void ScreenTextEntry::PositionCursor()
|
|
|
|
|
{
|
2005-09-02 21:36:56 +00:00
|
|
|
BitmapText &bt = *m_ptextKeys[m_iFocusY][m_iFocusX];
|
2005-03-22 23:58:16 +00:00
|
|
|
m_sprCursor->SetXY( bt.GetX(), bt.GetY() );
|
2005-09-02 21:36:56 +00:00
|
|
|
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();
|
|
|
|
|
}
|
2005-03-22 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-23 20:18:29 +00:00
|
|
|
void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2005-03-23 05:12:31 +00:00
|
|
|
if( m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Cancel.IsTransitioning() )
|
2002-08-23 20:18:29 +00:00
|
|
|
return;
|
|
|
|
|
|
2005-03-31 22:47:21 +00:00
|
|
|
//The user wants to input text traditionally
|
2005-05-06 20:41:05 +00:00
|
|
|
if ( g_bAllowOldKeyboardInput.Get() && ( type == IET_FIRST_PRESS ) )
|
2005-03-31 22:47:21 +00:00
|
|
|
{
|
|
|
|
|
if ( DeviceI.button == KEY_BACK )
|
|
|
|
|
{
|
|
|
|
|
BackspaceInAnswer();
|
|
|
|
|
}
|
|
|
|
|
else if ( DeviceI.ToChar() >= ' ' )
|
|
|
|
|
{
|
2005-04-02 20:18:01 +00:00
|
|
|
bool bIsHoldingShift =
|
|
|
|
|
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)) ||
|
|
|
|
|
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT));
|
|
|
|
|
if ( bIsHoldingShift )
|
2005-04-03 01:52:53 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char c = (char)toupper( DeviceI.ToChar() );
|
|
|
|
|
|
|
|
|
|
switch( c )
|
|
|
|
|
{
|
|
|
|
|
case '`': c='~'; break;
|
|
|
|
|
case '1': c='!'; break;
|
|
|
|
|
case '2': c='@'; break;
|
|
|
|
|
case '3': c='#'; break;
|
|
|
|
|
case '4': c='$'; break;
|
|
|
|
|
case '5': c='%'; break;
|
|
|
|
|
case '6': c='^'; break;
|
|
|
|
|
case '7': c='&'; break;
|
|
|
|
|
case '8': c='*'; break;
|
|
|
|
|
case '9': c='('; break;
|
|
|
|
|
case '0': c=')'; break;
|
|
|
|
|
case '-': c='_'; break;
|
|
|
|
|
case '=': c='+'; break;
|
|
|
|
|
case '[': c='{'; break;
|
|
|
|
|
case ']': c='}'; break;
|
|
|
|
|
case '\'': c='"'; break;
|
|
|
|
|
case '\\': c='|'; break;
|
|
|
|
|
case ';': c=':'; break;
|
|
|
|
|
case ',': c='<'; break;
|
|
|
|
|
case '.': c='>'; break;
|
|
|
|
|
case '/': c='?'; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppendToAnswer( ssprintf( "%c", c ) );
|
|
|
|
|
}
|
2005-04-02 20:18:01 +00:00
|
|
|
else
|
|
|
|
|
AppendToAnswer( ssprintf( "%c", DeviceI.ToChar() ) );
|
2005-03-31 22:47:21 +00:00
|
|
|
|
|
|
|
|
//If the user wishes to select text in traditional way, start should finish text entry
|
|
|
|
|
m_iFocusY = KEYBOARD_ROW_SPECIAL;
|
|
|
|
|
m_iFocusX = DONE;
|
|
|
|
|
|
|
|
|
|
UpdateKeyboardText();
|
|
|
|
|
PositionCursor();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-15 01:51:32 +00:00
|
|
|
ScreenWithMenuElements::Input( DeviceI, type, GameI, MenuI, StyleI );
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
void ScreenTextEntry::MoveX( int iDir )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
2005-03-22 23:58:16 +00:00
|
|
|
CString sKey;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
m_iFocusX += iDir;
|
|
|
|
|
wrap( m_iFocusX, KEYS_PER_ROW );
|
|
|
|
|
|
|
|
|
|
sKey = g_szKeys[m_iFocusY][m_iFocusX];
|
|
|
|
|
}
|
|
|
|
|
while( sKey == "" );
|
2005-03-22 20:15:24 +00:00
|
|
|
|
2005-03-23 03:41:40 +00:00
|
|
|
m_sndChange.Play();
|
2005-03-22 20:15:24 +00:00
|
|
|
PositionCursor();
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-22 20:15:24 +00:00
|
|
|
void ScreenTextEntry::MoveY( int iDir )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
2005-03-22 23:58:16 +00:00
|
|
|
CString sKey;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
m_iFocusY = (KeyboardRow)(m_iFocusY + iDir);
|
|
|
|
|
wrap( (int&)m_iFocusY, NUM_KEYBOARD_ROWS );
|
|
|
|
|
|
|
|
|
|
// HACK: Round to nearest option so that we always stop
|
|
|
|
|
// on KEYBOARD_ROW_SPECIAL.
|
|
|
|
|
if( m_iFocusY == KEYBOARD_ROW_SPECIAL )
|
|
|
|
|
{
|
|
|
|
|
for( int i=0; true; i++ )
|
|
|
|
|
{
|
|
|
|
|
sKey = g_szKeys[m_iFocusY][m_iFocusX];
|
|
|
|
|
if( sKey != "" )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// UGLY: Probe one space to the left before looking to the right
|
|
|
|
|
m_iFocusX += (i==0) ? -1 : +1;
|
|
|
|
|
wrap( m_iFocusX, KEYS_PER_ROW );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sKey = g_szKeys[m_iFocusY][m_iFocusX];
|
|
|
|
|
}
|
|
|
|
|
while( sKey == "" );
|
2005-03-22 20:15:24 +00:00
|
|
|
|
2005-03-23 03:41:40 +00:00
|
|
|
m_sndChange.Play();
|
2005-03-22 20:15:24 +00:00
|
|
|
PositionCursor();
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-22 23:58:16 +00:00
|
|
|
void ScreenTextEntry::AppendToAnswer( CString s )
|
|
|
|
|
{
|
2005-03-23 04:08:27 +00:00
|
|
|
wstring sNewAnswer = m_sAnswer+CStringToWstring(s);
|
2005-08-14 00:47:04 +00:00
|
|
|
if( (int)sNewAnswer.length() > g_iMaxInputLength )
|
2005-03-23 04:08:27 +00:00
|
|
|
{
|
|
|
|
|
SCREENMAN->PlayInvalidSound();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_sAnswer = sNewAnswer;
|
2005-03-22 23:58:16 +00:00
|
|
|
m_sndType.Play();
|
|
|
|
|
UpdateAnswerText();
|
|
|
|
|
|
|
|
|
|
UpdateKeyboardText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::BackspaceInAnswer()
|
|
|
|
|
{
|
2005-03-23 03:36:30 +00:00
|
|
|
if( m_sAnswer.empty() )
|
|
|
|
|
{
|
|
|
|
|
SCREENMAN->PlayInvalidSound();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-03-22 23:58:16 +00:00
|
|
|
m_sAnswer.erase( m_sAnswer.end()-1 );
|
|
|
|
|
m_sndBackspace.Play();
|
|
|
|
|
UpdateAnswerText();
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuStart( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
2005-03-22 20:15:24 +00:00
|
|
|
if( m_iFocusY == KEYBOARD_ROW_SPECIAL )
|
|
|
|
|
{
|
|
|
|
|
switch( m_iFocusX )
|
|
|
|
|
{
|
|
|
|
|
case SPACEBAR:
|
2005-03-22 23:58:16 +00:00
|
|
|
AppendToAnswer( " " );
|
2005-03-22 20:15:24 +00:00
|
|
|
break;
|
|
|
|
|
case BACKSPACE:
|
2005-03-22 23:58:16 +00:00
|
|
|
BackspaceInAnswer();
|
|
|
|
|
break;
|
|
|
|
|
case CANCEL:
|
|
|
|
|
End( true );
|
2005-03-22 20:15:24 +00:00
|
|
|
break;
|
|
|
|
|
case DONE:
|
2005-03-22 23:58:16 +00:00
|
|
|
End( false );
|
2005-03-22 20:15:24 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-03-22 23:58:16 +00:00
|
|
|
AppendToAnswer( g_szKeys[m_iFocusY][m_iFocusX] );
|
2005-03-22 20:15:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2005-03-22 23:58:16 +00:00
|
|
|
void ScreenTextEntry::End( bool bCancelled )
|
2005-03-22 20:15:24 +00:00
|
|
|
{
|
2005-03-22 23:58:16 +00:00
|
|
|
if( bCancelled )
|
2003-11-01 19:36:52 +00:00
|
|
|
{
|
2005-08-14 00:47:04 +00:00
|
|
|
if( g_pOnCancel )
|
|
|
|
|
g_pOnCancel();
|
2005-03-23 05:12:31 +00:00
|
|
|
|
2005-07-14 03:50:19 +00:00
|
|
|
m_Cancel.StartTransitioning( SM_GoToNextScreen );
|
2005-03-23 05:12:31 +00:00
|
|
|
}
|
|
|
|
|
else
|
2003-11-01 19:36:52 +00:00
|
|
|
{
|
2005-03-23 05:12:31 +00:00
|
|
|
CString sAnswer = WStringToCString(m_sAnswer);
|
|
|
|
|
CString sError;
|
2005-08-14 00:47:04 +00:00
|
|
|
if ( g_pValidate != NULL )
|
2005-03-23 05:12:31 +00:00
|
|
|
{
|
2005-08-14 00:47:04 +00:00
|
|
|
bool bValidAnswer = g_pValidate( sAnswer, sError );
|
2005-03-26 22:59:13 +00:00
|
|
|
if( !bValidAnswer )
|
|
|
|
|
{
|
2005-07-03 04:34:53 +00:00
|
|
|
ScreenPrompt::Prompt( SM_None, sError );
|
2005-03-26 22:59:13 +00:00
|
|
|
return; // don't end this screen.
|
|
|
|
|
}
|
2005-03-23 05:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-14 00:47:04 +00:00
|
|
|
if( g_pOnOK )
|
2003-01-06 07:43:14 +00:00
|
|
|
{
|
2003-01-28 00:45:01 +00:00
|
|
|
CString ret = WStringToCString(m_sAnswer);
|
2003-01-16 20:21:07 +00:00
|
|
|
FontCharAliases::ReplaceMarkers(ret);
|
2005-08-14 00:47:04 +00:00
|
|
|
g_pOnOK( ret );
|
2003-01-06 07:43:14 +00:00
|
|
|
}
|
2005-03-23 05:12:31 +00:00
|
|
|
|
2005-07-14 03:50:19 +00:00
|
|
|
m_Out.StartTransitioning( SM_GoToNextScreen );
|
2005-03-23 05:12:31 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2002-09-16 22:33:44 +00:00
|
|
|
}
|
2003-11-01 19:36:52 +00:00
|
|
|
|
2005-03-23 05:12:31 +00:00
|
|
|
OFF_COMMAND( m_textQuestion );
|
|
|
|
|
OFF_COMMAND( m_sprAnswerBox );
|
|
|
|
|
OFF_COMMAND( m_textAnswer );
|
|
|
|
|
OFF_COMMAND( m_sprCursor );
|
|
|
|
|
|
2005-03-23 04:08:27 +00:00
|
|
|
s_bCancelledLast = bCancelled;
|
|
|
|
|
s_sLastAnswer = bCancelled ? CString("") : WStringToCString(m_sAnswer);
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuBack( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
2005-03-22 23:58:16 +00:00
|
|
|
End( true );
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|