broadcast on changed course/trail
This commit is contained in:
@@ -122,9 +122,9 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
|
||||
return false;
|
||||
if( m_pCharacter && GAMESTATE->m_pCurCharacters[pn] != m_pCharacter )
|
||||
return false;
|
||||
if( m_pCourse && GAMESTATE->m_pCurCourse != m_pCourse )
|
||||
if( m_pCourse && GAMESTATE->m_pCurCourse.Get() != m_pCourse )
|
||||
return false;
|
||||
if( m_pTrail && GAMESTATE->m_pCurTrail[pn] != m_pTrail )
|
||||
if( m_pTrail && GAMESTATE->m_pCurTrail[pn].Get() != m_pTrail )
|
||||
return false;
|
||||
if( !m_sSongGroup.empty() && GAMESTATE->m_sPreferredSongGroup != m_sSongGroup )
|
||||
return false;
|
||||
@@ -744,12 +744,12 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps );
|
||||
if( m_pCourse )
|
||||
{
|
||||
GAMESTATE->m_pCurCourse = m_pCourse;
|
||||
GAMESTATE->m_pCurCourse.Set( m_pCourse );
|
||||
GAMESTATE->m_pPreferredCourse = m_pCourse;
|
||||
}
|
||||
if( m_pTrail )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_pCurTrail[*pn] = m_pTrail;
|
||||
GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail );
|
||||
if( m_CourseDifficulty != DIFFICULTY_INVALID )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty );
|
||||
|
||||
@@ -52,6 +52,8 @@ GameState::GameState() :
|
||||
m_PreferredDifficulty( MESSAGE_EDIT_PREFERRED_DIFFICULTY_P1_CHANGED ),
|
||||
m_pCurSong( MESSAGE_CURRENT_SONG_CHANGED ),
|
||||
m_pCurSteps( MESSAGE_CURRENT_STEPS_P1_CHANGED ),
|
||||
m_pCurCourse( MESSAGE_CURRENT_COURSE_CHANGED ),
|
||||
m_pCurTrail( MESSAGE_CURRENT_TRAIL_P1_CHANGED ),
|
||||
m_stEdit( MESSAGE_EDIT_STEPS_TYPE_CHANGED ),
|
||||
m_pEditSourceSteps( MESSAGE_EDIT_SOURCE_STEPS_CHANGED ),
|
||||
m_stEditSource( MESSAGE_EDIT_SOURCE_STEPS_TYPE_CHANGED )
|
||||
@@ -172,10 +174,10 @@ void GameState::Reset()
|
||||
m_pPreferredSong = NULL;
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pCurSteps[p].Set( NULL );
|
||||
m_pCurCourse = NULL;
|
||||
m_pCurCourse.Set( NULL );
|
||||
m_pPreferredCourse = NULL;
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pCurTrail[p] = NULL;
|
||||
m_pCurTrail[p].Set( NULL );
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pPlayerState[p]->Reset();
|
||||
@@ -1946,14 +1948,14 @@ public:
|
||||
PlayerNumber pn = (PlayerNumber)IArg(1);
|
||||
if( lua_isnil(L,2) ) { p->m_pCurSteps[pn].Set( NULL ); }
|
||||
else { Steps *pS = Luna<Steps>::check(L,2); p->m_pCurSteps[pn].Set( pS ); }
|
||||
MESSAGEMAN->Broadcast( ssprintf("CurrentStepsP%dChanged",pn+1) );
|
||||
MESSAGEMAN->Broadcast( (Message)(MESSAGE_CURRENT_STEPS_P1_CHANGED+pn) );
|
||||
return 0;
|
||||
}
|
||||
static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; }
|
||||
static int SetCurrentCourse( T* p, lua_State *L )
|
||||
{
|
||||
if( lua_isnil(L,1) ) { p->m_pCurCourse = NULL; }
|
||||
else { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse = pC; }
|
||||
if( lua_isnil(L,1) ) { p->m_pCurCourse.Set( NULL ); }
|
||||
else { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse.Set( pC ); }
|
||||
return 0;
|
||||
}
|
||||
static int GetCurrentTrail( T* p, lua_State *L )
|
||||
|
||||
@@ -139,10 +139,10 @@ public:
|
||||
BroadcastOnChangePtr1D<Steps,NUM_PLAYERS> m_pCurSteps;
|
||||
|
||||
// NULL on ScreenSelectMusic if the currently selected wheel item isn't a Course.
|
||||
Course* m_pCurCourse;
|
||||
BroadcastOnChangePtr<Course> m_pCurCourse;
|
||||
// The last Course that the user manually changed to.
|
||||
Course* m_pPreferredCourse;
|
||||
Trail* m_pCurTrail[NUM_PLAYERS];
|
||||
BroadcastOnChangePtr1D<Trail,NUM_PLAYERS> m_pCurTrail;
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -136,19 +136,17 @@ REGISTER_ACTOR_CLASS( GenreDisplay )
|
||||
|
||||
GenreDisplay::GenreDisplay()
|
||||
{
|
||||
MESSAGEMAN->Subscribe( this, "OnSongChanged" );
|
||||
MESSAGEMAN->Subscribe( this, "OnCourseChanged" );
|
||||
this->SubscribeToMessage( MESSAGE_CURRENT_SONG_CHANGED );
|
||||
this->SubscribeToMessage( MESSAGE_CURRENT_COURSE_CHANGED );
|
||||
}
|
||||
|
||||
GenreDisplay::~GenreDisplay()
|
||||
{
|
||||
MESSAGEMAN->Unsubscribe( this, "OnSongChanged" );
|
||||
MESSAGEMAN->Unsubscribe( this, "OnCourseChanged" );
|
||||
}
|
||||
|
||||
void GenreDisplay::PlayCommand( const CString &sCommandName )
|
||||
{
|
||||
if( sCommandName == "OnSongChanged" )
|
||||
if( sCommandName == MessageToString(MESSAGE_CURRENT_SONG_CHANGED) )
|
||||
{
|
||||
vector<CString> m_Artists, m_AltArtists;
|
||||
|
||||
@@ -160,7 +158,7 @@ void GenreDisplay::PlayCommand( const CString &sCommandName )
|
||||
|
||||
SetTips( m_Artists, m_AltArtists );
|
||||
}
|
||||
else if( sCommandName == "OnCourseChanged" )
|
||||
else if( sCommandName == MessageToString(MESSAGE_CURRENT_COURSE_CHANGED) )
|
||||
{
|
||||
vector<CString> m_Artists, m_AltArtists;
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ static const CString MessageNames[] = {
|
||||
"CurrentSongChanged",
|
||||
"CurrentStepsP1Changed",
|
||||
"CurrentStepsP2Changed",
|
||||
"CurrentCourseChanged",
|
||||
"CurrentTrailP1Changed",
|
||||
"CurrentTrailP2Changed",
|
||||
"EditStepsTypeChanged",
|
||||
"EditSourceStepsChanged",
|
||||
"EditSourceStepsTypeChanged",
|
||||
|
||||
@@ -20,6 +20,9 @@ enum Message
|
||||
MESSAGE_CURRENT_SONG_CHANGED,
|
||||
MESSAGE_CURRENT_STEPS_P1_CHANGED,
|
||||
MESSAGE_CURRENT_STEPS_P2_CHANGED,
|
||||
MESSAGE_CURRENT_COURSE_CHANGED,
|
||||
MESSAGE_CURRENT_TRAIL_P1_CHANGED,
|
||||
MESSAGE_CURRENT_TRAIL_P2_CHANGED,
|
||||
MESSAGE_EDIT_STEPS_TYPE_CHANGED,
|
||||
MESSAGE_EDIT_SOURCE_STEPS_CHANGED,
|
||||
MESSAGE_EDIT_SOURCE_STEPS_TYPE_CHANGED,
|
||||
|
||||
@@ -323,7 +323,7 @@ bool MusicWheel::SelectCourse( Course *p )
|
||||
if(p == NULL)
|
||||
return false;
|
||||
|
||||
GAMESTATE->m_pCurCourse = p;
|
||||
GAMESTATE->m_pCurCourse.Set( p );
|
||||
|
||||
unsigned i;
|
||||
vector<WheelItemData> &from = m_WheelItemDatas[GAMESTATE->m_SortOrder];
|
||||
|
||||
@@ -146,7 +146,7 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa
|
||||
GAMESTATE->m_bSideIsJoined[PLAYER_2] = true;
|
||||
GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
|
||||
GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() );
|
||||
GAMESTATE->m_pCurCourse = SONGMAN->GetRandomCourse();
|
||||
GAMESTATE->m_pCurCourse.Set( SONGMAN->GetRandomCourse() );
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
GAMESTATE->m_pCurSteps[PLAYER_2].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
STATSMAN->m_CurStageStats.m_player[PLAYER_1].vpPlayedSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] );
|
||||
|
||||
@@ -110,7 +110,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : ScreenWithMenuElement
|
||||
GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() );
|
||||
STATSMAN->m_CurStageStats.vpPlayedSongs.push_back( GAMESTATE->m_pCurSong );
|
||||
STATSMAN->m_CurStageStats.vpPossibleSongs.push_back( GAMESTATE->m_pCurSong );
|
||||
GAMESTATE->m_pCurCourse = SONGMAN->GetRandomCourse();
|
||||
GAMESTATE->m_pCurCourse.Set( SONGMAN->GetRandomCourse() );
|
||||
GAMESTATE->m_iCurrentStageIndex = 0;
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
@@ -122,7 +122,7 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : ScreenWithMenuElement
|
||||
GAMESTATE->m_pCurSteps[p].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
vector<Trail*> apTrails;
|
||||
GAMESTATE->m_pCurCourse->GetAllTrails( apTrails );
|
||||
GAMESTATE->m_pCurTrail[p] = apTrails[0];
|
||||
GAMESTATE->m_pCurTrail[p].Set( apTrails[0] );
|
||||
STATSMAN->m_CurStageStats.m_player[p].vpPlayedSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] );
|
||||
STATSMAN->m_CurStageStats.m_player[p].vpPossibleSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] );
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.m_fScrollSpeed = 2;
|
||||
|
||||
@@ -1371,7 +1371,7 @@ void ScreenSelectMusic::AfterTrailChange( const vector<PlayerNumber> &vpns )
|
||||
Course* pCourse = GAMESTATE->m_pCurCourse;
|
||||
Trail* pTrail = m_vpTrails.empty()? NULL: m_vpTrails[m_iSelection[pn]];
|
||||
|
||||
GAMESTATE->m_pCurTrail[pn] = pTrail;
|
||||
GAMESTATE->m_pCurTrail[pn].Set( pTrail );
|
||||
|
||||
int iScore = 0;
|
||||
if( pTrail )
|
||||
@@ -1503,14 +1503,14 @@ void ScreenSelectMusic::AfterMusicChange()
|
||||
m_GrooveGraph.SetFromSong( pSong );
|
||||
|
||||
Course* pCourse = m_MusicWheel.GetSelectedCourse();
|
||||
GAMESTATE->m_pCurCourse = pCourse;
|
||||
GAMESTATE->m_pCurCourse.Set( pCourse );
|
||||
if( pCourse )
|
||||
GAMESTATE->m_pPreferredCourse = pCourse;
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
GAMESTATE->m_pCurSteps[p].Set( NULL );
|
||||
GAMESTATE->m_pCurTrail[p] = NULL;
|
||||
GAMESTATE->m_pCurTrail[p].Set( NULL );
|
||||
m_vpSteps.clear();
|
||||
m_vpTrails.clear();
|
||||
}
|
||||
@@ -1660,8 +1660,6 @@ void ScreenSelectMusic::AfterMusicChange()
|
||||
|
||||
m_Artists.push_back( pSong->GetDisplayArtist() );
|
||||
m_AltArtists.push_back( pSong->GetTranslitArtist() );
|
||||
|
||||
MESSAGEMAN->Broadcast( "OnSongChanged" );
|
||||
}
|
||||
break;
|
||||
case TYPE_ROULETTE:
|
||||
@@ -1775,8 +1773,6 @@ void ScreenSelectMusic::AfterMusicChange()
|
||||
COMMAND( m_sprCourseHasMods, "Hide" );
|
||||
}
|
||||
|
||||
MESSAGEMAN->Broadcast( "OnCourseChanged" );
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -52,8 +52,6 @@ ScreenTitleMenu::ScreenTitleMenu( CString sScreenName ) :
|
||||
|
||||
// TRICKY: Do this after GameState::Reset.
|
||||
LIGHTSMAN->SetLightsMode( LIGHTSMODE_JOINING );
|
||||
|
||||
this->SubscribeToMessage( "CoinModeChanged" );
|
||||
}
|
||||
|
||||
void ScreenTitleMenu::Init()
|
||||
@@ -170,7 +168,7 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty
|
||||
|
||||
void ScreenTitleMenu::HandleMessage( const CString& sMessage )
|
||||
{
|
||||
if( sMessage == "CoinModeChanged" )
|
||||
if( sMessage == PREFSMAN->m_CoinMode.GetName()+"Changed" )
|
||||
{
|
||||
/* If the CoinMode was changed, we need to reload this screen
|
||||
* so that the right m_aGameCommands will show */
|
||||
|
||||
@@ -709,7 +709,10 @@ void SongManager::Invalidate( Song *pStaleSong )
|
||||
}
|
||||
}
|
||||
|
||||
CONVERT_COURSE_POINTER( GAMESTATE->m_pCurCourse );
|
||||
{
|
||||
CourseID id = mapOldCourseToCourseID[GAMESTATE->m_pCurCourse]; /* this will always succeed */
|
||||
GAMESTATE->m_pCurCourse.Set( id.ToCourse() );
|
||||
}
|
||||
CONVERT_COURSE_POINTER( GAMESTATE->m_pPreferredCourse );
|
||||
|
||||
#define CONVERT_TRAIL_POINTER( pTrail ) do { \
|
||||
@@ -720,7 +723,7 @@ void SongManager::Invalidate( Song *pStaleSong )
|
||||
const TrailIDAndCourse &tidc = it->second; \
|
||||
const TrailID &id = tidc.first; \
|
||||
const Course *pCourse = tidc.second; \
|
||||
pTrail = id.ToTrail( pCourse, true ); \
|
||||
pTrail.Set( id.ToTrail( pCourse, true ) ); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user