Files
itgmania212121/stepmania/src/ScreenSelect.cpp
T

175 lines
4.9 KiB
C++
Raw Normal View History

2003-03-03 10:03:02 +00:00
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ScreenSelect
Desc: See Header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenSelect.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
2003-07-26 23:05:16 +00:00
#include "RageSounds.h"
2003-03-03 10:03:02 +00:00
#include "GameConstantsAndTypes.h"
#include "PrefsManager.h"
#include "GameManager.h"
#include "RageLog.h"
#include "AnnouncerManager.h"
#include "GameState.h"
#include "GameConstantsAndTypes.h"
#include "ThemeManager.h"
#include "ModeChoice.h"
#include "RageDisplay.h"
#include "arch/ArchHooks/ArchHooks.h"
2003-03-03 10:03:02 +00:00
2003-09-21 20:10:15 +00:00
#define NUM_CHOICES THEME->GetMetricI(m_sName,"NumChoices")
#define CHOICE( choice ) THEME->GetMetric (m_sName,ssprintf("Choice%d",choice+1))
2003-04-12 06:16:12 +00:00
#define HELP_TEXT THEME->GetMetric (m_sName,"HelpText")
#define NEXT_SCREEN( choice ) THEME->GetMetric (m_sName,ssprintf("NextScreen%d",choice+1))
2003-03-03 10:03:02 +00:00
2003-04-12 06:16:12 +00:00
ScreenSelect::ScreenSelect( CString sClassName ) : Screen(sClassName)
2003-03-03 10:03:02 +00:00
{
LOG->Trace( "ScreenSelect::ScreenSelect()" );
2003-04-12 06:16:12 +00:00
m_sName = sClassName;
2003-03-03 10:03:02 +00:00
2003-09-21 21:20:37 +00:00
for( int c=0; c<NUM_CHOICES; c++ )
2003-03-09 00:55:49 +00:00
{
2003-09-21 20:10:15 +00:00
CString sChoice = CHOICE(c);
2003-03-03 10:03:02 +00:00
2003-09-21 20:10:15 +00:00
ModeChoice mc;
2003-09-25 05:56:38 +00:00
mc.Load( c, sChoice );
m_aModeChoices.push_back( mc );
CString sBGAnimationDir = THEME->GetPathTo(BGAnimations, ssprintf("%s %s",m_sName.c_str(),mc.m_sName.c_str()), true); // true="optional"
2003-03-03 10:03:02 +00:00
if( sBGAnimationDir == "" )
sBGAnimationDir = THEME->GetPathToB(m_sName+" background");
2003-03-03 10:03:02 +00:00
m_BGAnimations[c].LoadFromAniDir( sBGAnimationDir );
}
2003-03-30 21:02:15 +00:00
m_Menu.Load( sClassName );
2003-03-03 10:03:02 +00:00
this->AddChild( &m_Menu );
}
ScreenSelect::~ScreenSelect()
{
LOG->Trace( "ScreenSelect::~ScreenSelect()" );
}
void ScreenSelect::Update( float fDelta )
{
if(m_bFirstUpdate)
{
/* Don't play sounds during the ctor, since derived classes havn't loaded yet. */
2003-07-26 23:05:16 +00:00
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo(m_sName+" intro") );
SOUND->PlayMusic( THEME->GetPathToS(m_sName+" music") );
}
2003-03-03 10:03:02 +00:00
Screen::Update( fDelta );
2003-08-03 00:13:55 +00:00
int iSelection = this->GetSelectionIndex(GAMESTATE->m_MasterPlayerNumber);
m_BGAnimations[iSelection].Update( fDelta );
2003-03-03 10:03:02 +00:00
}
void ScreenSelect::DrawPrimitives()
{
2003-08-03 00:13:55 +00:00
int iSelection = this->GetSelectionIndex(GAMESTATE->m_MasterPlayerNumber);
m_BGAnimations[iSelection].Draw();
2003-03-03 10:03:02 +00:00
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
// LOG->Trace( "ScreenSelect::Input()" );
2003-03-03 10:03:02 +00:00
2003-11-09 01:09:35 +00:00
if( Screen::JoinInput(DeviceI, type, GameI, MenuI, StyleI) )
2003-03-03 10:03:02 +00:00
{
2003-11-09 01:09:35 +00:00
this->UpdateSelectableChoices();
return; // don't let the screen handle the MENU_START press
2003-03-03 10:03:02 +00:00
}
2003-03-09 00:55:49 +00:00
if( m_Menu.IsTransitioning() )
2003-03-03 10:03:02 +00:00
return;
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
}
void ScreenSelect::FinalizeChoices()
{
/* At this point, we're tweening out; we can't change the selection.
* We don't want to allow players to join if the style will be set,
* since that can change the available selection and is likely to
* invalidate the choice we've already made. Hack: apply the style.
* (Applying the style may have other side-effects, so it'll be re-applied
* in SM_GoToNextScreen.) */
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) )
{
const int sel = GetSelectionIndex( (PlayerNumber)p );
if( m_aModeChoices[sel].m_style != STYLE_INVALID )
GAMESTATE->m_CurStyle = m_aModeChoices[sel].m_style;
}
SCREENMAN->RefreshCreditsMessages();
}
2003-03-03 10:03:02 +00:00
void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
/* Screen is starting to tween out. */
case SM_BeginFadingOut:
FinalizeChoices();
break;
2003-03-03 10:03:02 +00:00
/* It's our turn to tween out. */
case SM_AllDoneChoosing:
FinalizeChoices();
if( !m_Menu.IsTransitioning() )
m_Menu.StartTransitioning( SM_GoToNextScreen );
2003-03-03 10:03:02 +00:00
break;
case SM_MenuTimer:
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) )
2003-03-03 10:03:02 +00:00
MenuStart( (PlayerNumber)p );
}
break;
case SM_GoToPrevScreen:
2003-07-26 23:05:16 +00:00
SOUND->StopMusic();
2003-03-03 10:03:02 +00:00
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
break;
case SM_GoToNextScreen:
{
2003-09-16 05:57:23 +00:00
/* Apply here, not in SM_AllDoneChoosing, because applying can take a very
* long time (200+ms), and at SM_AllDoneChoosing, we're still tweening stuff
* off-screen. */
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) )
m_aModeChoices[this->GetSelectionIndex((PlayerNumber)p)].Apply( (PlayerNumber)p );
2003-11-05 19:55:28 +00:00
const int iSelectionIndex = GetSelectionIndex(GAMESTATE->m_MasterPlayerNumber);
if( m_aModeChoices[iSelectionIndex].m_sScreen != "" )
SCREENMAN->SetNewScreen( m_aModeChoices[iSelectionIndex ].m_sScreen );
else
SCREENMAN->SetNewScreen( NEXT_SCREEN(iSelectionIndex) );
2003-03-03 10:03:02 +00:00
}
break;
}
}
void ScreenSelect::MenuBack( PlayerNumber pn )
{
2003-07-26 23:05:16 +00:00
SOUND->StopMusic();
2003-03-03 10:03:02 +00:00
2003-03-09 00:55:49 +00:00
m_Menu.Back( SM_GoToPrevScreen );
2003-03-03 10:03:02 +00:00
}