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.

127 lines
4.0 KiB

  1. //========= Copyright 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. class Color;
  15. class KeyValues;
  16. namespace vgui
  17. {
  18. typedef unsigned long HScheme;
  19. typedef unsigned long HTexture;
  20. class IBorder;
  21. class IImage;
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Holds all panel rendering data
  24. // This functionality is all wrapped in the Panel::GetScheme*() functions
  25. //-----------------------------------------------------------------------------
  26. class IScheme : public IBaseInterface
  27. {
  28. public:
  29. // gets a string from the default settings section
  30. virtual const char *GetResourceString(const char *stringName) = 0;
  31. // returns a pointer to an existing border
  32. virtual IBorder *GetBorder(const char *borderName) = 0;
  33. // returns a pointer to an existing font
  34. virtual HFont GetFont(const char *fontName, bool proportional = false) = 0;
  35. // inverse font lookup
  36. virtual char const *GetFontName( const HFont& font ) = 0;
  37. // colors
  38. virtual Color GetColor(const char *colorName, Color defaultColor) = 0;
  39. // Get the number of borders
  40. virtual int GetBorderCount() const = 0;
  41. // Get the border at the given index
  42. virtual IBorder *GetBorderAtIndex( int iIndex ) = 0;
  43. // Get the number of fonts
  44. virtual int GetFontCount() const = 0;
  45. // Get the font at the given index
  46. virtual HFont GetFontAtIndex( int iIndex ) = 0;
  47. // Get color data
  48. virtual const KeyValues *GetColorData() const = 0;
  49. };
  50. class ISchemeManager: public IBaseInterface
  51. {
  52. public:
  53. // loads a scheme from a file
  54. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  55. virtual HScheme LoadSchemeFromFile(const char *fileName, const char *tag) = 0;
  56. // reloads the scheme from the file - should only be used during development
  57. virtual void ReloadSchemes() = 0;
  58. // reloads scheme fonts
  59. virtual void ReloadFonts() = 0;
  60. // returns a handle to the default (first loaded) scheme
  61. virtual HScheme GetDefaultScheme() = 0;
  62. // returns a handle to the scheme identified by "tag"
  63. virtual HScheme GetScheme(const char *tag) = 0;
  64. // returns a pointer to an image
  65. virtual IImage *GetImage(const char *imageName, bool hardwareFiltered) = 0;
  66. virtual HTexture GetImageID(const char *imageName, bool hardwareFiltered) = 0;
  67. // This can only be called at certain times, like during paint()
  68. // It will assert-fail if you call it at the wrong time...
  69. // FIXME: This interface should go away!!! It's an icky back-door
  70. // If you're using this interface, try instead to cache off the information
  71. // in ApplySchemeSettings
  72. virtual IScheme *GetIScheme( HScheme scheme ) = 0;
  73. // unload all schemes
  74. virtual void Shutdown( bool full = true ) = 0;
  75. // gets the proportional coordinates for doing screen-size independant panel layouts
  76. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  77. virtual int GetProportionalScaledValue( int normalizedValue) = 0;
  78. virtual int GetProportionalNormalizedValue(int scaledValue) = 0;
  79. // loads a scheme from a file
  80. // first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
  81. virtual HScheme LoadSchemeFromFileEx( VPANEL sizingPanel, const char *fileName, const char *tag) = 0;
  82. // gets the proportional coordinates for doing screen-size independant panel layouts
  83. // use these for font, image and panel size scaling (they all use the pixel height of the display for scaling)
  84. virtual int GetProportionalScaledValueEx( HScheme scheme, int normalizedValue ) = 0;
  85. virtual int GetProportionalNormalizedValueEx( HScheme scheme, int scaledValue ) = 0;
  86. // Returns true if image evicted, false otherwise
  87. virtual bool DeleteImage( const char *pImageName ) = 0;
  88. };
  89. #define VGUI_SCHEME_INTERFACE_VERSION "VGUI_Scheme010"
  90. } // namespace vgui
  91. #endif // ISCHEME_H