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.

151 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #include "mdmpRipper.h"
  8. #include "vgui_controls/MessageMap.h"
  9. #include "vgui_controls/MenuBar.h"
  10. #include "vgui_controls/Menu.h"
  11. #include "tier1/KeyValues.h"
  12. #include "vgui/ISurface.h"
  13. #include "vgui_controls/Frame.h"
  14. #include "vgui_controls/FileOpenDialog.h"
  15. #include "vgui_controls/MenuButton.h"
  16. #include "CMDModulePanel.h"
  17. #include "CMDErrorPanel.h"
  18. using namespace vgui;
  19. //-----------------------------------------------------------------------------
  20. // Test panel
  21. //-----------------------------------------------------------------------------
  22. class CVGuiTestPanel : public vgui::Panel
  23. {
  24. DECLARE_CLASS_SIMPLE( CVGuiTestPanel, vgui::Panel );
  25. public:
  26. CVGuiTestPanel( vgui::Panel *pParent, const char *pName );
  27. virtual void PerformLayout();
  28. private:
  29. MESSAGE_FUNC( OnOpen, "Open" );
  30. MESSAGE_FUNC( OnError, "Error" );
  31. MESSAGE_FUNC_PARAMS( OnCompare, "compare", data );
  32. MESSAGE_FUNC_CHARPTR( OnFileSelected, "FileSelected", fullpath );
  33. void CVGuiTestPanel::MiniDumpCompare( CUtlVector<HANDLE> *pMiniDumpHandles );
  34. vgui::MenuBar *m_pMenuBar;
  35. vgui::Panel *m_pClientArea;
  36. // void OnFileSelected( const char * filename );
  37. };
  38. //-----------------------------------------------------------------------------
  39. // Class factory
  40. //-----------------------------------------------------------------------------
  41. vgui::Panel *CreateVGuiTestPanel( const char *pName )
  42. {
  43. CVGuiTestPanel *pVGuiTestPanel = new CVGuiTestPanel( NULL, pName );
  44. // pVGuiTestPanel->SetParent( g_pVGuiSurface->GetEmbeddedPanel() );
  45. return pVGuiTestPanel;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Constructor
  49. //-----------------------------------------------------------------------------
  50. CVGuiTestPanel::CVGuiTestPanel( vgui::Panel *pParent, const char *pName ) : BaseClass( NULL, pName )
  51. {
  52. // Create the menu bar
  53. m_pMenuBar = new vgui::MenuBar( this, "Main Menu Bar" );
  54. m_pMenuBar->SetSize( 10, 28 );
  55. // Create a test menu
  56. Menu *pFileMenu = new Menu(NULL, "File");
  57. pFileMenu->AddMenuItem( "&Open", new KeyValues( "Open" ), this );
  58. m_pMenuBar->AddMenu( "&File", pFileMenu );
  59. Menu *pErrorMenu = new Menu(NULL, "Error");
  60. pErrorMenu->AddMenuItem( "&Error", new KeyValues("Error"), this);
  61. m_pMenuBar->AddMenu( "&Error", pErrorMenu );
  62. MenuButton *pCloseButton = new vgui::MenuButton( this, "Close", "X" );
  63. m_pMenuBar->AddButton( pCloseButton );
  64. // Area below the menu bar
  65. m_pClientArea = new vgui::Panel( this, "VGuiTest Client Area ");
  66. }
  67. //-----------------------------------------------------------------------------
  68. // Test menu button
  69. //-----------------------------------------------------------------------------
  70. void CVGuiTestPanel::OnOpen()
  71. {
  72. FileOpenDialog *pFileDialog = new FileOpenDialog ( this, "File Open", true);
  73. pFileDialog->AddActionSignalTarget(this);
  74. pFileDialog->AddFilter( "*.mdmp", "MiniDumps", true );
  75. pFileDialog->DoModal( false );
  76. }
  77. void CVGuiTestPanel::OnError()
  78. {
  79. CMDErrorPanel *pPanel = new CMDErrorPanel( this, "MDError Panel" );
  80. pPanel->Create();
  81. pPanel->AddActionSignalTarget( this );
  82. pPanel->DoModal();
  83. }
  84. //-----------------------------------------------------------------------------
  85. // The editor panel should always fill the space...
  86. //-----------------------------------------------------------------------------
  87. void CVGuiTestPanel::PerformLayout()
  88. {
  89. // Make the editor panel fill the space
  90. int iWidth, iHeight;
  91. vgui::VPANEL parent = GetParent() ? GetParent()->GetVPanel() : vgui::surface()->GetEmbeddedPanel();
  92. vgui::ipanel()->GetSize( parent, iWidth, iHeight );
  93. SetSize( iWidth, iHeight );
  94. m_pMenuBar->SetSize( iWidth, 28 );
  95. // Make the client area also fill the space not used by the menu bar
  96. int iTemp, iMenuHeight;
  97. m_pMenuBar->GetSize( iTemp, iMenuHeight );
  98. m_pClientArea->SetPos( 0, iMenuHeight );
  99. m_pClientArea->SetSize( iWidth, iHeight - iMenuHeight );
  100. }
  101. void CVGuiTestPanel::OnCompare( KeyValues *data )
  102. {
  103. int test = data->GetInt( "handlePointer" );
  104. CUtlVector<HANDLE> *pMiniDumpHandles = (CUtlVector<HANDLE> *)(void *)test;
  105. CUtlVector<CMiniDumpObject *> miniDumps;
  106. for( int i = 0; i < pMiniDumpHandles->Count(); i++ )
  107. {
  108. miniDumps.AddToTail( new CMiniDumpObject( pMiniDumpHandles->Element( i ) ) );
  109. }
  110. CMDModulePanel *pPanel = new CMDModulePanel( this, "MDModule Panel" );
  111. pPanel->Create( &miniDumps );
  112. pPanel->DoModal();
  113. miniDumps.RemoveAll();
  114. pMiniDumpHandles->RemoveAll();
  115. }
  116. void CVGuiTestPanel::OnFileSelected( const char *filename )
  117. {
  118. CMDModulePanel *pPanel = new CMDModulePanel( this, "MDModule Panel" );
  119. pPanel->Create( filename );
  120. pPanel->DoModal();
  121. }