Files
itgmania212121/stepmania/src/ScreenWithMenuElements.cpp
T

204 lines
6.4 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
#include "ScreenWithMenuElements.h"
2003-11-07 20:10:38 +00:00
#include "MenuTimer.h"
2003-11-17 01:01:44 +00:00
#include "HelpDisplay.h"
#include "RageLog.h"
#include "ThemeManager.h"
#include "GameState.h"
2004-06-28 07:26:00 +00:00
#include "Style.h"
#include "PrefsManager.h"
#include "ScreenManager.h"
#define TIMER_SECONDS THEME->GetMetricI(m_sName,"TimerSeconds")
2004-12-04 21:13:29 +00:00
#define TIMER_STEALTH THEME->GetMetricB(m_sName,"TimerStealth")
#define STYLE_ICON THEME->GetMetricB(m_sName,"StyleIcon")
#define MEMORY_CARD_ICONS THEME->GetMetricB(m_sName,"MemoryCardIcons")
2002-05-27 18:36:01 +00:00
2004-11-26 17:28:47 +00:00
//REGISTER_SCREEN_CLASS( ScreenWithMenuElements );
ScreenWithMenuElements::ScreenWithMenuElements( CString sClassName ) : Screen( sClassName )
{
LOG->Trace( "ScreenWithMenuElements::ScreenWithMenuElements()" );
2003-11-07 20:10:38 +00:00
m_MenuTimer = new MenuTimer;
2003-11-17 01:01:44 +00:00
m_textHelp = new HelpDisplay;
2003-11-07 20:10:38 +00:00
LOG->Trace( "MenuElements::MenuElements()" );
2003-03-09 00:55:49 +00:00
ASSERT( this->m_SubActors.empty() ); // don't call Load twice!
2003-11-07 20:57:22 +00:00
this->SetName( sClassName );
2003-03-09 00:55:49 +00:00
m_Background.LoadFromAniDir( THEME->GetPathToB(m_sName+" background") );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_Background );
2003-11-04 21:49:38 +00:00
m_autoHeader.Load( THEME->GetPathToG(m_sName+" header") );
m_autoHeader->SetName("Header");
UtilSetXY( m_autoHeader, m_sName );
UtilOnCommand( m_autoHeader, m_sName );
2003-11-04 21:49:38 +00:00
this->AddChild( m_autoHeader );
2004-06-28 07:26:00 +00:00
if( STYLE_ICON && GAMESTATE->m_pCurStyle )
2003-03-09 00:55:49 +00:00
{
CString sIconFileName = CString("MenuElements icon ") + GAMESTATE->GetCurrentStyle()->m_szName;
2003-11-04 21:49:38 +00:00
m_sprStyleIcon.SetName( "StyleIcon" );
m_sprStyleIcon.Load( THEME->GetPathToG(sIconFileName) );
2003-03-09 00:55:49 +00:00
m_sprStyleIcon.StopAnimating();
m_sprStyleIcon.SetState( GAMESTATE->m_MasterPlayerNumber );
UtilSetXY( m_sprStyleIcon, m_sName );
UtilOnCommand( m_sprStyleIcon, m_sName );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_sprStyleIcon );
}
2002-05-27 18:36:01 +00:00
if( MEMORY_CARD_ICONS )
{
FOREACH_PlayerNumber( p )
{
m_MemoryCardDisplay[p].Load( (PlayerNumber)p );
m_MemoryCardDisplay[p].SetName( ssprintf("MemoryCardDisplayP%d",p+1) );
UtilSetXY( m_MemoryCardDisplay[p], m_sName );
UtilOnCommand( m_MemoryCardDisplay[p], m_sName );
this->AddChild( &m_MemoryCardDisplay[p] );
}
}
m_bTimerEnabled = (TIMER_SECONDS != -1);
if( m_bTimerEnabled )
{
2003-11-07 20:10:38 +00:00
m_MenuTimer->SetName( "Timer" );
2004-12-04 21:13:29 +00:00
if( TIMER_STEALTH )
m_MenuTimer->EnableStealth( true );
UtilSetXY( m_MenuTimer, m_sName );
UtilOnCommand( m_MenuTimer, m_sName );
2004-05-08 06:42:23 +00:00
ResetTimer();
2003-11-07 20:10:38 +00:00
this->AddChild( m_MenuTimer );
}
2002-05-27 08:23:27 +00:00
2003-11-04 21:49:38 +00:00
m_autoFooter.Load( THEME->GetPathToG(m_sName+" footer") );
m_autoFooter->SetName("Footer");
UtilSetXY( m_autoFooter, m_sName );
UtilOnCommand( m_autoFooter, m_sName );
2003-11-04 21:49:38 +00:00
this->AddChild( m_autoFooter );
2003-11-17 01:39:34 +00:00
m_textHelp->SetName( "HelpDisplay", "Help" );
m_textHelp->Load();
UtilSetXY( m_textHelp, m_sName );
UtilOnCommand( m_textHelp, m_sName );
2002-07-23 01:41:40 +00:00
CStringArray asHelpTips;
2003-04-12 06:16:12 +00:00
split( THEME->GetMetric(m_sName,"HelpText"), "\n", asHelpTips );
2003-11-17 01:01:44 +00:00
m_textHelp->SetTips( asHelpTips );
this->AddChild( m_textHelp );
m_In.Load( THEME->GetPathToB(m_sName+" in") );
2004-05-02 03:01:27 +00:00
m_In.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_In );
m_Out.Load( THEME->GetPathToB(m_sName+" out") );
2004-05-02 03:01:27 +00:00
m_Out.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_Out );
m_Back.Load( THEME->GetPathToB("Common back") );
2004-05-02 03:01:27 +00:00
m_Back.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
2003-03-09 00:55:49 +00:00
this->AddChild( &m_Back );
m_In.StartTransitioning();
}
ScreenWithMenuElements::~ScreenWithMenuElements()
{
SAFE_DELETE( m_MenuTimer );
SAFE_DELETE( m_textHelp );
2002-05-28 20:01:22 +00:00
}
2004-05-08 06:42:23 +00:00
void ScreenWithMenuElements::ResetTimer()
{
2004-12-04 10:35:50 +00:00
if( TIMER_SECONDS > 0.0f && PREFSMAN->m_bMenuTimer && !GAMESTATE->m_bEditing )
2004-05-08 06:42:23 +00:00
{
m_MenuTimer->SetSeconds( TIMER_SECONDS );
m_MenuTimer->Start();
}
else
2004-12-04 10:35:50 +00:00
{
2004-05-08 06:42:23 +00:00
m_MenuTimer->Disable();
2004-12-04 10:35:50 +00:00
}
2004-05-08 06:42:23 +00:00
}
void ScreenWithMenuElements::StartTransitioning( ScreenMessage smSendWhenDone )
2002-05-28 20:01:22 +00:00
{
if( m_bTimerEnabled )
{
2003-11-07 20:10:38 +00:00
m_MenuTimer->SetSeconds( 0 );
m_MenuTimer->Stop();
UtilOffCommand( m_MenuTimer, m_sName );
}
UtilOffCommand( m_autoHeader, m_sName );
UtilOffCommand( m_sprStyleIcon, m_sName );
FOREACH_PlayerNumber( p )
UtilOffCommand( m_MemoryCardDisplay[p], m_sName );
UtilOffCommand( m_autoFooter, m_sName );
UtilOffCommand( m_textHelp, m_sName );
m_Background.PlayCommand("Off");
2003-07-10 03:37:13 +00:00
m_Out.StartTransitioning(smSendWhenDone);
/* Ack. If the transition finishes transparent (eg. _options to options),
* then we don't want to send the message until all of the *actors* are
* done tweening. However, if it finishes with something onscreen (most
* of the rest), we have to send the message immediately after it finishes,
* or we'll draw a frame without the transition.
*
* For now, I'll make the SMMAX2 option tweening faster. */
/* This includes all of the actors: */
// float TimeUntilFinished = GetTweenTimeLeft();
// TimeUntilFinished = max(TimeUntilFinished, m_Out.GetLengthSeconds());
// SCREENMAN->PostMessageToTopScreen( smSendWhenDone, TimeUntilFinished );
}
void ScreenWithMenuElements::Back( ScreenMessage smSendWhenDone )
2002-09-04 22:56:19 +00:00
{
2003-03-11 08:52:45 +00:00
if( m_Back.IsTransitioning() )
return; // ignore
2003-11-07 20:10:38 +00:00
m_MenuTimer->Stop();
2003-03-09 00:55:49 +00:00
m_Back.StartTransitioning( smSendWhenDone );
SCREENMAN->PlayBackSound();
}
bool ScreenWithMenuElements::IsTransitioning()
2002-08-20 21:00:56 +00:00
{
2003-03-09 00:55:49 +00:00
return m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Back.IsTransitioning();
}
2003-11-07 20:10:38 +00:00
void ScreenWithMenuElements::StopTimer()
2003-11-07 20:10:38 +00:00
{
m_MenuTimer->Stop();
}
2004-06-08 05:22:33 +00:00
/*
* (c) 2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/