subscrube to required messages in C++ code rather than requiring theme to receive messages and funnel them through

This commit is contained in:
Chris Danford
2008-02-15 09:34:12 +00:00
parent e9518eca6a
commit 58cae9f108
2 changed files with 21 additions and 0 deletions
+19
View File
@@ -18,6 +18,12 @@ REGISTER_ACTOR_CLASS( DifficultyList )
DifficultyList::DifficultyList() DifficultyList::DifficultyList()
{ {
m_bShown = true; m_bShown = true;
FOREACH_ENUM( PlayerNumber, pn )
{
SubscribeToMessage( (MessageID)(Message_CurrentStepsP1Changed+pn) );
SubscribeToMessage( (MessageID)(Message_CurrentTrailP1Changed+pn) );
}
} }
DifficultyList::~DifficultyList() DifficultyList::~DifficultyList()
@@ -356,6 +362,19 @@ void DifficultyList::Hide()
COMMAND( m_Cursors[pn], "Hide" ); COMMAND( m_Cursors[pn], "Hide" );
} }
void DifficultyList::HandleMessage( const Message &msg )
{
FOREACH_ENUM( PlayerNumber, pn )
{
if( msg.GetName() == MessageIDToString((MessageID)(Message_CurrentStepsP1Changed+pn)) ||
msg.GetName() == MessageIDToString((MessageID)(Message_CurrentTrailP1Changed+pn)) )
SetFromGameState();
}
ActorFrame::HandleMessage(msg);
}
// lua start // lua start
#include "LuaBinding.h" #include "LuaBinding.h"
+2
View File
@@ -17,6 +17,8 @@ public:
virtual DifficultyList *Copy() const; virtual DifficultyList *Copy() const;
virtual void LoadFromNode( const XNode* pNode ); virtual void LoadFromNode( const XNode* pNode );
void HandleMessage( const Message &msg );
void SetFromGameState(); void SetFromGameState();
void TweenOnScreen(); void TweenOnScreen();
void TweenOffScreen(); void TweenOffScreen();