Files
itgmania212121/stepmania/src/ScreenTitleMenu.cpp
T

305 lines
8.4 KiB
C++
Raw Normal View History

2002-05-20 08:59:37 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-05-28 20:01:22 +00:00
Class: ScreenTitleMenu
2002-05-20 08:59:37 +00:00
2002-05-28 20:01: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-05-28 20:01:22 +00:00
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenTitleMenu.h"
#include "ScreenManager.h"
#include "GameConstantsAndTypes.h"
#include "RageUtil.h"
#include "StepMania.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-05-20 08:59:37 +00:00
#include "RageLog.h"
#include "SongManager.h"
#include "AnnouncerManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2002-05-28 20:01:22 +00:00
#include "GameManager.h"
#include "InputMapper.h"
#include "ThemeManager.h"
2002-11-12 07:04:45 +00:00
#include "SDL_Utils.h"
2003-01-02 07:54:28 +00:00
#include "RageSoundManager.h"
2002-05-20 08:59:37 +00:00
const CString CHOICE_TEXT[ScreenTitleMenu::NUM_TITLE_MENU_CHOICES] = {
2002-05-28 20:01:22 +00:00
"GAME START",
2002-05-27 08:23:27 +00:00
"SWITCH GAME",
2002-07-03 21:27:26 +00:00
"CONFIG KEY/JOY",
"INPUT OPTIONS",
"MACHINE OPTIONS",
"GRAPHIC OPTIONS",
2002-07-11 19:02:26 +00:00
"APPEARANCE OPTIONS",
2002-06-29 11:59:09 +00:00
"EDIT/RECORD/SYNCH",
2002-11-19 22:55:51 +00:00
#ifdef _DEBUG
"SANDBOX",
#endif
2002-05-20 08:59:37 +00:00
"EXIT",
};
#define HELP_X THEME->GetMetricF("ScreenTitleMenu","HelpX")
#define HELP_Y THEME->GetMetricF("ScreenTitleMenu","HelpY")
#define CHOICES_X THEME->GetMetricF("ScreenTitleMenu","ChoicesX")
#define CHOICES_START_Y THEME->GetMetricF("ScreenTitleMenu","ChoicesStartY")
#define CHOICES_SPACING_Y THEME->GetMetricF("ScreenTitleMenu","ChoicesSpacingY")
#define CHOICES_SHADOW_LENGTH THEME->GetMetricF("ScreenTitleMenu","ChoicesShadowLength")
#define COLOR_NOT_SELECTED THEME->GetMetricC("ScreenTitleMenu","ColorNotSelected")
#define COLOR_SELECTED THEME->GetMetricC("ScreenTitleMenu","ColorSelected")
#define ZOOM_NOT_SELECTED THEME->GetMetricF("ScreenTitleMenu","ZoomNotSelected")
#define ZOOM_SELECTED THEME->GetMetricF("ScreenTitleMenu","ZoomSelected")
#define SECONDS_BETWEEN_COMMENTS THEME->GetMetricF("ScreenTitleMenu","SecondsBetweenComments")
#define SECONDS_BEFORE_ATTRACT THEME->GetMetricF("ScreenTitleMenu","SecondsBeforeAttract")
#define HELP_TEXT THEME->GetMetric("ScreenTitleMenu","HelpText")
#define NEXT_SCREEN THEME->GetMetric("ScreenTitleMenu","NextScreen")
2002-05-20 08:59:37 +00:00
const ScreenMessage SM_PlayComment = ScreenMessage(SM_User+1);
const ScreenMessage SM_GoToNextScreen = ScreenMessage(SM_User+12);
const ScreenMessage SM_GoToAttractLoop = ScreenMessage(SM_User+13);
2002-08-02 09:31:06 +00:00
2002-05-20 08:59:37 +00:00
ScreenTitleMenu::ScreenTitleMenu()
{
LOG->Trace( "ScreenTitleMenu::ScreenTitleMenu()" );
}
2002-05-20 08:59:37 +00:00
void ScreenTitleMenu::FirstUpdate()
{
LOG->Trace( "ScreenTitleMenu::FirstUpdate()" );
2002-05-20 08:59:37 +00:00
ScreenLogo::FirstUpdate();
2002-05-20 08:59:37 +00:00
// we have to do init here because ScreenLogo does it's initialization in FirstUpdate()
2002-08-20 21:00:56 +00:00
m_textHelp.LoadFromFont( THEME->GetPathTo("Fonts","help") );
m_textHelp.SetText( HELP_TEXT );
m_textHelp.SetXY( HELP_X, HELP_Y );
2002-05-20 08:59:37 +00:00
m_textHelp.SetZoom( 0.5f );
m_textHelp.SetEffectBlinking();
m_textHelp.SetShadowLength( 2 );
this->AddChild( &m_textHelp );
2002-05-20 08:59:37 +00:00
2002-10-08 08:53:38 +00:00
int i;
for( i=0; i< NUM_TITLE_MENU_CHOICES; i++ )
2002-05-20 08:59:37 +00:00
{
m_textChoice[i].LoadFromFont( THEME->GetPathTo("Fonts","titlemenu") );
2002-05-20 08:59:37 +00:00
m_textChoice[i].SetText( CHOICE_TEXT[i] );
m_textChoice[i].SetXY( CHOICES_X, CHOICES_START_Y + i*CHOICES_SPACING_Y );
2002-10-08 08:53:38 +00:00
float fShadowLength = CHOICES_SHADOW_LENGTH;
m_textChoice[i].SetShadowLength( fShadowLength );
this->AddChild( &m_textChoice[i] );
2002-05-20 08:59:37 +00:00
}
2002-10-08 08:53:38 +00:00
2003-01-02 08:13:34 +00:00
SOUNDMAN->PlayOnceFromDir( ANNOUNCER->GetPathTo("title menu game name") );
2002-05-20 08:59:37 +00:00
2002-07-23 01:41:40 +00:00
m_soundAttract.Load( ANNOUNCER->GetPathTo("title menu attract") );
m_soundChange.Load( THEME->GetPathTo("Sounds","title menu change") );
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
m_soundInvalid.Load( THEME->GetPathTo("Sounds","menu invalid") );
2002-05-20 08:59:37 +00:00
2002-05-28 20:01:22 +00:00
m_TitleMenuChoice = CHOICE_GAME_START;
for( i=0; i<NUM_TITLE_MENU_CHOICES; i++ )
LoseFocus( i );
2002-05-20 08:59:37 +00:00
GainFocus( m_TitleMenuChoice );
m_soundMusic.Stop();
2003-01-02 07:39:58 +00:00
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","title menu music") );
2002-05-20 08:59:37 +00:00
this->SendScreenMessage( SM_PlayComment, SECONDS_BETWEEN_COMMENTS);
2002-05-20 08:59:37 +00:00
this->MoveToBack( &(ScreenAttract::m_Fade) ); // put it in the back so it covers up the stuff we just added
}
2002-05-20 08:59:37 +00:00
ScreenTitleMenu::~ScreenTitleMenu()
{
LOG->Trace( "ScreenTitleMenu::~ScreenTitleMenu()" );
2002-05-20 08:59:37 +00:00
}
void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
2002-09-06 00:31:25 +00:00
// LOG->Trace( "ScreenTitleMenu::Input()" );
2003-01-09 07:46:45 +00:00
LOG->Trace( "ScreenTitleMenu::Input( %d-%d )", DeviceI.device, DeviceI.button ); // debugging gameport joystick problem
2002-05-20 08:59:37 +00:00
if( m_Fade.IsClosing() )
return;
2003-01-07 01:23:41 +00:00
2002-05-20 08:59:37 +00:00
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
}
void ScreenTitleMenu::Update( float fDelta )
{
if(TimeToDemonstration.PeekDeltaTime() >= SECONDS_BEFORE_ATTRACT)
{
this->SendScreenMessage( SM_GoToAttractLoop, 0 );
TimeToDemonstration.GetDeltaTime();
}
Screen::Update(fDelta);
}
2002-05-20 08:59:37 +00:00
void ScreenTitleMenu::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_PlayComment:
m_soundAttract.PlayRandom();
this->SendScreenMessage( SM_PlayComment, SECONDS_BETWEEN_COMMENTS );
break;
case SM_GoToNextScreen:
switch( m_TitleMenuChoice )
{
case CHOICE_GAME_START:
SCREENMAN->SetNewScreen( NEXT_SCREEN );
break;
case CHOICE_SELECT_GAME:
SCREENMAN->SetNewScreen( "ScreenSelectGame" );
break;
case CHOICE_MAP_INSTRUMENTS:
SCREENMAN->SetNewScreen( "ScreenMapControllers" );
break;
case CHOICE_INPUT_OPTIONS:
SCREENMAN->SetNewScreen( "ScreenInputOptions" );
break;
case CHOICE_MACHINE_OPTIONS:
SCREENMAN->SetNewScreen( "ScreenMachineOptions" );
break;
case CHOICE_GRAPHIC_OPTIONS:
SCREENMAN->SetNewScreen( "ScreenGraphicOptions" );
break;
case CHOICE_APPEARANCE_OPTIONS:
SCREENMAN->SetNewScreen( "ScreenAppearanceOptions" );
break;
2002-11-19 22:55:51 +00:00
#ifdef _DEBUG
case CHOICE_SANDBOX:
SCREENMAN->SetNewScreen( "ScreenTest" );
2002-11-19 22:55:51 +00:00
break;
#endif
case CHOICE_EDIT:
SCREENMAN->SetNewScreen( "ScreenEditMenu" );
break;
case CHOICE_EXIT:
default:
RAGE_ASSERT_M(0, "CHOICE_EXIT reached?"); // should never get here
break;
}
2002-06-23 11:43:53 +00:00
break;
case SM_GoToAttractLoop:
SCREENMAN->SetNewScreen( "ScreenCompany" );
2002-08-02 09:31:06 +00:00
break;
2002-05-20 08:59:37 +00:00
}
}
void ScreenTitleMenu::LoseFocus( int iChoiceIndex )
{
m_textChoice[iChoiceIndex].SetEffectNone();
m_textChoice[iChoiceIndex].StopTweening();
2002-05-20 08:59:37 +00:00
m_textChoice[iChoiceIndex].BeginTweening( 0.3f );
m_textChoice[iChoiceIndex].SetTweenZoom( ZOOM_NOT_SELECTED );
2002-05-20 08:59:37 +00:00
}
void ScreenTitleMenu::GainFocus( int iChoiceIndex )
{
m_textChoice[iChoiceIndex].StopTweening();
2002-05-20 08:59:37 +00:00
m_textChoice[iChoiceIndex].BeginTweening( 0.3f );
m_textChoice[iChoiceIndex].SetTweenZoom( ZOOM_SELECTED );
RageColor color1, color2;
color1 = COLOR_SELECTED;
color2 = color1 * 0.5f;
color2.a = 1;
m_textChoice[iChoiceIndex].SetEffectCamelion( 2.5f, color1, color2 );
2002-05-20 08:59:37 +00:00
}
void ScreenTitleMenu::MenuUp( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */
2002-05-20 08:59:37 +00:00
LoseFocus( m_TitleMenuChoice );
if( m_TitleMenuChoice == 0 ) // wrap around
m_TitleMenuChoice = (ScreenTitleMenu::TitleMenuChoice)((int)NUM_TITLE_MENU_CHOICES);
m_TitleMenuChoice = TitleMenuChoice( m_TitleMenuChoice-1 );
m_soundChange.PlayRandom();
2002-05-20 08:59:37 +00:00
GainFocus( m_TitleMenuChoice );
}
void ScreenTitleMenu::MenuDown( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
TimeToDemonstration.GetDeltaTime(); /* Reset the demonstration timer when a key is pressed. */
2002-05-20 08:59:37 +00:00
LoseFocus( m_TitleMenuChoice );
if( m_TitleMenuChoice == (int)ScreenTitleMenu::NUM_TITLE_MENU_CHOICES-1 )
m_TitleMenuChoice = (TitleMenuChoice)-1; // wrap around
m_TitleMenuChoice = TitleMenuChoice( m_TitleMenuChoice+1 );
m_soundChange.PlayRandom();
2002-05-20 08:59:37 +00:00
GainFocus( m_TitleMenuChoice );
}
void ScreenTitleMenu::MenuStart( PlayerNumber pn )
2002-05-20 08:59:37 +00:00
{
GAMESTATE->m_bSideIsJoined[pn] = true;
GAMESTATE->m_MasterPlayerNumber = pn;
GAMESTATE->m_bPlayersCanJoin = false;
2002-05-20 08:59:37 +00:00
switch( m_TitleMenuChoice )
{
2002-05-28 20:01:22 +00:00
case CHOICE_GAME_START:
2002-05-20 08:59:37 +00:00
case CHOICE_SELECT_GAME:
case CHOICE_MAP_INSTRUMENTS:
case CHOICE_INPUT_OPTIONS:
case CHOICE_MACHINE_OPTIONS:
case CHOICE_GRAPHIC_OPTIONS:
2002-07-11 19:02:26 +00:00
case CHOICE_APPEARANCE_OPTIONS:
2002-11-19 22:55:51 +00:00
#ifdef _DEBUG
case CHOICE_SANDBOX:
#endif
2002-07-11 19:02:26 +00:00
m_soundSelect.PlayRandom();
m_Fade.CloseWipingRight( SM_GoToNextScreen );
break;
2002-05-20 08:59:37 +00:00
case CHOICE_EDIT:
if( SONGMAN->m_pSongs.empty() )
2002-07-04 21:05:18 +00:00
{
m_soundInvalid.PlayRandom();
}
else
{
m_soundSelect.PlayRandom();
m_Fade.CloseWipingRight( SM_GoToNextScreen );
2002-07-04 21:05:18 +00:00
}
break;
2002-11-12 07:04:45 +00:00
case CHOICE_EXIT: {
2002-05-20 08:59:37 +00:00
m_soundSelect.PlayRandom();
Exit();
LOG->Trace("CHOICE_EXIT: shutting down");
2002-11-12 07:04:45 +00:00
}
2002-05-20 08:59:37 +00:00
return;
2002-07-11 19:02:26 +00:00
default:
ASSERT(0);
2002-05-20 08:59:37 +00:00
}
}
void ScreenTitleMenu::MenuBack( PlayerNumber pn )
{
this->m_Fade.CloseWipingRight( SM_GoToAttractLoop );
2002-05-20 08:59:37 +00:00
}