2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/rc/Common_resource.h"
33 #include "../../sys/win32/rc/DeclEditor_resource.h"
35 #include "../comafx/CPathTreeCtrl.h"
36 #include "DialogDeclBrowser.h"
37 #include "DialogDeclEditor.h"
38 #include "DialogEntityDefEditor.h"
40 #ifdef ID_DEBUG_MEMORY
47 // DialogEntityDefEditor dialog
49 toolTip_t DialogEntityDefEditor::toolTips[] = {
50 { IDC_DECLEDITOR_BUTTON_TEST, "Test Decl" },
51 { IDOK, "Save Decl" },
52 { IDCANCEL, "Cancel" },
57 IMPLEMENT_DYNAMIC(DialogEntityDefEditor, CDialog)
61 DialogEntityDefEditor::DialogEntityDefEditor
64 DialogEntityDefEditor::DialogEntityDefEditor( CWnd* pParent /*=NULL*/ )
65 : CDialog(DialogEntityDefEditor::IDD, pParent)
73 DialogEntityDefEditor::~DialogEntityDefEditor
76 DialogEntityDefEditor::~DialogEntityDefEditor() {
81 DialogEntityDefEditor::DoDataExchange
84 void DialogEntityDefEditor::DoDataExchange(CDataExchange* pDX) {
85 CDialog::DoDataExchange(pDX);
86 //{{AFX_DATA_MAP(DialogEntityDefEditor)
87 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_EDIT_DECLNAME, declNameEdit);
88 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_COMBO_INHERIT, inheritCombo);
89 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_COMBO_SPAWNCLASS, spawnclassCombo);
91 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_LIST_KEYVALS, keyValsList);
93 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_STATIC_KEY, keyLabel);
94 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_EDIT_KEY, keyEdit);
95 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_BUTTON_ADD, addButton);
96 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_BUTTON_DELETE, delButton);
97 DDX_Control(pDX, IDC_ENTITYDEFEDITOR_LINE, line);
99 DDX_Control(pDX, IDC_DECLEDITOR_BUTTON_TEST, testButton);
100 DDX_Control(pDX, IDOK, okButton);
101 DDX_Control(pDX, IDCANCEL, cancelButton);
107 DialogEntityDefEditor::PreTranslateMessage
110 BOOL DialogEntityDefEditor::PreTranslateMessage( MSG* pMsg ) {
111 if ( WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST ) {
112 if ( m_hAccel && ::TranslateAccelerator( m_hWnd, m_hAccel, pMsg ) ) {
116 return CWnd::PreTranslateMessage(pMsg);
121 DialogEntityDefEditor::TestDecl
124 bool DialogEntityDefEditor::TestDecl( const idStr &declText ) {
125 idLexer src( LEXFL_NOSTRINGCONCAT );
129 src.LoadMemory( declText, declText.Length(), "decl text" );
132 while( src.ReadToken( &token ) ) {
133 if ( token == "{" ) {
135 } else if ( token == "}" ) {
141 MessageBox( "Missing opening brace!", va( "Error saving %s", decl->GetFileName() ), MB_OK | MB_ICONERROR );
145 MessageBox( "Missing closing brace!", va( "Error saving %s", decl->GetFileName() ), MB_OK | MB_ICONERROR );
153 DialogEntityDefEditor::UpdateStatusBar
156 void DialogEntityDefEditor::UpdateStatusBar( void ) {
158 statusBar.SetWindowText( "Editing decl" );
164 DialogEntityDefEditor::LoadDecl
167 void DialogEntityDefEditor::LoadDecl( idDeclEntityDef *decl ) {
173 // Fill up the spawnclass box with all spawn classes
175 idTypeInfo *c = idClass::GetClass("idClass");
176 for (; c; c = c->next) {
177 spawnclassCombo.AddString(c->classname);
181 // Fill up the inherit box with all entitydefs
182 int numDecls = declManager->GetNumDecls(DECL_ENTITYDEF);
183 for (int i=0; i<numDecls; i++) {
184 const idDecl *d = declManager->DeclByIndex(DECL_ENTITYDEF, i, false);
186 inheritCombo.AddString(d->GetName());
190 firstLine = decl->GetLineNum();
192 char *declText = (char *)_alloca( ( decl->GetTextLength() + 1 ) * sizeof( char ) );
193 decl->GetText( declText );
195 PopulateLists( declText );
197 SetWindowText( va( "EntityDef Editor (%s, line %d)", decl->GetFileName(), decl->GetLineNum() ) );
199 // Hack to get it to reflow the window
200 GetWindowRect( rect );
204 testButton.EnableWindow( FALSE );
205 okButton.EnableWindow( FALSE );
212 DialogEntityDefEditor::PopulateLists
215 void DialogEntityDefEditor::PopulateLists( const char *declText, const int textLength )
218 idToken token, token2;
222 src.LoadMemory( declText, textLength, decl->GetFileName(), firstLine);
223 src.SetFlags( DECL_LEXER_FLAGS );
224 src.SkipUntilString( "{" );
227 if ( !src.ReadToken( &token ) ) {
231 if ( !token.Icmp( "}" ) ) {
234 if ( token.type != TT_STRING ) {
235 src.Warning( "Expected quoted string, but found '%s'", token.c_str() );
239 if ( !src.ReadToken( &token2 ) ) {
240 src.Warning( "Unexpected end of file" );
244 if ( dict.FindKey( token ) ) {
245 src.Warning( "'%s' already defined", token.c_str() );
247 dict.Set( token, token2 );
250 // Get the parent, and remove the 'inherit' key so it doesn't show up in the list
251 // We currently don't support multiple inheritence properly, but nothing uses it anyway
253 const idKeyValue *inheritKeyVal = dict.FindKey("inherit");
255 inherit = inheritKeyVal->GetValue();
256 dict.Delete(inheritKeyVal->GetKey());
259 idStr spawnclass = dict.GetString("spawnclass", "");
260 dict.Delete("spawnclass");
262 keyValsList.ResetContent();
264 // Fill up the list with all the main info
265 size_t numPairs = dict.Size();
266 for (unsigned int i=0; i<numPairs; i++) {
267 const idKeyValue *keyVal = dict.GetKeyVal(i);
269 keyValsList.AddPropItem(new CPropertyItem(keyVal->GetKey().c_str(), keyVal->GetValue().c_str(), PIT_EDIT, ""));
273 //inheritCombo.SelectString(0, inherit);
275 inheritCombo.SelectString(0, inherit);
277 declNameEdit.SetWindowText(decl->GetName());
278 int index = spawnclassCombo.FindString(0, spawnclass);
279 if (index == CB_ERR) {
280 index = spawnclassCombo.AddString(spawnclass);
282 spawnclassCombo.SetCurSel(index);
287 DialogEntityDefEditor::SetInherit
291 void DialogEntityDefEditor::SetInherit(idStr &inherit)
295 for (int i=0; i<keyValsList.GetCount(); i++) {
296 CPropertyItem* pItem = (CPropertyItem*)keyValsList.GetItemDataPtr(i);
298 if (pItem->m_propName[0] == '*') {
300 keyValsList.DeleteString(i);
307 // Fill up the rest of the box with inherited info
308 if (!inherit.IsEmpty()) {
309 const idDecl *temp = declManager->FindType(DECL_ENTITYDEF, inherit, false);
310 const idDeclEntityDef *parent = static_cast<const idDeclEntityDef *>(temp);
312 size_t numPairs = parent->dict.Size();
313 for (unsigned int i=0; i<numPairs; i++) {
314 const idKeyValue *keyVal = parent->dict.GetKeyVal(i);
316 if (spawnclass.IsEmpty() && keyVal->GetKey() == "spawnclass") {
317 spawnclass = keyVal->GetValue();
320 CString key = keyVal->GetKey();
322 keyValsList.AddPropItem(new CPropertyItem(key, keyVal->GetValue().c_str(), PIT_EDIT, ""));
332 DialogEntityDefEditor::OnInitDialog
335 BOOL DialogEntityDefEditor::OnInitDialog() {
337 com_editors |= EDITOR_ENTITYDEF;
339 CDialog::OnInitDialog();
341 // load accelerator table
342 m_hAccel = ::LoadAccelerators( AfxGetResourceHandle(), MAKEINTRESOURCE( IDR_ACCELERATOR_DECLEDITOR ) );
345 statusBar.CreateEx( SBARS_SIZEGRIP, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, initialRect, this, AFX_IDW_STATUS_BAR );
347 GetClientRect( initialRect );
349 EnableToolTips( TRUE );
351 testButton.EnableWindow( FALSE );
352 okButton.EnableWindow( FALSE );
356 return FALSE; // return TRUE unless you set the focus to a control
357 // EXCEPTION: OCX Property Pages should return FALSE
361 BEGIN_MESSAGE_MAP(DialogEntityDefEditor, CDialog)
362 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
363 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
370 ON_CBN_EDITCHANGE(IDC_ENTITYDEFEDITOR_COMBO_INHERIT, OnInheritChange)
371 ON_CBN_SELCHANGE(IDC_ENTITYDEFEDITOR_COMBO_INHERIT, OnInheritChange)
372 ON_CBN_EDITCHANGE(IDC_ENTITYDEFEDITOR_COMBO_SPAWNCLASS, OnEditChange)
373 ON_EN_CHANGE(IDC_ENTITYDEFEDITOR_EDIT_DECLNAME, OnEditChange)
374 ON_NOTIFY(EN_MSGFILTER, IDC_DECLEDITOR_EDIT_TEXT, OnEnInputEdit)
376 ON_LBN_SELCHANGE(IDC_ENTITYDEFEDITOR_LIST_KEYVALS, OnKeyValChange)
378 ON_BN_CLICKED(IDC_ENTITYDEFEDITOR_BUTTON_ADD, OnBnClickedAdd)
379 ON_BN_CLICKED(IDC_ENTITYDEFEDITOR_BUTTON_DELETE, OnBnClickedDelete)
381 ON_BN_CLICKED(IDC_DECLEDITOR_BUTTON_TEST, OnBnClickedTest)
382 ON_BN_CLICKED(IDOK, OnBnClickedOk)
383 ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
388 // DialogEntityDefEditor message handlers
392 DialogEntityDefEditor::OnActivate
395 void DialogEntityDefEditor::OnActivate( UINT nState, CWnd *pWndOther, BOOL bMinimized ) {
396 CDialog::OnActivate( nState, pWndOther, bMinimized );
401 DialogEntityDefEditor::OnToolTipNotify
404 BOOL DialogEntityDefEditor::OnToolTipNotify( UINT id, NMHDR *pNMHDR, LRESULT *pResult ) {
405 return DefaultOnToolTipNotify( toolTips, id, pNMHDR, pResult );
410 DialogEntityDefEditor::OnSetFocus
413 void DialogEntityDefEditor::OnSetFocus( CWnd *pOldWnd ) {
414 CDialog::OnSetFocus( pOldWnd );
419 DialogEntityDefEditor::OnDestroy
422 void DialogEntityDefEditor::OnDestroy() {
423 return CDialog::OnDestroy();
428 DialogEntityDefEditor::OnMove
431 void DialogEntityDefEditor::OnMove( int x, int y ) {
432 if ( GetSafeHwnd() ) {
434 GetWindowRect( rct );
435 // FIXME: save position
437 CDialog::OnMove( x, y );
442 DialogEntityDefEditor::OnSize
445 #define BORDER_SIZE 4
446 #define BUTTON_SPACE 4
447 #define CONTROL_HEIGHT 24
448 #define TOOLBAR_HEIGHT 24
450 void DialogEntityDefEditor::OnSize( UINT nType, int cx, int cy ) {
451 CRect clientRect, rect;
455 CDialog::OnSize( nType, cx, cy );
457 GetClientRect( clientRect );
459 if ( keyValsList.GetSafeHwnd() ) {
460 keyValsList.GetClientRect( rect );
461 rect.left = BORDER_SIZE;
462 rect.right = clientRect.right - BORDER_SIZE;
463 rect.top = (TOOLBAR_HEIGHT * 2) + (BUTTON_SPACE * 3);
464 rect.bottom = clientRect.bottom - (TOOLBAR_HEIGHT * 4) - BUTTON_SPACE;
465 keyValsList.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
468 int keyRowTop = clientRect.Height() - TOOLBAR_HEIGHT * 3 - CONTROL_HEIGHT;
469 int keyRowBottom = keyRowTop + CONTROL_HEIGHT;
471 int lineTop = clientRect.Height() - TOOLBAR_HEIGHT * 3 + (CONTROL_HEIGHT / 2);
473 int buttonRowTop = clientRect.Height() - TOOLBAR_HEIGHT - CONTROL_HEIGHT;
474 int buttonRowBottom = buttonRowTop + CONTROL_HEIGHT;
476 if ( keyLabel.GetSafeHwnd() ) {
477 keyLabel.GetClientRect( rect );
478 int width = rect.Width();
479 rect.left = BORDER_SIZE;
480 rect.right = BORDER_SIZE + width;
481 rect.top = keyRowTop + 8;
482 rect.bottom = keyRowBottom;
483 keyLabel.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
486 if ( keyEdit.GetSafeHwnd() ) {
487 keyEdit.GetClientRect( rect );
489 rect.right = 40 + 200;
490 rect.top = keyRowTop;
491 rect.bottom = keyRowBottom;
492 keyEdit.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
496 if ( addButton.GetSafeHwnd() ) {
497 addButton.GetClientRect( rect );
498 int width = rect.Width();
499 rect.left = clientRect.Width() - BORDER_SIZE - BUTTON_SPACE - 2 * width;
500 rect.right = clientRect.Width() - BORDER_SIZE - BUTTON_SPACE - width;
501 rect.top = keyRowTop;
502 rect.bottom = keyRowBottom;
503 addButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
506 if ( delButton.GetSafeHwnd() ) {
507 delButton.GetClientRect( rect );
508 int width = rect.Width();
509 rect.left = clientRect.Width() - BORDER_SIZE - width;
510 rect.right = clientRect.Width() - BORDER_SIZE;
511 rect.top = keyRowTop;
512 rect.bottom = keyRowBottom;
513 delButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
516 if ( line.GetSafeHwnd() ) {
517 line.GetClientRect( rect );
518 int height = rect.Height();
519 rect.left = BORDER_SIZE;
520 rect.right = clientRect.Width() - BORDER_SIZE;
522 rect.bottom = lineTop + 3;
523 line.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
526 if ( testButton.GetSafeHwnd() ) {
527 testButton.GetClientRect( rect );
528 int width = rect.Width();
529 rect.left = BORDER_SIZE;
530 rect.right = BORDER_SIZE + width;
531 rect.top = buttonRowTop;
532 rect.bottom = buttonRowBottom;
533 testButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
536 if ( okButton.GetSafeHwnd() ) {
537 okButton.GetClientRect( rect );
538 int width = rect.Width();
539 rect.left = clientRect.Width() - BORDER_SIZE - BUTTON_SPACE - 2 * width;
540 rect.right = clientRect.Width() - BORDER_SIZE - BUTTON_SPACE - width;
541 rect.top = buttonRowTop;
542 rect.bottom = buttonRowBottom;
543 okButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
546 if ( cancelButton.GetSafeHwnd() ) {
547 cancelButton.GetClientRect( rect );
548 int width = rect.Width();
549 rect.left = clientRect.Width() - BORDER_SIZE - width;
550 rect.right = clientRect.Width() - BORDER_SIZE;
551 rect.top = buttonRowTop;
552 rect.bottom = buttonRowBottom;
553 cancelButton.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
556 if ( statusBar.GetSafeHwnd() ) {
557 rect.left = clientRect.Width() - 2;
558 rect.top = clientRect.Height() - 2;
559 rect.right = clientRect.Width() - 2;
560 rect.bottom = clientRect.Height() - 2;
561 statusBar.MoveWindow( rect.left, rect.top, rect.Width(), rect.Height() );
564 UnlockWindowUpdate();
569 DialogEntityDefEditor::OnSizing
572 void DialogEntityDefEditor::OnSizing( UINT nSide, LPRECT lpRect ) {
584 CDialog::OnSizing( nSide, lpRect );
586 if ( ( nSide - 1 ) % 3 == 0 ) {
587 if ( lpRect->right - lpRect->left < initialRect.Width() ) {
588 lpRect->left = lpRect->right - initialRect.Width();
590 } else if ( ( nSide - 2 ) % 3 == 0 ) {
591 if ( lpRect->right - lpRect->left < initialRect.Width() ) {
592 lpRect->right = lpRect->left + initialRect.Width();
595 if ( nSide >= 3 && nSide <= 5 ) {
596 if ( lpRect->bottom - lpRect->top < initialRect.Height() ) {
597 lpRect->top = lpRect->bottom - initialRect.Height();
599 } else if ( nSide >= 6 && nSide <= 9 ) {
600 if ( lpRect->bottom - lpRect->top < initialRect.Height() ) {
601 lpRect->bottom = lpRect->top + initialRect.Height();
608 DialogEntityDefEditor::OnEditChange
611 void DialogEntityDefEditor::OnEditChange( ) {
612 testButton.EnableWindow( TRUE );
613 okButton.EnableWindow( TRUE );
618 DialogEntityDefEditor::OnInheritChange
621 void DialogEntityDefEditor::OnInheritChange( ) {
622 testButton.EnableWindow( TRUE );
623 okButton.EnableWindow( TRUE );
627 int sel = inheritCombo.GetCurSel();
628 if ( sel == CB_ERR ) {
630 inheritCombo.GetWindowText( temp );
634 inheritCombo.GetLBText( sel, temp );
643 DialogEntityDefEditor::OnEnInputEdit
646 void DialogEntityDefEditor::OnEnInputEdit( NMHDR *pNMHDR, LRESULT *pResult ) {
647 MSGFILTER *msgFilter = (MSGFILTER *)pNMHDR;
649 if ( msgFilter->msg != 512 && msgFilter->msg != 33 ) {
658 DialogEntityDefEditor::BuildDeclText
662 void DialogEntityDefEditor::BuildDeclText( idStr &declText )
665 declNameEdit.GetWindowText(declName);
667 inheritCombo.GetWindowText(inherit);
669 spawnclassCombo.GetWindowText(spawnclass);
671 declText = "entityDef " + declName + "\r{\r";
672 declText += "\"inherit\"\t\t\t\"" + inherit + "\"\r";
673 declText += "\"spawnclass\"\t\t\t\"" + spawnclass + "\"\r";
674 for (int i=0; i<keyValsList.GetCount(); i++) {
675 CPropertyItem* pItem = (CPropertyItem*)keyValsList.GetItemDataPtr(i);
677 // Items with a * in front are inherited and shouldn't be written out
678 if (pItem->m_propName[0] == '*') {
681 declText += "\"" + pItem->m_propName + "\"\t\t\t\"" + pItem->m_curValue + "\"\r";
686 declText.Replace( "\r", "\r\n" );
687 declText.Insert( "\r\n\r\n", 0 );
688 declText.StripTrailing( "\r\n" );
693 DialogEntityDefEditor::OnBnClickedTest
696 void DialogEntityDefEditor::OnBnClickedTest() {
697 idStr declText, oldDeclText;
701 BuildDeclText(declText);
703 if ( !TestDecl( declText ) ) {
707 char *oldDeclText = (char *)_alloca( ( decl->GetTextLength() + 1 ) * sizeof( char ) );
708 decl->GetText( oldDeclText );
709 decl->SetText( declText );
711 declManager->DeclByIndex( decl->GetType(), decl->Index(), true );
712 decl->SetText( oldDeclText );
714 common->Printf( "tested %s\n", decl->GetName() );
716 testButton.EnableWindow( FALSE );
722 DialogEntityDefEditor::OnBnClickedOk
725 void DialogEntityDefEditor::OnBnClickedOk() {
729 BuildDeclText(declText);
731 if ( !TestDecl( declText ) ) {
735 if ( decl->SourceFileChanged() ) {
736 if ( MessageBox( va( "Declaration file %s has been modified outside of the editor.\r\nReload declarations and save?", decl->GetFileName() ),
737 va( "Warning saving: %s", decl->GetFileName() ), MB_OKCANCEL | MB_ICONERROR ) != IDOK ) {
740 declManager->Reload( false );
741 DeclBrowserReloadDeclarations();
744 decl->SetText( declText );
745 if ( !decl->ReplaceSourceFileText() ) {
746 MessageBox( va( "Couldn't save: %s.\r\nMake sure the declaration file is not read-only.", decl->GetFileName() ),
747 va( "Error saving: %s", decl->GetFileName() ), MB_OK | MB_ICONERROR );
753 okButton.EnableWindow( FALSE );
758 DialogEntityDefEditor::OnBnClickedCancel
761 void DialogEntityDefEditor::OnBnClickedCancel() {
762 if ( okButton.IsWindowEnabled() ) {
763 if ( MessageBox( "Cancel changes?", "Cancel", MB_YESNO | MB_ICONQUESTION ) != IDYES ) {
772 DialogEntityDefEditor::OnKeyValChange
775 void DialogEntityDefEditor::OnKeyValChange() {
776 int sel = keyValsList.GetCurSel();
778 CPropertyItem *pItem = (CPropertyItem *)keyValsList.GetItemDataPtr(sel);
779 keyEdit.SetWindowText(pItem->m_propName);
785 DialogEntityDefEditor::OnBnClickedAdd
788 void DialogEntityDefEditor::OnBnClickedAdd() {
790 keyEdit.GetWindowText(newKey);
792 int matchedInherit = -1;
795 // See if this key already exists
796 for (int i=0; i<keyValsList.GetCount(); i++) {
797 CPropertyItem* pItem = (CPropertyItem*)keyValsList.GetItemDataPtr(i);
799 // Items with a * in front are inherited and shouldn't be written out
800 if (pItem->m_propName[0] == '*') {
801 if (newKey = pItem->m_propName.Mid(1)) {
805 else if (pItem->m_propName == newKey) {
812 if (matchedKey >= 0) {
813 MessageBox("Key " + newKey + " already defined");
817 if (matchedInherit >= 0) {
818 delete keyValsList.GetItemDataPtr(matchedInherit);
819 keyValsList.DeleteString(matchedInherit);
821 keyValsList.AddPropItem(new CPropertyItem(newKey, "", PIT_EDIT, ""));
826 DialogEntityDefEditor::OnBnClickedDelete
829 void DialogEntityDefEditor::OnBnClickedDelete() {
831 keyEdit.GetWindowText(delKey);
833 int matchedInherit = -1;
836 // See if this key already exists
837 for (int i=0; i<keyValsList.GetCount(); i++) {
838 CPropertyItem* pItem = (CPropertyItem*)keyValsList.GetItemDataPtr(i);
840 // Items with a * in front are inherited and shouldn't be written out
841 if (pItem->m_propName[0] == '*') {
842 if (delKey = pItem->m_propName.Mid(1)) {
846 else if (pItem->m_propName == delKey) {
853 if (matchedKey >= 0) {
854 delete keyValsList.GetItemDataPtr(matchedKey);
855 keyValsList.DeleteString(matchedKey);
857 else if (matchedInherit) {
858 MessageBox("Cannot delete an inherited value");