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.

189 lines
6.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SAVEGAMEBROWSERDIALOG_H
  7. #define SAVEGAMEBROWSERDIALOG_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui/IScheme.h"
  12. #include "vgui/ILocalize.h"
  13. #include "vgui/ISurface.h"
  14. #include "vgui/ISystem.h"
  15. #include "vgui/IVGui.h"
  16. #include "vgui_controls/ImagePanel.h"
  17. #include "vgui_controls/footerpanel.h"
  18. #include "basepanel.h"
  19. class CSaveGameBrowserDialog;
  20. using namespace vgui;
  21. //-----------------------------------------------------------------------------
  22. // Purpose: selectable item with screenshot for an individual chapter in the dialog
  23. //-----------------------------------------------------------------------------
  24. class CGameSavePanel : public vgui::EditablePanel
  25. {
  26. DECLARE_CLASS_SIMPLE( CGameSavePanel, vgui::EditablePanel );
  27. public:
  28. CGameSavePanel( CSaveGameBrowserDialog *parent, SaveGameDescription_t *pSaveDesc, bool bCommandPanel = false );
  29. ~CGameSavePanel( void );
  30. virtual void ApplySchemeSettings( IScheme *pScheme );
  31. bool IsAutoSaveType( void ) { return ( Q_stristr( m_SaveInfo.szType, "autosave" ) != 0 ); }
  32. const SaveGameDescription_t *GetSaveInfo( void ) { return ( const SaveGameDescription_t * ) &m_SaveInfo; }
  33. void SetDescription( SaveGameDescription_t *pDesc );
  34. protected:
  35. SaveGameDescription_t m_SaveInfo; // Stored internally for easy access
  36. ImagePanel *m_pLevelPicBorder;
  37. ImagePanel *m_pLevelPic;
  38. ImagePanel *m_pCommentaryIcon;
  39. Label *m_pChapterTitle;
  40. Label *m_pTime;
  41. Label *m_pElapsedTime;
  42. Label *m_pType;
  43. Color m_TextColor;
  44. Color m_DisabledColor;
  45. Color m_SelectedColor;
  46. Color m_FillColor;
  47. bool m_bNewSavePanel;
  48. };
  49. // Slot indices in new game menu
  50. #define INVALID_INDEX -1
  51. #define SLOT_OFFLEFT 0
  52. #define SLOT_LEFT 1
  53. #define SLOT_CENTER 2
  54. #define SLOT_RIGHT 3
  55. #define SLOT_OFFRIGHT 4
  56. #define NUM_SLOTS 5
  57. //-----------------------------------------------------------------------------
  58. // Purpose: Handles starting a new game, skill and chapter selection
  59. //-----------------------------------------------------------------------------
  60. class CSaveGameBrowserDialog : public vgui::Frame
  61. {
  62. DECLARE_CLASS_SIMPLE( CSaveGameBrowserDialog, vgui::Frame );
  63. public:
  64. MESSAGE_FUNC( FinishScroll, "FinishScroll" );
  65. MESSAGE_FUNC( FinishDelete, "FinishDelete" );
  66. MESSAGE_FUNC( FinishInsert, "FinishInsert" );
  67. MESSAGE_FUNC( FinishOverwriteFadeDown, "FinishOverwriteFadeDown" );
  68. MESSAGE_FUNC( CloseAfterSave, "CloseAfterSave" );
  69. explicit CSaveGameBrowserDialog(vgui::Panel *parent );
  70. ~CSaveGameBrowserDialog();
  71. virtual void OnKeyCodePressed( vgui::KeyCode code );
  72. virtual void Activate( void );
  73. virtual void ApplySettings( KeyValues *inResourceData );
  74. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  75. virtual void OnClose( void );
  76. virtual void PaintBackground();
  77. virtual void PerformSelectedAction( void );
  78. virtual void PerformDeletion( void );
  79. virtual void UpdateFooterOptions( void );
  80. virtual void SortSaveGames( SaveGameDescription_t *pSaves, unsigned int nNumSaves );
  81. virtual void OnDoneScanningSaveGames( void ) {}
  82. virtual void RefreshSaveGames( void );
  83. unsigned int GetNumPanels( void ) { return m_SavePanels.Count(); }
  84. bool HasActivePanels( void ) { return ( m_SavePanels.Count() != 0 ); }
  85. CGameSavePanel *GetActivePanel( void );
  86. int GetActivePanelIndex( void ) { return m_iSelectedSave; }
  87. CFooterPanel *GetFooterPanel( void ) { return m_pFooter; }
  88. const SaveGameDescription_t *GetPanelSaveDecription( int idx ) { return ( IsValidPanel(idx) ? m_SavePanels[idx]->GetSaveInfo() : NULL ); }
  89. const SaveGameDescription_t *GetActivePanelSaveDescription( void ) { return GetPanelSaveDecription( m_iSelectedSave ); }
  90. uint GetStorageSpaceUsed( void ) { return m_nUsedStorageSpace; }
  91. void SetSelectedSaveIndex( int index );
  92. void SetSelectedSave( const char *chapter );
  93. void AddPanel( CGameSavePanel *pPanel ) { m_SavePanels.AddToHead( pPanel ); }
  94. void RemoveActivePanel( void );
  95. void AnimateInsertNewPanel( const SaveGameDescription_t *pDesc );
  96. void AnimateOverwriteActivePanel( const SaveGameDescription_t *pNewDesc );
  97. void SetControlDisabled( bool bState ) { m_bControlDisabled = bState; }
  98. // Xbox: Defined values are also used to shift the slot indices
  99. enum EScrollDirection
  100. {
  101. SCROLL_RIGHT = -1,
  102. SCROLL_NONE = 0,
  103. SCROLL_LEFT = 1
  104. };
  105. EScrollDirection m_ScrollDirection;
  106. protected:
  107. bool m_bFilterAutosaves;
  108. bool ParseSaveData( char const *pszFileName, char const *pszShortName, SaveGameDescription_t *save );
  109. private:
  110. CUtlVector<CGameSavePanel *> m_SavePanels;
  111. int m_iSelectedSave;
  112. float m_ScrollSpeedSlow;
  113. float m_ScrollSpeedFast;
  114. int m_nDeletedPanel; // Panel being subtracted
  115. int m_nAddedPanel; // Panel being added
  116. SaveGameDescription_t m_NewSaveGameDesc; // Held for panel animations
  117. uint m_nUsedStorageSpace; // Amount of disk space used by save games
  118. vgui::Panel *m_pCenterBg;
  119. vgui::CFooterPanel *m_pFooter;
  120. // Xbox
  121. void ScrollSelectionPanels( EScrollDirection dir );
  122. void PreScroll( EScrollDirection dir );
  123. void PostScroll( EScrollDirection dir );
  124. void SetFastScroll( bool fast );
  125. void ContinueScrolling( void );
  126. void AnimateSelectionPanels( void );
  127. void ShiftPanelIndices( int offset );
  128. bool IsValidPanel( const int idx );
  129. void InitPanelIndexForDisplay( const int idx );
  130. void UpdateMenuComponents( EScrollDirection dir );
  131. void ScanSavedGames( bool bIgnoreAutosave );
  132. void LayoutPanels( void );
  133. // "No Save Games" label
  134. void ShowNoSaveGameUI( void );
  135. void HideNoSaveGameUI( void );
  136. void PerformSlideAction( int nPanelIndex, int nNextPanelIndex );
  137. void AnimateDialogStart( void );
  138. int m_nCenterBgTallDefault;
  139. int m_PanelXPos[ NUM_SLOTS ];
  140. int m_PanelYPos[ NUM_SLOTS ];
  141. float m_PanelAlpha[ NUM_SLOTS ];
  142. int m_PanelIndex[ NUM_SLOTS ];
  143. float m_ScrollSpeed;
  144. int m_ButtonPressed;
  145. int m_ScrollCt;
  146. bool m_bScrolling : 1;
  147. bool m_bSaveGameIsCorrupt : 1;
  148. bool m_bControlDisabled : 1;
  149. };
  150. #endif // SAVEGAMEBROWSERDIALOG_H