2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
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"
|
2004-06-10 22:47:51 +00:00
|
|
|
#include "arch/Dialog/Dialog.h"
|
2004-06-03 08:22:02 +00:00
|
|
|
#include "Trail.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 );
|
2004-06-10 22:47:51 +00:00
|
|
|
Dialog::OK( sError );
|
2004-02-08 01:05:53 +00:00
|
|
|
}
|
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-06-03 08:22:02 +00:00
|
|
|
void DifficultyIcon::SetFromTrail( PlayerNumber pn, Trail* pTrail )
|
|
|
|
|
{
|
|
|
|
|
if( pTrail == NULL )
|
|
|
|
|
m_bBlank = true;
|
|
|
|
|
else
|
2004-06-04 03:42:49 +00:00
|
|
|
SetFromDifficulty( pn, pTrail->m_CourseDifficulty );
|
2004-06-03 08:22:02 +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-06-01 00:53:06 +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.
|
|
|
|
|
*/
|