Пример #1
0
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();
}
Пример #2
0
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);
	}
}
Пример #3
0
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);
		}
	}
}
Пример #4
0
// ---------------------------------------------------------------------------
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;
}