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.

172 lines
4.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ====
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "stdafx.h"
  7. #include "hammer.h"
  8. #include "PasteSpecialDlg.h"
  9. #pragma warning(disable:4244)
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include <tier0/memdbgon.h>
  12. static LPCTSTR pszIni = "Paste Special";
  13. CPasteSpecialDlg::CPasteSpecialDlg(CWnd* pParent /*=NULL*/, BoundBox* pBox)
  14. : CDialog(CPasteSpecialDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CPasteSpecialDlg)
  17. m_iCopies = 1;
  18. m_bGroup = FALSE;
  19. m_iOffsetX = 0;
  20. m_iOffsetY = 0;
  21. m_iOffsetZ = 0;
  22. m_fRotateX = 0.0f;
  23. m_fRotateZ = 0.0f;
  24. m_fRotateY = 0.0f;
  25. m_bCenterOriginal = TRUE;
  26. m_bMakeEntityNamesUnique = FALSE;
  27. m_bAddPrefix = FALSE;
  28. //}}AFX_DATA_INIT
  29. CWinApp *App = AfxGetApp();
  30. CString str;
  31. LPCTSTR p;
  32. m_iCopies = App->GetProfileInt(pszIni, "Copies", 1);
  33. m_bGroup = App->GetProfileInt(pszIni, "Group", FALSE);
  34. str = App->GetProfileString(pszIni, "Offset", "0 0 0");
  35. p = str.GetBuffer(0);
  36. m_iOffsetX = atoi(p);
  37. m_iOffsetY = atoi(strchr(p, ' ')+1);
  38. m_iOffsetZ = atoi(strrchr(p, ' ')+1);
  39. str = App->GetProfileString(pszIni, "Rotate", "0 0 0");
  40. p = str.GetBuffer(0);
  41. m_fRotateX = atof(p);
  42. m_fRotateY = atof(strchr(p, ' ')+1);
  43. m_fRotateZ = atof(strrchr(p, ' ')+1);
  44. m_bCenterOriginal = App->GetProfileInt(pszIni, "Center", TRUE);
  45. m_bMakeEntityNamesUnique = App->GetProfileInt(pszIni, "MakeNamesUnique", FALSE);
  46. m_bAddPrefix = App->GetProfileInt(pszIni, "AddPrefix", FALSE);
  47. m_strPrefix = App->GetProfileString(pszIni, "Prefix", "");
  48. ObjectsBox = *pBox;
  49. }
  50. void CPasteSpecialDlg::SaveToIni()
  51. {
  52. CWinApp *App = AfxGetApp();
  53. CString str;
  54. App->WriteProfileInt(pszIni, "Copies", m_iCopies);
  55. App->WriteProfileInt(pszIni, "Group", m_bGroup);
  56. str.Format("%d %d %d", m_iOffsetX, m_iOffsetY, m_iOffsetZ);
  57. App->WriteProfileString(pszIni, "Offset", str);
  58. str.Format("%.1f %.1f %.1f", m_fRotateX, m_fRotateY, m_fRotateZ);
  59. App->WriteProfileString(pszIni, "Rotate", str);
  60. App->WriteProfileInt(pszIni, "Center", m_bCenterOriginal);
  61. App->WriteProfileInt(pszIni, "MakeNamesUnique", m_bMakeEntityNamesUnique);
  62. App->WriteProfileInt(pszIni, "AddPrefix", m_bAddPrefix);
  63. App->WriteProfileString(pszIni, "Prefix", m_strPrefix);
  64. }
  65. BOOL CPasteSpecialDlg::OnInitDialog()
  66. {
  67. BOOL bEnable = m_bAddPrefix ? TRUE : FALSE;
  68. GetDlgItem( IDC_PASTE_SPECIAL_PREFIX_TEXT )->EnableWindow( bEnable );
  69. return CDialog::OnInitDialog();
  70. }
  71. void CPasteSpecialDlg::DoDataExchange(CDataExchange* pDX)
  72. {
  73. CDialog::DoDataExchange(pDX);
  74. //{{AFX_DATA_MAP(CPasteSpecialDlg)
  75. DDX_Text(pDX, IDC_COPIES, m_iCopies);
  76. DDV_MinMaxInt(pDX, m_iCopies, 1, 256);
  77. DDX_Check(pDX, IDC_GROUP, m_bGroup);
  78. DDX_Text(pDX, IDC_OFFSETX, m_iOffsetX);
  79. DDX_Text(pDX, IDC_OFFSETY, m_iOffsetY);
  80. DDX_Text(pDX, IDC_OFFSETZ, m_iOffsetZ);
  81. DDX_Text(pDX, IDC_ROTATEX, m_fRotateX);
  82. DDV_MinMaxFloat(pDX, m_fRotateX, 0.f, 360.f);
  83. DDX_Text(pDX, IDC_ROTATEZ, m_fRotateZ);
  84. DDV_MinMaxFloat(pDX, m_fRotateZ, 0.f, 360.f);
  85. DDX_Text(pDX, IDC_ROTATEY, m_fRotateY);
  86. DDV_MinMaxFloat(pDX, m_fRotateY, 0.f, 360.f);
  87. DDX_Check(pDX, IDC_CENTERORIGINAL, m_bCenterOriginal);
  88. DDX_Check(pDX, IDC_PASTE_SPECIAL_MAKE_UNIQUE, m_bMakeEntityNamesUnique);
  89. DDX_Check(pDX, IDC_PASTE_SPECIAL_ADD_PREFIX, m_bAddPrefix);
  90. DDX_Text(pDX, IDC_PASTE_SPECIAL_PREFIX_TEXT, m_strPrefix);
  91. //}}AFX_DATA_MAP
  92. }
  93. BEGIN_MESSAGE_MAP(CPasteSpecialDlg, CDialog)
  94. //{{AFX_MSG_MAP(CPasteSpecialDlg)
  95. ON_BN_CLICKED(IDC_GETOFFSETX, OnGetoffsetx)
  96. ON_BN_CLICKED(IDC_GETOFFSETY, OnGetoffsety)
  97. ON_BN_CLICKED(IDC_GETOFFSETZ, OnGetoffsetz)
  98. ON_BN_CLICKED(IDC_PASTE_SPECIAL_ADD_PREFIX, OnCheckUncheckAddPrefix)
  99. //}}AFX_MSG_MAP
  100. END_MESSAGE_MAP()
  101. void CPasteSpecialDlg::GetOffset(int iAxis, int iEditCtrl)
  102. {
  103. CWnd *pWnd = GetDlgItem(iEditCtrl);
  104. Assert(pWnd);
  105. // get current value
  106. CString strValue;
  107. pWnd->GetWindowText(strValue);
  108. int iValue = atoi(strValue);
  109. int iAxisSize = ObjectsBox.bmaxs[iAxis] - ObjectsBox.bmins[iAxis];
  110. if(iValue == iAxisSize) // if it's already positive, make it neg
  111. strValue.Format("%d", -iAxisSize);
  112. else // it's negative or !=, set it positive
  113. strValue.Format("%d", iAxisSize);
  114. // set the window text
  115. pWnd->SetWindowText(strValue);
  116. }
  117. void CPasteSpecialDlg::OnGetoffsetx()
  118. {
  119. GetOffset(0, IDC_OFFSETX);
  120. }
  121. void CPasteSpecialDlg::OnGetoffsety()
  122. {
  123. GetOffset(1, IDC_OFFSETY);
  124. }
  125. void CPasteSpecialDlg::OnGetoffsetz()
  126. {
  127. GetOffset(2, IDC_OFFSETZ);
  128. }
  129. void CPasteSpecialDlg::OnCheckUncheckAddPrefix()
  130. {
  131. CButton *pButton = ( CButton * )GetDlgItem( IDC_PASTE_SPECIAL_ADD_PREFIX );
  132. BOOL bEnable = pButton->GetCheck();
  133. GetDlgItem( IDC_PASTE_SPECIAL_PREFIX_TEXT )->EnableWindow( bEnable );
  134. }