forked from perilouswithadollarsign/cstrike15_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplacetexdlg.cpp
168 lines (140 loc) · 3.69 KB
/
replacetexdlg.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
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "stdafx.h"
#include "hammer.h"
#include "ReplaceTexDlg.h"
#include "MainFrm.h"
#include "GlobalFunctions.h"
#include "TextureBrowser.h"
#include "TextureSystem.h"
#include "mapdoc.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
CReplaceTexDlg::CReplaceTexDlg(int nSelected, CWnd* pParent /*=NULL*/)
: CDialog(CReplaceTexDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CReplaceTexDlg)
m_iSearchAll = nSelected ? FALSE : TRUE;
m_strFind = _T("");
m_strReplace = _T("");
m_iAction = 0;
m_bMarkOnly = FALSE;
m_bHidden = FALSE;
m_bRescaleTextureCoordinates = false;
//}}AFX_DATA_INIT
m_nSelected = nSelected;
}
void CReplaceTexDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReplaceTexDlg)
DDX_Control(pDX, IDC_FIND, m_cFind);
DDX_Control(pDX, IDC_REPLACE, m_cReplace);
DDX_Control(pDX, IDC_REPLACEPIC, m_cReplacePic);
DDX_Control(pDX, IDC_FINDPIC, m_cFindPic);
DDX_Radio(pDX, IDC_INMARKED, m_iSearchAll);
DDX_Text(pDX, IDC_FIND, m_strFind);
DDX_Text(pDX, IDC_REPLACE, m_strReplace);
DDX_Radio(pDX, IDC_ACTION, m_iAction);
DDX_Check(pDX, IDC_MARKONLY, m_bMarkOnly);
DDX_Check(pDX, IDC_HIDDEN, m_bHidden);
DDX_Check(pDX, IDC_RESCALETEXTURECOORDINATES, m_bRescaleTextureCoordinates);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReplaceTexDlg, CDialog)
//{{AFX_MSG_MAP(CReplaceTexDlg)
ON_BN_CLICKED(IDC_BROWSEREPLACE, OnBrowsereplace)
ON_BN_CLICKED(IDC_BROWSEFIND, OnBrowsefind)
ON_EN_UPDATE(IDC_FIND, OnUpdateFind)
ON_EN_UPDATE(IDC_REPLACE, OnUpdateReplace)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReplaceTexDlg message handlers
void CReplaceTexDlg::BrowseTex(int iEdit)
{
CString strTex;
CWnd *pWnd = GetDlgItem(iEdit);
pWnd->GetWindowText(strTex);
CTextureBrowser *pBrowser = new CTextureBrowser(GetMainWnd());
pBrowser->SetUsed(iEdit == IDC_FIND);
pBrowser->SetInitialTexture(strTex);
if (pBrowser->DoModal() == IDOK)
{
IEditorTexture *pTex = g_Textures.FindActiveTexture(pBrowser->m_cTextureWindow.szCurTexture);
char szName[MAX_PATH];
if (pTex != NULL)
{
pTex->GetShortName(szName);
}
else
{
szName[0] = '\0';
}
pWnd->SetWindowText(szName);
}
delete pBrowser;
}
void CReplaceTexDlg::OnBrowsereplace()
{
BrowseTex(IDC_REPLACE);
}
void CReplaceTexDlg::OnBrowsefind()
{
BrowseTex(IDC_FIND);
}
//
// find/replace text string updates:
//
void CReplaceTexDlg::OnUpdateFind()
{
// get texture window and set texture in there
CString strTex;
m_cFind.GetWindowText(strTex);
IEditorTexture *pTex = g_Textures.FindActiveTexture(strTex);
m_cFindPic.SetTexture(pTex);
}
void CReplaceTexDlg::OnUpdateReplace()
{
// get texture window and set texture in there
CString strTex;
m_cReplace.GetWindowText(strTex);
IEditorTexture *pTex = g_Textures.FindActiveTexture(strTex);
m_cReplacePic.SetTexture(pTex);
}
BOOL CReplaceTexDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(!m_nSelected)
{
CWnd *pWnd = GetDlgItem(IDC_INMARKED);
pWnd->EnableWindow(FALSE);
}
OnUpdateFind();
return TRUE;
}
void CReplaceTexDlg::DoReplaceTextures()
{
CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
if ( pDoc )
{
pDoc->ReplaceTextures(
m_strFind,
m_strReplace,
m_iSearchAll,
m_iAction | ( m_bMarkOnly ? 0x100 : 0 ),
m_bHidden,
(m_bRescaleTextureCoordinates != 0)
);
}
}