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.

119 lines
3.2 KiB

  1. //=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. ===========
  2. //
  3. // The copyright to the contents herein is the property of Valve, L.L.C.
  4. // The contents may be used and/or copied only with the written permission of
  5. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  6. // the agreement/contract under which the contents have been supplied.
  7. //
  8. //=============================================================================
  9. #ifdef _WIN32
  10. #include "appframework/vguimatsysapp.h"
  11. #include "vgui/IVGui.h"
  12. #include "vgui/ISurface.h"
  13. #include "vgui_controls/controls.h"
  14. #include "vgui/IScheme.h"
  15. #include "vgui/ILocalize.h"
  16. #include "tier0/dbg.h"
  17. #include "VGuiMatSurface/IMatSystemSurface.h"
  18. #include "tier3/tier3.h"
  19. #include "inputsystem/iinputstacksystem.h"
  20. //-----------------------------------------------------------------------------
  21. // Constructor
  22. //-----------------------------------------------------------------------------
  23. CVguiMatSysApp::CVguiMatSysApp()
  24. {
  25. m_hAppInputContext = INPUT_CONTEXT_HANDLE_INVALID;
  26. }
  27. //-----------------------------------------------------------------------------
  28. // Create all singleton systems
  29. //-----------------------------------------------------------------------------
  30. bool CVguiMatSysApp::Create()
  31. {
  32. if ( !BaseClass::Create() )
  33. return false;
  34. AppSystemInfo_t appSystems[] =
  35. {
  36. { "inputsystem.dll", INPUTSTACKSYSTEM_INTERFACE_VERSION },
  37. // NOTE: This has to occur before vgui2.dll so it replaces vgui2's surface implementation
  38. { "vguimatsurface.dll", VGUI_SURFACE_INTERFACE_VERSION },
  39. { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
  40. // Required to terminate the list
  41. { "", "" }
  42. };
  43. return AddSystems( appSystems );
  44. }
  45. void CVguiMatSysApp::Destroy()
  46. {
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Init, shutdown
  50. //-----------------------------------------------------------------------------
  51. bool CVguiMatSysApp::PreInit( )
  52. {
  53. if ( !BaseClass::PreInit() )
  54. return false;
  55. CreateInterfaceFn factory = GetFactory();
  56. ConnectTier3Libraries( &factory, 1 );
  57. if ( !vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 ) )
  58. return false;
  59. if ( !g_pMatSystemSurface )
  60. {
  61. Warning( "CVguiMatSysApp::PreInit: Unable to connect to necessary interface!\n" );
  62. return false;
  63. }
  64. g_pMatSystemSurface->EnableWindowsMessages( true );
  65. return true;
  66. }
  67. bool CVguiMatSysApp::PostInit()
  68. {
  69. if ( !BaseClass::PostInit() )
  70. return false;
  71. m_hAppInputContext = g_pInputStackSystem->PushInputContext();
  72. InputContextHandle_t hVGuiInputContext = g_pInputStackSystem->PushInputContext();
  73. g_pMatSystemSurface->SetInputContext( hVGuiInputContext );
  74. g_pMatSystemSurface->EnableWindowsMessages( true );
  75. return true;
  76. }
  77. void CVguiMatSysApp::PreShutdown()
  78. {
  79. g_pMatSystemSurface->EnableWindowsMessages( false );
  80. g_pMatSystemSurface->SetInputContext( NULL );
  81. if ( m_hAppInputContext != INPUT_CONTEXT_HANDLE_INVALID )
  82. {
  83. g_pInputStackSystem->PopInputContext(); // Vgui
  84. g_pInputStackSystem->PopInputContext(); // App
  85. }
  86. BaseClass::PreShutdown();
  87. }
  88. void CVguiMatSysApp::PostShutdown()
  89. {
  90. DisconnectTier3Libraries();
  91. BaseClass::PostShutdown();
  92. }
  93. InputContextHandle_t CVguiMatSysApp::GetAppInputContext()
  94. {
  95. return m_hAppInputContext;
  96. }
  97. #endif // _WIN32