add "success/try again" looping logic to lesson mode

This commit is contained in:
Chris Danford
2005-09-09 21:49:29 +00:00
parent 75087b00d4
commit 9580a5f8a4
8 changed files with 171 additions and 31 deletions
+2 -1
View File
@@ -56,7 +56,8 @@ static const CString MessageNames[] = {
"AutosyncChanged",
"PreferredSongGroupChanged",
"PreferredCourseGroupChanged",
"SortOrderChanged"
"SortOrderChanged",
"LessonYourTurn",
};
XToString( Message, NUM_Message );
+1
View File
@@ -72,6 +72,7 @@ enum Message
Message_PreferredSongGroupChanged,
Message_PreferredCourseGroupChanged,
Message_SortOrderChanged,
Message_LessonYourTurn,
NUM_Message, // leave this at the end
Message_Invalud
};
+66
View File
@@ -220,6 +220,68 @@ float PlayerStageStats::GetCurMaxPercentDancePoints() const
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 )
{
// 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 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 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)
{
@@ -471,6 +535,8 @@ public:
ADD_METHOD( FullCombo )
ADD_METHOD( MaxCombo )
ADD_METHOD( GetGrade )
ADD_METHOD( GetLessonScoreActual )
ADD_METHOD( GetLessonScorePossible )
Luna<T>::Register( L );
}
};
+4
View File
@@ -23,6 +23,10 @@ public:
float GetPercentDancePoints() const;
float GetCurMaxPercentDancePoints() const;
int GetLessonScoreActual() const;
int GetLessonScorePossible() const;
void ResetScoreForLesson();
vector<Steps*> vpPlayedSteps;
vector<Steps*> vpPossibleSteps;
float fAliveSeconds; // how far into the music did they last before failing? Updated by Gameplay, scaled by music rate.
+8 -3
View File
@@ -82,9 +82,6 @@ AutoScreenMessage( SM_StartLoadingNextSong )
// received while STATE_OUTRO
AutoScreenMessage( SM_GoToScreenAfterBack )
AutoScreenMessage( SM_BeginFailed )
AutoScreenMessage( SM_LeaveGameplay )
// received while STATE_INTRO
AutoScreenMessage( SM_StartHereWeGo )
AutoScreenMessage( SM_StopHereWeGo )
@@ -1051,6 +1048,14 @@ void ScreenGameplay::LoadCourseSongNumber( int iSongNumber )
SCREENMAN->ZeroNextUpdate();
}
void ScreenGameplay::ReloadCurrentSong()
{
FOREACH_EnabledPlayerInfoNotDummy( m_vPlayerInfo, pi )
pi->GetPlayerStageStats()->iSongsPlayed--;
LoadNextSong();
}
void ScreenGameplay::LoadNextSong()
{
GAMESTATE->ResetMusicStatistics();
+3
View File
@@ -34,6 +34,8 @@ class ScoreKeeper;
class PlayerScoreList;
AutoScreenMessage( SM_NotesEnded )
AutoScreenMessage( SM_BeginFailed )
AutoScreenMessage( SM_LeaveGameplay )
class PlayerInfo
{
@@ -132,6 +134,7 @@ protected:
bool IsLastSong();
void SetupSong( int iSongIndex );
void ReloadCurrentSong();
void LoadNextSong();
void LoadCourseSongNumber( int SongNumber );
float StartPlayingSong(float MinTimeToNotes, float MinTimeToMusic);
+73 -24
View File
@@ -3,13 +3,15 @@
#include "RageLog.h"
#include "GameState.h"
#include "PrefsManager.h"
#include "StatsManager.h"
REGISTER_SCREEN_CLASS( ScreenGameplayLesson );
ScreenGameplayLesson::ScreenGameplayLesson( CString sName ) : ScreenGameplayNormal( sName )
{
LOG->Trace( "ScreenGameplayLesson::ScreenGameplayLesson()" );
m_iCurrentLessonPageIndex = 0;
m_iCurrentPageIndex = 0;
m_Try = Try_1;
}
void ScreenGameplayLesson::Init()
@@ -27,16 +29,16 @@ void ScreenGameplayLesson::Init()
m_DancingState = STATE_DANCING;
// Load lessons
// Load pages
Song *pSong = GAMESTATE->m_pCurSong;
CString sDir = pSong->GetSongDir();
vector<CString> vs;
GetDirListing( sDir+"Page*", vs, true, true );
m_vLessonPages.resize( vs.size() );
m_vPages.resize( vs.size() );
FOREACH( CString, vs, s )
{
int i = s - vs.begin();
AutoActor &aa = m_vLessonPages[i];
AutoActor &aa = m_vPages[i];
LUA->SetGlobal( "PageIndex", i );
@@ -46,28 +48,44 @@ void ScreenGameplayLesson::Init()
LUA->UnsetGlobal( "NumPages" );
aa->SetDrawOrder( DRAW_ORDER_OVERLAY );
aa->SetDrawOrder( DRAW_ORDER_OVERLAY+1 );
this->AddChild( aa );
}
this->SortByDrawOrder();
// Show the first lesson page
if( !m_vLessonPages.empty() )
if( !m_vPages.empty() )
{
AutoActor &aa = m_vLessonPages[0];
aa->PlayCommand( "Show" );
AutoActor &aa = m_vPages[0];
}
FOREACH( AutoActor, m_vLessonPages, aa )
FOREACH( AutoActor, m_vPages, aa )
{
bool bIsFirst = aa == m_vPages.begin();
(*aa)->PlayCommand( bIsFirst ? "Show" : "Hide" );
(*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 )
{
//LOG->Trace( "ScreenGameplayLesson::Input()" );
if( m_iCurrentLessonPageIndex != -1 )
if( m_iCurrentPageIndex != -1 )
{
// show a lesson page
Screen::Input( input );
@@ -83,16 +101,37 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_NotesEnded )
{
bool bShowingAPage = m_iCurrentLessonPageIndex != -1;
bool bShowingAPage = m_iCurrentPageIndex != -1;
// While showing a page, loop the music.
if( bShowingAPage )
{
// reload and loop
ResetAndRestartCurrentSong();
}
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 );
@@ -100,41 +139,51 @@ void ScreenGameplayLesson::HandleScreenMessage( const ScreenMessage SM )
void ScreenGameplayLesson::MenuStart( PlayerNumber pn )
{
if( m_iCurrentLessonPageIndex == -1 )
if( m_iCurrentPageIndex == -1 )
return;
ChangeLessonPage( +1 );
}
void ScreenGameplayLesson::MenuBack( PlayerNumber pn )
{
if( m_iCurrentLessonPageIndex == -1 )
if( m_iCurrentPageIndex == -1 )
return;
ChangeLessonPage( -1 );
}
void ScreenGameplayLesson::ChangeLessonPage( int iDir )
{
if( m_iCurrentLessonPageIndex + iDir < 0 )
if( m_iCurrentPageIndex + iDir < 0 )
{
// don't change
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.
FOREACH( AutoActor, m_vLessonPages, aa )
(*aa)->PlayCommand( "Off" );
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
m_iCurrentPageIndex = -1;
m_sprTry[m_Try]->PlayCommand( "Show" );
m_iCurrentLessonPageIndex = -1;
ResetAndRestartCurrentSong();
MESSAGEMAN->Broadcast( Message_LessonYourTurn );
}
else
{
m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Hide" );
m_iCurrentLessonPageIndex += iDir;
m_vLessonPages[m_iCurrentLessonPageIndex]->PlayCommand( "Show" );
m_vPages[m_iCurrentPageIndex]->PlayCommand( "Hide" );
m_iCurrentPageIndex += iDir;
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
* All rights reserved.
+14 -3
View File
@@ -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
#define ScreenGameplayLesson_H
@@ -20,9 +20,20 @@ public:
protected:
void ChangeLessonPage( int iDir );
void ResetAndRestartCurrentSong();
vector<AutoActor> m_vLessonPages;
int m_iCurrentLessonPageIndex;
vector<AutoActor> m_vPages;
int m_iCurrentPageIndex;
enum Try
{
Try_1,
Try_2,
Try_3,
NUM_Try
};
AutoActor m_sprTry[NUM_Try];
Try m_Try;
};
#endif