diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 902eaf17ce..85d2281f4b 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -136,7 +136,7 @@ void SaveCatalogXml() { vector vStepsTypes; - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_CurGame, vStepsTypes ); + GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypes ); for( vector::const_iterator iter = vStepsTypes.begin(); iter != vStepsTypes.end(); iter++ ) { XNode* pNode2 = pNode->AppendChild( "StepsType", GAMEMAN->StepsTypeToString(*iter) ); @@ -156,7 +156,7 @@ void SaveCatalogXml() { vector vpStyle; - GAMEMAN->GetStylesForGame( GAMESTATE->m_CurGame, vpStyle ); + GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vpStyle ); FOREACH( const Style*, vpStyle, pStyle ) { if( !SHOW_STYLE(*pStyle) ) diff --git a/stepmania/src/ConditionalBGA.cpp b/stepmania/src/ConditionalBGA.cpp index 48f2ac7913..07ce158f42 100644 --- a/stepmania/src/ConditionalBGA.cpp +++ b/stepmania/src/ConditionalBGA.cpp @@ -250,7 +250,7 @@ void ConditionalBGA::Load(CString szScreenName) { LOG->Info( "Style:%s", asStyles[d].c_str() ); - m_bgainfo[bgano].styles.push_back(GAMEMAN->GameAndStringToStyle(GAMESTATE->m_CurGame,asStyles[d])); + m_bgainfo[bgano].styles.push_back(GAMEMAN->GameAndStringToStyle(GAMESTATE->m_pCurGame,asStyles[d])); } } diff --git a/stepmania/src/EditMenu.cpp b/stepmania/src/EditMenu.cpp index 0c435daca1..bef278f5d6 100644 --- a/stepmania/src/EditMenu.cpp +++ b/stepmania/src/EditMenu.cpp @@ -98,7 +98,7 @@ EditMenu::EditMenu() // fill in data structures SONGMAN->GetGroupNames( m_sGroups ); - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_CurGame, m_StepsTypes ); + GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_StepsTypes ); ChangeToRow( (Row)0 ); OnRowValueChanged( (Row)0 ); diff --git a/stepmania/src/Font.cpp b/stepmania/src/Font.cpp index c6bc738235..16c3e2a9e9 100644 --- a/stepmania/src/Font.cpp +++ b/stepmania/src/Font.cpp @@ -276,7 +276,7 @@ const glyph &Font::GetGlyph( wchar_t c ) const ASSERT(c >= 0 && c <= 0xFFFFFF); /* See if there's a game-specific version of this character. */ - int gc = FontManager::MakeGameGlyph(c, GAMESTATE->m_CurGame); + int gc = FontManager::MakeGameGlyph(c, GAMESTATE->m_pCurGame); map::const_iterator it = m_iCharToGlyph.find(gc); /* If there isn't, try the regular character. */ @@ -509,7 +509,7 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri */ CString codepoint = val.substr(4); /* "CODEPOINT" */ - Game game = GAME_INVALID; + const GameDef* pGame = NULL; if(codepoint.find_first_of(' ') != codepoint.npos) { @@ -518,9 +518,9 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri CString gamename = codepoint.substr(0, pos); codepoint = codepoint.substr(pos+1); - game = GameManager::StringToGameType(gamename); + pGame = GameManager::StringToGameType(gamename); - if(game == GAME_INVALID) + if(pGame == NULL) { LOG->Warn( "Font definition '%s' uses unknown game type '%s'", ini.GetPath().c_str(), gamename.c_str() ); @@ -546,9 +546,9 @@ void Font::LoadFontPageSettings(FontPageSettings &cfg, IniFile &ini, const CStri continue; } - if(game != GAME_INVALID) + if(pGame != NULL) { - longchar lc = FontManager::MakeGameGlyph(c, game); + longchar lc = FontManager::MakeGameGlyph(c, pGame); cfg.CharToGlyphNo[lc] = atoi(data); } else { cfg.CharToGlyphNo[c] = atoi(data); diff --git a/stepmania/src/FontManager.cpp b/stepmania/src/FontManager.cpp index 2c02c89661..b1c830e04f 100644 --- a/stepmania/src/FontManager.cpp +++ b/stepmania/src/FontManager.cpp @@ -5,6 +5,7 @@ #include "RageLog.h" #include "RageException.h" #include +#include "GameManager.h" FontManager* FONT = NULL; // global and accessable from anywhere in our program @@ -30,19 +31,21 @@ FontManager::~FontManager() /* A longchar is at least 32 bits. If c & 0xFF000000, it's a game-custom * character; game 0 is 0x0100nnnn, game 1 is 0x0200nnnn, and so on. */ -longchar FontManager::MakeGameGlyph(wchar_t c, Game g) +longchar FontManager::MakeGameGlyph(wchar_t c, const GameDef* g) { ASSERT(c >= 0 && c <= 0xFFFF); - ASSERT(g >= 0 && g <= 0xFF); - return longchar (((g+1) << 24) + c); + int index = GAMEMAN->GetIndexFromGame(g); + ASSERT(index >= 0 && index <= 0xFF); + return longchar (((index+1) << 24) + c); } -bool FontManager::ExtractGameGlyph(longchar ch, wchar_t &c, Game &g) +bool FontManager::ExtractGameGlyph(longchar ch, wchar_t &cOut, const GameDef *&gOut) { if((ch & 0xFF000000) == 0) return false; /* not a game glyph */ - g = Game((ch >> 24) - 1); - c = wchar_t(ch & 0xFFFF); + int index = (ch >> 24) - 1; + gOut = GAMEMAN->GetGameFromIndex( index ); + cOut = wchar_t(ch & 0xFFFF); return true; } diff --git a/stepmania/src/FontManager.h b/stepmania/src/FontManager.h index a0c3983b00..8a57399915 100644 --- a/stepmania/src/FontManager.h +++ b/stepmania/src/FontManager.h @@ -4,9 +4,9 @@ #define FONTMANAGER_H #include "RageUtil.h" -#include "Game.h" class Font; +class GameDef; class FontManager { @@ -24,8 +24,8 @@ public: * adjustment of fonts in ScreenTestFonts at the moment. */ void ReloadFonts(); - static longchar MakeGameGlyph(wchar_t c, Game g); - static bool ExtractGameGlyph(longchar ch, wchar_t &c, Game &g); + static longchar MakeGameGlyph(wchar_t c, const GameDef* g); + static bool ExtractGameGlyph(longchar ch, wchar_t &c, const GameDef*& g); }; extern FontManager* FONT; // global and accessable from anywhere in our program diff --git a/stepmania/src/Game.h b/stepmania/src/Game.h deleted file mode 100644 index 473a571084..0000000000 --- a/stepmania/src/Game.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef GAME_H -#define GAME_H - -enum Game -{ - GAME_DANCE, // Dance Dance Revolution - GAME_PUMP, // Pump It Up - GAME_EZ2, // Ez2dancer - GAME_PARA, // ParaPAraParadise - GAME_DS3DDX, // Dance Station 3DDX. - GAME_BM, // Beatmania - GAME_IIDX, // Beatmania IIDX - GAME_MANIAX, // DanceManiax - GAME_TECHNO, // TechnoMotion - GAME_PNM, // pop n music - GAME_LIGHTS, // cabinet lights (not really a game) - NUM_GAMES, // leave this at the end - GAME_INVALID, -}; - -#endif - -/* - * (c) 2001-2002 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. - */ diff --git a/stepmania/src/GameDef.cpp b/stepmania/src/GameDef.cpp index c00f5c4663..df91b9e991 100644 --- a/stepmania/src/GameDef.cpp +++ b/stepmania/src/GameDef.cpp @@ -9,7 +9,7 @@ #include "InputMapper.h" #include "PrefsManager.h" -int GameDef::GetNumGameplayButtons() +int GameDef::GetNumGameplayButtons() const { int iIndexOfStart = ButtonNameToIndex( "Start" ); ASSERT( iIndexOfStart != GAME_BUTTON_INVALID ); diff --git a/stepmania/src/GameDef.h b/stepmania/src/GameDef.h index ebd750a7f0..fa1e57de43 100644 --- a/stepmania/src/GameDef.h +++ b/stepmania/src/GameDef.h @@ -38,11 +38,12 @@ class Style; class GameDef { public: - char m_szName[60]; - char m_szDescription[60]; + const char *m_szName; + const char *m_szDescription; + int m_iNumControllers; int m_iButtonsPerController; - int GetNumGameplayButtons(); + int GetNumGameplayButtons() const; char m_szButtonNames[MAX_GAME_BUTTONS][60]; // The name used by the button graphics system. e.g. "left", "right", "middle C", "snare" char m_szSecondaryFunction[MAX_GAME_BUTTONS][60]; // displayed on the mapping screen GameButton m_DedicatedMenuButton[NUM_MENU_BUTTONS]; diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 9ff7c62a54..3c3a1b2a75 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -12,9 +12,28 @@ #include "RageInputDevice.h" #include "ThemeManager.h" #include "LightsManager.h" // for NUM_CABINET_LIGHTS +#include "GameDef.h" +#include "Style.h" GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program +enum Game +{ + GAME_DANCE, // Dance Dance Revolution + GAME_PUMP, // Pump It Up + GAME_EZ2, // Ez2dancer + GAME_PARA, // ParaPAraParadise + GAME_DS3DDX, // Dance Station 3DDX. + GAME_BM, // Beatmania + GAME_IIDX, // Beatmania IIDX + GAME_MANIAX, // DanceManiax + GAME_TECHNO, // TechnoMotion + GAME_PNM, // pop n music + GAME_LIGHTS, // cabinet lights (not really a game) + NUM_GAMES, // leave this at the end + GAME_INVALID, +}; + const int DANCE_COL_SPACING = 64; const int PUMP_COL_SPACING = 50; @@ -1188,7 +1207,7 @@ GameDef g_GameDefs[NUM_GAMES] = Style g_Styles[] = { { // STYLE_DANCE_SINGLE - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1219,7 +1238,7 @@ Style g_Styles[] = true, // m_bCanUseBeginnerHelper }, { // STYLE_DANCE_VERSUS - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1250,7 +1269,7 @@ Style g_Styles[] = true, // m_bCanUseBeginnerHelper }, { // STYLE_DANCE_DOUBLE - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1289,7 +1308,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_DANCE_COUPLE - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1320,7 +1339,7 @@ Style g_Styles[] = true, // m_bCanUseBeginnerHelper }, { // STYLE_DANCE_SOLO - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1355,7 +1374,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_DANCE_EDIT_COUPLE - GAME_DANCE, // m_Game + &g_GameDefs[GAME_DANCE], // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1424,7 +1443,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, */ { // STYLE_PUMP_SINGLE - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1457,7 +1476,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PUMP_VERSUS - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1490,7 +1509,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PUMP_HALFDOUBLE - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1525,7 +1544,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PUMP_DOUBLE - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1568,7 +1587,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PUMP_COUPLE - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1601,7 +1620,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PUMP_EDIT_COUPLE - GAME_PUMP, // m_Game + &g_GameDefs[GAME_PUMP], // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1639,7 +1658,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_EZ2_SINGLE - GAME_EZ2, // m_Game + &g_GameDefs[GAME_EZ2], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1672,7 +1691,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_EZ2_REAL - GAME_EZ2, // m_Game + &g_GameDefs[GAME_EZ2], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1709,7 +1728,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_EZ2_SINGLE_VERSUS - GAME_EZ2, // m_Game + &g_GameDefs[GAME_EZ2], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1742,7 +1761,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_EZ2_REAL_VERSUS - GAME_EZ2, // m_Game + &g_GameDefs[GAME_EZ2], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1779,7 +1798,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_EZ2_DOUBLE - GAME_EZ2, // m_Game + &g_GameDefs[GAME_EZ2], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -1822,7 +1841,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PARA_SINGLE - GAME_PARA, // m_Game + &g_GameDefs[GAME_PARA], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1855,7 +1874,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PARA_VERSUS - GAME_PARA, // m_Game + &g_GameDefs[GAME_PARA], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1888,7 +1907,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_DS3DDX_SINGLE - GAME_DS3DDX, // m_Game + &g_GameDefs[GAME_DS3DDX], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1927,7 +1946,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_BM_SINGLE - GAME_BM, // m_Game + &g_GameDefs[GAME_BM], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -1962,7 +1981,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_BM_DOUBLE - GAME_BM, // m_Game + &g_GameDefs[GAME_BM], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2009,7 +2028,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_SINGLE7 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2048,7 +2067,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_DOUBLE7 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2103,7 +2122,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_SINGLE5 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2142,7 +2161,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_DOUBLE5 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2197,7 +2216,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_EDIT_SINGLE5 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2236,7 +2255,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_IIDX_EDIT_DOUBLE5 - GAME_IIDX, // m_Game + &g_GameDefs[GAME_IIDX], // m_Game false, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2291,7 +2310,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_MANIAX_SINGLE - GAME_MANIAX, // m_Game + &g_GameDefs[GAME_MANIAX], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -2322,7 +2341,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_MANIAX_VERSUS - GAME_MANIAX, // m_Game + &g_GameDefs[GAME_MANIAX], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2353,7 +2372,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_MANIAX_DOUBLE - GAME_MANIAX, // m_Game + &g_GameDefs[GAME_MANIAX], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2392,7 +2411,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_SINGLE4 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2423,7 +2442,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_SINGLE5 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2456,7 +2475,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_SINGLE8 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2495,7 +2514,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_VERSUS4 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2526,7 +2545,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_VERSUS5 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2559,7 +2578,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_VERSUS8 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay false, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -2598,7 +2617,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_DOUBLE4 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2637,7 +2656,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_TECHNO_DOUBLE5 - GAME_TECHNO, // m_Game + &g_GameDefs[GAME_TECHNO], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2680,7 +2699,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PNM_FIVE - GAME_PNM, // m_Game + &g_GameDefs[GAME_PNM], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2713,7 +2732,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_PNM_NINE - GAME_PNM, // m_Game + &g_GameDefs[GAME_PNM], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit true, // m_bUsedForDemonstration @@ -2754,7 +2773,7 @@ Style g_Styles[] = false, // m_bCanUseBeginnerHelper }, { // STYLE_LIGHTS_CABINET - GAME_LIGHTS, // m_Game + &g_GameDefs[GAME_LIGHTS], // m_Game true, // m_bUsedForGameplay true, // m_bUsedForEdit false, // m_bUsedForDemonstration @@ -2805,18 +2824,12 @@ GameManager::~GameManager() { } -GameDef* GameManager::GetGameDefForGame( Game g ) -{ - ASSERT( g != GAME_INVALID ); // the game must be set before calling this - return &g_GameDefs[ g ]; -} - -void GameManager::GetStylesForGame( Game game, vector& aStylesAddTo, bool editor ) +void GameManager::GetStylesForGame( const GameDef *pGame, vector& aStylesAddTo, bool editor ) { for( unsigned s=0; sm_Game != game) + if( style->m_pGameDef != pGame) continue; if( !editor && !style->m_bUsedForGameplay ) continue; @@ -2841,7 +2854,7 @@ const Style* GameManager::GetEditorStyleForStepsType( StepsType st ) } -void GameManager::GetStepsTypesForGame( Game game, vector& aStepsTypeAddTo ) +void GameManager::GetStepsTypesForGame( const GameDef *pGame, vector& aStepsTypeAddTo ) { FOREACH_StepsType( st ) { @@ -2849,7 +2862,7 @@ void GameManager::GetStepsTypesForGame( Game game, vector& aStepsType for( unsigned s=0; !found && sm_Game != game || style->m_StepsType != st ) + if( style->m_pGameDef != pGame || style->m_StepsType != st ) continue; found = true; @@ -2859,12 +2872,12 @@ void GameManager::GetStepsTypesForGame( Game game, vector& aStepsType } } -const Style* GameManager::GetDemonstrationStyleForGame( Game game ) +const Style* GameManager::GetDemonstrationStyleForGame( const GameDef *pGame ) { for( unsigned s=0; sm_Game == game && style->m_bUsedForDemonstration ) + if( style->m_pGameDef == pGame && style->m_bUsedForDemonstration ) return style; } @@ -2872,12 +2885,12 @@ const Style* GameManager::GetDemonstrationStyleForGame( Game game ) return NULL; } -const Style* GameManager::GetHowToPlayStyleForGame( Game game ) +const Style* GameManager::GetHowToPlayStyleForGame( const GameDef *pGame ) { for( unsigned s=0; sm_Game == game && style->m_bUsedForHowToPlay ) + if( style->m_pGameDef == pGame && style->m_bUsedForHowToPlay ) return style; } @@ -2885,24 +2898,46 @@ const Style* GameManager::GetHowToPlayStyleForGame( Game game ) return NULL; } -void GameManager::GetEnabledGames( vector& aGamesOut ) +void GameManager::GetEnabledGames( vector& aGamesOut ) { for( int g=0; gGetNoteSkinNames( game, asNoteSkins ); + NOTESKIN->GetNoteSkinNames( pGame, asNoteSkins ); if( !asNoteSkins.empty() ) - aGamesOut.push_back( game ); + aGamesOut.push_back( pGame ); } } - -bool GameManager::IsGameEnabled( Game game ) +const GameDef* GameManager::GetDefaultGame() { - vector aGames; + return &g_GameDefs[0]; +} + +int GameManager::GetIndexFromGame( const GameDef* pGame ) +{ + for( int g=0; g= 0 ); + ASSERT( index < NUM_GAMES ); + return &g_GameDefs[index]; +} + +bool GameManager::IsGameEnabled( const GameDef *pGame ) +{ + vector aGames; GetEnabledGames( aGames ); - return find( aGames.begin(), aGames.end(), game ) != aGames.end(); + return find( aGames.begin(), aGames.end(), pGame ) != aGames.end(); } int GameManager::StepsTypeToNumTracks( StepsType st ) @@ -2957,22 +2992,22 @@ CString GameManager::StyleToThemedString( const Style* style ) return s; } -Game GameManager::StringToGameType( CString sGameType ) +const GameDef* GameManager::StringToGameType( CString sGameType ) { for( int i=0; im_Game != game ) + if( style->m_pGameDef != game ) continue; if( sStyle.CompareNoCase(style->m_szName) == 0 ) return style; diff --git a/stepmania/src/GameManager.h b/stepmania/src/GameManager.h index 4ad09215f9..51ccec32bd 100644 --- a/stepmania/src/GameManager.h +++ b/stepmania/src/GameManager.h @@ -3,11 +3,11 @@ #ifndef GAMEMANAGER_H #define GAMEMANAGER_H -#include "GameDef.h" -#include "Style.h" -#include "Game.h" class IniFile; +class Style; +class GameDef; +#include "GameConstantsAndTypes.h" class GameManager { @@ -15,24 +15,25 @@ public: GameManager(); ~GameManager(); - GameDef* GetGameDefForGame( Game g ); - - void GetStylesForGame( Game game, vector& aStylesAddTo, bool editor=false ); + void GetStylesForGame( const GameDef* pGame, vector& aStylesAddTo, bool editor=false ); void GetAllStyles( vector& aStylesAddTo, bool editor=false ); - void GetStepsTypesForGame( Game game, vector& aStepsTypeAddTo ); + void GetStepsTypesForGame( const GameDef* pGame, vector& aStepsTypeAddTo ); const Style* GetEditorStyleForStepsType( StepsType st ); - const Style* GetDemonstrationStyleForGame( Game game ); - const Style* GetHowToPlayStyleForGame( Game game ); + const Style* GetDemonstrationStyleForGame( const GameDef* pGame ); + const Style* GetHowToPlayStyleForGame( const GameDef* pGame ); - void GetEnabledGames( vector& aGamesOut ); - bool IsGameEnabled( Game game ); + void GetEnabledGames( vector& aGamesOut ); + const GameDef* GetDefaultGame(); + bool IsGameEnabled( const GameDef* pGame ); + int GetIndexFromGame( const GameDef* pGame ); + const GameDef* GetGameFromIndex( int index ); static int StepsTypeToNumTracks( StepsType st ); static StepsType StringToStepsType( CString sStepsType ); static CString StepsTypeToString( StepsType st ); static CString StepsTypeToThemedString( StepsType st ); - static Game StringToGameType( CString sGameType ); - const Style* GameAndStringToStyle( Game game, CString sStyle ); + static const GameDef* StringToGameType( CString sGameType ); + const Style* GameAndStringToStyle( const GameDef* pGame, CString sStyle ); static CString StyleToThemedString( const Style* s ); }; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 1ba10b2ee6..8ad3bcf4f4 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -41,7 +41,7 @@ GameState::GameState() { m_pPosition = NULL; - m_CurGame = GAME_DANCE; + m_pCurGame = NULL; m_iCoins = 0; m_timeGameStarted.SetZero(); m_bIsOnSystemMenu = false; @@ -122,7 +122,7 @@ void GameState::Reset() m_BeatToNoteSkinRev = 0; m_iNumStagesOfThisSong = 0; - NOTESKIN->RefreshNoteSkinData( this->m_CurGame ); + NOTESKIN->RefreshNoteSkinData( this->m_pCurGame ); m_iGameSeed = rand(); m_iRoundSeed = rand(); @@ -784,10 +784,10 @@ int GameState::GetNumSidesJoined() const return iNumSidesJoined; } -GameDef* GameState::GetCurrentGameDef() +const GameDef* GameState::GetCurrentGameDef() { - ASSERT( m_CurGame != GAME_INVALID ); // the game must be set before calling this - return GAMEMAN->GetGameDefForGame( m_CurGame ); + ASSERT( m_pCurGame != NULL ); // the game must be set before calling this + return m_pCurGame; } const Style* GameState::GetCurrentStyle() const diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 779a41b5b4..569d2b7838 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -6,7 +6,6 @@ #include "GameConstantsAndTypes.h" #include "PlayerOptions.h" #include "SongOptions.h" -#include "Game.h" #include "Grade.h" #include "Attack.h" #include "RageTimer.h" @@ -25,6 +24,7 @@ class NoteFieldPositioning; class Character; class TimingData; struct StageStats; +class GameDef; class Style; class GameState @@ -46,7 +46,7 @@ public: // // Main state info // - Game m_CurGame; + const GameDef* m_pCurGame; const Style* m_pCurStyle; bool m_bSideIsJoined[NUM_PLAYERS]; // left side, right side bool m_bPlayersFinalized; @@ -72,7 +72,7 @@ public: bool EnoughCreditsToJoin() const; // true if an unjoined player can join by pressint start int GetNumSidesJoined() const; - GameDef* GetCurrentGameDef(); + const GameDef* GetCurrentGameDef(); const Style* GetCurrentStyle() const; void GetPlayerInfo( PlayerNumber pn, bool& bIsEnabledOut, bool& bIsHumanOut ); diff --git a/stepmania/src/InputMapper.cpp b/stepmania/src/InputMapper.cpp index 3cf943940c..48a46c28e0 100644 --- a/stepmania/src/InputMapper.cpp +++ b/stepmania/src/InputMapper.cpp @@ -9,6 +9,8 @@ #include "PrefsManager.h" #include "RageInput.h" #include "arch/arch.h" +#include "GameDef.h" +#include "Style.h" InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program @@ -41,7 +43,7 @@ void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped() for( int j=0; jGetCurrentGameDef(); + const GameDef* pGameDef = GAMESTATE->GetCurrentGameDef(); for( int c=0; cm_iButtonsPerController; b++ ) @@ -59,7 +61,7 @@ void InputMapper::AddDefaultMappingsForCurrentGameIfUnmapped() struct AutoJoyMapping { - Game game; + const char *szGame; const char *szDriverRegex; // reported by InputHandler const char *szControllerName; // the product name of the controller struct Mapping { @@ -83,7 +85,7 @@ struct AutoJoyMapping const AutoJoyMapping g_AutoJoyMappings[] = { { - GAME_DANCE, + "dance", "GIC USB Joystick", "Boom USB convertor (black/gray)", { @@ -95,7 +97,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "4 axis 16 button joystick", "PC Magic Box", { @@ -107,7 +109,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "GamePad Pro USB ", // yes, there is a space at the end "GamePad Pro USB", { @@ -127,7 +129,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "SideWinder Game Pad USB version 1.0", "SideWinder Game Pad USB", { @@ -147,7 +149,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "4 axis 12 button joystick with hat switch", "Super Joy Box 5", { @@ -169,7 +171,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "MP-8866 Dual USB Joypad", "Super Dual Box", { @@ -191,7 +193,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "NTPAD", "NTPAD", { @@ -213,7 +215,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "Psx Gamepad", "PSXPAD", { @@ -235,7 +237,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "XBOX Gamepad Plugin V0.01", "X-Box gamepad", { @@ -255,7 +257,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_DANCE, + "dance", "0b43:0003", // The EMS USB2 doesn't provide a model string, so Linux // just gives us the VendorID and ModelID in hex. "EMS USB2", @@ -280,7 +282,7 @@ const AutoJoyMapping g_AutoJoyMappings[] = } }, { - GAME_PUMP, + "pump", "Pump USB", "Pump USB pad", { @@ -308,6 +310,8 @@ void InputMapper::AutoMapJoysticksForCurrentGame() int iNumJoysticksMapped = 0; + const GameDef* pGameDef = GAMESTATE->m_pCurGame; + for( unsigned i=0; iGetGameDefFromString(mapping.szGame) ) + continue; // games don't match + CString sDriverRegex = mapping.szDriverRegex; Regex regex( sDriverRegex ); - if( regex.Compare(sDescription) ) + if( !regex.Compare(sDescription) ) + continue; // driver names don't match + + // + // We have a mapping for this joystick + // + GameController gc = (GameController)iNumJoysticksMapped; + if( gc >= GAME_CONTROLLER_INVALID ) + break; // stop mapping. We already mapped one device for each game controller. + + LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)", + iNumJoysticksMapped+1, mapping.szDriverRegex, mapping.szControllerName ); + + for( int k=0; !mapping.maps[k].IsEndMarker(); k++ ) { - // - // We have a mapping for this joystick - // - GameController gc = (GameController)iNumJoysticksMapped; - if( gc >= GAME_CONTROLLER_INVALID ) - break; // stop mapping. We already mapped one device for each game controller. - - LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)", - iNumJoysticksMapped+1, mapping.szDriverRegex, mapping.szControllerName ); - - for( int k=0; !mapping.maps[k].IsEndMarker(); k++ ) + GameController map_gc = gc; + if( mapping.maps[k].SecondController ) { - GameController map_gc = gc; - if( mapping.maps[k].SecondController ) - { - map_gc = (GameController)(map_gc+1); + map_gc = (GameController)(map_gc+1); - /* If that pushed it over, then it's a second controller for - * a joystick that's already a second controller, so we'll - * just ignore it. (This can happen if eg. two primary - * Pump pads are connected.) */ - if( map_gc >= GAME_CONTROLLER_INVALID ) - continue; - } - - DeviceInput di( device, mapping.maps[k].deviceButton ); - GameInput gi( map_gc, mapping.maps[k].gb ); - SetInputMap( di, gi, mapping.maps[k].iSlotIndex ); + /* If that pushed it over, then it's a second controller for + * a joystick that's already a second controller, so we'll + * just ignore it. (This can happen if eg. two primary + * Pump pads are connected.) */ + if( map_gc >= GAME_CONTROLLER_INVALID ) + continue; } - iNumJoysticksMapped++; + DeviceInput di( device, mapping.maps[k].deviceButton ); + GameInput gi( map_gc, mapping.maps[k].gb ); + SetInputMap( di, gi, mapping.maps[k].iSlotIndex ); } + + iNumJoysticksMapped++; } } } diff --git a/stepmania/src/JukeboxMenu.cpp b/stepmania/src/JukeboxMenu.cpp index a552a34146..01f26ad0e5 100644 --- a/stepmania/src/JukeboxMenu.cpp +++ b/stepmania/src/JukeboxMenu.cpp @@ -5,6 +5,7 @@ #include "GameState.h" #include "ThemeManager.h" #include "GameManager.h" +#include "Style.h" // // Defines specific to JukeboxMenu @@ -53,7 +54,7 @@ JukeboxMenu::JukeboxMenu() // fill in data structures - GAMEMAN->GetStylesForGame( GAMESTATE->m_CurGame, m_Styles ); + GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, m_Styles ); SONGMAN->GetGroupNames( m_sGroups ); m_sGroups.insert( m_sGroups.begin(), "ALL MUSIC" ); m_sDifficulties.push_back( "all difficulties" ); diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index 70eb2f47a2..0a3d16e871 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -14,13 +14,14 @@ #include "arch/ArchHooks/ArchHooks.h" #include "MemoryCardManager.h" #include "song.h" +#include "GameDef.h" void ModeChoice::Init() { m_sName = ""; m_bInvalid = true; m_iIndex = -1; - m_game = GAME_INVALID; + m_pGameDef = NULL; m_pStyle = NULL; m_pm = PLAY_MODE_INVALID; m_dc = DIFFICULTY_INVALID; @@ -48,7 +49,7 @@ bool ModeChoice::DescribesCurrentModeForAllPlayers() const bool ModeChoice::DescribesCurrentMode( PlayerNumber pn ) const { - if( m_game != GAME_INVALID && m_game != GAMESTATE->m_CurGame ) + if( m_pGameDef != NULL && m_pGameDef != GAMESTATE->m_pCurGame ) return false; if( m_pm != PLAY_MODE_INVALID && GAMESTATE->m_PlayMode != m_pm ) return false; @@ -120,9 +121,9 @@ void ModeChoice::Load( int iIndex, CString sChoice ) if( sName == "game" ) { - Game game = GAMEMAN->StringToGameType( sValue ); - if( game != GAME_INVALID ) - m_game = game; + const GameDef* pGame = GAMEMAN->StringToGameType( sValue ); + if( pGame != NULL ) + m_pGameDef = pGame; else m_bInvalid |= true; } @@ -130,7 +131,7 @@ void ModeChoice::Load( int iIndex, CString sChoice ) if( sName == "style" ) { - const Style* style = GAMEMAN->GameAndStringToStyle( GAMESTATE->m_CurGame, sValue ); + const Style* style = GAMEMAN->GameAndStringToStyle( GAMESTATE->m_pCurGame, sValue ); if( style ) m_pStyle = style; else @@ -269,7 +270,7 @@ static bool AreStyleAndPlayModeCompatible( const Style *style, PlayMode pm ) // This is correct for dance (ie, no rave for solo and doubles), // and should be okay for pump .. not sure about other game types. // Techno Motion scales down versus arrows, though, so allow this. - if( style->m_iColsPerPlayer >= 6 && GAMESTATE->m_CurGame != GAME_TECHNO ) + if( style->m_iColsPerPlayer >= 6 && CString(GAMESTATE->m_pCurGame->m_szName) == "techno" ) return false; /* Don't allow battle modes if the style takes both sides. */ @@ -403,8 +404,8 @@ void ModeChoice::Apply( PlayerNumber pn ) const const PlayMode OldPlayMode = GAMESTATE->m_PlayMode; - if( m_game != GAME_INVALID ) - GAMESTATE->m_CurGame = m_game; + if( m_pGameDef != NULL ) + GAMESTATE->m_pCurGame = m_pGameDef; if( m_pm != PLAY_MODE_INVALID ) GAMESTATE->m_PlayMode = m_pm; @@ -484,7 +485,7 @@ void ModeChoice::Apply( PlayerNumber pn ) const bool ModeChoice::IsZero() const { - if( m_game != GAME_INVALID || + if( m_pGameDef != NULL || m_pm != PLAY_MODE_INVALID || m_pStyle != NULL || m_dc != DIFFICULTY_INVALID || diff --git a/stepmania/src/ModeChoice.h b/stepmania/src/ModeChoice.h index 6f1844acde..69d80072b9 100644 --- a/stepmania/src/ModeChoice.h +++ b/stepmania/src/ModeChoice.h @@ -3,7 +3,6 @@ #ifndef MODECHOICE_H #define MODECHOICE_H -#include "Game.h" #include "GameConstantsAndTypes.h" #include "PlayerNumber.h" #include @@ -14,6 +13,7 @@ class Course; class Trail; class Character; class Style; +class GameDef; struct ModeChoice // used in SelectMode { @@ -32,7 +32,7 @@ struct ModeChoice // used in SelectMode bool m_bInvalid; CString m_sInvalidReason; int m_iIndex; - Game m_game; + const GameDef* m_pGameDef; const Style* m_pStyle; PlayMode m_pm; Difficulty m_dc; diff --git a/stepmania/src/ModeSwitcher.cpp b/stepmania/src/ModeSwitcher.cpp index b34c4b02ad..4698e71a5d 100644 --- a/stepmania/src/ModeSwitcher.cpp +++ b/stepmania/src/ModeSwitcher.cpp @@ -9,6 +9,7 @@ #include "song.h" #include "ActorUtil.h" #include "GameManager.h" +#include "GameDef.h" #define PREVMODE_X THEME->GetMetricF("ModeSwitcher","PrevModeX") #define PREVMODE_Y THEME->GetMetricF("ModeSwitcher","PrevModeY") @@ -75,7 +76,7 @@ CString ModeSwitcher::GetStyleName() case DIFFICULTY_BEGINNER: sDiff[i] = "Beginner\n"; break; case DIFFICULTY_EASY: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Normal\n"; break; } @@ -86,7 +87,7 @@ CString ModeSwitcher::GetStyleName() } case DIFFICULTY_MEDIUM: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Hard\n"; break; } @@ -97,7 +98,7 @@ CString ModeSwitcher::GetStyleName() } case DIFFICULTY_HARD: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Crazy\n"; break; } @@ -138,7 +139,7 @@ CString ModeSwitcher::GetNextStyleName() { case DIFFICULTY_BEGINNER: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Normal\n"; break; } @@ -149,7 +150,7 @@ CString ModeSwitcher::GetNextStyleName() } case DIFFICULTY_EASY: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Hard\n"; break; } @@ -160,7 +161,7 @@ CString ModeSwitcher::GetNextStyleName() } case DIFFICULTY_MEDIUM: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Crazy\n"; break; } @@ -211,7 +212,7 @@ CString ModeSwitcher::GetPrevStyleName() { case DIFFICULTY_CHALLENGE: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Crazy\n"; break; } @@ -223,7 +224,7 @@ CString ModeSwitcher::GetPrevStyleName() case DIFFICULTY_EASY: sDiff[i] = "Beginner\n"; break; case DIFFICULTY_MEDIUM: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Normal\n"; break; } @@ -234,7 +235,7 @@ CString ModeSwitcher::GetPrevStyleName() } case DIFFICULTY_HARD: { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { sDiff[i] = "Hard\n"; break; } @@ -268,7 +269,7 @@ CString ModeSwitcher::GetPrevStyleName() void ModeSwitcher::ChangeMode(PlayerNumber pn, int dir) { - if(GAMESTATE->m_CurGame == GAME_PUMP) + if(GAMESTATE->m_pCurGame->m_szName == CString("pump")) { if(GAMESTATE->IsPlayerEnabled(pn)) { @@ -297,7 +298,7 @@ void ModeSwitcher::ChangeMode(PlayerNumber pn, int dir) // Make a list of all styles for the current Game. vector vPossibleStyles; - GAMEMAN->GetStylesForGame( GAMESTATE->m_CurGame, vPossibleStyles ); + GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vPossibleStyles ); ASSERT( !vPossibleStyles.empty() ); int index = 0; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index e2d77a7cf1..ef6e02f8b5 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -22,6 +22,7 @@ #include "SongUtil.h" #include "CourseUtil.h" #include "Foreach.h" +#include "Style.h" #define FADE_SECONDS THEME->GetMetricF("MusicWheel","FadeSeconds") diff --git a/stepmania/src/NoteFieldPositioning.cpp b/stepmania/src/NoteFieldPositioning.cpp index 3e742a9576..17b003c65a 100644 --- a/stepmania/src/NoteFieldPositioning.cpp +++ b/stepmania/src/NoteFieldPositioning.cpp @@ -9,7 +9,6 @@ #include "GameState.h" #include "GameManager.h" #include "IniFile.h" -#include "Game.h" #include "GameDef.h" /* Copies of the current mode. Update this by calling Load. */ @@ -94,10 +93,10 @@ void NoteFieldMode::Load(IniFile &ini, CString id, int pn) split(games[n], "-", bits); ASSERT(bits.size() == 2); - const Game game = GAMEMAN->StringToGameType( bits[0] ); - ASSERT(game != GAME_INVALID); + const GameDef* pGame = GAMEMAN->StringToGameType( bits[0] ); + ASSERT(pGame != NULL); - const Style *style = GAMEMAN->GameAndStringToStyle( game, bits[1] ); + const Style *style = GAMEMAN->GameAndStringToStyle( pGame, bits[1] ); ASSERT(style != NULL); Styles.insert(style); } diff --git a/stepmania/src/NoteSkinManager.cpp b/stepmania/src/NoteSkinManager.cpp index 4d56462fb3..1c2c6cd69e 100644 --- a/stepmania/src/NoteSkinManager.cpp +++ b/stepmania/src/NoteSkinManager.cpp @@ -24,20 +24,20 @@ static map g_PathCache; NoteSkinManager::NoteSkinManager() { - m_CurGame = GAME_INVALID; + m_pCurGame = NULL; } NoteSkinManager::~NoteSkinManager() { } -void NoteSkinManager::RefreshNoteSkinData( Game game ) +void NoteSkinManager::RefreshNoteSkinData( const GameDef* game ) { /* Reload even if we don't need to, so exiting out of the menus refreshes the note * skin list (so you don't have to restart to see new noteskins). */ - m_CurGame = GAMESTATE->m_CurGame; + m_pCurGame = GAMESTATE->m_pCurGame; - GameDef* pGameDef = GAMEMAN->GetGameDefForGame( game ); + const GameDef* pGameDef = game; // clear path cache g_PathCache.clear(); @@ -80,8 +80,8 @@ void NoteSkinManager::LoadNoteSkinData( CString sNoteSkinName, NoteSkinData& dat void NoteSkinManager::GetNoteSkinNames( CStringArray &AddTo ) { /* If the skin data for the current game isn't already load it, load it now. */ - if( m_CurGame != GAMESTATE->m_CurGame ) - RefreshNoteSkinData( GAMESTATE->m_CurGame ); + if( m_pCurGame != GAMESTATE->m_pCurGame ) + RefreshNoteSkinData( GAMESTATE->m_pCurGame ); /* Don't call GetNoteSkinNames below, since we don't want to call RefreshNoteSkinData; it's * slow. */ @@ -103,7 +103,7 @@ void NoteSkinManager::GetNoteSkinNames( CStringArray &AddTo ) } } -void NoteSkinManager::GetNoteSkinNames( Game game, CStringArray &AddTo ) +void NoteSkinManager::GetNoteSkinNames( const GameDef* game, CStringArray &AddTo ) { RefreshNoteSkinData( game ); @@ -114,7 +114,7 @@ void NoteSkinManager::GetNoteSkinNames( Game game, CStringArray &AddTo ) } /* Put the note skins back. */ - RefreshNoteSkinData( GAMESTATE->m_CurGame ); + RefreshNoteSkinData( GAMESTATE->m_pCurGame ); } diff --git a/stepmania/src/NoteSkinManager.h b/stepmania/src/NoteSkinManager.h index 3151844826..0c361b0620 100644 --- a/stepmania/src/NoteSkinManager.h +++ b/stepmania/src/NoteSkinManager.h @@ -2,11 +2,11 @@ #define NoteSkinMANAGER_H #include "RageTypes.h" -#include "Game.h" #include "PlayerNumber.h" #include "IniFile.h" #include +class GameDef; class NoteSkinManager { @@ -14,10 +14,10 @@ public: NoteSkinManager(); ~NoteSkinManager(); - void RefreshNoteSkinData( Game game ); - void GetNoteSkinNames( Game game, CStringArray &AddTo ); - void GetNoteSkinNames( CStringArray &AddTo ); // looks up current Game in GAMESTATE - bool DoesNoteSkinExist( CString sSkinName ); // looks up current Game in GAMESTATE + void RefreshNoteSkinData( const GameDef* game ); + void GetNoteSkinNames( const GameDef* game, CStringArray &AddTo ); + void GetNoteSkinNames( CStringArray &AddTo ); // looks up current const GameDef* in GAMESTATE + bool DoesNoteSkinExist( CString sSkinName ); // looks up current const GameDef* in GAMESTATE CString GetPathToFromPlayerAndCol( PlayerNumber pn, int col, CString sElement, bool bOptional=false ); CString GetPathToFromNoteSkinAndButton( CString NoteSkin, CString sButtonName, CString sElement, bool bOptional=false ); @@ -43,7 +43,7 @@ protected: }; void LoadNoteSkinData( CString sNoteSkinName, NoteSkinData& data_out ); map m_mapNameToData; - Game m_CurGame; + const GameDef* m_pCurGame; }; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index d511ffdca6..e0b0e79ad2 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -24,6 +24,7 @@ #include "ScreenManager.h" #include "StageStats.h" #include "ArrowEffects.h" +#include "GameDef.h" CachedThemeMetricF GRAY_ARROWS_Y_STANDARD ("Player","ReceptorArrowsYStandard"); CachedThemeMetricF GRAY_ARROWS_Y_REVERSE ("Player","ReceptorArrowsYReverse"); diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index da6e20f264..82952fe112 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -20,7 +20,7 @@ const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+10); // MUST be sam bool PrepareForDemonstration() // always return true. { - GAMESTATE->m_pCurStyle = GAMEMAN->GetDemonstrationStyleForGame(GAMESTATE->m_CurGame); + GAMESTATE->m_pCurStyle = GAMEMAN->GetDemonstrationStyleForGame(GAMESTATE->m_pCurGame); GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; diff --git a/stepmania/src/ScreenEnding.cpp b/stepmania/src/ScreenEnding.cpp index c2d68c2357..33e32467ee 100644 --- a/stepmania/src/ScreenEnding.cpp +++ b/stepmania/src/ScreenEnding.cpp @@ -102,7 +102,7 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2, false); GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; - GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAME_DANCE, "versus" ); + GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAMEMAN->GetDefaultGame(), "versus" ); GAMESTATE->m_bSideIsJoined[PLAYER_1] = true; GAMESTATE->m_bSideIsJoined[PLAYER_2] = true; GAMESTATE->m_MasterPlayerNumber = PLAYER_1; diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index ac08c3aac0..39f9e98a08 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -101,7 +101,7 @@ void ScreenEvaluation::Init() PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2, false); GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; - GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAME_DANCE, "versus" ); + GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAMEMAN->GetDefaultGame(), "versus" ); GAMESTATE->m_bSideIsJoined[PLAYER_1] = true; GAMESTATE->m_bSideIsJoined[PLAYER_2] = true; GAMESTATE->m_MasterPlayerNumber = PLAYER_1; diff --git a/stepmania/src/ScreenHowToPlay.cpp b/stepmania/src/ScreenHowToPlay.cpp index 8389fa5484..33e3608768 100644 --- a/stepmania/src/ScreenHowToPlay.cpp +++ b/stepmania/src/ScreenHowToPlay.cpp @@ -130,7 +130,7 @@ ScreenHowToPlay::ScreenHowToPlay( CString sName ) : ScreenAttract( sName ) m_pLifeMeterBar->FillForHowToPlay( NUM_PERFECTS, NUM_MISSES ); } - GAMESTATE->m_pCurStyle = GAMEMAN->GetHowToPlayStyleForGame(GAMESTATE->m_CurGame); + GAMESTATE->m_pCurStyle = GAMEMAN->GetHowToPlayStyleForGame(GAMESTATE->m_pCurGame); if( USEPLAYER ) { diff --git a/stepmania/src/ScreenLogo.cpp b/stepmania/src/ScreenLogo.cpp index bfac102718..fb08f15b2a 100644 --- a/stepmania/src/ScreenLogo.cpp +++ b/stepmania/src/ScreenLogo.cpp @@ -8,7 +8,7 @@ ScreenLogo::ScreenLogo( CString sName ) : ScreenAttract( sName ) { m_sprLogo.SetName( "Logo" ); - m_sprLogo.Load( THEME->GetPathToG(ssprintf("ScreenLogo %s",GAMESTATE->GetCurrentGameDef()->m_szName)) ); + m_sprLogo.Load( THEME->GetPathG("ScreenLogo",GAMESTATE->GetCurrentGameDef()->m_szName) ); ON_COMMAND( m_sprLogo ); this->AddChild( &m_sprLogo ); diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index 59eb2e0f70..790e16183d 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -11,6 +11,7 @@ #include "GameSoundManager.h" #include "ThemeManager.h" #include "RageDisplay.h" +#include "GameDef.h" #define EVEN_LINE_IN THEME->GetMetric("ScreenMapControllers","EvenLineIn") diff --git a/stepmania/src/ScreenNameEntry.cpp b/stepmania/src/ScreenNameEntry.cpp index fecadf1740..fcc3bc8b8d 100644 --- a/stepmania/src/ScreenNameEntry.cpp +++ b/stepmania/src/ScreenNameEntry.cpp @@ -16,6 +16,7 @@ #include "ProfileManager.h" #include "NoteFieldPositioning.h" #include "StageStats.h" +#include "GameDef.h" // diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index b0af13d4d5..abfcae4ee4 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -131,7 +131,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S GAMESTATE->m_bSideIsJoined[PLAYER_2] = true; GAMESTATE->m_MasterPlayerNumber = PLAYER_1; GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; - GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAME_DANCE, "versus" ); + GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAMEMAN->GetDefaultGame(), "versus" ); StageStats ss; for( int z = 0; z < 3; ++z ) { diff --git a/stepmania/src/ScreenOptionsMasterPrefs.cpp b/stepmania/src/ScreenOptionsMasterPrefs.cpp index 02cc2fce2d..39e5c8fbe4 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.cpp +++ b/stepmania/src/ScreenOptionsMasterPrefs.cpp @@ -12,6 +12,8 @@ #include "GameState.h" #include "InputMapper.h" #include "StepMania.h" +#include "GameDef.h" +#include "Foreach.h" static void GetDefaultModifiers( PlayerOptions &po, SongOptions &so ) { @@ -82,12 +84,11 @@ static void MoveData( int &sel, bool &opt, bool ToSel ) static void GameChoices( CStringArray &out ) { - vector aGames; + vector aGames; GAMEMAN->GetEnabledGames( aGames ); - for( unsigned i=0; iGetGameDefForGame(game)->m_szName; + CString sGameName = (*g)->m_szName; sGameName.MakeUpper(); out.push_back( sGameName ); } @@ -97,14 +98,14 @@ static void GameSel( int &sel, bool ToSel, const CStringArray &choices ) { if( ToSel ) { - const CString sCurGameName = GAMEMAN->GetGameDefForGame(GAMESTATE->m_CurGame)->m_szName; + const CString sCurGameName = GAMESTATE->m_pCurGame->m_szName; sel = 0; for(unsigned i = 0; i < choices.size(); ++i) if( !stricmp(choices[i], sCurGameName) ) sel = i; } else { - vector aGames; + vector aGames; GAMEMAN->GetEnabledGames( aGames ); ChangeCurrentGame( aGames[sel] ); } diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 1f87895c86..bc31adbb9a 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -265,7 +265,7 @@ ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName ) // calculate which StepsTypes to show vector aStepsTypesToShow; { - GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_CurGame, aStepsTypesToShow ); + GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, aStepsTypesToShow ); // subtract hidden StepsTypes { diff --git a/stepmania/src/ScreenStyleSplash.cpp b/stepmania/src/ScreenStyleSplash.cpp index 16ce0b781f..cf1db2c9dc 100644 --- a/stepmania/src/ScreenStyleSplash.cpp +++ b/stepmania/src/ScreenStyleSplash.cpp @@ -8,6 +8,8 @@ #include "GameState.h" #include "GameManager.h" #include "RageLog.h" +#include "GameDef.h" +#include "Style.h" #define NEXT_SCREEN THEME->GetMetric("ScreenStyleSplash","NextScreen") #define NONSTOP_SCREEN THEME->GetMetric("ScreenStyleSplash","NonstopScreen") diff --git a/stepmania/src/ScreenTestInput.cpp b/stepmania/src/ScreenTestInput.cpp index f42ca7ae1f..7100260698 100644 --- a/stepmania/src/ScreenTestInput.cpp +++ b/stepmania/src/ScreenTestInput.cpp @@ -11,7 +11,7 @@ #include "GameSoundManager.h" #include "ThemeManager.h" #include "RageDisplay.h" - +#include "GameDef.h" ScreenTestInput::ScreenTestInput( CString sClassName ) : ScreenWithMenuElements( sClassName ) diff --git a/stepmania/src/ScreenTestLights.cpp b/stepmania/src/ScreenTestLights.cpp index bfafb520fa..85e7c33bd5 100644 --- a/stepmania/src/ScreenTestLights.cpp +++ b/stepmania/src/ScreenTestLights.cpp @@ -12,6 +12,7 @@ #include "ThemeManager.h" #include "RageDisplay.h" #include "LightsManager.h" +#include "GameDef.h" ScreenTestLights::ScreenTestLights( CString sClassName ) : ScreenWithMenuElements( sClassName ) diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index e12c4d81c4..68b7dd3d62 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -21,6 +21,7 @@ #include "LightsManager.h" #include "CodeDetector.h" #include "CommonMetrics.h" +#include "GameDef.h" #define LOGO_ON_COMMAND THEME->GetMetric("ScreenTitleMenu","LogoOnCommand") @@ -73,7 +74,7 @@ ScreenTitleMenu::ScreenTitleMenu( CString sClassName ) : ScreenSelect( sClassNam LIGHTSMAN->SetLightsMode( LIGHTSMODE_JOINING ); // do this after Reset! - m_sprLogo.Load( THEME->GetPathToG(ssprintf("ScreenLogo %s",GAMESTATE->GetCurrentGameDef()->m_szName)) ); + m_sprLogo.Load( THEME->GetPathG("ScreenLogo",GAMESTATE->GetCurrentGameDef()->m_szName) ); m_sprLogo.Command( PREFSMAN->GetCoinMode()==COIN_HOME ? LOGO_HOME_ON_COMMAND : LOGO_ON_COMMAND ); this->AddChild( &m_sprLogo ); @@ -287,19 +288,24 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME) || CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME2) ) { - for( int i=0; im_CurGame = (Game)(GAMESTATE->m_CurGame+1); - wrap( (int&)GAMESTATE->m_CurGame, NUM_GAMES ); - - if( GAMEMAN->IsGameEnabled(GAMESTATE->m_CurGame) ) - break; // found the first enabled game. Stop searching. - } + vector vGames; + GAMEMAN->GetEnabledGames( vGames ); + ASSERT( !vGames.empty() ); + vector::iterator iter = find(vGames.begin(),vGames.end(),GAMESTATE->m_pCurGame); + ASSERT( iter != vGames.end() ); + + iter++; // move to the next game + + // wrap + if( iter == vGames.end() ) + iter = vGames.begin(); + + GAMESTATE->m_pCurGame = *iter; /* Reload the theme if it's changed, but don't back to the initial screen. */ ResetGame( false ); - SCREENMAN->SystemMessage( ssprintf("Game: %s",GAMESTATE->GetCurrentGameDef()->m_szName) ); + SCREENMAN->SystemMessage( CString("Game: ") + GAMESTATE->GetCurrentGameDef()->m_szName ); SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); } diff --git a/stepmania/src/ScreenWithMenuElements.cpp b/stepmania/src/ScreenWithMenuElements.cpp index 6e2042ee4f..7872b4a563 100644 --- a/stepmania/src/ScreenWithMenuElements.cpp +++ b/stepmania/src/ScreenWithMenuElements.cpp @@ -38,7 +38,7 @@ ScreenWithMenuElements::ScreenWithMenuElements( CString sClassName ) : Screen( s if( STYLE_ICON && GAMESTATE->m_pCurStyle ) { - CString sIconFileName = ssprintf("MenuElements icon %s", GAMESTATE->GetCurrentStyle()->m_szName ); + CString sIconFileName = CString("MenuElements icon ") + GAMESTATE->GetCurrentStyle()->m_szName; m_sprStyleIcon.SetName( "StyleIcon" ); m_sprStyleIcon.Load( THEME->GetPathToG(sIconFileName) ); m_sprStyleIcon.StopAnimating(); diff --git a/stepmania/src/SnapDisplay.cpp b/stepmania/src/SnapDisplay.cpp index eb1588ac91..96380f24bf 100644 --- a/stepmania/src/SnapDisplay.cpp +++ b/stepmania/src/SnapDisplay.cpp @@ -3,6 +3,7 @@ #include "GameManager.h" #include "GameState.h" #include "ThemeManager.h" +#include "Style.h" SnapDisplay::SnapDisplay() diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index c82313c53b..b0d15101eb 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -29,6 +29,7 @@ #include "Screen.h" #include "CodeDetector.h" #include "CommonMetrics.h" +#include "GameDef.h" // // StepMania global classes @@ -187,7 +188,7 @@ void ResetGame( bool ReturnToFirstScreen ) ReadGamePrefsFromDisk(); INPUTMAPPER->ReadMappingsFromDisk(); - NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_CurGame ); + NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_pCurGame ); /* GameState::Reset() will switch the NoteSkin @@ -689,14 +690,14 @@ static void RestoreAppPri() #define GAMEPREFS_INI_PATH "Data/GamePrefs.ini" #define STATIC_INI_PATH "Data/Static.ini" -void ChangeCurrentGame( Game g ) +void ChangeCurrentGame( const GameDef* g ) { - ASSERT( g >= 0 && g < NUM_GAMES ); + ASSERT( g ); SaveGamePrefsToDisk(); INPUTMAPPER->SaveMappingsToDisk(); // save mappings before switching the game - GAMESTATE->m_CurGame = g; + GAMESTATE->m_pCurGame = g; ReadGamePrefsFromDisk( false ); INPUTMAPPER->ReadMappingsFromDisk(); @@ -710,8 +711,12 @@ void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame ) ASSERT( GAMESTATE ); ASSERT( ANNOUNCER ); ASSERT( THEME ); + ASSERT( GAMESTATE ); + if( GAMESTATE->m_pCurGame == NULL ) + GAMESTATE->m_pCurGame = GAMEMAN->GetDefaultGame(); CString sGameName = GAMESTATE->GetCurrentGameDef()->m_szName; + IniFile ini; ini.ReadFile( GAMEPREFS_INI_PATH ); // it's OK if this fails ini.ReadFile( STATIC_INI_PATH ); // it's OK if this fails, too @@ -734,9 +739,9 @@ void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame ) CString sGame; if( ini.GetValue("Options", "Game", sGame) ) { - GAMESTATE->m_CurGame = GAMEMAN->StringToGameType( sGame ); - if( GAMESTATE->m_CurGame == GAME_INVALID ) - GAMESTATE->m_CurGame = (Game)0; + GAMESTATE->m_pCurGame = GAMEMAN->StringToGameType( sGame ); + if( GAMESTATE->m_pCurGame == NULL ) + GAMESTATE->m_pCurGame = GAMEMAN->GetDefaultGame(); } } } @@ -1302,7 +1307,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam THEME->ReloadMetrics(); TEXTUREMAN->ReloadAll(); SCREENMAN->ReloadCreditsText(); - NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_CurGame ); + NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_pCurGame ); CodeDetector::RefreshCacheItems(); diff --git a/stepmania/src/StepMania.h b/stepmania/src/StepMania.h index 813bfb5712..33821a3baa 100644 --- a/stepmania/src/StepMania.h +++ b/stepmania/src/StepMania.h @@ -1,7 +1,7 @@ #ifndef STEPMANIA_H #define STEPMANIA_H -#include "Game.h" +class GameDef; #ifdef _XBOX #include "Xbox Compilance\stdafx.h" @@ -15,7 +15,7 @@ void ExitGame(); void ResetGame( bool ReturnToFirstScreen=true ); void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame=true ); void SaveGamePrefsToDisk(); -void ChangeCurrentGame( Game g ); +void ChangeCurrentGame( const GameDef* g ); void FocusChanged( bool bHasFocus ); // If successful, return filename of screenshot in sDir, else return "" diff --git a/stepmania/src/Style.h b/stepmania/src/Style.h index 8f0955c6da..ee41945b47 100644 --- a/stepmania/src/Style.h +++ b/stepmania/src/Style.h @@ -5,7 +5,6 @@ #include "StyleInput.h" #include "GameInput.h" -#include "Game.h" #include "NoteTypes.h" #include "PlayerNumber.h" #include "GameConstantsAndTypes.h" @@ -14,18 +13,19 @@ const int MAX_COLS_PER_PLAYER = MAX_NOTE_TRACKS; class NoteData; +class GameDef; class Style { public: - Game m_Game; // Which Game is this Style used with? - bool m_bUsedForGameplay; // Can be used only for gameplay? - bool m_bUsedForEdit; // Can be used for editing? - bool m_bUsedForDemonstration; // Can be used for editing? - bool m_bUsedForHowToPlay; // Can be used for editing? + const GameDef* m_pGameDef; // Which Game is this Style used with? + bool m_bUsedForGameplay; // Can be used only for gameplay? + bool m_bUsedForEdit; // Can be used for editing? + bool m_bUsedForDemonstration; // Can be used for demonstration? + bool m_bUsedForHowToPlay; // Can be used for HowToPlay? /* The name of the style. (This is currently unused.) */ - char m_szName[60]; + const char *m_szName; /* Steps format used for each player. For example, "dance versus" reads * the Steps with the tag "dance-single". */ diff --git a/stepmania/src/StyleUtil.cpp b/stepmania/src/StyleUtil.cpp index b9dc1a22ec..93784b9459 100644 --- a/stepmania/src/StyleUtil.cpp +++ b/stepmania/src/StyleUtil.cpp @@ -2,13 +2,14 @@ #include "StyleUtil.h" #include "GameManager.h" #include "XmlFile.h" +#include "GameDef.h" void StyleID::FromStyle( const Style *p ) { if( p ) { - sGame = GAMEMAN->GetGameDefForGame(p->m_Game)->m_szName; + sGame = p->m_pGameDef->m_szName; sStyle = p->m_szName; } else @@ -20,11 +21,11 @@ void StyleID::FromStyle( const Style *p ) const Style *StyleID::ToStyle() const { - Game game = GameManager::StringToGameType( sGame ); - if( game == GAME_INVALID ) + const GameDef* pGame = GameManager::StringToGameType( sGame ); + if( pGame == NULL ) return NULL; - return GAMEMAN->GameAndStringToStyle( game, sStyle ); + return GAMEMAN->GameAndStringToStyle( pGame, sStyle ); } XNode* StyleID::CreateNode() const