From 7db5d72fb61776a48cef9eecf4c030bff107381c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Wed, 9 Feb 2005 05:33:29 +0000 Subject: [PATCH] add experimental GenreDisplay --- stepmania/src/HelpDisplay.cpp | 87 +++++++++++++++++++++++++++++++---- stepmania/src/HelpDisplay.h | 17 +++++-- 2 files changed, 92 insertions(+), 12 deletions(-) diff --git a/stepmania/src/HelpDisplay.cpp b/stepmania/src/HelpDisplay.cpp index 7f6715ea37..de68287769 100644 --- a/stepmania/src/HelpDisplay.cpp +++ b/stepmania/src/HelpDisplay.cpp @@ -15,17 +15,21 @@ HelpDisplay::HelpDisplay() void HelpDisplay::Load() { - m_textTip.SetName( "Tip" ); - m_textTip.LoadFromFont( THEME->GetPathF(m_sName,"text") ); - ON_COMMAND( m_textTip ); - this->AddChild( &m_textTip ); + RunCommands( THEME->GetMetricA(m_sName,"TipOnCommand") ); + LoadFromFont( THEME->GetPathF(m_sName,"text") ); + m_fSecsUntilSwitch = TIP_SHOW_TIME; } +void HelpDisplay::LoadFromNode( const CString& sDir, const XNode* pNode ) +{ + BitmapText::LoadFromNode( sDir, pNode ); +} + void HelpDisplay::SetName( const CString &sName, const CString &sID ) { - ActorFrame::SetName( sName, sID ); + BitmapText::SetName( sName, sID ); TIP_SHOW_TIME.Load( m_sName, "TipShowTime" ); } @@ -37,7 +41,7 @@ void HelpDisplay::SetTips( const CStringArray &arrayTips, const CStringArray &ar if( arrayTips == m_arrayTips && arrayTipsAlt == m_arrayTipsAlt ) return; - m_textTip.SetText( "" ); + SetText( "" ); m_arrayTips = arrayTips; m_arrayTipsAlt = arrayTipsAlt; @@ -50,7 +54,7 @@ void HelpDisplay::SetTips( const CStringArray &arrayTips, const CStringArray &ar void HelpDisplay::Update( float fDeltaTime ) { - ActorFrame::Update( fDeltaTime ); + BitmapText::Update( fDeltaTime ); if( m_arrayTips.empty() ) return; @@ -61,11 +65,78 @@ void HelpDisplay::Update( float fDeltaTime ) // time to switch states m_fSecsUntilSwitch = TIP_SHOW_TIME; - m_textTip.SetText( m_arrayTips[m_iCurTipIndex], m_arrayTipsAlt[m_iCurTipIndex] ); + SetText( m_arrayTips[m_iCurTipIndex], m_arrayTipsAlt[m_iCurTipIndex] ); m_iCurTipIndex++; m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.size(); } + +#include "song.h" +#include "GameState.h" +#include "Course.h" +#include "Style.h" +#include "Foreach.h" + +REGISTER_ACTOR_CLASS( GenreDisplay ); + +GenreDisplay::GenreDisplay() +{ + MESSAGEMAN->Subscribe( this, "OnSongChanged" ); + MESSAGEMAN->Subscribe( this, "OnCourseChanged" ); +} + +GenreDisplay::~GenreDisplay() +{ + MESSAGEMAN->Unsubscribe( this, "OnSongChanged" ); + MESSAGEMAN->Unsubscribe( this, "OnCourseChanged" ); +} + +void GenreDisplay::PlayCommand( const CString &sCommandName ) +{ + if( sCommandName == "OnSongChanged" ) + { + vector m_Artists, m_AltArtists; + + Song* pSong = GAMESTATE->m_pCurSong; + ASSERT( pSong ); + + m_Artists.push_back( pSong->GetDisplayArtist() ); + m_AltArtists.push_back( pSong->GetTranslitArtist() ); + + SetTips( m_Artists, m_AltArtists ); + } + else if( sCommandName == "OnCourseChanged" ) + { + vector m_Artists, m_AltArtists; + + Course* pCourse = GAMESTATE->m_pCurCourse; + StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType; + Trail *pTrail = pCourse->GetTrail( st ); + ASSERT( pTrail ); + + FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) + { + if( e->bMystery ) + { + m_Artists.push_back( "???" ); + m_AltArtists.push_back( "???" ); + } + else + { + m_Artists.push_back( e->pSong->GetDisplayArtist() ); + m_AltArtists.push_back( e->pSong->GetTranslitArtist() ); + } + } + + SetTips( m_Artists, m_AltArtists ); + } + else + { + Actor::PlayCommand( sCommandName ); + } +} + + /* * (c) 2001-2003 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/HelpDisplay.h b/stepmania/src/HelpDisplay.h index 62cf17e634..9aaf381e76 100644 --- a/stepmania/src/HelpDisplay.h +++ b/stepmania/src/HelpDisplay.h @@ -3,16 +3,19 @@ #ifndef HELP_DISPLAY_H #define HELP_DISPLAY_H -#include "ActorFrame.h" #include "BitmapText.h" #include "ThemeMetric.h" +#include "MessageManager.h" -class HelpDisplay : public ActorFrame +class HelpDisplay : public BitmapText { public: HelpDisplay(); void Load(); + + void LoadFromNode( const CString& sDir, const XNode* pNode ); + void SetTips( const CStringArray &arrayTips ) { SetTips( arrayTips, arrayTips ); } void SetTips( const CStringArray &arrayTips, const CStringArray &arrayTipsAlt ); @@ -22,14 +25,20 @@ public: protected: ThemeMetric TIP_SHOW_TIME; - BitmapText m_textTip; - CStringArray m_arrayTips, m_arrayTipsAlt; int m_iCurTipIndex; float m_fSecsUntilSwitch; }; +class GenreDisplay : public HelpDisplay +{ +public: + GenreDisplay(); + ~GenreDisplay(); + void PlayCommand( const CString &sCommandName ); +}; + #endif /*