/* ================ DialogDeclEditor::OnBnClickedTest ================ */ void DialogDeclEditor::OnBnClickedTest() { 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; } char *oldDeclText = (char *)_alloca((decl->GetTextLength() + 1) * sizeof(char)); decl->GetText(oldDeclText); decl->SetText(declText); decl->Invalidate(); declManager->DeclByIndex(decl->GetType(), decl->Index(), true); decl->SetText(oldDeclText); decl->Invalidate(); common->Printf("tested %s\n", decl->GetName()); testButton.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 ); }
/* ================ 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::OnBnClickedTest ================ */ void DialogEntityDefEditor::OnBnClickedTest() { idStr declText, oldDeclText; if( decl ) { BuildDeclText( declText ); if( !TestDecl( declText ) ) { return; } char *oldDeclText = ( char * )_alloca( ( decl->GetTextLength() + 1 ) * sizeof( char ) ); decl->GetText( oldDeclText ); decl->SetText( declText ); decl->Invalidate(); declManager->DeclByIndex( decl->GetType(), decl->Index(), true ); decl->SetText( oldDeclText ); decl->Invalidate(); common->Printf( "tested %s\n", decl->GetName() ); testButton.EnableWindow( FALSE ); } }