Files
itgmania212121/stepmania/src/MenuElements.cpp
T

231 lines
6.0 KiB
C++
Raw Normal View History

#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: MenuElements.h
2002-05-19 01:59:48 +00:00
Desc: Base class for menu Screens.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "MenuElements.h"
#include "RageTextureManager.h"
#include "RageUtil.h"
#include "RageMusic.h"
2002-05-19 01:59:48 +00:00
#include "ScreenManager.h"
#include "ScreenGameplay.h"
2002-05-01 19:14:55 +00:00
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-05-01 19:14:55 +00:00
#include "RageLog.h"
2002-05-28 20:01:22 +00:00
#include "RageLog.h"
#include "GameManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
const float HELP_X = CENTER_X;
2002-05-28 20:01:22 +00:00
const float HELP_Y = SCREEN_BOTTOM-28;
2002-05-27 08:23:27 +00:00
2002-05-28 20:01:22 +00:00
const float STYLE_ICON_LOCAL_X = 130;
const float STYLE_ICON_LOCAL_Y = 6;
2002-05-27 18:36:01 +00:00
2002-05-27 08:23:27 +00:00
const float TIMER_LOCAL_X = 270;
const float TIMER_LOCAL_Y = 0;
2002-05-27 18:36:01 +00:00
MenuElements::MenuElements()
{
2002-07-23 01:41:40 +00:00
m_frameTopBar.AddSubActor( &m_sprTopEdge );
m_frameTopBar.AddSubActor( &m_sprStyleIcon );
m_frameTopBar.AddSubActor( &m_MenuTimer );
2002-05-27 08:23:27 +00:00
2002-07-23 01:41:40 +00:00
m_frameBottomBar.AddSubActor( &m_sprBottomEdge );
2002-05-27 08:23:27 +00:00
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_sprBG );
this->AddSubActor( &m_frameTopBar );
this->AddSubActor( &m_frameBottomBar );
this->AddSubActor( &m_textHelp );
2002-05-28 20:01:22 +00:00
m_KeepAlive.SetZ( -2 );
m_KeepAlive.SetOpened();
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_KeepAlive );
2002-05-28 20:01:22 +00:00
m_Wipe.SetZ( -2 );
m_Wipe.SetOpened();
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_Wipe );
2002-06-27 17:49:10 +00:00
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_Invisible );
}
2002-07-11 19:02:26 +00:00
void MenuElements::Load( CString sBackgroundPath, CString sTopEdgePath, CString sHelpText, bool bShowStyleIcon, bool bTimerEnabled, int iTimerSeconds )
{
LOG->Trace( "MenuElements::MenuElements()" );
m_sprBG.Load( sBackgroundPath );
m_sprBG.StretchTo( CRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT) );
m_sprBG.TurnShadowOff();
2002-05-27 08:23:27 +00:00
m_frameTopBar.SetZ( -1 );
m_sprTopEdge.Load( sTopEdgePath );
m_sprTopEdge.TurnShadowOff();
2002-05-27 18:36:01 +00:00
m_sprStyleIcon.Load( THEME->GetPathTo("Graphics","menu style icons") );
2002-05-27 18:36:01 +00:00
m_sprStyleIcon.StopAnimating();
2002-05-28 20:01:22 +00:00
m_sprStyleIcon.SetXY( STYLE_ICON_LOCAL_X, STYLE_ICON_LOCAL_Y );
2002-05-27 18:36:01 +00:00
m_sprStyleIcon.SetZ( -1 );
2002-07-23 01:41:40 +00:00
if( GAMESTATE->m_CurStyle == STYLE_NONE || !bShowStyleIcon )
2002-05-28 20:01:22 +00:00
m_sprStyleIcon.SetDiffuseColor( D3DXCOLOR(1,1,1,0) );
else
2002-07-23 01:41:40 +00:00
m_sprStyleIcon.SetState( GAMESTATE->m_CurStyle );
2002-05-27 08:23:27 +00:00
m_MenuTimer.SetXY( TIMER_LOCAL_X, TIMER_LOCAL_Y );
m_MenuTimer.SetZ( -1 );
2002-07-11 19:02:26 +00:00
if( !bTimerEnabled || !PREFSMAN->m_bMenuTimer )
{
m_MenuTimer.SetTimer( 99 );
2002-07-27 19:29:51 +00:00
m_MenuTimer.Update( 0 );
2002-07-11 19:02:26 +00:00
m_MenuTimer.StopTimer();
}
else
m_MenuTimer.SetTimer( iTimerSeconds );
2002-05-27 08:23:27 +00:00
m_frameBottomBar.SetZ( -1 );
m_sprBottomEdge.Load( THEME->GetPathTo("Graphics","menu bottom edge") );
m_sprBottomEdge.TurnShadowOff();
m_textHelp.SetXY( HELP_X, HELP_Y );
2002-07-23 01:41:40 +00:00
// m_textHelp.SetZ( -1 );
CStringArray asHelpTips;
split( sHelpText, "\n", asHelpTips );
m_textHelp.SetTips( asHelpTips );
//m_textHelp.SetText( sHelpText );
m_textHelp.SetZoom( 0.5f );
m_soundSwoosh.Load( THEME->GetPathTo("Sounds","menu swoosh") );
m_soundBack.Load( THEME->GetPathTo("Sounds","menu back") );
2002-05-28 20:01:22 +00:00
m_frameTopBar.SetXY( CENTER_X, m_sprTopEdge.GetZoomedHeight()/2 );
2002-05-28 20:01:22 +00:00
m_frameBottomBar.SetXY( CENTER_X, SCREEN_HEIGHT - m_sprBottomEdge.GetZoomedHeight()/2 );
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenTopLayerOnScreen()
{
m_frameTopBar.SetXY( CENTER_X+SCREEN_WIDTH, m_sprTopEdge.GetZoomedHeight()/2 );
2002-07-28 20:28:37 +00:00
m_frameTopBar.BeginTweening( MENU_ELEMENTS_TWEEN_TIME, TWEEN_SPRING );
2002-05-27 08:23:27 +00:00
m_frameTopBar.SetTweenX( CENTER_X );
2002-05-28 20:01:22 +00:00
float fOriginalZoom = m_textHelp.GetZoomY();
m_textHelp.SetZoomY( 0 );
2002-07-28 20:28:37 +00:00
m_textHelp.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
2002-05-28 20:01:22 +00:00
m_textHelp.SetTweenZoomY( fOriginalZoom );
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenOnScreenFromMenu( ScreenMessage smSendWhenDone )
{
TweenTopLayerOnScreen();
m_KeepAlive.OpenWipingRight( smSendWhenDone );
2002-05-19 01:59:48 +00:00
m_soundSwoosh.Play();
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenTopLayerOffScreen()
{
2002-07-28 20:28:37 +00:00
m_frameTopBar.BeginTweening( MENU_ELEMENTS_TWEEN_TIME, TWEEN_BIAS_END );
2002-05-27 08:23:27 +00:00
m_frameTopBar.SetTweenX( SCREEN_WIDTH*1.5f );
2002-04-16 17:31:00 +00:00
2002-07-28 20:28:37 +00:00
m_textHelp.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
m_textHelp.SetTweenZoomY( 0 );
2002-05-28 20:01:22 +00:00
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenOffScreenToMenu( ScreenMessage smSendWhenDone )
{
TweenTopLayerOffScreen();
m_KeepAlive.CloseWipingRight( smSendWhenDone );
2002-05-19 01:59:48 +00:00
m_soundSwoosh.Play();
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenBottomLayerOnScreen()
{
m_frameBottomBar.SetXY( CENTER_X, SCREEN_HEIGHT + m_sprBottomEdge.GetZoomedHeight()/2 );
2002-07-28 20:28:37 +00:00
m_frameBottomBar.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
2002-05-27 08:23:27 +00:00
m_frameBottomBar.SetTweenY( SCREEN_HEIGHT - m_sprBottomEdge.GetZoomedHeight()/2 );
m_sprBG.SetDiffuseColor( D3DXCOLOR(0,0,0,1) );
2002-07-28 20:28:37 +00:00
m_sprBG.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
m_sprBG.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,1) );
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenBottomLayerOffScreen()
{
2002-07-28 20:28:37 +00:00
m_frameBottomBar.BeginTweening( MENU_ELEMENTS_TWEEN_TIME/2 );
2002-05-27 08:23:27 +00:00
m_frameBottomBar.SetTweenY( SCREEN_HEIGHT + m_sprTopEdge.GetZoomedHeight() );
m_sprBG.SetDiffuseColor( D3DXCOLOR(1,1,1,1) );
2002-07-28 20:28:37 +00:00
m_sprBG.StopTweening();
m_sprBG.BeginTweeningQueued( MENU_ELEMENTS_TWEEN_TIME*3/2.0f ); // sleep
m_sprBG.BeginTweeningQueued( MENU_ELEMENTS_TWEEN_TIME/2 ); // fade
m_sprBG.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,1) );
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenOnScreenFromBlack( ScreenMessage smSendWhenDone )
{
2002-05-28 20:01:22 +00:00
TweenTopLayerOnScreen();
TweenBottomLayerOnScreen();
2002-05-29 09:47:24 +00:00
//m_Wipe.OpenWipingRight( smSendWhenDone );
2002-05-28 20:01:22 +00:00
m_soundSwoosh.Play();
}
2002-05-28 20:01:22 +00:00
void MenuElements::TweenOffScreenToBlack( ScreenMessage smSendWhenDone, bool bPlayBackSound )
{
2002-05-28 20:01:22 +00:00
if( !bPlayBackSound )
{
TweenTopLayerOffScreen();
TweenBottomLayerOffScreen();
2002-07-28 20:28:37 +00:00
m_Invisible.SetTransitionTime( MENU_ELEMENTS_TWEEN_TIME*2 );
2002-06-27 17:49:10 +00:00
m_Invisible.CloseWipingRight( smSendWhenDone );
2002-05-28 20:01:22 +00:00
}
2002-05-29 09:47:24 +00:00
else
{
2002-05-28 20:01:22 +00:00
m_soundBack.Play();
2002-05-29 09:47:24 +00:00
m_Wipe.CloseWipingLeft( smSendWhenDone );
}
}
2002-05-19 01:59:48 +00:00
void MenuElements::DrawPrimitives()
{
// do nothing. Call DrawBottomLayer() and DrawTopLayer() instead.
}
void MenuElements::DrawTopLayer()
{
2002-08-19 20:02:30 +00:00
BeginDraw();
2002-05-27 08:23:27 +00:00
m_frameTopBar.Draw();
m_frameBottomBar.Draw();
m_textHelp.Draw();
2002-05-28 20:01:22 +00:00
m_KeepAlive.Draw();
m_Wipe.Draw();
2002-08-19 20:02:30 +00:00
EndDraw();
}
void MenuElements::DrawBottomLayer()
{
2002-08-19 20:02:30 +00:00
BeginDraw();
m_sprBG.Draw();
2002-08-19 20:02:30 +00:00
EndDraw();
}
2002-07-11 19:02:26 +00:00
void MenuElements::StopTimer()
{
m_MenuTimer.StopTimer();
}