Files
itgmania212121/stepmania/src/ScreenSelectStyle.cpp
T

321 lines
8.3 KiB
C++
Raw Normal View History

2002-05-20 08:59:37 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-06-27 17:49:10 +00:00
Class: ScreenSelectStyle
2002-05-20 08:59:37 +00:00
Desc: Testing the Screen class.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-06-27 17:49:10 +00:00
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenSelectStyle.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "RageMusic.h"
#include "ScreenTitleMenu.h"
#include "ScreenCaution.h"
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "ScreenSelectDifficulty.h"
#include "ScreenSandbox.h"
#include "GameManager.h"
#include "RageLog.h"
#include "AnnouncerManager.h"
2002-05-27 18:36:01 +00:00
const float ICONS_START_X = SCREEN_LEFT + 60;
const float ICONS_SPACING_X = 76;
const float ICON_Y = SCREEN_TOP + 100;
const float EXPLANATION_X = SCREEN_RIGHT - 160;
2002-05-28 20:01:22 +00:00
const float EXPLANATION_Y = CENTER_Y-70;
2002-05-27 18:36:01 +00:00
const float INFO_X = SCREEN_RIGHT - 160;
2002-05-28 20:01:22 +00:00
const float INFO_Y = CENTER_Y+40;
2002-05-27 18:36:01 +00:00
const float PREVIEW_X = SCREEN_LEFT + 160;
const float PREVIEW_Y = CENTER_Y;
2002-05-20 08:59:37 +00:00
const ScreenMessage SM_GoToPrevState = ScreenMessage(SM_User + 1);
const ScreenMessage SM_GoToNextState = ScreenMessage(SM_User + 2);
ScreenSelectStyle::ScreenSelectStyle()
{
LOG->WriteLine( "ScreenSelectStyle::ScreenSelectStyle()" );
2002-06-24 22:04:31 +00:00
// Reset the current style and game
GAMEMAN->m_CurStyle = STYLE_NONE;
2002-05-27 18:36:01 +00:00
for( int s=0; s<NUM_STYLES; s++ )
2002-05-20 08:59:37 +00:00
{
2002-05-27 18:36:01 +00:00
Style style = (Style)s;
if( StyleToGame(style) == GAMEMAN->m_CurGame ) // games match
m_aPossibleStyles.Add( style );
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
m_iSelection = 0;
2002-05-20 08:59:37 +00:00
2002-05-27 18:36:01 +00:00
for( int i=0; i<m_aPossibleStyles.GetSize(); i++ )
2002-05-20 08:59:37 +00:00
{
2002-05-27 18:36:01 +00:00
Style style = m_aPossibleStyles[i];
m_sprIcon[i].Load( THEME->GetPathTo(GRAPHIC_SELECT_STYLE_ICONS) );
m_sprIcon[i].StopAnimating();
m_sprIcon[i].SetState( style );
m_sprIcon[i].SetXY( ICONS_START_X + ICONS_SPACING_X*i, ICON_Y );
this->AddActor( &m_sprIcon[i] );
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
m_sprExplanation.Load( THEME->GetPathTo(GRAPHIC_SELECT_STYLE_EXPLANATION) );
m_sprExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y );
this->AddActor( &m_sprExplanation );
m_sprPreview.SetXY( PREVIEW_X, PREVIEW_Y );
this->AddActor( &m_sprPreview );
m_sprInfo.SetXY( INFO_X, INFO_Y );
this->AddActor( &m_sprInfo );
2002-05-20 08:59:37 +00:00
2002-06-27 17:49:10 +00:00
// Load dummy Sprites
2002-06-27 19:14:23 +00:00
for( i=0; i<m_aPossibleStyles.GetSize(); i++ )
2002-06-27 17:49:10 +00:00
{
ThemeElement te;
te = (ThemeElement)(GRAPHIC_SELECT_STYLE_PREVIEW_GAME_0_STYLE_0+m_aPossibleStyles[i]);
m_sprDummyPreview[i].Load( THEME->GetPathTo(te) );
te = (ThemeElement)(GRAPHIC_SELECT_STYLE_INFO_GAME_0_STYLE_0+m_aPossibleStyles[i]);
m_sprDummyInfo[i].Load( THEME->GetPathTo(te) );
}
2002-05-20 08:59:37 +00:00
m_Menu.Load(
THEME->GetPathTo(GRAPHIC_SELECT_STYLE_BACKGROUND),
THEME->GetPathTo(GRAPHIC_SELECT_STYLE_TOP_EDGE),
2002-07-11 19:02:26 +00:00
ssprintf("Use %c %c to select, then press START", char(1), char(2) ),
false, true, 40
2002-05-20 08:59:37 +00:00
);
this->AddActor( &m_Menu );
2002-05-27 18:36:01 +00:00
m_soundChange.Load( THEME->GetPathTo(SOUND_SELECT_STYLE_CHANGE) );
m_soundSelect.Load( THEME->GetPathTo(SOUND_MENU_START) );
2002-05-20 08:59:37 +00:00
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ANNOUNCER_SELECT_STYLE_INTRO) );
if( !MUSIC->IsPlaying() )
{
MUSIC->Load( THEME->GetPathTo(SOUND_MENU_MUSIC) );
MUSIC->Play( true );
}
2002-05-27 18:36:01 +00:00
AfterChange();
2002-05-20 08:59:37 +00:00
TweenOnScreen();
2002-05-28 20:01:22 +00:00
m_Menu.TweenOnScreenFromBlack( SM_None );
2002-05-20 08:59:37 +00:00
}
ScreenSelectStyle::~ScreenSelectStyle()
{
LOG->WriteLine( "ScreenSelectStyle::~ScreenSelectStyle()" );
}
void ScreenSelectStyle::DrawPrimitives()
{
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
void ScreenSelectStyle::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
LOG->WriteLine( "ScreenSelectStyle::Input()" );
2002-05-28 20:01:22 +00:00
if( m_Menu.IsClosing() )
2002-05-20 08:59:37 +00:00
return;
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
}
void ScreenSelectStyle::HandleScreenMessage( const ScreenMessage SM )
{
Screen::HandleScreenMessage( SM );
switch( SM )
{
2002-05-27 08:23:27 +00:00
case SM_MenuTimer:
2002-06-24 22:04:31 +00:00
MenuStart(PLAYER_INVALID);
2002-05-27 08:23:27 +00:00
break;
2002-05-20 08:59:37 +00:00
case SM_GoToPrevState:
MUSIC->Stop();
SCREENMAN->SetNewScreen( new ScreenTitleMenu );
break;
case SM_GoToNextState:
SCREENMAN->SetNewScreen( new ScreenSelectDifficulty );
break;
}
}
2002-05-27 18:36:01 +00:00
void ScreenSelectStyle::BeforeChange()
{
m_sprIcon[m_iSelection].SetEffectNone();
}
void ScreenSelectStyle::AfterChange()
{
m_sprIcon[m_iSelection].SetEffectGlowing();
ThemeElement te;
2002-05-28 20:01:22 +00:00
// Tween Preview
2002-06-14 22:25:22 +00:00
te = (ThemeElement)(GRAPHIC_SELECT_STYLE_PREVIEW_GAME_0_STYLE_0+GetSelectedStyle());
2002-05-27 18:36:01 +00:00
m_sprPreview.Load( THEME->GetPathTo(te) );
2002-05-28 20:01:22 +00:00
m_sprPreview.StopTweening();
m_sprPreview.SetAddColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.BeginTweeningQueued( 0.25f ); // sleep
m_sprPreview.BeginTweeningQueued( 0.2f ); // fade to white
m_sprPreview.SetTweenAddColor( D3DXCOLOR(1,1,1,1) );
m_sprPreview.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.BeginTweeningQueued( 0.01f ); // turn color on
m_sprPreview.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) );
m_sprPreview.BeginTweeningQueued( 0.2f ); // fade to color
m_sprPreview.SetTweenAddColor( D3DXCOLOR(1,1,1,0) );
m_sprPreview.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) );
// Tween Info
2002-06-14 22:25:22 +00:00
te = (ThemeElement)(GRAPHIC_SELECT_STYLE_INFO_GAME_0_STYLE_0+GetSelectedStyle());
2002-05-27 18:36:01 +00:00
m_sprInfo.Load( THEME->GetPathTo(te) );
2002-05-28 20:01:22 +00:00
m_sprInfo.StopTweening();
2002-05-27 18:36:01 +00:00
m_sprInfo.SetZoomY( 0 );
2002-05-28 20:01:22 +00:00
m_sprInfo.BeginTweeningQueued( 0.5f, Actor::TWEEN_BOUNCE_END );
2002-05-27 18:36:01 +00:00
m_sprInfo.SetTweenZoomY( 1 );
}
void ScreenSelectStyle::MenuLeft( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
2002-05-27 08:23:27 +00:00
if( m_iSelection == 0 ) // can't go left any further
2002-05-20 08:59:37 +00:00
return;
BeforeChange();
2002-05-27 18:36:01 +00:00
m_iSelection--;
2002-05-20 08:59:37 +00:00
m_soundChange.PlayRandom();
AfterChange();
}
2002-05-27 18:36:01 +00:00
void ScreenSelectStyle::MenuRight( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
2002-05-27 18:36:01 +00:00
if( m_iSelection == m_aPossibleStyles.GetSize()-1 ) // can't go right any further
2002-05-20 08:59:37 +00:00
return;
BeforeChange();
2002-05-27 18:36:01 +00:00
m_iSelection++;
2002-05-20 08:59:37 +00:00
m_soundChange.PlayRandom();
AfterChange();
}
2002-05-27 18:36:01 +00:00
void ScreenSelectStyle::MenuStart( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
2002-06-24 22:04:31 +00:00
if( p != PLAYER_INVALID )
2002-05-28 20:01:22 +00:00
GAMEMAN->m_sMasterPlayerNumber = p;
2002-05-27 18:36:01 +00:00
GAMEMAN->m_CurStyle = GetSelectedStyle();
2002-05-20 08:59:37 +00:00
2002-05-27 08:23:27 +00:00
AnnouncerElement ae;
switch( GAMEMAN->m_CurStyle )
{
case STYLE_DANCE_SINGLE: ae = ANNOUNCER_SELECT_STYLE_COMMENT_SINGLE; break;
case STYLE_DANCE_VERSUS: ae = ANNOUNCER_SELECT_STYLE_COMMENT_VERSUS; break;
case STYLE_DANCE_DOUBLE: ae = ANNOUNCER_SELECT_STYLE_COMMENT_DOUBLE; break;
case STYLE_DANCE_COUPLE: ae = ANNOUNCER_SELECT_STYLE_COMMENT_COUPLE; break;
case STYLE_DANCE_SOLO: ae = ANNOUNCER_SELECT_STYLE_COMMENT_SOLO; break;
case STYLE_PUMP_SINGLE: ae = ANNOUNCER_SELECT_STYLE_COMMENT_SINGLE; break;
case STYLE_PUMP_VERSUS: ae = ANNOUNCER_SELECT_STYLE_COMMENT_VERSUS; break;
default: ASSERT(0); break; // invalid Style
}
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo(ae) );
2002-05-20 08:59:37 +00:00
2002-05-28 20:01:22 +00:00
m_Menu.TweenOffScreenToMenu( SM_GoToNextState );
2002-05-20 08:59:37 +00:00
m_soundSelect.PlayRandom();
TweenOffScreen();
}
2002-05-27 18:36:01 +00:00
void ScreenSelectStyle::MenuBack( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
MUSIC->Stop();
2002-05-28 20:01:22 +00:00
m_Menu.TweenOffScreenToBlack( SM_GoToPrevState, true );
2002-05-20 08:59:37 +00:00
2002-05-28 20:01:22 +00:00
// m_Fade.CloseWipingLeft( SM_GoToPrevState );
2002-05-20 08:59:37 +00:00
2002-05-28 20:01:22 +00:00
// TweenOffScreen();
2002-05-20 08:59:37 +00:00
}
void ScreenSelectStyle::TweenOffScreen()
{
2002-05-27 18:36:01 +00:00
for( int i=0; i<NUM_STYLES; i++ )
2002-05-20 08:59:37 +00:00
{
2002-05-27 18:36:01 +00:00
m_sprIcon[i].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprIcon[i].SetTweenZoomY( 0 );
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
m_sprExplanation.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprExplanation.SetTweenZoomY( 0 );
2002-05-20 08:59:37 +00:00
2002-05-27 18:36:01 +00:00
m_sprPreview.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprPreview.SetTweenZoomY( 0 );
2002-05-20 08:59:37 +00:00
2002-05-27 18:36:01 +00:00
m_sprInfo.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprInfo.SetTweenZoomX( 0 );
2002-05-20 08:59:37 +00:00
}
void ScreenSelectStyle::TweenOnScreen()
{
2002-05-27 18:36:01 +00:00
float fOriginalZoom;
2002-05-20 08:59:37 +00:00
2002-05-27 18:36:01 +00:00
for( int i=0; i<NUM_STYLES; i++ )
2002-05-20 08:59:37 +00:00
{
2002-05-27 18:36:01 +00:00
fOriginalZoom = m_sprIcon[i].GetZoomY();
m_sprIcon[i].SetZoomY( 0 );
m_sprIcon[i].BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprIcon[i].SetTweenZoomY( fOriginalZoom );
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
fOriginalZoom = m_sprExplanation.GetZoomY();
m_sprExplanation.SetZoomY( 0 );
m_sprExplanation.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprExplanation.SetTweenZoomY( fOriginalZoom );
2002-05-20 08:59:37 +00:00
2002-05-28 20:01:22 +00:00
// let AfterChange tween Preview and Info
/*
2002-05-27 18:36:01 +00:00
fOriginalZoom = m_sprPreview.GetZoomY();
m_sprPreview.SetZoomY( 0 );
m_sprPreview.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprPreview.SetTweenZoomY( fOriginalZoom );
2002-05-20 08:59:37 +00:00
2002-05-27 18:36:01 +00:00
fOriginalZoom = m_sprInfo.GetZoomY();
m_sprInfo.SetZoomY( 0 );
m_sprInfo.BeginTweening( MENU_ELEMENTS_TWEEN_TIME );
m_sprInfo.SetTweenZoomY( fOriginalZoom );
2002-05-28 20:01:22 +00:00
*/
2002-05-20 08:59:37 +00:00
}