//----------------------------------------------------------------------------- // Purpose: Invokes the texture replace dialog. //----------------------------------------------------------------------------- void CFaceEditMaterialPage::OnReplace( void ) { // Set the material tool current. SetMaterialPageTool( MATERIALPAGETOOL_MATERIAL ); // // get active map doc // CMapDoc *pDoc = CMapDoc::GetActiveMapDoc(); if( !pDoc ) return; // ready the replace dialog CReplaceTexDlg dlg( pDoc->GetSelection()->GetCount() ); // get the texture to replace -- the default texture?! dlg.m_strFind = GetDefaultTextureName(); // // open replace dialog -- modal // if( dlg.DoModal() != IDOK ) return; // mark undo position GetHistory()->MarkUndoPosition( pDoc->GetSelection()->GetList(), "Replace Textures" ); if( dlg.m_bMarkOnly ) { pDoc->SelectObject( NULL, scClear ); // clear selection first } dlg.DoReplaceTextures(); }
//----------------------------------------------------------------------------- // Purpose: Replaces any missing textures with the default texture. // Input : pError - //----------------------------------------------------------------------------- static void FixInvalidTexture(MapError *pError) { CMapSolid *pSolid = (CMapSolid *)pError->pObjects[0]; int nFaces = pSolid->GetFaceCount(); for (int i = 0; i < nFaces; i++) { CMapFace *pFace = pSolid->GetFace(i); if (pFace != NULL) { IEditorTexture *pTex = pFace->GetTexture(); if (pTex != NULL) { if (pTex->IsDummy()) { pFace->SetTexture(GetDefaultTextureName()); } } } } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOnlyFace - //----------------------------------------------------------------------------- void CFaceEditMaterialPage::UpdateDialogData( CMapFace *pOnlyFace ) { BOOL bFirst; int nFaceAlignCount; int nWorldAlignCount; float fshiftX = NOT_INIT; float fshiftY = NOT_INIT; float fscaleX = NOT_INIT; float fscaleY = NOT_INIT; float frotate = NOT_INIT; //float fsmooth = NOT_INIT; int material = NOT_INIT; int nLightmapScale = NOT_INIT; CString strTexture; bFirst = TRUE; nFaceAlignCount = 0; nWorldAlignCount = 0; CFaceEditSheet *pSheet = ( CFaceEditSheet* )GetParent(); int faceCount = pSheet->GetFaceListCount(); for( int i = 0; i < faceCount || pOnlyFace; i++ ) { CMapFace *pFace; if( pOnlyFace ) { pFace = pOnlyFace; } else { pFace = pSheet->GetFaceListDataFace( i ); } TEXTURE &t = pFace->texture; // // Gather statistics about the texture alignment of all the selected faces. // This is used later to set the state of the alignment checkboxes. // int nAlignment = pFace->GetTextureAlignment(); if (nAlignment & TEXTURE_ALIGN_FACE) { nFaceAlignCount++; } if (nAlignment & TEXTURE_ALIGN_WORLD) { nWorldAlignCount++; } // // First update - copy first face's stuff into edit fields. // if (bFirst) { fshiftX = t.UAxis[3]; fshiftY = t.VAxis[3]; fscaleX = t.scale[0]; fscaleY = t.scale[1]; frotate = t.rotate; material = t.material; strTexture = t.texture; nLightmapScale = t.nLightmapScale; // // Get the face's orientation. This is used by Apply to make intelligent decisions. // m_eOrientation = pFace->GetOrientation(); Assert(m_eOrientation != FACE_ORIENTATION_INVALID); // // Set the appropriate checkbox state for the face attributes. // m_FaceContents = t.q2contents; m_FaceSurface = t.q2surface; for (int nItem = 0; nItem < sizeof(FaceAttributes) / sizeof(FaceAttributes[0]); nItem++) { int nSet = ((*FaceAttributes[nItem].puAttribute & FaceAttributes[nItem].uFlag) != 0); CButton *pButton = (CButton *)GetDlgItem(FaceAttributes[nItem].uControlID); if (pButton != NULL) { pButton->SetCheck(nSet); } } bFirst = FALSE; if (pOnlyFace) // use one face - now break { break; } } else { // update fields with face's data if (t.UAxis[3] != fshiftX) { fshiftX = NOT_INIT; } if (t.VAxis[3] != fshiftY) { fshiftY = NOT_INIT; } if (t.scale[0] != fscaleX) { fscaleX = NOT_INIT; } if (t.scale[1] != fscaleY) { fscaleY = NOT_INIT; } if (t.rotate != frotate) { frotate = NOT_INIT; } if (t.material != material) { material = NOT_INIT; } if (t.nLightmapScale != nLightmapScale) { nLightmapScale = NOT_INIT; } if (!strTexture.IsEmpty() && strTexture != t.texture) { strTexture = ""; } // // Update the checkbox state for the face attributes. If any of this face's // attributes are different from the current checkbox state, set the checkbox // to the undefined state. // m_FaceContents = t.q2contents; m_FaceSurface = t.q2surface; for (int nItem = 0; nItem < sizeof(FaceAttributes) / sizeof(FaceAttributes[0]); nItem++) { int nSet = ((*FaceAttributes[nItem].puAttribute & FaceAttributes[nItem].uFlag) != 0); CButton *pButton = (CButton *)GetDlgItem(FaceAttributes[nItem].uControlID); if (pButton != NULL) { if (pButton->GetCheck() != nSet) { pButton->SetButtonStyle(BS_AUTO3STATE); pButton->SetCheck(2); } } } } } // // Set the state of the face alignment checkbox. // CButton *pFaceAlign = (CButton *)GetDlgItem(IDC_ALIGN_FACE); if (nFaceAlignCount == 0) { pFaceAlign->SetCheck(0); } else if (nFaceAlignCount == faceCount) { pFaceAlign->SetCheck(1); } else { pFaceAlign->SetCheck(2); } // // Set the state of the world alignment checkbox. // CButton *pWorldAlign = (CButton *)GetDlgItem(IDC_ALIGN_WORLD); if (nWorldAlignCount == 0) { pWorldAlign->SetCheck(0); } else if (nWorldAlignCount == faceCount) { pWorldAlign->SetCheck(1); } else { pWorldAlign->SetCheck(2); } // // Set up fields. // FloatToSpin(fshiftX, (CSpinButtonCtrl*)GetDlgItem(IDC_SPINSHIFTX), FALSE); FloatToSpin(fshiftY, (CSpinButtonCtrl*)GetDlgItem(IDC_SPINSHIFTY), FALSE); IntegerToSpin(nLightmapScale, (CSpinButtonCtrl *)GetDlgItem(IDC_SPIN_LIGHTMAP_SCALE)); FloatToWnd(fscaleX, &m_scaleX); FloatToWnd(fscaleY, &m_scaleY); FloatToSpin(frotate, (CSpinButtonCtrl*)GetDlgItem(IDC_SPINROTATE), TRUE); if (!strTexture.IsEmpty()) { SelectTexture( strTexture ); } else { // make empty m_TextureList.SetCurSel( -1 ); } // // if no faces selected -- get selection from texture bar // if( faceCount == 0 ) { CString strTexName = GetDefaultTextureName(); SelectTexture( strTexName ); } // // Call ctexturebar implementation because OUR implementation sets the // q2 checkboxes, which flashes the screen a bit (cuz we change them // again three lines down.) // UpdateTexture(); // Update the smoothing group data. if ( GetMaterialPageTool() == MATERIALPAGETOOL_SMOOTHING_GROUP ) { m_FaceSmoothDlg.UpdateControls(); } }