allow courses to set their preferred style
This commit is contained in:
@@ -16,6 +16,8 @@
|
|||||||
#include "Steps.h"
|
#include "Steps.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "UnlockManager.h"
|
#include "UnlockManager.h"
|
||||||
|
#include "Game.h"
|
||||||
|
#include "Style.h"
|
||||||
|
|
||||||
static Preference<int> MAX_SONGS_IN_EDIT_COURSE( "MaxSongsInEditCourse", -1 );
|
static Preference<int> MAX_SONGS_IN_EDIT_COURSE( "MaxSongsInEditCourse", -1 );
|
||||||
|
|
||||||
@@ -711,6 +713,20 @@ bool Course::AllSongsAreFixed() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Style *Course::GetCourseStyle( const Game *pGame ) const
|
||||||
|
{
|
||||||
|
for( int s=0; pGame->m_apStyles[s]; ++s )
|
||||||
|
{
|
||||||
|
const Style *pStyle = pGame->m_apStyles[s];
|
||||||
|
FOREACHS_CONST( RString, m_setStyles, style )
|
||||||
|
{
|
||||||
|
if( !style->CompareNoCase(pStyle->m_szName) )
|
||||||
|
return pStyle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void Course::Invalidate( const Song *pStaleSong )
|
void Course::Invalidate( const Song *pStaleSong )
|
||||||
{
|
{
|
||||||
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
FOREACH_CONST( CourseEntry, m_vEntries, e )
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
class Style;
|
||||||
|
class Game;
|
||||||
|
|
||||||
const int MAX_EDIT_COURSE_TITLE_LENGTH = 12;
|
const int MAX_EDIT_COURSE_TITLE_LENGTH = 12;
|
||||||
|
|
||||||
@@ -122,6 +124,7 @@ public:
|
|||||||
int GetMeter( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const;
|
int GetMeter( StepsType st, CourseDifficulty cd=Difficulty_Medium ) const;
|
||||||
bool HasMods() const;
|
bool HasMods() const;
|
||||||
bool AllSongsAreFixed() const;
|
bool AllSongsAreFixed() const;
|
||||||
|
const Style *GetCourseStyle( const Game *pGame ) const;
|
||||||
|
|
||||||
int GetEstimatedNumStages() const { return m_vEntries.size(); }
|
int GetEstimatedNumStages() const { return m_vEntries.size(); }
|
||||||
bool IsPlayableIn( StepsType st ) const;
|
bool IsPlayableIn( StepsType st ) const;
|
||||||
@@ -208,6 +211,9 @@ public:
|
|||||||
|
|
||||||
typedef map<CacheEntry, RadarValues> RadarCache_t;
|
typedef map<CacheEntry, RadarValues> RadarCache_t;
|
||||||
RadarCache_t m_RadarCache;
|
RadarCache_t m_RadarCache;
|
||||||
|
|
||||||
|
/* Preferred styles: */
|
||||||
|
set<RString> m_setStyles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -282,6 +282,15 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
|||||||
rv.FromString( sParams[3] );
|
rv.FromString( sParams[3] );
|
||||||
out.m_RadarCache[Course::CacheEntry(st, cd)] = rv;
|
out.m_RadarCache[Course::CacheEntry(st, cd)] = rv;
|
||||||
}
|
}
|
||||||
|
else if( 0 == stricmp(sValueName, "STYLE") )
|
||||||
|
{
|
||||||
|
RString sStyles = sParams[1];
|
||||||
|
vector<RString> asStyles;
|
||||||
|
split( sStyles, ",", asStyles );
|
||||||
|
FOREACH( RString, asStyles, s )
|
||||||
|
out.m_setStyles.insert( *s );
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG->UserLog( "Course file", sPath, "contains an unexpected value named \"%s\"", sValueName.c_str() );
|
LOG->UserLog( "Course file", sPath, "contains an unexpected value named \"%s\"", sValueName.c_str() );
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
|
|||||||
f.PutLine( "#REPEAT:YES;" );
|
f.PutLine( "#REPEAT:YES;" );
|
||||||
if( course.m_iLives != -1 )
|
if( course.m_iLives != -1 )
|
||||||
f.PutLine( ssprintf("#LIVES:%i;", course.m_iLives) );
|
f.PutLine( ssprintf("#LIVES:%i;", course.m_iLives) );
|
||||||
|
if( !course.m_setStyles.empty() )
|
||||||
|
{
|
||||||
|
vector<RString> asStyles;
|
||||||
|
asStyles.insert( asStyles.begin(), course.m_setStyles.begin(), course.m_setStyles.end() );
|
||||||
|
f.PutLine( ssprintf("#STYLE:%i;", join( ",", asStyles ).c_str()) );
|
||||||
|
}
|
||||||
|
|
||||||
FOREACH_ENUM( CourseDifficulty,cd )
|
FOREACH_ENUM( CourseDifficulty,cd )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
#include "PlayerState.h"
|
#include "PlayerState.h"
|
||||||
|
#include "CommonMetrics.h"
|
||||||
|
|
||||||
static Preference<bool> g_bMoveRandomToEnd( "MoveRandomToEnd", false );
|
static Preference<bool> g_bMoveRandomToEnd( "MoveRandomToEnd", false );
|
||||||
|
|
||||||
@@ -981,8 +982,13 @@ void MusicWheel::SetOpenGroup( RString group )
|
|||||||
if( !m_CurWheelItemData.empty() )
|
if( !m_CurWheelItemData.empty() )
|
||||||
old = GetCurWheelItemData(m_iSelection);
|
old = GetCurWheelItemData(m_iSelection);
|
||||||
|
|
||||||
|
vector<const Style*> vpPossibleStyles;
|
||||||
|
if( CommonMetrics::AUTO_SET_STYLE )
|
||||||
|
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled(), vpPossibleStyles );
|
||||||
|
|
||||||
m_CurWheelItemData.clear();
|
m_CurWheelItemData.clear();
|
||||||
vector<WheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
|
vector<WheelItemData *> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
|
||||||
|
m_CurWheelItemData.reserve( from.size() );
|
||||||
for( unsigned i = 0; i < from.size(); ++i )
|
for( unsigned i = 0; i < from.size(); ++i )
|
||||||
{
|
{
|
||||||
WheelItemData &d = *from[i];
|
WheelItemData &d = *from[i];
|
||||||
@@ -990,6 +996,17 @@ void MusicWheel::SetOpenGroup( RString group )
|
|||||||
d.m_sText != group )
|
d.m_sText != group )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* If AUTO_SET_STYLE, hide courses that prefer a style that isn't available. */
|
||||||
|
if( d.m_Type == TYPE_COURSE && CommonMetrics::AUTO_SET_STYLE )
|
||||||
|
{
|
||||||
|
const Style *pStyle = d.m_pCourse->GetCourseStyle( GAMESTATE->m_pCurGame );
|
||||||
|
if( pStyle )
|
||||||
|
{
|
||||||
|
if( find( vpPossibleStyles.begin(), vpPossibleStyles.end(), pStyle ) == vpPossibleStyles.end() )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Only show tutorial songs in arcade */
|
/* Only show tutorial songs in arcade */
|
||||||
if( GAMESTATE->m_PlayMode!=PLAY_MODE_REGULAR &&
|
if( GAMESTATE->m_PlayMode!=PLAY_MODE_REGULAR &&
|
||||||
d.m_pSong &&
|
d.m_pSong &&
|
||||||
@@ -1017,6 +1034,12 @@ void MusicWheel::SetOpenGroup( RString group )
|
|||||||
RebuildWheelItems();
|
RebuildWheelItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called on late join. Selectable courses may have changed; reopen the section. */
|
||||||
|
void MusicWheel::PlayerJoined()
|
||||||
|
{
|
||||||
|
SetOpenGroup( m_sExpandedSectionName );
|
||||||
|
}
|
||||||
|
|
||||||
bool MusicWheel::IsRouletting() const
|
bool MusicWheel::IsRouletting() const
|
||||||
{
|
{
|
||||||
return m_WheelState == STATE_ROULETTE_SPINNING || m_WheelState == STATE_ROULETTE_SLOWING_DOWN ||
|
return m_WheelState == STATE_ROULETTE_SPINNING || m_WheelState == STATE_ROULETTE_SLOWING_DOWN ||
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
SortOrder GetSortOrder() const { return m_SortOrder; }
|
SortOrder GetSortOrder() const { return m_SortOrder; }
|
||||||
virtual void ChangeMusic( int dist ); /* +1 or -1 */ //CHECK THIS
|
virtual void ChangeMusic( int dist ); /* +1 or -1 */ //CHECK THIS
|
||||||
void FinishChangingSorts();
|
void FinishChangingSorts();
|
||||||
|
void PlayerJoined();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MusicWheelItem *MakeItem();
|
MusicWheelItem *MakeItem();
|
||||||
|
|||||||
@@ -106,14 +106,6 @@ void ScreenSelectMusic::Init()
|
|||||||
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","mode")) );
|
m_TexturePreload.Load( Banner::SongBannerTexture(THEME->GetPathG("Banner","mode")) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CommonMetrics::AUTO_SET_STYLE )
|
|
||||||
{
|
|
||||||
vector<StepsType> vst;
|
|
||||||
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vst );
|
|
||||||
const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), vst[0] );
|
|
||||||
GAMESTATE->SetCurrentStyle( pStyle );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load low-res banners, if needed. */
|
/* Load low-res banners, if needed. */
|
||||||
BANNERCACHE->Demand();
|
BANNERCACHE->Demand();
|
||||||
|
|
||||||
@@ -188,6 +180,14 @@ void ScreenSelectMusic::BeginScreen()
|
|||||||
|
|
||||||
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
|
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
|
||||||
|
|
||||||
|
if( CommonMetrics::AUTO_SET_STYLE )
|
||||||
|
{
|
||||||
|
vector<StepsType> vst;
|
||||||
|
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vst );
|
||||||
|
const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), vst[0] );
|
||||||
|
GAMESTATE->SetCurrentStyle( pStyle );
|
||||||
|
}
|
||||||
|
|
||||||
if( GAMESTATE->GetCurrentStyle() == NULL )
|
if( GAMESTATE->GetCurrentStyle() == NULL )
|
||||||
RageException::Throw( "The Style has not been set. A theme must set the Style before loading ScreenSelectMusic." );
|
RageException::Throw( "The Style has not been set. A theme must set the Style before loading ScreenSelectMusic." );
|
||||||
|
|
||||||
@@ -347,6 +347,10 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
|
|||||||
FOREACH_ENUM( PlayerNumber, p )
|
FOREACH_ENUM( PlayerNumber, p )
|
||||||
GAMESTATE->m_pCurSteps[p].SetWithoutBroadcast( NULL );
|
GAMESTATE->m_pCurSteps[p].SetWithoutBroadcast( NULL );
|
||||||
|
|
||||||
|
/* If a course is selected, it may no longer be playable. Let MusicWheel know
|
||||||
|
* about the late join. */
|
||||||
|
m_MusicWheel.PlayerJoined();
|
||||||
|
|
||||||
AfterMusicChange();
|
AfterMusicChange();
|
||||||
|
|
||||||
int iSel = 0;
|
int iSel = 0;
|
||||||
@@ -888,14 +892,20 @@ void ScreenSelectMusic::MenuStart( const InputEventPlus &input )
|
|||||||
if( CommonMetrics::AUTO_SET_STYLE )
|
if( CommonMetrics::AUTO_SET_STYLE )
|
||||||
{
|
{
|
||||||
/* Now that Steps have been chosen, set a Style that can play them. */
|
/* Now that Steps have been chosen, set a Style that can play them. */
|
||||||
StepsType stCurrent;
|
const Style *pStyle = NULL;
|
||||||
PlayerNumber pn = GAMESTATE->m_MasterPlayerNumber;
|
|
||||||
if( GAMESTATE->IsCourseMode() )
|
if( GAMESTATE->IsCourseMode() )
|
||||||
stCurrent = GAMESTATE->m_pCurTrail[pn]->m_StepsType;
|
pStyle = GAMESTATE->m_pCurCourse->GetCourseStyle( GAMESTATE->m_pCurGame );
|
||||||
else
|
if( pStyle == NULL )
|
||||||
stCurrent = GAMESTATE->m_pCurSteps[pn]->m_StepsType;
|
{
|
||||||
vector<StepsType> vst;
|
StepsType stCurrent;
|
||||||
const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), stCurrent );
|
PlayerNumber pn = GAMESTATE->m_MasterPlayerNumber;
|
||||||
|
if( GAMESTATE->IsCourseMode() )
|
||||||
|
stCurrent = GAMESTATE->m_pCurTrail[pn]->m_StepsType;
|
||||||
|
else
|
||||||
|
stCurrent = GAMESTATE->m_pCurSteps[pn]->m_StepsType;
|
||||||
|
vector<StepsType> vst;
|
||||||
|
pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), stCurrent );
|
||||||
|
}
|
||||||
GAMESTATE->SetCurrentStyle( pStyle );
|
GAMESTATE->SetCurrentStyle( pStyle );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1160,12 +1170,13 @@ void ScreenSelectMusic::AfterMusicChange()
|
|||||||
|
|
||||||
case TYPE_COURSE:
|
case TYPE_COURSE:
|
||||||
{
|
{
|
||||||
Course* pCourse = m_MusicWheel.GetSelectedCourse();
|
const Course *pCourse = m_MusicWheel.GetSelectedCourse();
|
||||||
StepsType st = GAMESTATE->GetCurrentStyle()->m_StepsType;
|
const Style *pStyle = NULL;
|
||||||
Trail *pTrail = pCourse->GetTrail( st );
|
if( CommonMetrics::AUTO_SET_STYLE )
|
||||||
ASSERT( pTrail );
|
pStyle = pCourse->GetCourseStyle( GAMESTATE->m_pCurGame );
|
||||||
|
if( pStyle == NULL )
|
||||||
pCourse->GetTrails( m_vpTrails, GAMESTATE->GetCurrentStyle()->m_StepsType );
|
pStyle = GAMESTATE->GetCurrentStyle();
|
||||||
|
pCourse->GetTrails( m_vpTrails, pStyle->m_StepsType );
|
||||||
|
|
||||||
m_sSampleMusicToPlay = m_sCourseMusicPath;
|
m_sSampleMusicToPlay = m_sCourseMusicPath;
|
||||||
m_fSampleStartSeconds = 0;
|
m_fSampleStartSeconds = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user