diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index def9fc5d0b..651c0fe552 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -45,6 +45,38 @@ GameState* GAMESTATE = NULL; // global and accessable from anywhere in our progr #define NAME_BLACKLIST_FILE "/Data/NamesBlacklist.txt" +class GameStateMessageHandler: public MessageSubscriber +{ + void HandleMessage( const Message &msg ) + { + if( msg.GetName() == "RefreshCreditText" ) + { + RString sJoined; + FOREACH_HumanPlayer( pn ) + { + if( sJoined != "" ) + sJoined += ", "; + sJoined += ssprintf( "P%i", pn+1 ); + } + + if( sJoined == "" ) + sJoined = "none"; + + LOG->MapLog( "JOINED", "Players joined: %s", sJoined.c_str() ); + } + } +}; + +struct GameStateImpl +{ + GameStateMessageHandler m_Subscriber; + GameStateImpl::GameStateImpl() + { + m_Subscriber.SubscribeToMessage( "RefreshCreditText" ); + } +}; +static GameStateImpl *g_pImpl = NULL; + ThemeMetric USE_NAME_BLACKLIST("GameState","UseNameBlacklist"); ThemeMetric DEFAULT_SORT ("GameState","DefaultSort"); @@ -87,6 +119,8 @@ GameState::GameState() : m_iEditCourseEntryIndex( Message_EditCourseEntryIndexChanged ), m_sEditLocalProfileID( Message_EditLocalProfileIDChanged ) { + g_pImpl = new GameStateImpl; + SetCurrentStyle( NULL ); m_pCurGame.Set( NULL ); @@ -140,6 +174,7 @@ GameState::~GameState() SAFE_DELETE( m_pMultiPlayerState[p] ); SAFE_DELETE( m_Environment ); + SAFE_DELETE( g_pImpl ); } void GameState::ApplyGameCommand( const RString &sCommand, PlayerNumber pn ) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 40a24068b8..413a934587 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -71,7 +71,6 @@ #include "ScreenDimensions.h" #include "Foreach.h" #include "ActorUtil.h" -#include "GameState.h" // XXX: bad dep ScreenManager* SCREENMAN = NULL; // global and accessable from anywhere in our program @@ -784,20 +783,6 @@ void ScreenManager::HideSystemMessage() void ScreenManager::RefreshCreditsMessages() { MESSAGEMAN->Broadcast( "RefreshCreditText" ); - - /* This is called when GAMESTATE->m_bSideIsJoined changes. */ - RString joined; - FOREACH_HumanPlayer( pn ) - { - if( joined != "" ) - joined += ", "; - joined += ssprintf( "P%i", pn+1 ); - } - - if( joined == "" ) - joined = "none"; - - LOG->MapLog( "JOINED", "Players joined: %s", joined.c_str() ); } void ScreenManager::ZeroNextUpdate()