From be1039221e873e1c516abbd7ca714b787113a34f Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 28 Aug 2005 08:59:46 +0000 Subject: [PATCH] add ScreenEvaluationMultiplayer --- stepmania/src/Makefile.am | 4 +- stepmania/src/ScreenEvaluationMultiplayer.cpp | 315 ++++++++++++++++++ stepmania/src/ScreenEvaluationMultiplayer.h | 72 ++++ stepmania/src/StepMania-net2003.vcproj | 6 + stepmania/src/StepMania.dsp | 12 +- stepmania/src/StepMania.vcproj | 6 + 6 files changed, 412 insertions(+), 3 deletions(-) create mode 100644 stepmania/src/ScreenEvaluationMultiplayer.cpp create mode 100644 stepmania/src/ScreenEvaluationMultiplayer.h diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 08312eadb7..d3b2f0d1be 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -30,7 +30,9 @@ ScreenDemonstration.cpp ScreenDemonstration.h ScreenDimensions.h \ ScreenEdit.cpp ScreenEdit.h \ ScreenEditCourseMods.cpp ScreenEditCourseMods.h \ ScreenEditMenu.cpp ScreenEditMenu.h ScreenEnding.cpp ScreenEnding.h \ -ScreenEvaluation.cpp ScreenEvaluation.h ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ +ScreenEvaluation.cpp ScreenEvaluation.h \ +ScreenEvaluationMultiplayer.cpp ScreenEvaluationMultiplayer.h \ +ScreenExit.cpp ScreenExit.h ScreenNetEvaluation.cpp ScreenNetEvaluation.h \ ScreenNetSelectMusic.cpp ScreenNetSelectMusic.h ScreenNetSelectBase.cpp ScreenNetSelectBase.h ScreenNetRoom.cpp ScreenNetRoom.h \ ScreenEz2SelectMusic.cpp ScreenEz2SelectMusic.h ScreenEz2SelectPlayer.cpp ScreenEz2SelectPlayer.h \ ScreenGameplay.cpp ScreenGameplay.h \ diff --git a/stepmania/src/ScreenEvaluationMultiplayer.cpp b/stepmania/src/ScreenEvaluationMultiplayer.cpp new file mode 100644 index 0000000000..2091d3fb74 --- /dev/null +++ b/stepmania/src/ScreenEvaluationMultiplayer.cpp @@ -0,0 +1,315 @@ +#include "global.h" +#include "ScreenEvaluationMultiplayer.h" +#include "BitmapText.h" +#include "PlayerState.h" +#include "PlayerStageStats.h" +#include "GameState.h" +#include "StatsManager.h" +#include "GameCommand.h" +#include "PrefsManager.h" +#include "GameManager.h" +#include "SongManager.h" +#include "Song.h" +#include "ScoreKeeperMAX2.h" +#include "PercentageDisplay.h" + + +static const CString JudgeLineNames[] = { + "Marvelous", + "Perfect", + "Great", + "Good", + "Boo", + "Miss", + "Ok", +}; +XToString( JudgeLine, NUM_JudgeLine ); + +static void PositionItem( LuaExpression &expr, Actor *pSelf, int iItemIndex, int iNumItems ) +{ + Lua *L = LUA->Get(); + expr.PushSelf( L ); + ASSERT( !lua_isnil(L, -1) ); + pSelf->PushSelf( L ); + LuaHelpers::Push( iItemIndex, L ); + LuaHelpers::Push( iNumItems, L ); + lua_call( L, 3, 0 ); // 3 args, 0 results + LUA->Release(L); +} + +class MultiplayerEvalScoreRow : public ActorFrame +{ +protected: + AutoActor m_sprFrame; + PercentageDisplay m_score; + BitmapText m_textJudgmentNumber[NUM_JudgeLine]; + +public: + MultiplayerEvalScoreRow( MultiPlayer mp, int iRankIndex ) + { + PlayerState *pPlayerState = GAMESTATE->m_pMultiPlayerState[mp]; + PlayerStageStats *pPlayerStageStats = &STATSMAN->m_CurStageStats.m_multiPlayer[mp]; + + ASSERT( GAMESTATE->IsPlayerEnabled(pPlayerState) ); + + + m_sprFrame.Load( THEME->GetPathG("MultiplayerEvalScoreRow","frame") ); + this->AddChild( m_sprFrame ); + + + m_score.Load( pPlayerState, pPlayerStageStats, "MultiplayerEvalScoreRow Percent", true ); + m_score.SetName( "Score" ); + ActorUtil::OnCommand( &m_score, "MultiplayerEvalScoreRow" ); + this->AddChild( &m_score ); + + + LuaExpression expr; + expr.SetFromExpression( THEME->GetMetric("MultiplayerEvalScoreRow","NumberOnCommandFunction") ); + + for( int i=0; iGetPathF("MultiplayerEvalScoreRow","JudgmentNumber") ); + this->AddChild( &text ); + + int iVal = -1; + switch( i ) + { + default: ASSERT(0); + case JudgeLine_Marvelous: iVal = pPlayerStageStats->iTapNoteScores[TNS_MARVELOUS];break; + case JudgeLine_Perfect: iVal = pPlayerStageStats->iTapNoteScores[TNS_PERFECT]; break; + case JudgeLine_Great: iVal = pPlayerStageStats->iTapNoteScores[TNS_GREAT]; break; + case JudgeLine_Good: iVal = pPlayerStageStats->iTapNoteScores[TNS_GOOD]; break; + case JudgeLine_Boo: iVal = pPlayerStageStats->iTapNoteScores[TNS_BOO]; break; + case JudgeLine_Miss: iVal = pPlayerStageStats->iTapNoteScores[TNS_MISS]; break; + case JudgeLine_Ok: iVal = pPlayerStageStats->iHoldNoteScores[HNS_OK]; break; + } + + CString s = ssprintf( "%3d", iVal ); + text.SetText( s ); + + PositionItem( expr, &text, i, NUM_JudgeLine ); + } + } +}; + + +REGISTER_SCREEN_CLASS( ScreenEvaluationMultiplayer ); +ScreenEvaluationMultiplayer::ScreenEvaluationMultiplayer( CString sClassName ) : ScreenWithMenuElements( sClassName ) +{ + // + // debugging + // + if( PREFSMAN->m_bScreenTestMode ) + { + GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); + GAMESTATE->m_pCurStyle.Set( GAMEMAN->GameAndStringToStyle(GAMEMAN->GetDefaultGame(),"single") ); + + GAMESTATE->m_bMultiplayer = true; + + STATSMAN->m_CurStageStats.playMode = GAMESTATE->m_PlayMode; + STATSMAN->m_CurStageStats.pStyle = GAMESTATE->m_pCurStyle; + STATSMAN->m_CurStageStats.StageType = StageStats::STAGE_NORMAL; + GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + 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.Set( SONGMAN->GetRandomCourse() ); + GAMESTATE->m_iCurrentStageIndex = 0; + + GAMESTATE->m_pCurSteps[PLAYER_1].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] ); + STATSMAN->m_CurStageStats.m_player[PLAYER_1].vpPlayedSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] ); + STATSMAN->m_CurStageStats.m_player[PLAYER_1].vpPossibleSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] ); + GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_fScrollSpeed = 2; + GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.ChooseRandomMofifiers(); + + FOREACH_MultiPlayer( p ) + { + GAMESTATE->m_bIsMultiPlayerJoined[p] = (rand() % 4) != 0; + } + + FOREACH_MultiPlayer( p ) + { + STATSMAN->m_CurStageStats.m_multiPlayer[p].iActualDancePoints = rand()%3; + STATSMAN->m_CurStageStats.m_multiPlayer[p].iPossibleDancePoints = 2; + STATSMAN->m_CurStageStats.m_multiPlayer[p].iCurCombo = 0; + STATSMAN->m_CurStageStats.m_multiPlayer[p].UpdateComboList( 0, false ); + STATSMAN->m_CurStageStats.m_multiPlayer[p].iCurCombo = 1; + STATSMAN->m_CurStageStats.m_multiPlayer[p].UpdateComboList( 1, false ); + STATSMAN->m_CurStageStats.m_multiPlayer[p].iCurCombo = 50; + STATSMAN->m_CurStageStats.m_multiPlayer[p].UpdateComboList( 25, false ); + STATSMAN->m_CurStageStats.m_multiPlayer[p].iCurCombo = 250; + STATSMAN->m_CurStageStats.m_multiPlayer[p].UpdateComboList( 100, false ); + if( rand()%2 ) + { + STATSMAN->m_CurStageStats.m_multiPlayer[p].iCurCombo = rand()%11000; + STATSMAN->m_CurStageStats.m_multiPlayer[p].UpdateComboList( 110, false ); + } + if( rand()%5 == 0 ) + { + STATSMAN->m_CurStageStats.m_multiPlayer[p].bFailedEarlier = true; + } + STATSMAN->m_CurStageStats.m_multiPlayer[p].iTapNoteScores[TNS_MARVELOUS] = rand()%3; + STATSMAN->m_CurStageStats.m_multiPlayer[p].iTapNoteScores[TNS_PERFECT] = rand()%3; + STATSMAN->m_CurStageStats.m_multiPlayer[p].iTapNoteScores[TNS_GREAT] = rand()%3; + STATSMAN->m_CurStageStats.m_multiPlayer[p].iPossibleGradePoints = 4*ScoreKeeperMAX2::TapNoteScoreToGradePoints(TNS_MARVELOUS, false); + STATSMAN->m_CurStageStats.m_multiPlayer[p].fLifeRemainingSeconds = randomf( 90, 580 ); + } + + STATSMAN->m_vPlayedStageStats.clear(); + } + + + ASSERT( GAMESTATE->m_bMultiplayer ); +} + +ScreenEvaluationMultiplayer::~ScreenEvaluationMultiplayer() +{ + FOREACH( MultiplayerEvalScoreRow*, m_vpMultiplayerEvalScoreRow, iter ) + SAFE_DELETE( *iter ); + m_vpMultiplayerEvalScoreRow.clear(); +} + +struct EnabledPlayerIndexAndScore +{ + MultiPlayer m_MultiPlayer; + float fScore; + + bool operator<( const EnabledPlayerIndexAndScore &other ) const { return fScore > other.fScore; } +}; + +void ScreenEvaluationMultiplayer::Init() +{ + ScreenWithMenuElements::Init(); + + int iNumEnabledPlayers = 0; + FOREACH_EnabledMultiPlayer( p ) + iNumEnabledPlayers++; + + int iNumLines = iNumEnabledPlayers+1; + + LuaExpression exprBullet; + exprBullet.SetFromExpression( THEME->GetMetric("ScreenEvaluationMultiplayer","BulletOnCommandFunction") ); + LuaExpression exprLine; + exprLine.SetFromExpression( THEME->GetMetric("ScreenEvaluationMultiplayer","LineOnCommandFunction") ); + + this->AddChild( &m_frameLabels ); + PositionItem( exprLine, &m_frameLabels, 0, iNumLines ); + { + LuaExpression expr; + expr.SetFromExpression( THEME->GetMetric("ScreenEvaluationMultiplayer","LabelOnCommandFunction") ); + + FOREACH_JudgeLine( i ) + { + AutoActor &a = m_sprJudgmentLabel[i]; + a.Load( THEME->GetPathG("ScreenEvaluationMultiplayer","JudgmentLabel"+JudgeLineToString(i)) ); + m_frameLabels.AddChild( m_sprJudgmentLabel[i] ); + + PositionItem( expr, a, i, NUM_JudgeLine ); + } + } + + vector v; + FOREACH_EnabledMultiPlayer( p ) + { + PlayerStageStats *pPlayerStageStats = &STATSMAN->m_CurStageStats.m_multiPlayer[p]; + EnabledPlayerIndexAndScore t = { p, pPlayerStageStats->GetPercentDancePoints() }; + v.push_back( t ); + } + stable_sort( v.begin(), v.end() ); + + GameCommand gc; + int iRankIndex = 0; + m_vsprBullet.resize( v.size() ); + FOREACH( EnabledPlayerIndexAndScore, v, iter ) + { + int i = iter - v.begin(); + gc.m_iIndex = i; + gc.m_MultiPlayer = iter->m_MultiPlayer; + + Lua *L = LUA->Get(); + gc.PushSelf( L ); + lua_setglobal( L, "ThisGameCommand" ); + LUA->Release( L ); + + { + MultiplayerEvalScoreRow *pRow = new MultiplayerEvalScoreRow( iter->m_MultiPlayer, iRankIndex ); + m_vpMultiplayerEvalScoreRow.push_back( pRow ); + PositionItem( exprLine, pRow, iRankIndex+1, iNumLines ); + this->AddChild( pRow ); + } + + { + AutoActor &a = m_vsprBullet[i]; + a.Load( THEME->GetPathG("ScreenEvaluationMultiplayer","Bullet") ); + PositionItem( exprBullet, a, iRankIndex+1, iNumLines ); + this->AddChild( a ); + } + + LUA->UnsetGlobal( "ThisGameCommand" ); + + iRankIndex++; + } + + this->SortByDrawOrder(); +} + +void ScreenEvaluationMultiplayer::HandleScreenMessage( const ScreenMessage SM ) +{ + ScreenWithMenuElements::HandleScreenMessage( SM ); +} + +void ScreenEvaluationMultiplayer::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ + if( this->IsTransitioning() ) + return; + + ScreenWithMenuElements::Input( DeviceI, type, GameI, MenuI, StyleI ); +} + +void ScreenEvaluationMultiplayer::Update( float fDeltaTime ) +{ + ScreenWithMenuElements::Update(fDeltaTime); +} + +void ScreenEvaluationMultiplayer::DrawPrimitives() +{ + ScreenWithMenuElements::DrawPrimitives(); +} + +void ScreenEvaluationMultiplayer::MenuBack( PlayerNumber pn ) +{ + MenuStart( pn ); +} + +void ScreenEvaluationMultiplayer::MenuStart( PlayerNumber pn ) +{ + + this->StartTransitioning( SM_GoToNextScreen ); +} + + +/* + * (c) 2005 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/stepmania/src/ScreenEvaluationMultiplayer.h b/stepmania/src/ScreenEvaluationMultiplayer.h new file mode 100644 index 0000000000..d5a553d16a --- /dev/null +++ b/stepmania/src/ScreenEvaluationMultiplayer.h @@ -0,0 +1,72 @@ +#ifndef ScreenEvaluationMultiplayer_H +#define ScreenEvaluationMultiplayer_H + +#include "ScreenWithMenuElements.h" + +class MultiplayerEvalScoreRow; + +enum JudgeLine +{ + JudgeLine_Marvelous, + JudgeLine_Perfect, + JudgeLine_Great, + JudgeLine_Good, + JudgeLine_Boo, + JudgeLine_Miss, + JudgeLine_Ok, + NUM_JudgeLine, + JudgeLine_INVALID +}; +#define FOREACH_JudgeLine( i ) FOREACH_ENUM( JudgeLine, NUM_JudgeLine, i ) +const CString& JudgeLineToString( JudgeLine i ); + +class ScreenEvaluationMultiplayer : public ScreenWithMenuElements +{ +public: + ScreenEvaluationMultiplayer( CString sName ); + ~ScreenEvaluationMultiplayer(); + virtual void Init(); + + 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 Update(float f); + virtual void DrawPrimitives(); + +protected: + void MenuBack( PlayerNumber pn ); + void MenuStart( PlayerNumber pn ); + + ActorFrame m_frameLabels; + AutoActor m_sprJudgmentLabel[NUM_JudgeLine]; + + vector m_vsprBullet; + vector m_vpMultiplayerEvalScoreRow; +}; + +#endif + +/* + * (c) 2005 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + diff --git a/stepmania/src/StepMania-net2003.vcproj b/stepmania/src/StepMania-net2003.vcproj index c03f6f0ce3..4a05003a9b 100644 --- a/stepmania/src/StepMania-net2003.vcproj +++ b/stepmania/src/StepMania-net2003.vcproj @@ -327,6 +327,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 3c0d0d9efc..be14deeb45 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -62,7 +62,7 @@ IntDir=.\../Debug6 TargetDir=\cvs\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -99,7 +99,7 @@ IntDir=.\../Release6 TargetDir=\cvs\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -2612,6 +2612,14 @@ SOURCE=.\ScreenEvaluation.h # End Source File # Begin Source File +SOURCE=.\ScreenEvaluationMultiplayer.cpp +# End Source File +# Begin Source File + +SOURCE=.\ScreenEvaluationMultiplayer.h +# End Source File +# Begin Source File + SOURCE=.\ScreenExit.cpp # End Source File # Begin Source File diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 6649a0966f..04c2540411 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -307,6 +307,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + +