clean up ScreenTestLights

This commit is contained in:
Chris Danford
2004-03-29 09:44:00 +00:00
parent 60a89b8cf4
commit 936f2066e1
10 changed files with 66 additions and 49 deletions
+37
View File
@@ -0,0 +1,37 @@
#ifndef EnumHelper_H
#define EnumHelper_H
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; ((int&)var)++ )
static const CString EMPTY_STRING;
#define XToString(X) \
const CString& X##ToString( X x ) \
{ \
if( x == ARRAYSIZE(X##Names)+1 ) \
return EMPTY_STRING; \
ASSERT(unsigned(x) < ARRAYSIZE(X##Names)); \
return X##Names[x]; \
}
#define XToThemedString(X) \
CString X##ToThemedString( X x ) \
{ \
return THEME->GetMetric( #X, X##ToString(x) ); \
}
#define StringToX(X) \
X StringTo##X( const CString& s ) \
{ \
CString s2 = s; \
s2.MakeLower(); \
unsigned i; \
for( i = 0; i < ARRAYSIZE(X##Names); ++i ) \
if( !s2.CompareNoCase(X##Names[i]) ) \
return (X)i; \
return (X)(i+1); /*invalid*/ \
}
#endif
-6
View File
@@ -1,6 +0,0 @@
#ifndef FOREACHENUM_H
#define FOREACHENUM_H
#define FOREACH_ENUM( e, max, var ) for( e var=(e)0; var<max; ((int&)var)++ )
#endif
+1 -29
View File
@@ -14,35 +14,7 @@
#include "GameState.h"
#include "RageUtil.h"
#include "ThemeManager.h"
static const CString EMPTY_STRING;
#define XToString(X) \
const CString& X##ToString( X x ) \
{ \
if( x == ARRAYSIZE(X##Names)+1 ) \
return EMPTY_STRING; \
ASSERT(unsigned(x) < ARRAYSIZE(X##Names)); \
return X##Names[x]; \
}
#define XToThemedString(X) \
CString X##ToThemedString( X x ) \
{ \
return THEME->GetMetric( #X, X##ToString(x) ); \
}
#define StringToX(X) \
X StringTo##X( const CString& s ) \
{ \
CString s2 = s; \
s2.MakeLower(); \
unsigned i; \
for( i = 0; i < ARRAYSIZE(X##Names); ++i ) \
if( !s2.CompareNoCase(X##Names[i]) ) \
return (X)i; \
return (X)(i+1); /*invalid*/ \
}
#include "EnumHelper.h"
static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = {
+1 -8
View File
@@ -14,7 +14,7 @@
*/
#include "PlayerNumber.h" // TODO: Get rid of this dependency. -Chris
#include "ForeachEnum.h"
#include "EnumHelper.h"
//
// Screen Dimensions
@@ -59,7 +59,6 @@ enum RadarCategory
NUM_RADAR_CATEGORIES // leave this at the end
};
#define FOREACH_RadarCategory( rc ) FOREACH_ENUM( RadarCategory, NUM_RADAR_CATEGORIES, rc )
const CString& RadarCategoryToString( RadarCategory cat );
struct RadarValues
@@ -96,7 +95,6 @@ enum Difficulty
DIFFICULTY_INVALID
};
#define FOREACH_Difficulty( dc ) FOREACH_ENUM( Difficulty, NUM_DIFFICULTIES, dc )
const CString& DifficultyToString( Difficulty dc );
CString DifficultyToThemedString( Difficulty dc );
Difficulty StringToDifficulty( const CString& sDC );
@@ -110,7 +108,6 @@ enum CourseDifficulty
COURSE_DIFFICULTY_INVALID
};
#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, NUM_COURSE_DIFFICULTIES, cd )
const CString& CourseDifficultyToString( CourseDifficulty dc );
CString CourseDifficultyToThemedString( CourseDifficulty dc );
CourseDifficulty StringToCourseDifficulty( const CString& sDC );
@@ -165,7 +162,6 @@ enum PlayMode
PLAY_MODE_INVALID
};
#define FOREACH_PlayMode( pm ) FOREACH_ENUM( PlayMode, NUM_PLAY_MODES, pm )
const CString& PlayModeToString( PlayMode pm );
PlayMode StringToPlayMode( const CString& s );
@@ -195,9 +191,7 @@ enum SortOrder {
SORT_INVALID
};
const SortOrder MAX_SELECTABLE_SORT = (SortOrder)(SORT_ROULETTE-1);
#define FOREACH_SortOrder( so ) FOREACH_ENUM( SortOrder, NUM_SORT_ORDERS, so )
const CString& SortOrderToString( SortOrder so );
SortOrder StringToSortOrder( const CString& str );
@@ -219,7 +213,6 @@ enum TapNoteScore {
NUM_TAP_NOTE_SCORES
};
#define FOREACH_TapNoteScore( tns ) FOREACH_ENUM( TapNoteScore, NUM_TAP_NOTE_SCORES, tns )
const CString& TapNoteScoreToString( TapNoteScore tns );
//enum TapNoteTiming {
+1 -1
View File
@@ -11,7 +11,7 @@
-----------------------------------------------------------------------------
*/
#include "ForeachEnum.h"
#include "EnumHelper.h"
enum GameController
{
+13
View File
@@ -20,6 +20,19 @@
#include "InputMapper.h"
static const CString CabinetLightNames[NUM_CABINET_LIGHTS] = {
"MarqueeUpLeft",
"MarqueeUpRight",
"MarqueeLrLeft",
"MarqueeLrRight",
"ButtonsLeft",
"ButtonsRight",
"BassLeft",
"BassRight",
};
XToString( CabinetLight );
LightsManager* LIGHTSMAN = NULL; // global and accessable from anywhere in our program
LightsManager::LightsManager(CString sDriver)
+2 -1
View File
@@ -13,7 +13,7 @@
#include "PlayerNumber.h"
#include "GameInput.h"
#include "ForeachEnum.h"
#include "EnumHelper.h"
enum CabinetLight
{
@@ -28,6 +28,7 @@ enum CabinetLight
NUM_CABINET_LIGHTS
};
#define FOREACH_CabinetLight( i ) FOREACH_ENUM( CabinetLight, NUM_CABINET_LIGHTS, i )
const CString& CabinetLightToString( CabinetLight cl );
enum LightsMode
{
+1 -1
View File
@@ -14,7 +14,7 @@
*/
#include "RageTypes.h" // for RageColor
#include "ForeachEnum.h"
#include "EnumHelper.h"
//
+2 -1
View File
@@ -249,7 +249,8 @@ void PlayerOptions::FromString( CString sOptions )
#define SET_FLOAT( opt ) \
{ m_ ## opt = level; m_Speed ## opt = speed; }
const bool on = (level > 0.5f);
if( sBit == "boost" ) SET_FLOAT( fAccels[ACCEL_BOOST] )
if( sBit == "clearall" ) Init();
else if( sBit == "boost" ) SET_FLOAT( fAccels[ACCEL_BOOST] )
else if( sBit == "brake" || sBit == "land" ) SET_FLOAT( fAccels[ACCEL_BRAKE] )
else if( sBit == "wave" ) SET_FLOAT( fAccels[ACCEL_WAVE] )
else if( sBit == "expand" ) SET_FLOAT( fAccels[ACCEL_EXPAND] )
+8 -2
View File
@@ -59,10 +59,16 @@ void ScreenTestLights::Update( float fDeltaTime )
int iSec = (int)RageTimer::GetTimeSinceStart();
CabinetLight cl = (CabinetLight)(iSec%NUM_CABINET_LIGHTS);
int iNumGameButtons = GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController;
GameButton gb = (GameButton)(iSec%iNumGameButtons);
CString sCabLight = CabinetLightToString(cl);
CString sGameButton = GAMESTATE->GetCurrentGameDef()->m_szButtonNames[gb];
CString s;
s += ssprintf("cabinet light %d\n", iSec%NUM_CABINET_LIGHTS);
s += ssprintf("cabinet light %d: %s\n", cl, sCabLight.c_str());
FOREACH_GameController( gc )
s += ssprintf("controller %d light %d\n", gc+1, iSec%MAX_GAME_BUTTONS);
s += ssprintf("controller %d light %d: %s\n", gc+1, gb, sGameButton.c_str());
m_textInputs.SetText( s );
}