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.

71 lines
2.3 KiB

  1. //===== Copyright � Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Defines scripting system.
  4. //
  5. //===========================================================================//
  6. #ifndef GAMEUISCRIPTINTERFACE_H
  7. #define GAMEUISCRIPTINTERFACE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "game_controls/igameuisystemmgr.h"
  12. #include "gameuiscriptsystem.h"
  13. #include "tier1/utlntree.h"
  14. #include "utlmap.h"
  15. class CGameUIDefinition;
  16. class CGameGraphic;
  17. //-----------------------------------------------------------------------------
  18. // These are functions that can be called from lua that do things in the gameui.
  19. //-----------------------------------------------------------------------------
  20. class CGameUIScriptInterface
  21. {
  22. public:
  23. explicit CGameUIScriptInterface( IScriptVM *pScriptVM, CGameUIDefinition *pDef );
  24. ~CGameUIScriptInterface();
  25. int GetGraphicID( CGameGraphic *pGraphic );
  26. public:
  27. void Shutdown();
  28. // Load a new menu to show now.
  29. HSCRIPT LoadMenu( const char *szMenuName, HSCRIPT hParams );
  30. // Create a graphic by classname
  31. HSCRIPT CreateGraphic( const char *szGraphicClassName, HSCRIPT hParams );
  32. // Execute a script command from menus
  33. HSCRIPT CallScript( int32 iScriptHandle, const char *szCommandName, HSCRIPT hParams );
  34. // Call a function inside a graphic
  35. HSCRIPT CallGraphic( int32 iGraphicHandle, const char *szCommandName, HSCRIPT hParams );
  36. // Interface with nuggets
  37. HSCRIPT Nugget( const char *szCommandName, HSCRIPT hParams );
  38. public:
  39. enum { KV_VARIANT_SCRATCH_BUF_SIZE = 128 };
  40. static bool ScriptVmKeyValueToVariant( IScriptVM *pVM, KeyValues *val, ScriptVariant_t &varValue, char chScratchBuffer[KV_VARIANT_SCRATCH_BUF_SIZE] );
  41. static bool ScriptVmStringFromVariant( ScriptVariant_t &varValue, char chScratchBuffer[KV_VARIANT_SCRATCH_BUF_SIZE] );
  42. static KeyValues * ScriptVmKeyValueFromVariant( IScriptVM *pVM, ScriptVariant_t &varValue );
  43. static KeyValues * ScriptTableToKeyValues( IScriptVM *pVM, char const *szName, HSCRIPT hTable );
  44. static HSCRIPT ScriptTableFromKeyValues( IScriptVM *pVM, KeyValues *kv );
  45. private:
  46. HSCRIPT m_Scope;
  47. IScriptVM *m_pScriptVM;
  48. CGameUIDefinition *m_pMenu;
  49. CUtlMap< CUtlString, IGameUIScreenController * > m_Nuggets;
  50. CUtlMap< CUtlString, CGameGraphic * > m_GraphicScriptInstances; // graphics created from scripting.
  51. };
  52. #endif // GAMEUISCRIPTINTERFACE_H