initial
This commit is contained in:
63
game/client/gameui/nuggets/ui_matchevents.cpp
Normal file
63
game/client/gameui/nuggets/ui_matchevents.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
//=========== (C) Copyright Valve, L.L.C. All rights reserved. ===========
|
||||
|
||||
#include "cbase.h"
|
||||
#include "ui_nugget.h"
|
||||
#include "matchmaking/imatchframework.h"
|
||||
|
||||
class CUiNuggetMatchEvents : public CUiNuggetBase, IMatchEventsSink
|
||||
{
|
||||
DECLARE_NUGGET_FN_MAP( CUiNuggetMatchEvents, CUiNuggetBase );
|
||||
|
||||
virtual void OnEvent( KeyValues *pEvent )
|
||||
{
|
||||
BroadcastEventToScreens( pEvent );
|
||||
return;
|
||||
|
||||
#if SCRIPTS_NEED_EVENT_NAMES_WITH_BASIC_CHARSET
|
||||
// In case scripts cannot define function names
|
||||
// associations with any characters, then we'll
|
||||
// need to do some work to make event names conform
|
||||
// with those scripts.
|
||||
//
|
||||
// In lua we can easily do any member function names:
|
||||
/*
|
||||
mainmenu["Command::Game::SampleCmd"] = function(self, params)
|
||||
print( "Command::Game::SampleCmd" )
|
||||
print( self.extraPieceOfData )
|
||||
end
|
||||
*/
|
||||
//
|
||||
// Fix the event name for scripting:
|
||||
char chEventName[256] = {0}, *pch = chEventName;
|
||||
Q_snprintf( chEventName, ARRAYSIZE( chEventName ), "%s", pEvent->GetName() );
|
||||
for ( ; *pch; ++ pch )
|
||||
{
|
||||
bool bValidChar = (
|
||||
( *pch >= 'a' && *pch <= 'z' ) ||
|
||||
( *pch >= 'A' && *pch <= 'Z' ) ||
|
||||
( *pch >= '0' && *pch <= '9' )
|
||||
);
|
||||
if ( !bValidChar )
|
||||
*pch = '_';
|
||||
}
|
||||
|
||||
// New event for scripting
|
||||
KeyValues *pEventCopy = pEvent->MakeCopy();
|
||||
KeyValues::AutoDelete autodelete_pEventCopy( pEventCopy );
|
||||
pEventCopy->SetName( chEventName );
|
||||
BroadcastEventToScreens( pEventCopy );
|
||||
#endif
|
||||
}
|
||||
|
||||
public:
|
||||
CUiNuggetMatchEvents()
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->Subscribe( this );
|
||||
}
|
||||
~CUiNuggetMatchEvents()
|
||||
{
|
||||
g_pMatchFramework->GetEventsSubscription()->Unsubscribe( this );
|
||||
}
|
||||
};
|
||||
|
||||
UI_NUGGET_FACTORY_SINGLETON( CUiNuggetMatchEvents, "matchevents" );
|
Reference in New Issue
Block a user