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.

160 lines
4.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GAMEUISCHEME_H
  8. #define GAMEUISCHEME_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "igameuisystemmgr.h"
  13. #include "vgui_surfacelib/ifontsurface.h"
  14. #include "tier1/utlstring.h"
  15. //#include "color.h"
  16. #include "tier1/utlsymbol.h"
  17. class CGameUISystemSurface;
  18. class KeyValues;
  19. //-----------------------------------------------------------------------------
  20. // Game UI version of a vgui scheme
  21. //-----------------------------------------------------------------------------
  22. class CGameUIScheme : public IGameUIScheme
  23. {
  24. public:
  25. CGameUIScheme();
  26. ~CGameUIScheme();
  27. FontHandle_t GetFont( const char *fontName, bool proportional = false );
  28. FontHandle_t GetFontNextSize( bool bUp, const char *fontName, bool proportional = false );
  29. //Color GetColor( const char *colorName, Color defaultColor ){ return Color( 255, 255, 255, 255 ); }
  30. // These fxns are very similar to CScheme.
  31. void Shutdown( bool full );
  32. void LoadFromFile( const char *pFilename, const char *inTag, KeyValues *inKeys );
  33. // Gets at the scheme's name
  34. const char *GetName() { return m_pTag; }
  35. const char *GetFileName() { return m_pFileName; }
  36. char const *GetFontName( const FontHandle_t &font );
  37. void ReloadFontGlyphs( int inScreenTall = -1 );
  38. void SpewFonts();
  39. bool GetFontRange( const char *fontname, int &nMin, int &nMax );
  40. void SetFontRange( const char *fontname, int nMin, int nMax );
  41. void SetActive( bool bActive );
  42. bool IsActive() const;
  43. private:
  44. const char *GetMungedFontName( const char *fontName, const char *scheme, bool proportional );
  45. void LoadFonts();
  46. int GetMinimumFontHeightForCurrentLanguage( const char *pLanguage = NULL );
  47. FontHandle_t FindFontInAliasList( const char *fontName );
  48. bool m_bActive;
  49. CUtlString m_pFileName;
  50. CUtlString m_pTag;
  51. KeyValues *m_pData;
  52. #pragma pack(1)
  53. struct fontalias_t
  54. {
  55. CUtlSymbol _fontName;
  56. CUtlSymbol _trueFontName;
  57. unsigned short _font : 15;
  58. unsigned short m_bProportional : 1;
  59. };
  60. #pragma pack()
  61. struct fontrange_t
  62. {
  63. CUtlSymbol _fontName;
  64. int _min;
  65. int _max;
  66. };
  67. CUtlVector< fontrange_t > m_FontRanges;
  68. CUtlVector< fontalias_t > m_FontAliases;
  69. };
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. //-----------------------------------------------------------------------------
  73. class CGameUISchemeManager : public IGameUISchemeMgr
  74. {
  75. public:
  76. CGameUISchemeManager();
  77. ~CGameUISchemeManager();
  78. // loads a scheme from a file
  79. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  80. // tag is friendly string representing the name of the loaded scheme
  81. IGameUIScheme * LoadSchemeFromFile( const char *fileName, const char *tag );
  82. // reloads the schemes from the file
  83. void ReloadSchemes();
  84. // reloads scheme fonts
  85. void ReloadFonts( int inScreenTall = -1 );
  86. // returns a handle to the default (first loaded) scheme
  87. IGameUIScheme * GetDefaultScheme();
  88. // returns a handle to the scheme identified by "tag"
  89. IGameUIScheme * GetScheme( const char *tag );
  90. void Shutdown( bool full );
  91. // gets the proportional coordinates for doing screen-size independant panel layouts
  92. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  93. int GetProportionalScaledValue( int normalizedValue, int screenTall = -1 );
  94. int GetProportionalNormalizedValue( int scaledValue ){ return 1; }
  95. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  96. IGameUIScheme * LoadSchemeFromFileEx( const char *pFilename, const char *tag );
  97. // gets the proportional coordinates for doing screen-size independant panel layouts
  98. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  99. int GetProportionalScaledValueEx( IGameUIScheme * scheme, int normalizedValue, int screenTall = -1 ){ return 0; }
  100. int GetProportionalNormalizedValueEx( IGameUIScheme * scheme, int scaledValue ){ return 0; }
  101. // gets the proportional coordinates for doing screen-size independant panel layouts
  102. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  103. int GetProportionalScaledValueEx( CGameUIScheme *pScheme, int normalizedValue, int screenTall = -1 );
  104. int GetProportionalNormalizedValueEx( CGameUIScheme *pScheme, int scaledValue );
  105. void SpewFonts();
  106. void SetLanguage( const char *pLanguage );
  107. const char *GetLanguage();
  108. private:
  109. int GetProportionalScaledValue_( int screenTall, int normalizedValue );
  110. // Search for already-loaded schemes
  111. IGameUIScheme * FindLoadedScheme(const char *pFilename);
  112. CUtlVector< CGameUIScheme * > m_Schemes;
  113. };
  114. extern CGameUISchemeManager *g_pGameUISchemeManager;
  115. #endif // GAMEUISCHEME_H