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.

163 lines
4.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // syncfiledialog.cpp : implementation file
  9. //
  10. #include "stdafx.h"
  11. #include "hammer.h"
  12. #include "syncfiledialog.h"
  13. #include "mapdoc.h"
  14. #include "p4lib/ip4.h"
  15. #include "options.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include <tier0/memdbgon.h>
  18. // CSyncFileDialog dialog
  19. bool CSyncFileDialog::m_bRepeatOperation = false;
  20. bool CSyncFileDialog::m_bDoSync = false;
  21. IMPLEMENT_DYNAMIC(CSyncFileDialog, CDialog)
  22. //-----------------------------------------------------------------------------
  23. // Purpose:
  24. // Input :
  25. // Output :
  26. //-----------------------------------------------------------------------------
  27. CSyncFileDialog::CSyncFileDialog( P4File_t *pFileInfo, CWnd* pParent /*=NULL*/ )
  28. : CDialog(CSyncFileDialog::IDD, pParent)
  29. {
  30. m_pFileInfo = pFileInfo;
  31. }
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. // Input :
  35. // Output :
  36. //-----------------------------------------------------------------------------
  37. CSyncFileDialog::~CSyncFileDialog()
  38. {
  39. }
  40. //-----------------------------------------------------------------------------
  41. // Purpose:
  42. // Input :
  43. // Output :
  44. //-----------------------------------------------------------------------------
  45. void CSyncFileDialog::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CDialog::DoDataExchange(pDX);
  48. DDX_Control(pDX, IDC_FILENAME, m_FileNameControl);
  49. DDX_Control(pDX, IDC_REVISION, m_RevisionControl);
  50. DDX_Control(pDX, IDC_DO_OPERATION, m_DoOperationControl);
  51. DDX_Control(pDX, IDC_SYNC_ICON, m_IconControl);
  52. }
  53. BEGIN_MESSAGE_MAP(CSyncFileDialog, CDialog)
  54. ON_BN_CLICKED(IDOK, &CSyncFileDialog::OnBnClickedOk)
  55. ON_BN_CLICKED(IDCANCEL, &CSyncFileDialog::OnBnClickedCancel)
  56. END_MESSAGE_MAP()
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. // Input :
  60. // Output :
  61. //-----------------------------------------------------------------------------
  62. void CSyncFileDialog::OnBnClickedOk()
  63. {
  64. m_bRepeatOperation = ( m_DoOperationControl.GetCheck() ? true : false );
  65. m_bDoSync = true;
  66. OnOK();
  67. }
  68. //-----------------------------------------------------------------------------
  69. // Purpose:
  70. // Input :
  71. // Output :
  72. //-----------------------------------------------------------------------------
  73. void CSyncFileDialog::OnBnClickedCancel()
  74. {
  75. m_bRepeatOperation = ( m_DoOperationControl.GetCheck() ? true : false );
  76. m_bDoSync = false;
  77. OnCancel();
  78. }
  79. //-----------------------------------------------------------------------------
  80. // Purpose:
  81. // Input :
  82. // Output :
  83. //-----------------------------------------------------------------------------
  84. BOOL CSyncFileDialog::OnInitDialog()
  85. {
  86. CDialog::OnInitDialog();
  87. char temp[ 256 ];
  88. m_FileNameControl.SetWindowText( p4->String( m_pFileInfo->m_sLocalFile ) );
  89. sprintf( temp, "Local Revision: %d Head Revision: %d", m_pFileInfo->m_iHaveRevision, m_pFileInfo->m_iHeadRevision );
  90. m_RevisionControl.SetWindowText( temp );
  91. m_DoOperationControl.SetCheck( m_bRepeatOperation ? TRUE : FALSE );
  92. HICON Icon = ::LoadIcon( NULL, MAKEINTRESOURCE( IDI_ERROR ) );
  93. m_IconControl.SetIcon( Icon );
  94. return TRUE;
  95. }
  96. //-----------------------------------------------------------------------------
  97. // Purpose:
  98. // Input :
  99. // Output :
  100. //-----------------------------------------------------------------------------
  101. void CheckForFileSync( const char *pszFileName, bool bClearRepeat )
  102. {
  103. if ( bClearRepeat == true )
  104. {
  105. CSyncFileDialog::m_bRepeatOperation = false;
  106. }
  107. if ( p4 && Options.general.bEnablePerforceIntegration == TRUE )
  108. {
  109. P4File_t FileInfo;
  110. if ( p4->GetFileInfo( pszFileName, &FileInfo ) == true )
  111. {
  112. if ( FileInfo.m_iHeadRevision != FileInfo.m_iHaveRevision )
  113. {
  114. if ( bClearRepeat == true || CSyncFileDialog::m_bRepeatOperation == false )
  115. {
  116. CSyncFileDialog SyncFileDialog( &FileInfo );
  117. SyncFileDialog.DoModal();
  118. }
  119. if ( CSyncFileDialog::m_bDoSync == true )
  120. {
  121. if ( p4->SyncFile( pszFileName ) == false )
  122. {
  123. AfxMessageBox( "Sync operation was NOT successful!", MB_OK ) ;
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }