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.

155 lines
4.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef NEWGAMEDIALOG_H
  8. #define NEWGAMEDIALOG_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "vgui_controls/Frame.h"
  13. #include "vgui_controls/KeyRepeat.h"
  14. #include "utlvector.h"
  15. class CGameChapterPanel;
  16. class CSkillSelectionDialog;
  17. // Slot indices in new game menu
  18. #define INVALID_INDEX -1
  19. #define SLOT_OFFLEFT 0
  20. #define SLOT_LEFT 1
  21. #define SLOT_CENTER 2
  22. #define SLOT_RIGHT 3
  23. #define SLOT_OFFRIGHT 4
  24. #define NUM_SLOTS 5
  25. class CNewGamePlayButton : public vgui::Button
  26. {
  27. DECLARE_CLASS_SIMPLE( CNewGamePlayButton, vgui::Button );
  28. public:
  29. CNewGamePlayButton( Panel *parent, const char *panelName, const char *text, Panel *pActionSignalTarget=NULL, const char *pCmd=NULL )
  30. : vgui::Button( parent, panelName, text, pActionSignalTarget, pCmd )
  31. {
  32. }
  33. void OnKeyCodePressed( vgui::KeyCode code )
  34. {
  35. if ( code == KEY_XBUTTON_A || code == STEAMCONTROLLER_A )
  36. {
  37. ConVarRef var( "joystick" );
  38. if ( var.IsValid() && !var.GetBool() )
  39. {
  40. var.SetValue( true );
  41. }
  42. ConVarRef var2( "hud_fastswitch" );
  43. if ( var2.IsValid() && var2.GetInt() != 2 )
  44. {
  45. var2.SetValue( 2 );
  46. }
  47. DoClick();
  48. return;
  49. }
  50. BaseClass::OnKeyCodePressed( code );
  51. }
  52. };
  53. //-----------------------------------------------------------------------------
  54. // Purpose: Handles starting a new game, skill and chapter selection
  55. //-----------------------------------------------------------------------------
  56. class CNewGameDialog : public vgui::Frame
  57. {
  58. DECLARE_CLASS_SIMPLE( CNewGameDialog, vgui::Frame );
  59. public:
  60. MESSAGE_FUNC( FinishScroll, "FinishScroll" );
  61. MESSAGE_FUNC( StartGame, "StartGame" );
  62. CNewGameDialog(vgui::Panel *parent, bool bCommentaryMode );
  63. ~CNewGameDialog();
  64. virtual void Activate( void );
  65. virtual void ApplySettings( KeyValues *inResourceData );
  66. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  67. virtual void OnCommand( const char *command );
  68. virtual void OnClose( void );
  69. virtual void PaintBackground();
  70. void SetSelectedChapterIndex( int index );
  71. void SetSelectedChapter( const char *chapter );
  72. void UpdatePanelLockedStatus( int iUnlockedChapter, int i, CGameChapterPanel *pChapterPanel );
  73. void SetCommentaryMode( bool bCommentary ) { m_bCommentaryMode = bCommentary; }
  74. virtual void OnKeyCodePressed( vgui::KeyCode code );
  75. virtual void OnKeyCodeReleased( vgui::KeyCode code );
  76. virtual void OnThink();
  77. // Xbox: Defined values are also used to shift the slot indices
  78. enum EScrollDirection
  79. {
  80. SCROLL_RIGHT = -1,
  81. SCROLL_NONE = 0,
  82. SCROLL_LEFT = 1
  83. };
  84. EScrollDirection m_ScrollDirection;
  85. private:
  86. int m_iSelectedChapter;
  87. CUtlVector<CGameChapterPanel *> m_ChapterPanels;
  88. vgui::DHANDLE<CSkillSelectionDialog> m_hSkillSelectionDialog;
  89. vgui::Button *m_pPlayButton;
  90. vgui::Button *m_pNextButton;
  91. vgui::Button *m_pPrevButton;
  92. vgui::Panel *m_pCenterBg;
  93. vgui::Label *m_pChapterTitleLabels[2];
  94. vgui::Label *m_pBonusSelection;
  95. vgui::ImagePanel *m_pBonusSelectionBorder;
  96. CFooterPanel *m_pFooter;
  97. bool m_bCommentaryMode;
  98. vgui::Label *m_pCommentaryLabel;
  99. // Xbox
  100. void ScrollSelectionPanels( EScrollDirection dir );
  101. void ScrollBonusSelection( EScrollDirection dir );
  102. void PreScroll( EScrollDirection dir );
  103. void PostScroll( EScrollDirection dir );
  104. void SetFastScroll( bool fast );
  105. void ContinueScrolling( void );
  106. void AnimateSelectionPanels( void );
  107. void ShiftPanelIndices( int offset );
  108. bool IsValidPanel( const int idx );
  109. void InitPanelIndexForDisplay( const int idx );
  110. void UpdateMenuComponents( EScrollDirection dir );
  111. void UpdateBonusSelection( void );
  112. int m_PanelXPos[ NUM_SLOTS ];
  113. int m_PanelYPos[ NUM_SLOTS ];
  114. float m_PanelAlpha[ NUM_SLOTS ];
  115. int m_PanelIndex[ NUM_SLOTS ];
  116. float m_ScrollSpeed;
  117. int m_ButtonPressed;
  118. int m_ScrollCt;
  119. bool m_bScrolling;
  120. char m_ActiveTitleIdx;
  121. bool m_bMapStarting;
  122. int m_iBonusSelection;
  123. bool m_bScrollToFirstBonusMap;
  124. struct BonusMapDescription_t *m_pBonusMapDescription;
  125. vgui::CKeyRepeatHandler m_KeyRepeat;
  126. };
  127. #endif // NEWGAMEDIALOG_H