Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. //=========== (C) Copyright Valve, L.L.C. All rights reserved. ===========
  2. #include "cbase.h"
  3. #include "ui_nugget.h"
  4. class CUiNuggetSemaphore : public CUiNuggetBase
  5. {
  6. DECLARE_NUGGET_FN_MAP( CUiNuggetSemaphore, CUiNuggetBase );
  7. NUGGET_FN( Configure )
  8. {
  9. m_pUiNuggetData->MergeFrom( args, KeyValues::MERGE_KV_UPDATE );
  10. return NULL;
  11. }
  12. NUGGET_FN( Signal )
  13. {
  14. char const *szSemaphoreSignal = m_pUiNuggetData->GetString( "signal" );
  15. if ( !*szSemaphoreSignal )
  16. return NULL;
  17. KeyValues *pEvent = m_pUiNuggetData->MakeCopy();
  18. pEvent->SetName( szSemaphoreSignal );
  19. KeyValues::AutoDelete autodelete_pEvent( pEvent );
  20. char const *szEventData = m_pUiNuggetData->GetString( "eventdata" );
  21. if ( *szEventData )
  22. {
  23. if ( KeyValues *pSub = pEvent->FindKey( szEventData ) )
  24. {
  25. pEvent->RemoveSubKey( pSub );
  26. pSub->deleteThis();
  27. }
  28. KeyValues *pParams = args->MakeCopy();
  29. pParams->SetName( szEventData );
  30. pEvent->AddSubKey( pParams );
  31. }
  32. BroadcastEventToScreens( pEvent );
  33. return NULL;
  34. }
  35. public:
  36. CUiNuggetSemaphore()
  37. {
  38. m_pUiNuggetData->SetString( "signal", "OnSemaphore" );
  39. m_pUiNuggetData->SetString( "eventdata", "eventdata" );
  40. }
  41. };
  42. UI_NUGGET_FACTORY_INSTANCES( CUiNuggetSemaphore, "semaphore" );