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.

140 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ISCHEME_H
  8. #define ISCHEME_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui/vgui.h"
  13. #include "tier1/interface.h"
  14. #include "tier1/utlsymbol.h"
  15. class Color;
  16. class KeyValues;
  17. class ISchemeSurface;
  18. namespace vgui
  19. {
  20. typedef unsigned long HScheme;
  21. typedef unsigned long HTexture;
  22. class IBorder;
  23. class IImage;
  24. //-----------------------------------------------------------------------------
  25. // Purpose: Holds all panel rendering data
  26. // This functionality is all wrapped in the Panel::GetScheme*() functions
  27. //-----------------------------------------------------------------------------
  28. class IScheme : public IBaseInterface
  29. {
  30. public:
  31. #pragma pack(1)
  32. struct fontalias_t
  33. {
  34. CUtlSymbol _fontName;
  35. CUtlSymbol _trueFontName;
  36. unsigned short _font : 15;
  37. unsigned short m_bProportional : 1;
  38. };
  39. #pragma pack()
  40. struct fontrange_t
  41. {
  42. CUtlSymbol _fontName;
  43. int _min;
  44. int _max;
  45. };
  46. // gets a string from the default settings section
  47. virtual const char *GetResourceString(const char *stringName) = 0;
  48. // returns a pointer to an existing border
  49. virtual IBorder *GetBorder(const char *borderName) = 0;
  50. // returns a pointer to an existing font
  51. virtual HFont GetFont(const char *fontName, bool proportional = false) = 0;
  52. // inverse font lookup
  53. virtual char const *GetFontName( const HFont& font ) = 0;
  54. // colors
  55. virtual Color GetColor(const char *colorName, Color defaultColor) = 0;
  56. // Gets at the scheme's short name
  57. virtual const char *GetName() const = 0;
  58. // Gets at the scheme's resource file name
  59. virtual const char *GetFileName() const = 0;
  60. };
  61. class ISchemeManager: public IBaseInterface
  62. {
  63. public:
  64. // loads a scheme from a file
  65. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  66. virtual HScheme LoadSchemeFromFile(const char *fileName, const char *tag) = 0;
  67. // reloads the scheme from the file - should only be used during development
  68. virtual void ReloadSchemes() = 0;
  69. // reloads scheme fonts
  70. virtual void ReloadFonts( int inScreenTall = -1 ) = 0;
  71. // returns a handle to the default (first loaded) scheme
  72. virtual HScheme GetDefaultScheme() = 0;
  73. // returns a handle to the scheme identified by "tag"
  74. virtual HScheme GetScheme(const char *tag) = 0;
  75. // returns a pointer to an image
  76. virtual IImage *GetImage(const char *imageName, bool hardwareFiltered) = 0;
  77. virtual HTexture GetImageID(const char *imageName, bool hardwareFiltered) = 0;
  78. // This can only be called at certain times, like during paint()
  79. // It will assert-fail if you call it at the wrong time...
  80. // FIXME: This interface should go away!!! It's an icky back-door
  81. // If you're using this interface, try instead to cache off the information
  82. // in ApplySchemeSettings
  83. virtual IScheme *GetIScheme( HScheme scheme ) = 0;
  84. // unload all schemes
  85. virtual void Shutdown( bool full = true ) = 0;
  86. // gets the proportional coordinates for doing screen-size independant panel layouts
  87. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  88. virtual int GetProportionalScaledValue( int normalizedValue) = 0;
  89. virtual int GetProportionalNormalizedValue(int scaledValue) = 0;
  90. // loads a scheme from a file
  91. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  92. virtual HScheme LoadSchemeFromFileEx( VPANEL sizingPanel, const char *fileName, const char *tag) = 0;
  93. // gets the proportional coordinates for doing screen-size independant panel layouts
  94. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  95. virtual int GetProportionalScaledValueEx( HScheme scheme, int normalizedValue ) = 0;
  96. virtual int GetProportionalNormalizedValueEx( HScheme scheme, int scaledValue ) = 0;
  97. // Returns true if image evicted, false otherwise
  98. virtual bool DeleteImage( const char *pImageName ) = 0;
  99. virtual ISchemeSurface *GetSurface() = 0;
  100. virtual void SetLanguage( const char *pLanguage ) = 0;
  101. virtual const char *GetLanguage() = 0;
  102. };
  103. } // namespace vgui
  104. #endif // ISCHEME_H