Files
itgmania212121/stepmania/src/DifficultyMeter.cpp
T

110 lines
2.6 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
// const int NUM_FEET_IN_METER = 10;
// const int MAX_FEET_IN_METER = 14;
// const int GLOW_IF_METER_GREATER_THAN = 9;
#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
}
2003-08-03 00:13:55 +00:00
void DifficultyMeter::SetFromNotes( 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()) );
}
void DifficultyMeter::SetFromCourse( Course* pCourse )
{
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
int meter = (int) roundf(pCourse->GetMeter());
2003-07-21 22:38:41 +00:00
SetMeter( meter );
// XXX
if(meter <= 1 )
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_BEGINNER) );
else if(meter <= 2 )
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_EASY) );
else if(meter <= 5 )
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_MEDIUM) );
else if(meter <= 7 )
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_HARD) );
else
SetDiffuse( SONGMAN->GetDifficultyColor(DIFFICULTY_CHALLENGE) );
}
void DifficultyMeter::Unset()
{
this->SetEffectNone();
SetDiffuse( RageColor(0.8f,0.8f,0.8f,1) );
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 )
this->SetEffectGlowShift();
else
this->SetEffectNone();
2002-11-16 08:54:15 +00:00
}