add "success/try again" looping logic to lesson mode
This commit is contained in:
@@ -56,7 +56,8 @@ static const CString MessageNames[] = {
|
|||||||
"AutosyncChanged",
|
"AutosyncChanged",
|
||||||
"PreferredSongGroupChanged",
|
"PreferredSongGroupChanged",
|
||||||
"PreferredCourseGroupChanged",
|
"PreferredCourseGroupChanged",
|
||||||
"SortOrderChanged"
|
"SortOrderChanged",
|
||||||
|
"LessonYourTurn",
|
||||||
};
|
};
|
||||||
XToString( Message, NUM_Message );
|
XToString( Message, NUM_Message );
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ enum Message
|
|||||||
Message_PreferredSongGroupChanged,
|
Message_PreferredSongGroupChanged,
|
||||||
Message_PreferredCourseGroupChanged,
|
Message_PreferredCourseGroupChanged,
|
||||||
Message_SortOrderChanged,
|
Message_SortOrderChanged,
|
||||||
|
Message_LessonYourTurn,
|
||||||
NUM_Message, // leave this at the end
|
NUM_Message, // leave this at the end
|
||||||
Message_Invalud
|
Message_Invalud
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -220,6 +220,68 @@ float PlayerStageStats::GetCurMaxPercentDancePoints() const
|
|||||||
return fCurMaxPercentDancePoints;
|
return fCurMaxPercentDancePoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PlayerStageStats::GetLessonScoreActual() const
|
||||||
|
{
|
||||||
|
int iScore = 0;
|
||||||
|
|
||||||
|
FOREACH_TapNoteScore( tns )
|
||||||
|
{
|
||||||
|
switch( tns )
|
||||||
|
{
|
||||||
|
case TNS_AVOIDED_MINE:
|
||||||
|
case TNS_MISS:
|
||||||
|
case TNS_BOO:
|
||||||
|
case TNS_GOOD:
|
||||||
|
case TNS_GREAT:
|
||||||
|
case TNS_PERFECT:
|
||||||
|
case TNS_MARVELOUS:
|
||||||
|
iScore += iTapNoteScores[tns];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FOREACH_HoldNoteScore( hns )
|
||||||
|
{
|
||||||
|
switch( hns )
|
||||||
|
{
|
||||||
|
case HNS_OK:
|
||||||
|
iScore += iHoldNoteScores[hns];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return iScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PlayerStageStats::GetLessonScorePossible() const
|
||||||
|
{
|
||||||
|
int iScore = 0;
|
||||||
|
|
||||||
|
FOREACH_TapNoteScore( tns )
|
||||||
|
iScore += iTapNoteScores[tns];
|
||||||
|
|
||||||
|
FOREACH_HoldNoteScore( hns )
|
||||||
|
iScore += iHoldNoteScores[hns];
|
||||||
|
|
||||||
|
return iScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerStageStats::ResetScoreForLesson()
|
||||||
|
{
|
||||||
|
iCurPossibleDancePoints = 0;
|
||||||
|
iActualDancePoints = 0;
|
||||||
|
FOREACH_TapNoteScore( tns )
|
||||||
|
iTapNoteScores[tns] = 0;
|
||||||
|
FOREACH_HoldNoteScore( hns )
|
||||||
|
iHoldNoteScores[hns] = 0;
|
||||||
|
iCurCombo = 0;
|
||||||
|
iMaxCombo = 0;
|
||||||
|
iCurMissCombo = 0;
|
||||||
|
iScore = 0;
|
||||||
|
iCurMaxScore = 0;
|
||||||
|
iMaxScore = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond )
|
void PlayerStageStats::SetLifeRecordAt( float fLife, float fStepsSecond )
|
||||||
{
|
{
|
||||||
// Don't save life stats in endless courses, or could run OOM in a few hours.
|
// Don't save life stats in endless courses, or could run OOM in a few hours.
|
||||||
@@ -462,6 +524,8 @@ public:
|
|||||||
static int FullCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->FullCombo()); return 1; }
|
static int FullCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->FullCombo()); return 1; }
|
||||||
static int MaxCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->GetMaxCombo().cnt); return 1; }
|
static int MaxCombo( T* p, lua_State *L ) { lua_pushnumber(L, p->GetMaxCombo().cnt); return 1; }
|
||||||
static int GetGrade( T* p, lua_State *L ) { lua_pushnumber(L, p->GetGrade()); return 1; }
|
static int GetGrade( T* p, lua_State *L ) { lua_pushnumber(L, p->GetGrade()); return 1; }
|
||||||
|
static int GetLessonScoreActual( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScoreActual()); return 1; }
|
||||||
|
static int GetLessonScorePossible( T* p, lua_State *L ) { lua_pushnumber(L, p->GetLessonScorePossible()); return 1; }
|
||||||
|
|
||||||
static void Register(lua_State *L)
|
static void Register(lua_State *L)
|
||||||
{
|
{
|
||||||
@@ -471,6 +535,8 @@ public:
|
|||||||
ADD_METHOD( FullCombo )
|
ADD_METHOD( FullCombo )
|
||||||
ADD_METHOD( MaxCombo )
|
ADD_METHOD( MaxCombo )
|
||||||
ADD_METHOD( GetGrade )
|
ADD_METHOD( GetGrade )
|
||||||
|
ADD_METHOD( GetLessonScoreActual )
|
||||||
|
ADD_METHOD( GetLessonScorePossible )
|
||||||
Luna<T>::Register( L );
|
Luna<T>::Register( L );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ public:
|
|||||||
float GetPercentDancePoints() const;
|
float GetPercentDancePoints() const;
|
||||||
float GetCurMaxPercentDancePoints() const;
|
float GetCurMaxPercentDancePoints() const;
|
||||||
|
|
||||||
|
int GetLessonScoreActual() const;
|
||||||
|
int GetLessonScorePossible() const;
|
||||||
|
void ResetScoreForLesson();
|
||||||
|
|
||||||
vector<Steps*> vpPlayedSteps;
|
vector<Steps*> vpPlayedSteps;
|
||||||
vector<Steps*> vpPossibleSteps;
|
vector<Steps*> vpPossibleSteps;
|
||||||
float fAliveSeconds; // how far into the music did they last before failing? Updated by Gameplay, scaled by music rate.
|
float fAliveSeconds; // how far into the music did they last before failing? Updated by Gameplay, scaled by music rate.
|
||||||
|
|||||||
@@ -82,9 +82,6 @@ AutoScreenMessage( SM_StartLoadingNextSong )
|
|||||||
// received while STATE_OUTRO
|
// received while STATE_OUTRO
|
||||||
AutoScreenMessage( SM_GoToScreenAfterBack )
|
AutoScreenMessage( SM_GoToScreenAfterBack )
|
||||||
|
|
||||||
AutoScreenMessage( SM_BeginFailed )
|
|
||||||
AutoScreenMessage( SM_LeaveGameplay )
|
|
||||||
|
|
||||||
// received while STATE_INTRO
|
// received while STATE_INTRO
|
||||||
AutoScreenMessage( SM_StartHereWeGo )
|
AutoScreenMessage( SM_StartHereWeGo )
|
||||||
AutoScreenMessage( SM_StopHereWeGo )
|
AutoScreenMessage( SM_StopHereWeGo )
|
||||||
@@ -1051,6 +1048,14 @@ void ScreenGameplay::LoadCourseSongNumber( int iSongNumber )
|
|||||||
SCREENMAN->ZeroNextUpdate();
|
SCREENMAN->ZeroNextUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenGameplay::ReloadCurrentSong()
|
||||||
|
{
|
||||||
|
FOREACH_EnabledPlayerInfoNotDummy( m_vPlayerInfo, pi )
|
||||||
|
pi->GetPlayerStageStats()->iSongsPlayed--;
|
||||||
|
|
||||||
|
LoadNextSong();
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenGameplay::LoadNextSong()
|
void ScreenGameplay::LoadNextSong()
|
||||||
{
|
{
|
||||||
GAMESTATE->ResetMusicStatistics();
|
GAMESTATE->ResetMusicStatistics();
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class ScoreKeeper;
|
|||||||
class PlayerScoreList;
|
class PlayerScoreList;
|
||||||
|
|
||||||
AutoScreenMessage( SM_NotesEnded )
|
AutoScreenMessage( SM_NotesEnded )
|
||||||
|
AutoScreenMessage( SM_BeginFailed )
|
||||||
|
AutoScreenMessage( SM_LeaveGameplay )
|
||||||
|
|
||||||
class PlayerInfo
|
class PlayerInfo
|
||||||
{
|
{
|
||||||
@@ -132,6 +134,7 @@ protected:
|
|||||||
|
|
||||||
bool IsLastSong();
|
bool IsLastSong();
|
||||||
void SetupSong( int iSongIndex );
|
void SetupSong( int iSongIndex );
|
||||||
|
void ReloadCurrentSong();
|
||||||
void LoadNextSong();
|
void LoadNextSong();
|
||||||
void LoadCourseSongNumber( int SongNumber );
|
void LoadCourseSongNumber( int SongNumber );
|
||||||
float StartPlayingSong(float MinTimeToNotes, float MinTimeToMusic);
|
float StartPlayingSong(float MinTimeToNotes, float MinTimeToMusic);
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "GameState.h"
|
#include "GameState.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
|
#include "StatsManager.h"
|
||||||
|
|
||||||
REGISTER_SCREEN_CLASS( ScreenGameplayLesson );
|
REGISTER_SCREEN_CLASS( ScreenGameplayLesson );
|
||||||
ScreenGameplayLesson::ScreenGameplayLesson( CString sName ) : ScreenGameplayNormal( sName )
|
ScreenGameplayLesson::ScreenGameplayLesson( CString sName ) : ScreenGameplayNormal( sName )
|
||||||
{
|
{
|
||||||
LOG->Trace( "ScreenGameplayLesson::ScreenGameplayLesson()" );
|
LOG->Trace( "ScreenGameplayLesson::ScreenGameplayLesson()" );
|
||||||
|
|
||||||
m_iCurrentLessonPageIndex = 0;
|
m_iCurrentPageIndex = 0;
|
||||||
|
m_Try = Try_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenGameplayLesson::Init()
|
void ScreenGameplayLesson::Init()
|
||||||
@@ -27,16 +29,16 @@ void ScreenGameplayLesson::Init()
|
|||||||
m_DancingState = STATE_DANCING;
|
m_DancingState = STATE_DANCING;
|
||||||
|
|
||||||
|
|
||||||
// Load lessons
|
// Load pages
|
||||||
Song *pSong = GAMESTATE->m_pCurSong;
|
Song *pSong = GAMESTATE->m_pCurSong;
|
||||||
CString sDir = pSong->GetSongDir();
|
CString sDir = pSong->GetSongDir();
|
||||||
vector<CString> vs;
|
vector<CString> vs;
|
||||||
GetDirListing( sDir+"Page*", vs, true, true );
|
GetDirListing( sDir+"Page*", vs, true, true );
|
||||||
m_vLessonPages.resize( vs.size() );
|
m_vPages.resize( vs.size() );
|
||||||
FOREACH( CString, vs, s )
|
FOREACH( CString, vs, s )
|
||||||
{
|
{
|
||||||
int i = s - vs.begin();
|
int i = s - vs.begin();
|
||||||
AutoActor &aa = m_vLessonPages[i];
|
AutoActor &aa = m_vPages[i];
|
||||||
|
|
||||||
|
|
||||||
LUA->SetGlobal( "PageIndex", i );
|
LUA->SetGlobal( "PageIndex", i );
|
||||||
@@ -46,28 +48,44 @@ void ScreenGameplayLesson::Init()
|
|||||||
LUA->UnsetGlobal( "NumPages" );
|
LUA->UnsetGlobal( "NumPages" );
|
||||||
|
|
||||||
|
|
||||||
aa->SetDrawOrder( DRAW_ORDER_OVERLAY );
|
aa->SetDrawOrder( DRAW_ORDER_OVERLAY+1 );
|
||||||
this->AddChild( aa );
|
this->AddChild( aa );
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SortByDrawOrder();
|
this->SortByDrawOrder();
|
||||||
|
|
||||||
// Show the first lesson page
|
// Show the first lesson page
|
||||||
if( !m_vLessonPages.empty() )
|
if( !m_vPages.empty() )
|
||||||
{
|
{
|
||||||
AutoActor &aa = m_vLessonPages[0];
|
AutoActor &aa = m_vPages[0];
|
||||||
aa->PlayCommand( "Show" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FOREACH( AutoActor, m_vLessonPages, aa )
|
FOREACH( AutoActor, m_vPages, aa )
|
||||||
|
{
|
||||||
|
bool bIsFirst = aa == m_vPages.begin();
|
||||||
|
(*aa)->PlayCommand( bIsFirst ? "Show" : "Hide" );
|
||||||
(*aa)->PlayCommand( "On" );
|
(*aa)->PlayCommand( "On" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// load Try graphics
|
||||||
|
for( int i=0; i<NUM_Try; i++ )
|
||||||
|
{
|
||||||
|
CString s = ssprintf("Try%d",i+1);
|
||||||
|
m_sprTry[i].Load( THEME->GetPathB(m_sName,s) );
|
||||||
|
m_sprTry[i]->PlayCommand( "Hide" );
|
||||||
|
m_sprTry[i]->SetDrawOrder( DRAW_ORDER_OVERLAY+1 );
|
||||||
|
this->AddChild( m_sprTry[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SortByDrawOrder();
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenGameplayLesson::Input( const InputEventPlus &input )
|
void ScreenGameplayLesson::Input( const InputEventPlus &input )
|
||||||
{
|
{
|
||||||
//LOG->Trace( "ScreenGameplayLesson::Input()" );
|
//LOG->Trace( "ScreenGameplayLesson::Input()" );
|
||||||
|
|
||||||
if( m_iCurrentLessonPageIndex != -1 )
|
if( m_iCurrentPageIndex != -1 )
|
||||||
{
|
{
|
||||||
// show a lesson page
|
// show a lesson page
|
||||||
Screen::Input( input );
|
Screen::Input( input );
|
||||||
@@ -83,16 +101,37 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
{
|
{
|
||||||
if( SM == SM_NotesEnded )
|
if( SM == SM_NotesEnded )
|
||||||
{
|
{
|
||||||
bool bShowingAPage = m_iCurrentLessonPageIndex != -1;
|
bool bShowingAPage = m_iCurrentPageIndex != -1;
|
||||||
|
|
||||||
|
// While showing a page, loop the music.
|
||||||
if( bShowingAPage )
|
if( bShowingAPage )
|
||||||
{
|
{
|
||||||
// reload and loop
|
ResetAndRestartCurrentSong();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// show finish message if passed, loop if failed
|
bool bCleared = false; // TODO
|
||||||
|
bool bAnyTriesLeft = m_Try + 1 < NUM_Try;
|
||||||
|
|
||||||
|
if( bCleared )
|
||||||
|
{
|
||||||
|
this->HandleScreenMessage( SM_LeaveGameplay );
|
||||||
}
|
}
|
||||||
|
else if( bAnyTriesLeft )
|
||||||
|
{
|
||||||
|
ResetAndRestartCurrentSong();
|
||||||
|
|
||||||
|
m_sprTry[m_Try]->PlayCommand( "Hide" );
|
||||||
|
m_Try = (Try)(m_Try+1);
|
||||||
|
m_sprTry[m_Try]->PlayCommand( "Show" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sprTry[m_Try]->PlayCommand( "Hide" );
|
||||||
|
this->HandleScreenMessage( SM_BeginFailed );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return; // handled
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenGameplay::HandleScreenMessage( SM );
|
ScreenGameplay::HandleScreenMessage( SM );
|
||||||
@@ -100,41 +139,51 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
|
|||||||
|
|
||||||
void ScreenGameplayLesson::MenuStart( PlayerNumber pn )
|
void ScreenGameplayLesson::MenuStart( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
if( m_iCurrentLessonPageIndex == -1 )
|
if( m_iCurrentPageIndex == -1 )
|
||||||
return;
|
return;
|
||||||
ChangeLessonPage( +1 );
|
ChangeLessonPage( +1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenGameplayLesson::MenuBack( PlayerNumber pn )
|
void ScreenGameplayLesson::MenuBack( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
if( m_iCurrentLessonPageIndex == -1 )
|
if( m_iCurrentPageIndex == -1 )
|
||||||
return;
|
return;
|
||||||
ChangeLessonPage( -1 );
|
ChangeLessonPage( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenGameplayLesson::ChangeLessonPage( int iDir )
|
void ScreenGameplayLesson::ChangeLessonPage( int iDir )
|
||||||
{
|
{
|
||||||
if( m_iCurrentLessonPageIndex + iDir < 0 )
|
if( m_iCurrentPageIndex + iDir < 0 )
|
||||||
{
|
{
|
||||||
// don't change
|
// don't change
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if( m_iCurrentLessonPageIndex + iDir >= m_vLessonPages.size() )
|
else if( m_iCurrentPageIndex + iDir >= m_vPages.size() )
|
||||||
{
|
{
|
||||||
// dismissed the last page. Proceed to the "your turn" portion.
|
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
|
||||||
FOREACH( AutoActor, m_vLessonPages, aa )
|
m_iCurrentPageIndex = -1;
|
||||||
(*aa)->PlayCommand( "Off" );
|
m_sprTry[m_Try]->PlayCommand( "Show" );
|
||||||
|
|
||||||
m_iCurrentLessonPageIndex = -1;
|
ResetAndRestartCurrentSong();
|
||||||
|
|
||||||
|
MESSAGEMAN->Broadcast( Message_LessonYourTurn );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Hide" );
|
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
|
||||||
m_iCurrentLessonPageIndex += iDir;
|
m_iCurrentPageIndex += iDir;
|
||||||
m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Show" );
|
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Show" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenGameplayLesson::ResetAndRestartCurrentSong()
|
||||||
|
{
|
||||||
|
STATSMAN->m_CurStageStats.m_player[PLAYER_1].ResetScoreForLesson();
|
||||||
|
m_pSoundMusic->Stop();
|
||||||
|
ReloadCurrentSong();
|
||||||
|
StartPlayingSong( 2, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* ScreenGameplayLesson - Plays whole songs continuously. */
|
/* ScreenGameplayLesson - Shows some explanation pages, then allows 3 tries to pass a song. */
|
||||||
|
|
||||||
#ifndef ScreenGameplayLesson_H
|
#ifndef ScreenGameplayLesson_H
|
||||||
#define ScreenGameplayLesson_H
|
#define ScreenGameplayLesson_H
|
||||||
@@ -20,9 +20,20 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ChangeLessonPage( int iDir );
|
void ChangeLessonPage( int iDir );
|
||||||
|
void ResetAndRestartCurrentSong();
|
||||||
|
|
||||||
vector<AutoActor> m_vLessonPages;
|
vector<AutoActor> m_vPages;
|
||||||
int m_iCurrentLessonPageIndex;
|
int m_iCurrentPageIndex;
|
||||||
|
|
||||||
|
enum Try
|
||||||
|
{
|
||||||
|
Try_1,
|
||||||
|
Try_2,
|
||||||
|
Try_3,
|
||||||
|
NUM_Try
|
||||||
|
};
|
||||||
|
AutoActor m_sprTry[NUM_Try];
|
||||||
|
Try m_Try;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user