Had to go back on the ScreenNetSelectMusic controls commit. My apologies.

The MusicWheelType metric is still there, though.
This commit is contained in:
AJ Kelly
2011-02-10 14:00:09 -06:00
parent 6131f27571
commit 0178610e55
3 changed files with 124 additions and 128 deletions
+112 -115
View File
@@ -7,7 +7,6 @@
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "GameState.h"
#include "CodeDetector.h"
#include "Style.h"
#include "Steps.h"
#include "RageTimer.h"
@@ -25,6 +24,7 @@
#include "SongUtil.h"
#include "RageInput.h"
#include "SongManager.h"
#include "CodeDetector.h"
AutoScreenMessage( SM_NoSongs )
AutoScreenMessage( SM_ChangeSong )
@@ -45,12 +45,11 @@ void ScreenNetSelectMusic::Init()
ScreenNetSelectBase::Init();
SAMPLE_MUSIC_PREVIEW_MODE.Load( m_sName, "SampleMusicPreviewMode" );
CODES.Load( m_sName, "Codes" );
MUSIC_WHEEL_TYPE.Load( m_sName, "MusicWheelType" );
FOREACH_EnabledPlayer (p)
{
m_Difficulty[p] = GAMESTATE->m_PreferredDifficulty[p];
m_DC[p] = GAMESTATE->m_PreferredDifficulty[p];
m_StepsDisplays[p].SetName( ssprintf("StepsDisplayP%d",p+1) );
m_StepsDisplays[p].Load( "StepsDisplayNet", NULL );
@@ -95,8 +94,6 @@ void ScreenNetSelectMusic::Init()
m_bInitialSelect = false;
m_bAllowInput = false;
ZERO( m_iSelection );
}
void ScreenNetSelectMusic::Input( const InputEventPlus &input )
@@ -116,7 +113,7 @@ 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 );
@@ -141,19 +138,6 @@ void ScreenNetSelectMusic::Input( const InputEventPlus &input )
m_MusicWheel.Move(+1);
}
// todo: handle input here instead of in Menu* functions -aj
if( input.MenuI == GAME_BUTTON_SELECT && input.type != IET_REPEAT )
{
NSMAN->ReportNSSOnOff(3);
GAMESTATE->m_EditMode = EditMode_Full;
// todo: allow themers to define options screen -aj
SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromPlayerOptions );
}
// handle CodeDetector
if( input.type == IET_FIRST_PRESS && DetectCodes(input) )
return;
ScreenNetSelectBase::Input( input );
}
@@ -178,9 +162,8 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
}
else if( SM == SM_ChangeSong )
{
/* First check to see if this song is already selected. This is so that
* if you have multiple copies of the "same" song, you can choose which
* copy to play. */
// First check to see if this song is already selected. This is so that if
// you have multiple copies of the "same" song you can chose which copy to play.
Song* CurSong = m_MusicWheel.GetSelectedSong();
if(CurSong != NULL )
@@ -196,8 +179,8 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
NSMAN->m_iSelectMode = 0;
NSMAN->SelectUserSong();
break;
case 2: //Proper starting of song
case 3: //Blind starting of song
case 2: // Proper starting of song
case 3: // Blind starting of song
StartSelectedSong();
goto done;
}
@@ -221,7 +204,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
case 3:
StartSelectedSong();
break;
case 2: //We need to do cmd 1 as well here
case 2: // We need to do cmd 1 as well here
if(haveSong)
{
if(!m_MusicWheel.SelectSong( m_cSong ) )
@@ -237,7 +220,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
m_MusicWheel.Select();
}
break;
case 1: //Scroll to song as well
case 1: // Scroll to song as well
if(haveSong)
{
if(!m_MusicWheel.SelectSong( m_cSong ) )
@@ -254,8 +237,8 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
m_MusicWheel.Move(1);
m_MusicWheel.Select();
}
//don't break here
case 0: //See if client has song
// don't break here
case 0: // See if client has song
if(haveSong)
NSMAN->m_iSelectMode = 0;
else
@@ -263,7 +246,7 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
NSMAN->SelectUserSong();
}
}
else if( SM == SM_SetWheelSong ) // After we're done the sort on wheel, select song.
else if( SM == SM_SetWheelSong ) // After we've done the sort on wheel, select song.
{
m_MusicWheel.SelectSong( m_cSong );
}
@@ -311,14 +294,6 @@ void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
}
}
}
else if( SM == SM_GainFocus )
{
CodeDetector::RefreshCacheItems( CODES );
}
else if( SM == SM_LoseFocus )
{
CodeDetector::RefreshCacheItems(); // reset for other screens
}
done:
// Must be at end, as so it is last resort for SMOnline packets.
@@ -326,68 +301,94 @@ done:
ScreenNetSelectBase::HandleScreenMessage( SM );
}
void ScreenNetSelectMusic::ChangeSteps( const InputEventPlus &input, int dir )
bool ScreenNetSelectMusic::LeftAndRightPressed( const PlayerNumber pn )
{
if( GAMESTATE->m_pCurSong == NULL )
return;
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
m_vpSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st );
if( m_vpSteps.size() == 0 )
m_Difficulty[input.pn] = NUM_Difficulty;
else
{
m_iSelection[input.pn] += dir;
wrap( m_iSelection[input.pn], m_vpSteps.size() );
Steps *pSteps = m_vpSteps[m_iSelection[input.pn]];
m_Difficulty[input.pn] = (Difficulty)pSteps->GetDifficulty();
GAMESTATE->ChangePreferredDifficultyAndStepsType( input.pn, m_Difficulty[input.pn], st );
}
UpdateDifficulty( input.pn );
}
bool ScreenNetSelectMusic::DetectCodes( const InputEventPlus &input )
{
if( CodeDetector::EnteredPrevSteps(input.GameI.controller) )
{
ChangeSteps( input, -1 );
}
else if( CodeDetector::EnteredNextSteps(input.GameI.controller) )
{
ChangeSteps( input, +1 );
}
else if( CodeDetector::EnteredModeMenu(input.GameI.controller) )
{
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
}
// todo: support NextGroup/PrevGroup
else if( CodeDetector::EnteredCloseFolder(input.GameI.controller) )
{
RString sCurSection = m_MusicWheel.GetSelectedSection();
m_MusicWheel.SelectSection(sCurSection);
m_MusicWheel.SetOpenSection("");
MusicChanged();
}
else
{
return false;
}
return true;
return INPUTMAPPER->IsBeingPressed( GAME_BUTTON_LEFT, pn )
&& INPUTMAPPER->IsBeingPressed( GAME_BUTTON_RIGHT, pn );
}
void ScreenNetSelectMusic::MenuLeft( const InputEventPlus &input )
{
MESSAGEMAN->Broadcast( "PreviousSong" );
m_MusicWheel.Move( -1 );
PlayerNumber pn = input.pn;
if( LeftAndRightPressed(pn) )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_MusicWheel.Move( -1 );
}
void ScreenNetSelectMusic::MenuRight( const InputEventPlus &input )
{
MESSAGEMAN->Broadcast( "NextSong" );
m_MusicWheel.Move( +1 );
PlayerNumber pn = input.pn;
if( LeftAndRightPressed(pn) )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_MusicWheel.Move( +1 );
}
void ScreenNetSelectMusic::MenuUp( const InputEventPlus &input )
{
NSMAN->ReportNSSOnOff(3);
GAMESTATE->m_EditMode = EditMode_Full;
SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromPlayerOptions );
}
void ScreenNetSelectMusic::MenuDown( const InputEventPlus &input )
{
/* Tricky: If we have a player on player 2, and there is only player 2,
* allow them to use player 1's controls to change their difficulty. */
/* Why? Nothing else allows that. (-who?) */
// I agree, that's a stupid idea -aj
PlayerNumber pn = input.pn;
if( GAMESTATE->IsPlayerEnabled( PLAYER_2 ) &&
!GAMESTATE->IsPlayerEnabled( PLAYER_1 ) )
pn = PLAYER_2;
if( GAMESTATE->m_pCurSong == NULL )
return;
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
vector <Steps *> MultiSteps;
MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st );
if(MultiSteps.size() == 0)
m_DC[pn] = NUM_Difficulty;
else
{
int i;
bool dcs[NUM_Difficulty];
for( i=0; i<NUM_Difficulty; ++i )
dcs[i] = false;
for( i=0; i<(int)MultiSteps.size(); ++i )
dcs[MultiSteps[i]->GetDifficulty()] = true;
for( i=0; i<NUM_Difficulty; ++i )
{
if( (dcs[i]) && (i > m_DC[pn]) )
{
m_DC[pn] = (Difficulty)i;
break;
}
}
// If failed to go up, loop
if( i == NUM_Difficulty )
{
for(i = 0;i<NUM_Difficulty;i++)
{
if(dcs[i])
{
m_DC[pn] = (Difficulty)i;
break;
}
}
}
}
UpdateDifficulties( pn );
GAMESTATE->m_PreferredDifficulty[pn].Set( m_DC[pn] );
}
void ScreenNetSelectMusic::MenuStart( const InputEventPlus &input )
@@ -438,6 +439,7 @@ void ScreenNetSelectMusic::TweenOffScreen()
FOREACH_EnabledPlayer (pn)
{
OFF_COMMAND( m_StepsDisplays[pn] );
//OFF_COMMAND( m_DifficultyIcon[pn] );
OFF_COMMAND( m_ModIconRow[pn] );
}
@@ -453,8 +455,8 @@ void ScreenNetSelectMusic::StartSelectedSong()
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; //StepsType_dance_single;
FOREACH_EnabledPlayer (pn)
{
GAMESTATE->m_PreferredDifficulty[pn].Set( m_Difficulty[pn] );
Steps *pSteps = SongUtil::GetStepsByDifficulty(pSong, st, m_Difficulty[pn]);
GAMESTATE->m_PreferredDifficulty[pn].Set( m_DC[pn] );
Steps *pSteps = SongUtil::GetStepsByDifficulty(pSong, st, m_DC[pn]);
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
}
@@ -468,19 +470,21 @@ void ScreenNetSelectMusic::StartSelectedSong()
StartTransitioningScreen( SM_GoToNextScreen );
}
void ScreenNetSelectMusic::UpdateDifficulty( PlayerNumber pn )
void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn )
{
if( GAMESTATE->m_pCurSong == NULL )
{
m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid );
m_StepsDisplays[pn].SetFromStepsTypeAndMeterAndDifficultyAndCourseType( StepsType_Invalid, 0, Difficulty_Beginner, CourseType_Invalid );
//m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); // It will blank it out
return;
}
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
Steps* pSteps = SongUtil::GetStepsByDifficulty( GAMESTATE->m_pCurSong, st, m_Difficulty[pn] );
Steps * pSteps = SongUtil::GetStepsByDifficulty( GAMESTATE->m_pCurSong, st, m_DC[pn] );
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
if( ( m_Difficulty[pn] < NUM_Difficulty ) && ( m_Difficulty[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 );
@@ -492,31 +496,23 @@ void ScreenNetSelectMusic::MusicChanged()
{
m_BPMDisplay.NoBPM();
FOREACH_EnabledPlayer (pn)
UpdateDifficulty( pn );
UpdateDifficulties( pn );
SOUND->StopMusic();
// todo: handle playing section music correctly. -aj
/*
if(SOUND->GetMusicPath().CompareNoCase(m_sSectionMusicPath))
{
SOUND->PlayMusic( m_sSectionMusicPath, NULL, true, 0, -1 );
}
*/
// SOUND->PlayMusic( m_sSectionMusicPath, NULL, true, 0, -1 );
return;
}
m_BPMDisplay.SetBpmFromSong( GAMESTATE->m_pCurSong );
SongUtil::GetPlayableSteps( GAMESTATE->m_pCurSong, m_vpSteps );
FOREACH_EnabledPlayer(pn)
FOREACH_EnabledPlayer (pn)
{
// Wondering if this can be simplified... -aj
m_Difficulty[pn] = GAMESTATE->m_PreferredDifficulty[pn];
m_DC[pn] = GAMESTATE->m_PreferredDifficulty[pn];
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
vector<Steps*> MultiSteps;
vector <Steps *> MultiSteps;
MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st );
if(MultiSteps.size() == 0)
m_Difficulty[pn] = NUM_Difficulty;
m_DC[pn] = NUM_Difficulty;
else
{
int i;
@@ -534,17 +530,17 @@ void ScreenNetSelectMusic::MusicChanged()
if( dcs[i] )
{
Target = (Difficulty)i;
if( i >= m_Difficulty[pn] )
if( i >= m_DC[pn] )
{
m_Difficulty[pn] = (Difficulty)i;
m_DC[pn] = (Difficulty)i;
break;
}
}
if( i == NUM_Difficulty )
m_Difficulty[pn] = Target;
m_DC[pn] = Target;
}
UpdateDifficulty( pn );
UpdateDifficulties( pn );
}
// Copied from ScreenSelectMusic
@@ -552,7 +548,8 @@ void ScreenNetSelectMusic::MusicChanged()
SOUND->StopMusic();
if( GAMESTATE->m_pCurSong->HasMusic() )
{
if(SOUND->GetMusicPath().CompareNoCase(GAMESTATE->m_pCurSong->GetMusicPath())) // don't play the same sound over and over
// don't play the same sound over and over
if(SOUND->GetMusicPath().CompareNoCase(GAMESTATE->m_pCurSong->GetMusicPath()))
{
SOUND->StopMusic();
SOUND->PlayMusic(