diff --git a/src/ScreenNetSelectMusic.cpp b/src/ScreenNetSelectMusic.cpp index cf4909910e..c73e78d990 100644 --- a/src/ScreenNetSelectMusic.cpp +++ b/src/ScreenNetSelectMusic.cpp @@ -34,17 +34,11 @@ AutoScreenMessage( SM_SongChanged ) AutoScreenMessage( SM_UsersUpdate ) AutoScreenMessage( SM_BackFromPlayerOptions ) -// todo: metric this? -const RString AllGroups = "[ALL MUSIC]"; - -#define DIFFBG_WIDTH THEME->GetMetricF(m_sName,"DiffBGWidth") -#define DIFFBG_HEIGHT THEME->GetMetricF(m_sName,"DiffBGHeight") - REGISTER_SCREEN_CLASS( ScreenNetSelectMusic ); void ScreenNetSelectMusic::Init() { - /* Finish any previous stage. It's OK to call this when we haven't played a stage yet. */ + // Finish any previous stage. It's OK to call this when we haven't played a stage yet. GAMESTATE->FinishStage(); ScreenNetSelectBase::Init(); @@ -78,14 +72,14 @@ void ScreenNetSelectMusic::Init() this->AddChild( &m_MusicWheel ); this->MoveToHead( &m_MusicWheel ); - // todo: lua me? + // todo: handle me theme-side -aj m_BPMDisplay.SetName( "BPMDisplay" ); m_BPMDisplay.LoadFromFont( THEME->GetPathF("BPMDisplay","bpm") ); m_BPMDisplay.Load(); LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_BPMDisplay ); this->AddChild( &m_BPMDisplay ); - // todo: lua me + // todo: handle me theme-side -aj FOREACH_EnabledPlayer( p ) { m_ModIconRow[p].SetName( ssprintf("ModIconsP%d",p+1) ); @@ -114,7 +108,7 @@ void ScreenNetSelectMusic::Input( const InputEventPlus &input ) if( !m_bAllowInput || IsTransitioning() ) return; - if ( input.type == IET_RELEASE ) + if( input.type == IET_RELEASE ) { m_MusicWheel.Move(0); return; @@ -126,21 +120,22 @@ void ScreenNetSelectMusic::Input( const InputEventPlus &input ) 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 + (!NSMAN->useSMserver); //If we are disconnected, assume no chatting wchar_t c = INPUTMAN->DeviceInputToChar(input.DeviceI,false); MakeUpper( &c, 1 ); - if ( bHoldingCtrl && ( c >= 'A' ) && ( c <= 'Z' ) ) + // Ctrl+[A-Z] to go to that letter of the alphabet + if( bHoldingCtrl && ( c >= 'A' ) && ( c <= 'Z' ) ) { SortOrder so = GAMESTATE->m_SortOrder; - if ( ( so != SORT_TITLE ) && ( so != SORT_ARTIST ) ) + if( ( so != SORT_TITLE ) && ( so != SORT_ARTIST ) ) { so = SORT_TITLE; GAMESTATE->m_PreferredSortOrder = so; GAMESTATE->m_SortOrder.Set( so ); - //Odd, changing the sort order requires us to call SetOpenSection more than once + // Odd, changing the sort order requires us to call SetOpenSection more than once m_MusicWheel.ChangeSort( so ); m_MusicWheel.SetOpenSection( ssprintf("%c", c ) ); } @@ -179,9 +174,9 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) //you can chose which copy to play. Song* CurSong = m_MusicWheel.GetSelectedSong(); - if (CurSong != NULL ) + if(CurSong != NULL ) - if ( ( !CurSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) && + if( ( !CurSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) && ( !CurSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) && ( !CurSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) ) { @@ -204,7 +199,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) for( i=0; i < AllSongs.size(); i++ ) { m_cSong = AllSongs[i]; - if ( ( !m_cSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) && + if( ( !m_cSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) && ( !m_cSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) && ( !m_cSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) ) break; @@ -218,9 +213,9 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) StartSelectedSong(); break; case 2: //We need to do cmd 1 as well here - if (haveSong) + if(haveSong) { - if (!m_MusicWheel.SelectSong( m_cSong ) ) + if(!m_MusicWheel.SelectSong( m_cSong ) ) { m_MusicWheel.ChangeSort( SORT_GROUP ); m_MusicWheel.FinishTweening(); @@ -234,9 +229,9 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) } break; case 1: //Scroll to song as well - if (haveSong) + if(haveSong) { - if (!m_MusicWheel.SelectSong( m_cSong ) ) + if(!m_MusicWheel.SelectSong( m_cSong ) ) { //m_MusicWheel.ChangeSort( SORT_GROUP ); //m_MusicWheel.FinishTweening(); @@ -252,14 +247,14 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) } //don't break here case 0: //See if client has song - if (haveSong) + if(haveSong) NSMAN->m_iSelectMode = 0; else NSMAN->m_iSelectMode = 1; NSMAN->SelectUserSong(); } } - else if( SM == SM_SetWheelSong ) //After we're done the sort on wheel, select song. + else if( SM == SM_SetWheelSong ) // After we're done the sort on wheel, select song. { m_MusicWheel.SelectSong( m_cSong ); } @@ -289,7 +284,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) } else if( SM == SM_SMOnlinePack ) { - if ( NSMAN->m_SMOnlinePacket.Read1() == 1 ) + if( NSMAN->m_SMOnlinePacket.Read1() == 1 ) { switch ( NSMAN->m_SMOnlinePacket.Read1() ) { @@ -298,7 +293,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM ) RString titleSub; titleSub = NSMAN->m_SMOnlinePacket.ReadNT() + "\n"; titleSub += NSMAN->m_SMOnlinePacket.ReadNT(); - if ( NSMAN->m_SMOnlinePacket.Read1() != 1 ) + if( NSMAN->m_SMOnlinePacket.Read1() != 1 ) { RString SMOnlineSelectScreen = THEME->GetMetric( m_sName, "RoomSelectScreen" ); SCREENMAN->SetNewScreen( SMOnlineSelectScreen ); @@ -322,7 +317,7 @@ void ScreenNetSelectMusic::MenuLeft( const InputEventPlus &input ) bool bRightPressed = INPUTMAPPER->IsBeingPressed( GAME_BUTTON_RIGHT, pn ); bool bLeftAndRightPressed = bLeftPressed && bRightPressed; - if ( bLeftAndRightPressed ) + if( bLeftAndRightPressed ) m_MusicWheel.ChangeSort( SORT_MODE_MENU ); else m_MusicWheel.Move( -1 ); @@ -336,8 +331,8 @@ void ScreenNetSelectMusic::MenuRight( const InputEventPlus &input ) bool bRightPressed = INPUTMAPPER->IsBeingPressed( GAME_BUTTON_RIGHT, pn ); bool bLeftAndRightPressed = bLeftPressed && bRightPressed; - if ( bLeftAndRightPressed ) - m_MusicWheel.ChangeSort( SORT_MODE_MENU ); + if( bLeftAndRightPressed ) + m_MusicWheel.ChangeSort( SORT_MODE_MENU ); else m_MusicWheel.Move( +1 ); } @@ -357,16 +352,16 @@ void ScreenNetSelectMusic::MenuDown( const InputEventPlus &input ) // I agree, that's a stupid idea -aj PlayerNumber pn = input.pn; - if ( GAMESTATE->IsPlayerEnabled( PLAYER_2 ) && + if( GAMESTATE->IsPlayerEnabled( PLAYER_2 ) && !GAMESTATE->IsPlayerEnabled( PLAYER_1 ) ) pn = PLAYER_2; - if ( GAMESTATE->m_pCurSong == NULL ) + if( GAMESTATE->m_pCurSong == NULL ) return; StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; vector MultiSteps; MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st ); - if (MultiSteps.size() == 0) + if(MultiSteps.size() == 0) m_DC[pn] = NUM_Difficulty; else { @@ -374,26 +369,26 @@ void ScreenNetSelectMusic::MenuDown( const InputEventPlus &input ) bool dcs[NUM_Difficulty]; - for ( i=0; iGetDifficulty()] = true; - for ( i=0; i m_DC[pn]) ) + if( (dcs[i]) && (i > m_DC[pn]) ) { m_DC[pn] = (Difficulty)i; break; } } // If failed to go up, loop - if ( i == NUM_Difficulty ) + if( i == NUM_Difficulty ) { - for (i = 0;im_pCurSong.Set( pSong ); - if ( NSMAN->useSMserver ) + if( NSMAN->useSMserver ) { - //int j = m_iSongNum % m_vSongs.size(); NSMAN->m_sArtist = pSong->GetTranslitArtist(); NSMAN->m_sMainTitle = pSong->GetTranslitMainTitle(); NSMAN->m_sSubTitle = pSong->GetTranslitSubTitle(); - NSMAN->m_iSelectMode = 2; //Command for user selecting song + NSMAN->m_iSelectMode = 2; // Command for user selecting song NSMAN->SelectUserSong (); } else @@ -444,7 +438,6 @@ void ScreenNetSelectMusic::MenuBack( const InputEventPlus &input ) Cancel( SM_GoToPrevScreen ); } - void ScreenNetSelectMusic::TweenOffScreen() { ScreenNetSelectBase::TweenOffScreen(); @@ -480,7 +473,7 @@ void ScreenNetSelectMusic::StartSelectedSong() GAMESTATE->m_PreferredSortOrder = GAMESTATE->m_SortOrder; GAMESTATE->m_pPreferredSong = pSong; - //force event mode + // force event mode GAMESTATE->m_bTemporaryEventMode = true; TweenOffScreen(); @@ -489,14 +482,14 @@ void ScreenNetSelectMusic::StartSelectedSong() void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn ) { - if ( GAMESTATE->m_pCurSong == NULL ) + if( GAMESTATE->m_pCurSong == NULL ) { m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid ); //m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); //It will blank it out return; } - if ( m_DC[pn] < Difficulty_Edit && m_DC[pn] >= Difficulty_Beginner ) + if( m_DC[pn] < Difficulty_Edit && m_DC[pn] >= Difficulty_Beginner ) { /* m_DifficultyIcon[pn].SetPlayer( pn ); @@ -513,7 +506,7 @@ void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn ) Steps * pSteps = SongUtil::GetStepsByDifficulty( GAMESTATE->m_pCurSong, st, m_DC[pn] ); GAMESTATE->m_pCurSteps[pn].Set( pSteps ); - if ( ( m_DC[pn] < NUM_Difficulty ) && ( m_DC[pn] >= Difficulty_Beginner ) ) + if( ( m_DC[pn] < NUM_Difficulty ) && ( m_DC[pn] >= Difficulty_Beginner ) ) m_StepsDisplays[pn].SetFromSteps( pSteps ); else m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid ); @@ -521,14 +514,15 @@ void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn ) void ScreenNetSelectMusic::MusicChanged() { - if ( GAMESTATE->m_pCurSong == NULL ) + if( GAMESTATE->m_pCurSong == NULL ) { m_BPMDisplay.NoBPM(); FOREACH_EnabledPlayer (pn) UpdateDifficulties( pn ); SOUND->StopMusic(); - // xxx: it should play the menu music instead. -aj + // todo: handle playing section music correctly. -aj + // SOUND->PlayMusic( m_sSectionMusicPath, NULL, true, 0, -1 ); return; } m_BPMDisplay.SetBpmFromSong( GAMESTATE->m_pCurSong ); @@ -539,7 +533,7 @@ void ScreenNetSelectMusic::MusicChanged() StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; vector MultiSteps; MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st ); - if (MultiSteps.size() == 0) + if(MultiSteps.size() == 0) m_DC[pn] = NUM_Difficulty; else { @@ -548,24 +542,24 @@ void ScreenNetSelectMusic::MusicChanged() bool dcs[NUM_Difficulty]; - for ( i=0; iGetDifficulty()] = true; - for ( i=0; i= m_DC[pn] ) + if( i >= m_DC[pn] ) { m_DC[pn] = (Difficulty)i; break; } } - if ( i == NUM_Difficulty ) + if( i == NUM_Difficulty ) m_DC[pn] = Target; } UpdateDifficulties( pn ); @@ -591,7 +585,7 @@ void ScreenNetSelectMusic::MusicChanged() void ScreenNetSelectMusic::Update( float fDeltaTime ) { - if (!m_bInitialSelect) + if(!m_bInitialSelect) { m_bInitialSelect = true; SCREENMAN->PostMessageToTopScreen( SM_RefreshWheelLocation, 1.0f ); @@ -599,9 +593,8 @@ void ScreenNetSelectMusic::Update( float fDeltaTime ) ScreenNetSelectBase::Update( fDeltaTime ); } - #endif - + /* * (c) 2004-2005 Charles Lohr * All rights reserved. diff --git a/src/ScreenNetSelectMusic.h b/src/ScreenNetSelectMusic.h index 7f9e79abad..57140f9801 100644 --- a/src/ScreenNetSelectMusic.h +++ b/src/ScreenNetSelectMusic.h @@ -21,30 +21,8 @@ public: virtual void Input( const InputEventPlus &input ); virtual void HandleScreenMessage( const ScreenMessage SM ); - void UpdateSongsListPos(); - void UpdateGroupsListPos(); - void UpdateSongsList(); - void UpdateTextInput(); - void StartSelectedSong(); -private: - int m_iSongNum; - int m_iShowSongs; //The number of songs to display to each side - int m_iGroupNum; - int m_iShowGroups; //The number of groups to display to each side - - enum NetScreenSelectModes - { - SelectGroup = 0, - SelectSong, - SelectDifficulty, - SelectOptions, - SelectModes, - }; - - NetScreenSelectModes m_SelectMode; - protected: virtual void MenuStart( const InputEventPlus &input ); virtual void MenuLeft( const InputEventPlus &input ); @@ -67,7 +45,7 @@ protected: private: MusicWheel m_MusicWheel; - // todo: replace difficulty icons with StepsDisplay out the ass + // todo: replace difficulty icons with StepsDisplay -aj //Difficulty Icon(s) //DifficultyIcon m_DifficultyIcon[NUM_PLAYERS]; Difficulty m_DC[NUM_PLAYERS]; @@ -78,6 +56,7 @@ private: RageSound m_soundChangeOpt; RageSound m_soundChangeSel; + // todo: do these theme-side instead. -aj BPMDisplay m_BPMDisplay; ModIconRow m_ModIconRow[NUM_PLAYERS];