Files
itgmania212121/stepmania/src/ScreenSelectCourse.cpp
T

280 lines
7.2 KiB
C++
Raw Normal View History

2002-06-14 22:25:22 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
Class: ScreenSelectCourse
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenSelectCourse.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "SongManager.h"
#include "GameManager.h"
#include "RageMusic.h"
#include "ScreenTitleMenu.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-06-14 22:25:22 +00:00
#include "ScreenGameplay.h"
#include "ScreenPrompt.h"
#include "ScreenPlayerOptions.h"
#include "RageLog.h"
#include "InputMapper.h"
#include "InputQueue.h"
#include "ScreenStage.h"
#include "AnnouncerManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2002-06-14 22:25:22 +00:00
const float COURSE_INFO_FRAME_X = 160;
const float COURSE_INFO_FRAME_Y = SCREEN_TOP+118;
const float COURSE_CONTENTS_FRAME_X = 160;
2002-07-23 01:41:40 +00:00
const float COURSE_CONTENTS_FRAME_Y = CENTER_Y+70;
2002-06-14 22:25:22 +00:00
const float WHEEL_X = CENTER_X+160;
const float WHEEL_Y = CENTER_Y+8;
const float TWEEN_TIME = 0.5f;
const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User+1);
const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User+2);
const ScreenMessage SM_ConfirmChange = ScreenMessage(SM_User+3);
ScreenSelectCourse::ScreenSelectCourse()
{
LOG->Trace( "ScreenSelectCourse::ScreenSelectCourse()" );
2002-06-14 22:25:22 +00:00
2002-07-27 19:29:51 +00:00
m_bMadeChoice = false;
m_bGoToOptions = false;
2002-06-14 22:25:22 +00:00
m_Menu.Load(
THEME->GetPathTo(GRAPHIC_SELECT_COURSE_BACKGROUND),
THEME->GetPathTo(GRAPHIC_SELECT_COURSE_TOP_EDGE),
2002-07-27 19:29:51 +00:00
ssprintf("%c or %c change course then press START", char(1), char(2)),
2002-07-11 19:02:26 +00:00
false, true, 60
);
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_Menu );
2002-06-14 22:25:22 +00:00
m_CourseInfoFrame.SetXY( COURSE_INFO_FRAME_X, COURSE_INFO_FRAME_Y );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_CourseInfoFrame );
2002-06-14 22:25:22 +00:00
m_CourseContentsFrame.SetXY( COURSE_CONTENTS_FRAME_X, COURSE_CONTENTS_FRAME_Y );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_CourseContentsFrame );
2002-06-14 22:25:22 +00:00
m_MusicWheel.SetXY( WHEEL_X, WHEEL_Y );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_MusicWheel );
2002-06-14 22:25:22 +00:00
m_textHoldForOptions.Load( THEME->GetPathTo(FONT_STAGE) );
m_textHoldForOptions.SetXY( CENTER_X, CENTER_Y );
2002-07-27 19:29:51 +00:00
m_textHoldForOptions.SetText( "press START again for options" );
2002-06-14 22:25:22 +00:00
m_textHoldForOptions.SetZoom( 1 );
m_textHoldForOptions.SetZoomY( 0 );
m_textHoldForOptions.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_textHoldForOptions );
2002-06-14 22:25:22 +00:00
m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) );
m_soundChangeNotes.Load( THEME->GetPathTo(SOUND_SELECT_MUSIC_CHANGE_NOTES) );
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_COURSE_INTRO) );
AfterCourseChange();
TweenOnScreen();
m_Menu.TweenOnScreenFromMenu( SM_None );
}
ScreenSelectCourse::~ScreenSelectCourse()
{
LOG->Trace( "ScreenSelectCourse::~ScreenSelectCourse()" );
2002-06-14 22:25:22 +00:00
}
void ScreenSelectCourse::DrawPrimitives()
{
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
void ScreenSelectCourse::TweenOnScreen()
{
m_CourseInfoFrame.SetXY( COURSE_INFO_FRAME_X - 400, COURSE_INFO_FRAME_Y );
m_CourseInfoFrame.BeginTweening( TWEEN_TIME, Actor::TWEEN_BIAS_END );
m_CourseInfoFrame.SetTweenXY( COURSE_INFO_FRAME_X, COURSE_INFO_FRAME_Y );
2002-07-27 19:29:51 +00:00
m_CourseContentsFrame.SetXY( COURSE_CONTENTS_FRAME_X - 400, COURSE_CONTENTS_FRAME_Y );
m_CourseContentsFrame.BeginTweeningQueued( TWEEN_TIME, Actor::TWEEN_BIAS_END );
m_CourseContentsFrame.SetTweenXY( COURSE_CONTENTS_FRAME_X, COURSE_CONTENTS_FRAME_Y );
2002-06-14 22:25:22 +00:00
m_MusicWheel.TweenOnScreen();
}
void ScreenSelectCourse::TweenOffScreen()
{
m_CourseInfoFrame.BeginTweening( TWEEN_TIME, Actor::TWEEN_BOUNCE_END );
m_CourseInfoFrame.SetTweenXY( COURSE_INFO_FRAME_X - 400, COURSE_INFO_FRAME_Y );
2002-07-27 19:29:51 +00:00
m_CourseContentsFrame.BeginTweeningQueued( TWEEN_TIME, Actor::TWEEN_BOUNCE_END );
m_CourseContentsFrame.SetTweenXY( COURSE_CONTENTS_FRAME_X - 400, COURSE_CONTENTS_FRAME_Y );
2002-06-14 22:25:22 +00:00
m_MusicWheel.TweenOffScreen();
}
void ScreenSelectCourse::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
LOG->Trace( "ScreenSelectCourse::Input()" );
2002-06-14 22:25:22 +00:00
if( m_Menu.IsClosing() )
return; // ignore
2002-06-24 22:04:31 +00:00
if( MenuI.player == PLAYER_INVALID )
2002-06-14 22:25:22 +00:00
return;
2002-07-27 19:29:51 +00:00
if( m_bMadeChoice && !m_bGoToOptions && MenuI.button == MENU_BUTTON_START )
{
m_bGoToOptions = true;
m_textHoldForOptions.SetText( "Entering Options..." );
SOUND->PlayOnceStreamed( THEME->GetPathTo(SOUND_MENU_START) );
return;
}
2002-07-28 20:28:37 +00:00
if( m_bMadeChoice )
return;
2002-06-14 22:25:22 +00:00
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
}
void ScreenSelectCourse::HandleScreenMessage( const ScreenMessage SM )
{
Screen::HandleScreenMessage( SM );
switch( SM )
{
case SM_MenuTimer:
MenuStart(PLAYER_1);
break;
case SM_GoToPrevState:
SCREENMAN->SetNewScreen( new ScreenTitleMenu );
break;
case SM_GoToNextState:
// find out if the Next button is being held down on any of the pads
bool bIsHoldingNext;
bIsHoldingNext = false;
int player;
for( player=0; player<NUM_PLAYERS; player++ )
{
MenuInput mi( (PlayerNumber)player, MENU_BUTTON_START );
if( INPUTMAPPER->IsButtonDown( mi ) )
bIsHoldingNext = true;
}
2002-07-27 19:29:51 +00:00
if( bIsHoldingNext || m_bGoToOptions )
2002-06-14 22:25:22 +00:00
{
SCREENMAN->SetNewScreen( new ScreenPlayerOptions );
}
else
{
2002-06-24 22:04:31 +00:00
SCREENMAN->SetNewScreen( new ScreenStage );
2002-06-14 22:25:22 +00:00
}
break;
}
}
void ScreenSelectCourse::MenuLeft( const PlayerNumber p, const InputEventType type )
{
m_MusicWheel.PrevMusic();
AfterCourseChange();
}
void ScreenSelectCourse::MenuRight( const PlayerNumber p, const InputEventType type )
{
m_MusicWheel.NextMusic();
AfterCourseChange();
}
void ScreenSelectCourse::MenuStart( const PlayerNumber p )
{
// this needs to check whether valid Notes are selected!
2002-06-23 11:43:53 +00:00
m_MusicWheel.Select();
2002-06-14 22:25:22 +00:00
2002-06-23 11:43:53 +00:00
switch( m_MusicWheel.GetSelectedType() )
2002-06-14 22:25:22 +00:00
{
2002-06-23 11:43:53 +00:00
case TYPE_COURSE:
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_MUSIC_COMMENT_GENERAL) );
TweenOffScreen();
2002-06-14 22:25:22 +00:00
2002-06-23 11:43:53 +00:00
m_soundSelect.PlayRandom();
2002-06-14 22:25:22 +00:00
2002-07-27 19:29:51 +00:00
m_bMadeChoice = true;
2002-06-23 11:43:53 +00:00
// show "hold START for options"
m_textHoldForOptions.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_textHoldForOptions.BeginTweeningQueued( 0.25f ); // fade in
m_textHoldForOptions.SetTweenZoomY( 1 );
m_textHoldForOptions.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_textHoldForOptions.BeginTweeningQueued( 2.0f ); // sleep
m_textHoldForOptions.BeginTweeningQueued( 0.25f ); // fade out
m_textHoldForOptions.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_textHoldForOptions.SetTweenZoomY( 0 );
2002-06-23 02:50:33 +00:00
2002-06-23 11:43:53 +00:00
m_Menu.TweenOffScreenToBlack( SM_None, false );
2002-06-23 02:50:33 +00:00
2002-07-28 20:28:37 +00:00
Course* pCourse = m_MusicWheel.GetSelectedCourse();
GAMESTATE->m_pCurCourse = pCourse;
for( int p=0; p<NUM_PLAYERS; p++ )
pCourse->GetPlayerOptions( &GAMESTATE->m_PlayerOptions[p] );
pCourse->GetSongOptions( &GAMESTATE->m_SongOptions );
2002-07-04 21:05:18 +00:00
2002-06-23 11:43:53 +00:00
this->SendScreenMessage( SM_GoToNextState, 2.5f );
break;
2002-06-14 22:25:22 +00:00
}
}
void ScreenSelectCourse::MenuBack( const PlayerNumber p )
{
MUSIC->Stop();
m_Menu.TweenOffScreenToBlack( SM_GoToPrevState, true );
}
void ScreenSelectCourse::AfterCourseChange()
{
switch( m_MusicWheel.GetSelectedType() )
{
case TYPE_COURSE:
{
Course* pCourse = m_MusicWheel.GetSelectedCourse();
m_CourseInfoFrame.SetFromCourse( pCourse );
m_CourseContentsFrame.SetFromCourse( pCourse );
}
break;
2002-07-27 19:29:51 +00:00
case TYPE_SECTION: // this probably means "no courses"
break;
2002-06-14 22:25:22 +00:00
default:
ASSERT(0);
}
}