From 1cef7612530f697a1e3dd5a55d3154fff5d7e27f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 21 May 2005 06:19:57 +0000 Subject: [PATCH] specify StyleTypes to use in ScreenDemonstration --- stepmania/Themes/default/metrics.ini | 1 + stepmania/src/GameConstantsAndTypes.h | 3 ++- stepmania/src/GameManager.cpp | 15 +++++++------- stepmania/src/GameManager.h | 2 +- stepmania/src/ScreenDemonstration.cpp | 28 ++++++++++++++++++++++++++- 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 86d1e1d9bb..fa2066753a 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3648,6 +3648,7 @@ StartScreen=@ScreenTitleBranch() PlayMusic=0 ShowCourseModifiersProbability=0 AllowAdvancedModifiers=0 +AllowStyleTypes=TwoPlayersTwoSides [ScreenJukebox] ShowCourseModifiersProbability=0 diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index b63f69fa41..5a82957a57 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -353,7 +353,8 @@ enum StyleType ONE_PLAYER_ONE_SIDE, // e.g. single TWO_PLAYERS_TWO_SIDES, // e.g. versus ONE_PLAYER_TWO_SIDES, // e.g. double - NUM_STYLE_TYPES + NUM_STYLE_TYPES, + STYLE_TYPE_INVALID }; const CString& StyleTypeToString( StyleType s ); StyleType StringToStyleType( const CString& s ); diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 8aa3f6ea7c..c34975abd9 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -1014,7 +1014,7 @@ Style g_Styles[] = &g_Games[GAME_DANCE], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit - false, // m_bUsedForDemonstration + true, // m_bUsedForDemonstration true, // m_bUsedForHowToPlay "single", // m_szName STEPS_TYPE_DANCE_SINGLE, // m_StepsType @@ -1082,7 +1082,7 @@ Style g_Styles[] = &g_Games[GAME_DANCE], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit - false, // m_bUsedForDemonstration + true, // m_bUsedForDemonstration false, // m_bUsedForHowToPlay "double", // m_szName STEPS_TYPE_DANCE_DOUBLE, // m_StepsType @@ -2613,17 +2613,18 @@ void GameManager::GetStepsTypesForGame( const Game *pGame, vector& aS } } -const Style* GameManager::GetDemonstrationStyleForGame( const Game *pGame ) const +void GameManager::GetDemonstrationStylesForGame( const Game *pGame, vector &vpStylesOut ) const { + vpStylesOut.clear(); + for( unsigned s=0; sm_pGame == pGame && style->m_bUsedForDemonstration ) - return style; + vpStylesOut.push_back( style ); } - - ASSERT(0); // this Game is missing a Style that can be used with the demonstration - return NULL; + + ASSERT( vpStylesOut.size()>0 ); // this Game is missing a Style that can be used with the demonstration } const Style* GameManager::GetHowToPlayStyleForGame( const Game *pGame ) const diff --git a/stepmania/src/GameManager.h b/stepmania/src/GameManager.h index 7de0e08fb2..ae14835a3d 100644 --- a/stepmania/src/GameManager.h +++ b/stepmania/src/GameManager.h @@ -19,7 +19,7 @@ public: void GetAllStyles( vector& aStylesAddTo, bool editor=false ) const; void GetStepsTypesForGame( const Game* pGame, vector& aStepsTypeAddTo ) const; const Style* GetEditorStyleForStepsType( StepsType st ) const; - const Style* GetDemonstrationStyleForGame( const Game* pGame ) const; + void GetDemonstrationStylesForGame( const Game *pGame, vector &vpStylesOut ) const; const Style* GetHowToPlayStyleForGame( const Game* pGame ) const; void GetEnabledGames( vector& aGamesOut ) const; diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 213210caab..899d68a10f 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -9,10 +9,12 @@ #include "RageSoundManager.h" #include "GameSoundManager.h" #include "GameManager.h" +#include "Style.h" #define SECONDS_TO_SHOW THEME->GetMetricF(m_sName,"SecondsToShow") #define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen") +#define ALLOW_STYLE_TYPES THEME->GetMetric (m_sName,"AllowStyleTypes") REGISTER_SCREEN_CLASS( ScreenDemonstration ); ScreenDemonstration::ScreenDemonstration( CString sName ) : ScreenJukebox( sName ) @@ -23,7 +25,31 @@ ScreenDemonstration::ScreenDemonstration( CString sName ) : ScreenJukebox( sName void ScreenDemonstration::Init() { - GAMESTATE->m_pCurStyle.Set( GAMEMAN->GetDemonstrationStyleForGame(GAMESTATE->m_pCurGame) ); + // Choose a Style + { + vector v; + split( ALLOW_STYLE_TYPES, ",", v ); + vector vStyleTypeAllow; + FOREACH_CONST( CString, v, s ) + { + StyleType st = StringToStyleType( *s ); + ASSERT( st != STYLE_TYPE_INVALID ); + vStyleTypeAllow.push_back( st ); + } + + vector vStylePossible; + GAMEMAN->GetDemonstrationStylesForGame( GAMESTATE->m_pCurGame, vStylePossible ); + for( int i=(int)(vStylePossible.size())-1; i>=0; i-- ) + { + bool bAllowThis = find( vStyleTypeAllow.begin(), vStyleTypeAllow.end(), vStylePossible[i]->m_StyleType ) != vStyleTypeAllow.end(); + if( !bAllowThis ) + vStylePossible.erase( vStylePossible.begin()+i ); + } + + ASSERT( vStylePossible.size() > 0 ); + const Style* pStyle = vStylePossible[ rand() % vStylePossible.size() ]; + GAMESTATE->m_pCurStyle.Set( pStyle ); + } GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR;