Team Fortress 2 Source Code as on 22/4/2020
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.

178 lines
4.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "interface.h"
  9. #include <windows.h>
  10. //#include "..\..\tracker\common\winlite.h"
  11. #include "vgui_controls/Controls.h"
  12. #include "vgui/vgui.h"
  13. #include "VGUI\IPanel.h"
  14. #include "VGUI\IScheme.h"
  15. #include "VGUI\ISurface.h"
  16. #include "VGUI\ILocalize.h"
  17. #include "VGUI\IVGui.h"
  18. #include "vgui_controls/Panel.h"
  19. #include "filesystem.h"
  20. #include "tier0/icommandline.h"
  21. #include "appframework/tier3app.h"
  22. #include "inputsystem/iinputsystem.h"
  23. #include "CControlCatalog.h"
  24. #include <stdio.h>
  25. //-----------------------------------------------------------------------------
  26. // Purpose: Warning/Msg call back through this API
  27. // Input : type -
  28. // *pMsg -
  29. // Output : SpewRetval_t
  30. //-----------------------------------------------------------------------------
  31. SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg )
  32. {
  33. switch ( type )
  34. {
  35. default:
  36. case SPEW_MESSAGE:
  37. case SPEW_ASSERT:
  38. case SPEW_LOG:
  39. OutputDebugString( pMsg );
  40. break;
  41. case SPEW_WARNING:
  42. OutputDebugString( pMsg );
  43. break;
  44. case SPEW_ERROR:
  45. OutputDebugString( pMsg );
  46. exit( -1 );
  47. break;
  48. }
  49. return SPEW_CONTINUE;
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: Entry point
  53. // loads interfaces and initializes dialog
  54. //-----------------------------------------------------------------------------
  55. static CreateInterfaceFn s_pFactoryList[2];
  56. void *VGuiFactory( const char *pName, int *pReturnCode )
  57. {
  58. for ( int i = 0; i < ARRAYSIZE( s_pFactoryList ); ++i )
  59. {
  60. void *pInterface = s_pFactoryList[i]( pName, pReturnCode );
  61. if ( pInterface )
  62. return pInterface;
  63. }
  64. return NULL;
  65. }
  66. //-----------------------------------------------------------------------------
  67. // The application object
  68. //-----------------------------------------------------------------------------
  69. class CPanelZooApp : public CVguiSteamApp
  70. {
  71. typedef CVguiSteamApp BaseClass;
  72. public:
  73. // Methods of IApplication
  74. virtual bool Create();
  75. virtual bool PreInit();
  76. virtual int Main();
  77. virtual void Destroy() {}
  78. };
  79. DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CPanelZooApp );
  80. //-----------------------------------------------------------------------------
  81. // The application object
  82. //-----------------------------------------------------------------------------
  83. bool CPanelZooApp::Create()
  84. {
  85. SpewOutputFunc( SpewFunc );
  86. SpewActivate( "panelzoo", 2 );
  87. AppSystemInfo_t appSystems[] =
  88. {
  89. { "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
  90. { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
  91. { "", "" } // Required to terminate the list
  92. };
  93. return AddSystems( appSystems );
  94. }
  95. //-----------------------------------------------------------------------------
  96. // Setup
  97. //-----------------------------------------------------------------------------
  98. bool CPanelZooApp::PreInit()
  99. {
  100. if ( !BaseClass::PreInit() )
  101. return false;
  102. if ( !BaseClass::SetupSearchPaths( NULL, false, true ) )
  103. {
  104. ::MessageBox( NULL, "Error", "Unable to initialize file system\n", MB_OK );
  105. return false;
  106. }
  107. g_pFullFileSystem->AddSearchPath( "platform", "PLATFORM" );
  108. return true;
  109. }
  110. //-----------------------------------------------------------------------------
  111. // Purpose: Entry point
  112. //-----------------------------------------------------------------------------
  113. int CPanelZooApp::Main()
  114. {
  115. // In order to load resource files the file must be in your vgui filesystem path.
  116. // g_pFullFileSystem->AddSearchPath("../", "resources");
  117. // Init the surface
  118. // vgui::surface()->Init();
  119. // Make a embedded panel
  120. vgui::Panel *panel = new vgui::Panel(NULL, "TopPanel");
  121. vgui::surface()->SetEmbeddedPanel( panel->GetVPanel() );
  122. // Load the scheme
  123. if (!vgui::scheme()->LoadSchemeFromFile( "//platform/Resource/SourceScheme.res", "PANELZOO" ))
  124. return 1;
  125. // localization
  126. g_pVGuiLocalize->AddFile( "Resource/platform_english.txt" );
  127. g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt" );
  128. g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt" );
  129. // Start vgui
  130. vgui::ivgui()->Start();
  131. // Add our main window
  132. CControlCatalog *panelZoo = new CControlCatalog();
  133. panelZoo->Activate();
  134. // Run app frame loop
  135. while (vgui::ivgui()->IsRunning())
  136. {
  137. vgui::ivgui()->RunFrame();
  138. }
  139. delete panelZoo;
  140. // delete panel;
  141. return 1;
  142. }