doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EntKeyFindReplace.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 //#include "stdafx.h"
33 #include "radiant.h"
34 #include "GetString.h" // for ErrorBox() etc
35 #include "qe3.h"
36 
37 #include "EntKeyFindReplace.h"
38 //#include "oddbits.h"
39 /*
40 #include "stdafx.h"
41 #include "Radiant.h"
42 #include "ZWnd.h"
43 #include "qe3.h"
44 #include "zclip.h"
45 */
46 
47 #ifdef _DEBUG
48 #define new DEBUG_NEW
49 #undef THIS_FILE
50 static char THIS_FILE[] = __FILE__;
51 #endif
52 
54 // CEntKeyFindReplace dialog
55 
57  CString* p_strFindValue,
58  CString* p_strReplaceKey,
59  CString* p_strReplaceValue,
60  bool* p_bWholeStringMatchOnly,
61  bool* p_bSelectAllMatchingEnts,
62  CWnd* pParent /*=NULL*/)
63  : CDialog(CEntKeyFindReplace::IDD, pParent)
64 {
65  m_pStrFindKey = p_strFindKey;
66  m_pStrFindValue = p_strFindValue;
67  m_pStrReplaceKey = p_strReplaceKey;
68  m_pStrReplaceValue = p_strReplaceValue;
69  m_pbWholeStringMatchOnly = p_bWholeStringMatchOnly;
70  m_pbSelectAllMatchingEnts= p_bSelectAllMatchingEnts;
71 
72  //{{AFX_DATA_INIT(CEntKeyFindReplace)
79  //}}AFX_DATA_INIT
80 }
81 
82 
83 void CEntKeyFindReplace::DoDataExchange(CDataExchange* pDX)
84 {
85  CDialog::DoDataExchange(pDX);
86  //{{AFX_DATA_MAP(CEntKeyFindReplace)
87  DDX_Text(pDX, IDC_EDIT_FIND_KEY, m_strFindKey);
88  DDX_Text(pDX, IDC_EDIT_FIND_VALUE, m_strFindValue);
89  DDX_Text(pDX, IDC_EDIT_REPLACE_KEY, m_strReplaceKey);
93  //}}AFX_DATA_MAP
94 }
95 
96 
97 BEGIN_MESSAGE_MAP(CEntKeyFindReplace, CDialog)
98  //{{AFX_MSG_MAP(CEntKeyFindReplace)
99  ON_BN_CLICKED(IDC_REPLACE, OnReplace)
100  ON_BN_CLICKED(IDC_FIND, OnFind)
101  ON_BN_CLICKED(IDC_KEYCOPY, OnKeycopy)
102  ON_BN_CLICKED(IDC_VALUECOPY, OnValuecopy)
103  //}}AFX_MSG_MAP
104 END_MESSAGE_MAP()
105 
107 // CEntKeyFindReplace message handlers
108 
109 void CEntKeyFindReplace::OnCancel()
110 {
111  CDialog::OnCancel();
112 }
113 
115 {
116  // quick check, if no key value is specified then there's not much to do...
117  //
118  UpdateData(DIALOG_TO_DATA);
119  if (m_strFindKey.IsEmpty())
120  {
121  ErrorBox("Empty FIND <key>!\n\n(This is only permitted for FIND, not replace, for safety reasons)");
122  }
123  else
124  {
125  if (!m_strFindValue.IsEmpty() || GetYesNo(va("Empty FIND <value> means replace any existing ( & non-blank ) <value> for <key> \"%s\"\n\nProceed?",(LPCSTR)m_strFindKey)))
126  {
127  // another check, if they're trying to do a replace with a missing replace key, it'll just delete found keys...
128  //
129  if ((!m_strReplaceKey.IsEmpty() && !m_strReplaceValue.IsEmpty()) || GetYesNo(va("Empty REPLACE <key> or <value> fields will just delete all occurence of <key> \"%s\"\n\nProceed?",m_strFindKey)))
130  {
131  if (GetYesNo("Sure?"))
132  {
133  CopyFields();
134  EndDialog(ID_RET_REPLACE);
135  }
136  }
137  }
138  }
139 }
140 
142 {
143  // quick check, if no key value is specified then there's not much to do...
144  //
145  UpdateData(DIALOG_TO_DATA);
146 
147  if (m_strFindKey.IsEmpty() && m_strFindValue.IsEmpty())
148  {
149  ErrorBox("Empty FIND fields!");
150  }
151  else
152  {
153 // if (m_strFindKey.IsEmpty() && m_bSelectAllMatchingEnts)
154 // {
155 // if (GetYesNo("Warning! Having a blank FIND <key> and ticking \"Select all matching ents\" can take a LONG time to do (and is probably a wrong choice anyway?)\n\nProceed?"))
156 // {
157 // CopyFields();
158 // EndDialog(ID_RET_FIND);
159 // }
160 // }
161 // else
162  {
163  CopyFields();
164  EndDialog(ID_RET_FIND);
165  }
166  }
167 }
168 
170 {
171  UpdateData(DIALOG_TO_DATA);
172 
179 }
180 
181 
183 {
184  UpdateData(DIALOG_TO_DATA);
185 
187 
188  UpdateData(DATA_TO_DIALOG);
189 }
190 
192 {
193  UpdateData(DIALOG_TO_DATA);
194 
196 
197  UpdateData(DATA_TO_DIALOG);
198 }
199 
CString * m_pStrReplaceValue
afx_msg void OnReplace()
#define IDC_KEYCOPY
#define IDC_EDIT_REPLACE_VALUE
#define IDC_EDIT_FIND_VALUE
#define IDC_EDIT_REPLACE_KEY
#define IDC_FIND
afx_msg void OnKeycopy()
#define DATA_TO_DIALOG
Definition: Radiant.h:75
afx_msg void OnValuecopy()
#define IDC_CHECK_FIND_WHOLESTRINGMATCHONLY
virtual void DoDataExchange(CDataExchange *pDX)
CEntKeyFindReplace(CString *p_strFindKey, CString *p_strFindValue, CString *p_strReplaceKey, CString *p_strReplaceValue, bool *p_bWholeStringMatchOnly, bool *p_bSelectAllMatchingEnts, CWnd *pParent=NULL)
#define DIALOG_TO_DATA
Definition: Radiant.h:76
#define ID_RET_REPLACE
#define ID_RET_FIND
#define IDC_EDIT_FIND_KEY
#define IDC_REPLACE
char * va(const char *fmt,...)
Definition: Str.cpp:1568
#define IDC_CHECK_SELECTALLMATCHING
#define IDC_VALUECOPY
void ErrorBox(const char *sString)
Definition: GetString.cpp:112
bool GetYesNo(const char *psQuery)
Definition: GetString.cpp:104