/* ================ DialogDeclEditor::OnBnClickedOk ================ */ void DialogDeclEditor::OnBnClickedOk() { idStr declText; if( decl ) { declEdit.GetText( declText ); // clean up new-line crapola declText.Replace( "\n", "" ); declText.Replace( "\r", "\r\n" ); declText.Replace( "\v", "\r\n" ); declText.StripLeading( "\r\n" ); declText.Insert( "\r\n\r\n", 0 ); declText.StripTrailing( "\r\n" ); if( !TestDecl( declText ) ) { return; } if( decl->SourceFileChanged() ) { if( MessageBox( va( "Declaration file %s has been modified outside of the editor.\r\nReload declarations and save?", decl->GetFileName() ), va( "Warning saving: %s", decl->GetFileName() ), MB_OKCANCEL | MB_ICONERROR ) != IDOK ) { return; } declManager->Reload( false ); DeclBrowserReloadDeclarations(); } decl->SetText( declText ); if( !decl->ReplaceSourceFileText() ) { MessageBox( va( "Couldn't save: %s.\r\nMake sure the declaration file is not read-only.", decl->GetFileName() ), va( "Error saving: %s", decl->GetFileName() ), MB_OK | MB_ICONERROR ); return; } decl->Invalidate(); } okButton.EnableWindow( FALSE ); }
/* ================ DialogEntityDefEditor::OnBnClickedOk ================ */ void DialogEntityDefEditor::OnBnClickedOk() { if ( decl ) { idStr declText; BuildDeclText(declText); if ( !TestDecl( declText ) ) { return; } if ( decl->SourceFileChanged() ) { if ( MessageBox( va( "Declaration file %s has been modified outside of the editor.\r\nReload declarations and save?", decl->GetFileName() ), va( "Warning saving: %s", decl->GetFileName() ), MB_OKCANCEL | MB_ICONERROR ) != IDOK ) { return; } declManager->Reload( false ); DeclBrowserReloadDeclarations(); } decl->SetText( declText ); if ( !decl->ReplaceSourceFileText() ) { MessageBox( va( "Couldn't save: %s.\r\nMake sure the declaration file is not read-only.", decl->GetFileName() ), va( "Error saving: %s", decl->GetFileName() ), MB_OK | MB_ICONERROR ); return; } decl->Invalidate(); } okButton.EnableWindow( FALSE ); }