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.

105 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //=======================================================================================//
  4. #ifndef SLIDESHOWPANEL_H
  5. #define SLIDESHOWPANEL_H
  6. #ifdef _WIN32
  7. #pragma once
  8. #endif
  9. #include "vgui_controls/EditablePanel.h"
  10. #include "vgui_controls/ProgressBar.h"
  11. #include "vgui_controls/ImagePanel.h"
  12. using namespace vgui;
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Allows fade from one image to another
  15. //-----------------------------------------------------------------------------
  16. class CCrossfadableImagePanel : public EditablePanel
  17. {
  18. DECLARE_CLASS_SIMPLE( CCrossfadableImagePanel, EditablePanel );
  19. public:
  20. CCrossfadableImagePanel( Panel* pParent, const char *pName );
  21. ~CCrossfadableImagePanel();
  22. virtual void ApplySettings( KeyValues *pInResourceData );
  23. virtual void ApplySchemeSettings( IScheme *pScheme );
  24. virtual void PerformLayout();
  25. // A duplicate of the ImagePanel interface - the only difference being that
  26. // here we have blend times for SetImage().
  27. void SetImage( IImage *pImage, float flBlendTime = 0.0f );
  28. void SetImage( const char *pImageName, float flBlendTime = 0.0f );
  29. void SetShouldScaleImage( bool bState );
  30. void SetScaleAmount( float flScale );
  31. void SetDrawColor( Color clrDrawColor );
  32. IImage *GetImage();
  33. const char *GetImageName();
  34. void SetFillColor( Color c );
  35. float GetScaleAmount();
  36. bool GetShouldScaleImage();
  37. Color GetFillColor();
  38. Color GetDrawColor();
  39. virtual void InstallMouseHandler( Panel *pHandler );
  40. private:
  41. virtual void OnSizeChanged( int nWide, int nTall );
  42. virtual void OnTick();
  43. inline ImagePanel *SrcImg() { return m_pImages[ m_iSrcImg ]; }
  44. inline ImagePanel *DstImg() { return m_pImages[ !m_iSrcImg ]; }
  45. void SetupImageBlend( float flBlendTime );
  46. float m_flStartBlendTime; // the gpGlobals->realtime when we started blending
  47. float m_flBlendTime; // amount of time to blend from one image to the next one
  48. float m_flBlend; // blend value in [0,1] where 0 maps to the source image, and 1 maps to the dest image
  49. bool m_bBlending; // are we currently transitioning/blending from one image to another?
  50. ImagePanel* m_pImages[2];
  51. int m_iSrcImg; // 0 or 1
  52. };
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Displays a slideshow of images at a set interval
  55. //-----------------------------------------------------------------------------
  56. class CSlideshowPanel : public EditablePanel
  57. {
  58. DECLARE_CLASS_SIMPLE( CSlideshowPanel, EditablePanel );
  59. public:
  60. CSlideshowPanel( Panel *pParent, const char *pName );
  61. ~CSlideshowPanel();
  62. // Pass in a vgui-relative path, like "training/screenshots/cp_dustbowl_", and
  63. // the slideshow panel will add "0.vmt", "1.vmt" etc. until it can't find anymore images.
  64. void FillWithImages( const char *pBasePath );
  65. void AddImage( const char *pImageName );
  66. void AddImage( IImage *pImage );
  67. void SetInterval( float flInterval );
  68. void SetTransitionTime( float flTransitionLength );
  69. CCrossfadableImagePanel *GetImagePanel() { return m_pImagePanel; }
  70. int GetImageCount() const { return m_vecImages.Count(); }
  71. private:
  72. virtual void ApplySettings( KeyValues *pInResourceData );
  73. virtual void OnSizeChanged( int nWide, int nTall );
  74. virtual void OnTick();
  75. void UpdateNextTransitionTime();
  76. CCrossfadableImagePanel *m_pImagePanel;
  77. CUtlVector< IImage * > m_vecImages;
  78. float m_flNextTransitionTime; // gpGlobals->realtime of time when we should transition next
  79. float m_flInterval; // Amount of time between blend begins to next image, in seconds
  80. float m_flTransitionLength; // Length of each transition
  81. int m_iCurImg; // Current image index
  82. };
  83. #endif // SLIDESHOWPANEL_H