void CDlgBrowseByClass::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); CWorldEditorDoc *pDoc = theApp.GetDocument(); // if dialog is recieving data if( (pDX->m_bSaveAndValidate == FALSE) && (::IsWindow(m_listEntities.m_hWnd)) ) { INDEX ctEntities = m_listEntities.GetItemCount(); INDEX ctSelectedEntities = m_listEntities.GetSelectedCount(); char achrEntitiesCount[ 64]; sprintf( achrEntitiesCount, "Selected entities: %d Total entities: %d", ctSelectedEntities, ctEntities); m_strEntitiesInVolume = achrEntitiesCount; INDEX iSelectedItem = m_listEntities.GetNextItem( -1, LVNI_ALL|LVNI_SELECTED); if( iSelectedItem != -1) m_listEntities.EnsureVisible( iSelectedItem, FALSE); } //{{AFX_DATA_MAP(CDlgBrowseByClass) DDX_Control(pDX, IDC_PLUGGINS, m_ctrlPluggins); DDX_Control(pDX, IDC_ENTITY_LIST, m_listEntities); DDX_Text(pDX, IDC_ENTITIES_IN_VOLUME_T, m_strEntitiesInVolume); DDX_Check(pDX, IDC_DISPLAY_VOLUME, m_bShowVolume); DDX_Check(pDX, IDC_DISPLAY_IMPORTANTS, m_bShowImportants); //}}AFX_DATA_MAP // if dialog is giving data if( pDX->m_bSaveAndValidate != FALSE) { // clear document selection pDoc->m_selEntitySelection.Clear(); // mark all selected entities in list as selected in document's entity selection INDEX iSelectedItem = -1; FOREVER { iSelectedItem = m_listEntities.GetNextItem( iSelectedItem, LVNI_ALL|LVNI_SELECTED); if( iSelectedItem == -1) { break; } // get selected entity CEntity *penEntity = (CEntity *) m_listEntities.GetItemData(iSelectedItem); // add entity into normal selection pDoc->m_selEntitySelection.Select( *penEntity); } if( pDoc->m_bBrowseEntitiesMode) { // clear volume container pDoc->m_cenEntitiesSelectedByVolume.Clear(); // go out of browse by volume mode pDoc->OnBrowseEntitiesMode(); } // mark that selections have been changed pDoc->m_chSelections.MarkChanged(); }
void CChildFrame::OnEnableVisibilityTweaks() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bDisableVisibilityTweaks = !m_bDisableVisibilityTweaks; pDoc->UpdateAllViews( NULL); }
void CChildFrame::OnViewSelection() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bSelectionVisible = !m_bSelectionVisible; pDoc->UpdateAllViews( NULL); }
void CTriangularisationCombo::OnSelchange() { // get document ptr CWorldEditorDoc* pDoc = theApp.GetActiveDocument(); if( pDoc == NULL) return; int iSelected = GetCurSel(); theApp.m_vfpCurrent.vfp_ttTriangularisationType = (enum TriangularisationType) iSelected; pDoc->CreatePrimitive(); pDoc->UpdateAllViews(NULL); }
void CChildFrame::OnRestorePosition03() { m_mvViewer.mv_plViewer = wo_plStored03; m_mvViewer.mv_fTargetDistance = wo_fStored03; CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); pDoc->UpdateAllViews( NULL); }
void CChildFrame::OnToggleVisibilityTweaks() { // get document CWorldEditorView *pWEDView = (CWorldEditorView *) m_wndSplitter.GetPane( 0, 0); ASSERT( pWEDView != NULL); CWorldEditorDoc* pDoc = pWEDView->GetDocument(); ASSERT_VALID(pDoc); m_bShowVisibilityTweaks = !m_bShowVisibilityTweaks; // auto turn off disabling of visibility tweaks m_bDisableVisibilityTweaks = FALSE; pDoc->UpdateAllViews( NULL); }
void CChildFrame::OnUpdateKeyY(CCmdUI* pCmdUI) { CWorldEditorDoc* pDoc = theApp.GetActiveDocument(); if( pDoc->GetEditingMode() == TERRAIN_MODE) { pCmdUI->SetCheck(TRUE); } else { OnUpdateViewFromEntity(pCmdUI); } }
void CChildFrame::OnKeyY() { CWorldEditorDoc* pDoc = theApp.GetActiveDocument(); if( pDoc->GetEditingMode() == TERRAIN_MODE) { theApp.m_iTerrainBrushMode=TBM_CONTINOUS_NOISE; theApp.m_ctTerrainPageCanvas.MarkChanged(); pDoc->SetStatusLineModeInfoMessage(); return; } else { OnViewFromEntity(); } }
BOOL CTriangularisationCombo::OnIdle(LONG lCount) { // get document ptr CWorldEditorDoc* pDoc = theApp.GetActiveDocument(); if( (pDoc == NULL) || (pDoc->GetEditingMode() != CSG_MODE) || (!pDoc->m_bPrimitiveMode) ) { // we should disable triangularisation combo if(GetCount() == 1) return TRUE; // we allready have "not available" in combo // remove all combo entries ResetContent(); // set none available message AddString( L"None Available"); SetCurSel( 0); } // we should enable triangularisation combo else { // if it is allready enabled if(GetCount() != 1) return TRUE; ResetContent(); // add all possible triangularisation types AddString( L"None"); AddString( L"Center"); AddString( L"Vertex 1"); AddString( L"Vertex 2"); AddString( L"Vertex 3"); AddString( L"Vertex 4"); AddString( L"Vertex 5"); AddString( L"Vertex 6"); AddString( L"Vertex 7"); AddString( L"Vertex 8"); AddString( L"Vertex 9"); AddString( L"Vertex 10"); AddString( L"Vertex 11"); AddString( L"Vertex 12"); AddString( L"Vertex 13"); AddString( L"Vertex 14"); AddString( L"Vertex 15"); AddString( L"Vertex 16"); // select currently selected triangularisation type SetCurSel( (int)theApp.m_vfpCurrent.vfp_ttTriangularisationType); } return TRUE; }
// --------------------------------------------------------------------------- void CBuilderZone::calcMask() { sint32 i; sint32 x, y; _MinY = _MinX = 1000000; _MaxY = _MaxX = -1000000; if (_ZoneRegions.size() == 0) return; CWorldEditorDoc *doc = getDocument (); for (i = 0; i < (sint32)_ZoneRegions.size(); ++i) { const CZoneRegion *pBZR = &(doc->getZoneRegion (i)); if (_MinX > pBZR->getMinX()) _MinX = pBZR->getMinX(); if (_MinY > pBZR->getMinY()) _MinY = pBZR->getMinY(); if (_MaxX < pBZR->getMaxX()) _MaxX = pBZR->getMaxX(); if (_MaxY < pBZR->getMaxY()) _MaxY = pBZR->getMaxY(); } _ZoneMask.resize ((1+_MaxX-_MinX)*(1+_MaxY-_MinY)); sint32 stride = (1+_MaxX-_MinX); for (y = _MinY; y <= _MaxY; ++y) for (x = _MinX; x <= _MaxX; ++x) { _ZoneMask[x-_MinX+(y-_MinY)*stride] = true; for (i = 0; i < (sint32)_ZoneRegions.size(); ++i) if (i != _ZoneRegionSelected) { const CZoneRegion *pBZR = &(doc->getZoneRegion (i)); const string &rSZone = pBZR->getName (x, y); if ((rSZone != STRING_OUT_OF_BOUND) && (rSZone != STRING_UNUSED)) { _ZoneMask[x-_MinX+(y-_MinY)*stride] = false; } } } }
void OnModifyPrimitive (CPrimitives &primitives) { // Look for the good database element using the primitives pointer CWorldEditorDoc *doc = getDocument (); uint i; const uint count = doc->getNumDatabaseElement (); for (i=0; i<count; i++) { if (&doc->getDatabaseElements (i) == &primitives) break; } // If found, modify it if (i < count) { doc->modifyDatabase (i); } }
void InvalidateAllPrimitives () { // Erase all caches /* Selection.clear (); PrimitiveQuadGrid.clear (); ModifiedPrimitive.clear ();*/ // Invalidate quad grid CWorldEditorDoc *doc = getDocument (); if (doc) { uint i; uint count = doc->getNumDatabaseElement (); for (i=0; i<count; i++) { // Is a primtive ? CDatabaseLocatorPointer locator; locator.getRoot (i); InvalidatePrimitiveRec (locator, QuadTree|LogicTreeStruct|SelectionState); } } }
void UpdateSelection () { // Get the tools window CToolsLogic *toolWnd = dynamic_cast<CToolsLogic*>(getMainFrame ()->m_wndSplitter.GetPane(0,1)); // Selection is changed ? bool selectionChanged = false; // For each modified primitive CWorldEditorDoc *doc = getDocument (); std::list<NLLIGO::IPrimitive*>::iterator ite = ModifiedPrimitive.begin (); while (ite != ModifiedPrimitive.end ()) { CDatabaseLocatorPointer locator; doc->getLocator (locator, *ite); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (*ite); // Selection ? if (primitiveEditor->_Channels & _SelectionSelectState) { // Update the selection UpdatePrimitiveSelection (primitiveEditor, locator, selectionChanged); // Validate primitiveEditor->_Channels &= ~_SelectionSelectState; } // Next primitive to update ite++; } /*// Change dialog selection ? if (selectionChanged) { PropertyDialog.changeSelection (Selection); }*/ }
void VerifyPrimitivesStructures() { getMainFrame()->launchLoadingDialog("checking primitives structures"); // Invalidate quad grid CWorldEditorDoc *doc = getDocument (); if (doc) { // Begin modifications doc->beginModification (); string path; string errors; uint i; uint count = doc->getNumDatabaseElement (); IPrimitiveEditor::StructureError error = IPrimitiveEditor::NoError; for (i=0; i<count; i++) { getMainFrame()->progressLoadingDialog(float(i+0.0001f)/count); if (doc->isEditable (i)) { // Is a primtive ? CDatabaseLocatorPointer locator; locator.getRoot (i); error = (IPrimitiveEditor::StructureError)((sint)VerifyPrimitiveRec (locator, path, errors) | (sint)error); //VerifyPrimitiveRec (locator); // auto generate missing ID doc->resetUniqueID(*(doc->getDatabaseElements(i).RootNode), true); } } // End modifications doc->endModification (); if (error != IPrimitiveEditor::NoError) { errors = "Found errors in the tree structure:\n"+errors; int first = errors.find_first_not_of ("\n"); int end = errors.find_first_of ("\n"); while (first != string::npos) { nlwarning (errors.substr(first, end-first).c_str()); first = end; end = errors.find_first_of ("\n", end+1); } theApp.errorMessage (errors.c_str()); } } getMainFrame()->terminateLoadingDialog(); }
void CChildFrame::TestGame( BOOL bFullScreen) { // turn off info window CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); pMainFrame->HideInfoWindow(); CWorldEditorView *pPerspectiveView = GetPerspectiveView(); ASSERT( pPerspectiveView != NULL); SetActiveView( pPerspectiveView, FALSE); CWorldEditorDoc* pDoc = pPerspectiveView->GetDocument(); CTFileName fnmWorldToPlay; CTFileName fnmTempWorld = CTString("Temp\\TestGame.wld"); // if the world was never saved or if it is modified if( (!pDoc->m_bWasEverSaved && wed_bSaveTestGameFirstTime) || pDoc->IsModified()) { // save world under temporary name ASSERT_VALID(pDoc); try { pDoc->m_woWorld.Save_t(fnmTempWorld); fnmWorldToPlay = fnmTempWorld; } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } // if the world is not modified (it is saved on disk) } else { // use the saved world fnmWorldToPlay = CTString(CStringA(pDoc->GetPathName())); try { fnmWorldToPlay.RemoveApplicationPath_t(); } catch( char *strError) { AfxMessageBox( CString(strError)); pPerspectiveView->EnableToolTips(TRUE); return; } } // set rendering preferences _wrpWorldRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_wrpWorldRenderPrefs; _mrpModelRenderPrefs = pPerspectiveView->m_vpViewPrefs.m_mrpModelRenderPrefs; _wrpWorldRenderPrefs.SetShadowsType( pPerspectiveView->GetChildFrame()->m_stShadowType); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture1, 0); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture2, 1); _wrpWorldRenderPrefs.SetTextureLayerOn( theApp.m_bTexture3, 2); _wrpWorldRenderPrefs.DisableVisTweaks(FALSE); _wrpWorldRenderPrefs.SetSelectedEntityModel( theApp.m_pEntityMarkerModelObject); _wrpWorldRenderPrefs.SetSelectedPortalModel( theApp.m_pPortalMarkerModelObject); _wrpWorldRenderPrefs.SetEmptyBrushModel( theApp.m_pEmptyBrushModelObject); // prepare test game view/draw ports CViewPort *pvp = pPerspectiveView->m_pvpViewPort; CDrawPort *pdp = pPerspectiveView->m_pdpDrawPort; pdp->SetOverlappedRendering(FALSE); // we are not rendering scene over already rendered scene (used for CSG layer) // if full screen mode is required HWND hWndFullScreen=NULL; HINSTANCE hInstanceFullScreen; WNDCLASSEX wcFullScreen; char achWindowTitle[256]; // current window title if( bFullScreen) { // get full screen display mode info const PIX pixSizeI = theApp.m_dmFullScreen.dm_pixSizeI; const PIX pixSizeJ = theApp.m_dmFullScreen.dm_pixSizeJ; const DisplayDepth dd = theApp.m_dmFullScreen.dm_ddDepth; const GfxAPIType gat = theApp.m_gatFullScreen; // set OpenGL fullscreen (before window) if( gat==GAT_OGL) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); return; } } // register the window class hInstanceFullScreen = AfxGetInstanceHandle(); ASSERT( hInstanceFullScreen!=NULL); wcFullScreen.cbSize = sizeof(wcFullScreen); wcFullScreen.style = CS_HREDRAW | CS_VREDRAW; wcFullScreen.lpfnWndProc = ::DefWindowProc; wcFullScreen.cbClsExtra = 0; wcFullScreen.cbWndExtra = 0; wcFullScreen.hInstance = hInstanceFullScreen; wcFullScreen.hIcon = LoadIcon( hInstanceFullScreen, (LPCTSTR)IDR_MAINFRAME ); wcFullScreen.hCursor = NULL; wcFullScreen.hbrBackground = NULL; wcFullScreen.lpszMenuName = CString(APPLICATION_NAME); wcFullScreen.lpszClassName = CString(APPLICATION_NAME); wcFullScreen.hIconSm = NULL; RegisterClassEx(&wcFullScreen); // create a window, invisible initially hWndFullScreen = CreateWindowExA( WS_EX_TOPMOST, APPLICATION_NAME, "Serious Editor - Full Screen Test Game", // title WS_POPUP, 0,0, pixSizeI, pixSizeJ, // window size NULL, NULL, hInstanceFullScreen, NULL); // didn't make it? ASSERT( hWndFullScreen!=NULL); if( hWndFullScreen==NULL) { if( gat==GAT_OGL) _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup window for full screen display."); return; } // set windows for engine CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); SE_UpdateWindowHandle( hWndFullScreen); // set window title and show it sprintf( achWindowTitle, "Serious Editor - Test Game (FullScreen %dx%d)", pixSizeI, pixSizeJ); ::SetWindowTextA( hWndFullScreen, achWindowTitle); ::ShowWindow( hWndFullScreen, SW_SHOWNORMAL); // set Direct3D full screen (after window) #ifdef SE1_D3D if( gat==GAT_D3D) { const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd); if( !bRes) { WarningMessage( "Unable to setup full screen display."); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); return; } } #endif // SE1_D3D // create canvas _pGfx->CreateWindowCanvas( hWndFullScreen, &pvp, &pdp); // initial screen fill and swap, just to get context running BOOL bSuccess = FALSE; if( pdp!=NULL && pdp->Lock()) { pdp->Fill(C_dGREEN|CT_OPAQUE); pdp->Unlock(); pvp->SwapBuffers(); bSuccess = TRUE; } // must succeed! ASSERT( bSuccess); if( !bSuccess) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); WarningMessage( "Unable to setup canvas for full screen display."); return; } } // enable sound snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16); _pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat, TRUE); // run quick test game extern BOOL _bInOnDraw; _bInOnDraw = TRUE; _pGameGUI->QuickTest( fnmWorldToPlay, pdp, pvp); _bInOnDraw = FALSE; // disable sound _pSound->SetFormat( CSoundLibrary::SF_NONE); // restore default display mode and close test full screen window if( hWndFullScreen!=NULL) { _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi); ::DestroyWindow( hWndFullScreen); SE_UpdateWindowHandle( pMainFrame->m_hWnd); } // redraw all views pDoc->UpdateAllViews( NULL); pPerspectiveView->EnableToolTips( TRUE); }
void UpdatePrimitives () { // Get the tools window CMainFrame *mainWnd = getMainFrame (); if (mainWnd) { CToolsLogic *toolWnd = dynamic_cast<CToolsLogic*>(getMainFrame ()->m_wndSplitter.GetPane(0,1)); // Sort the list static vector<CDatabaseLocatorPointer> toSort; toSort.clear (); CWorldEditorDoc *doc = getDocument (); std::list<NLLIGO::IPrimitive*>::iterator ite = ModifiedPrimitive.begin (); while (ite != ModifiedPrimitive.end ()) { CDatabaseLocatorPointer locator; doc->getLocator (locator, *ite); toSort.push_back (locator); ite++; } sort (toSort.begin (), toSort.end ()); // For each modified primitive sint i; sint count = (sint)toSort.size (); for (i=count-1; i>=0; i--) { CDatabaseLocatorPointer locator; doc->getLocator (locator, toSort[i].Primitive); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(toSort[i].Primitive)); // Logic tree structure modified ? if (primitiveEditor->_Channels & LogicTreeStruct) { // Remove from the tree primitiveEditor->removeFromLogicTree (); } } // Selection is changed ? bool selectionChanged = false; // For each modified primitive for (i=0; i<count; i++) { const IPrimitive *primitive = toSort[i].Primitive; CDatabaseLocatorPointer locator; doc->getLocator (locator, primitive); IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(primitive)); // Quad grid ? if (primitiveEditor->_Channels & QuadTree) { // Remove from the container primitiveEditor->removeFromQuadGrid (); // Num points uint pointCount = (primitive)->getNumVector (); if (pointCount > 0) { // Point pointer const CPrimVector *points = (primitive)->getPrimVector (); // BBox CAABBox bbox; bbox.setCenter (points[0]); // Extend the bbox uint j; for (j=1; j<pointCount; j++) { bbox.extend (points[j]); } // Insert in the quadtree primitiveEditor->_QuadIterator = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), const_cast<IPrimitive*> (primitive)); // Get the linked primitives const IPrimitive* linkedPrimitive = theApp.Config.getLinkedPrimitive (*primitive); // Is this primitive linked with another one ? if (linkedPrimitive) { IPrimitiveEditor *primitiveEditorLinked = getPrimitiveEditor (const_cast<IPrimitive*>(linkedPrimitive)); if (linkedPrimitive->getNumVector () > 0) { bbox.setCenter (points[0]); bbox.extend (linkedPrimitive->getPrimVector ()[0]); // Insert in the quadtree primitiveEditor->_QuadIteratorLink = PrimitiveQuadGrid.insert (bbox.getMin (), bbox.getMax (), CQuadGridEntry (const_cast<IPrimitive*> (primitive), const_cast<IPrimitive*> (linkedPrimitive))); } } } // Validate primitiveEditor->_Channels &= ~QuadTree; } // Logic tree structure ? if (primitiveEditor->_Channels & LogicTreeStruct) { // Add the primitive AddPrimitivesLogicTree (locator, primitiveEditor, toolWnd); // The flag is validated by AddPrimitivesLogicTree } // Logic tree parameters ? if (primitiveEditor->_Channels & LogicTreeParam) { // Update tree item parameters if (toolWnd) toolWnd->updatePrimitive (primitiveEditor->_TreeItem, locator); // Validate primitiveEditor->_Channels &= ~LogicTreeParam; } // Selection ? if (primitiveEditor->_Channels & _SelectionSelectState) { // Update the selection UpdatePrimitiveSelection (primitiveEditor, locator, selectionChanged); // Validate primitiveEditor->_Channels &= ~_SelectionSelectState; } // Remove from the modified list nlassert (primitiveEditor->_Channels == 0); ModifiedPrimitive.erase (primitiveEditor->_ModifiedIterator); primitiveEditor->_ModifiedIterator = ModifiedPrimitive.end (); } /*// Change dialog selection ? if (selectionChanged) { if ( pDlg ) pDlg->changeSelection (Selection); } */ nlassert (ModifiedPrimitive.size ()==0); } }
IPrimitiveEditor::StructureError VerifyPrimitiveRec (const CDatabaseLocatorPointer &locator, const string &path, string &errors) { IPrimitiveEditor::StructureError error = IPrimitiveEditor::NoError; // For every child, we check the errors CDatabaseLocatorPointer myLocator = locator; const IPrimitive *primitive = locator.Primitive; string newPath = "?"; if (primitive) { if (primitive->getParent()) { primitive->getPropertyByName ("name", newPath); newPath = ":"+newPath; } else { CWorldEditorDoc *doc = getDocument (); uint databaseIndex = locator.getDatabaseIndex (); newPath = doc->getDatabaseElement (databaseIndex); } } newPath = path + newPath; // we parse the tree recursively, collection errors, and propagating to the parent if (myLocator.firstChild ()) { do { // not very elegant, but we need to set bit fields error = (IPrimitiveEditor::StructureError)((sint)VerifyPrimitiveRec (myLocator, newPath, errors) | (sint)error); } while (myLocator.nextChild ()); } // when we finished to recurse the tree, we simply check if the StaticChildren are all here // all other children MUST be either Dynamic or Generated if (primitive) { string className; bool Success; Success = primitive->getPropertyByName ("class", className); if (!Success) { // is this the root node ? const IPrimitive *parent = primitive->getParent(); if (!parent) { // if no parent, we have a root node className = "root"; Success = true; } } if (Success) { const CPrimitiveClass *primClass = theApp.Config.getPrimitiveClass (className.c_str ()); if (primClass) { uint CountStaticChildren = 0; uint MissingChildren = 0; myLocator = locator; // we parse the tree recursively, collection errors, and propagating to the parent if (myLocator.firstChild ()) { do { const IPrimitive *primitive2 = myLocator.Primitive; if (primitive2) { string ClassName2; nlverify (primitive2->getPropertyByName ("class", ClassName2)); string name; if (primitive2->getPropertyByName ("name", name)) { uint c; bool Found = false; for (c=0; c<primClass->StaticChildren.size (); c++) { if (primClass->StaticChildren[c].ClassName == ClassName2 && primClass->StaticChildren[c].Name == name) { Found = true; ++CountStaticChildren; break; } } for (c=0; c<primClass->GeneratedChildren.size (); c++) { if (primClass->GeneratedChildren[c].ClassName == ClassName2) { Found = true; break; } } for (c=0; c<primClass->DynamicChildren.size (); c++) { if (primClass->DynamicChildren[c].ClassName == ClassName2) { Found = true; break; } } if (!Found) { ++MissingChildren; // Mark the child as error IPrimitiveEditor *childPrimitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(primitive2)); childPrimitiveEditor->_Error = IPrimitiveEditor::InExcessField; InvalidatePrimitive (myLocator, LogicTreeParam); string childName; primitive2->getPropertyByName ("name", childName); errors += newPath + " : " + "The child \"" + childName + "\" (class \"" + ClassName2 + "\") is not declared in class \"" + className + "\".\n"; } } } } while (myLocator.nextChild ()); } if (MissingChildren) { error = IPrimitiveEditor::InExcessField; } if (CountStaticChildren != primClass->StaticChildren.size()) { error = IPrimitiveEditor::InExcessField; errors += newPath+" : "+"Missing static children.\n"; } } } } if (locator.Primitive) { IPrimitiveEditor *primitiveEditor = getPrimitiveEditor (const_cast<IPrimitive*>(locator.Primitive)); // set the error message primitiveEditor->_Error = error; InvalidatePrimitive (locator, LogicTreeParam); } return error; }
// --------------------------------------------------------------------------- bool CBuilderZone::refresh () { // Reset all _ZoneRegions.clear (); _ZoneRegionSelected = -1; CWorldEditorDoc *doc = getDocument (); for (uint j=0; j<doc->getNumDatabaseElement (); j++) { // Is it a landscape ? if (doc->isLandscape (j)) { _ZoneRegionSelected++; newZone (false); // Check if we can load this zone const CZoneRegion *pBZR = &(getDocument ()->getZoneRegion (_ZoneRegionSelected)); for (sint32 y = pBZR->getMinY(); y <= pBZR->getMaxY(); ++y) for (sint32 x = pBZR->getMinX(); x <= pBZR->getMaxX(); ++x) { const string &refSZone = pBZR->getName (x, y); if (refSZone != STRING_UNUSED) { sint zoneRegionSelected2 = -1; CWorldEditorDoc *doc = getDocument (); for (uint i=0; i<doc->getNumDatabaseElement (); i++) { // Is it a landscape ? if (doc->isLandscape (i)) { zoneRegionSelected2++; if (i!=j) { const CZoneRegion *pBZR2 = &(getDocument ()->getZoneRegion (zoneRegionSelected2)); const string &sZone = pBZR2->getName (x, y); if ((sZone != STRING_UNUSED)&&(sZone != STRING_OUT_OF_BOUND)) { unload (_ZoneRegionSelected); MessageBox (NULL, "Cannot add this zone because it overlaps existing ones", "Error", MB_ICONERROR|MB_OK); return false; } } } } } } string error; if (!_ZoneRegions[_ZoneRegionSelected]->init (&_ZoneBank, this, error)) { unload (_ZoneRegionSelected); MessageBox (NULL, ("Cannot add this zone :\n"+error).c_str(), "Error", MB_ICONERROR|MB_OK); return false; } _Display->_Offset.x = _Display->_CellSize*(pBZR->getMinX() + pBZR->getMaxX()) / 2.0f; _Display->_Offset.y = _Display->_CellSize*(pBZR->getMinY() + pBZR->getMaxY()) / 2.0f; calcMask (); } } return true; }
void CDlgPgPosition::DoDataExchange(CDataExchange* pDX) { if( theApp.m_bDisableDataExchange) return; CPropertyPage::DoDataExchange(pDX); SetModified( TRUE); // obtain document CWorldEditorDoc* pDoc = theApp.GetDocument(); // if document doesn't exist, return if( pDoc == NULL) return; // get active view CWorldEditorView *pWorldEditorView = theApp.GetActiveView(); // if dialog is recieving data if( pDX->m_bSaveAndValidate == FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, pick up coordinates for editting from second layer m_fHeading = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(1)); m_fPitch = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(2)); m_fBanking = DegAngle( pDoc->m_plSecondLayer.pl_OrientationAngle(3)); m_fX = pDoc->m_plSecondLayer.pl_PositionVector(1); m_fY = pDoc->m_plSecondLayer.pl_PositionVector(2); m_fZ = pDoc->m_plSecondLayer.pl_PositionVector(3); } // otherwise if we are in entity mode and there is only one entity selected else if( (pDoc->m_iMode == ENTITY_MODE) && ( pDoc->m_selEntitySelection.Count() == 1) ) { // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); m_fHeading = DegAngle( plEntityOnePlacement.pl_OrientationAngle(1)); m_fPitch = DegAngle( plEntityOnePlacement.pl_OrientationAngle(2)); m_fBanking = DegAngle( plEntityOnePlacement.pl_OrientationAngle(3)); m_fX = plEntityOnePlacement.pl_PositionVector(1); m_fY = plEntityOnePlacement.pl_PositionVector(2); m_fZ = plEntityOnePlacement.pl_PositionVector(3); } m_udSelection.MarkUpdated(); } //{{AFX_DATA_MAP(CDlgPgPosition) DDX_Text(pDX, IDC_EDIT_BANKING, m_fBanking); DDX_Text(pDX, IDC_EDIT_HEADING, m_fHeading); DDX_Text(pDX, IDC_EDIT_PITCH, m_fPitch); DDX_Text(pDX, IDC_EDIT_X, m_fX); DDX_Text(pDX, IDC_EDIT_Y, m_fY); DDX_Text(pDX, IDC_EDIT_Z, m_fZ); //}}AFX_DATA_MAP // if dialog is giving data if( pDX->m_bSaveAndValidate != FALSE) { // is CSG on? if( pDoc->m_pwoSecondLayer != NULL) { // yes, copy coordinates from editting controls into second layer pDoc->m_plSecondLayer.pl_OrientationAngle(1) = AngleDeg( m_fHeading); pDoc->m_plSecondLayer.pl_OrientationAngle(2) = AngleDeg( m_fPitch); pDoc->m_plSecondLayer.pl_OrientationAngle(3) = AngleDeg( m_fBanking); pDoc->m_plSecondLayer.pl_PositionVector(1) = m_fX; pDoc->m_plSecondLayer.pl_PositionVector(2) = m_fY; pDoc->m_plSecondLayer.pl_PositionVector(3) = m_fZ; // snap values to grid pDoc->SnapToGrid( pDoc->m_plSecondLayer, SNAP_FLOAT_12); theApp.m_vfpCurrent.vfp_plPrimitive = pDoc->m_plSecondLayer; // update all document's views pDoc->UpdateAllViews( NULL); } // otherwise if we are in entity mode else if( pDoc->m_iMode == ENTITY_MODE) { // there must be only one entity selected ASSERT( pDoc->m_selEntitySelection.Count() == 1); // lock selection's dynamic container pDoc->m_selEntitySelection.Lock(); // get first entity CEntity *penEntityOne = pDoc->m_selEntitySelection.Pointer(0); // unlock selection's dynamic container pDoc->m_selEntitySelection.Unlock(); // get placement of first entity CPlacement3D plEntityOnePlacement = penEntityOne->GetPlacement(); plEntityOnePlacement.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plEntityOnePlacement.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plEntityOnePlacement.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plEntityOnePlacement.pl_PositionVector(1) = m_fX; plEntityOnePlacement.pl_PositionVector(2) = m_fY; plEntityOnePlacement.pl_PositionVector(3) = m_fZ; // snap entity's placement pDoc->SnapToGrid( plEntityOnePlacement, SNAP_FLOAT_12); // set placement back to entity penEntityOne->SetPlacement( plEntityOnePlacement); pDoc->SetModifiedFlag( TRUE); pDoc->UpdateAllViews( NULL); m_udSelection.MarkUpdated(); // update all document's views pDoc->UpdateAllViews( NULL); } } }