Files
itgmania212121/stepmania/src/GameConstantsAndTypes.cpp
T

407 lines
8.3 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"
2005-02-18 12:06:19 +00:00
#include "LuaManager.h"
2005-02-22 23:11:59 +00:00
#include "GameManager.h"
2006-09-29 09:54:50 +00:00
#include "LocalizedString.h"
#include <float.h>
2005-06-24 06:06:16 +00:00
2006-01-22 01:00:06 +00:00
const RString RANKING_TO_FILL_IN_MARKER[NUM_PLAYERS] = {"#P1#","#P2#"};
2006-01-22 01:00:06 +00:00
extern const RString GROUP_ALL = "---Group All---";
2005-06-24 06:06:16 +00:00
static const char *RadarCategoryNames[] = {
2004-03-25 06:21:58 +00:00
"Stream",
"Voltage",
"Air",
"Freeze",
"Chaos",
"TapsAndHolds",
2004-03-25 06:21:58 +00:00
"Jumps",
"Holds",
"Mines",
"Hands",
2005-04-25 09:35:22 +00:00
"Rolls"
2004-03-12 08:31:40 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( RadarCategory );
2006-01-07 04:11:29 +00:00
XToLocalizedString( RadarCategory );
2006-09-26 07:48:47 +00:00
LuaFunction( RadarCategoryToLocalizedString, RadarCategoryToLocalizedString(Enum::Check<RadarCategory>(L, 1)) );
LuaXType( RadarCategory );
2004-03-12 08:31:40 +00:00
2006-09-27 06:09:52 +00:00
RString StepsTypeToString( StepsType st )
2005-02-22 23:11:59 +00:00
{
2006-09-27 06:09:52 +00:00
RString s = GAMEMAN->StepsTypeToString( st );
/* foo-bar -> Foo_Bar */
2006-09-27 06:09:52 +00:00
s.Replace('-','_');
for( size_t i = 0; i < s.size(); ++i )
2005-02-22 23:11:59 +00:00
{
2006-09-30 08:49:23 +00:00
if( i == 0 || s[i-1] == '_' )
s[i] = toupper( s[i] );
2005-02-22 23:11:59 +00:00
}
return s;
2005-02-22 23:11:59 +00:00
}
2006-09-27 06:09:52 +00:00
LuaXType( StepsType );
2005-02-22 23:11:59 +00:00
static const char *PlayModeNames[] = {
"Regular",
2004-03-25 06:21:58 +00:00
"Nonstop",
"Oni",
"Endless",
"Battle",
"Rave",
2004-03-12 08:31:40 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( PlayMode );
2006-01-07 04:11:29 +00:00
XToLocalizedString( PlayMode );
2004-03-12 08:31:40 +00:00
StringToX( PlayMode );
2006-09-26 20:13:20 +00:00
LuaFunction( PlayModeToLocalizedString, PlayModeToLocalizedString(Enum::Check<PlayMode>(L, 1)) );
2006-09-26 07:13:54 +00:00
LuaXType( PlayMode );
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;
}
static const char *RankingCategoryNames[] = {
2004-03-12 08:31:40 +00:00
"a",
"b",
"c",
"d",
};
2006-10-15 00:09:18 +00:00
XToString( RankingCategory );
2004-03-12 08:31:40 +00:00
StringToX( RankingCategory );
2003-06-16 17:28:58 +00:00
static const char *PlayerControllerNames[] = {
2005-05-18 07:15:56 +00:00
"Human",
"Autoplay",
"Cpu",
};
2006-10-15 00:09:18 +00:00
XToString( PlayerController );
2006-10-07 07:43:18 +00:00
StringToX( PlayerController );
2006-01-08 18:40:20 +00:00
XToLocalizedString( PlayerController );
2006-10-07 07:43:18 +00:00
LuaXType( PlayerController );
2005-05-18 07:15:56 +00:00
static const char *CoinModeNames[] = {
2006-09-26 07:48:47 +00:00
"Home",
"Pay",
"Free",
2004-03-12 08:31:40 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( CoinMode );
2006-10-07 07:43:18 +00:00
StringToX( CoinMode );
2006-09-26 07:48:47 +00:00
LuaXType( CoinMode );
2004-03-12 08:31:40 +00:00
static const char *PremiumNames[] = {
2006-09-26 07:33:26 +00:00
"None",
"Double",
"Joint",
};
2006-10-15 00:09:18 +00:00
XToString( Premium );
2006-10-07 07:43:18 +00:00
StringToX( Premium );
2006-09-26 07:33:26 +00:00
LuaXType( Premium );
static const char *SortOrderNames[] = {
2004-12-04 22:41:34 +00:00
"Preferred",
"Group",
"Title",
2005-07-16 02:59:58 +00:00
"BPM",
2004-12-04 22:41:34 +00:00
"Popularity",
2005-04-15 07:18:40 +00:00
"TopGrades",
2004-12-04 22:41:34 +00:00
"Artist",
2005-03-02 01:48:38 +00:00
"Genre",
2004-12-04 22:41:34 +00:00
"EasyMeter",
"MediumMeter",
"HardMeter",
"ChallengeMeter",
2005-04-15 07:18:40 +00:00
"ModeMenu",
"AllCourses",
2004-12-04 22:41:34 +00:00
"Nonstop",
"Oni",
"Endless",
"Roulette",
2003-07-20 06:26:29 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( SortOrder );
2004-03-12 08:31:40 +00:00
StringToX( SortOrder );
2006-09-26 07:48:47 +00:00
LuaXType( SortOrder );
2005-04-15 07:18:40 +00:00
2004-03-12 08:31:40 +00:00
static const char *TapNoteScoreNames[] = {
2004-03-12 08:31:40 +00:00
"None",
"HitMine",
"AvoidMine",
2004-03-12 08:31:40 +00:00
"Miss",
"W5",
"W4",
"W3",
"W2",
"W1",
2004-03-12 08:31:40 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( TapNoteScore );
2006-09-26 07:13:54 +00:00
LuaXType( TapNoteScore );
2006-01-22 01:00:06 +00:00
TapNoteScore StringToTapNoteScore( const RString &s )
{
// new style
2006-07-11 06:51:46 +00:00
if ( s == "None" ) return TNS_None;
else if( s == "HitMine" ) return TNS_HitMine;
else if( s == "AvoidMine" ) return TNS_AvoidMine;
else if( s == "Miss" ) return TNS_Miss;
else if( s == "W5" ) return TNS_W5;
else if( s == "W4" ) return TNS_W4;
else if( s == "W3" ) return TNS_W3;
else if( s == "W2" ) return TNS_W2;
else if( s == "W1" ) return TNS_W1;
// for backward compatibility
else if( s == "Boo" ) return TNS_W5;
else if( s == "Good" ) return TNS_W4;
else if( s == "Great" ) return TNS_W3;
else if( s == "Perfect" ) return TNS_W2;
else if( s == "Marvelous" ) return TNS_W1;
2006-10-07 04:39:48 +00:00
return TapNoteScore_Invalid;
}
2006-01-07 04:11:29 +00:00
XToLocalizedString( TapNoteScore );
2006-09-26 08:01:12 +00:00
LuaFunction( TapNoteScoreToLocalizedString, TapNoteScoreToLocalizedString(Enum::Check<TapNoteScore>(L, 1)) );
static const char *HoldNoteScoreNames[] = {
"None",
"LetGo",
"Held",
};
2006-10-15 00:09:18 +00:00
XToString( HoldNoteScore );
2006-09-26 08:01:12 +00:00
LuaXType( HoldNoteScore );
2006-01-22 01:00:06 +00:00
HoldNoteScore StringToHoldNoteScore( const RString &s )
{
// for backward compatibility
2006-07-13 05:52:56 +00:00
if ( s == "NG" ) return HNS_LetGo;
else if( s == "OK" ) return HNS_Held;
// new style
else if( s == "None" ) return HNS_None;
else if( s == "LetGo" ) return HNS_LetGo;
else if( s == "Held" ) return HNS_Held;
2006-10-07 04:39:48 +00:00
return HoldNoteScore_Invalid;
}
2006-01-07 04:11:29 +00:00
XToLocalizedString( HoldNoteScore );
2004-03-07 04:34:49 +00:00
static const char *TimingWindowNames[] = {
"W1",
"W2",
"W3",
"W4",
"W5",
"Mine",
"Attack",
"Hold",
"Roll",
};
XToString( TimingWindow );
2004-03-07 04:34:49 +00:00
2006-11-21 03:29:39 +00:00
static const char *ScoreEventNames[] = {
"W1",
"W2",
"W3",
"W4",
"W5",
"Miss",
"HitMine",
"Held",
"LetGo",
};
XToString( ScoreEvent );
static const char *MemoryCardStateNames[] = {
2004-03-12 08:31:40 +00:00
"ready",
"checking",
2004-03-12 08:31:40 +00:00
"late",
"error",
"removed",
2004-03-12 08:31:40 +00:00
"none",
};
2006-10-15 00:09:18 +00:00
XToString( MemoryCardState );
2004-03-07 04:34:49 +00:00
static const char *PerDifficultyAwardNames[] = {
"FullComboW3",
"SingleDigitW3",
"OneW3",
"FullComboW2",
"SingleDigitW2",
"OneW2",
"FullComboW1",
"Percent80W3",
"Percent90W3",
"Percent100W3",
2004-03-07 04:34:49 +00:00
};
2006-10-15 00:09:18 +00:00
XToString( PerDifficultyAward );
2006-01-07 04:11:29 +00:00
XToLocalizedString( PerDifficultyAward );
2004-03-07 04:34:49 +00:00
StringToX( PerDifficultyAward );
2006-09-26 07:33:26 +00:00
LuaFunction( PerDifficultyAwardToLocalizedString, PerDifficultyAwardToLocalizedString(Enum::Check<PerDifficultyAward>(L, 1)) );
LuaXType( 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 char *PeakComboAwardNames[] = {
2004-03-07 04:34:49 +00:00
"Peak1000Combo",
"Peak2000Combo",
"Peak3000Combo",
"Peak4000Combo",
"Peak5000Combo",
"Peak6000Combo",
"Peak7000Combo",
"Peak8000Combo",
"Peak9000Combo",
"Peak10000Combo",
};
2006-10-15 00:09:18 +00:00
XToString( PeakComboAward );
2006-01-07 04:11:29 +00:00
XToLocalizedString( PeakComboAward );
2004-03-07 04:34:49 +00:00
StringToX( PeakComboAward );
2006-09-26 07:33:26 +00:00
LuaFunction( PeakComboAwardToLocalizedString, PeakComboAwardToLocalizedString(Enum::Check<PeakComboAward>(L, 1)) );
LuaXType( PeakComboAward );
void DisplayBpms::Add( float f )
{
vfBpms.push_back( f );
}
float DisplayBpms::GetMin() const
{
float fMin = FLT_MAX;
FOREACH_CONST( float, vfBpms, f )
{
if( *f != -1 )
fMin = min( fMin, *f );
}
if( fMin == FLT_MAX )
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 char *StyleTypeNames[] = {
"OnePlayerOneSide",
"TwoPlayersTwoSides",
"OnePlayerTwoSides",
2006-06-16 23:46:36 +00:00
"TwoPlayersSharedSides",
};
2006-10-15 00:09:18 +00:00
XToString( StyleType );
StringToX( StyleType );
2006-10-06 23:09:03 +00:00
LuaXType( StyleType );
2005-02-06 05:15:57 +00:00
static const char *GoalTypeNames[] = {
2005-02-17 19:36:10 +00:00
"Calories",
"Time",
"None",
};
2006-10-15 00:09:18 +00:00
XToString( GoalType );
2005-02-17 19:36:10 +00:00
StringToX( GoalType );
2006-09-26 08:01:12 +00:00
LuaXType( GoalType );
2005-02-06 05:15:57 +00:00
2006-03-14 03:39:38 +00:00
static const char *EditModeNames[] = {
"Practice",
"CourseMods",
"Home",
"Full"
};
2006-10-15 00:09:18 +00:00
XToString( EditMode );
2006-03-14 03:39:38 +00:00
StringToX( EditMode );
2006-09-26 07:13:54 +00:00
LuaXType( EditMode );
2005-02-06 05:15:57 +00:00
static const char *StageNames[] = {
2005-05-06 10:48:32 +00:00
"1",
"2",
"3",
"4",
"5",
"6",
"Final",
"Extra1",
"Extra2",
"Nonstop",
"Oni",
"Endless",
"Event",
"Demo",
};
2006-10-15 00:09:18 +00:00
XToString( Stage );
2006-09-26 07:13:54 +00:00
LuaXType( Stage );
2005-05-06 10:48:32 +00:00
2006-04-21 00:43:32 +00:00
static const char *MultiPlayerStatusNames[] = {
"Joined",
"NotJoined",
"Unplugged",
"MissingMultitap",
};
2006-10-15 00:09:18 +00:00
XToString( MultiPlayerStatus );
2006-04-21 00:43:32 +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.
*/