Files
itgmania212121/stepmania/src/DifficultyMeter.cpp
T

108 lines
2.4 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-01-16 10:01:32 +00:00
/*
-----------------------------------------------------------------------------
2003-03-09 00:55:49 +00:00
Class: DifficultyMeter
2002-01-16 10:01:32 +00:00
2002-05-27 08:23:27 +00:00
Desc: See header.
2002-01-16 10:01:32 +00:00
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-05-27 08:23:27 +00:00
Chris Danford
2002-01-16 10:01:32 +00:00
-----------------------------------------------------------------------------
*/
2003-03-09 00:55:49 +00:00
#include "DifficultyMeter.h"
2002-01-16 10:01:32 +00:00
#include "RageUtil.h"
2002-05-01 19:14:55 +00:00
#include "GameConstantsAndTypes.h"
2003-07-21 22:38:41 +00:00
#include "GameState.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
#include "ThemeManager.h"
2003-08-03 00:13:55 +00:00
#include "Steps.h"
2003-07-21 22:38:41 +00:00
#include "Course.h"
#include "SongManager.h"
2002-01-16 10:01:32 +00:00
#define NUM_FEET_IN_METER THEME->GetMetricI("DifficultyMeter","NumFeetInMeter")
#define MAX_FEET_IN_METER THEME->GetMetricI("DifficultyMeter","MaxFeetInMeter")
#define GLOW_IF_METER_GREATER_THAN THEME->GetMetricI("DifficultyMeter","GlowIfMeterGreaterThan")
2002-10-06 16:56:58 +00:00
2002-01-16 10:01:32 +00:00
2003-03-09 00:55:49 +00:00
DifficultyMeter::DifficultyMeter()
2002-05-19 01:59:48 +00:00
{
BitmapText::LoadFromTextureAndChars( THEME->GetPathToG("DifficultyMeter bar 2x1"), "10" );
2002-05-19 01:59:48 +00:00
2003-07-21 22:38:41 +00:00
Unset();
2002-05-19 01:59:48 +00:00
}
void DifficultyMeter::SetFromNotes( const Steps* pNotes )
2002-05-19 01:59:48 +00:00
{
2003-07-21 22:38:41 +00:00
if( pNotes == NULL )
2002-05-19 01:59:48 +00:00
{
2003-07-21 22:38:41 +00:00
Unset();
return;
2002-05-19 01:59:48 +00:00
}
2003-07-21 22:38:41 +00:00
SetMeter( pNotes->GetMeter() );
SetDiffuse( SONGMAN->GetDifficultyColor(pNotes->GetDifficulty()) );
2003-07-21 22:38:41 +00:00
}
void DifficultyMeter::SetFromCourse( const Course* pCourse )
2003-07-21 22:38:41 +00:00
{
if( pCourse == NULL )
2002-05-19 01:59:48 +00:00
{
2003-07-21 22:38:41 +00:00
Unset();
return;
2002-05-19 01:59:48 +00:00
}
2003-07-21 22:38:41 +00:00
const int meter = (int) roundf(pCourse->GetMeter());
2003-07-21 22:38:41 +00:00
SetMeter( meter );
// XXX
RageColor c;
if( meter <= 1 )
c = SONGMAN->GetDifficultyColor( DIFFICULTY_BEGINNER );
else if( meter <= 2 )
c = SONGMAN->GetDifficultyColor( DIFFICULTY_EASY );
else if( meter <= 5 )
c = SONGMAN->GetDifficultyColor( DIFFICULTY_MEDIUM );
else if( meter <= 7 )
c = SONGMAN->GetDifficultyColor( DIFFICULTY_HARD );
2003-07-21 22:38:41 +00:00
else
c = SONGMAN->GetDifficultyColor( DIFFICULTY_CHALLENGE );
SetDiffuse( c );
2003-07-21 22:38:41 +00:00
}
void DifficultyMeter::Unset()
{
SetEffectNone();
SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) );
2003-07-21 22:38:41 +00:00
SetMeter( 0 );
}
void DifficultyMeter::SetFromGameState( PlayerNumber pn )
{
if( GAMESTATE->m_pCurNotes[pn] )
SetFromNotes( GAMESTATE->m_pCurNotes[pn] );
else if( GAMESTATE->m_pCurCourse )
SetFromCourse( GAMESTATE->m_pCurCourse );
else
Unset();
2002-05-19 01:59:48 +00:00
}
2003-03-09 00:55:49 +00:00
void DifficultyMeter::SetMeter( int iMeter )
2002-05-19 01:59:48 +00:00
{
CString sNewText;
2002-11-16 08:54:15 +00:00
int f;
for( f=0; f<NUM_FEET_IN_METER; f++ )
2003-03-09 00:55:49 +00:00
sNewText += (f<iMeter) ? "1" : "0";
2003-04-06 23:59:35 +00:00
for( f=NUM_FEET_IN_METER; f<MAX_FEET_IN_METER; f++ )
2003-03-09 00:55:49 +00:00
if( f<iMeter )
2002-05-19 01:59:48 +00:00
sNewText += "1";
SetText( sNewText );
2003-07-21 22:38:41 +00:00
if( iMeter > GLOW_IF_METER_GREATER_THAN )
SetEffectGlowShift();
2003-07-21 22:38:41 +00:00
else
SetEffectNone();
2002-11-16 08:54:15 +00:00
}