Files
itgmania212121/stepmania/src/ScreenNetSelectMusic.cpp
T

619 lines
17 KiB
C++
Raw Normal View History

2004-08-26 08:06:22 +00:00
#include "global.h"
2004-09-10 23:21:56 +00:00
#if !defined(WITHOUT_NETWORKING)
2004-08-26 08:06:22 +00:00
#include "ScreenNetSelectMusic.h"
#include "ScreenManager.h"
#include "GameSoundManager.h"
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "GameState.h"
#include "Style.h"
#include "Steps.h"
#include "RageTimer.h"
#include "ActorUtil.h"
#include "AnnouncerManager.h"
#include "MenuTimer.h"
#include "NetworkSyncManager.h"
2004-08-26 08:06:22 +00:00
#include "StepsUtil.h"
2004-08-27 14:18:42 +00:00
#include "RageUtil.h"
2005-01-22 05:31:35 +00:00
#include "MusicWheel.h"
#include "InputMapper.h"
#include "RageLog.h"
2005-09-03 06:12:43 +00:00
#include "song.h"
#include "InputEventPlus.h"
2006-06-13 03:51:18 +00:00
#include "SongUtil.h"
2006-06-10 06:50:50 +00:00
#include "RageInput.h"
2006-09-13 08:42:22 +00:00
#include "SongManager.h"
2004-11-23 22:06:27 +00:00
AutoScreenMessage( SM_NoSongs )
AutoScreenMessage( SM_ChangeSong )
AutoScreenMessage( SM_SMOnlinePack )
AutoScreenMessage( SM_SetWheelSong )
AutoScreenMessage( SM_RefreshWheelLocation )
AutoScreenMessage( SM_SongChanged )
AutoScreenMessage( SM_UsersUpdate )
2005-07-18 02:36:03 +00:00
AutoScreenMessage( SM_BackFromPlayerOptions )
2006-01-22 01:00:06 +00:00
const RString AllGroups = "[ALL MUSIC]";
2004-08-26 08:06:22 +00:00
2005-01-27 03:08:04 +00:00
#define DIFFBG_WIDTH THEME->GetMetricF(m_sName,"DiffBGWidth")
#define DIFFBG_HEIGHT THEME->GetMetricF(m_sName,"DiffBGHeight")
2006-01-15 20:46:15 +00:00
REGISTER_SCREEN_CLASS( ScreenNetSelectMusic );
2006-01-15 19:04:34 +00:00
void ScreenNetSelectMusic::Init()
2004-08-26 08:06:22 +00:00
{
/* Finish any previous stage. It's OK to call this when we havn't played a stage yet. */
GAMESTATE->FinishStage();
ScreenNetSelectBase::Init();
2004-08-26 08:06:22 +00:00
//Diff Icon background
2005-01-27 03:08:04 +00:00
m_sprDiff.Load( THEME->GetPathG( m_sName, "DiffBG" ) );
m_sprDiff.SetName( "DiffBG" );
m_sprDiff.SetWidth( DIFFBG_WIDTH );
m_sprDiff.SetHeight( DIFFBG_HEIGHT );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_sprDiff );
2005-01-27 03:08:04 +00:00
this->AddChild( &m_sprDiff);
2004-08-26 08:06:22 +00:00
FOREACH_EnabledPlayer (p)
{
m_DifficultyIcon[p].SetName( ssprintf("DifficultyIconP%d",p+1) );
2004-09-06 21:28:56 +00:00
m_DifficultyIcon[p].Load( THEME->GetPathG( "ScreenSelectMusic",
ssprintf("difficulty icons 1x%d",
2006-01-07 04:11:29 +00:00
NUM_Difficulty)) );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY( m_DifficultyIcon[p] );
2004-08-26 08:06:22 +00:00
this->AddChild( &m_DifficultyIcon[p] );
ON_COMMAND( m_DifficultyIcon[p] );
m_DC[p] = GAMESTATE->m_PreferredDifficulty[p];
m_DifficultyMeters[p].SetName( ssprintf("MeterP%d",p+1) );
m_DifficultyMeters[p].Load( "DifficultyMeter" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_DifficultyMeters[p] );
this->AddChild( &m_DifficultyMeters[p] );
2004-08-26 08:06:22 +00:00
}
2005-05-31 07:41:04 +00:00
m_MusicWheel.SetName( "MusicWheel" );
2006-08-13 22:22:44 +00:00
m_MusicWheel.Load( "MusicWheel" );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY( m_MusicWheel );
2006-04-09 05:52:25 +00:00
m_MusicWheel.BeginScreen();
2006-08-10 07:21:52 +00:00
ON_COMMAND( m_MusicWheel );
2005-01-22 05:31:35 +00:00
this->AddChild( &m_MusicWheel );
this->MoveToHead( &m_MusicWheel );
2006-04-09 05:52:25 +00:00
2005-01-22 05:31:35 +00:00
ON_COMMAND( m_MusicWheel );
2005-01-22 05:31:35 +00:00
m_BPMDisplay.SetName( "BPMDisplay" );
2006-08-16 07:19:41 +00:00
m_BPMDisplay.LoadFromFont( THEME->GetPathF("BPMDisplay","bpm") );
2005-01-22 05:31:35 +00:00
m_BPMDisplay.Load();
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_BPMDisplay );
2005-01-22 05:31:35 +00:00
this->AddChild( &m_BPMDisplay );
2005-01-22 05:31:35 +00:00
FOREACH_EnabledPlayer( p )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
m_OptionIconRow[p].SetName( ssprintf("OptionIconsP%d",p+1) );
2005-07-09 08:09:29 +00:00
m_OptionIconRow[p].Load();
m_OptionIconRow[p].SetFromGameState( p );
2007-02-19 09:30:07 +00:00
LOAD_ALL_COMMANDS_AND_SET_XY_AND_ON_COMMAND( m_OptionIconRow[p] );
2005-01-22 05:31:35 +00:00
this->AddChild( &m_OptionIconRow[p] );
2004-08-26 08:06:22 +00:00
}
//Load SFX next
2005-02-06 03:32:53 +00:00
m_soundChangeOpt.Load( THEME->GetPathS(m_sName,"change opt") );
m_soundChangeSel.Load( THEME->GetPathS(m_sName,"change sel") );
NSMAN->ReportNSSOnOff(1);
2004-09-06 04:24:51 +00:00
NSMAN->ReportPlayerOptions();
2005-01-22 05:31:35 +00:00
m_bInitialSelect = false;
2005-01-24 03:11:00 +00:00
m_bAllowInput = false;
2004-08-26 08:06:22 +00:00
}
void ScreenNetSelectMusic::Input( const InputEventPlus &input )
2005-01-22 05:31:35 +00:00
{
2006-11-24 17:39:49 +00:00
if( !m_bAllowInput || IsTransitioning() )
2004-08-26 08:06:22 +00:00
return;
if ( input.type == IET_RELEASE )
2005-01-22 05:31:35 +00:00
{
m_MusicWheel.Move(0);
return;
}
2006-09-13 02:59:05 +00:00
if( input.type != IET_FIRST_PRESS && input.type != IET_REPEAT )
2004-08-26 08:06:22 +00:00
return;
bool bHoldingCtrl =
2004-09-09 17:48:25 +00:00
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_LCTRL)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, KEY_RCTRL)) ||
(!NSMAN->useSMserver); //If we are disconnected, assume no chatting
2004-08-26 08:06:22 +00:00
wchar_t c = INPUTMAN->DeviceInputToChar(input.DeviceI,false);
2006-06-11 01:28:52 +00:00
MakeUpper( &c, 1 );
2004-08-26 08:06:22 +00:00
2005-01-22 05:31:35 +00:00
if ( bHoldingCtrl && ( c >= 'A' ) && ( c <= 'Z' ) )
{
SortOrder so = GAMESTATE->m_SortOrder;
2005-01-25 07:07:11 +00:00
if ( ( so != SORT_TITLE ) && ( so != SORT_ARTIST ) )
{
2005-01-25 07:07:11 +00:00
so = SORT_TITLE;
GAMESTATE->m_PreferredSortOrder = so;
GAMESTATE->m_SortOrder.Set( so );
//Odd, changing the sort order requires us to call SetOpenGroup more than once
m_MusicWheel.ChangeSort( so );
m_MusicWheel.SetOpenGroup( ssprintf("%c", c ) );
}
2005-01-22 05:31:35 +00:00
m_MusicWheel.SelectSection( ssprintf("%c", c ) );
m_MusicWheel.ChangeSort( so );
m_MusicWheel.SetOpenGroup( ssprintf("%c", c ) );
m_MusicWheel.Move(+1);
2004-08-26 08:06:22 +00:00
}
2004-11-17 00:25:32 +00:00
ScreenNetSelectBase::Input( input );
2004-08-26 08:06:22 +00:00
}
void ScreenNetSelectMusic::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_GoToPrevScreen )
2004-08-26 08:06:22 +00:00
{
SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "PrevScreen") );
}
else if( SM == SM_GoToNextScreen )
{
2004-08-26 08:06:22 +00:00
SOUND->StopMusic();
SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "NextScreen") );
}
else if( SM == SM_UsersUpdate )
{
m_MusicWheel.Move( 0 );
}
else if( SM == SM_NoSongs )
{
SCREENMAN->SetNewScreen( THEME->GetMetric (m_sName, "NoSongsScreen") );
}
2005-03-28 19:26:14 +00:00
else if( SM == SM_ChangeSong )
{
//First check to see if this song is already selected.
//This is so that if you multiple copies of the "same" song
//you can chose which copy to play.
Song* CurSong = m_MusicWheel.GetSelectedSong();
2005-01-22 05:31:35 +00:00
if (CurSong != NULL )
2005-01-22 05:31:35 +00:00
if ( ( !CurSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) &&
( !CurSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) &&
( !CurSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) )
{
switch ( NSMAN->m_iSelectMode )
{
case 0:
case 1:
NSMAN->m_iSelectMode = 0;
NSMAN->SelectUserSong();
break;
case 2: //Proper starting of song
case 3: //Blind starting of song
StartSelectedSong();
goto done;
}
}
vector <Song *> AllSongs = SONGMAN->GetAllSongs();
unsigned i;
for( i=0; i < AllSongs.size(); i++ )
{
m_cSong = AllSongs[i];
if ( ( !m_cSong->GetTranslitArtist().CompareNoCase( NSMAN->m_sArtist ) ) &&
( !m_cSong->GetTranslitMainTitle().CompareNoCase( NSMAN->m_sMainTitle ) ) &&
( !m_cSong->GetTranslitSubTitle().CompareNoCase( NSMAN->m_sSubTitle ) ) )
break;
}
2005-01-22 05:31:35 +00:00
bool haveSong = i != AllSongs.size();
2004-08-28 03:37:52 +00:00
switch (NSMAN->m_iSelectMode)
{
case 3:
StartSelectedSong();
break;
case 2: //We need to do cmd 1 as well here
if (haveSong)
2004-08-28 03:37:52 +00:00
{
if (!m_MusicWheel.SelectSong( m_cSong ) )
2004-08-28 04:43:29 +00:00
{
m_MusicWheel.ChangeSort( SORT_GROUP );
m_MusicWheel.FinishTweening();
SCREENMAN->PostMessageToTopScreen( SM_SetWheelSong, 0.710f );
2004-08-28 04:43:29 +00:00
}
m_MusicWheel.Select();
m_MusicWheel.Move(-1);
m_MusicWheel.Move(1);
StartSelectedSong();
m_MusicWheel.Select();
}
break;
case 1: //Scroll to song as well
if (haveSong)
{
if (!m_MusicWheel.SelectSong( m_cSong ) )
2004-08-28 03:37:52 +00:00
{
//m_MusicWheel.ChangeSort( SORT_GROUP );
//m_MusicWheel.FinishTweening();
//SCREENMAN->PostMessageToTopScreen( SM_SetWheelSong, 0.710f );
m_MusicWheel.ChangeSort( SORT_GROUP );
m_MusicWheel.SetOpenGroup( "" );
2004-08-28 03:37:52 +00:00
}
m_MusicWheel.SelectSong( m_cSong );
m_MusicWheel.Select();
m_MusicWheel.Move(-1);
m_MusicWheel.Move(1);
m_MusicWheel.Select();
2004-08-28 03:37:52 +00:00
}
//don't break here
case 0: //See if client has song
if (haveSong)
NSMAN->m_iSelectMode = 0;
else
NSMAN->m_iSelectMode = 1;
NSMAN->SelectUserSong();
2004-08-28 03:37:52 +00:00
}
}
else if( SM == SM_SetWheelSong ) //After we're done the sort on wheel, select song.
{
2005-01-22 05:31:35 +00:00
m_MusicWheel.SelectSong( m_cSong );
}
else if( SM == SM_RefreshWheelLocation )
{
2005-01-22 05:31:35 +00:00
m_MusicWheel.Select();
m_MusicWheel.Move(-1);
m_MusicWheel.Move(1);
m_MusicWheel.Select();
2005-01-24 03:11:00 +00:00
m_bAllowInput = true;
}
else if( SM == SM_BackFromPlayerOptions )
{
2004-09-06 03:25:26 +00:00
//XXX: HACK: This will causes ScreenSelectOptions to go back here.
2004-10-29 01:58:56 +00:00
NSMAN->ReportNSSOnOff(1);
2006-10-07 04:25:28 +00:00
GAMESTATE->m_EditMode = EditMode_Invalid;
2004-09-06 03:25:26 +00:00
NSMAN->ReportPlayerOptions();
2005-01-22 05:31:35 +00:00
//Update changes
FOREACH_EnabledPlayer(p)
2005-07-09 08:09:29 +00:00
m_OptionIconRow[p].SetFromGameState( p );
}
else if( SM == SM_SongChanged )
{
GAMESTATE->m_pCurSong.Set( m_MusicWheel.GetSelectedSong() );
2005-01-22 05:31:35 +00:00
MusicChanged();
}
else if( SM == SM_SMOnlinePack )
{
2005-02-09 05:17:56 +00:00
if ( NSMAN->m_SMOnlinePacket.Read1() == 1 )
{
2005-02-09 05:17:56 +00:00
switch ( NSMAN->m_SMOnlinePacket.Read1() )
{
case 0: //Room title Change
{
2006-01-22 01:00:06 +00:00
RString titleSub;
2005-02-09 05:17:56 +00:00
titleSub = NSMAN->m_SMOnlinePacket.ReadNT() + "\n";
titleSub += NSMAN->m_SMOnlinePacket.ReadNT();
if ( NSMAN->m_SMOnlinePacket.Read1() != 1 )
{
2006-09-22 19:40:32 +00:00
RString SMOnlineSelectScreen = THEME->GetMetric( m_sName, "RoomSelectScreen" );
2005-02-09 05:17:56 +00:00
SCREENMAN->SetNewScreen( SMOnlineSelectScreen );
}
}
}
}
2004-08-26 08:06:22 +00:00
}
done:
//Must be at end, as so it is last resort for SMOnline packets.
//If it doens't know what to do, then it'll just remove them.
ScreenNetSelectBase::HandleScreenMessage( SM );
2004-08-26 08:06:22 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenNetSelectMusic::MenuLeft( const InputEventPlus &input )
2004-08-26 08:06:22 +00:00
{
2006-09-15 01:47:24 +00:00
PlayerNumber pn = input.pn;
2006-09-14 04:07:52 +00:00
bool bLeftPressed = INPUTMAPPER->IsBeingPressed( MENU_BUTTON_LEFT, pn );
bool bRightPressed = INPUTMAPPER->IsBeingPressed( MENU_BUTTON_RIGHT, pn );
2005-01-22 05:31:35 +00:00
bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
2004-10-26 19:28:29 +00:00
2006-08-10 06:39:08 +00:00
if ( bLeftAndRightPressed )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_MusicWheel.Move( -1 );
2005-01-22 05:31:35 +00:00
}
2004-10-26 19:28:29 +00:00
2006-09-15 01:47:24 +00:00
void ScreenNetSelectMusic::MenuRight( const InputEventPlus &input )
2005-01-22 05:31:35 +00:00
{
2006-09-15 01:47:24 +00:00
PlayerNumber pn = input.pn;
2006-09-14 04:07:52 +00:00
bool bLeftPressed = INPUTMAPPER->IsBeingPressed( MENU_BUTTON_LEFT, pn );
bool bRightPressed = INPUTMAPPER->IsBeingPressed( MENU_BUTTON_RIGHT, pn );
2005-01-22 05:31:35 +00:00
bool bLeftAndRightPressed = bLeftPressed && bRightPressed;
2004-09-06 03:25:26 +00:00
2006-08-10 06:39:08 +00:00
if ( bLeftAndRightPressed )
m_MusicWheel.ChangeSort( SORT_MODE_MENU );
else
m_MusicWheel.Move( +1 );
2004-08-26 08:06:22 +00:00
}
void ScreenNetSelectMusic::MenuUp( const InputEventPlus &input )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
NSMAN->ReportNSSOnOff(3);
GAMESTATE->m_EditMode = EditMode_Full;
2005-07-18 02:45:40 +00:00
SCREENMAN->AddNewScreenToTop( "ScreenPlayerOptions", SM_BackFromPlayerOptions );
2005-01-22 05:31:35 +00:00
}
void ScreenNetSelectMusic::MenuDown( const InputEventPlus &input )
2005-01-22 05:31:35 +00:00
{
/*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. */
2006-09-13 10:11:36 +00:00
PlayerNumber pn = input.pn;
if ( GAMESTATE->IsPlayerEnabled( PLAYER_2 ) &&
!GAMESTATE->IsPlayerEnabled( PLAYER_1 ) )
pn = PLAYER_2;
2005-01-22 05:31:35 +00:00
if ( GAMESTATE->m_pCurSong == NULL )
return;
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
vector <Steps *> MultiSteps;
2005-02-23 22:14:58 +00:00
MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st );
2005-01-22 05:31:35 +00:00
if (MultiSteps.size() == 0)
2006-01-07 04:11:29 +00:00
m_DC[pn] = NUM_Difficulty;
2005-01-22 05:31:35 +00:00
else
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
int i;
2004-10-26 19:28:29 +00:00
2006-01-07 04:11:29 +00:00
bool dcs[NUM_Difficulty];
2004-10-26 19:28:29 +00:00
2006-01-07 04:11:29 +00:00
for ( i=0; i<NUM_Difficulty; ++i )
2005-01-22 05:31:35 +00:00
dcs[i] = false;
2004-10-26 19:28:29 +00:00
2005-01-22 05:31:35 +00:00
for ( i=0; i<(int)MultiSteps.size(); ++i )
dcs[MultiSteps[i]->GetDifficulty()] = true;
2004-10-26 19:28:29 +00:00
2006-01-07 04:11:29 +00:00
for ( i=0; i<NUM_Difficulty; ++i )
2005-01-22 05:31:35 +00:00
{
if ( (dcs[i]) && (i > m_DC[pn]) )
{
m_DC[pn] = (Difficulty)i;
break;
2004-09-06 03:25:26 +00:00
}
2004-08-26 08:06:22 +00:00
}
2005-01-22 05:31:35 +00:00
//If failed to go up, loop
2006-01-07 04:11:29 +00:00
if ( i == NUM_Difficulty )
for (i = 0;i<NUM_Difficulty;i++)
2005-01-22 05:31:35 +00:00
if (dcs[i])
{
m_DC[pn] = (Difficulty)i;
break;
}
2004-08-26 08:06:22 +00:00
}
2005-01-22 05:31:35 +00:00
UpdateDifficulties( pn );
2005-02-26 08:32:49 +00:00
GAMESTATE->m_PreferredDifficulty[pn].Set( m_DC[pn] );
2004-08-26 08:06:22 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenNetSelectMusic::MenuStart( const InputEventPlus &input )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
bool bResult = m_MusicWheel.Select();
2004-08-26 08:06:22 +00:00
2005-01-22 05:31:35 +00:00
if( !bResult )
return;
if ( m_MusicWheel.GetSelectedType() != TYPE_SONG )
return;
2005-01-26 06:28:19 +00:00
Song * pSong = m_MusicWheel.GetSelectedSong();
if ( pSong == NULL )
return;
GAMESTATE->m_pCurSong.Set( pSong );
2004-08-26 08:06:22 +00:00
2004-08-28 03:37:52 +00:00
if ( NSMAN->useSMserver )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
//int j = m_iSongNum % m_vSongs.size();
NSMAN->m_sArtist = pSong->GetTranslitArtist();
NSMAN->m_sMainTitle = pSong->GetTranslitMainTitle();
NSMAN->m_sSubTitle = pSong->GetTranslitSubTitle();
2004-08-28 03:37:52 +00:00
NSMAN->m_iSelectMode = 2; //Command for user selecting song
NSMAN->SelectUserSong ();
2004-09-06 21:28:56 +00:00
}
else
2004-08-28 03:37:52 +00:00
StartSelectedSong();
2004-08-26 08:06:22 +00:00
}
2006-09-15 01:47:24 +00:00
void ScreenNetSelectMusic::MenuBack( const InputEventPlus &input )
2004-08-26 08:06:22 +00:00
{
SOUND->StopMusic();
TweenOffScreen();
Cancel( SM_GoToPrevScreen );
2004-08-26 08:06:22 +00:00
}
void ScreenNetSelectMusic::TweenOffScreen()
{
2004-11-17 00:25:32 +00:00
ScreenNetSelectBase::TweenOffScreen();
2004-08-26 08:06:22 +00:00
2005-01-22 05:31:35 +00:00
OFF_COMMAND( m_MusicWheel );
2004-08-26 08:06:22 +00:00
2005-01-22 05:31:35 +00:00
OFF_COMMAND( m_BPMDisplay );
2004-08-26 08:06:22 +00:00
2005-01-27 03:08:04 +00:00
OFF_COMMAND( m_sprDiff );
2004-08-26 08:06:22 +00:00
FOREACH_EnabledPlayer (pn)
{
OFF_COMMAND( m_DifficultyMeters[pn] );
2004-08-26 08:06:22 +00:00
OFF_COMMAND( m_DifficultyIcon[pn] );
2005-01-22 05:31:35 +00:00
OFF_COMMAND( m_OptionIconRow[pn] );
}
2005-01-22 05:31:35 +00:00
OFF_COMMAND( m_MusicWheel );
NSMAN->ReportNSSOnOff(0);
2004-08-26 08:06:22 +00:00
}
2004-08-28 03:37:52 +00:00
void ScreenNetSelectMusic::StartSelectedSong()
{
2005-01-22 05:31:35 +00:00
Song * pSong = m_MusicWheel.GetSelectedSong();
GAMESTATE->m_pCurSong.Set( pSong );
2004-08-28 03:37:52 +00:00
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; //STEPS_TYPE_DANCE_SINGLE;
FOREACH_EnabledPlayer (pn)
{
2005-02-26 08:32:49 +00:00
GAMESTATE->m_PreferredDifficulty[pn].Set( m_DC[pn] );
2006-06-13 03:51:18 +00:00
Steps *pSteps = SongUtil::GetStepsByDifficulty(pSong, st, m_DC[pn]);
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
2004-08-28 03:37:52 +00:00
}
GAMESTATE->m_PreferredSortOrder = GAMESTATE->m_SortOrder;
GAMESTATE->m_pPreferredSong = pSong;
2004-08-28 03:37:52 +00:00
2006-05-16 03:32:01 +00:00
//force event mode
GAMESTATE->m_bTemporaryEventMode = true;
2004-08-28 03:37:52 +00:00
TweenOffScreen();
StartTransitioningScreen( SM_GoToNextScreen );
2004-08-28 03:37:52 +00:00
}
void ScreenNetSelectMusic::UpdateDifficulties( PlayerNumber pn )
{
2005-01-22 05:31:35 +00:00
if ( GAMESTATE->m_pCurSong == NULL )
{
m_DifficultyMeters[pn].SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); //It will blank it out
return;
}
2006-08-16 21:36:15 +00:00
if ( m_DC[pn] < DIFFICULTY_EDIT && m_DC[pn] >= DIFFICULTY_BEGINNER )
{
m_DifficultyIcon[pn].SetPlayer( pn );
m_DifficultyIcon[pn].SetFromDifficulty( m_DC[pn] );
}
2004-09-17 22:53:17 +00:00
else
m_DifficultyIcon[pn].SetFromSteps( pn, NULL ); //It will blank it out
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
2004-09-17 22:53:17 +00:00
2006-06-13 03:51:18 +00:00
Steps * pSteps = SongUtil::GetStepsByDifficulty( GAMESTATE->m_pCurSong, st, m_DC[pn] );
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
2006-01-07 04:11:29 +00:00
if ( ( m_DC[pn] < NUM_Difficulty ) && ( m_DC[pn] >= DIFFICULTY_BEGINNER ) )
m_DifficultyMeters[pn].SetFromSteps( pSteps );
else
2004-09-17 22:53:17 +00:00
m_DifficultyMeters[pn].SetFromMeterAndDifficulty( 0, DIFFICULTY_BEGINNER );
}
2005-01-22 05:31:35 +00:00
void ScreenNetSelectMusic::MusicChanged()
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
if ( GAMESTATE->m_pCurSong == NULL )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
m_BPMDisplay.NoBPM();
FOREACH_EnabledPlayer (pn)
UpdateDifficulties( pn );
return;
}
m_BPMDisplay.SetBpmFromSong( GAMESTATE->m_pCurSong );
2004-08-26 08:06:22 +00:00
FOREACH_EnabledPlayer (pn)
{
m_DC[pn] = GAMESTATE->m_PreferredDifficulty[pn];
2004-08-26 08:06:22 +00:00
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
vector <Steps *> MultiSteps;
2005-02-23 22:14:58 +00:00
MultiSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( st );
2004-08-26 08:06:22 +00:00
if (MultiSteps.size() == 0)
2006-01-07 04:11:29 +00:00
m_DC[pn] = NUM_Difficulty;
2004-08-26 08:06:22 +00:00
else
{
2004-10-26 19:28:29 +00:00
int i;
2004-11-08 06:16:22 +00:00
Difficulty Target = DIFFICULTY_EASY;
2004-10-26 19:28:29 +00:00
2006-01-07 04:11:29 +00:00
bool dcs[NUM_Difficulty];
2004-10-26 19:28:29 +00:00
2006-01-07 04:11:29 +00:00
for ( i=0; i<NUM_Difficulty; ++i )
2004-10-26 19:28:29 +00:00
dcs[i] = false;
2004-09-06 21:28:56 +00:00
for ( i=0; i<(int)MultiSteps.size(); ++i )
2004-10-26 19:28:29 +00:00
dcs[MultiSteps[i]->GetDifficulty()] = true;
2004-08-26 08:06:22 +00:00
2006-01-07 04:11:29 +00:00
for ( i=0; i<NUM_Difficulty; ++i )
2004-10-26 19:28:29 +00:00
if ( dcs[i] )
{
Target = (Difficulty)i;
if ( i >= m_DC[pn] )
{
m_DC[pn] = (Difficulty)i;
break;
}
}
2006-01-07 04:11:29 +00:00
if ( i == NUM_Difficulty )
2004-10-26 19:28:29 +00:00
m_DC[pn] = Target;
2004-08-26 08:06:22 +00:00
}
UpdateDifficulties( pn );
2004-08-26 08:06:22 +00:00
}
2005-01-22 05:31:35 +00:00
//Copied from ScreenSelectMusic
SOUND->StopMusic();
2005-01-22 05:31:35 +00:00
if( GAMESTATE->m_pCurSong->HasMusic() )
{
2005-01-22 05:31:35 +00:00
if(SOUND->GetMusicPath().CompareNoCase(GAMESTATE->m_pCurSong->GetMusicPath())) // dont play the same sound over and over
{
SOUND->StopMusic();
2005-07-22 22:17:34 +00:00
SOUND->PlayMusic(
GAMESTATE->m_pCurSong->GetMusicPath(),
NULL,
true,
2005-01-22 05:31:35 +00:00
GAMESTATE->m_pCurSong->m_fMusicSampleStartSeconds,
2005-07-22 22:17:34 +00:00
GAMESTATE->m_pCurSong->m_fMusicSampleLengthSeconds );
}
}
2004-08-26 08:06:22 +00:00
}
2005-01-22 05:31:35 +00:00
void ScreenNetSelectMusic::Update( float fDeltaTime )
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
if (!m_bInitialSelect)
2004-08-26 08:06:22 +00:00
{
2005-01-22 05:31:35 +00:00
m_bInitialSelect = true;
SCREENMAN->PostMessageToTopScreen( SM_RefreshWheelLocation, 1.0f );
}
ScreenNetSelectBase::Update( fDeltaTime );
2004-08-26 08:06:22 +00:00
}
2004-08-26 08:06:22 +00:00
2004-09-10 23:21:56 +00:00
#endif
2005-01-22 05:31:35 +00:00
2004-08-26 08:06:22 +00:00
/*
2005-01-22 05:31:35 +00:00
* (c) 2004-2005 Charles Lohr
2004-08-26 08:06:22 +00:00
* 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.
*/