Files
itgmania212121/stepmania/src/GameConstantsAndTypes.cpp
T

326 lines
7.1 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-07-27 19:29:51 +00:00
#include "GameConstantsAndTypes.h"
#include "GameState.h"
#include "RageUtil.h"
2005-02-02 06:53:31 +00:00
#include "ThemeMetric.h"
2004-03-29 09:44:00 +00:00
#include "EnumHelper.h"
#include "Foreach.h"
#include "PrefsManager.h"
2005-02-18 12:06:19 +00:00
#include "LuaManager.h"
2005-02-22 23:11:59 +00:00
#include "GameManager.h"
2004-03-12 08:31:40 +00:00
static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = {
2004-03-25 06:21:58 +00:00
"Stream",
"Voltage",
"Air",
"Freeze",
"Chaos",
"Taps",
"Jumps",
"Holds",
"Mines",
"Hands",
2004-03-12 08:31:40 +00:00
};
2005-03-05 21:50:33 +00:00
XToString( RadarCategory, NUM_RADAR_CATEGORIES );
2005-02-02 06:53:31 +00:00
XToThemedString( RadarCategory, NUM_RADAR_CATEGORIES );
2004-03-12 08:31:40 +00:00
2005-02-23 05:02:28 +00:00
static void LuaStepsType(lua_State* L)
2005-02-22 23:11:59 +00:00
{
FOREACH_StepsType( st )
{
CString s = GAMEMAN->StepsTypeToString( st );
s.MakeUpper();
s.Replace('-','_');
LUA->SetGlobal( "STEPS_TYPE_"+s, st );
}
}
REGISTER_WITH_LUA_FUNCTION( LuaStepsType );
2004-03-12 08:31:40 +00:00
static const CString PlayModeNames[NUM_PLAY_MODES] = {
"Regular",
2004-03-25 06:21:58 +00:00
"Nonstop",
"Oni",
"Endless",
"Battle",
"Rave",
2004-03-12 08:31:40 +00:00
};
2005-03-05 21:50:33 +00:00
XToString( PlayMode, NUM_PLAY_MODES );
2005-02-02 06:53:31 +00:00
XToThemedString( PlayMode, NUM_PLAY_MODES );
2004-03-12 08:31:40 +00:00
StringToX( PlayMode );
2005-02-23 05:02:28 +00:00
static void LuaPlayMode(lua_State* L)
2005-02-21 06:49:43 +00:00
{
FOREACH_PlayMode( pm )
{
CString s = PlayModeNames[pm];
s.MakeUpper();
LUA->SetGlobal( "PLAY_MODE_"+s, pm );
}
LUA->SetGlobal( "NUM_PLAY_MODES", NUM_PLAY_MODES );
}
REGISTER_WITH_LUA_FUNCTION( LuaPlayMode );
2004-08-30 06:41:56 +00:00
RankingCategory AverageMeterToRankingCategory( int iAverageMeter )
{
2004-08-30 06:45:43 +00:00
if( iAverageMeter <= 3 ) return RANKING_A;
else if( iAverageMeter <= 6 ) return RANKING_B;
else if( iAverageMeter <= 9 ) return RANKING_C;
2003-01-26 07:33:03 +00:00
else return RANKING_D;
}
2004-03-12 08:31:40 +00:00
static const CString RankingCategoryNames[NUM_RANKING_CATEGORIES] = {
"a",
"b",
"c",
"d",
};
2005-03-05 21:50:33 +00:00
XToString( RankingCategory, NUM_RANKING_CATEGORIES );
2004-03-12 08:31:40 +00:00
StringToX( RankingCategory );
2003-06-16 17:28:58 +00:00
2004-03-12 08:31:40 +00:00
static const CString CoinModeNames[NUM_COIN_MODES] = {
"home",
"pay",
"free",
};
2005-03-05 21:50:33 +00:00
XToString( CoinMode, NUM_COIN_MODES );
2004-03-12 08:31:40 +00:00
static const CString PremiumNames[NUM_PREMIUMS] = {
"none",
"doubles",
"joint",
};
2005-03-05 21:50:33 +00:00
XToString( Premium, NUM_PREMIUMS );
2004-03-12 08:31:40 +00:00
static const CString SortOrderNames[NUM_SORT_ORDERS] = {
2004-12-04 22:41:34 +00:00
"Preferred",
"Group",
"Title",
2003-07-20 06:26:29 +00:00
"BPM",
2004-12-04 22:41:34 +00:00
"Popularity",
"TopGrade",
"Artist",
2005-03-02 01:48:38 +00:00
"Genre",
2004-12-04 22:41:34 +00:00
"EasyMeter",
"MediumMeter",
"HardMeter",
"ChallengeMeter",
"Mode",
"Courses",
"Nonstop",
"Oni",
"Endless",
"Roulette",
2003-07-20 06:26:29 +00:00
};
2005-03-05 21:50:33 +00:00
XToString( SortOrder, NUM_SORT_ORDERS );
2004-03-12 08:31:40 +00:00
StringToX( SortOrder );
static const CString TapNoteScoreNames[NUM_TAP_NOTE_SCORES] = {
"None",
"HitMine",
"Miss",
"Boo",
"Good",
"Great",
"Perfect",
"Marvelous",
};
2005-03-05 21:50:33 +00:00
XToString( TapNoteScore, NUM_TAP_NOTE_SCORES );
StringToX( TapNoteScore );
2005-02-02 06:53:31 +00:00
XToThemedString( TapNoteScore, NUM_TAP_NOTE_SCORES );
static const CString HoldNoteScoreNames[NUM_HOLD_NOTE_SCORES] = {
"None",
"NG",
2004-08-30 22:43:30 +00:00
"OK",
};
2005-03-05 21:50:33 +00:00
XToString( HoldNoteScore, NUM_HOLD_NOTE_SCORES );
StringToX( HoldNoteScore );
2005-02-02 06:53:31 +00:00
XToThemedString( HoldNoteScore, NUM_HOLD_NOTE_SCORES );
2004-03-07 04:34:49 +00:00
2004-03-12 08:31:40 +00:00
static const CString MemoryCardStateNames[NUM_MEMORY_CARD_STATES] = {
"ready",
"checking",
2004-03-12 08:31:40 +00:00
"late",
"error",
"removed",
2004-03-12 08:31:40 +00:00
"none",
};
2005-03-05 21:50:33 +00:00
XToString( MemoryCardState, NUM_MEMORY_CARD_STATES );
2004-03-07 04:34:49 +00:00
2004-03-12 08:31:40 +00:00
static const CString PerDifficultyAwardNames[NUM_PER_DIFFICULTY_AWARDS] = {
2004-03-07 04:34:49 +00:00
"FullComboGreats",
"SingleDigitGreats",
2004-03-25 08:32:47 +00:00
"OneGreat",
2004-06-22 08:41:25 +00:00
"FullComboPerfects",
"SingleDigitPerfects",
2004-03-25 08:32:47 +00:00
"OnePerfect",
2004-06-22 08:41:25 +00:00
"FullComboMarvelouses",
2004-03-07 04:34:49 +00:00
"Greats80Percent",
"Greats90Percent",
"Greats100Percent",
};
2005-03-05 21:50:33 +00:00
XToString( PerDifficultyAward, NUM_PER_DIFFICULTY_AWARDS );
2005-02-02 06:53:31 +00:00
XToThemedString( PerDifficultyAward, NUM_PER_DIFFICULTY_AWARDS );
2004-03-07 04:34:49 +00:00
StringToX( PerDifficultyAward );
2004-03-12 08:31:40 +00:00
// Numbers are intentially not at the front of these strings so that the
// strings can be used as XML entity names.
// Numbers are intentially not at the back so that "1000" and "10000" don't
// conflict when searching for theme elements.
static const CString PeakComboAwardNames[NUM_PEAK_COMBO_AWARDS] = {
2004-03-07 04:34:49 +00:00
"Peak1000Combo",
"Peak2000Combo",
"Peak3000Combo",
"Peak4000Combo",
"Peak5000Combo",
"Peak6000Combo",
"Peak7000Combo",
"Peak8000Combo",
"Peak9000Combo",
"Peak10000Combo",
};
2005-03-05 21:50:33 +00:00
XToString( PeakComboAward, NUM_PEAK_COMBO_AWARDS );
2005-02-02 06:53:31 +00:00
XToThemedString( PeakComboAward, NUM_PEAK_COMBO_AWARDS );
2004-03-07 04:34:49 +00:00
StringToX( PeakComboAward );
#include "LuaFunctions.h"
#define LuaXToString(X) \
CString Lua##X##ToString( int n ) \
{ return X##ToString( (X) n ); } \
LuaFunction_Int( X##ToString, Lua##X##ToString(a1) ); /* register it */
#define LuaStringToX(X) \
X LuaStringTo##X( CString s ) \
{ return (X) StringTo##X( s ); } \
LuaFunction_Str( StringTo##X, LuaStringTo##X(str) ); /* register it */
LuaXToString( Difficulty );
LuaStringToX( Difficulty );
void DisplayBpms::Add( float f )
{
vfBpms.push_back( f );
}
float DisplayBpms::GetMin() const
{
float fMin = 99999;
FOREACH_CONST( float, vfBpms, f )
{
if( *f != -1 )
fMin = min( fMin, *f );
}
if( fMin == 99999 )
return 0;
else
return fMin;
}
float DisplayBpms::GetMax() const
{
float fMax = 0;
FOREACH_CONST( float, vfBpms, f )
{
if( *f != -1 )
fMax = max( fMax, *f );
}
return fMax;
}
bool DisplayBpms::BpmIsConstant() const
{
return fabsf( GetMin() - GetMax() ) < 0.001f;
}
2005-03-10 22:54:55 +00:00
bool DisplayBpms::IsSecret() const
{
FOREACH_CONST( float, vfBpms, f )
{
if( *f == -1 )
return true;
}
return false;
}
2004-05-31 22:42:12 +00:00
static const CString StyleTypeNames[NUM_STYLE_TYPES] = {
"OnePlayerOneSide",
"TwoPlayersTwoSides",
"OnePlayerTwoSides",
};
2005-03-05 21:50:33 +00:00
XToString( StyleType, NUM_STYLE_TYPES );
StringToX( StyleType );
2005-02-06 05:15:57 +00:00
static const CString MenuDirNames[NUM_MENU_DIRS] = {
"Up",
"Down",
"Left",
"Right",
"Auto",
};
2005-03-05 21:50:33 +00:00
XToString( MenuDir, NUM_MENU_DIRS );
2005-02-17 19:36:10 +00:00
static const CString GoalTypeNames[NUM_GOAL_TYPES] = {
"Calories",
"Time",
"None",
};
2005-03-05 21:50:33 +00:00
XToString( GoalType, NUM_GOAL_TYPES );
2005-02-17 19:36:10 +00:00
StringToX( GoalType );
2005-02-23 05:02:28 +00:00
static void LuaGoalType(lua_State* L)
2005-02-18 12:06:19 +00:00
{
FOREACH_GoalType( gt )
{
CString s = GoalTypeNames[gt];
s.MakeUpper();
2005-02-19 01:02:15 +00:00
LUA->SetGlobal( "GOAL_"+s, gt );
2005-02-18 12:06:19 +00:00
}
}
REGISTER_WITH_LUA_FUNCTION( LuaGoalType );
2005-02-06 05:15:57 +00:00
#include "LuaFunctions.h"
LuaFunction_NoArgs( CoinMode, CoinModeToString(PREFSMAN->m_CoinMode) )
LuaFunction_NoArgs( Premium, PremiumToString(PREFSMAN->m_Premium) )
2005-02-18 12:06:19 +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.
*/