more progress on Ranking

This commit is contained in:
Chris Danford
2003-01-27 02:00:38 +00:00
parent 8870fa3044
commit 025539e52c
15 changed files with 277 additions and 152 deletions
+9 -9
View File
@@ -381,37 +381,37 @@ MarvelousP1X=230
MarvelousP2X=410
MarvelousOniP1X=230
MarvelousOniP2X=410
MarvelousY=176
MarvelousY=160
PerfectP1X=230
PerfectP2X=410
PerfectOniP1X=230
PerfectOniP2X=410
PerfectY=176
PerfectY=192
GreatP1X=230
GreatP2X=410
GreatOniP1X=230
GreatOniP2X=410
GreatY=208
GreatY=224
GoodP1X=230
GoodP2X=410
GoodOniP1X=230
GoodOniP2X=410
GoodY=240
GoodY=256
BooP1X=230
BooP2X=410
BooOniP1X=230
BooOniP2X=410
BooY=272
BooY=288
MissP1X=230
MissP2X=410
MissOniP1X=230
MissOniP2X=410
MissY=304
MissY=320
OKP1X=230
OKP2X=410
OKOniP1X=230
OKOniP2X=410
OKY=336
OKY=352
MaxComboP1X=134
MaxComboP2X=578
MaxComboOniP1X=1000 // off screen
@@ -774,11 +774,11 @@ LineSpacingX=0
LineSpacingY=60
BulletsStartX=100
BulletsStartY=140
NamesStartX=250
NamesStartX=180
NamesStartY=140
NamesZoom=1.2
NamesColor=0.8,0.8,1,1
ScoresStartX=450
ScoresStartX=520
ScoresStartY=140
ScoresZoom=1.2
ScoresColor=0.8,0.8,1,1
+21 -29
View File
@@ -36,7 +36,7 @@ Course::Course()
//
unsigned i, j;
for( i=0; i<NUM_NOTES_TYPES; i++ )
for( j=0; j<NUM_HIGH_SCORE_LINES; j++ )
for( j=0; j<NUM_RANKING_LINES; j++ )
{
m_MachineScores[i][j].iDancePoints = 0;
m_MachineScores[i][j].fSurviveTime = 0;
@@ -305,77 +305,69 @@ int Course::GetNumStages() const
}
bool Course::IsNewMachineRecord( PlayerNumber pn, int iDancePoints, float fSurviveTime ) const // return true if this would be a new machine record
{
for( int i=0; i<NUM_HIGH_SCORE_LINES; i++ )
{
const MachineScore& hs = m_MachineScores[GAMESTATE->m_CurStyle][i];
if( iDancePoints > hs.iDancePoints )
return true;
}
return false;
}
struct MachineScoreAndPlayerNumber : public Course::MachineScore
struct CourseScoreToInsert
{
PlayerNumber pn;
int iDancePoints;
float fSurviveTime;
static int CompareDescending( const MachineScoreAndPlayerNumber &hs1, const MachineScoreAndPlayerNumber &hs2 )
static int CompareDescending( const CourseScoreToInsert &hs1, const CourseScoreToInsert &hs2 )
{
if( hs1.iDancePoints > hs2.iDancePoints ) return -1;
else if( hs1.iDancePoints == hs2.iDancePoints ) return 0;
else return +1;
}
static void SortDescending( vector<MachineScoreAndPlayerNumber>& vHSout )
static void SortDescending( vector<CourseScoreToInsert>& vHSout )
{
sort( vHSout.begin(), vHSout.end(), CompareDescending );
}
};
void Course::AddMachineRecord( int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ) // set iNewRecordIndex = -1 if not a new record
void Course::AddMachineRecords( NotesType nt, int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iRankingIndexOut[NUM_PLAYERS] ) // set iNewRecordIndex = -1 if not a new record
{
vector<MachineScoreAndPlayerNumber> vHS;
vector<CourseScoreToInsert> vHS;
for( int p=0; p<NUM_PLAYERS; p++ )
{
iNewRecordIndexOut[p] = -1;
iRankingIndexOut[p] = -1;
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
MachineScoreAndPlayerNumber hs;
CourseScoreToInsert hs;
hs.iDancePoints = iDancePoints[p];
hs.fSurviveTime = fSurviveTime[p];
hs.sName = ""; // this must be filled in later!
hs.pn = (PlayerNumber)p;
vHS.push_back( hs );
}
// Sort descending before inserting.
// This guarantees that a high score will not switch poitions on us when we later insert scores for the other player
MachineScoreAndPlayerNumber::SortDescending( vHS );
CourseScoreToInsert::SortDescending( vHS );
for( unsigned i=0; i<vHS.size(); i++ )
{
MachineScoreAndPlayerNumber& newHS = vHS[i];
MachineScore* machineScores = m_MachineScores[GAMESTATE->m_CurStyle];
for( int i=0; i<NUM_HIGH_SCORE_LINES; i++ )
CourseScoreToInsert& newHS = vHS[i];
MachineScore* machineScores = m_MachineScores[nt];
for( int i=0; i<NUM_RANKING_LINES; i++ )
{
if( newHS.iDancePoints > machineScores[i].iDancePoints )
{
// We found the insert point. Shift down.
for( int j=i+1; j<NUM_HIGH_SCORE_LINES; j++ )
for( int j=i+1; j<NUM_RANKING_LINES; j++ )
machineScores[j] = machineScores[j-1];
// insert
machineScores[i] = newHS;
iNewRecordIndexOut[newHS.pn] = i;
machineScores[i].fSurviveTime = newHS.fSurviveTime;
machineScores[i].iDancePoints = newHS.iDancePoints;
machineScores[i].sName = "STEP";
iRankingIndexOut[newHS.pn] = i;
}
}
}
}
bool Course::AddMemCardRecord( PlayerNumber pn, int iDancePoints, float fSurviveTime ) // return true if new record
bool Course::AddMemCardRecord( PlayerNumber pn, NotesType nt, int iDancePoints, float fSurviveTime ) // return true if new record
{
MemCardScore& hs = m_MemCardScores[GAMESTATE->m_CurStyle][pn];
MemCardScore& hs = m_MemCardScores[nt][pn];
if( iDancePoints > hs.iDancePoints )
{
hs.iDancePoints = iDancePoints;
+3 -6
View File
@@ -64,18 +64,15 @@ public:
int iDancePoints;
float fSurviveTime;
CString sName;
} m_MachineScores[NUM_NOTES_TYPES][NUM_HIGH_SCORE_LINES]; // sorted highest to lowest by iDancePoints
bool IsNewMachineRecord( PlayerNumber pn, int iDancePoints, float fSurviveTime ) const; // return true if this is would be a new machine record
void AddMachineRecord( int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record
} m_MachineScores[NUM_NOTES_TYPES][NUM_RANKING_LINES]; // sorted highest to lowest by iDancePoints
void AddMachineRecords( NotesType nt, int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iLineIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record
struct MemCardScore
{
int iDancePoints;
float fSurviveTime;
} m_MemCardScores[NUM_NOTES_TYPES][NUM_PLAYERS];
bool AddMemCardRecord( PlayerNumber pn, int iDancePoints, float fSurviveTime ); // return true if this is a new record
bool AddMemCardRecord( PlayerNumber pn, NotesType nt, int iDancePoints, float fSurviveTime ); // return true if this is a new record
private:
+3 -2
View File
@@ -174,7 +174,7 @@ inline int HoldNoteScoreToDancePoints( HoldNoteScore hns )
//
// High Score stuff
// Ranking stuff
//
enum RankingCategory
{
@@ -187,6 +187,7 @@ enum RankingCategory
RankingCategory AverageMeterToRankingCategory( float fAverageMeter );
const int NUM_HIGH_SCORE_LINES = 5;
const int NUM_RANKING_LINES = 5;
const int MAX_RANKING_NAME_LENGTH = 4;
#endif
+15 -2
View File
@@ -84,7 +84,7 @@ void GameState::Reset()
for( p=0; p<NUM_PLAYERS; p++ )
{
m_LastRankingCategory[p] = (RankingCategory)-1;
m_iLastHighScoreIndex[p] = -1;
m_iLastRankingIndex[p] = -1;
}
}
@@ -249,4 +249,17 @@ bool GameState::HasEarnedExtraStage()
}
}
return false;
}
}
void GameState::GetFinalEvalStatsAndSongs( StageStats& statsOut, vector<Song*>& vSongsOut )
{
statsOut = StageStats();
// Show stats only for the latest 3 normal songs + passed extra stages
int iNumSongsToThrowAway = max( 0, PREFSMAN->m_iNumArcadeStages-3 );
for( unsigned i=iNumSongsToThrowAway; i<GAMESTATE->m_vPassedStageStats.size(); i++ )
{
statsOut += GAMESTATE->m_vPassedStageStats[i];
vSongsOut.push_back( GAMESTATE->m_vPassedStageStats[i].pSong );
}
}
+6 -4
View File
@@ -105,6 +105,7 @@ public:
vector<StageStats> m_vPassedStageStats; // Only useful in Arcade for final evaluation
// A song is only inserted here if at least one player passed.
// StageStats are added by the Evaluation screen
void GetFinalEvalStatsAndSongs( StageStats& statsOut, vector<Song*>& vSongsOut ); // shown on arcade final evaluation
Grade GetCurrentGrade( PlayerNumber pn ); // grade so far
@@ -117,10 +118,11 @@ public:
bool HasEarnedExtraStage();
// High score stuff.
// These should be set by final evaluation, and used by ScreenNameEntry and ScreenRanking
RankingCategory m_LastRankingCategory[NUM_PLAYERS]; // meaningless if a course was played
int m_iLastHighScoreIndex[NUM_PLAYERS]; // -1 if no new high score
// Filled in by ScreenNameEntry and used by ScreenRanking to flash the recent high scores
NotesType m_LastRankingNotesType; // meaningless if a course was played
RankingCategory m_LastRankingCategory[NUM_PLAYERS]; // meaningless if a course was played
Course* m_pLastPlayedCourse; // meaningless if arcade was played
int m_iLastRankingIndex[NUM_PLAYERS]; // -1 if no new high score
};
+1 -1
View File
@@ -44,7 +44,7 @@ void GrayArrow::Update( float fDeltaTime )
int OnState = (GetNumStates() == 3)? 1: 0;
int OffState = (GetNumStates() == 3)? 2: 1;
if( !GAMESTATE->m_bPastHereWeGo )
if( !GAMESTATE->m_fSongBeat > 0 )
{
SetState( IdleState );
return;
+10 -22
View File
@@ -105,10 +105,10 @@ float JUDGE_Y( int l ) {
}
const ScreenMessage SM_GoToSelectMusic = ScreenMessage(SM_User+1);
const ScreenMessage SM_GoToSelectCourse = ScreenMessage(SM_User+2);
const ScreenMessage SM_GoToFinalEvaluation = ScreenMessage(SM_User+3);
const ScreenMessage SM_GoToMusicScroll = ScreenMessage(SM_User+4);
const ScreenMessage SM_PlayCheer = ScreenMessage(SM_User+5);
const ScreenMessage SM_GoToSelectCourse = ScreenMessage(SM_User+3);
const ScreenMessage SM_GoToFinalEvaluation = ScreenMessage(SM_User+4);
const ScreenMessage SM_GoToGameFinished = ScreenMessage(SM_User+5);
const ScreenMessage SM_PlayCheer = ScreenMessage(SM_User+6);
ScreenEvaluation::ScreenEvaluation( bool bSummary )
@@ -140,15 +140,7 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary )
switch( m_ResultMode )
{
case RM_ARCADE_SUMMARY:
{
// Show stats only for the latest 3 normal songs + passed extra stages
int iNumSongsToThrowAway = max( 0, PREFSMAN->m_iNumArcadeStages-3 );
for( unsigned i=iNumSongsToThrowAway; i<GAMESTATE->m_vPassedStageStats.size(); i++ )
{
stageStats += GAMESTATE->m_vPassedStageStats[i];
vSongsToShow.push_back( GAMESTATE->m_vPassedStageStats[i].pSong );
}
}
GAMESTATE->GetFinalEvalStatsAndSongs( stageStats, vSongsToShow );
break;
case RM_ARCADE_STAGE:
case RM_COURSE:
@@ -256,7 +248,6 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary )
//
bool bNewRecord[NUM_PLAYERS];
memset( bNewRecord, 0, sizeof(bNewRecord) );
m_bGoToNameEntry = false;
for( p=0; p<NUM_PLAYERS; p++ )
{
if( !GAMESTATE->IsPlayerEnabled(p) || grade[p] == GRADE_E )
@@ -273,16 +264,13 @@ ScreenEvaluation::ScreenEvaluation( bool bSummary )
break;
case RM_ARCADE_SUMMARY:
{
float fAverageMeter = stageStats.iMeter[p] / (float)PREFSMAN->m_iNumArcadeStages; // intentional: doesn't count extra stage
RankingCategory hsc = AverageMeterToRankingCategory( fAverageMeter );
m_bGoToNameEntry |= SONGMAN->IsNewMachineRecord( hsc, stageStats.fScore[p] );
}
break;
case RM_COURSE:
{
Course* pCourse = GAMESTATE->m_pCurCourse;
pCourse->IsNewMachineRecord( (PlayerNumber)p, stageStats.iActualDancePoints[p], stageStats.fAliveSeconds[p] );
m_bGoToNameEntry |= true;
NotesType nt = GAMESTATE->GetCurrentStyleDef()->m_NotesType;
pCourse->AddMemCardRecord( (PlayerNumber)p, nt, stageStats.iActualDancePoints[p], stageStats.fAliveSeconds[p] );
}
break;
default:
@@ -758,8 +746,8 @@ void ScreenEvaluation::HandleScreenMessage( const ScreenMessage SM )
case SM_GoToSelectCourse:
SCREENMAN->SetNewScreen( "ScreenSelectCourse" );
break;
case SM_GoToMusicScroll:
SCREENMAN->SetNewScreen( "ScreenMusicScroll" );
case SM_GoToGameFinished:
SCREENMAN->SetNewScreen( "ScreenNameEntry" );
break;
case SM_GoToFinalEvaluation:
SCREENMAN->SetNewScreen( "ScreenFinalEvaluation" );
@@ -830,7 +818,7 @@ void ScreenEvaluation::MenuStart( PlayerNumber pn )
else if( m_ResultMode == RM_ARCADE_STAGE && GAMESTATE->m_iCurrentStageIndex < PREFSMAN->m_iNumArcadeStages-1 )
m_Menu.TweenOffScreenToMenu( SM_GoToSelectMusic );
else
m_Menu.TweenOffScreenToBlack( SM_GoToMusicScroll, false );
m_Menu.TweenOffScreenToBlack( SM_GoToGameFinished, false );
}
GAMESTATE->m_iCurrentStageIndex++; // Increment the stage counter.
-2
View File
@@ -78,8 +78,6 @@ protected:
Sprite m_sprNewRecord[NUM_PLAYERS];
bool m_bGoToNameEntry;
bool m_bTryExtraStage;
Sprite m_sprTryExtraStage;
};
+133 -28
View File
@@ -90,6 +90,8 @@ ScreenNameEntry::ScreenNameEntry()
{
LOG->Trace( "ScreenNameEntry::ScreenNameEntry()" );
// update cache
g_fCharsZoomSmall = CHARS_ZOOM_SMALL;
g_fCharsZoomLarge = CHARS_ZOOM_LARGE;
@@ -102,19 +104,80 @@ ScreenNameEntry::ScreenNameEntry()
g_fFakeBeatsPerSec = FAKE_BEATS_PER_SEC;
// DEBUGGING STUFF
// DEBUGGING STUFF
// GAMESTATE->m_CurGame = GAME_DANCE;
// GAMESTATE->m_CurStyle = STYLE_DANCE_SINGLE;
// GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE;
// GAMESTATE->m_bSideIsJoined[PLAYER_1] = true;
// GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
// GAMESTATE->m_LastRankingCategory[PLAYER_1] = RANKING_A;
// GAMESTATE->m_iLastHighScoreIndex[PLAYER_1] = 0;
// GAMESTATE->m_iLastRankingIndex[PLAYER_1] = 0;
// Find out if any of the players deserve to enter their name
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_ARCADE:
{
StageStats stageStats;
vector<Song*> vSongs;
GAMESTATE->GetFinalEvalStatsAndSongs( stageStats, vSongs );
float fAverageMeter[NUM_PLAYERS];
RankingCategory cat[NUM_PLAYERS];
float fScore[NUM_PLAYERS];
int iRankingIndex[NUM_PLAYERS];
for( int p=0; p<NUM_PLAYERS; p++ )
{
fAverageMeter[p] = stageStats.iMeter[p] / (float)PREFSMAN->m_iNumArcadeStages;
cat[p] = AverageMeterToRankingCategory( fAverageMeter[p] );
fScore[p] = stageStats.fScore[p];
}
NotesType nt = GAMESTATE->GetCurrentStyleDef()->m_NotesType;
SONGMAN->AddMachineRecords( nt, cat, fScore, iRankingIndex );
GAMESTATE->m_LastRankingNotesType = nt;
COPY( GAMESTATE->m_LastRankingCategory, cat );
COPY( GAMESTATE->m_iLastRankingIndex, iRankingIndex );
}
break;
case PLAY_MODE_NONSTOP:
case PLAY_MODE_ONI:
case PLAY_MODE_ENDLESS:
{
StageStats stageStats;
vector<Song*> vSongs;
GAMESTATE->GetFinalEvalStatsAndSongs( stageStats, vSongs );
Course* pCourse = GAMESTATE->m_pCurCourse;
int iDancePoints[NUM_PLAYERS];
float fAliveSeconds[NUM_PLAYERS];
int iRankingIndex[NUM_PLAYERS];
for( int p=0; p<NUM_PLAYERS; p++ )
{
iDancePoints[p] = stageStats.iActualDancePoints[p];
fAliveSeconds[p] = stageStats.fAliveSeconds[p];
}
NotesType nt = GAMESTATE->GetCurrentStyleDef()->m_NotesType;
pCourse->AddMachineRecords( nt, iDancePoints, fAliveSeconds, iRankingIndex );
GAMESTATE->m_LastRankingNotesType = nt;
GAMESTATE->m_pLastPlayedCourse = pCourse;
COPY( GAMESTATE->m_iLastRankingIndex, iRankingIndex );
}
break;
}
GAMESTATE->m_bPastHereWeGo = true; // enable the gray arrows
m_Background.LoadFromAniDir( THEME->GetPathTo("BGAnimations","name entry") );
@@ -122,8 +185,10 @@ ScreenNameEntry::ScreenNameEntry()
for( int p=0; p<NUM_PLAYERS; p++ )
{
bool bNewHighScore = GAMESTATE->m_iLastHighScoreIndex[p] != -1;
m_bConfirmedName[p] = !bNewHighScore; // false if they made a new high score
bool bNewHighScore = GAMESTATE->m_iLastRankingIndex[p] != -1;
m_bStillEnteringName[p] = bNewHighScore; // false if they made a new high score
for( int i=0; i<MAX_RANKING_NAME_LENGTH; i++ )
m_sSelectedName[p] += ' ';
if( !bNewHighScore )
continue; // skip
@@ -158,7 +223,7 @@ ScreenNameEntry::ScreenNameEntry()
m_textCategory[p].LoadFromFont( THEME->GetPathTo("Fonts","header2") );
m_textCategory[p].SetX( (float)GAMESTATE->GetCurrentStyleDef()->m_iCenterX[p] );
m_textCategory[p].SetY( CATEGORY_Y );
CString sCategoryText = ssprintf("No. %d", GAMESTATE->m_iLastHighScoreIndex[p]+1);
CString sCategoryText = ssprintf("No. %d", GAMESTATE->m_iLastRankingIndex[p]+1);
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_ARCADE:
@@ -176,6 +241,19 @@ ScreenNameEntry::ScreenNameEntry()
this->AddChild( &m_textCategory[p] );
}
bool bAnyStillEntering = false;
for( int p=0; p<NUM_PLAYERS; p++ )
bAnyStillEntering |= m_bStillEnteringName[p];
if( !bAnyStillEntering )
{
this->SendScreenMessage( SM_GoToNextScreen, 0 );
return;
}
m_Timer.SetTimer(TIMER_SECONDS);
m_Timer.SetXY( TIMER_X, TIMER_Y );
this->AddChild( &m_Timer );
@@ -217,8 +295,8 @@ void ScreenNameEntry::DrawPrimitives()
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( m_bConfirmedName[p] )
continue; // don't draw scrolling arrows. They already confirmed.
if( !m_bStillEnteringName[p] )
continue; // don't draw scrolling arrows
float fY = GRAY_ARROWS_Y + GetClosestCharYPos(m_fFakeBeat) - g_iNumCharsToDrawBehind*g_fCharsSpacingY;
int iCharIndex = iStartDrawingIndex % NUM_NAME_CHARS;
@@ -268,28 +346,13 @@ void ScreenNameEntry::Input( const DeviceInput& DeviceI, const InputEventType ty
if( StyleI.IsValid() )
{
m_GrayArrowRow[StyleI.player].Step( StyleI.col );
m_soundStep.Play();
char c = NAME_CHARS[GetClosestCharIndex(m_fFakeBeat)];
m_textSelectedChars[StyleI.player][StyleI.col].SetText( ssprintf("%c",c) );
}
if( MenuI.IsValid() )
{
if( MenuI.button == MENU_BUTTON_START )
if( StyleI.col < MAX_RANKING_NAME_LENGTH )
{
m_GrayArrowRow[StyleI.player].Step( StyleI.col );
m_soundStep.Play();
m_bConfirmedName[MenuI.player] = true;
bool bAllConfirmed = true;
for( int p=0; p<NUM_PLAYERS; p++ )
bAllConfirmed &= m_bConfirmedName[p];
if( bAllConfirmed )
{
if( !m_Fade.IsClosing() )
m_Fade.CloseWipingRight( SM_GoToNextScreen );
}
char c = NAME_CHARS[GetClosestCharIndex(m_fFakeBeat)];
m_textSelectedChars[StyleI.player][StyleI.col].SetText( ssprintf("%c",c) );
m_sSelectedName[StyleI.player][StyleI.col] = c;
}
}
@@ -302,10 +365,52 @@ void ScreenNameEntry::HandleScreenMessage( const ScreenMessage SM )
{
case SM_MenuTimer:
if( !m_Fade.IsClosing() )
{
for( int p=0; p<NUM_PLAYERS; p++ )
this->MenuStart( (PlayerNumber)p );
m_Fade.CloseWipingRight( SM_GoToNextScreen );
}
break;
case SM_GoToNextScreen:
SCREENMAN->SetNewScreen( "ScreenMusicScroll" );
break;
}
}
void ScreenNameEntry::MenuStart( PlayerNumber pn )
{
if( m_bStillEnteringName[pn] )
{
m_soundStep.Play();
m_bStillEnteringName[pn] = false;
TrimRight( m_sSelectedName[pn], " " );
TrimLeft( m_sSelectedName[pn], " " );
if( m_sSelectedName[pn] == "" )
m_sSelectedName[pn] = "STEP";
switch( GAMESTATE->m_PlayMode )
{
case PLAY_MODE_ARCADE:
SONGMAN->m_MachineScores[GAMESTATE->m_LastRankingNotesType][GAMESTATE->m_LastRankingCategory[pn]][GAMESTATE->m_iLastRankingIndex[pn]].sName = m_sSelectedName[pn];
break;
case PLAY_MODE_NONSTOP:
case PLAY_MODE_ONI:
case PLAY_MODE_ENDLESS:
GAMESTATE->m_pLastPlayedCourse->m_MachineScores[GAMESTATE->m_LastRankingNotesType][GAMESTATE->m_iLastRankingIndex[pn]].sName = m_sSelectedName[pn];
break;
default:
ASSERT(0);
}
bool bAnyStillEntering = false;
for( int p=0; p<NUM_PLAYERS; p++ )
bAnyStillEntering |= m_bStillEnteringName[p];
if( !bAnyStillEntering && !m_Fade.IsClosing() )
m_Fade.CloseWipingRight( SM_GoToNextScreen );
}
}
+6 -4
View File
@@ -16,7 +16,6 @@
#include "RandomSample.h"
#include "GrayArrowRow.h"
const int MAX_COLS_IN_NAME_ENTRY = 12;
class ScreenNameEntry : public Screen
{
@@ -29,13 +28,15 @@ public:
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void MenuStart( PlayerNumber pn );
private:
BGAnimation m_Background;
GrayArrowRow m_GrayArrowRow[NUM_PLAYERS];
BitmapText m_textSelectedChars[NUM_PLAYERS][MAX_COLS_IN_NAME_ENTRY];
BitmapText m_textScrollingChars[NUM_PLAYERS][MAX_COLS_IN_NAME_ENTRY];
BitmapText m_textSelectedChars[NUM_PLAYERS][MAX_RANKING_NAME_LENGTH];
BitmapText m_textScrollingChars[NUM_PLAYERS][MAX_RANKING_NAME_LENGTH];
BitmapText m_textCategory[NUM_PLAYERS];
MenuTimer m_Timer;
@@ -44,7 +45,8 @@ private:
RageSound m_soundStep;
float m_fFakeBeat;
bool m_bConfirmedName[NUM_PLAYERS];
CString m_sSelectedName[NUM_PLAYERS];
bool m_bStillEnteringName[NUM_PLAYERS];
};
+41 -5
View File
@@ -55,7 +55,7 @@ ScreenRanking::ScreenRanking() : ScreenAttract("ScreenRanking","ranking")
m_textType.SetXY( TYPE_X, TYPE_Y );
this->AddChild( &m_textType );
for( int i=0; i<NUM_HIGH_SCORE_LINES; i++ )
for( int i=0; i<NUM_RANKING_LINES; i++ )
{
m_sprBullets[i].Load( THEME->GetPathTo("Graphics",("ranking bullets 1x5")) );
m_sprBullets[i].SetXY( BULLETS_START_X+LINE_SPACING_X*i, BULLETS_START_Y+LINE_SPACING_Y*i );
@@ -69,6 +69,7 @@ ScreenRanking::ScreenRanking() : ScreenAttract("ScreenRanking","ranking")
m_textNames[i].SetXY( NAMES_START_X+LINE_SPACING_X*i, NAMES_START_Y+LINE_SPACING_Y*i );
m_textNames[i].SetZoom( NAMES_ZOOM );
m_textNames[i].SetDiffuse( NAMES_COLOR );
m_textNames[i].SetHorizAlign( Actor::align_left );
this->AddChild( &m_textNames[i] );
m_textScores[i].LoadFromFont( THEME->GetPathTo("Fonts","ranking") );
@@ -76,6 +77,7 @@ ScreenRanking::ScreenRanking() : ScreenAttract("ScreenRanking","ranking")
m_textScores[i].SetXY( SCORES_START_X+LINE_SPACING_X*i, SCORES_START_Y+LINE_SPACING_Y*i );
m_textScores[i].SetZoom( SCORES_ZOOM );
m_textScores[i].SetDiffuse( SCORES_COLOR );
m_textScores[i].SetHorizAlign( Actor::align_right );
this->AddChild( &m_textScores[i] );
}
@@ -177,12 +179,29 @@ void ScreenRanking::SetPage( PageToShow pts )
{
m_textCategory.SetText( ssprintf("Type %c", 'A'+pts.category) );
m_textType.SetText( GameManager::NotesTypeToString(pts.nt) );
for( int l=0; l<NUM_HIGH_SCORE_LINES; l++ )
for( int l=0; l<NUM_RANKING_LINES; l++ )
{
CString sName = SONGMAN->m_MachineScores[pts.nt][pts.category][l].sName;
float fScore = SONGMAN->m_MachineScores[pts.nt][pts.category][l].fScore;
m_textNames[l].SetText( sName );
m_textScores[l].SetText( ssprintf("%.0f",fScore) );
m_textNames[l].SetDiffuse( NAMES_COLOR );
m_textScores[l].SetDiffuse( SCORES_COLOR );
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( pts.nt == GAMESTATE->m_LastRankingNotesType &&
GAMESTATE->m_LastRankingCategory[p] == pts.category &&
GAMESTATE->m_iLastRankingIndex[p] == l )
{
m_textNames[l].SetEffectBlinking();
m_textScores[l].SetEffectBlinking();
}
else
{
m_textNames[l].SetEffectNone();
m_textScores[l].SetEffectNone();
}
}
}
}
break;
@@ -190,12 +209,29 @@ void ScreenRanking::SetPage( PageToShow pts )
{
m_textCategory.SetText( pts.pCourse->m_sName );
m_textType.SetText( GameManager::NotesTypeToString(pts.nt) );
for( int l=0; l<NUM_HIGH_SCORE_LINES; l++ )
for( int l=0; l<NUM_RANKING_LINES; l++ )
{
CString sName = pts.pCourse->m_MachineScores[pts.nt][l].sName;
int iDancePoints = pts.pCourse->m_MachineScores[pts.nt][l].iDancePoints;
m_textNames[l].SetText( sName );
m_textScores[l].SetText( ssprintf("%d",iDancePoints) );
m_textNames[l].SetDiffuse( NAMES_COLOR );
m_textScores[l].SetDiffuse( SCORES_COLOR );
for( int p=0; p<NUM_PLAYERS; p++ )
{
if( pts.pCourse == GAMESTATE->m_pLastPlayedCourse &&
pts.nt == GAMESTATE->m_LastRankingNotesType &&
GAMESTATE->m_iLastRankingIndex[p] == l )
{
m_textNames[l].SetEffectBlinking();
m_textScores[l].SetEffectBlinking();
}
else
{
m_textNames[l].SetEffectNone();
m_textScores[l].SetEffectNone();
}
}
}
}
break;
@@ -211,7 +247,7 @@ void ScreenRanking::TweenPageOnScreen()
m_textType.SetDiffuse( RageColor(1,1,1,1) );
m_textType.FadeOn(0.1f,"bounce right",0.5f);
for( int l=0; l<NUM_HIGH_SCORE_LINES; l++ )
for( int l=0; l<NUM_RANKING_LINES; l++ )
{
m_sprBullets[l].SetDiffuse( RageColor(1,1,1,1) );
m_sprBullets[l].FadeOn(0.2f+l*0.1f,"bounce right far",1.f);
@@ -227,7 +263,7 @@ void ScreenRanking::TweenPageOffScreen()
m_textCategory.FadeOff(0,"fade",0.25f);
m_textType.FadeOff(0.1f,"fade",0.25f);
for( int l=0; l<NUM_HIGH_SCORE_LINES; l++ )
for( int l=0; l<NUM_RANKING_LINES; l++ )
{
m_sprBullets[l].FadeOff(0.2f+l*0.1f,"fade",0.25f);
m_textNames[l].FadeOff(0.2f+l*0.1f,"fade",0.25f);
+4 -4
View File
@@ -10,7 +10,7 @@
*/
#include "ScreenAttract.h"
#include "GameConstantsAndTypes.h" // for NUM_HIGH_SCORE_LINES
#include "GameConstantsAndTypes.h" // for NUM_RANKING_LINES
#include "Style.h"
@@ -40,9 +40,9 @@ protected:
BitmapText m_textCategory;
BitmapText m_textType;
Sprite m_sprBullets[NUM_HIGH_SCORE_LINES];
BitmapText m_textNames[NUM_HIGH_SCORE_LINES];
BitmapText m_textScores[NUM_HIGH_SCORE_LINES];
Sprite m_sprBullets[NUM_RANKING_LINES];
BitmapText m_textNames[NUM_RANKING_LINES];
BitmapText m_textScores[NUM_RANKING_LINES];
vector<PageToShow> m_vPagesToShow;
};
+23 -30
View File
@@ -210,7 +210,7 @@ void SongManager::InitMachineScoresFromDisk()
{
for( int i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
for( int k=0; k<NUM_HIGH_SCORE_LINES; k++ )
for( int k=0; k<NUM_RANKING_LINES; k++ )
{
m_MachineScores[i][j][k].fScore = 573000;
m_MachineScores[i][j][k].sName = "STEP";
@@ -228,7 +228,7 @@ void SongManager::InitMachineScoresFromDisk()
{
for( int i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
for( int k=0; k<NUM_HIGH_SCORE_LINES; k++ )
for( int k=0; k<NUM_RANKING_LINES; k++ )
if( fp && !feof(fp) )
{
char szName[256];
@@ -257,7 +257,7 @@ void SongManager::InitMachineScoresFromDisk()
Course* pCourse = GetCourseFromPath( szPath );
for( int i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_HIGH_SCORE_LINES; j++ )
for( int j=0; j<NUM_RANKING_LINES; j++ )
if( fp && !feof(fp) )
{
int iDancePoints;
@@ -288,7 +288,7 @@ void SongManager::SaveMachineScoresToDisk()
fprintf(fp,"%d",CATEGORY_TOP_SCORE_VERSION);
for( int i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_RANKING_CATEGORIES; j++ )
for( int k=0; k<NUM_HIGH_SCORE_LINES; k++ )
for( int k=0; k<NUM_RANKING_LINES; k++ )
if( fp )
fprintf(fp, "%f %s\n", m_MachineScores[i][j][k].fScore, m_MachineScores[i][j][k].sName.c_str());
fclose(fp);
@@ -309,7 +309,7 @@ void SongManager::SaveMachineScoresToDisk()
fprintf(fp, "%s\n", pCourse->m_sPath.c_str());
for( int i=0; i<NUM_NOTES_TYPES; i++ )
for( int j=0; j<NUM_HIGH_SCORE_LINES; j++ )
for( int j=0; j<NUM_RANKING_LINES; j++ )
fprintf(fp, "%d %f %s\n",
pCourse->m_MachineScores[i][j].iDancePoints,
pCourse->m_MachineScores[i][j].fSurviveTime,
@@ -630,36 +630,27 @@ bool SongManager::IsUsingMemoryCard( PlayerNumber pn )
}
bool SongManager::IsNewMachineRecord( RankingCategory hsc, float fScore ) const // return true if this is would be a new machine record
{
for( int i=0; i<NUM_HIGH_SCORE_LINES; i++ )
{
const MachineScore& hs = m_MachineScores[GAMESTATE->m_CurStyle][hsc][i];
if( fScore > hs.fScore )
return true;
}
return false;
}
struct MachineScoreAndPlayerNumber : public SongManager::MachineScore
struct CategoryScoreToInsert
{
PlayerNumber pn;
RankingCategory cat;
float fScore;
static int CompareDescending( const MachineScoreAndPlayerNumber &hs1, const MachineScoreAndPlayerNumber &hs2 )
static int CompareDescending( const CategoryScoreToInsert &hs1, const CategoryScoreToInsert &hs2 )
{
if( hs1.fScore > hs2.fScore ) return -1;
else if( hs1.fScore == hs2.fScore ) return 0;
else return +1;
}
static void SortDescending( vector<MachineScoreAndPlayerNumber>& vHSout )
static void SortDescending( vector<CategoryScoreToInsert>& vHSout )
{
sort( vHSout.begin(), vHSout.end(), CompareDescending );
}
};
void SongManager::AddMachineRecord( RankingCategory hsc, float fScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ) // set iNewRecordIndex = -1 if not a new record
void SongManager::AddMachineRecords( NotesType nt, RankingCategory hsc[NUM_PLAYERS], float fScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ) // set iNewRecordIndex = -1 if not a new record
{
vector<MachineScoreAndPlayerNumber> vHS;
vector<CategoryScoreToInsert> vHS;
for( int p=0; p<NUM_PLAYERS; p++ )
{
iNewRecordIndexOut[p] = -1;
@@ -667,31 +658,33 @@ void SongManager::AddMachineRecord( RankingCategory hsc, float fScore[NUM_PLAYER
if( !GAMESTATE->IsPlayerEnabled(p) )
continue; // skip
MachineScoreAndPlayerNumber hs;
hs.fScore = fScore[p];
hs.sName = ""; // this must be filled in later!
CategoryScoreToInsert hs;
hs.pn = (PlayerNumber)p;
hs.cat = hsc[p];
hs.fScore = fScore[p];
vHS.push_back( hs );
}
// Sort descending before inserting.
// This guarantees that a high score will not switch poitions on us when we later insert scores for the other player
MachineScoreAndPlayerNumber::SortDescending( vHS );
CategoryScoreToInsert::SortDescending( vHS );
for( unsigned i=0; i<vHS.size(); i++ )
{
MachineScoreAndPlayerNumber& newHS = vHS[i];
MachineScore* machineScores = m_MachineScores[GAMESTATE->m_CurStyle][GAMESTATE->m_PreferredDifficulty[newHS.pn]];
for( int i=0; i<NUM_HIGH_SCORE_LINES; i++ )
CategoryScoreToInsert& newHS = vHS[i];
MachineScore* machineScores = m_MachineScores[nt][newHS.cat];
for( int i=0; i<NUM_RANKING_LINES; i++ )
{
if( newHS.fScore > machineScores[i].fScore )
{
// We found the insert point. Shift down.
for( int j=i+1; j<NUM_HIGH_SCORE_LINES; j++ )
for( int j=i+1; j<NUM_RANKING_LINES; j++ )
machineScores[j] = machineScores[j-1];
// insert
machineScores[i] = newHS;
machineScores[i].fScore = newHS.fScore;
machineScores[i].sName = "STEP";
iNewRecordIndexOut[newHS.pn] = i;
break;
}
}
}
+2 -4
View File
@@ -84,10 +84,8 @@ public:
{
float fScore;
CString sName;
} m_MachineScores[NUM_NOTES_TYPES][NUM_RANKING_CATEGORIES][NUM_HIGH_SCORE_LINES];
bool IsNewMachineRecord( RankingCategory hsc, float fScore ) const; // return true if this is would be a new machine record
void AddMachineRecord( RankingCategory hsc, float fScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record
} m_MachineScores[NUM_NOTES_TYPES][NUM_RANKING_CATEGORIES][NUM_RANKING_LINES];
void AddMachineRecords( NotesType nt, RankingCategory hsc[NUM_PLAYERS], float fScore[NUM_PLAYERS], int iNewRecordIndexOut[NUM_PLAYERS] ); // set iNewRecordIndex = -1 if not a new record
protected:
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );