when a 2nd player joins, remove double steps from the list. They're no longer playable with 2 players joined.

This commit is contained in:
Chris Danford
2007-03-06 08:06:26 +00:00
parent 8a773bfab8
commit 8cbbc48523
7 changed files with 92 additions and 58 deletions
+1
View File
@@ -11,6 +11,7 @@
#include "Foreach.h"
#include "GameState.h"
#include "LocalizedString.h"
#include "LuaManager.h"
//
+35 -46
View File
@@ -247,67 +247,56 @@ void DifficultyList::SetFromGameState()
{
const Song *pSong = GAMESTATE->m_pCurSong;
const bool bSongChanged = (pSong != m_CurSong);
/* If the song has changed, update displays: */
if( bSongChanged )
for( int m = 0; m < MAX_METERS; ++m )
{
m_CurSong = pSong;
m_Lines[m].m_Meter.Unset();
}
for( int m = 0; m < MAX_METERS; ++m )
m_Rows.clear();
if( pSong == NULL )
{
// FIXME: This clamps to between the min and the max difficulty, but
// it really should round to the nearest difficulty that's in
// DIFFICULTIES_TO_SHOW.
unsigned i=0;
FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), d )
{
m_Lines[m].m_Meter.Unset();
m_Rows.resize( m_Rows.size()+1 );
Row &row = m_Rows.back();
row.m_dc = *d;
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficulty( StepsType_Invalid, 0, *d );
i++;
}
}
else
{
vector<Steps*> vpSteps;
SongUtil::GetPlayableSteps( pSong, vpSteps );
/* Should match the sort in ScreenSelectMusic::AfterMusicChange. */
m_Rows.clear();
if( pSong == NULL )
m_Rows.resize( vpSteps.size() );
for( unsigned i = 0; i < vpSteps.size(); ++i )
{
// FIXME: This clamps to between the min and the max difficulty, but
// it really should round to the nearest difficulty that's in
// DIFFICULTIES_TO_SHOW.
unsigned i=0;
FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), d )
{
m_Rows.resize( m_Rows.size()+1 );
Row &row = m_Rows[i];
Row &row = m_Rows.back();
row.m_Steps = vpSteps[i];
row.m_dc = *d;
m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps );
m_Lines[i].m_Meter.SetFromStepsTypeAndMeterAndDifficulty( StepsType_Invalid, 0, *d );
i++;
}
}
else
{
vector<Steps*> vpSteps;
SongUtil::GetPossibleSteps( pSong, vpSteps );
/* Should match the sort in ScreenSelectMusic::AfterMusicChange. */
m_Rows.resize( vpSteps.size() );
for( unsigned i = 0; i < vpSteps.size(); ++i )
{
Row &row = m_Rows[i];
row.m_Steps = vpSteps[i];
m_Lines[i].m_Meter.SetFromSteps( m_Rows[i].m_Steps );
row.m_dc = row.m_Steps->GetDifficulty();
}
row.m_dc = row.m_Steps->GetDifficulty();
}
}
UpdatePositions();
PositionItems();
if( bSongChanged )
{
for( int m = 0; m < MAX_METERS; ++m )
m_Lines[m].m_Meter.FinishTweening();
}
for( int m = 0; m < MAX_METERS; ++m )
m_Lines[m].m_Meter.FinishTweening();
}
void DifficultyList::HideRows()
+6 -4
View File
@@ -2340,21 +2340,23 @@ void GameManager::GetCompatibleStyles( const Game *pGame, int iNumPlayers, vecto
{
FOREACH_ENUM( StyleType, styleType )
{
int iNumPlayersRequired;
switch( styleType )
{
DEFAULT_FAIL( styleType );
case StyleType_OnePlayerOneSide:
case StyleType_OnePlayerTwoSides:
if( iNumPlayers != 1 )
continue;
iNumPlayersRequired = 1;
break;
case StyleType_TwoPlayersTwoSides:
case StyleType_TwoPlayersSharedSides:
if( iNumPlayers != 2 )
continue;
iNumPlayersRequired = 2;
break;
}
if( iNumPlayers != iNumPlayersRequired )
continue;
for( unsigned s=0; s<NUM_STYLES; s++ )
{
const Style* style = &g_Styles[s];
+1 -1
View File
@@ -170,7 +170,7 @@ void MusicWheel::BeginScreen()
if( GAMESTATE->m_pCurSteps[p] != NULL )
{
vector<Steps*> vpPossibleSteps;
SongUtil::GetPossibleSteps( GAMESTATE->m_pCurSong, vpPossibleSteps );
SongUtil::GetPlayableSteps( GAMESTATE->m_pCurSong, vpPossibleSteps );
bool bStepsIsPossible = find( vpPossibleSteps.begin(), vpPossibleSteps.end(), GAMESTATE->m_pCurSteps[p] ) == vpPossibleSteps.end();
if( !bStepsIsPossible )
GAMESTATE->m_pCurSteps[p].Set( NULL );
+5 -1
View File
@@ -298,6 +298,9 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
// Handle late joining
if( input.MenuI == MENU_BUTTON_START && input.type == IET_FIRST_PRESS && GAMESTATE->JoinInput(input.pn) )
{
// refresh the steps list so that 2-side StepsTypes will be removed since they're no longer playable
AfterMusicChange();
int iSel = 0;
PlayerNumber pn = input.pn;
m_iSelection[pn] = iSel;
@@ -311,6 +314,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]];
GAMESTATE->m_pCurSteps[pn].Set( pSteps );
}
return; // don't handle this press again below
}
@@ -1058,7 +1062,7 @@ void ScreenSelectMusic::AfterMusicChange()
m_fSampleStartSeconds = pSong->m_fMusicSampleStartSeconds;
m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds;
SongUtil::GetPossibleSteps( pSong, m_vpSteps );
SongUtil::GetPlayableSteps( pSong, m_vpSteps );
if ( PREFSMAN->m_bShowBanners )
g_sBannerPath = pSong->GetBannerPath();
+42 -5
View File
@@ -16,6 +16,8 @@
#include "RageLog.h"
#include "GameManager.h"
#include "CommonMetrics.h"
#include "LuaBinding.h"
#include "EnumHelper.h"
bool SongCriteria::Matches( const Song *pSong ) const
{
@@ -810,30 +812,35 @@ void SongUtil::FilterSongs( const SongCriteria &sc, const vector<Song*> &in, vec
}
}
void SongUtil::GetPossibleSteps( const Song *pSong, vector<Steps*> &vOut )
static void GetPlayableStepsTypes( set<StepsType> &vOut )
{
vector<const Style*> vpPossibleStyles;
if( CommonMetrics::ALL_STEPS_TYPES_IN_ONE_LIST )
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumPlayersEnabled(), vpPossibleStyles );
else
vpPossibleStyles.push_back( GAMESTATE->m_pCurStyle );
set<StepsType> vStepsType;
FOREACH( const Style*, vpPossibleStyles, s )
vStepsType.insert( (*s)->m_StepsType );
vOut.insert( (*s)->m_StepsType );
// filter out hidden StepsTypes
const vector<StepsType> &vstToShow = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue();
FOREACHS( StepsType, vStepsType, st )
FOREACHS( StepsType, vOut, st )
{
bool bShowThis = find( vstToShow.begin(), vstToShow.end(), *st ) != vstToShow.end();
if( !bShowThis )
{
set<StepsType>::iterator to_erase = st;
++st;
vStepsType.erase( to_erase );
vOut.erase( to_erase );
--st;
}
}
}
void SongUtil::GetPlayableSteps( const Song *pSong, vector<Steps*> &vOut )
{
set<StepsType> vStepsType;
GetPlayableStepsTypes( vStepsType );
FOREACHS( StepsType, vStepsType, st )
SongUtil::GetSteps( pSong, vOut, *st );
@@ -853,6 +860,13 @@ void SongUtil::GetPossibleSteps( const Song *pSong, vector<Steps*> &vOut )
}
}
bool SongUtil::IsStepsTypePlayable( StepsType st )
{
set<StepsType> vStepsType;
GetPlayableStepsTypes( vStepsType );
return vStepsType.find( st ) != vStepsType.end();
}
//////////////////////////////////
// SongID
//////////////////////////////////
@@ -906,6 +920,29 @@ bool SongID::IsValid() const
return !sDir.empty();
}
// lua start
#include "LuaBinding.h"
namespace
{
int IsStepsTypePlayable( lua_State *L )
{
StepsType st = Enum::Check<StepsType>(L, 1);
bool b = SongUtil::IsStepsTypePlayable( st );
LuaHelpers::Push( L, b );
return 1;
}
const luaL_Reg SongUtilTable[] =
{
LIST_METHOD( IsStepsTypePlayable ),
{ NULL, NULL }
};
}
LUA_REGISTER_NAMESPACE( SongUtil )
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
+2 -1
View File
@@ -110,7 +110,8 @@ namespace SongUtil
void GetAllSongGenres( vector<RString> &vsOut );
void FilterSongs( const SongCriteria &sc, const vector<Song*> &in, vector<Song*> &out );
void GetPossibleSteps( const Song *pSong, vector<Steps*> &vOut );
void GetPlayableSteps( const Song *pSong, vector<Steps*> &vOut );
bool IsStepsTypePlayable( StepsType st );
}
class SongID