Cleanup of theme element names
Renamed ScreenSelectMax* back to their old names Replaced all hard-coded transitions with TransitionBGAnimations
This commit is contained in:
+81
-240
@@ -24,263 +24,120 @@
|
||||
#include "ThemeManager.h"
|
||||
|
||||
|
||||
#define TOP_EDGE_X THEME->GetMetricF("MenuElements","TopEdgeX")
|
||||
#define TOP_EDGE_Y THEME->GetMetricF("MenuElements","TopEdgeY")
|
||||
#define BOTTOM_EDGE_X THEME->GetMetricF("MenuElements","BottomEdgeX")
|
||||
#define BOTTOM_EDGE_Y THEME->GetMetricF("MenuElements","BottomEdgeY")
|
||||
#define STYLE_ICON_X THEME->GetMetricF("MenuElements","StyleIconX")
|
||||
#define STYLE_ICON_Y THEME->GetMetricF("MenuElements","StyleIconY")
|
||||
#define TIMER_X THEME->GetMetricF("MenuElements","TimerX")
|
||||
#define TIMER_Y THEME->GetMetricF("MenuElements","TimerY")
|
||||
#define HELP_X THEME->GetMetricF("MenuElements","HelpX")
|
||||
#define HELP_Y THEME->GetMetricF("MenuElements","HelpY")
|
||||
#define HEADER_ON_COMMAND THEME->GetMetric("MenuElements","HeaderOnCommand")
|
||||
#define HEADER_OFF_COMMAND THEME->GetMetric("MenuElements","HeaderOffCommand")
|
||||
#define FOOTER_ON_COMMAND THEME->GetMetric("MenuElements","FooterOnCommand")
|
||||
#define FOOTER_OFF_COMMAND THEME->GetMetric("MenuElements","FooterOffCommand")
|
||||
#define STYLE_ICON_ON_COMMAND THEME->GetMetric("MenuElements","StyleIconOnCommand")
|
||||
#define STYLE_ICON_OFF_COMMAND THEME->GetMetric("MenuElements","StyleIconOffCommand")
|
||||
#define TIMER_ON_COMMAND THEME->GetMetric("MenuElements","TimerOnCommand")
|
||||
#define TIMER_OFF_COMMAND THEME->GetMetric("MenuElements","TimerOffCommand")
|
||||
#define HELP_ON_COMMAND THEME->GetMetric("MenuElements","HelpOnCommand")
|
||||
#define HELP_OFF_COMMAND THEME->GetMetric("MenuElements","HelpOffCommand")
|
||||
|
||||
|
||||
MenuElements::MenuElements()
|
||||
{
|
||||
this->AddChild( &m_sprTopEdge );
|
||||
this->AddChild( &m_sprStyleIcon );
|
||||
this->AddChild( &m_MenuTimer );
|
||||
this->AddChild( &m_sprBottomEdge );
|
||||
this->AddChild( &m_Background );
|
||||
this->AddChild( &m_quadBrightness );
|
||||
this->AddChild( &m_textHelp );
|
||||
|
||||
m_KeepAlive.SetOpened();
|
||||
this->AddChild( &m_KeepAlive );
|
||||
|
||||
m_Wipe.SetOpened();
|
||||
this->AddChild( &m_Wipe );
|
||||
|
||||
this->AddChild( &m_Invisible );
|
||||
}
|
||||
|
||||
void MenuElements::StealthTimer( int iActive )
|
||||
{
|
||||
|
||||
m_MenuTimer.StealthTimer( iActive ); // go a bit deeper... get rid of the sound...
|
||||
|
||||
if (iActive == 0) // if we wanna hide the timer...
|
||||
if (iActive == 0) // leave it on screen
|
||||
{
|
||||
m_MenuTimer.SetXY( TIMER_X, TIMER_Y ); // set it off-screen
|
||||
// m_MenuTimer.SetXY( MENU_TIMER_X, MENU_TIMER_Y ); // set it on-screen
|
||||
}
|
||||
else if (iActive == 1) // we wanna hide the timer
|
||||
else if (iActive == 1) // hide the timer
|
||||
{
|
||||
m_MenuTimer.SetXY( 999.0f, 999.0f ); // otherwise position it off-screen
|
||||
// otherwise position it off-screen
|
||||
m_MenuTimer.StopTweening();
|
||||
m_MenuTimer.SetXY( 1000, 1000 );
|
||||
}
|
||||
// else... take no action :)
|
||||
}
|
||||
|
||||
void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString sHelpText, bool bShowStyleIcon, bool bTimerEnabled, int iTimerSeconds )
|
||||
void MenuElements::Load( CString sClassName, bool bEnableTimer, bool bLoadStyleIcon )
|
||||
{
|
||||
LOG->Trace( "MenuElements::MenuElements()" );
|
||||
|
||||
ASSERT( this->m_SubActors.empty() ); // don't call Load twice!
|
||||
|
||||
if( sBackgroundPath != "" )
|
||||
m_Background.LoadFromAniDir( sBackgroundPath );
|
||||
m_sClassName = sClassName;
|
||||
|
||||
m_quadBrightness.SetDiffuse( RageColor(0,0,0,0) );
|
||||
m_quadBrightness.StretchTo( RectI(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) );
|
||||
m_Background.LoadFromAniDir( THEME->GetPathTo("BGAnimations",m_sClassName+" background") );
|
||||
this->AddChild( &m_Background );
|
||||
|
||||
m_sprTopEdge.Load( sTopEdgePath );
|
||||
m_sprTopEdge.SetXY( TOP_EDGE_X, TOP_EDGE_Y );
|
||||
|
||||
m_sprStyleIcon.Load( THEME->GetPathTo("Graphics",ssprintf("menu style icons %s",GAMESTATE->GetCurrentGameDef()->m_szName)) );
|
||||
m_sprStyleIcon.StopAnimating();
|
||||
m_sprStyleIcon.SetXY( STYLE_ICON_X, STYLE_ICON_Y );
|
||||
if( GAMESTATE->m_CurStyle == STYLE_INVALID || !bShowStyleIcon )
|
||||
m_sprStyleIcon.SetDiffuse( RageColor(1,1,1,0) );
|
||||
else
|
||||
m_sprHeader.Load( THEME->GetPathTo("Graphics",m_sClassName+" header") );
|
||||
m_sprHeader.Command( HEADER_ON_COMMAND );
|
||||
this->AddChild( &m_sprHeader );
|
||||
|
||||
if( bLoadStyleIcon && GAMESTATE->m_CurStyle != STYLE_INVALID )
|
||||
{
|
||||
int iRowNum = GetStyleIndexRelativeToGame( GAMESTATE->m_CurGame, GAMESTATE->m_CurStyle );
|
||||
m_sprStyleIcon.SetState( iRowNum*2+GAMESTATE->m_MasterPlayerNumber );
|
||||
CString sIconFileName = ssprintf("MenuElements icon %s", GAMESTATE->GetCurrentStyleDef()->m_szName );
|
||||
m_sprStyleIcon.Load( THEME->GetPathTo("Graphics",sIconFileName) );
|
||||
m_sprStyleIcon.StopAnimating();
|
||||
m_sprStyleIcon.Command( STYLE_ICON_ON_COMMAND );
|
||||
this->AddChild( &m_sprStyleIcon );
|
||||
}
|
||||
|
||||
m_MenuTimer.SetXY( TIMER_X, TIMER_Y );
|
||||
if( !bTimerEnabled || !PREFSMAN->m_bMenuTimer || GAMESTATE->m_bEditing )
|
||||
|
||||
m_MenuTimer.Command( TIMER_ON_COMMAND );
|
||||
if( bEnableTimer && PREFSMAN->m_bMenuTimer && !GAMESTATE->m_bEditing )
|
||||
{
|
||||
m_MenuTimer.SetTimer( THEME->GetMetricI(m_sClassName,"TimerSeconds") );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MenuTimer.SetTimer( 99 );
|
||||
m_MenuTimer.Update( 0 );
|
||||
m_MenuTimer.StopTimer();
|
||||
}
|
||||
else
|
||||
m_MenuTimer.SetTimer( iTimerSeconds );
|
||||
this->AddChild( &m_MenuTimer );
|
||||
|
||||
m_sprBottomEdge.Load( THEME->GetPathTo("Graphics","menu bottom edge") );
|
||||
m_sprBottomEdge.SetXY( BOTTOM_EDGE_X, BOTTOM_EDGE_Y );
|
||||
m_sprFooter.Load( THEME->GetPathTo("Graphics",m_sClassName+" footer") );
|
||||
m_sprFooter.Command( FOOTER_ON_COMMAND );
|
||||
this->AddChild( &m_sprFooter );
|
||||
|
||||
m_textHelp.SetXY( HELP_X, HELP_Y );
|
||||
m_textHelp.Command( HELP_ON_COMMAND );
|
||||
CStringArray asHelpTips;
|
||||
split( sHelpText, "\n", asHelpTips );
|
||||
split( THEME->GetMetric(m_sClassName,"HelpText"), "\n", asHelpTips );
|
||||
m_textHelp.SetTips( asHelpTips );
|
||||
m_textHelp.SetZoom( 0.5f );
|
||||
this->AddChild( &m_textHelp );
|
||||
|
||||
|
||||
m_soundSwoosh.Load( THEME->GetPathTo("Sounds","menu swoosh") );
|
||||
m_soundBack.Load( THEME->GetPathTo("Sounds","menu back") );
|
||||
m_In.Load( THEME->GetPathTo("BGAnimations",m_sClassName+" in") );
|
||||
this->AddChild( &m_In );
|
||||
|
||||
m_Out.Load( THEME->GetPathTo("BGAnimations",m_sClassName+" out") );
|
||||
this->AddChild( &m_Out );
|
||||
|
||||
m_Back.Load( THEME->GetPathTo("BGAnimations","Common back") );
|
||||
this->AddChild( &m_Back );
|
||||
|
||||
|
||||
m_soundBack.Load( THEME->GetPathTo("Sounds","Common back") );
|
||||
|
||||
|
||||
m_In.StartTransitioning( SM_None );
|
||||
}
|
||||
|
||||
void MenuElements::TweenTopLayerOnScreen(float tm)
|
||||
{
|
||||
if(tm == -1)
|
||||
tm = MENU_ELEMENTS_TWEEN_TIME;
|
||||
|
||||
vector<Actor*> apActorsInTopFrame;
|
||||
apActorsInTopFrame.push_back( &m_sprTopEdge );
|
||||
apActorsInTopFrame.push_back( &m_sprStyleIcon );
|
||||
apActorsInTopFrame.push_back( &m_MenuTimer );
|
||||
for( unsigned i=0; i<apActorsInTopFrame.size(); i++ )
|
||||
{
|
||||
float fOriginalX = apActorsInTopFrame[i]->GetX();
|
||||
apActorsInTopFrame[i]->SetX( fOriginalX+SCREEN_WIDTH );
|
||||
apActorsInTopFrame[i]->BeginTweening( tm, TWEEN_SPRING );
|
||||
apActorsInTopFrame[i]->SetTweenX( fOriginalX );
|
||||
}
|
||||
|
||||
float fOriginalZoom = m_textHelp.GetZoomY();
|
||||
m_textHelp.SetZoomY( 0 );
|
||||
m_textHelp.BeginTweening( tm/2 );
|
||||
m_textHelp.SetTweenZoomY( fOriginalZoom );
|
||||
}
|
||||
|
||||
void MenuElements::TweenOnScreenFromMenu( ScreenMessage smSendWhenDone, bool bLeaveKeepAliveOn )
|
||||
{
|
||||
TweenTopLayerOnScreen();
|
||||
if( !bLeaveKeepAliveOn )
|
||||
m_KeepAlive.OpenWipingRight( smSendWhenDone );
|
||||
else
|
||||
m_KeepAlive.SetClosed();
|
||||
m_soundSwoosh.Play();
|
||||
}
|
||||
|
||||
void MenuElements::TweenTopLayerOffScreen(float tm)
|
||||
{
|
||||
/*
|
||||
This trick is neat, but there's a problem: fOriginalX may not be the settled
|
||||
position--we might still be tweening, and if it's a bounce tween, it might be
|
||||
left of center, which means fOriginalX+SCREEN_WIDTH won't actually take it
|
||||
completely off-screen. fOriginalX+SCREEN_WIDTH*2 would, but that'd make the
|
||||
bounce faster. SCREEN_WIDTH+SCREEN_WIDTH/2 would, but ignoring fOriginalX
|
||||
will make each component tween off at a different rate ...
|
||||
-glenn
|
||||
vector<Actor*> apActorsInTopFrame;
|
||||
apActorsInTopFrame.push_back( &m_sprTopEdge );
|
||||
apActorsInTopFrame.push_back( &m_sprStyleIcon );
|
||||
apActorsInTopFrame.push_back( &m_MenuTimer );
|
||||
for( unsigned i=0; i<apActorsInTopFrame.size(); i++ )
|
||||
{
|
||||
float fOriginalX = apActorsInTopFrame[i]->GetX();
|
||||
apActorsInTopFrame[i]->BeginTweening( MENU_ELEMENTS_TWEEN_TIME, TWEEN_BOUNCE_BEGIN );
|
||||
apActorsInTopFrame[i]->SetTweenX( fOriginalX+SCREEN_WIDTH );
|
||||
}
|
||||
*/
|
||||
|
||||
if(tm == -1)
|
||||
tm = MENU_ELEMENTS_TWEEN_TIME;
|
||||
|
||||
m_sprTopEdge.StopTweening();
|
||||
m_sprTopEdge.BeginTweening( tm, TWEEN_BOUNCE_BEGIN );
|
||||
m_sprTopEdge.SetTweenX( TOP_EDGE_X+SCREEN_WIDTH );
|
||||
|
||||
m_sprStyleIcon.StopTweening();
|
||||
m_sprStyleIcon.BeginTweening( tm, TWEEN_BOUNCE_BEGIN );
|
||||
m_sprStyleIcon.SetTweenX( STYLE_ICON_X+SCREEN_WIDTH );
|
||||
|
||||
m_MenuTimer.StopTweening();
|
||||
m_MenuTimer.BeginTweening( tm, TWEEN_BOUNCE_BEGIN );
|
||||
m_MenuTimer.SetTweenX( TIMER_X+SCREEN_WIDTH );
|
||||
|
||||
m_textHelp.StopTweening();
|
||||
m_textHelp.BeginTweening( tm/2 );
|
||||
m_textHelp.SetTweenZoomY( 0 );
|
||||
}
|
||||
|
||||
void MenuElements::TweenOffScreenToMenu( ScreenMessage smSendWhenDone )
|
||||
{
|
||||
m_MenuTimer.StopTimer();
|
||||
TweenTopLayerOffScreen();
|
||||
if( !m_KeepAlive.IsClosed() )
|
||||
m_KeepAlive.CloseWipingRight( smSendWhenDone );
|
||||
else
|
||||
SCREENMAN->SendMessageToTopScreen( smSendWhenDone, m_KeepAlive.GetTransitionTime() );
|
||||
m_soundSwoosh.Play();
|
||||
}
|
||||
|
||||
void MenuElements::ImmedOnScreenFromMenu( bool bLeaveKeepAliveOn )
|
||||
{
|
||||
TweenTopLayerOnScreen(0);
|
||||
Update(0);
|
||||
|
||||
if( !bLeaveKeepAliveOn )
|
||||
m_KeepAlive.SetOpened();
|
||||
else
|
||||
m_KeepAlive.SetClosed();
|
||||
}
|
||||
|
||||
void MenuElements::ImmedOffScreenToMenu()
|
||||
{
|
||||
m_MenuTimer.StopTimer();
|
||||
m_KeepAlive.SetClosed();
|
||||
|
||||
/* Remove the top layer immediately. */
|
||||
TweenTopLayerOffScreen(0);
|
||||
|
||||
/* We need to do a null update after doing null tweens (tweens with zero time),
|
||||
* or they'll show up in their default positions for a frame (since screens
|
||||
* draw once before they're updated for the first time). */
|
||||
Update(0);
|
||||
}
|
||||
|
||||
void MenuElements::TweenBottomLayerOnScreen()
|
||||
{
|
||||
float fOriginalY = m_sprBottomEdge.GetY();
|
||||
m_sprBottomEdge.SetY( fOriginalY + 100 );
|
||||
m_sprBottomEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
|
||||
m_sprBottomEdge.SetTweenY( fOriginalY );
|
||||
|
||||
m_quadBrightness.SetDiffuse( RageColor(0,0,0,1) );
|
||||
m_quadBrightness.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
|
||||
m_quadBrightness.SetTweenDiffuse( RageColor(0,0,0,0) );
|
||||
}
|
||||
|
||||
void MenuElements::TweenBottomLayerOffScreen()
|
||||
{
|
||||
float fOriginalY = m_sprBottomEdge.GetY();
|
||||
m_sprBottomEdge.StopTweening();
|
||||
m_sprBottomEdge.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
|
||||
m_sprBottomEdge.SetTweenY( fOriginalY + 100 );
|
||||
|
||||
m_quadBrightness.SetDiffuse( RageColor(0,0,0,0) );
|
||||
m_quadBrightness.StopTweening();
|
||||
m_quadBrightness.BeginTweening( MENU_ELEMENTS_TWEEN_TIME*3/2.0f ); // sleep
|
||||
m_quadBrightness.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 ); // fade
|
||||
m_quadBrightness.SetTweenDiffuse( RageColor(0,0,0,1) );
|
||||
}
|
||||
|
||||
void MenuElements::TweenOnScreenFromBlack( ScreenMessage smSendWhenDone )
|
||||
{
|
||||
TweenTopLayerOnScreen();
|
||||
TweenBottomLayerOnScreen();
|
||||
//m_Wipe.OpenWipingRight( smSendWhenDone );
|
||||
m_soundSwoosh.Play();
|
||||
}
|
||||
|
||||
void MenuElements::TweenOffScreenToBlack( ScreenMessage smSendWhenDone, bool bPlayBackSound )
|
||||
void MenuElements::StartTransitioning( ScreenMessage smSendWhenDone )
|
||||
{
|
||||
m_MenuTimer.SetTimer( 0 );
|
||||
m_MenuTimer.StopTimer();
|
||||
|
||||
if( !bPlayBackSound )
|
||||
{
|
||||
TweenTopLayerOffScreen();
|
||||
TweenBottomLayerOffScreen();
|
||||
m_Invisible.SetTransitionTime( MENU_ELEMENTS_TWEEN_TIME*2 );
|
||||
m_Invisible.CloseWipingRight( smSendWhenDone );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_soundBack.Play();
|
||||
m_Wipe.CloseWipingLeft( smSendWhenDone );
|
||||
}
|
||||
m_sprHeader.Command( HEADER_OFF_COMMAND );
|
||||
m_sprStyleIcon.Command( STYLE_ICON_OFF_COMMAND );
|
||||
m_MenuTimer.Command( TIMER_OFF_COMMAND );
|
||||
m_sprFooter.Command( FOOTER_OFF_COMMAND );
|
||||
m_textHelp.Command( HELP_OFF_COMMAND );
|
||||
|
||||
m_Out.StartTransitioning( smSendWhenDone );
|
||||
}
|
||||
|
||||
void MenuElements::Back( ScreenMessage smSendWhenDone )
|
||||
{
|
||||
m_Back.StartTransitioning( smSendWhenDone );
|
||||
m_soundBack.Play();
|
||||
}
|
||||
|
||||
void MenuElements::DrawPrimitives()
|
||||
@@ -292,13 +149,14 @@ void MenuElements::DrawTopLayer()
|
||||
{
|
||||
BeginDraw();
|
||||
|
||||
m_sprTopEdge.Draw();
|
||||
m_sprHeader.Draw();
|
||||
m_sprStyleIcon.Draw();
|
||||
m_MenuTimer.Draw();
|
||||
m_sprBottomEdge.Draw();
|
||||
m_sprFooter.Draw();
|
||||
m_textHelp.Draw();
|
||||
m_KeepAlive.Draw();
|
||||
m_Wipe.Draw();
|
||||
m_In.Draw();
|
||||
m_Out.Draw();
|
||||
m_Back.Draw();
|
||||
|
||||
EndDraw();
|
||||
}
|
||||
@@ -308,28 +166,11 @@ void MenuElements::DrawBottomLayer()
|
||||
BeginDraw();
|
||||
|
||||
m_Background.Draw();
|
||||
m_quadBrightness.Draw();
|
||||
|
||||
EndDraw();
|
||||
}
|
||||
|
||||
void MenuElements::SetTimer( int iTimerSeconds )
|
||||
bool MenuElements::IsTransitioning()
|
||||
{
|
||||
m_MenuTimer.SetTimer( iTimerSeconds );
|
||||
return m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Back.IsTransitioning();
|
||||
}
|
||||
|
||||
void MenuElements::StartTimer()
|
||||
{
|
||||
m_MenuTimer.StartTimer();
|
||||
}
|
||||
|
||||
void MenuElements::StopTimer()
|
||||
{
|
||||
m_MenuTimer.StopTimer();
|
||||
}
|
||||
|
||||
void MenuElements::StallTimer()
|
||||
{
|
||||
m_MenuTimer.StallTimer();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user