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