2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "ScoreDisplayNormal.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "GameState.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2004-12-20 06:25:59 +00:00
|
|
|
#include "PlayerState.h"
|
2005-02-16 03:25:45 +00:00
|
|
|
#include "StatsManager.h"
|
2005-02-12 21:03:39 +00:00
|
|
|
#include "CommonMetrics.h"
|
2008-03-19 11:38:14 +00:00
|
|
|
#include "ActorUtil.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ScoreDisplayNormal::ScoreDisplayNormal()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScoreDisplayNormal::ScoreDisplayNormal()" );
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2008-03-19 11:38:14 +00:00
|
|
|
RString sType = "ScoreDisplayNormal";
|
|
|
|
|
|
|
|
|
|
m_sprFrame.Load( THEME->GetPathG(sType,"Frame") );
|
|
|
|
|
m_sprFrame->SetName( "Frame" );
|
|
|
|
|
ActorUtil::LoadAllCommandsAndSetXY( m_sprFrame, sType );
|
|
|
|
|
this->AddChild( m_sprFrame );
|
|
|
|
|
|
2003-05-05 06:48:20 +00:00
|
|
|
|
2002-07-23 01:41:40 +00:00
|
|
|
// init the text
|
2008-03-19 11:38:14 +00:00
|
|
|
m_text.LoadFromFont( THEME->GetPathF("ScoreDisplayNormal","Text") );
|
|
|
|
|
m_text.SetName( "Text" );
|
2004-03-20 02:59:08 +00:00
|
|
|
m_text.SetShadowLength( 0 );
|
2005-02-15 00:49:22 +00:00
|
|
|
m_text.UpdateText();
|
2008-03-19 11:38:14 +00:00
|
|
|
ActorUtil::LoadAllCommandsAndSetXY( m_text, sType );
|
2003-02-25 00:33:42 +00:00
|
|
|
this->AddChild( &m_text );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-23 20:40:47 +00:00
|
|
|
void ScoreDisplayNormal::Init( const PlayerState* pPlayerState, const PlayerStageStats* pPlayerStageStats )
|
2002-07-23 01:41:40 +00:00
|
|
|
{
|
2005-08-23 20:40:47 +00:00
|
|
|
ScoreDisplay::Init( pPlayerState, pPlayerStageStats );
|
2004-12-20 06:25:59 +00:00
|
|
|
|
|
|
|
|
// TODO: Remove use of PlayerNumber.
|
2008-03-19 11:38:14 +00:00
|
|
|
//PlayerNumber pn = pPlayerState->m_PlayerNumber;
|
2004-12-20 06:25:59 +00:00
|
|
|
|
2008-03-19 11:38:14 +00:00
|
|
|
//m_text.RunCommands( CommonMetrics::PLAYER_COLOR.GetValue(pn) );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-18 20:08:39 +00:00
|
|
|
void ScoreDisplayNormal::SetScore( int iNewScore )
|
|
|
|
|
{
|
2005-02-15 21:58:35 +00:00
|
|
|
float fScore = (float)iNewScore;
|
|
|
|
|
|
2005-01-09 07:47:38 +00:00
|
|
|
// TODO: Remove use of PlayerNumber.
|
|
|
|
|
PlayerNumber pn = m_pPlayerState->m_PlayerNumber;
|
|
|
|
|
|
2005-02-15 00:49:22 +00:00
|
|
|
// Play some games to display the correct score -- the actual internal
|
|
|
|
|
// score does not change at all but the displayed one can (ie: displayed
|
|
|
|
|
// score for subtracrive is MaxScore - score).
|
2005-01-09 07:47:38 +00:00
|
|
|
|
|
|
|
|
|
2006-11-14 11:13:21 +00:00
|
|
|
int iMaxScore = STATSMAN->m_CurStageStats.m_player[pn].m_iMaxScore;
|
|
|
|
|
int iCurMaxScore = STATSMAN->m_CurStageStats.m_player[pn].m_iCurMaxScore;
|
2002-07-23 01:41:40 +00:00
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
switch( m_pPlayerState->m_PlayerOptions.GetCurrent().m_ScoreDisplay )
|
2002-07-23 01:41:40 +00:00
|
|
|
{
|
2005-02-15 00:49:22 +00:00
|
|
|
case PlayerOptions::SCORING_ADD:
|
|
|
|
|
// nothing to do
|
|
|
|
|
break;
|
|
|
|
|
case PlayerOptions::SCORING_SUBTRACT:
|
2005-02-15 21:58:35 +00:00
|
|
|
fScore = iMaxScore - ( iCurMaxScore - fScore );
|
2005-02-15 00:49:22 +00:00
|
|
|
break;
|
|
|
|
|
case PlayerOptions::SCORING_AVERAGE:
|
|
|
|
|
if( iCurMaxScore == 0 ) // don't divide by zero fats
|
2002-07-28 20:28:37 +00:00
|
|
|
{
|
2005-02-15 21:58:35 +00:00
|
|
|
fScore = 0;
|
2005-02-15 00:49:22 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-02-15 21:58:35 +00:00
|
|
|
float fScoreRatio = fScore / (float)iCurMaxScore;
|
|
|
|
|
fScore = fScoreRatio * iMaxScore;
|
2002-07-28 20:28:37 +00:00
|
|
|
}
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
2005-02-15 00:49:22 +00:00
|
|
|
|
2005-02-15 21:58:35 +00:00
|
|
|
m_text.SetTargetNumber( fScore );
|
2002-07-23 01:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-06-08 00:08:04 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 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.
|
|
|
|
|
*/
|