add experimental MessageManager
This commit is contained in:
@@ -275,7 +275,8 @@ FontManager.cpp FontManager.h GameSoundManager.cpp GameSoundManager.h GameManage
|
|||||||
GameState.cpp GameState.h InputFilter.cpp InputFilter.h \
|
GameState.cpp GameState.h InputFilter.cpp InputFilter.h \
|
||||||
InputMapper.cpp InputMapper.h InputQueue.cpp InputQueue.h \
|
InputMapper.cpp InputMapper.h InputQueue.cpp InputQueue.h \
|
||||||
LuaManager.cpp LuaManager.h LightsManager.cpp LightsManager.h \
|
LuaManager.cpp LuaManager.h LightsManager.cpp LightsManager.h \
|
||||||
MemoryCardManager.cpp MemoryCardManager.h NetworkSyncManager.cpp NetworkSyncManager.h \
|
MemoryCardManager.cpp MemoryCardManager.h \
|
||||||
|
MessageManager.cpp MessageManager.h NetworkSyncManager.cpp NetworkSyncManager.h \
|
||||||
NetworkSyncServer.cpp NetworkSyncServer.h NoteSkinManager.cpp NoteSkinManager.h \
|
NetworkSyncServer.cpp NetworkSyncServer.h NoteSkinManager.cpp NoteSkinManager.h \
|
||||||
PrefsManager.cpp PrefsManager.h ProfileManager.cpp ProfileManager.h ScreenManager.cpp \
|
PrefsManager.cpp PrefsManager.h ProfileManager.cpp ProfileManager.h ScreenManager.cpp \
|
||||||
ScreenManager.h SongManager.cpp SongManager.h ThemeManager.cpp ThemeManager.h \
|
ScreenManager.h SongManager.cpp SongManager.h ThemeManager.cpp ThemeManager.h \
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
#include "global.h"
|
||||||
|
#include "MessageManager.h"
|
||||||
|
#include "Foreach.h"
|
||||||
|
#include "Actor.h"
|
||||||
|
#include "RageUtil.h"
|
||||||
|
|
||||||
|
MessageManager* MESSAGEMAN = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
|
|
||||||
|
MessageManager::MessageManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageManager::~MessageManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageManager::Subscribe( Actor* pActor, const CString& sMessage )
|
||||||
|
{
|
||||||
|
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
|
||||||
|
#if _DEBUG
|
||||||
|
SubscribersSet::iterator iter = subs.find(pActor);
|
||||||
|
ASSERT_M( iter == subs.end(), "already subscribed" );
|
||||||
|
#endif
|
||||||
|
subs.insert( pActor );
|
||||||
|
}
|
||||||
|
void MessageManager::Unsubscribe( Actor* pActor, const CString& sMessage )
|
||||||
|
{
|
||||||
|
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
|
||||||
|
SubscribersSet::iterator iter = subs.find(pActor);
|
||||||
|
ASSERT( iter != subs.end() );
|
||||||
|
subs.erase( iter );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageManager::Broadcast( const CString& sMessage )
|
||||||
|
{
|
||||||
|
SubscribersSet& subs = m_MessageToSubscribers[sMessage];
|
||||||
|
FOREACHS_CONST( Actor*, subs, p )
|
||||||
|
{
|
||||||
|
(*p)->PlayCommand( sMessage );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2003-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.
|
||||||
|
*/
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/* MessageManager - Control lights. */
|
||||||
|
|
||||||
|
#ifndef MessageManager_H
|
||||||
|
#define MessageManager_H
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
#include <map>
|
||||||
|
class Actor;
|
||||||
|
struct XNode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MessageManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MessageManager();
|
||||||
|
~MessageManager();
|
||||||
|
|
||||||
|
void Subscribe( Actor* pActor, const CString& sMessage );
|
||||||
|
void Unsubscribe( Actor* pActor, const CString& sMessage );
|
||||||
|
void Broadcast( const CString& sMessage );
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef set<Actor*> SubscribersSet;
|
||||||
|
map<CString,SubscribersSet> m_MessageToSubscribers;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern MessageManager* MESSAGEMAN; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (c) 2003-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.
|
||||||
|
*/
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
#include "ModelManager.h"
|
#include "ModelManager.h"
|
||||||
#include "CryptManager.h"
|
#include "CryptManager.h"
|
||||||
#include "NetworkSyncManager.h"
|
#include "NetworkSyncManager.h"
|
||||||
|
#include "MessageManager.h"
|
||||||
|
|
||||||
#if defined(XBOX)
|
#if defined(XBOX)
|
||||||
#include "Archutils/Xbox/VirtualMemory.h"
|
#include "Archutils/Xbox/VirtualMemory.h"
|
||||||
@@ -177,6 +178,7 @@ void ShutdownGame()
|
|||||||
SOUNDMAN->Shutdown();
|
SOUNDMAN->Shutdown();
|
||||||
|
|
||||||
SAFE_DELETE( SCREENMAN );
|
SAFE_DELETE( SCREENMAN );
|
||||||
|
SAFE_DELETE( MESSAGEMAN );
|
||||||
SAFE_DELETE( NSMAN );
|
SAFE_DELETE( NSMAN );
|
||||||
/* Delete INPUTMAN before the other INPUTFILTER handlers, or an input
|
/* Delete INPUTMAN before the other INPUTFILTER handlers, or an input
|
||||||
* driver may try to send a message to INPUTFILTER after we delete it. */
|
* driver may try to send a message to INPUTFILTER after we delete it. */
|
||||||
@@ -1085,8 +1087,9 @@ int main(int argc, char* argv[])
|
|||||||
PROFILEMAN->Init(); // must load after SONGMAN
|
PROFILEMAN->Init(); // must load after SONGMAN
|
||||||
UNLOCKMAN = new UnlockSystem;
|
UNLOCKMAN = new UnlockSystem;
|
||||||
NSMAN = new NetworkSyncManager( loading_window );
|
NSMAN = new NetworkSyncManager( loading_window );
|
||||||
|
MESSAGEMAN = new MessageManager;
|
||||||
|
|
||||||
delete loading_window; // destroy this before init'ing Display
|
SAFE_DELETE( loading_window ); // destroy this before init'ing Display
|
||||||
|
|
||||||
DISPLAY = CreateDisplay();
|
DISPLAY = CreateDisplay();
|
||||||
|
|
||||||
|
|||||||
@@ -3012,6 +3012,14 @@ SOURCE=.\MemoryCardManager.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\MessageManager.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\MessageManager.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\NetworkSyncManager.cpp
|
SOURCE=.\NetworkSyncManager.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -2346,6 +2346,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
|||||||
<File
|
<File
|
||||||
RelativePath="MemoryCardManager.h">
|
RelativePath="MemoryCardManager.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="MessageManager.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="MessageManager.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="NetworkSyncManager.cpp">
|
RelativePath="NetworkSyncManager.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
Reference in New Issue
Block a user