Rewrite ScreenMusicScroll as a ScreenAttract. Fixed start button and
a memory leak.
This commit is contained in:
@@ -5,21 +5,16 @@
|
|||||||
|
|
||||||
Desc: See header.
|
Desc: See header.
|
||||||
|
|
||||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
||||||
Chris Danford
|
Chris Danford
|
||||||
|
Glenn Maynard
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ScreenMusicScroll.h"
|
#include "ScreenMusicScroll.h"
|
||||||
#include "ScreenManager.h"
|
|
||||||
#include "PrefsManager.h"
|
|
||||||
#include "GameManager.h"
|
|
||||||
#include "RageLog.h"
|
|
||||||
#include "GameConstantsAndTypes.h"
|
|
||||||
#include "SongManager.h"
|
#include "SongManager.h"
|
||||||
#include "RageSounds.h"
|
#include "RageSounds.h"
|
||||||
#include "GameState.h"
|
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "AnnouncerManager.h"
|
#include "AnnouncerManager.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
@@ -28,7 +23,6 @@
|
|||||||
#define SCROLL_DELAY THEME->GetMetricF("ScreenMusicScroll","ScrollDelay")
|
#define SCROLL_DELAY THEME->GetMetricF("ScreenMusicScroll","ScrollDelay")
|
||||||
#define SCROLL_SPEED THEME->GetMetricF("ScreenMusicScroll","ScrollSpeed")
|
#define SCROLL_SPEED THEME->GetMetricF("ScreenMusicScroll","ScrollSpeed")
|
||||||
#define TEXT_ZOOM THEME->GetMetricF("ScreenMusicScroll","TextZoom")
|
#define TEXT_ZOOM THEME->GetMetricF("ScreenMusicScroll","TextZoom")
|
||||||
#define NEXT_SCREEN THEME->GetMetric("ScreenMusicScroll","NextScreen")
|
|
||||||
|
|
||||||
|
|
||||||
const CString CREDIT_LINES[] =
|
const CString CREDIT_LINES[] =
|
||||||
@@ -38,22 +32,13 @@ const CString CREDIT_LINES[] =
|
|||||||
const unsigned NUM_CREDIT_LINES = sizeof(CREDIT_LINES) / sizeof(CString);
|
const unsigned NUM_CREDIT_LINES = sizeof(CREDIT_LINES) / sizeof(CString);
|
||||||
|
|
||||||
|
|
||||||
ScreenMusicScroll::ScreenMusicScroll( CString sClassName ) : Screen( sClassName )
|
ScreenMusicScroll::ScreenMusicScroll( CString sClassName ) : ScreenAttract( sClassName )
|
||||||
{
|
{
|
||||||
LOG->Trace( "ScreenMusicScroll::ScreenMusicScroll()" );
|
|
||||||
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
GAMESTATE->Reset(); // so that credits message for both players will show
|
|
||||||
|
|
||||||
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenMusicScroll background") );
|
|
||||||
this->AddChild( &m_Background );
|
|
||||||
|
|
||||||
|
|
||||||
vector<Song*> arraySongs;
|
vector<Song*> arraySongs;
|
||||||
SONGMAN->GetSongs( arraySongs );
|
SONGMAN->GetSongs( arraySongs );
|
||||||
SortSongPointerArrayByTitle( arraySongs );
|
SortSongPointerArrayByTitle( arraySongs );
|
||||||
|
|
||||||
|
unsigned i;
|
||||||
for( i=0; i < arraySongs.size(); i++ )
|
for( i=0; i < arraySongs.size(); i++ )
|
||||||
{
|
{
|
||||||
BitmapText *bt = new BitmapText;
|
BitmapText *bt = new BitmapText;
|
||||||
@@ -64,6 +49,8 @@ ScreenMusicScroll::ScreenMusicScroll( CString sClassName ) : Screen( sClassName
|
|||||||
bt->SetText( pSong->GetFullDisplayTitle(), pSong->GetFullTranslitTitle() );
|
bt->SetText( pSong->GetFullDisplayTitle(), pSong->GetFullTranslitTitle() );
|
||||||
bt->SetDiffuse( SONGMAN->GetSongColor(pSong) );
|
bt->SetDiffuse( SONGMAN->GetSongColor(pSong) );
|
||||||
bt->SetZoom( TEXT_ZOOM );
|
bt->SetZoom( TEXT_ZOOM );
|
||||||
|
|
||||||
|
this->AddChild( bt );
|
||||||
}
|
}
|
||||||
|
|
||||||
// for( i=0; i<min(NUM_CREDIT_LINES, MAX_CREDIT_LINES); i++ )
|
// for( i=0; i<min(NUM_CREDIT_LINES, MAX_CREDIT_LINES); i++ )
|
||||||
@@ -83,81 +70,39 @@ ScreenMusicScroll::ScreenMusicScroll( CString sClassName ) : Screen( sClassName
|
|||||||
m_textLines[i]->SetXY( CENTER_X, SCREEN_TOP - 40 );
|
m_textLines[i]->SetXY( CENTER_X, SCREEN_TOP - 40 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->MoveToTail( &m_In ); // put it in the back so it covers up the stuff we just added
|
||||||
|
this->MoveToTail( &m_Out ); // put it in the back so it covers up the stuff we just added
|
||||||
|
|
||||||
|
this->ClearMessageQueue( SM_BeginFadingOut ); // ignore ScreenAttract's SecsToShow
|
||||||
this->PostScreenMessage( SM_BeginFadingOut, 0.2f * i + 3.0f );
|
this->PostScreenMessage( SM_BeginFadingOut, 0.2f * i + 3.0f );
|
||||||
|
|
||||||
m_In.Load( THEME->GetPathToB("ScreenMusicScroll in") );
|
|
||||||
// this->AddChild( &m_In ); // draw and update manually
|
|
||||||
m_In.StartTransitioning();
|
|
||||||
|
|
||||||
m_Out.Load( THEME->GetPathToB("ScreenMusicScroll out") );
|
|
||||||
// this->AddChild( &m_Out ); // draw and update manually
|
|
||||||
|
|
||||||
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("music scroll") );
|
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("music scroll") );
|
||||||
|
|
||||||
SOUND->PlayMusic( THEME->GetPathToS("ScreenMusicScroll music") );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenMusicScroll::~ScreenMusicScroll()
|
||||||
|
{
|
||||||
|
for( unsigned i=0; i<m_textLines.size(); i++ )
|
||||||
|
delete m_textLines[i];
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenMusicScroll::Update( float fDeltaTime )
|
void ScreenMusicScroll::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<m_textLines.size(); i++ )
|
ScreenAttract::Update( fDeltaTime );
|
||||||
m_textLines[i]->Update( fDeltaTime );
|
|
||||||
|
|
||||||
m_In.Update( fDeltaTime );
|
|
||||||
m_Out.Update( fDeltaTime );
|
|
||||||
|
|
||||||
Screen::Update( fDeltaTime );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ScreenMusicScroll::DrawPrimitives()
|
|
||||||
{
|
|
||||||
Screen::DrawPrimitives();
|
|
||||||
|
|
||||||
for( unsigned i=0; i<m_textLines.size(); i++ )
|
for( unsigned i=0; i<m_textLines.size(); i++ )
|
||||||
{
|
{
|
||||||
if( m_textLines[i]->GetY() > SCREEN_TOP-20 &&
|
const bool shown = ( m_textLines[i]->GetY() > SCREEN_TOP-20 &&
|
||||||
m_textLines[i]->GetY() < SCREEN_BOTTOM+20 )
|
m_textLines[i]->GetY() < SCREEN_BOTTOM+20 );
|
||||||
m_textLines[i]->Draw();
|
m_textLines[i]->SetHidden( !shown );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_In.Draw(); // render it again so it shows over the text
|
|
||||||
m_Out.Draw(); // render it again so it shows over the text
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ScreenMusicScroll::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
||||||
{
|
|
||||||
// LOG->Trace( "ScreenMusicScroll::Input()" );
|
|
||||||
|
|
||||||
if( m_In.IsTransitioning() || m_Out.IsTransitioning() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default input handler
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenMusicScroll::HandleScreenMessage( const ScreenMessage SM )
|
void ScreenMusicScroll::HandleScreenMessage( const ScreenMessage SM )
|
||||||
{
|
{
|
||||||
switch( SM )
|
/* XXX: is this needed anymore? */
|
||||||
{
|
if( SM == SM_GoToNextScreen )
|
||||||
case SM_BeginFadingOut:
|
|
||||||
if( !m_Out.IsTransitioning() )
|
|
||||||
m_Out.StartTransitioning( SM_GoToNextScreen );
|
|
||||||
break;
|
|
||||||
case SM_GoToNextScreen:
|
|
||||||
SONGMAN->SaveMachineScoresToDisk();
|
SONGMAN->SaveMachineScoresToDisk();
|
||||||
SCREENMAN->SetNewScreen( NEXT_SCREEN );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenMusicScroll::MenuStart( PlayerNumber pn )
|
ScreenAttract::HandleScreenMessage( SM );
|
||||||
{
|
|
||||||
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenMusicScroll::MenuBack( PlayerNumber pn )
|
|
||||||
{
|
|
||||||
this->PostScreenMessage( SM_BeginFadingOut, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,44 +4,27 @@
|
|||||||
|
|
||||||
Desc: Music plays and song names scroll across the screen.
|
Desc: Music plays and song names scroll across the screen.
|
||||||
|
|
||||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
Copyright (c) 2001-2003 by the person(s) listed below. All rights reserved.
|
||||||
Chris Danford
|
Chris Danford
|
||||||
|
Glenn Maynard
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Screen.h"
|
|
||||||
#include "Sprite.h"
|
|
||||||
#include "Transition.h"
|
|
||||||
#include "MenuElements.h"
|
|
||||||
#include "BitmapText.h"
|
#include "BitmapText.h"
|
||||||
|
#include "ScreenAttract.h"
|
||||||
|
|
||||||
//const unsigned MAX_MUSIC_LINES = 1200;
|
class ScreenMusicScroll : public ScreenAttract
|
||||||
//const unsigned MAX_CREDIT_LINES = 100;
|
|
||||||
//const unsigned MAX_TOTAL_LINES = MAX_MUSIC_LINES;// + MAX_CREDIT_LINES;
|
|
||||||
|
|
||||||
|
|
||||||
class ScreenMusicScroll : public Screen
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScreenMusicScroll( CString sName );
|
ScreenMusicScroll( CString sName );
|
||||||
|
virtual ~ScreenMusicScroll();
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void Update( float fDeltaTime );
|
||||||
virtual void DrawPrimitives();
|
|
||||||
|
|
||||||
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
|
|
||||||
virtual void HandleScreenMessage( const ScreenMessage SM );
|
virtual void HandleScreenMessage( const ScreenMessage SM );
|
||||||
|
|
||||||
void MenuStart( PlayerNumber pn );
|
|
||||||
void MenuBack( PlayerNumber pn );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
BGAnimation m_Background;
|
|
||||||
vector<BitmapText *> m_textLines;
|
vector<BitmapText *> m_textLines;
|
||||||
float m_fTimeLeftInScreen;
|
|
||||||
|
|
||||||
Transition m_In;
|
|
||||||
Transition m_Out;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user