Files
itgmania212121/stepmania/src/ScreenSelectMusic.cpp
T

816 lines
24 KiB
C++
Raw Normal View History

2002-05-20 08:59:37 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-06-14 22:25:22 +00:00
Class: ScreenSelectMusic
2002-05-20 08:59:37 +00:00
2002-06-14 22:25:22 +00:00
Desc: See header.
2002-05-20 08:59:37 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-06-14 22:25:22 +00:00
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenSelectMusic.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "SongManager.h"
#include "GameManager.h"
#include "RageMusic.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-05-20 08:59:37 +00:00
#include "RageLog.h"
#include "InputMapper.h"
#include "InputQueue.h"
#include "AnnouncerManager.h"
2002-07-23 01:41:40 +00:00
#include "InputMapper.h"
#include "GameState.h"
#include "CodeDetector.h"
2002-05-20 08:59:37 +00:00
2002-09-03 06:33:08 +00:00
#define BANNER_FRAME_X THEME->GetMetricF("ScreenSelectMusic","BannerFrameX")
#define BANNER_FRAME_Y THEME->GetMetricF("ScreenSelectMusic","BannerFrameY")
#define BANNER_X THEME->GetMetricF("ScreenSelectMusic","BannerX")
#define BANNER_Y THEME->GetMetricF("ScreenSelectMusic","BannerY")
#define BANNER_WIDTH THEME->GetMetricF("ScreenSelectMusic","BannerWidth")
#define BANNER_HEIGHT THEME->GetMetricF("ScreenSelectMusic","BannerHeight")
#define BPM_X THEME->GetMetricF("ScreenSelectMusic","BPMX")
#define BPM_Y THEME->GetMetricF("ScreenSelectMusic","BPMY")
#define STAGE_X THEME->GetMetricF("ScreenSelectMusic","StageX")
#define STAGE_Y THEME->GetMetricF("ScreenSelectMusic","StageY")
#define CD_TITLE_X THEME->GetMetricF("ScreenSelectMusic","CDTitleX")
#define CD_TITLE_Y THEME->GetMetricF("ScreenSelectMusic","CDTitleY")
#define DIFFICULTY_FRAME_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("DifficultyFrameP%dX",p+1))
#define DIFFICULTY_FRAME_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("DifficultyFrameP%dY",p+1))
#define DIFFICULTY_ICON_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("DifficultyIconP%dX",p+1))
#define DIFFICULTY_ICON_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("DifficultyIconP%dY",p+1))
#define RADAR_X THEME->GetMetricF("ScreenSelectMusic","RadarX")
#define RADAR_Y THEME->GetMetricF("ScreenSelectMusic","RadarY")
#define SORT_ICON_X THEME->GetMetricF("ScreenSelectMusic","SortIconX")
#define SORT_ICON_Y THEME->GetMetricF("ScreenSelectMusic","SortIconY")
#define SCORE_FRAME_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("ScoreFrameP%dX",p+1))
#define SCORE_FRAME_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("ScoreFrameP%dY",p+1))
#define SCORE_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("ScoreP%dX",p+1))
#define SCORE_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("ScoreP%dY",p+1))
#define METER_FRAME_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("MeterFrameP%dX",p+1))
#define METER_FRAME_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("MeterFrameP%dY",p+1))
#define METER_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("MeterP%dX",p+1))
#define METER_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("MeterP%dY",p+1))
#define WHEEL_X THEME->GetMetricF("ScreenSelectMusic","WheelX")
#define WHEEL_Y THEME->GetMetricF("ScreenSelectMusic","WheelY")
#define PLAYER_OPTIONS_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("PlayerOptionsP%dX",p+1))
#define PLAYER_OPTIONS_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("PlayerOptionsP%dY",p+1))
#define SONG_OPTIONS_X THEME->GetMetricF("ScreenSelectMusic","SongOptionsX")
#define SONG_OPTIONS_Y THEME->GetMetricF("ScreenSelectMusic","SongOptionsY")
#define OPTION_ICONS_X( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("OptionIconsP%dX",p+1))
#define OPTION_ICONS_Y( p ) THEME->GetMetricF("ScreenSelectMusic",ssprintf("OptionIconsP%dY",p+1))
#define HELP_TEXT THEME->GetMetric("ScreenSelectMusic","HelpText")
#define TIMER_SECONDS THEME->GetMetricI("ScreenSelectMusic","TimerSeconds")
2002-08-28 22:42:40 +00:00
#define SCORE_CONNECTED_TO_MUSIC_WHEEL THEME->GetMetricB("ScreenSelectMusic","ScoreConnectedToMusicWheel")
2002-05-20 08:59:37 +00:00
const float TWEEN_TIME = 0.5f;
const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User+1);
const ScreenMessage SM_GoToNextScreen = ScreenMessage(SM_User+2);
2002-05-20 08:59:37 +00:00
ScreenSelectMusic::ScreenSelectMusic()
{
LOG->Trace( "ScreenSelectMusic::ScreenSelectMusic()" );
2002-05-20 08:59:37 +00:00
CodeDetector::RefreshCacheItems();
2002-05-28 20:01:22 +00:00
2002-05-20 08:59:37 +00:00
int p;
m_Menu.Load(
THEME->GetPathTo("Graphics","select music background"),
THEME->GetPathTo("Graphics","select music top edge"),
HELP_TEXT, true, true, TIMER_SECONDS
2002-07-11 19:02:26 +00:00
);
this->AddChild( &m_Menu );
2002-05-20 08:59:37 +00:00
// these guys get loaded SetSong and TweenToSong
m_Banner.SetXY( BANNER_X, BANNER_Y );
m_Banner.SetCroppedSize( BANNER_WIDTH, BANNER_HEIGHT );
this->AddChild( &m_Banner );
m_sprBannerFrame.Load( THEME->GetPathTo("Graphics","select music info frame") );
m_sprBannerFrame.SetXY( BANNER_FRAME_X, BANNER_FRAME_Y );
this->AddChild( &m_sprBannerFrame );
m_BPMDisplay.SetXY( BPM_X, BPM_Y );
this->AddChild( &m_BPMDisplay );
m_textStage.LoadFromFont( THEME->GetPathTo("Fonts","Header2") );
m_textStage.TurnShadowOff();
m_textStage.SetZoomX( 1.0f );
m_textStage.SetXY( STAGE_X, STAGE_Y );
m_textStage.SetText( GAMESTATE->GetStageText() );
m_textStage.SetDiffuse( GAMESTATE->GetStageColor() );
this->AddChild( &m_textStage );
m_sprCDTitle.Load( THEME->GetPathTo("Graphics","fallback cd title") );
m_sprCDTitle.TurnShadowOff();
m_sprCDTitle.SetXY( CD_TITLE_X, CD_TITLE_Y );
this->AddChild( &m_sprCDTitle );
2002-05-20 08:59:37 +00:00
for( p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
m_sprDifficultyFrame[p].Load( THEME->GetPathTo("Graphics","select music difficulty frame 2x1") );
m_sprDifficultyFrame[p].SetXY( DIFFICULTY_FRAME_X(p), DIFFICULTY_FRAME_Y(p) );
m_sprDifficultyFrame[p].StopAnimating();
m_sprDifficultyFrame[p].SetState( p );
this->AddChild( &m_sprDifficultyFrame[p] );
m_DifficultyIcon[p].SetXY( DIFFICULTY_ICON_X(p), DIFFICULTY_ICON_Y(p) );
this->AddChild( &m_DifficultyIcon[p] );
2002-05-20 08:59:37 +00:00
}
m_GrooveRadar.SetXY( RADAR_X, RADAR_Y );
this->AddChild( &m_GrooveRadar );
// m_OptionIcons.SetXY( OPTION_ICONS_X, OPTION_ICONS_Y );
// this->AddChild( &m_OptionIcons );
2002-05-20 08:59:37 +00:00
m_textSongOptions.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_textSongOptions.SetXY( SONG_OPTIONS_X, SONG_OPTIONS_Y );
m_textSongOptions.SetZoom( 0.5f );
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_textSongOptions.SetEffectCamelion( 2.5f, D3DXCOLOR(1,0,0,1), D3DXCOLOR(1,1,1,1) ); // blink red
m_textSongOptions.SetDiffuse( D3DXCOLOR(1,1,1,1) ); // white
this->AddChild( &m_textSongOptions );
2002-09-03 06:33:08 +00:00
/*
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled(p) )
continue;
m_textPlayerOptions[p].LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_textPlayerOptions[p].SetXY( PLAYER_OPTIONS_X(p), PLAYER_OPTIONS_Y(p) );
m_textPlayerOptions[p].SetZoom( 0.5f );
m_textPlayerOptions[p].SetHorizAlign( p==PLAYER_1 ? Actor::align_left : Actor::align_right );
m_textPlayerOptions[p].SetVertAlign( Actor::align_middle );
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_textPlayerOptions[p].SetEffectCamelion( 2.5f, D3DXCOLOR(1,0,0,1), D3DXCOLOR(1,1,1,1) ); // blink red
m_textPlayerOptions[p].SetDiffuse( D3DXCOLOR(1,1,1,1) ); // white
this->AddChild( &m_textPlayerOptions[p] );
}
2002-09-03 06:33:08 +00:00
*/
2002-05-20 08:59:37 +00:00
for( p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
if( !GAMESTATE->IsPlayerEnabled(p) )
continue;
m_OptionIconRow[p].SetXY( OPTION_ICONS_X(p), OPTION_ICONS_Y(p) );
m_OptionIconRow[p].Refresh( (PlayerNumber)p );
this->AddChild( &m_OptionIconRow[p] );
m_sprMeterFrame[p].Load( THEME->GetPathTo("Graphics","select music meter frame") );
m_sprMeterFrame[p].SetXY( METER_FRAME_X(p), METER_FRAME_Y(p) );
m_sprMeterFrame[p].StopAnimating();
m_sprMeterFrame[p].SetState( p );
this->AddChild( &m_sprMeterFrame[p] );
m_FootMeter[p].SetXY( METER_X(p), METER_Y(p) );
2002-05-20 08:59:37 +00:00
m_FootMeter[p].SetShadowLength( 2 );
this->AddChild( &m_FootMeter[p] );
2002-05-20 08:59:37 +00:00
}
m_MusicWheel.SetXY( WHEEL_X, WHEEL_Y );
this->AddChild( &m_MusicWheel );
2002-05-20 08:59:37 +00:00
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled((PlayerNumber)p) )
continue; // skip
m_sprHighScoreFrame[p].Load( THEME->GetPathTo("Graphics","select music score frame") );
m_sprHighScoreFrame[p].StopAnimating();
m_sprHighScoreFrame[p].SetState( p );
2002-08-29 20:18:41 +00:00
m_sprHighScoreFrame[p].SetXY( SCORE_X(p), SCORE_Y(p) );
this->AddChild( &m_sprHighScoreFrame[p] );
2002-08-29 20:18:41 +00:00
m_HighScore[p].SetXY( SCORE_X(p), SCORE_Y(p) );
m_HighScore[p].SetZoom( 0.6f );
m_HighScore[p].SetDiffuse( PlayerToColor(p) );
this->AddChild( &m_HighScore[p] );
}
m_MusicSortDisplay.SetXY( SORT_ICON_X, SORT_ICON_Y );
2002-08-20 21:00:56 +00:00
//m_MusicSortDisplay.SetEffectGlowing( 1.0f );
m_MusicSortDisplay.Set( GAMESTATE->m_SongSortOrder );
this->AddChild( &m_MusicSortDisplay );
m_textHoldForOptions.LoadFromFont( THEME->GetPathTo("Fonts","select music stage") );
2002-05-20 08:59:37 +00:00
m_textHoldForOptions.SetXY( CENTER_X, CENTER_Y );
2002-06-14 22:25:22 +00:00
m_textHoldForOptions.SetText( "press START again for options" );
2002-05-20 08:59:37 +00:00
m_textHoldForOptions.SetZoom( 1 );
m_textHoldForOptions.SetZoomY( 0 );
m_textHoldForOptions.SetDiffuse( D3DXCOLOR(1,1,1,0) );
2002-05-29 09:47:24 +00:00
m_textHoldForOptions.SetZ( -2 );
this->AddChild( &m_textHoldForOptions );
2002-05-20 08:59:37 +00:00
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
m_soundChangeNotes.Load( THEME->GetPathTo("Sounds","select music change notes") );
m_soundOptionsChange.Load( THEME->GetPathTo("Sounds","select music change options") );
m_soundLocked.Load( THEME->GetPathTo("Sounds","select music wheel locked") );
2002-05-20 08:59:37 +00:00
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("select music intro") );
2002-05-20 08:59:37 +00:00
2002-06-14 22:25:22 +00:00
m_bMadeChoice = false;
m_bGoToOptions = false;
2002-05-20 08:59:37 +00:00
UpdateOptionsDisplays();
2002-05-20 08:59:37 +00:00
AfterMusicChange();
TweenOnScreen();
2002-05-28 20:01:22 +00:00
m_Menu.TweenOnScreenFromMenu( SM_None );
2002-05-20 08:59:37 +00:00
}
ScreenSelectMusic::~ScreenSelectMusic()
{
LOG->Trace( "ScreenSelectMusic::~ScreenSelectMusic()" );
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::DrawPrimitives()
{
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
void ScreenSelectMusic::TweenOnScreen()
{
2002-08-28 22:42:40 +00:00
2002-09-03 06:33:08 +00:00
m_sprBannerFrame.FadeOn( 0, "bounce left", TWEEN_TIME );
m_Banner.FadeOn( 0, "bounce left", TWEEN_TIME );
m_BPMDisplay.FadeOn( 0, "bounce left", TWEEN_TIME );
m_textStage.FadeOn( 0, "bounce left", TWEEN_TIME );
m_sprCDTitle.FadeOn( 0, "bounce left", TWEEN_TIME );
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
m_sprDifficultyFrame[p].FadeOn( 0, "fade", TWEEN_TIME );
m_sprMeterFrame[p].FadeOn( 0, "fade", TWEEN_TIME );
}
2002-05-20 08:59:37 +00:00
m_GrooveRadar.TweenOnScreen();
2002-09-03 06:33:08 +00:00
m_textSongOptions.FadeOn( 0, "fade", TWEEN_TIME );
for( p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
m_OptionIconRow[p].FadeOn( 0, "foldy", TWEEN_TIME );
// fOriginalZoomY = m_textPlayerOptions[p].GetZoomY();
// m_textPlayerOptions[p].BeginTweening( TWEEN_TIME );
// m_textPlayerOptions[p].SetTweenZoomY( fOriginalZoomY );
2002-09-03 06:33:08 +00:00
m_DifficultyIcon[p].FadeOn( 0, "foldy", TWEEN_TIME );
2002-05-20 08:59:37 +00:00
2002-09-03 06:33:08 +00:00
m_FootMeter[p].FadeOn( 0, "foldy", TWEEN_TIME );
2002-05-20 08:59:37 +00:00
}
2002-09-03 06:33:08 +00:00
m_MusicSortDisplay.FadeOn( 0, "fade", TWEEN_TIME );
for( p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
m_sprHighScoreFrame[p].FadeOn( 0, SCORE_CONNECTED_TO_MUSIC_WHEEL?"accelerate right":"accelerate left", TWEEN_TIME );
m_HighScore[p].FadeOn( 0, SCORE_CONNECTED_TO_MUSIC_WHEEL?"accelerate right":"accelerate left", TWEEN_TIME );
}
2002-05-20 08:59:37 +00:00
m_MusicWheel.TweenOnScreen();
}
void ScreenSelectMusic::TweenOffScreen()
{
int i;
2002-08-28 22:42:40 +00:00
2002-09-03 06:33:08 +00:00
m_sprBannerFrame.FadeOff( 0, "bounce left", TWEEN_TIME );
m_Banner.FadeOff( 0, "bounce left", TWEEN_TIME );
m_BPMDisplay.FadeOff( 0, "bounce left", TWEEN_TIME );
m_textStage.FadeOff( 0, "bounce left", TWEEN_TIME );
m_sprCDTitle.FadeOff( 0, "bounce left", TWEEN_TIME );
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
m_sprDifficultyFrame[p].FadeOff( 0, "fade", TWEEN_TIME );
m_sprMeterFrame[p].FadeOff( 0, "fade", TWEEN_TIME );
}
2002-05-20 08:59:37 +00:00
m_GrooveRadar.TweenOffScreen();
2002-09-03 06:33:08 +00:00
m_textSongOptions.FadeOff( 0, "fade", TWEEN_TIME );
for( p=0; p<NUM_PLAYERS; p++ )
2002-05-20 08:59:37 +00:00
{
2002-09-03 06:33:08 +00:00
m_OptionIconRow[p].FadeOff( 0, "foldy", TWEEN_TIME );
// m_textPlayerOptions[p].FadeOff( 0, "fade", TWEEN_TIME );
2002-09-03 06:33:08 +00:00
m_DifficultyIcon[p].FadeOff( 0, "foldy", TWEEN_TIME );
2002-05-20 08:59:37 +00:00
2002-09-03 06:33:08 +00:00
m_FootMeter[p].FadeOff( 0, "foldy", TWEEN_TIME );
2002-05-20 08:59:37 +00:00
}
2002-09-03 06:33:08 +00:00
m_MusicSortDisplay.FadeOff( 0, "fade", TWEEN_TIME );
2002-08-28 22:42:40 +00:00
CArray<Actor*,Actor*> apActorsInScore;
for( p=0; p<NUM_PLAYERS; p++ )
2002-08-28 22:42:40 +00:00
{
apActorsInScore.Add( &m_sprHighScoreFrame[p] );
apActorsInScore.Add( &m_HighScore[p] );
}
for( i=0; i<apActorsInScore.GetSize(); i++ )
{
2002-08-28 22:42:40 +00:00
apActorsInScore[i]->BeginTweening( TWEEN_TIME, TWEEN_BIAS_END );
apActorsInScore[i]->SetTweenX( SCORE_CONNECTED_TO_MUSIC_WHEEL ? apActorsInScore[i]->GetX()+400 : apActorsInScore[i]->GetX()-400 );
}
2002-05-20 08:59:37 +00:00
m_MusicWheel.TweenOffScreen();
}
2002-08-28 22:42:40 +00:00
void ScreenSelectMusic::TweenScoreOnAndOffAfterChangeSort()
{
if( !SCORE_CONNECTED_TO_MUSIC_WHEEL )
return; // do nothing
CArray<Actor*,Actor*> apActorsInScore;
for( int p=0; p<NUM_PLAYERS; p++ )
{
apActorsInScore.Add( &m_sprHighScoreFrame[p] );
apActorsInScore.Add( &m_HighScore[p] );
}
for( int i=0; i<apActorsInScore.GetSize(); i++ )
{
apActorsInScore[i]->StopTweening();
2002-08-29 20:18:41 +00:00
float fOriginalX = apActorsInScore[i]->GetX();
2002-08-28 22:42:40 +00:00
apActorsInScore[i]->BeginTweening( TWEEN_TIME, TWEEN_BIAS_END ); // tween off screen
apActorsInScore[i]->SetTweenX( fOriginalX+400 );
apActorsInScore[i]->BeginTweening( 0.5f ); // sleep
2002-08-28 22:42:40 +00:00
apActorsInScore[i]->BeginTweening( 1, TWEEN_BIAS_BEGIN ); // tween back on screen
2002-08-28 22:42:40 +00:00
apActorsInScore[i]->SetTweenX( fOriginalX );
}
}
void ScreenSelectMusic::Update( float fDeltaTime )
{
Screen::Update( fDeltaTime );
float fNewRotation = m_sprCDTitle.GetRotationY()+D3DX_PI*fDeltaTime/2;
fNewRotation = fmodf( fNewRotation, D3DX_PI*2 );
m_sprCDTitle.SetRotationY( fNewRotation );
if( fNewRotation > D3DX_PI/2 && fNewRotation <= D3DX_PI*3.0f/2 )
m_sprCDTitle.SetDiffuse( D3DXCOLOR(0.2f,0.2f,0.2f,1) );
else
m_sprCDTitle.SetDiffuse( D3DXCOLOR(1,1,1,1) );
}
2002-05-20 08:59:37 +00:00
void ScreenSelectMusic::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
LOG->Trace( "ScreenSelectMusic::Input()" );
if( type == IET_RELEASE ) return; // don't care
2002-05-20 08:59:37 +00:00
if( m_Menu.IsClosing() ) return; // ignore
2002-06-14 22:25:22 +00:00
if( !GameI.IsValid() ) return; // don't care
2002-05-20 08:59:37 +00:00
if( m_bMadeChoice && !m_bGoToOptions && MenuI.IsValid() && MenuI.button == MENU_BUTTON_START && !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() )
2002-06-14 22:25:22 +00:00
{
m_bGoToOptions = true;
m_textHoldForOptions.SetText( "Entering Options..." );
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") );
2002-06-14 22:25:22 +00:00
return;
}
if( m_bMadeChoice )
2002-05-20 08:59:37 +00:00
return;
PlayerNumber pn = GAMESTATE->GetCurrentStyleDef()->ControllerToPlayerNumber( GameI.controller );
if( CodeDetector::EnteredEasierDifficulty(GameI.controller) )
2002-05-20 08:59:37 +00:00
{
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_soundLocked.Play();
else
EasierDifficulty( pn );
2002-05-20 08:59:37 +00:00
return;
}
if( CodeDetector::EnteredHarderDifficulty(GameI.controller) )
2002-05-20 08:59:37 +00:00
{
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_soundLocked.Play();
else
HarderDifficulty( pn );
2002-05-20 08:59:37 +00:00
return;
}
if( CodeDetector::EnteredNextSort(GameI.controller) )
2002-08-20 21:00:56 +00:00
{
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_soundLocked.Play();
else
if( m_MusicWheel.NextSort() )
{
MUSIC->Stop();
2002-08-28 22:42:40 +00:00
2002-08-20 21:00:56 +00:00
m_MusicSortDisplay.BeginTweening( 0.3f );
m_MusicSortDisplay.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
2002-08-28 22:42:40 +00:00
TweenScoreOnAndOffAfterChangeSort();
2002-08-20 21:00:56 +00:00
}
return;
}
if( CodeDetector::DetectAndAdjustOptions(GameI.controller) )
{
m_soundOptionsChange.Play();
UpdateOptionsDisplays();
return;
}
2002-05-20 08:59:37 +00:00
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
}
void ScreenSelectMusic::EasierDifficulty( PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenSelectMusic::EasierDifficulty( %d )", p );
2002-05-20 08:59:37 +00:00
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled(p) )
2002-05-20 08:59:37 +00:00
return;
if( m_arrayNotes.GetSize() == 0 )
return;
if( m_iSelection[p] == 0 )
return;
m_iSelection[p]--;
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->m_PreferredDifficultyClass[p] = m_arrayNotes[ m_iSelection[p] ]->m_DifficultyClass;
m_soundChangeNotes.Play();
2002-05-20 08:59:37 +00:00
AfterNotesChange( p );
}
void ScreenSelectMusic::HarderDifficulty( PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenSelectMusic::HarderDifficulty( %d )", p );
2002-05-20 08:59:37 +00:00
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled(p) )
2002-05-20 08:59:37 +00:00
return;
if( m_arrayNotes.GetSize() == 0 )
return;
if( m_iSelection[p] == m_arrayNotes.GetSize()-1 )
return;
m_iSelection[p]++;
// the user explicity switched difficulties. Update the preferred difficulty
GAMESTATE->m_PreferredDifficultyClass[p] = m_arrayNotes[ m_iSelection[p] ]->m_DifficultyClass;
m_soundChangeNotes.Play();
2002-05-20 08:59:37 +00:00
AfterNotesChange( p );
}
void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
{
Screen::HandleScreenMessage( SM );
switch( SM )
{
2002-05-27 08:23:27 +00:00
case SM_MenuTimer:
2002-08-20 21:00:56 +00:00
if( m_MusicWheel.IsRouletting() )
{
MenuStart(PLAYER_INVALID);
m_Menu.SetTimer( 15 );
}
else if( m_MusicWheel.GetSelectedType() != TYPE_SONG )
{
m_MusicWheel.StartRoulette();
m_Menu.SetTimer( 15 );
}
else
{
MenuStart(PLAYER_INVALID);
}
2002-05-27 08:23:27 +00:00
break;
case SM_GoToPrevScreen:
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
2002-05-20 08:59:37 +00:00
break;
case SM_GoToNextScreen:
if( m_bGoToOptions )
2002-05-20 08:59:37 +00:00
{
SCREENMAN->SetNewScreen( "ScreenPlayerOptions" );
2002-05-20 08:59:37 +00:00
}
else
{
MUSIC->Stop();
SCREENMAN->SetNewScreen( "ScreenStage" );
2002-05-20 08:59:37 +00:00
}
break;
case SM_PlaySongSample:
PlayMusicSample();
break;
2002-06-30 23:19:33 +00:00
case SM_SongChanged:
AfterMusicChange();
break;
2002-08-20 21:00:56 +00:00
case SM_SortOrderChanged:
SortOrderChanged();
break;
2002-05-20 08:59:37 +00:00
}
}
void ScreenSelectMusic::MenuLeft( PlayerNumber p, const InputEventType type )
2002-05-20 08:59:37 +00:00
{
2002-07-23 01:41:40 +00:00
if( type >= IET_SLOW_REPEAT && INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_RIGHT) ) )
return; // ignore
2002-07-23 01:41:40 +00:00
if( ! m_MusicWheel.WheelIsLocked() )
2002-08-20 21:00:56 +00:00
MUSIC->Stop();
2002-07-28 20:28:37 +00:00
2002-05-20 08:59:37 +00:00
m_MusicWheel.PrevMusic();
}
void ScreenSelectMusic::MenuRight( PlayerNumber p, const InputEventType type )
2002-05-20 08:59:37 +00:00
{
2002-07-23 01:41:40 +00:00
if( type >= IET_SLOW_REPEAT && INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_LEFT) ) )
return; // ignore
if( ! m_MusicWheel.WheelIsLocked() )
2002-08-20 21:00:56 +00:00
MUSIC->Stop();
2002-07-28 20:28:37 +00:00
2002-05-20 08:59:37 +00:00
m_MusicWheel.NextMusic();
}
void ScreenSelectMusic::MenuStart( PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
2002-08-20 21:00:56 +00:00
if( p != PLAYER_INVALID &&
INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_LEFT) ) &&
2002-07-23 01:41:40 +00:00
INPUTMAPPER->IsButtonDown( MenuInput(p, MENU_BUTTON_RIGHT) ) )
{
if( GAMESTATE->IsExtraStage() || GAMESTATE->IsExtraStage2() )
m_soundLocked.Play();
else
{
2002-08-20 21:00:56 +00:00
if( m_MusicWheel.NextSort() )
{
MUSIC->Stop();
2002-08-20 21:00:56 +00:00
m_MusicSortDisplay.BeginTweening( 0.3f );
m_MusicSortDisplay.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
2002-08-28 22:42:40 +00:00
TweenScoreOnAndOffAfterChangeSort();
2002-08-20 21:00:56 +00:00
}
}
2002-07-23 01:41:40 +00:00
return;
}
2002-05-20 08:59:37 +00:00
// this needs to check whether valid Notes are selected!
2002-06-24 22:04:31 +00:00
bool bResult = m_MusicWheel.Select();
2002-05-20 08:59:37 +00:00
2002-08-20 21:00:56 +00:00
if( !bResult )
{
/* why do this? breaks tabs and roulette -glenn */
// if( p != PLAYER_INVALID )
// this->SendScreenMessage( SM_MenuTimer, 1 ); // re-throw a timer message
2002-08-20 21:00:56 +00:00
}
else // if !bResult
2002-05-20 08:59:37 +00:00
{
2002-06-24 22:04:31 +00:00
// a song was selected
switch( m_MusicWheel.GetSelectedType() )
2002-05-20 08:59:37 +00:00
{
2002-06-24 22:04:31 +00:00
case TYPE_SONG:
2002-06-23 11:43:53 +00:00
{
2002-06-24 22:04:31 +00:00
if( !m_MusicWheel.GetSelectedSong()->HasMusic() )
{
2002-08-30 22:53:31 +00:00
/* TODO: gray these out.
*
* XXX: also, make sure they're not selected by roulette */
SCREENMAN->Prompt( SM_None, "ERROR:\n \nThis song does not have a music file\n and cannot be played." );
2002-06-24 22:04:31 +00:00
return;
}
bool bIsNew = m_MusicWheel.GetSelectedSong()->IsNew();
bool bIsHard = false;
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) )
2002-06-24 22:04:31 +00:00
continue; // skip
2002-07-23 01:41:40 +00:00
if( GAMESTATE->m_pCurNotes[p] && GAMESTATE->m_pCurNotes[p]->m_iMeter >= 9 )
2002-06-24 22:04:31 +00:00
bIsHard = true;
}
if( bIsNew )
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("select music comment new") );
2002-06-24 22:04:31 +00:00
else if( bIsHard )
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("select music comment hard") );
2002-06-24 22:04:31 +00:00
else
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("select music comment general") );
2002-06-24 22:04:31 +00:00
TweenOffScreen();
m_bMadeChoice = true;
m_soundSelect.Play();
2002-06-24 22:04:31 +00:00
if( !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() )
{
// show "hold START for options"
m_textHoldForOptions.SetDiffuse( D3DXCOLOR(1,1,1,0) );
m_textHoldForOptions.BeginTweening( 0.25f ); // fade in
m_textHoldForOptions.SetTweenZoomY( 1 );
m_textHoldForOptions.SetTweenDiffuse( D3DXCOLOR(1,1,1,1) );
m_textHoldForOptions.BeginTweening( 2.0f ); // sleep
m_textHoldForOptions.BeginTweening( 0.25f ); // fade out
m_textHoldForOptions.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
m_textHoldForOptions.SetTweenZoomY( 0 );
}
2002-06-24 22:04:31 +00:00
m_Menu.TweenOffScreenToBlack( SM_None, false );
2002-08-20 21:00:56 +00:00
m_Menu.StopTimer();
this->SendScreenMessage( SM_GoToNextScreen, 2.5f );
2002-06-23 11:43:53 +00:00
}
2002-06-24 22:04:31 +00:00
break;
case TYPE_SECTION:
break;
case TYPE_ROULETTE:
2002-06-23 11:43:53 +00:00
2002-06-24 22:04:31 +00:00
break;
2002-05-20 08:59:37 +00:00
}
2002-06-23 11:43:53 +00:00
}
2002-06-24 22:04:31 +00:00
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::MenuBack( PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
MUSIC->Stop();
m_Menu.TweenOffScreenToBlack( SM_GoToPrevScreen, true );
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::AfterNotesChange( PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled(p) )
2002-05-20 08:59:37 +00:00
return;
m_iSelection[p] = clamp( m_iSelection[p], 0, m_arrayNotes.GetSize()-1 ); // bounds clamping
Notes* pNotes = m_arrayNotes.GetSize()>0 ? m_arrayNotes[m_iSelection[p]] : NULL;
2002-07-23 01:41:40 +00:00
GAMESTATE->m_pCurNotes[p] = pNotes;
2002-05-20 08:59:37 +00:00
// m_BPMDisplay.SetZoomY( 0 );
// m_BPMDisplay.BeginTweening( 0.2f );
// m_BPMDisplay.SetTweenZoomY( 1.2f );
DifficultyClass dc = GAMESTATE->m_PreferredDifficultyClass[p];
Song* pSong = GAMESTATE->m_pCurSong;
Notes* m_pNotes = GAMESTATE->m_pCurNotes[p];
if( m_pNotes )
m_HighScore[p].SetScore( (float)m_pNotes->m_iTopScore );
2002-05-20 08:59:37 +00:00
m_DifficultyIcon[p].SetFromNotes( pNotes );
m_FootMeter[p].SetFromNotes( pNotes );
m_GrooveRadar.SetFromNotes( p, pNotes );
m_MusicWheel.NotesChanged( p );
}
void ScreenSelectMusic::AfterMusicChange()
{
2002-08-20 21:00:56 +00:00
m_Menu.StallTimer();
2002-05-20 08:59:37 +00:00
Song* pSong = m_MusicWheel.GetSelectedSong();
2002-07-23 01:41:40 +00:00
GAMESTATE->m_pCurSong = pSong;
2002-05-20 08:59:37 +00:00
m_arrayNotes.RemoveAll();
switch( m_MusicWheel.GetSelectedType() )
{
case TYPE_SECTION:
{
CString sGroup = m_MusicWheel.GetSelectedSection();
for( int p=0; p<NUM_PLAYERS; p++ )
{
m_iSelection[p] = -1;
}
m_Banner.SetFromGroup( sGroup ); // if this isn't a group, it'll default to the fallback banner
m_BPMDisplay.SetBPMRange( 0, 0 );
m_sprCDTitle.UnloadTexture();
2002-05-20 08:59:37 +00:00
}
break;
case TYPE_SONG:
{
2002-07-23 01:41:40 +00:00
pSong->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef()->m_NotesType, m_arrayNotes );
SortNotesArrayByDifficulty( m_arrayNotes );
m_Banner.SetFromSong( pSong );
float fMinBPM, fMaxBPM;
pSong->GetMinMaxBPM( fMinBPM, fMaxBPM );
m_BPMDisplay.SetBPMRange( fMinBPM, fMaxBPM );
if( pSong->HasCDTitle() )
m_sprCDTitle.Load( pSong->GetCDTitlePath() );
else
m_sprCDTitle.Load( THEME->GetPathTo("Graphics","fallback cd title") );
2002-05-20 08:59:37 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-07-23 01:41:40 +00:00
if( !GAMESTATE->IsPlayerEnabled( PlayerNumber(p) ) )
2002-05-20 08:59:37 +00:00
continue;
2002-06-30 23:19:33 +00:00
for( int i=0; i<m_arrayNotes.GetSize(); i++ )
2002-07-23 01:41:40 +00:00
if( m_arrayNotes[i]->m_DifficultyClass == GAMESTATE->m_PreferredDifficultyClass[p] )
2002-06-30 23:19:33 +00:00
m_iSelection[p] = i;
2002-05-20 08:59:37 +00:00
m_iSelection[p] = clamp( m_iSelection[p], 0, m_arrayNotes.GetSize() ) ;
}
}
break;
case TYPE_ROULETTE:
m_Banner.SetRoulette();
m_BPMDisplay.SetBPMRange( 0, 0 );
m_sprCDTitle.UnloadTexture();
2002-05-20 08:59:37 +00:00
break;
}
for( int p=0; p<NUM_PLAYERS; p++ )
{
AfterNotesChange( (PlayerNumber)p );
}
}
void ScreenSelectMusic::PlayMusicSample()
{
//LOG->Trace( "ScreenSelectSong::PlaySONGample()" );
2002-05-20 08:59:37 +00:00
Song* pSong = m_MusicWheel.GetSelectedSong();
if( pSong )
2002-08-27 16:53:25 +00:00
{
MUSIC->Stop();
MUSIC->Load( pSong->GetMusicPath() );
MUSIC->Play( true, pSong->m_fMusicSampleStartSeconds, pSong->m_fMusicSampleLengthSeconds );
}
else
MUSIC->LoadAndPlayIfNotAlready( THEME->GetPathTo("Sounds","select music music") );
2002-05-20 08:59:37 +00:00
}
void ScreenSelectMusic::UpdateOptionsDisplays()
{
// m_OptionIcons.Load( GAMESTATE->m_PlayerOptions, &GAMESTATE->m_SongOptions );
2002-09-03 06:33:08 +00:00
// m_PlayerOptionIcons.Refresh();
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-09-03 06:33:08 +00:00
m_OptionIconRow[p].Refresh( (PlayerNumber)p );
if( GAMESTATE->IsPlayerEnabled(p) )
{
CString s = GAMESTATE->m_PlayerOptions[p].GetString();
s.Replace( ", ", "\n" );
2002-09-03 06:33:08 +00:00
// m_textPlayerOptions[p].SetText( s );
}
}
CString s = GAMESTATE->m_SongOptions.GetString();
s.Replace( ", ", "\n" );
m_textSongOptions.SetText( s );
}
2002-08-20 21:00:56 +00:00
void ScreenSelectMusic::SortOrderChanged()
{
m_MusicSortDisplay.SetState( GAMESTATE->m_SongSortOrder );
// tween music sort on screen
// m_MusicSortDisplay.SetEffectGlowing();
m_MusicSortDisplay.BeginTweening( 0.3f );
m_MusicSortDisplay.SetTweenDiffuse( D3DXCOLOR(1,1,1,1) );
2002-08-20 21:00:56 +00:00
}
2002-05-20 08:59:37 +00:00