2004-09-06 21:28:56 +00:00
|
|
|
#include "global.h"
|
2004-09-10 23:21:56 +00:00
|
|
|
|
|
|
|
|
#if !defined(WITHOUT_NETWORKING)
|
2004-08-31 16:41:58 +00:00
|
|
|
#include "ScreenNetEvaluation.h"
|
2004-09-01 04:09:36 +00:00
|
|
|
#include "ThemeManager.h"
|
2004-09-01 07:59:13 +00:00
|
|
|
#include "GameState.h"
|
2005-01-10 00:35:43 +00:00
|
|
|
#include "RageLog.h"
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
const int NUM_SCORE_DIGITS = 9;
|
|
|
|
|
|
|
|
|
|
#define USERSBG_WIDTH THEME->GetMetricF("ScreenNetEvaluation","UsersBGWidth")
|
|
|
|
|
#define USERSBG_HEIGHT THEME->GetMetricF("ScreenNetEvaluation","UsersBGHeight")
|
2005-08-26 21:12:48 +00:00
|
|
|
#define USERSBG_COMMAND THEME->GetMetricA("ScreenNetEvaluation","UsersBGCommand")
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
#define USERDX THEME->GetMetricF("ScreenNetEvaluation","UserDX")
|
|
|
|
|
#define USERDY THEME->GetMetricF("ScreenNetEvaluation","UserDY")
|
2004-08-31 16:41:58 +00:00
|
|
|
|
2004-09-02 03:15:39 +00:00
|
|
|
#define MAX_COMBO_NUM_DIGITS THEME->GetMetricI("ScreenEvaluation","MaxComboNumDigits")
|
|
|
|
|
|
2005-03-28 08:01:36 +00:00
|
|
|
AutoScreenMessage( SM_GotEval )
|
2004-09-02 23:53:26 +00:00
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenNetEvaluation );
|
2005-02-23 06:29:05 +00:00
|
|
|
|
|
|
|
|
void ScreenNetEvaluation::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenEvaluation::Init();
|
|
|
|
|
|
2004-09-02 23:53:26 +00:00
|
|
|
m_bHasStats = false;
|
2004-09-03 15:33:00 +00:00
|
|
|
m_iCurrentPlayer = 0;
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
FOREACH_PlayerNumber (pn)
|
|
|
|
|
if ( GAMESTATE->IsPlayerEnabled( pn ) )
|
|
|
|
|
m_pActivePlayer = pn;
|
|
|
|
|
|
|
|
|
|
if (m_pActivePlayer == PLAYER_1)
|
2005-01-10 00:35:43 +00:00
|
|
|
m_iShowSide = 2;
|
2004-09-01 04:09:36 +00:00
|
|
|
else
|
2005-01-10 00:35:43 +00:00
|
|
|
m_iShowSide = 1;
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
m_rectUsersBG.SetWidth( USERSBG_WIDTH );
|
|
|
|
|
m_rectUsersBG.SetHeight( USERSBG_HEIGHT );
|
2005-08-26 21:12:48 +00:00
|
|
|
m_rectUsersBG.RunCommands( USERSBG_COMMAND );
|
2004-09-01 04:09:36 +00:00
|
|
|
m_rectUsersBG.SetName( "UsersBG" );
|
|
|
|
|
ON_COMMAND( m_rectUsersBG );
|
|
|
|
|
|
|
|
|
|
m_rectUsersBG.SetXY(
|
2005-01-10 00:35:43 +00:00
|
|
|
THEME->GetMetricF("ScreenNetEvaluation",ssprintf("UsersBG%dX",m_iShowSide)),
|
|
|
|
|
THEME->GetMetricF("ScreenNetEvaluation",ssprintf("UsersBG%dY",m_iShowSide)) );
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
this->AddChild( &m_rectUsersBG );
|
|
|
|
|
|
2005-01-10 00:35:43 +00:00
|
|
|
RedoUserTexts();
|
|
|
|
|
|
|
|
|
|
NSMAN->ReportNSSOnOff( 5 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenNetEvaluation::RedoUserTexts()
|
|
|
|
|
{
|
2004-09-01 04:09:36 +00:00
|
|
|
m_iActivePlayers = NSMAN->m_ActivePlayers;
|
2006-11-24 16:03:49 +00:00
|
|
|
|
|
|
|
|
//If unnecessary, just don't do this function.
|
2005-01-10 07:04:44 +00:00
|
|
|
if ( m_iActivePlayers == (int)m_textUsers.size() )
|
2005-01-10 00:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
2006-11-24 16:03:49 +00:00
|
|
|
for( unsigned int i=0; i < m_textUsers.size(); ++i )
|
|
|
|
|
this->RemoveChild( &m_textUsers[i] );
|
|
|
|
|
|
2005-01-10 00:35:43 +00:00
|
|
|
float cx = THEME->GetMetricF("ScreenNetEvaluation",ssprintf("User%dX",m_iShowSide));
|
|
|
|
|
float cy = THEME->GetMetricF("ScreenNetEvaluation",ssprintf("User%dY",m_iShowSide));
|
|
|
|
|
|
2004-09-01 04:09:36 +00:00
|
|
|
m_iCurrentPlayer = 0;
|
2004-12-08 05:35:03 +00:00
|
|
|
m_textUsers.resize(m_iActivePlayers);
|
|
|
|
|
|
2004-09-06 21:28:56 +00:00
|
|
|
for( int i=0; i<m_iActivePlayers; ++i )
|
2004-09-01 04:09:36 +00:00
|
|
|
{
|
|
|
|
|
m_textUsers[i].LoadFromFont( THEME->GetPathF(m_sName,"names") );
|
|
|
|
|
m_textUsers[i].SetName( "User" );
|
|
|
|
|
m_textUsers[i].SetShadowLength( 1 );
|
|
|
|
|
m_textUsers[i].SetXY( cx, cy );
|
|
|
|
|
|
|
|
|
|
this->AddChild( &m_textUsers[i] );
|
|
|
|
|
cx+=USERDX;
|
|
|
|
|
cy+=USERDY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 00:44:52 +00:00
|
|
|
void ScreenNetEvaluation::MenuLeft( const InputEventPlus &input )
|
2004-09-01 04:09:36 +00:00
|
|
|
{
|
2005-09-23 00:44:52 +00:00
|
|
|
MenuUp( input );
|
2004-09-01 04:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-23 00:44:52 +00:00
|
|
|
void ScreenNetEvaluation::MenuUp( const InputEventPlus &input )
|
2004-09-01 04:09:36 +00:00
|
|
|
{
|
2006-11-24 16:03:49 +00:00
|
|
|
if ( (m_iActivePlayers == 0) || !m_bHasStats )
|
2004-09-02 23:53:26 +00:00
|
|
|
return;
|
2006-11-24 16:03:49 +00:00
|
|
|
|
2004-09-01 04:09:36 +00:00
|
|
|
COMMAND( m_textUsers[m_iCurrentPlayer], "DeSel" );
|
|
|
|
|
m_iCurrentPlayer = (m_iCurrentPlayer + m_iActivePlayers - 1) % m_iActivePlayers;
|
|
|
|
|
COMMAND( m_textUsers[m_iCurrentPlayer], "Sel" );
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-23 00:44:52 +00:00
|
|
|
void ScreenNetEvaluation::MenuRight( const InputEventPlus &input )
|
2004-09-01 04:09:36 +00:00
|
|
|
{
|
2005-09-23 00:44:52 +00:00
|
|
|
MenuDown( input );
|
2004-09-01 04:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
2005-09-23 00:44:52 +00:00
|
|
|
void ScreenNetEvaluation::MenuDown( const InputEventPlus &input )
|
2004-09-01 04:09:36 +00:00
|
|
|
{
|
2006-11-24 16:03:49 +00:00
|
|
|
if ( (m_iActivePlayers == 0) || !m_bHasStats )
|
2004-09-02 23:53:26 +00:00
|
|
|
return;
|
2006-11-24 16:03:49 +00:00
|
|
|
|
2004-09-01 04:09:36 +00:00
|
|
|
COMMAND( m_textUsers[m_iCurrentPlayer], "DeSel" );
|
|
|
|
|
m_iCurrentPlayer = (m_iCurrentPlayer + 1) % m_iActivePlayers;
|
|
|
|
|
COMMAND( m_textUsers[m_iCurrentPlayer], "Sel" );
|
|
|
|
|
UpdateStats();
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:53:26 +00:00
|
|
|
void ScreenNetEvaluation::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
2006-11-24 16:03:49 +00:00
|
|
|
if( SM == SM_GotEval)
|
2004-09-02 23:53:26 +00:00
|
|
|
{
|
|
|
|
|
m_bHasStats = true;
|
2005-01-10 00:35:43 +00:00
|
|
|
|
|
|
|
|
LOG->Trace("SMNETDebug:%d,%d",m_iActivePlayers,NSMAN->m_ActivePlayers);
|
|
|
|
|
|
|
|
|
|
RedoUserTexts();
|
|
|
|
|
|
|
|
|
|
LOG->Trace("SMNETCheckpoint");
|
2004-09-06 21:28:56 +00:00
|
|
|
for( int i=0; i<m_iActivePlayers; ++i )
|
2004-09-02 23:53:26 +00:00
|
|
|
{
|
2005-01-24 03:11:00 +00:00
|
|
|
//Strange occourances because of timing
|
|
|
|
|
//cause these things not to work right
|
|
|
|
|
//and will sometimes cause a crash.
|
|
|
|
|
//We should make SURE we won't crash!
|
2005-01-24 10:12:46 +00:00
|
|
|
if ( size_t(i) >= NSMAN->m_EvalPlayerData.size() )
|
2005-01-24 03:11:00 +00:00
|
|
|
break;
|
|
|
|
|
|
2005-01-24 10:12:46 +00:00
|
|
|
if ( size_t(NSMAN->m_EvalPlayerData[i].name) >= NSMAN->m_PlayerNames.size() )
|
2005-01-24 03:11:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if ( NSMAN->m_EvalPlayerData[i].name < 0 )
|
|
|
|
|
break;
|
|
|
|
|
|
2005-01-24 10:12:46 +00:00
|
|
|
if ( size_t(i) >= m_textUsers.size() )
|
2005-01-24 03:11:00 +00:00
|
|
|
break;
|
|
|
|
|
|
2004-09-02 23:53:26 +00:00
|
|
|
m_textUsers[i].SetText( NSMAN->m_PlayerNames[NSMAN->m_EvalPlayerData[i].name] );
|
2005-08-14 11:38:31 +00:00
|
|
|
if ( NSMAN->m_EvalPlayerData[i].grade < Grade_Tier03 ) //Yes, hardcoded (I'd like to leave it that way)
|
2007-02-19 09:32:07 +00:00
|
|
|
m_textUsers[i].SetRainbowScroll( true );
|
2004-09-17 22:53:17 +00:00
|
|
|
else
|
2007-02-19 09:32:07 +00:00
|
|
|
m_textUsers[i].SetRainbowScroll( false );
|
2004-09-02 23:53:26 +00:00
|
|
|
ON_COMMAND( m_textUsers[i] );
|
2005-01-10 00:35:43 +00:00
|
|
|
LOG->Trace("SMNETCheckpoint%d",i);
|
2004-09-02 23:53:26 +00:00
|
|
|
}
|
2004-09-03 00:12:53 +00:00
|
|
|
return; //no need to let ScreenEvaluation get ahold of this.
|
2005-03-23 08:48:38 +00:00
|
|
|
}
|
|
|
|
|
else if( SM == SM_GoToNextScreen )
|
|
|
|
|
{
|
2004-10-29 01:58:56 +00:00
|
|
|
NSMAN->ReportNSSOnOff( 4 );
|
2004-09-02 23:53:26 +00:00
|
|
|
}
|
2004-09-03 00:12:53 +00:00
|
|
|
ScreenEvaluation::HandleScreenMessage( SM );
|
2004-09-02 23:53:26 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-03 15:33:00 +00:00
|
|
|
void ScreenNetEvaluation::TweenOffScreen( )
|
|
|
|
|
{
|
2004-09-06 21:28:56 +00:00
|
|
|
for( int i=0; i<m_iActivePlayers; ++i )
|
2004-09-03 15:33:00 +00:00
|
|
|
OFF_COMMAND( m_textUsers[i] );
|
|
|
|
|
OFF_COMMAND( m_rectUsersBG );
|
|
|
|
|
ScreenEvaluation::TweenOffScreen();
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-01 04:09:36 +00:00
|
|
|
void ScreenNetEvaluation::UpdateStats()
|
|
|
|
|
{
|
2005-01-25 18:23:27 +00:00
|
|
|
if( m_iCurrentPlayer >= (int) NSMAN->m_EvalPlayerData.size() )
|
2005-01-25 05:07:29 +00:00
|
|
|
return;
|
|
|
|
|
|
2005-01-31 03:18:46 +00:00
|
|
|
m_Grades[m_pActivePlayer].SetGrade( m_pActivePlayer, (Grade)NSMAN->m_EvalPlayerData[m_iCurrentPlayer].grade );
|
2004-09-01 04:09:36 +00:00
|
|
|
|
|
|
|
|
m_textScore[m_pActivePlayer].SetText( ssprintf("%*.0i", NUM_SCORE_DIGITS, NSMAN->m_EvalPlayerData[m_iCurrentPlayer].score) );
|
2004-08-31 16:41:58 +00:00
|
|
|
|
2005-01-25 05:07:29 +00:00
|
|
|
//Values greater than 6 will cause crash
|
|
|
|
|
if ( NSMAN->m_EvalPlayerData[m_iCurrentPlayer].difficulty < 6 )
|
2006-08-16 21:36:15 +00:00
|
|
|
{
|
|
|
|
|
m_DifficultyIcon[m_pActivePlayer].SetPlayer( m_pActivePlayer );
|
|
|
|
|
m_DifficultyIcon[m_pActivePlayer].SetFromDifficulty( NSMAN->m_EvalPlayerData[m_iCurrentPlayer].difficulty );
|
|
|
|
|
}
|
2004-09-01 17:16:01 +00:00
|
|
|
|
2004-09-06 21:28:56 +00:00
|
|
|
for (int j=0; j<NETNUMTAPSCORES; ++j)
|
2004-09-02 03:15:39 +00:00
|
|
|
{
|
2005-10-09 04:30:59 +00:00
|
|
|
int iNumDigits = (j==JudgeLine_MaxCombo) ? MAX_COMBO_NUM_DIGITS : 4;
|
2004-09-09 05:32:00 +00:00
|
|
|
if (m_textJudgeNumbers[j][m_pActivePlayer].m_pFont != NULL)
|
|
|
|
|
m_textJudgeNumbers[j][m_pActivePlayer].SetText( ssprintf( "%*d", iNumDigits, NSMAN->m_EvalPlayerData[m_iCurrentPlayer].tapScores[j] ) );
|
2004-09-02 03:15:39 +00:00
|
|
|
}
|
2004-09-06 03:54:04 +00:00
|
|
|
|
2004-09-06 04:24:51 +00:00
|
|
|
m_textPlayerOptions[m_pActivePlayer].SetText( NSMAN->m_EvalPlayerData[m_iCurrentPlayer].playerOptions );
|
2004-08-31 16:41:58 +00:00
|
|
|
}
|
2004-09-10 23:21:56 +00:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-02-08 16:04:28 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2004-2005 Charles Lohr, Joshua Allen
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|