force TypeName arrays for XToString to be an array of const char*, not CString

This commit is contained in:
Glenn Maynard
2006-01-04 22:30:51 +00:00
parent 8ed46bd67f
commit b734b602d2
30 changed files with 65 additions and 56 deletions
+1 -1
View File
@@ -497,7 +497,7 @@ void ActorUtil::SortByZPosition( vector<Actor*> &vActors )
stable_sort( vActors.begin(), vActors.end(), CompareActorsByZPosition ); stable_sort( vActors.begin(), vActors.end(), CompareActorsByZPosition );
} }
static const CString FileTypeNames[] = { static const char *FileTypeNames[] = {
"Bitmap", "Bitmap",
"Movie", "Movie",
"Directory", "Directory",
+1 -1
View File
@@ -11,7 +11,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "PlayerState.h" #include "PlayerState.h"
const CString CodeNames[] = { const char *CodeNames[] = {
"Easier1", "Easier1",
"Easier2", "Easier2",
"Harder1", "Harder1",
+2 -2
View File
@@ -24,7 +24,7 @@
#include "LuaFunctions.h" #include "LuaFunctions.h"
static const CString CourseTypeNames[] = { static const char *CourseTypeNames[] = {
"Nonstop", "Nonstop",
"Oni", "Oni",
"Endless", "Endless",
@@ -36,7 +36,7 @@ XToThemedString( CourseType, NUM_CourseType );
LuaFunction( CourseTypeToThemedString, CourseTypeToThemedString((CourseType) IArg(1)) ); LuaFunction( CourseTypeToThemedString, CourseTypeToThemedString((CourseType) IArg(1)) );
static const CString SongSortNames[] = { static const char *SongSortNames[] = {
"Randomize", "Randomize",
"MostPlays", "MostPlays",
"FewestPlays", "FewestPlays",
+2 -2
View File
@@ -158,7 +158,7 @@ CString LastDayToString( int iLastDayIndex )
return LAST_DAYS_NAME[iLastDayIndex]; return LAST_DAYS_NAME[iLastDayIndex];
} }
static const CString DAY_OF_WEEK_TO_NAME[DAYS_IN_WEEK] = static const char *DAY_OF_WEEK_TO_NAME[DAYS_IN_WEEK] =
{ {
"Sunday", "Sunday",
"Monday", "Monday",
@@ -179,7 +179,7 @@ CString HourInDayToString( int iHourInDayIndex )
return ssprintf("Hour%02d", iHourInDayIndex); return ssprintf("Hour%02d", iHourInDayIndex);
} }
static const CString MonthNames[] = static const char *MonthNames[] =
{ {
"January", "January",
"February", "February",
+2 -2
View File
@@ -6,7 +6,7 @@
#include "LuaFunctions.h" #include "LuaFunctions.h"
static const CString DifficultyNames[] = { static const char *DifficultyNames[] = {
"Beginner", "Beginner",
"Easy", "Easy",
"Medium", "Medium",
@@ -60,7 +60,7 @@ REGISTER_WITH_LUA_FUNCTION( LuaDifficulty );
static const CString CourseDifficultyNames[] = static const char *CourseDifficultyNames[] =
{ {
"Beginner", "Beginner",
"Easy", "Easy",
+2 -2
View File
@@ -15,7 +15,7 @@
#include "SongUtil.h" #include "SongUtil.h"
static const CString EditMenuRowNames[] = { static const char *EditMenuRowNames[] = {
"Group", "Group",
"Song", "Song",
"StepsType", "StepsType",
@@ -27,7 +27,7 @@ static const CString EditMenuRowNames[] = {
XToString( EditMenuRow, NUM_EDIT_MENU_ROWS ); XToString( EditMenuRow, NUM_EDIT_MENU_ROWS );
XToThemedString( EditMenuRow, NUM_EDIT_MENU_ROWS ); XToThemedString( EditMenuRow, NUM_EDIT_MENU_ROWS );
static const CString EditMenuActionNames[] = { static const char *EditMenuActionNames[] = {
"Edit", "Edit",
"Delete", "Delete",
"Create", "Create",
+10 -1
View File
@@ -45,14 +45,23 @@ static inline T enum_add2( T val, int iAmt )
static const CString EMPTY_STRING; static const CString EMPTY_STRING;
// TypeName[] must be an array of const char *, not RString, to
// avoid initialization order problems when calling XToString.
static void CheckXToStringParamType( const char **p ) { }
#define XToString(X, CNT) \ #define XToString(X, CNT) \
const CString& X##ToString( X x ) \ const CString& X##ToString( X x ) \
{ \ { \
CheckXToStringParamType( X##Names ); \
static auto_ptr<CString> as_##X##Name[CNT]; \
if( as_##X##Name[0].get() == NULL ) { \
for( unsigned i = 0; i < CNT; ++i ) \
as_##X##Name[i].reset( new CString(X##Names[i]) ); \
} \
ASSERT( CNT == ARRAYSIZE(X##Names) ); \ ASSERT( CNT == ARRAYSIZE(X##Names) ); \
if( x == CNT+1 ) \ if( x == CNT+1 ) \
return EMPTY_STRING; \ return EMPTY_STRING; \
ASSERT( x < CNT ); \ ASSERT( x < CNT ); \
return X##Names[x]; \ return *as_##X##Name[x]; \
} }
#define XToThemedString(X, CNT) \ #define XToThemedString(X, CNT) \
+16 -16
View File
@@ -15,7 +15,7 @@ const CString RANKING_TO_FILL_IN_MARKER[NUM_PLAYERS] = {"#P1#","#P2#"};
extern const CString GROUP_ALL = "---Group All---"; extern const CString GROUP_ALL = "---Group All---";
static const CString RadarCategoryNames[] = { static const char *RadarCategoryNames[] = {
"Stream", "Stream",
"Voltage", "Voltage",
"Air", "Air",
@@ -56,7 +56,7 @@ static void LuaStepsType(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaStepsType ); REGISTER_WITH_LUA_FUNCTION( LuaStepsType );
static const CString PlayModeNames[] = { static const char *PlayModeNames[] = {
"Regular", "Regular",
"Nonstop", "Nonstop",
"Oni", "Oni",
@@ -80,7 +80,7 @@ RankingCategory AverageMeterToRankingCategory( int iAverageMeter )
} }
static const CString RankingCategoryNames[] = { static const char *RankingCategoryNames[] = {
"a", "a",
"b", "b",
"c", "c",
@@ -90,7 +90,7 @@ XToString( RankingCategory, NUM_RANKING_CATEGORIES );
StringToX( RankingCategory ); StringToX( RankingCategory );
static const CString PlayerControllerNames[] = { static const char *PlayerControllerNames[] = {
"Human", "Human",
"Autoplay", "Autoplay",
"Cpu", "Cpu",
@@ -98,7 +98,7 @@ static const CString PlayerControllerNames[] = {
XToString( PlayerController, NUM_PLAYER_CONTROLLERS ); XToString( PlayerController, NUM_PLAYER_CONTROLLERS );
static const CString CoinModeNames[] = { static const char *CoinModeNames[] = {
"home", "home",
"pay", "pay",
"free", "free",
@@ -116,7 +116,7 @@ static void LuaCoinMode(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaCoinMode ); REGISTER_WITH_LUA_FUNCTION( LuaCoinMode );
static const CString PremiumNames[] = { static const char *PremiumNames[] = {
"none", "none",
"double", "double",
"joint", "joint",
@@ -134,7 +134,7 @@ static void LuaPremium(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaPremium ); REGISTER_WITH_LUA_FUNCTION( LuaPremium );
static const CString SortOrderNames[] = { static const char *SortOrderNames[] = {
"Preferred", "Preferred",
"Group", "Group",
"Title", "Title",
@@ -180,7 +180,7 @@ static void LuaSortOrder(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaSortOrder ); REGISTER_WITH_LUA_FUNCTION( LuaSortOrder );
static const CString TapNoteScoreNames[] = { static const char *TapNoteScoreNames[] = {
"None", "None",
"HitMine", "HitMine",
"AvoidMine", "AvoidMine",
@@ -227,7 +227,7 @@ static void LuaTapNoteScores( lua_State* L )
REGISTER_WITH_LUA_FUNCTION( LuaTapNoteScores ); REGISTER_WITH_LUA_FUNCTION( LuaTapNoteScores );
static const CString HoldNoteScoreNames[] = { static const char *HoldNoteScoreNames[] = {
"None", "None",
"LetGo", "LetGo",
"Held", "Held",
@@ -258,7 +258,7 @@ static void LuaHoldNoteScores( lua_State* L )
REGISTER_WITH_LUA_FUNCTION( LuaHoldNoteScores ); REGISTER_WITH_LUA_FUNCTION( LuaHoldNoteScores );
static const CString MemoryCardStateNames[] = { static const char *MemoryCardStateNames[] = {
"ready", "ready",
"checking", "checking",
"late", "late",
@@ -269,7 +269,7 @@ static const CString MemoryCardStateNames[] = {
XToString( MemoryCardState, NUM_MemoryCardState ); XToString( MemoryCardState, NUM_MemoryCardState );
static const CString PerDifficultyAwardNames[] = { static const char *PerDifficultyAwardNames[] = {
"FullComboW3", "FullComboW3",
"SingleDigitW3", "SingleDigitW3",
"OneW3", "OneW3",
@@ -296,7 +296,7 @@ REGISTER_WITH_LUA_FUNCTION( LuaPerDifficultyAward );
// strings can be used as XML entity names. // strings can be used as XML entity names.
// Numbers are intentially not at the back so that "1000" and "10000" don't // Numbers are intentially not at the back so that "1000" and "10000" don't
// conflict when searching for theme elements. // conflict when searching for theme elements.
static const CString PeakComboAwardNames[] = { static const char *PeakComboAwardNames[] = {
"Peak1000Combo", "Peak1000Combo",
"Peak2000Combo", "Peak2000Combo",
"Peak3000Combo", "Peak3000Combo",
@@ -368,7 +368,7 @@ bool DisplayBpms::IsSecret() const
return false; return false;
} }
static const CString StyleTypeNames[] = { static const char *StyleTypeNames[] = {
"OnePlayerOneSide", "OnePlayerOneSide",
"TwoPlayersTwoSides", "TwoPlayersTwoSides",
"OnePlayerTwoSides", "OnePlayerTwoSides",
@@ -377,7 +377,7 @@ XToString( StyleType, NUM_STYLE_TYPES );
StringToX( StyleType ); StringToX( StyleType );
static const CString MenuDirNames[] = { static const char *MenuDirNames[] = {
"Up", "Up",
"Down", "Down",
"Left", "Left",
@@ -387,7 +387,7 @@ static const CString MenuDirNames[] = {
XToString( MenuDir, NUM_MENU_DIRS ); XToString( MenuDir, NUM_MENU_DIRS );
static const CString GoalTypeNames[] = { static const char *GoalTypeNames[] = {
"Calories", "Calories",
"Time", "Time",
"None", "None",
@@ -406,7 +406,7 @@ static void LuaGoalType(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaGoalType ); REGISTER_WITH_LUA_FUNCTION( LuaGoalType );
static const CString StageNames[] = { static const char *StageNames[] = {
"1", "1",
"2", "2",
"3", "3",
+1 -1
View File
@@ -5,7 +5,7 @@
#include "Game.h" #include "Game.h"
static const CString GameControllerNames[] = { static const char *GameControllerNames[] = {
"Controller1", "Controller1",
"Controller2", "Controller2",
}; };
+2 -2
View File
@@ -23,7 +23,7 @@ Preference<float> g_fLightsFalloffSeconds( "LightsFalloffSeconds", 0.1f );
Preference<float> g_fLightsAheadSeconds( "LightsAheadSeconds", 0.05f ); Preference<float> g_fLightsAheadSeconds( "LightsAheadSeconds", 0.05f );
static const CString CabinetLightNames[] = { static const char *CabinetLightNames[] = {
"MarqueeUpLeft", "MarqueeUpLeft",
"MarqueeUpRight", "MarqueeUpRight",
"MarqueeLrLeft", "MarqueeLrLeft",
@@ -36,7 +36,7 @@ static const CString CabinetLightNames[] = {
XToString( CabinetLight, NUM_CABINET_LIGHTS ); XToString( CabinetLight, NUM_CABINET_LIGHTS );
StringToX( CabinetLight ); StringToX( CabinetLight );
static const CString LightsModeNames[] = { static const char *LightsModeNames[] = {
"Attract", "Attract",
"Joining", "Joining",
"Menu", "Menu",
+1 -1
View File
@@ -11,7 +11,7 @@
MessageManager* MESSAGEMAN = NULL; // global and accessable from anywhere in our program MessageManager* MESSAGEMAN = NULL; // global and accessable from anywhere in our program
static const CString MessageNames[] = { static const char *MessageNames[] = {
"CurrentGameChanged", "CurrentGameChanged",
"CurrentStyleChanged", "CurrentStyleChanged",
"PlayModeChanged", "PlayModeChanged",
+3 -3
View File
@@ -15,7 +15,7 @@
const CString& NoteNotePartToString( NotePart i ); const CString& NoteNotePartToString( NotePart i );
#define FOREACH_NotePart( i ) FOREACH_ENUM( NotePart, NUM_NotePart, i ) #define FOREACH_NotePart( i ) FOREACH_ENUM( NotePart, NUM_NotePart, i )
static const CString NotePartNames[] = { static const char *NotePartNames[] = {
"TapNote", "TapNote",
"TapAddition", "TapAddition",
"TapMine", "TapMine",
@@ -222,13 +222,13 @@ void NoteColorSprite::Load( const CString &sButton, const CString &sElement )
} }
static const CString HoldTypeNames[] = { static const char *HoldTypeNames[] = {
"hold", "hold",
"roll", "roll",
}; };
XToString( HoldType, NUM_HOLD_TYPES ); XToString( HoldType, NUM_HOLD_TYPES );
static const CString ActiveTypeNames[] = { static const char *ActiveTypeNames[] = {
"active", "active",
"inactive", "inactive",
}; };
+1 -1
View File
@@ -15,7 +15,7 @@ TapNote TAP_ORIGINAL_AUTO_KEYSOUND ( TapNote::autoKeysound,TapNote::SubType_inva
TapNote TAP_ADDITION_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 ); TapNote TAP_ADDITION_TAP ( TapNote::tap, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 );
TapNote TAP_ADDITION_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 ); TapNote TAP_ADDITION_MINE ( TapNote::mine, TapNote::SubType_invalid, TapNote::addition, "", 0, false, 0 );
static const CString NoteTypeNames[] = { static const char *NoteTypeNames[] = {
"4th", "4th",
"8th", "8th",
"12th", "12th",
+2 -2
View File
@@ -11,7 +11,7 @@
#include "Style.h" #include "Style.h"
#include "ActorUtil.h" #include "ActorUtil.h"
static const CString SelectTypeNames[] = { static const char *SelectTypeNames[] = {
"SelectOne", "SelectOne",
"SelectMultiple", "SelectMultiple",
"SelectNone", "SelectNone",
@@ -19,7 +19,7 @@ static const CString SelectTypeNames[] = {
XToString( SelectType, NUM_SELECT_TYPES ); XToString( SelectType, NUM_SELECT_TYPES );
StringToX( SelectType ); StringToX( SelectType );
static const CString LayoutTypeNames[] = { static const char *LayoutTypeNames[] = {
"ShowAllInRow", "ShowAllInRow",
"ShowOneInRow", "ShowOneInRow",
}; };
+2 -2
View File
@@ -4,7 +4,7 @@
#include "LuaManager.h" #include "LuaManager.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
static const CString PlayerNumberNames[] = { static const char *PlayerNumberNames[] = {
"P1", "P1",
"P2", "P2",
}; };
@@ -20,7 +20,7 @@ void LuaPlayerNumber(lua_State* L)
REGISTER_WITH_LUA_FUNCTION( LuaPlayerNumber ); REGISTER_WITH_LUA_FUNCTION( LuaPlayerNumber );
static const CString MultiPlayerNames[] = { static const char *MultiPlayerNames[] = {
"P1", "P1",
"P2", "P2",
"P3", "P3",
+2 -2
View File
@@ -18,7 +18,7 @@ const CString TYPE_TXT_FILE = "Data/Type.txt";
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
static const CString TimingWindowNames[] = { static const char *TimingWindowNames[] = {
"W1", "W1",
"W2", "W2",
"W3", "W3",
@@ -32,7 +32,7 @@ static const CString TimingWindowNames[] = {
XToString( TimingWindow, NUM_TimingWindow ); XToString( TimingWindow, NUM_TimingWindow );
static const CString ScoreEventNames[] = { static const char *ScoreEventNames[] = {
"W1", "W1",
"W2", "W2",
"W3", "W3",
+1 -1
View File
@@ -35,7 +35,7 @@ RageDisplay* DISPLAY = NULL;
Preference<bool> LOG_FPS( "LogFPS", true ); Preference<bool> LOG_FPS( "LogFPS", true );
Preference<float> g_fFrameLimitPercent( "FrameLimitPercent", 0.0f ); Preference<float> g_fFrameLimitPercent( "FrameLimitPercent", 0.0f );
static const CString PixelFormatNames[] = { static const char *PixelFormatNames[] = {
"RGBA8", "RGBA8",
"RGBA4", "RGBA4",
"RGB5A1", "RGB5A1",
+1 -1
View File
@@ -169,7 +169,7 @@ DeviceButton StringToDeviceButton( const CString& s )
} }
static const CString InputDeviceNames[] = { static const char *InputDeviceNames[] = {
"Key", "Key",
"Joy1", "Joy1",
"Joy2", "Joy2",
+1 -1
View File
@@ -77,7 +77,7 @@ AutoScreenMessage( SM_DoExit )
AutoScreenMessage( SM_SaveSuccessful ); AutoScreenMessage( SM_SaveSuccessful );
AutoScreenMessage( SM_SaveFailed ); AutoScreenMessage( SM_SaveFailed );
static const CString EditStateNames[] = { static const char *EditStateNames[] = {
"Edit", "Edit",
"Record", "Record",
"RecordPaused", "RecordPaused",
+2 -2
View File
@@ -39,14 +39,14 @@ const int NUM_SCORE_DIGITS = 9;
// metrics that are common to all ScreenEvaluation classes // metrics that are common to all ScreenEvaluation classes
#define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth") #define BANNER_WIDTH THEME->GetMetricF(m_sName,"BannerWidth")
#define BANNER_HEIGHT THEME->GetMetricF(m_sName,"BannerHeight") #define BANNER_HEIGHT THEME->GetMetricF(m_sName,"BannerHeight")
static const CString JudgeLineNames[] = static const char *JudgeLineNames[] =
{ {
"W1", "W2", "W3", "W4", "W5", "Miss", "Held", "MaxCombo", "TotalError" "W1", "W2", "W3", "W4", "W5", "Miss", "Held", "MaxCombo", "TotalError"
}; };
XToString( JudgeLine, NUM_JudgeLine ); XToString( JudgeLine, NUM_JudgeLine );
#define FOREACH_JudgeLine( rc ) FOREACH_ENUM( JudgeLine, NUM_JudgeLine, rc ) #define FOREACH_JudgeLine( rc ) FOREACH_ENUM( JudgeLine, NUM_JudgeLine, rc )
static const CString StatLineNames[NUM_StatLine] = static const char *StatLineNames[NUM_StatLine] =
{ {
"Jumps", "Holds", "Mines", "Hands", "Rolls", "Jumps", "Holds", "Mines", "Hands", "Rolls",
}; };
@@ -14,7 +14,7 @@
#include "PercentageDisplay.h" #include "PercentageDisplay.h"
static const CString MultiplayerJudgeLineNames[] = { static const char *MultiplayerJudgeLineNames[] = {
"W1", "W1",
"W2", "W2",
"W3", "W3",
+1 -1
View File
@@ -15,7 +15,7 @@ class Style;
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include "LocalizedString.h" #include "LocalizedString.h"
static const CString MultiPlayerStatusNames[] = { static const char *MultiPlayerStatusNames[] = {
"Joined", "Joined",
"NotJoined", "NotJoined",
"Unplugged", "Unplugged",
+1 -1
View File
@@ -28,7 +28,7 @@ enum CourseEntryAction
CourseEntryAction_Delete, CourseEntryAction_Delete,
NUM_CourseEntryAction NUM_CourseEntryAction
}; };
static const CString CourseEntryActionNames[] = { static const char *CourseEntryActionNames[] = {
"Edit", "Edit",
"Insert Entry", "Insert Entry",
"Delete", "Delete",
+1 -1
View File
@@ -94,7 +94,7 @@ enum CourseAction
CourseAction_Delete, CourseAction_Delete,
NUM_CourseAction NUM_CourseAction
}; };
static const CString CourseActionNames[] = { static const char *CourseActionNames[] = {
"Edit", "Edit",
"Rename", "Rename",
"Delete", "Delete",
@@ -24,7 +24,7 @@ enum StepsEditAction
StepsEditAction_Delete, StepsEditAction_Delete,
NUM_StepsEditAction NUM_StepsEditAction
}; };
static const CString StepsEditActionNames[] = { static const char *StepsEditActionNames[] = {
"Edit", "Edit",
"Rename", "Rename",
"Delete", "Delete",
@@ -32,7 +32,7 @@ enum ProfileAction
ProfileAction_Clear, ProfileAction_Clear,
NUM_ProfileAction NUM_ProfileAction
}; };
static const CString ProfileActionNames[] = { static const char *ProfileActionNames[] = {
"SetDefaultP1", "SetDefaultP1",
"SetDefaultP2", "SetDefaultP2",
"Edit", "Edit",
+1 -1
View File
@@ -16,7 +16,7 @@
#include "ScreenDimensions.h" #include "ScreenDimensions.h"
#include "PercentageDisplay.h" #include "PercentageDisplay.h"
static const CString PageTypeNames[] = { static const char *PageTypeNames[] = {
"Category", "Category",
"Course", "Course",
"AllSteps", "AllSteps",
+1 -1
View File
@@ -11,7 +11,7 @@
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
static const CString SetTimeSelectionNames[] = { static const char *SetTimeSelectionNames[] = {
"Year", "Year",
"Month", "Month",
"Day", "Day",
+1 -1
View File
@@ -25,7 +25,7 @@
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
static const RString ElementCategoryNames[] = { static const char *ElementCategoryNames[] = {
"BGAnimations", "BGAnimations",
"Fonts", "Fonts",
"Graphics", "Graphics",
+1 -1
View File
@@ -19,7 +19,7 @@ UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our p
#define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames") #define UNLOCK_NAMES THEME->GetMetric ("Unlocks","UnlockNames")
#define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str())) #define UNLOCK(sLineName) THEME->GetMetric ("Unlocks",ssprintf("Unlock%s",sLineName.c_str()))
static CString UnlockTypeNames[] = static const char *UnlockTypeNames[] =
{ {
"ArcadePoints", "ArcadePoints",
"DancePoints", "DancePoints",