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.

96 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Client DLL VGUI2 Viewport
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "cbase.h"
  14. #pragma warning( disable : 4800 ) // disable forcing int to bool performance warning
  15. // VGUI panel includes
  16. #include <vgui_controls/Panel.h>
  17. #include <vgui/ISurface.h>
  18. #include <KeyValues.h>
  19. #include <vgui/Cursor.h>
  20. #include <vgui/IScheme.h>
  21. #include <vgui/IVGui.h>
  22. #include <vgui/ILocalize.h>
  23. #include <vgui/VGUI.h>
  24. // client dll/engine defines
  25. #include "hud.h"
  26. #include <voice_status.h>
  27. // viewport definitions
  28. #include <baseviewport.h>
  29. #include "TFCViewport.h"
  30. #include "tfcteammenu.h"
  31. #include "vguicenterprint.h"
  32. #include "text_message.h"
  33. #include "tfcclassmenu.h"
  34. //
  35. // This is the main function of the viewport. Right here is where we create our class menu,
  36. // team menu, and anything else that we want to turn on and off in the UI.
  37. //
  38. void TFCViewport::CreateDefaultPanels( void )
  39. {
  40. AddNewPanel( new CTFCTeamMenu( this ), "CTFCTeamMenu" );
  41. AddNewPanel( new CTFCClassMenu( this ), "CTFCClassMenu" );
  42. BaseClass::CreateDefaultPanels();
  43. }
  44. void TFCViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
  45. {
  46. BaseClass::ApplySchemeSettings( pScheme );
  47. gHUD.InitColors( pScheme );
  48. SetPaintBackgroundEnabled( false );
  49. }
  50. IViewPortPanel* TFCViewport::CreatePanelByName(const char *szPanelName)
  51. {
  52. IViewPortPanel* newpanel = NULL;
  53. // Up here, strcmp against each type of panel we know how to create.
  54. // else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
  55. // {
  56. // newpanel = new CCSMapOverview( this );
  57. // }
  58. // create a generic base panel, don't add twice
  59. newpanel = BaseClass::CreatePanelByName( szPanelName );
  60. return newpanel;
  61. }
  62. int TFCViewport::GetDeathMessageStartHeight( void )
  63. {
  64. int x = YRES(2);
  65. IViewPortPanel *spectator = gViewPortInterface->FindPanelByName( PANEL_SPECGUI );
  66. //TODO: Link to actual height of spectator bar
  67. if ( spectator && spectator->IsVisible() )
  68. {
  69. x += YRES(52);
  70. }
  71. return x;
  72. }