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.

103 lines
3.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Handles loading/unloading of different vgui modules into a shared context
  4. //
  5. //=============================================================================//
  6. #ifndef VGUISYSTEMMODULELOADER_H
  7. #define VGUISYSTEMMODULELOADER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/PHandle.h"
  12. #include "utlvector.h"
  13. #include "IVGuiModuleLoader.h"
  14. class IVGuiModule;
  15. class KeyValues;
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Handles loading/unloading of different vgui modules into a shared context
  18. //-----------------------------------------------------------------------------
  19. class CVGuiSystemModuleLoader : public IVGuiModuleLoader
  20. {
  21. public:
  22. CVGuiSystemModuleLoader();
  23. ~CVGuiSystemModuleLoader();
  24. // loads all the modules in the platform
  25. bool LoadPlatformModules(CreateInterfaceFn *factorylist, int factorycount, bool useSteamModules);
  26. // returns true if the module loader has loaded the modules
  27. bool IsPlatformReady();
  28. // needs to be called every frame - updates all the modules states
  29. void RunFrame();
  30. // returns number of modules loaded
  31. int GetModuleCount();
  32. // returns the string menu name (unlocalized) of a module
  33. // moduleIndex is of the range [0, GetModuleCount())
  34. const char *GetModuleLabel(int moduleIndex);
  35. bool IsModuleHidden(int moduleIndex);
  36. bool IsModuleVisible(int moduleIndex);
  37. // returns a modules interface factory
  38. CreateInterfaceFn GetModuleFactory(int moduleIndex);
  39. // brings the specified module to the foreground
  40. bool ActivateModule(int moduleIndex);
  41. bool ActivateModule(const char *moduleName);
  42. // Deactivates all the modules (puts them into in inactive but recoverable state)
  43. void DeactivatePlatformModules();
  44. // Reenables all the deactivated platform modules
  45. void ReactivatePlatformModules();
  46. // shuts down all the platform modules
  47. void ShutdownPlatformModules();
  48. // unload all active platform modules/dlls from memory
  49. void UnloadPlatformModules();
  50. // posts a message to all active modules
  51. void PostMessageToAllModules(KeyValues *message);
  52. // posts a message to a single module
  53. bool PostMessageToModule( int moduleIndex, KeyValues *message );
  54. bool PostMessageToModule( const char *moduleName, KeyValues *message );
  55. // sets the the platform should update and restart when it quits
  56. void SetPlatformToRestart();
  57. // returns true if the platform should restart after exit
  58. bool ShouldPlatformRestart();
  59. private:
  60. // sets up all the modules for use
  61. bool InitializeAllModules(CreateInterfaceFn *factorylist, int factorycount);
  62. int GetModuleIndexFromName( const char* name );
  63. bool m_bModulesInitialized;
  64. bool m_bPlatformShouldRestartAfterExit;
  65. struct module_t
  66. {
  67. CSysModule *module;
  68. IVGuiModule *moduleInterface;
  69. KeyValues *data;
  70. };
  71. CUtlVector<module_t> m_Modules;
  72. KeyValues *m_pPlatformModuleData;
  73. };
  74. extern CVGuiSystemModuleLoader g_VModuleLoader;
  75. #endif // VGUISYSTEMMODULELOADER_H