2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-01-16 10:01:32 +00:00
|
|
|
#include "Grade.h"
|
2004-01-20 03:32:48 +00:00
|
|
|
#include "RageUtil.h"
|
2004-02-16 09:23:34 +00:00
|
|
|
#include "ThemeManager.h"
|
2004-05-20 03:50:42 +00:00
|
|
|
#include "RageLog.h"
|
2005-03-31 02:06:24 +00:00
|
|
|
#include "EnumHelper.h"
|
|
|
|
|
#include "LuaManager.h"
|
2002-01-16 10:01:32 +00:00
|
|
|
|
2006-09-26 07:13:54 +00:00
|
|
|
LuaXType( Grade );
|
2005-03-31 06:14:28 +00:00
|
|
|
|
2008-04-04 18:24:35 +00:00
|
|
|
ThemeMetric<int> NUM_GRADE_TIERS_USED("PlayerStageStats","NumGradeTiersUsed");
|
|
|
|
|
|
|
|
|
|
Grade GetNextPossibleGrade( Grade g )
|
|
|
|
|
{
|
|
|
|
|
if( g < NUM_GRADE_TIERS_USED - 1 )
|
|
|
|
|
return (Grade)(g+1);
|
|
|
|
|
else if( g == NUM_GRADE_TIERS_USED - 1 )
|
|
|
|
|
return Grade_Failed;
|
|
|
|
|
else
|
|
|
|
|
return Grade_Invalid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString GradeToLocalizedString( Grade g )
|
2004-02-16 09:23:34 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString s = GradeToString(g);
|
2006-06-24 05:13:54 +00:00
|
|
|
if( !THEME->HasString("Grade",s) )
|
2004-02-22 03:06:54 +00:00
|
|
|
return "???";
|
2006-01-08 18:40:20 +00:00
|
|
|
return THEME->GetString( "Grade",s );
|
2004-02-16 09:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
RString GradeToOldString( Grade g )
|
2004-01-20 07:09:44 +00:00
|
|
|
{
|
|
|
|
|
// string is meant to be human readable
|
|
|
|
|
switch( g )
|
|
|
|
|
{
|
2005-08-14 11:38:31 +00:00
|
|
|
case Grade_Tier01: return "AAAA";
|
|
|
|
|
case Grade_Tier02: return "AAA";
|
|
|
|
|
case Grade_Tier03: return "AA";
|
|
|
|
|
case Grade_Tier04: return "A";
|
|
|
|
|
case Grade_Tier05: return "B";
|
|
|
|
|
case Grade_Tier06: return "C";
|
|
|
|
|
case Grade_Tier07: return "D";
|
|
|
|
|
case Grade_Failed: return "E";
|
|
|
|
|
case Grade_NoData: return "N";
|
2006-09-15 04:40:27 +00:00
|
|
|
default: return "N";
|
2002-02-02 05:11:12 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
Grade StringToGrade( const RString &sGrade )
|
2002-02-02 05:11:12 +00:00
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
RString s = sGrade;
|
2002-02-02 05:11:12 +00:00
|
|
|
s.MakeUpper();
|
2004-01-20 03:32:48 +00:00
|
|
|
|
2005-10-09 04:30:59 +00:00
|
|
|
// new style
|
|
|
|
|
int iTier;
|
2006-09-15 22:50:15 +00:00
|
|
|
if( sscanf(sGrade.c_str(),"Tier%02d",&iTier) == 1 && iTier >= 0 && iTier < NUM_Grade)
|
2006-09-15 04:40:27 +00:00
|
|
|
return (Grade)(iTier-1);
|
|
|
|
|
else if( s == "FAILED" )
|
|
|
|
|
return Grade_Failed;
|
|
|
|
|
else if( s == "NODATA" )
|
|
|
|
|
return Grade_NoData;
|
2005-10-09 04:30:59 +00:00
|
|
|
|
2004-05-20 03:50:42 +00:00
|
|
|
LOG->Warn( "Invalid grade: %s", sGrade.c_str() );
|
2005-08-14 11:38:31 +00:00
|
|
|
return Grade_NoData;
|
2002-02-02 05:11:12 +00:00
|
|
|
};
|
2004-01-20 03:32:48 +00:00
|
|
|
|
2004-05-31 22:42:12 +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.
|
|
|
|
|
*/
|