2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-01-16 10:01:32 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-10-06 16:56:58 +00:00
|
|
|
Class: DifficultyIcon
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-10-06 16:56:58 +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-10-06 16:56:58 +00:00
|
|
|
Chris Danford
|
2002-01-16 10:01:32 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-11-17 01:41:49 +00:00
|
|
|
/* Obsolete: use DifficultyClass. */
|
2004-03-08 02:21:22 +00:00
|
|
|
/* DifficultyClass was the old name for enum Difficulty, right? -Chris */
|
2004-03-08 02:43:11 +00:00
|
|
|
/* Maybe, but that wouldn't make sense. I might have meant DifficultyMeter, whose
|
|
|
|
|
* functionality is a superset of DifficultyIcon; this class can probably be phased
|
|
|
|
|
* out. -glenn */
|
2004-03-08 02:21:22 +00:00
|
|
|
|
2002-01-16 10:01:32 +00:00
|
|
|
#include "DifficultyIcon.h"
|
2002-10-06 16:56:58 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "RageLog.h"
|
2003-08-03 00:13:55 +00:00
|
|
|
#include "Steps.h"
|
2002-10-06 16:56:58 +00:00
|
|
|
#include "GameState.h"
|
2003-08-02 19:27:57 +00:00
|
|
|
#include "RageDisplay.h"
|
|
|
|
|
#include "arch/ArchHooks/ArchHooks.h"
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2004-04-28 22:57:42 +00:00
|
|
|
DifficultyIcon::DifficultyIcon()
|
|
|
|
|
{
|
|
|
|
|
m_bBlank = false;
|
|
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2002-10-06 16:56:58 +00:00
|
|
|
bool DifficultyIcon::Load( CString sPath )
|
|
|
|
|
{
|
|
|
|
|
Sprite::Load( sPath );
|
2003-09-27 21:49:02 +00:00
|
|
|
int iStates = GetNumStates();
|
2004-02-08 01:05:53 +00:00
|
|
|
if( iStates != NUM_DIFFICULTIES && iStates != NUM_DIFFICULTIES*2 )
|
|
|
|
|
{
|
|
|
|
|
CString sError = ssprintf(
|
|
|
|
|
"The difficulty icon graphic '%s' must have %d or %d frames. It has %d states.",
|
|
|
|
|
sPath.c_str(),
|
|
|
|
|
NUM_DIFFICULTIES,
|
|
|
|
|
NUM_DIFFICULTIES*2,
|
|
|
|
|
iStates );
|
|
|
|
|
HOOKS->MessageBoxOK( sError );
|
|
|
|
|
}
|
2002-10-06 16:56:58 +00:00
|
|
|
StopAnimating();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2004-05-29 04:50:47 +00:00
|
|
|
void DifficultyIcon::SetFromSteps( PlayerNumber pn, Steps* pSteps )
|
2002-10-06 16:56:58 +00:00
|
|
|
{
|
2004-05-24 03:41:39 +00:00
|
|
|
if( pSteps == NULL )
|
2004-04-28 22:57:42 +00:00
|
|
|
m_bBlank = true;
|
2002-10-06 16:56:58 +00:00
|
|
|
else
|
2004-05-24 03:41:39 +00:00
|
|
|
SetFromDifficulty( pn, pSteps->GetDifficulty() );
|
2004-03-08 02:21:22 +00:00
|
|
|
}
|
2002-10-06 16:56:58 +00:00
|
|
|
|
2004-03-08 02:21:22 +00:00
|
|
|
void DifficultyIcon::SetFromDifficulty( PlayerNumber pn, Difficulty dc )
|
|
|
|
|
{
|
2004-04-28 22:57:42 +00:00
|
|
|
m_bBlank = false;
|
2004-03-08 02:21:22 +00:00
|
|
|
switch( GetNumStates() )
|
|
|
|
|
{
|
|
|
|
|
case NUM_DIFFICULTIES: SetState( dc ); break;
|
|
|
|
|
case NUM_DIFFICULTIES*2: SetState( dc*2+pn ); break;
|
2004-04-28 23:36:18 +00:00
|
|
|
default: m_bBlank = true; break;
|
2004-03-08 02:21:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-10-06 16:56:58 +00:00
|
|
|
|
2004-03-08 02:21:22 +00:00
|
|
|
void DifficultyIcon::SetFromCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
|
|
|
|
|
{
|
2004-04-28 22:57:42 +00:00
|
|
|
m_bBlank = false;
|
2004-03-08 02:21:22 +00:00
|
|
|
switch( cd )
|
|
|
|
|
{
|
2004-05-22 04:41:25 +00:00
|
|
|
case COURSE_DIFFICULTY_EASY: SetFromDifficulty(pn,DIFFICULTY_EASY); break;
|
2004-03-08 02:21:22 +00:00
|
|
|
case COURSE_DIFFICULTY_REGULAR: SetFromDifficulty(pn,DIFFICULTY_MEDIUM); break;
|
|
|
|
|
case COURSE_DIFFICULTY_DIFFICULT: SetFromDifficulty(pn,DIFFICULTY_HARD); break;
|
|
|
|
|
default: ASSERT(0);
|
2002-10-06 16:56:58 +00:00
|
|
|
}
|
|
|
|
|
}
|