diff --git a/stepmania/Themes/default/BGAnimations/ScreenTextEntry in.redir b/stepmania/Themes/default/BGAnimations/ScreenTextEntry in.redir index 3f7392358b..c19a0bafb9 100644 --- a/stepmania/Themes/default/BGAnimations/ScreenTextEntry in.redir +++ b/stepmania/Themes/default/BGAnimations/ScreenTextEntry in.redir @@ -1 +1 @@ -_prompt in normal +_prompt in instant diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 888185dd21..a39c620c6e 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -4398,3 +4398,18 @@ Fallback=ScreenMiniMenu [ScreenMiniMenuCourseOptions] Fallback=ScreenMiniMenu +[ScreenTextEntry] +QuestionX=SCREEN_CENTER_X +QuestionY=SCREEN_CENTER_Y-150 +QuestionOnCommand= +QuestionOffCommand= +AnswerBoxX=SCREEN_CENTER_X +AnswerBoxY=SCREEN_CENTER_Y-100 +AnswerBoxOnCommand= +AnswerBoxOffCommand= +AnswerX=SCREEN_CENTER_X +AnswerY=SCREEN_CENTER_Y-100 +AnswerOnCommand= +AnswerOffCommand= +CursorOnCommand= +CursorOffCommand= \ No newline at end of file diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 511a841e8d..cd412bd2c5 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -90,8 +90,6 @@ StyleInput.h TimingData.cpp TimingData.h \ ThemeMetric.h \ Trail.cpp Trail.h TrailUtil.cpp TrailUtil.h TitleSubstitution.cpp TitleSubstitution.h -VirtualKeyboard = VirtualKeyboard.cpp VirtualKeyboard.h - FileTypes = IniFile.cpp IniFile.h \ MsdFile.cpp MsdFile.h \ XmlFile.cpp XmlFile.h @@ -338,7 +336,6 @@ CryptHelpers.cpp CryptHelpers.h main_SOURCES = $(Screens) \ $(DataStructures) \ - $(VirtualKeyboard) \ $(FileTypes) \ $(StepMania) \ $(Arch) \ diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 09161bb45b..96e8989570 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -319,10 +319,7 @@ void PrefsManager::Init() m_sMemoryCardProfileSubdir = PRODUCT_NAME; m_iProductID = 1; - m_bEnableVirtualKeyboard = false; - #if defined(XBOX) - m_bEnableVirtualKeyboard = true; m_bEnableVirtualMemory = true; m_iPageFileSize = 384; m_iPageSize = 16; @@ -532,8 +529,6 @@ void PrefsManager::ReadGlobalPrefsFromIni( const IniFile &ini ) FixSlashesInPlace(m_sAdditionalSongFolders); FixSlashesInPlace(m_sAdditionalFolders); - ini.GetValue( "Options", "EnableVirtualKeyboard", m_bEnableVirtualKeyboard ); - #if defined(XBOX) ini.GetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory ); ini.GetValue( "Options", "PageFileSize", m_iPageFileSize ); @@ -766,8 +761,6 @@ void PrefsManager::SaveGlobalPrefsToIni( IniFile &ini ) const ini.SetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders); ini.SetValue( "Options", "AdditionalFolders", m_sAdditionalFolders); - ini.SetValue( "Options", "EnableVirtualKeyboard", m_bEnableVirtualKeyboard ); - #if defined(XBOX) ini.SetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory ); ini.SetValue( "Options", "PageFileSize", m_iPageFileSize ); diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index cb0feb9b78..50bd99267e 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -278,9 +278,6 @@ public: /* Game-specific prefs: */ CString m_sDefaultModifiers; - // Virtual keyboard - bool m_bEnableVirtualKeyboard; - #if defined(XBOX) // Virtual memory preferences bool m_bEnableVirtualMemory; diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index baa2d0d11d..d941bf0895 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -194,50 +194,39 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) break; case EDIT_MENU_ACTION_COPY: case EDIT_MENU_ACTION_AUTOGEN: - ASSERT( !pSteps ); - ASSERT( pSourceSteps ); - { - // Yuck. Doing the memory allocation doesn't seem right since - // Song allocates all of the other Steps. - pSteps = new Steps; - switch( action ) - { - case EDIT_MENU_ACTION_COPY: - pSteps->CopyFrom( pSourceSteps, st ); - break; - case EDIT_MENU_ACTION_AUTOGEN: - pSteps->AutogenFrom( pSourceSteps, st ); - pSteps->DeAutogen(); - break; - default: - ASSERT(0); - } - pSteps->SetDifficulty( dc ); // override difficulty with the user's choice - CString sEditName = GetCopyDescription(pSourceSteps); - pSong->MakeUniqueEditDescription( st, sEditName ); - pSteps->SetDescription( sEditName ); - pSong->AddSteps( pSteps ); - - SCREENMAN->PlayStartSound(); - - GAMESTATE->m_pCurSong.Set( pSong ); - GAMESTATE->m_pCurSteps[0].Set( pSteps ); - } - break; case EDIT_MENU_ACTION_BLANK: ASSERT( !pSteps ); { // Yuck. Doing the memory allocation doesn't seem right since // Song allocates all of the other Steps. pSteps = new Steps; - pSteps->CreateBlank( st ); - pSteps->SetDifficulty( dc ); - pSteps->SetMeter( 1 ); - CString sEditName = "Blank"; + CString sEditName; + switch( action ) + { + case EDIT_MENU_ACTION_COPY: + ASSERT( pSourceSteps ); + pSteps->CopyFrom( pSourceSteps, st ); + sEditName = GetCopyDescription(pSourceSteps); + break; + case EDIT_MENU_ACTION_AUTOGEN: + ASSERT( pSourceSteps ); + pSteps->AutogenFrom( pSourceSteps, st ); + pSteps->DeAutogen(); + sEditName = GetCopyDescription(pSourceSteps); + break; + case EDIT_MENU_ACTION_BLANK: + pSteps->CreateBlank( st ); + pSteps->SetMeter( 1 ); + sEditName = "Blank"; + break; + default: + ASSERT(0); + } + pSteps->SetDifficulty( dc ); // override difficulty with the user's choice pSong->MakeUniqueEditDescription( st, sEditName ); pSteps->SetDescription( sEditName ); pSong->AddSteps( pSteps ); - + SCREENMAN->PlayStartSound(); GAMESTATE->m_pCurSong.Set( pSong ); @@ -262,7 +251,8 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn ) ASSERT( pSteps ); SOUND->StopMusic(); SCREENMAN->PlayStartSound(); - StartTransitioning( SM_GoToNextScreen ); + //StartTransitioning( SM_GoToNextScreen ); + SCREENMAN->TextEntry( SM_None, "Testing", ""); break; case EDIT_MENU_ACTION_DELETE: break; diff --git a/stepmania/src/ScreenNetRoom.cpp b/stepmania/src/ScreenNetRoom.cpp index 6fe81469f6..b9a344ae36 100644 --- a/stepmania/src/ScreenNetRoom.cpp +++ b/stepmania/src/ScreenNetRoom.cpp @@ -8,7 +8,6 @@ #include "ThemeManager.h" #include "ScreenTextEntry.h" #include "ScreenManager.h" -#include "VirtualKeyboard.h" #include "Command.h" #define TITLEBG_WIDTH THEME->GetMetricF(m_sName,"TitleBGWidth") @@ -144,14 +143,15 @@ void ScreenNetRoom::HandleScreenMessage( const ScreenMessage SM ) } break; case SM_BackFromRoomName: - if ( !ScreenTextEntry::s_bCancelledLast ) { + if ( !ScreenTextEntry::s_bCancelledLast ) + { m_newRoomName = ScreenTextEntry::s_sLastAnswer; - VIRTUALKB.Reset(VKMODE_PROFILE); // allow all characters SCREENMAN->TextEntry( SM_BackFromRoomDesc, "Enter Room Description:", ""); } break; case SM_BackFromRoomDesc: - if ( !ScreenTextEntry::s_bCancelledLast ) { + if ( !ScreenTextEntry::s_bCancelledLast ) + { m_newRoomDesc = ScreenTextEntry::s_sLastAnswer; CreateNewRoom( m_newRoomName, m_newRoomDesc); } @@ -192,7 +192,6 @@ void ScreenNetRoom::MenuStart( PlayerNumber pn ) } break; case SelectMakeRoom: - VIRTUALKB.Reset(VKMODE_PROFILE); // allow all characters SCREENMAN->TextEntry( SM_BackFromRoomName, "Enter Room Name:", ""); break; }; diff --git a/stepmania/src/ScreenNetworkOptions.cpp b/stepmania/src/ScreenNetworkOptions.cpp index 4b0dd3ab11..36755d9013 100644 --- a/stepmania/src/ScreenNetworkOptions.cpp +++ b/stepmania/src/ScreenNetworkOptions.cpp @@ -11,7 +11,6 @@ #include "ScreenTextEntry.h" #include "ScreenPrompt.h" #include "NetworkSyncServer.h" -#include "VirtualKeyboard.h" enum { PO_CONNECTION, @@ -123,10 +122,10 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type case PO_CONNECTION: if ( !NSMAN->useSMserver ) { - VIRTUALKB.Reset(VKMODE_IP); SCREENMAN->TextEntry( SM_DoneConnecting, "Enter a Network Address\n127.0.0.1 to connect to yourself", g_sLastServer ); } - else { + else + { NSMAN->CloseConnection(); SCREENMAN->SystemMessage("Disconnected from server."); UpdateConnectStatus( ); @@ -138,7 +137,6 @@ void ScreenNetworkOptions::MenuStart( PlayerNumber pn, const InputEventType type case NO_START_SERVER: if (!NSMAN->isLanServer) { - VIRTUALKB.Reset(VKMODE_PROFILE); SCREENMAN->TextEntry( SM_ServerNameEnter, "Enter a server name...", "", NULL ); } break; diff --git a/stepmania/src/ScreenPackages.cpp b/stepmania/src/ScreenPackages.cpp index 6f418f58da..b943d22bb0 100644 --- a/stepmania/src/ScreenPackages.cpp +++ b/stepmania/src/ScreenPackages.cpp @@ -11,7 +11,6 @@ #include "RageFile.h" #include "ScreenTextEntry.h" #include "ScreenManager.h" -#include "VirtualKeyboard.h" #include #define EXISTINGBG_WIDTH THEME->GetMetricF(m_sName,"PackagesBGWidth") @@ -165,14 +164,9 @@ void ScreenPackages::MenuStart( PlayerNumber pn ) if ( m_iDLorLST == 1 ) { if ( m_iLinksPos == 0 ) - { - VIRTUALKB.Reset(VKMODE_PROFILE); // allow all characters SCREENMAN->TextEntry( SM_BackFromURL, "Enter URL:", "http://" ); - } else - { EnterURL( m_Links[m_iLinksPos] ); - } } ScreenWithMenuElements::MenuStart( pn ); } diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index ff49303d8f..e6414b6088 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -8,7 +8,6 @@ #include "ScreenManager.h" #include "ScreenTextEntry.h" #include "ScreenPrompt.h" -#include "VirtualKeyboard.h" #include "GameState.h" @@ -197,9 +196,6 @@ void ScreenProfileOptions::MenuStart( PlayerNumber pn, const InputEventType type switch( GetCurrentRow() ) { case PO_CREATE_NEW: - - VIRTUALKB.Reset(VKMODE_PROFILE); // set the xbox virtual keyboard to profile mode - SCREENMAN->TextEntry( SM_DoneCreating, "Enter a profile name", "", NULL ); break; case PO_DELETE_: diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index f53e61b572..7866b22287 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -9,7 +9,6 @@ #include "ScreenManager.h" #include "ScreenTextEntry.h" #include "ScreenPrompt.h" -#include "VirtualKeyboard.h" #include "GameState.h" #include "NetworkSyncManager.h" #include "ScreenTextEntry.h" diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index 70188e622e..31be4ae93c 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -8,16 +8,22 @@ #include "ThemeManager.h" #include "FontCharAliases.h" #include "ScreenDimensions.h" -#include "VirtualKeyboard.h" +#include "ActorUtil.h" -#define QUESTION_X (SCREEN_CENTER_X) -#define QUESTION_Y (SCREEN_CENTER_Y - 60) +const SPECIAL_KEY_WIDTH = 3; // special keys are 3x as wide as normal keys -#define ANSWER_X (SCREEN_CENTER_X) -#define ANSWER_Y (SCREEN_CENTER_Y + 120) -#define ANSWER_WIDTH (440) -#define ANSWER_HEIGHT (30) +const int MAX_KEYS_PER_ROW = 13; + +float GetButtonX( int x ) +{ + return roundf( SCALE( x, 0, MAX_KEYS_PER_ROW-1, SCREEN_LEFT+100, SCREEN_RIGHT-100 ) ); +} + +float GetButtonY( KeyboardRow r ) +{ + return roundf( SCALE( r, 0, NUM_KEYBOARD_ROWS-1, SCREEN_CENTER_Y, SCREEN_BOTTOM-100 ) ); +} CString ScreenTextEntry::s_sLastAnswer = ""; bool ScreenTextEntry::s_bCancelledLast = false; @@ -34,13 +40,15 @@ bool ScreenTextEntry::s_bCancelledLast = false; ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString sInitialAnswer, 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_sAnswer = CStringToWstring( sInitialAnswer ); m_bCancelled = false; m_sQuestion = sQuestion; @@ -48,46 +56,146 @@ ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString void ScreenTextEntry::Init() { - m_Background.LoadFromAniDir( THEME->GetPathB("ScreenPrompt","background") ); - this->AddChild( &m_Background ); + m_Background.Load( THEME->GetPathB(m_sName,"background") ); + m_Background->SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING ); + this->AddChild( m_Background ); + m_Background->PlayCommand( "On" ); - m_textQuestion.LoadFromFont( THEME->GetPathF("Common","normal") ); + m_textQuestion.LoadFromFont( THEME->GetPathF(m_sName,"question") ); + m_textQuestion.SetName( "Question" ); m_textQuestion.SetText( m_sQuestion ); - m_textQuestion.SetXY( QUESTION_X, QUESTION_Y ); + SET_XY_AND_ON_COMMAND( m_textQuestion ); this->AddChild( &m_textQuestion ); - m_rectAnswerBox.SetDiffuse( RageColor(0.5f,0.5f,1.0f,0.7f) ); - m_rectAnswerBox.SetXY( ANSWER_X, ANSWER_Y ); - m_rectAnswerBox.SetZoomX( ANSWER_WIDTH ); - m_rectAnswerBox.SetZoomY( ANSWER_HEIGHT ); - this->AddChild( &m_rectAnswerBox ); + 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("Common","title") ); - m_textAnswer.SetXY( ANSWER_X, ANSWER_Y ); - UpdateText(); + 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_In.Load( THEME->GetPathB("ScreenPrompt","in") ); + + 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; + + + // Fill in m_Keys + { + static const char* g_szKeys[NUM_KEYBOARD_CASES][NUM_KEYBOARD_ROWS][MAX_KEYS_PER_ROW+1] = + { + { + {"`","1","2","3","4","5","6","7","8","9","0","-","=",NULL}, + {"q","w","e","r","t","y","u","i","o","p","[","]","\\",NULL}, + {"a","s","d","f","g","h","j","k","l",";","\"",NULL}, + {"z","x","c","v","b","n","m",",",".","/",NULL}, + {"Caps","Space","Backsp","Done",NULL} + }, + { + {"~","!","@","#","$","%","^","&","*","(",")","_","+",NULL}, + {"Q","W","E","R","T","Y","U","I","O","P","{","}","|",NULL}, + {"A","S","D","F","G","H","J","K","L",":","'",NULL}, + {"Z","X","C","V","B","N","M","<",">","?",NULL}, + {"CAPS","Space","Backsp","Done",NULL} + } + }; + FOREACH_KeyboardCase( k ) + { + FOREACH_KeyboardRow( r ) + { + for( int x=0; true; x++ ) + { + const char *c=g_szKeys[LOWERCASE][r][x]; + if( c == NULL ) + break; + m_Keys[k][r].push_back( c ); + + } + + ASSERT_M( m_Keys[k][r].size() == m_Keys[0][r].size(), "uppercase and lowercase sizes don't match" ); + } + } + } + + // Init keyboard + FOREACH_KeyboardRow( r ) + { + vector &v = m_textKeyboardChars[r]; + const CStringArray &vKeys = m_Keys[LOWERCASE][r]; + for( unsigned x=0; xLoadFromFont( THEME->GetPathF(m_sName,"keyboard") ); + p->SetXY( GetButtonX(x), GetButtonY(r) ); + v.push_back( p ); + this->AddChild( p ); + } + } + + UpdateKeyboardText(); + + PositionCursor(); + + m_In.Load( THEME->GetPathB(m_sName,"in") ); m_In.StartTransitioning(); this->AddChild( &m_In ); - m_Out.Load( THEME->GetPathB("ScreenPrompt","out") ); + m_Out.Load( THEME->GetPathB(m_sName,"out") ); this->AddChild( &m_Out ); } -void ScreenTextEntry::UpdateText() +ScreenTextEntry::~ScreenTextEntry() +{ + for( int i=0; i &v = m_textKeyboardChars[r]; + const CStringArray &vKeys = m_Keys[LOWERCASE][r]; + for( unsigned x=0; xSetText( vKeys[x] ); + } + } +} + +void ScreenTextEntry::UpdateAnswerText() { CString txt = WStringToCString(m_sAnswer); - if(m_bPassword) { - int len = txt.GetLength(); - txt = ""; - for(int i=0;iSetXY( p->GetX(), p->GetY() ); +} + void ScreenTextEntry::Update( float fDeltaTime ) { Screen::Update( fDeltaTime ); @@ -106,95 +214,74 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty if( type != IET_FIRST_PRESS ) return; - int button = DeviceI.button; - - if(PREFSMAN->m_bEnableVirtualKeyboard) + if( !MenuI.IsValid() ) { - bool nextChar = false; - - wchar_t toAdd = VIRTUALKB.Translate(DeviceI, MenuI, m_sAnswer, &nextChar); - - if( toAdd != 0 && toAdd != KEY_BACK && toAdd != KEY_ESC && toAdd != KEY_ENTER ) + switch( DeviceI.button ) { - if(!nextChar) + case KEY_ESC: + m_bCancelled = true; + End(); + break; + case KEY_ENTER: + case KEY_KP_ENTER: + End(); + break; + case KEY_BACK: + if(!m_sAnswer.empty()) + m_sAnswer = m_sAnswer.erase( m_sAnswer.size()-1 ); + UpdateAnswerText(); + break; + default: + char c = DeviceI.ToChar(); + + bool bHoldingShift = + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)); + + // International keyboards often have other keys mapped to shifted keys, and always + // using a US layout is a bit gimped. This is better than nothing though. + if( bHoldingShift ) { - if(!m_sAnswer.empty()) - m_sAnswer = m_sAnswer.erase( m_sAnswer.size()-1 ); + c = (char)toupper(c); + + 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; + } } - - m_sAnswer += toAdd; - - UpdateText(); - return; + + if( c >= ' ' ) + { + m_sAnswer += c; + UpdateAnswerText(); + } + break; } - button = toAdd; + return; // don't let Screen::Input handle } - - switch( button ) - { - case KEY_ESC: - m_bCancelled = true; - MenuStart(PLAYER_1); - break; - case KEY_ENTER: - case KEY_KP_ENTER: - MenuStart(PLAYER_1); - break; - case KEY_BACK: - if(!m_sAnswer.empty()) - m_sAnswer = m_sAnswer.erase( m_sAnswer.size()-1 ); - UpdateText(); - break; - default: - char c; - - c = DeviceI.ToChar(); - - bool bHoldingShift = - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)); - - // International keyboards often have other keys mapped to shifted keys, and always - // using a US layout is a bit gimped. This is better than nothing though. - if( bHoldingShift ) - { - c = (char)toupper(c); - - 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; - } - } - - if( c >= ' ' ) - { - m_sAnswer += c; - UpdateText(); - } - break; - } + Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } void ScreenTextEntry::HandleScreenMessage( const ScreenMessage SM ) @@ -213,28 +300,63 @@ void ScreenTextEntry::HandleScreenMessage( const ScreenMessage SM ) } } -void ScreenTextEntry::MenuLeft( PlayerNumber pn ) +void ScreenTextEntry::MoveX( int iDir ) { + m_iFocusX += iDir; + wrap( m_iFocusX, m_Keys[LOWERCASE][m_iFocusY].size() ); + + PositionCursor(); } -void ScreenTextEntry::MenuRight( PlayerNumber pn ) +void ScreenTextEntry::MoveY( int iDir ) { + m_iFocusY = (KeyboardRow)(m_iFocusY + iDir); + wrap( (int&)m_iFocusY, NUM_KEYBOARD_ROWS ); + CLAMP( m_iFocusX, 0, (int)m_Keys[LOWERCASE][m_iFocusY].size()-1 ); + + PositionCursor(); } void ScreenTextEntry::MenuStart( PlayerNumber pn ) +{ + if( m_iFocusY == KEYBOARD_ROW_SPECIAL ) + { + switch( m_iFocusX ) + { + case CAPS: + break; + case SPACEBAR: + m_sAnswer += CStringToWstring( " " ); + UpdateAnswerText(); + break; + case BACKSPACE: + m_sAnswer.erase( m_sAnswer.end()-1 ); + UpdateAnswerText(); + break; + case DONE: + End(); + break; + default: + break; + } + } + else + { + m_sAnswer += CStringToWstring( m_Keys[LOWERCASE][m_iFocusY][m_iFocusX] ); + UpdateAnswerText(); + } +} + +void ScreenTextEntry::End() { m_Out.StartTransitioning( SM_DoneOpeningWipingRight ); - m_textQuestion.BeginTweening( 0.2f ); - m_textQuestion.SetDiffuse( RageColor(1,1,1,0) ); + m_Background->PlayCommand("Off"); - m_rectAnswerBox.BeginTweening( 0.2f ); - m_rectAnswerBox.SetDiffuse( RageColor(1,1,1,0) ); - - m_textAnswer.SetEffectNone(); - - m_textAnswer.BeginTweening( 0.2f ); - m_textAnswer.SetDiffuse( RageColor(1,1,1,0) ); + OFF_COMMAND( m_textQuestion ); + OFF_COMMAND( m_sprAnswerBox ); + OFF_COMMAND( m_textAnswer ); + OFF_COMMAND( m_sprCursor ); SCREENMAN->PlayStartSound(); @@ -261,7 +383,7 @@ void ScreenTextEntry::MenuStart( PlayerNumber pn ) void ScreenTextEntry::MenuBack( PlayerNumber pn ) { m_bCancelled = true; - MenuStart(pn); + End(); } /* diff --git a/stepmania/src/ScreenTextEntry.h b/stepmania/src/ScreenTextEntry.h index 11c00a271b..8476f07293 100644 --- a/stepmania/src/ScreenTextEntry.h +++ b/stepmania/src/ScreenTextEntry.h @@ -9,11 +9,35 @@ #include "Quad.h" #include "RandomSample.h" #include "BGAnimation.h" +#include "EnumHelper.h" + +enum KeyboardRow +{ + KEYBOARD_ROW_1, + KEYBOARD_ROW_2, + KEYBOARD_ROW_3, + KEYBOARD_ROW_4, + KEYBOARD_ROW_SPECIAL, + NUM_KEYBOARD_ROWS +}; +#define FOREACH_KeyboardRow( i ) FOREACH_ENUM( KeyboardRow, NUM_KEYBOARD_ROWS, i ) +enum KeyboardRowSpecialKey +{ + CAPS, SPACEBAR, BACKSPACE, DONE +}; +enum KeyboardCase +{ + LOWERCASE, + UPPERCASE, + NUM_KEYBOARD_CASES +}; +#define FOREACH_KeyboardCase( i ) FOREACH_ENUM( KeyboardCase, NUM_KEYBOARD_CASES, i ) class ScreenTextEntry : public Screen { public: ScreenTextEntry( CString sName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL, bool bPassword = false ); + ~ScreenTextEntry(); virtual void Init(); virtual void Update( float fDeltaTime ); @@ -25,27 +49,47 @@ public: static bool s_bCancelledLast; protected: - virtual void MenuLeft( PlayerNumber pn ); - virtual void MenuRight( PlayerNumber pn ); + void MoveX( int iDir ); + void MoveY( int iDir ); + + void End(); + + virtual void MenuLeft( PlayerNumber pn ) { MoveX(-1); } + virtual void MenuRight( PlayerNumber pn ) { MoveX(+1); } + virtual void MenuUp( PlayerNumber pn ) { MoveY(-1); } + virtual void MenuDown( PlayerNumber pn ) { MoveY(+1); } virtual void MenuStart( PlayerNumber pn ); virtual void MenuBack( PlayerNumber pn ); - void UpdateText(); + void UpdateKeyboardText(); + void UpdateAnswerText(); CString m_sQuestion; bool m_bPassword; - BGAnimation m_Background; + AutoActor m_Background; BitmapText m_textQuestion; - Quad m_rectAnswerBox; + AutoActor m_sprAnswerBox; wstring m_sAnswer; BitmapText m_textAnswer; void(*m_pOnOK)( CString sAnswer ); void(*m_pOnCancel)(); bool m_bCancelled; + + AutoActor m_sprCursor; + + int m_iFocusX; + KeyboardRow m_iFocusY; + + void PositionCursor(); + + vector m_Keys[NUM_KEYBOARD_CASES][NUM_KEYBOARD_ROWS]; + vector m_textKeyboardChars[NUM_KEYBOARD_ROWS]; + Transition m_In; Transition m_Out; }; + #endif /* diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index e02329286b..9f7572bb2f 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -3178,14 +3178,6 @@ SOURCE=.\UnlockManager.cpp SOURCE=.\UnlockManager.h # End Source File -# Begin Source File - -SOURCE=.\VirtualKeyboard.cpp -# End Source File -# Begin Source File - -SOURCE=.\VirtualKeyboard.h -# End Source File # End Group # Begin Group "Crypto" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index a2ddb190c7..011ea88fcb 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -2544,12 +2544,6 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ - - - - diff --git a/stepmania/src/VirtualKeyboard.cpp b/stepmania/src/VirtualKeyboard.cpp deleted file mode 100644 index 53577b47f0..0000000000 --- a/stepmania/src/VirtualKeyboard.cpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Commands are mapped as follows: - * left - delete - * right - move cursor right (with space as default character) - * up/down - change right most character to next/previous character - */ - -#include "global.h" -#include "VirtualKeyboard.h" -#include "RageUtil.h" - -VirtualKeyboard VIRTUALKB; - -VirtualKeyboard::VirtualKeyboard() -{ - currentMode = VKMODE_PROFILE; -} - -VirtualKeyboard::~VirtualKeyboard() -{ -} - -void VirtualKeyboard::Reset( VirtualKeyboardMode mode ) -{ - currentMode = mode; -} - -wchar_t VirtualKeyboard::Translate( const DeviceInput& DeviceI, const MenuInput &MenuI, const wstring &cur_string, bool *nextChar ) -{ - *nextChar = false; - MenuButton button = MenuI.button; - - switch( button ) - { - case MENU_BUTTON_LEFT: return KEY_BACK; - case MENU_BUTTON_START: return KEY_ENTER; - case MENU_BUTTON_BACK: return KEY_ESC; - } - - if(button == MENU_BUTTON_RIGHT) - { - *nextChar = true; - switch( currentMode ) - { - case VKMODE_PROFILE: return ' '; - case VKMODE_IP: return '0'; - default: FAIL_M( ssprintf("%i", currentMode) ); - } - } - else if(button == MENU_BUTTON_UP) - { - if(cur_string.empty()) - { - *nextChar = true; - return 'a'; - } - else - { - wchar_t c = cur_string[cur_string.size() - 1]; - - if(c == ' ') - c = 'a'; - else if(c == 'z') - c = 'A'; - else if(c == 'Z') - c = '0'; - else if(c == '9' && currentMode != VKMODE_IP) - c = '!'; - else if(c == '9' && currentMode == VKMODE_IP) - c = '.'; - else if(c == '.' && currentMode == VKMODE_IP) - c = '0'; - else if(c == '/') - c = ':'; - else if(c == '@') - c = '['; - else if(c == '`') - c = '{'; - else if(c == '~') - c = ' '; - else - c++; - - return c; - } - } - else if(button == MENU_BUTTON_DOWN) - { - if(cur_string.empty()) - { - *nextChar = true; - return 'z'; - } - else - { - wchar_t c = cur_string[cur_string.size() - 1]; - - if(c == ' ') - c = '~'; - else if(c == 'a') - c = ' '; - else if(c == 'A') - c = 'z'; - else if(c == '0' && currentMode != VKMODE_IP) - c = 'Z'; - else if(c == '0' && currentMode == VKMODE_IP) - c = '.'; - else if(c == '.' && currentMode == VKMODE_IP) - c = '9'; - else if(c == '!') - c = '9'; - else if(c == ':') - c = '/'; - else if(c == '[') - c = '@'; - else if(c == '{') - c = '`'; - else - c--; - - return c; - } - } - else - { - // platform specific handlers here -#if defined(XBOX) - int dButton = DeviceI.button; - - if(dButton == JOY_1) // A - { - // make a space or . - - switch( currentMode ) - { - case VKMODE_PROFILE: - { - if(cur_string.empty()) - *nextChar = true; - - return ' '; - } - case VKMODE_IP: - { - if(!cur_string.empty()) - return '.'; - else - return 0; - } - } - else if(dButton == JOY_4) // Y - { - // switch to next character type - if(cur_string.empty()) - return 0; - - int c = cur_string[cur_string.size() - 1]; - - if(c >= 'a' && c <= 'z') - { - c = toupper(c); - return c; - } - else if(c >= 'A' && c <= 'Z') - { - return '0'; - } - else if(c >= '0' && c <= '9' && currentMode != VKMODE_IP) - { - return '!'; - } - else if((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || - (c >= '[' && c <= '`') || (c >= '{' || c <= '~')) - { - return 'a'; - } - } - else if(button == JOY_2) // B - { - // switch to previous character type - if(cur_string.empty()) - return 0; - - int c = cur_string[cur_string.size() - 1]; - - if(c >= 'a' && c <= 'z') - { - return '!'; - } - else if(c >= 'A' && c <= 'Z') - { - return 'a'; - } - else if(c >= '0' && c <= '9' && currentMode != VKMODE_IP) - { - return 'A'; - } - else if((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || - (c >= '[' && c <= '`') || (c >= '{' || c <= '~')) - { - return '0'; - } - } -#endif - return 0; - } -} - -/* - * (c) 2004 Ryan Dortmans - * 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. - */ diff --git a/stepmania/src/VirtualKeyboard.h b/stepmania/src/VirtualKeyboard.h deleted file mode 100644 index 20ec97cae9..0000000000 --- a/stepmania/src/VirtualKeyboard.h +++ /dev/null @@ -1,51 +0,0 @@ -/* VirtualKeyboard - Allows a user to enter text without a keyboard. */ - -#ifndef VIRTUAL_KEYBOARD_H -#define VIRTUAL_KEYBOARD_H - -#include "RageInputDevice.h" -#include "MenuInput.h" - -enum VirtualKeyboardMode { VKMODE_PROFILE, VKMODE_IP }; - -class VirtualKeyboard -{ -public: - VirtualKeyboard(); - ~VirtualKeyboard(); - - void Reset( VirtualKeyboardMode mode ); - wchar_t Translate( const DeviceInput& DeviceI, const MenuInput &MenuI, const wstring &cur_string, bool *nextChar ); - -protected: - VirtualKeyboardMode currentMode; -}; - -extern VirtualKeyboard VIRTUALKB; - -#endif - -/* - * (c) 2004 Ryan Dortmans - * 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. - */