From 914b8233eee6dfa0de9b939a8d832db4db20e8ca Mon Sep 17 00:00:00 2001 From: Adam Lowman Date: Wed, 26 Jan 2005 08:50:09 +0000 Subject: [PATCH] New Pasword Input Screen and SMOnline Login --- stepmania/Themes/default/metrics.ini | 212 ++++++++++------- stepmania/src/ScreenManager.cpp | 26 +- stepmania/src/ScreenManager.h | 1 + stepmania/src/ScreenSMOnlineLogin.cpp | 331 +++++++++++--------------- stepmania/src/ScreenSMOnlineLogin.h | 51 ++-- stepmania/src/ScreenTextEntry.cpp | 34 +-- stepmania/src/ScreenTextEntry.h | 3 +- 7 files changed, 309 insertions(+), 349 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index f5eb680667..660ee49753 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -49,7 +49,7 @@ ChoiceNames=1,2,3,4,5,6,7 DefaultChoice=1 NumChoicesOnPage1=100 WrapCursor=1 -Choice1=ApplyDefaultOptions;screen,ScreenCautionBranch +Choice1=ApplyDefaultOptions;screen,ScreenCaution Choice2=screen,ScreenSelectGame Choice3=screen,ScreenOptionsMenu Choice4=screen,ScreenEditMenu @@ -104,14 +104,6 @@ Class=ScreenTitleMenu Fallback=ScreenTitleMenu ChoiceNames=1 -[ScreenCautionBranch] -Class=ScreenBranch -Choices=1,2 -Condition1=ShowCaution() -Condition2=true -NextScreen1=screen,ScreenCaution -NextScreen2=screen,ScreenSelectStyle - [ScreenCaution] PrevScreen=ScreenTitleBranch Class=ScreenSelectMaster @@ -700,8 +692,8 @@ StyleIcon=1 MemoryCardIcons=1 SampleMusicDelay=0.25 PrevScreen=ScreenTitleBranch -NextScreen=ScreenStage -NextOptionsScreen=@SelectFirstOptionsScreen() +NextScreen=ScreenBranchGameplay +NextOptionsScreen=ScreenBranchFirstOptions DoRouletteOnMenuTimer=1 AlignMusicBeat=0 Codes= @@ -756,45 +748,15 @@ ScoreFrameP2OnCommand=hidden,1 Fallback=ScreenSelectCourse DefaultSort=Endless -[ScreenSMOnlineLogin1] -PlayerNumber=1 -Class=ScreenSMOnlineLogin -Fallback=ScreenSMOnlineLogin - -[ScreenSMOnlineLogin2] -PlayerNumber=2 -Class=ScreenSMOnlineLogin -Fallback=ScreenSMOnlineLogin - [ScreenSMOnlineLogin] -PasswordBG= -NextScreen=@LoginScreen() +Fallback=ScreenOperatorMenu +NextScreen=ScreenNetRoom PrevScreen=ScreenTitleBranch -PasswordBGX=235 -PasswordBGY=260 -PasswordBGOnCommand= -PasswordBGOffCommand= -TitleX=320 -TitleY=50 -TitleOnCommand= -TitleOffCommand= -UserNameX=320 -UserNameY=150 -UserNameOnCommand= -UserNameOffCommand= -PasswordX=315 -PasswordY=260 -PasswordOnCommand= -PasswordOffCommand= -LoginMessageX=320 -LoginMessageY=290 -LoginMessageOnCommand= -LoginMessageOffCommand= -StyleIcon= -MemoryCardIcons= -TimerSeconds=99 +CapitalizeAllOptionNames=0 HelpText= -Fallback=ScreenWithMenuElements +StyleIcon=0 +MemoryCardIcons=0 +TimerSeconds=0 [ScreenNetRoom] MusicSelectScreen=ScreenSMOnlineSelectMusic @@ -833,7 +795,7 @@ CreateRoomOnCommand=diffusealpha,0;linear,1;diffusealpha,1.0;zoom,0.5 CreateRoomOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 NumRoomsShow=10 PrevScreen=ScreenTitleBranch -NextScreen=ScreenGameplayBranch +NextScreen=ScreenStage Fallback=ScreenNetSelectMusic [ScreenSMOnlineSelectMusic] @@ -842,44 +804,50 @@ Class=ScreenNetSelectMusic Fallback=ScreenNetSelectMusic [ScreenNetSelectMusic] -WheelX=SCREEN_CENTER_X+160 -WheelY=SCREEN_CENTER_Y+4 -WheelOnCommand= -WheelOffCommand= -BPMDisplayX=SCREEN_CENTER_X-200 -BPMDisplayY=SCREEN_CENTER_Y+180 -BPMDisplayOnCommand=addx,-SCREEN_WIDTH*0.6;bounceend,0.5;addx,SCREEN_WIDTH*0.6 -BPMDisplayOffCommand=bouncebegin,0.5;addx,-SCREEN_WIDTH*0.6 -OptionIconsP1X=SCREEN_CENTER_X-290 -OptionIconsP1Y=SCREEN_CENTER_Y-175 -OptionIconsP1OnCommand=zoomy,0;linear,0.5;zoomy,1 -OptionIconsP1OffCommand=linear,0.5;zoomy,0 -OptionIconsP2X=SCREEN_CENTER_X-290 -OptionIconsP2Y=SCREEN_CENTER_Y-145 -OptionIconsP2OnCommand=zoomy,0;linear,0.5;zoomy,1 -OptionIconsP2OffCommand=linear,0.5;zoomy,0 -ChatInputBoxY=SCREEN_CENTER_Y+110 +ChatInputBoxY=SCREEN_CENTER_Y+90 ChatInputBoxX=SCREEN_CENTER_X-150 ChatInputBoxOnCommand=addx,-SCREEN_WIDTH*0.6;bounceend,0.5;addx,SCREEN_WIDTH*0.6 ChatInputBoxOffCommand=bouncebegin,0.5;addx,-SCREEN_WIDTH*0.6 ChatInputBoxWidth=300 ChatInputBoxHeight=50 ChatInputBoxColor=0.5,0.5,1.0,0.7 //transparent cyan -ChatOutputBoxY=SCREEN_CENTER_Y-28 +ChatOutputBoxY=SCREEN_CENTER_Y-48 ChatOutputBoxX=SCREEN_CENTER_X-150 ChatOutputBoxOnCommand=diffusealpha,0;linear,0.5;diffusealpha,1 ChatOutputBoxOffCommand=diffusealpha,1;linear,0.5;diffusealpha,0;zoomx,0.0;zoomy,0.0 ChatOutputBoxWidth=300 ChatOutputBoxHeight=200 ChatOutputBoxColor=1.0,0.5,0.5,0.7 //transparent reddish -ChatInputY=SCREEN_CENTER_Y+90 +ChatInputY=SCREEN_CENTER_Y+70 ChatInputX=SCREEN_CENTER_X-300 ChatInputOnCommand=zoomx,0.0;zoomy,0.0;diffusealpha,0;linear,0.5;diffusealpha,0.8;zoomx,0.5;zoomy,0.5 ChatInputOffCommand=diffusealpha,1;linear,0.5;diffusealpha,0;zoomx,0.25;zoomy,0.25 -ChatOutputY=SCREEN_CENTER_Y+84 +ChatOutputY=SCREEN_CENTER_Y+64 ChatOutputX=SCREEN_CENTER_X-300 ChatOutputOnCommand=zoomx,1.0;zoomy,1.0;diffusealpha,0;linear,0.5;diffusealpha,0.8;zoomx,0.5;zoomy,0.5 ChatOutputOffCommand=diffusealpha,1;linear,0.5;diffusealpha,0;zoomx,0.25;zoomy,0.25 +GroupsListY=SCREEN_CENTER_Y-90 +GroupsListX=SCREEN_CENTER_X+160 +GroupsListOnCommand=zoomx,0.0;diffusealpha,0;linear,0.5;diffusealpha,1;zoomx,1.0 +GroupsListOffCommand=diffusealpha,1;linear,0.5;diffusealpha,0;zoomx,0.0 +GroupsBGColor=0.7,0.7,0.7,0.7 //grayish +GroupsBGWidth=300 +GroupsBGHeight=150 +GroupsBGY=SCREEN_CENTER_Y-90 +GroupsBGX=SCREEN_CENTER_X+160 +GroupsBGOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 +GroupsBGOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +SongsListY=SCREEN_CENTER_Y+110 +SongsListX=SCREEN_CENTER_X+160 +SongsListOnCommand=addy,400;bounceend,0.5;addy,-400 +SongsListOffCommand=bouncebegin,0.5;addy,400 +SongsBGColor=0.7,0.7,0.7,0.7 +SongsBGWidth=300 +SongsBGHeight=220 +SongsBGX=SCREEN_CENTER_X+160 +SongsBGY=SCREEN_CENTER_Y+110 +SongsBGOnCommand=addx,SCREEN_WIDTH*0.6;bounceend,0.5;addx,-SCREEN_WIDTH*0.6 +SongsBGOffCommand=bouncebegin,0.5;addx,SCREEN_WIDTH*0.6 UsersBGColor=0.7,0.7,0.7,0.7 UsersBGWidth=640 UsersBGHeight=50 @@ -898,6 +866,17 @@ Users1Color=1.0,1.0,1.0,1.0 //Inactive; Undefined Users2Color=0.5,0.5,1.0,1.0 //Active, In NetScreen Users3Color=0.5,1.0,0.5,1.0 //Active, In Options Users4Color=1.0,0.5,0.5,1.0 //Active, in Evaluation +SelectionColor=0.0,1.0,0.2,0.4 +SelectionHeight=30 +SelectionWidth=300 +SelectionY=SCREEN_CENTER_Y-90 +SelectionX=SCREEN_CENTER_X+160 +SelectionOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0;diffusealpha,0.7 +SelectionOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +SelectionTo1Command=linear,0.3;zoomy,1.0;zoomx,1.0;x,480;y,150 +SelectionTo2Command=linear,0.3;zoomy,1.0;zoomx,1.0;x,480;y,350 +SelectionTo3Command=linear,0.3;x,260;y,400;zoomx,0.4;zoomy,2.0 +SelectionTo4Command=linear,0.3;x,80;y,70;zoomx,0.4;zoomy,2.2 optionsY=SCREEN_CENTER_Y-170 optionsX=SCREEN_CENTER_X-240 optionsOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,0.7;zoomx,0.7 @@ -925,6 +904,28 @@ DiffBGY=SCREEN_CENTER_Y+160 DiffBGX=SCREEN_CENTER_X-60 DiffBGOnCommand=zoomz,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 DiffBGOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +ExInfoBGColor=0.7,0.7,0.7,0.7 +ExInfoBGWidth=200 +ExInfoBGHeight=60 +ExInfoBGY=SCREEN_CENTER_Y+160 +ExInfoBGX=SCREEN_CENTER_X-220 +ExInfoBGOnCommand=zoomz,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 +ExInfoBGOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +SongsArtistY=SCREEN_CENTER_Y+140 +SongsArtistX=SCREEN_CENTER_X-220 +SongsArtistWidth=200 +SongsArtistOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 +SongsArtistOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +SongsSubtitleY=SCREEN_CENTER_Y+160 +SongsSubtitleX=SCREEN_CENTER_X-220 +SongsSubtitleWidth=200 +SongsSubtitleOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 +SongsSubtitleOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 +SongsGroupY=SCREEN_CENTER_Y+180 +SongsGroupX=SCREEN_CENTER_X-220 +SongsGroupWidth=200 +SongsGroupOnCommand=zoomx,0.0;zoomy,0.0;linear,0.5;zoomy,1.0;zoomx,1.0 +SongsGroupOffCommand=linear,0.5;zoomx,0.0;zoomy,0.0 ChatOutputLines=18 NumStylesShow=1 NumSongsShow=4 @@ -932,7 +933,7 @@ NumGroupsShow=3 StyleIcon= MemoryCardIcons= TimerSeconds= -HelpText=Up: Options, Down: Change Difficulty, Left + Right: Change Sort +HelpText= PrevScreen=ScreenTitleBranch NextScreen=ScreenStage NoSongsScreen=ScreenTitleBranch @@ -990,16 +991,24 @@ DifficultyRatingOrientation=0 DifficultyRatingSpacing=40.0 PreviewMusicMode=0 // 0 = play music as you select, 1 = no music plays, select once and preview music plays, select again for confirm, 2 = no music plays at all, 3 = play music as select, press twice to confirm, 4 = static menu music plays, no confirm PrevScreen=ScreenTitleBranch -NextScreen=ScreenStage -NextOptionsScreen=@SelectFirstOptionsScreen() +NextScreen=ScreenBranchGameplay +NextOptionsScreen=ScreenBranchFirstOptions TimerSeconds=60 TimerStealth=0 StyleIcon=0 MemoryCardIcons=0 +[ScreenBranchGameplay] +Class=ScreenBranch +Choices=1,2 +Condition1=IsExtraStage() or IsExtraStage2() +Condition2=true +NextScreen1=screen,ScreenStageExtra +NextScreen2=screen,ScreenStage + [ScreenStage] -NextScreen=@SelectGameplayScreen() -PrevScreen=@SongSelectionScreen() +NextScreen=ScreenGameplay +PrevScreen=ScreenBranchSelectSongOrCourse // This is the minimum delay after the "in" transition before the // "out" transition will begin. (NextScreen is loaded during this // time.) @@ -1030,11 +1039,16 @@ BackgroundOffCommand= OverlayOnCommand= OverlayOffCommand= +[ScreenStageExtra] +Class=ScreenStage +Fallback=ScreenStage +NextScreen=ScreenGameplayExtra + [ScreenGameplay] ShowEvaluationOnFail=0 StaticBGY=SCREEN_CENTER_Y+0 StaticBGX=SCREEN_CENTER_X+0 -PrevScreen=@SongSelectionScreen() +PrevScreen=ScreenBranchSelectSongOrCourse NextScreen=@SelectEvaluationScreen() InitialBackgroundBrightnessRegular=1 InitialBackgroundBrightnessNonstop=1 @@ -3319,7 +3333,7 @@ TimerSeconds=24 MaxRankingNameLength=4 StyleIcon=1 MemoryCardIcons=1 -NextScreen=@SelectEndingScreen() +NextScreen=ScreenBranchEnding PlayerP1OnePlayerOneSideX=SCREEN_CENTER_X-160 PlayerP2OnePlayerOneSideX=SCREEN_CENTER_X+160 PlayerP1TwoPlayersTwoSidesX=SCREEN_CENTER_X-160 @@ -3327,6 +3341,14 @@ PlayerP2TwoPlayersTwoSidesX=SCREEN_CENTER_X+160 PlayerP1OnePlayerTwoSidesX=SCREEN_CENTER_X PlayerP2OnePlayerTwoSidesX=SCREEN_CENTER_X +[ScreenBranchEnding] +Class=ScreenBranch +Choices=Credits,MusicScroll +ConditionCredits=GetBestFinalGrade() <= Grade("AA") +ConditionMusicScroll=true +NextScreenCredits=screen,ScreenCredits +NextScreenMusicScroll=screen,ScreenMusicScroll + [EditMenu] Arrows1X=SCREEN_CENTER_X-130 Arrows2X=SCREEN_CENTER_X+270 @@ -3501,6 +3523,18 @@ LineNames=1 OptionMenuFlags=together Line1=conf,Game +[ScreenBranchSelectSongOrCourse] +Class=ScreenBranch +Choices=1,2,3,4 +Condition1=PlayModeName() == "Nonstop" +Condition2=PlayModeName() == "Oni" +Condition3=PlayModeName() == "Endless" +Condition4=true +NextScreen1=screen,ScreenSelectCourseNonstop +NextScreen2=screen,ScreenSelectCourseOni +NextScreen3=screen,ScreenSelectCourseEndless +NextScreen4=screen,ScreenSelectBranchForNet + [ScreenEvaluationExitBranch] Class=ScreenBranch Choices=1,2,3 @@ -3511,9 +3545,19 @@ NextScreen1=screen,ScreenNetRoom NextScreen2=screen,ScreenNetSelectMusic NextScreen3=screen,ScreenSelectMusic +[ScreenSelectBranchForNet] +Class=ScreenBranch +Choices=1,2,3 +Condition1=IsNetSMOnline() +Condition2=IsNetConnected() +Condition3=true +NextScreen1=screen,ScreenSMOnlineLogin +NextScreen2=screen,ScreenNetSelectMusic +NextScreen3=screen,ScreenSelectMusic + [ScreenPlayerOptions] Fallback=ScreenOptions -PrevScreen=@SongSelectionScreen() +PrevScreen=ScreenBranchSelectSongOrCourse NextScreen=ScreenSongOptions TimerSeconds=30 StyleIcon=0 @@ -3549,7 +3593,7 @@ CancelAllP2ShowCommand= Fallback=ScreenOptions Class=ScreenOptionsMaster PrevScreen=ScreenSelectMusic -NextScreen=ScreenStage +NextScreen=ScreenBranchGameplay TimerSeconds=30 StyleIcon=0 MemoryCardIcons=0 @@ -3562,10 +3606,18 @@ Line3=list,NoteSkins Line4=list,Persp Line5=Steps +[ScreenBranchFirstOptions] +Class=ScreenBranch +Choices=1,2 +Condition1=PlayModeName() == "Rave" +Condition2=true +NextScreen1=screen,ScreenRaveOptions +NextScreen2=screen,ScreenPlayerOptions + [ScreenSongOptions] Fallback=ScreenOptions -PrevScreen=@SelectFirstOptionsScreen() -NextScreen=ScreenStage +PrevScreen=ScreenBranchFirstOptions +NextScreen=ScreenBranchGameplay Game=Change the current game type with this option. TimerSeconds=30 StyleIcon=0 @@ -3650,7 +3702,7 @@ TimerSeconds=40 StyleIcon=1 MemoryCardIcons=1 PrevScreen=ScreenTitleBranch -NextScreen=@SongSelectionScreen() +NextScreen=ScreenBranchSelectSongOrCourse [BeginnerHelper] # All X,Y coordinates are relative to the HelperX,Y diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 006c479d46..7e45d848a6 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -99,7 +99,6 @@ void ScreenManager::ThemeChanged() // reload shared BGA m_pSharedBGA->LoadFromAniDir( m_sLastLoadedBackgroundPath ); - m_pSharedBGA->PlayCommand( "On" ); } void ScreenManager::EmptyDeleteQueue() @@ -214,15 +213,8 @@ void ScreenManager::Input( const DeviceInput& DeviceI, const InputEventType type // DeviceI.device, DeviceI.button, GameI.controller, GameI.button, MenuI.player, MenuI.button, StyleI.player, StyleI.col ); // pass input only to topmost state - if( m_ScreenStack.empty() ) - return; - - /* If a screen is queued to load, discard other inputs. Coin inputs - * are handled before they get here, so they won't be discarded. */ - if( m_sDelayedScreen != "" ) - return; - - m_ScreenStack.back()->Input( DeviceI, type, GameI, MenuI, StyleI ); + if( !m_ScreenStack.empty() ) + m_ScreenStack.back()->Input( DeviceI, type, GameI, MenuI, StyleI ); } @@ -384,7 +376,6 @@ retry: // any common textures loaded. BGAnimation *pNewBGA = new BGAnimation; pNewBGA->LoadFromAniDir( sNewBGA ); - pNewBGA->PlayCommand( "On" ); SAFE_DELETE( m_pSharedBGA ); m_pSharedBGA = pNewBGA; @@ -461,6 +452,19 @@ void ScreenManager::TextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, 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(); + SetFromNewScreen( pNewScreen, true ); + + m_MessageSendOnPop = SM_SendWhenDone; +} + void ScreenManager::MiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ) { if( m_ScreenStack.size() ) diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index 458e58a429..e9004b3301 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -41,6 +41,7 @@ public: void SetNewScreen( const CString &sName ); void AddNewScreenToTop( const CString &sName, ScreenMessage messageSendOnPop ); void Prompt( ScreenMessage SM_SendWhenDone, const CString &sText, bool bYesNo = false, bool bDefaultAnswer = false, 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 MiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel = SM_None ); void PopTopScreen( ScreenMessage SM = SM_None ); diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index 2626f13207..6c0ba84229 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -1,213 +1,155 @@ -#include "global.h" - #if !defined(WITHOUT_NETWORKING) +#include "global.h" #include "ScreenSMOnlineLogin.h" -#include "ScreenManager.h" -#include "ThemeManager.h" -#include "RageTimer.h" -#include "ActorUtil.h" -#include "Actor.h" +#include "RageLog.h" +#include "ProfileManager.h" #include "GameSoundManager.h" -#include "MenuTimer.h" -#include "NetworkSyncManager.h" -#include "RageUtil.h" +#include "ThemeManager.h" +#include "PrefsManager.h" +#include "ScreenManager.h" +#include "ScreenTextEntry.h" +#include "ScreenPrompt.h" +#include "VirtualKeyboard.h" #include "GameState.h" -#include "ScreenDimensions.h" +#include "NetworkSyncManager.h" +#include "ScreenTextEntry.h" #include "crypto/CryptMD5.h" -const ScreenMessage SM_SMOnlinePack = ScreenMessage(SM_User+8); +REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin); -REGISTER_SCREEN_CLASS( ScreenSMOnlineLogin ); -ScreenSMOnlineLogin::ScreenSMOnlineLogin( const CString& sName ) : ScreenWithMenuElements( sName ) -{ - m_iPlayer = THEME->GetMetricI( sName, "PlayerNumber" ) - 1; +#define PREV_SCREEN THEME->GetMetric (m_sName,"PrevScreen") +#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen") +const ScreenMessage SM_SMOnlinePack = ScreenMessage(SM_User+8); +const ScreenMessage SM_PasswordDone = ScreenMessage(SM_User+9); +OptionRowData g_ProfileLine[1] = { + OptionRowData("Profile",false) +}; - if ( GAMESTATE->IsPlayerEnabled( (PlayerNumber)m_iPlayer ) ) - m_sUserName = GAMESTATE->GetPlayerDisplayName((PlayerNumber)m_iPlayer); - else - m_sUserName = "INVALID"; + ScreenSMOnlineLogin::ScreenSMOnlineLogin(CString sClassName) : ScreenOptions(sClassName) { + LOG->Trace( "ScreenSMOnlineLogin::ScreenSMOnlineLogin()" ); - m_sprPassword.SetName( "PasswordBG" ); - m_sprPassword.Load( THEME->GetPathG( m_sName, "PasswordBG" ) ); - m_sprPassword.SetHorizAlign( align_left ); - SET_XY_AND_ON_COMMAND( m_sprPassword ); - this->AddChild( &m_sprPassword ); + g_ProfileLine[0].choices.clear(); + PROFILEMAN->GetLocalProfileNames( g_ProfileLine[0].choices ); - m_textTitle.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - m_textTitle.SetName( "Title" ); - SET_XY_AND_ON_COMMAND( m_textTitle ); - this->AddChild( &m_textTitle ); - - m_textTitle.SetText( NSMAN->GetServerName() ); - - m_textUserName.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - m_textUserName.SetName( "UserName" ); - m_textUserName.SetWrapWidthPixels( (int)SCREEN_WIDTH ); - SET_XY_AND_ON_COMMAND( m_textUserName ); - this->AddChild( &m_textUserName ); - - //XXX: Yuck, this should be metric'ed out when we get a chance - m_textUserName.SetText( "You are logging on as " + m_sUserName + " if this is incorrect, please change your profile." ); - - m_textPassword.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - m_textPassword.SetName( "Password" ); - SET_XY_AND_ON_COMMAND( m_textPassword ); - this->AddChild( &m_textPassword ); - m_sPassword = ""; - - m_textLoginMessage.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - m_textLoginMessage.SetName( "LoginMessage" ); - SET_XY_AND_ON_COMMAND( m_textLoginMessage ); - this->AddChild( &m_textLoginMessage ); - - NSMAN->isSMOLoggedIn[m_iPlayer] = false; -} - -void ScreenSMOnlineLogin::Input( const DeviceInput& DeviceI, const InputEventType type, - const GameInput& GameI, const MenuInput& MenuI, - const StyleInput& StyleI ) -{ - if( m_In.IsTransitioning() || m_Out.IsTransitioning() ) - return; - - if( (type != IET_FIRST_PRESS) && (type != IET_SLOW_REPEAT) && (type != IET_FAST_REPEAT ) ) - return; - - bool bHoldingShift = - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)); - - bool bHoldingCtrl = - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL)) || - (!NSMAN->useSMserver); //If we are disconnected, assume no chatting - - switch( DeviceI.button ) - { - case KEY_ENTER: - case KEY_KP_ENTER: - if ( m_sPassword != "" ) - SendLogin(); - return; - break; - case KEY_BACK: - if(!m_sPassword.empty()) - m_sPassword = m_sPassword.erase( m_sPassword.size()-1 ); - UpdateTextInput(); - break; - default: - char c; - c = DeviceI.ToChar(); - - if( bHoldingShift && !bHoldingCtrl ) - { - 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 >= ' ') && (!bHoldingCtrl) ) - { - m_sPassword += c; - UpdateTextInput(); - } - break; + if(!g_ProfileLine[0].choices.size()) { + SCREENMAN->SystemMessage("You Must Define A Profile!"); + SCREENMAN->SetNewScreen("ScreenProfileOptions"); } - Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler -} + else { + InitMenu(INPUTMODE_SHARE_CURSOR, g_ProfileLine, 1); + SOUND->PlayMusic( THEME->GetPathToS("ScreenMachineOptions music")); + Row &row = *m_Rows.back(); + BitmapText *bt = row.m_textItems.back(); + bt->SetText("Login"); //Change "Exit" Text + } + } -void ScreenSMOnlineLogin::HandleScreenMessage( const ScreenMessage SM ) -{ - Screen::HandleScreenMessage( SM ); - switch( SM ) - { - case SM_GoToPrevScreen: - SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "PrevScreen") ); - break; - case SM_GoToNextScreen: - SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "NextScreen") ); - break; - case SM_SMOnlinePack: + void ScreenSMOnlineLogin::ImportOptions() { + vector vsProfiles; + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); + CStringArray::iterator iter; + + iter = find( + vsProfiles.begin(), + vsProfiles.end(), + PREFSMAN->m_sDefaultLocalProfileID[0] ); + if( iter != vsProfiles.end() ) + m_Rows[0]->SetOneSelection((PlayerNumber) 0, iter - vsProfiles.begin()); + + iter = find( + vsProfiles.begin(), + vsProfiles.end(), + PREFSMAN->m_sDefaultLocalProfileID[1] ); + if( iter != vsProfiles.end() ) + m_Rows[0]->SetOneSelection((PlayerNumber) 1, iter - vsProfiles.begin()); + } + + void ScreenSMOnlineLogin::ExportOptions() { + vector vsProfiles; + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); + + if(GAMESTATE->IsPlayerEnabled((PlayerNumber) 0)) + PREFSMAN->m_sDefaultLocalProfileID[0] = vsProfiles[m_Rows[0]->GetOneSelection((PlayerNumber) 0)]; + + if(GAMESTATE->IsPlayerEnabled((PlayerNumber) 1)) + PREFSMAN->m_sDefaultLocalProfileID[0] = vsProfiles[m_Rows[0]->GetOneSelection((PlayerNumber) 1)]; + } + + void ScreenSMOnlineLogin::GoToPrevScreen() { + SCREENMAN->SetNewScreen(PREV_SCREEN); + } + + void ScreenSMOnlineLogin::GoToNextScreen() { + PREFSMAN->SaveGlobalPrefsToDisk(); + PROFILEMAN->LoadLocalProfileFromMachine((PlayerNumber) 0); + PROFILEMAN->LoadLocalProfileFromMachine((PlayerNumber) 1); //Update Profiles + + if(GAMESTATE->IsPlayerEnabled((PlayerNumber) 0) && GAMESTATE->IsPlayerEnabled((PlayerNumber) 1) && + (GAMESTATE->GetPlayerDisplayName((PlayerNumber) 0) == GAMESTATE->GetPlayerDisplayName((PlayerNumber) 1))) { + SCREENMAN->SystemMessage("Each Player Needs A Unique Profile!"); + SCREENMAN->SetNewScreen("ScreenSMOnlineLogin"); + } + else { + m_iPlayer=0; + while(!GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer)) + ++m_iPlayer; + SCREENMAN->Password(SM_PasswordDone, "You are logging on as:\n" + GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n\nPlease enter you password.", NULL ); + } + } + + void ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM) { + switch(SM) { + case SM_PasswordDone: + if(!ScreenTextEntry::s_bCancelledLast) + SendLogin(ScreenTextEntry::s_sLastAnswer); + else + SCREENMAN->SetNewScreen(PREV_SCREEN); + break; + + case SM_SMOnlinePack: int ResponceCode = NSMAN->m_SMOnlinePacket.Read1(); - if ( ResponceCode == 0 ) - { - int Status = NSMAN->m_SMOnlinePacket.Read1(); - if ( Status == 0 ) - { - NSMAN->isSMOLoggedIn[m_iPlayer] = true; - SCREENMAN->SendMessageToTopScreen( SM_GoToNextScreen ); - } - else - { - CString Responce = NSMAN->m_SMOnlinePacket.ReadNT(); - m_textLoginMessage.SetText( Responce ); - } + if (ResponceCode == 0) { + int Status = NSMAN->m_SMOnlinePacket.Read1(); + if(Status == 0) { + NSMAN->isSMOLoggedIn[m_iPlayer++] = true; + if(GAMESTATE->IsPlayerEnabled((PlayerNumber) m_iPlayer)) + SCREENMAN->Password(SM_PasswordDone, "You are logging on as:\n" + GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n\nPlease enter you password.", NULL ); + else + SCREENMAN->SetNewScreen(NEXT_SCREEN); + } + else { + CString Responce = NSMAN->m_SMOnlinePacket.ReadNT(); + SCREENMAN->Password( SM_PasswordDone, Responce + "\n\nYou are logging on as:\n" + GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer) + "\n\nPlease enter you password.", NULL ); + } } - //Else we ignore it. - - break; + break; } -} + ScreenOptions::HandleScreenMessage(SM); + } -void ScreenSMOnlineLogin::MenuStart( PlayerNumber pn ) -{ - SendLogin(); -} + void ScreenSMOnlineLogin::MenuStart(PlayerNumber pn,const InputEventType type) { + ScreenOptions::MenuStart(pn,type); + } -void ScreenSMOnlineLogin::MenuBack( PlayerNumber pn ) -{ - SCREENMAN->SendMessageToTopScreen( SM_GoToPrevScreen ); -} + CString ScreenSMOnlineLogin::GetSelectedProfileID() { + vector vsProfiles; + PROFILEMAN->GetLocalProfileIDs( vsProfiles ); -void ScreenSMOnlineLogin::TweenOffScreen() -{ - OFF_COMMAND( m_textTitle ); - OFF_COMMAND( m_textUserName ); - OFF_COMMAND( m_textPassword ); - OFF_COMMAND( m_textLoginMessage ); - OFF_COMMAND( m_sprPassword ); -} + const Row &row = *m_Rows[GetCurrentRow()]; + const int Selection = row.GetOneSharedSelection(); + if( !Selection ) + return ""; + return vsProfiles[ Selection-1 ]; + } -void ScreenSMOnlineLogin::UpdateTextInput() -{ - CString PasswordText; - - for ( unsigned i = 0; i < m_sPassword.length(); ++i ) - PasswordText+='*'; - - m_textPassword.SetText( PasswordText ); -} - -void ScreenSMOnlineLogin::SendLogin() -{ + void ScreenSMOnlineLogin::SendLogin(CString sPassword) { + CString PlayerName = GAMESTATE->GetPlayerDisplayName((PlayerNumber) m_iPlayer); CString HashedName; CString PreHashedName; unsigned char Output[16]; - const unsigned char *Input = (unsigned char *)m_sPassword.c_str(); + const unsigned char *Input = (unsigned char *)sPassword.c_str(); MD5Context BASE; @@ -217,7 +159,7 @@ void ScreenSMOnlineLogin::SendLogin() MD5Init( &BASE ); - MD5Update( &BASE, Input, m_sPassword.length()); + MD5Update( &BASE, Input, sPassword.length()); MD5Final( Output, &BASE ); @@ -235,20 +177,19 @@ void ScreenSMOnlineLogin::SendLogin() HashedName += PreHashedName.c_str()[i]; NSMAN->m_SMOnlinePacket.ClearPacket(); - NSMAN->m_SMOnlinePacket.Write1((uint8_t)0); //Login command - NSMAN->m_SMOnlinePacket.Write1((uint8_t)m_iPlayer); //Player - NSMAN->m_SMOnlinePacket.Write1((uint8_t)0); //MD5 hash style - NSMAN->m_SMOnlinePacket.WriteNT(m_sUserName); + NSMAN->m_SMOnlinePacket.Write1((uint8_t)0); //Login command + NSMAN->m_SMOnlinePacket.Write1((uint8_t)m_iPlayer); //Player + NSMAN->m_SMOnlinePacket.Write1((uint8_t)0); //MD5 hash style + NSMAN->m_SMOnlinePacket.WriteNT(PlayerName); NSMAN->m_SMOnlinePacket.WriteNT(HashedName); NSMAN->SendSMOnline( ); -} + } #endif /* - * (c) 2004 Charles Lohr + * (c) 2004 Charles Lohr Adam Lowman * All rights reserved. - * Elements from ScreenTextEntry * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -269,4 +210,4 @@ void ScreenSMOnlineLogin::SendLogin() * 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. - */ + */ \ No newline at end of file diff --git a/stepmania/src/ScreenSMOnlineLogin.h b/stepmania/src/ScreenSMOnlineLogin.h index ae21578950..c2c5f164fc 100644 --- a/stepmania/src/ScreenSMOnlineLogin.h +++ b/stepmania/src/ScreenSMOnlineLogin.h @@ -1,46 +1,23 @@ -/* ScreenSMOnlineLogin - Login for StepMania online */ - #ifndef SCREENSMONLINELOGIN_H #define SCREENSMONLINELOGIN_H -#include "ScreenWithMenuElements.h" -#include "Sprite.h" -#include "Quad.h" -#include "BitmapText.h" +#include "ScreenOptions.h" -class ScreenSMOnlineLogin : public ScreenWithMenuElements -{ -public: - ScreenSMOnlineLogin( const CString& sName ); +class ScreenSMOnlineLogin : public ScreenOptions { - virtual void Input( const DeviceInput& DeviceI, const InputEventType type, - const GameInput& GameI, const MenuInput& MenuI, - const StyleInput& StyleI ); - - virtual void MenuStart( PlayerNumber pn ); - virtual void MenuBack( PlayerNumber pn ); + public: + ScreenSMOnlineLogin(CString sName); + virtual void HandleScreenMessage(const ScreenMessage SM); + virtual void MenuStart(PlayerNumber pn,const InputEventType type); + void SendLogin(CString sPassword); - virtual void HandleScreenMessage( const ScreenMessage SM ); - - virtual void TweenOffScreen(); - - void UpdateTextInput(); - void SendLogin(); -private: - - BitmapText m_textTitle; - - BitmapText m_textUserName; - - BitmapText m_textPassword; - BitmapText m_textLoginMessage; - - CString m_sUserName; - CString m_sPassword; - - Sprite m_sprPassword; - - int m_iPlayer; + private: + void ImportOptions(); + void ExportOptions(); + void GoToNextScreen(); + void GoToPrevScreen(); + CString GetSelectedProfileID(); + int m_iPlayer; }; #endif diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index 3c33b1e1a2..7316b44703 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -22,7 +22,6 @@ CString ScreenTextEntry::s_sLastAnswer = ""; bool ScreenTextEntry::s_bCancelledLast = false; - /* XXX: Don't let the user use internal-use codepoints (those * that resolve to Unicode codepoints above 0xFFFF); those are * subject to change and shouldn't be written to .SMs. @@ -31,9 +30,11 @@ bool ScreenTextEntry::s_bCancelledLast = false; * a whole UTF-8 character. Better would be to operate in longchars. */ //REGISTER_SCREEN_CLASS( ScreenTextEntry ); -ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)() ) : + +ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)(), bool bPassword ) : Screen( sClassName ) { + m_bPassword = bPassword; // Added Password Support -APL 1/20/05 m_bIsTransparent = true; // draw screens below us m_pOnOK = OnOK; @@ -43,7 +44,6 @@ ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString m_bCancelled = false; m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenPrompt background") ); - m_Background.PlayCommand( "On" ); this->AddChild( &m_Background ); m_textQuestion.LoadFromFont( THEME->GetPathToF("Common normal") ); @@ -73,6 +73,12 @@ ScreenTextEntry::ScreenTextEntry( CString sClassName, CString sQuestion, CString void ScreenTextEntry::UpdateText() { CString txt = WStringToCString(m_sAnswer); + if(m_bPassword) { + int len = txt.GetLength(); + txt = ""; + for(int i=0;i= ' ' ) { m_sAnswer += c; UpdateText(); } - break; } } diff --git a/stepmania/src/ScreenTextEntry.h b/stepmania/src/ScreenTextEntry.h index 8a62a1824e..8febd32c84 100644 --- a/stepmania/src/ScreenTextEntry.h +++ b/stepmania/src/ScreenTextEntry.h @@ -13,7 +13,7 @@ class ScreenTextEntry : public Screen { public: - ScreenTextEntry( CString sName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL ); + ScreenTextEntry( CString sName, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer) = NULL, void(*OnCanel)() = NULL, bool bPassword = false ); virtual void Update( float fDeltaTime ); virtual void DrawPrimitives(); @@ -31,6 +31,7 @@ protected: void UpdateText(); + bool m_bPassword; BGAnimation m_Background; BitmapText m_textQuestion; Quad m_rectAnswerBox;