//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pObject - The object whose bounding box has changed.
//-----------------------------------------------------------------------------
void CCullTreeNode::UpdateAllCullTreeObjectsRecurse(void)
{
	int nChildCount = GetChildCount();
	if (nChildCount != 0)
	{
		for (int nChild = 0; nChild < nChildCount; nChild++)
		{
			CCullTreeNode *pChild = GetCullTreeChild(nChild);
			pChild->UpdateAllCullTreeObjectsRecurse();
		}
	}
	else
	{
		int nObjectCount = GetObjectCount();
		for (int nObject = 0; nObject < nObjectCount; nObject++)
		{
			CMapClass *pObject = GetCullTreeObject(nObject);

			Vector mins;
			Vector maxs;
			pObject->GetCullBox(mins, maxs);
			if (!BoxesIntersect(mins, maxs, bmins, bmaxs))
			{
				RemoveCullTreeObject(pObject);
			}
		}
	}
}
C_BaseEntity *CPlayerAndObjectEnumerator::GetObject( int index )
{
	if ( index < 0 || index >= GetObjectCount() )
		return NULL;

	return m_Objects[ index ];
}
Пример #3
0
Файл: Ase.cpp Проект: RinM/CGA
void CLoadASE::ReadAseFile(t3DModel *pModel)
{
	tMaterialInfo newMaterial = {0};
	tMaterialInfo newNormalMap = {0};
	t3DObject     newObject   = {0};
				
	int i = 0;	

	pModel->numOfObjects   = GetObjectCount();

	pModel->numOfMaterials = GetMaterialCount();

	for(i = 0; i < pModel->numOfMaterials; i++)
	{
		pModel->pMaterials.push_back(newMaterial);
		GetTextureInfo(&(pModel->pMaterials[i]), i + 1);
	}

	for(i = 0; i < pModel->numOfObjects; i++)
	{	
		pModel->pObject.push_back(newObject);
		pModel->pObject[i].materialID = -1;

		MoveToObject(i + 1);

		ReadObjectInfo(pModel, &(pModel->pObject[i]), i + 1);
		ReadObjectData(pModel, &(pModel->pObject[i]), i + 1);
		
	}

}
Пример #4
0
/*
 *	CTxtEdit::ObjectFromIOB
 *
 *	@mfunc	Gets an object based on an IOB type index.
 *
 *	@rdesc:
 *		pointer to COleObject or NULL if none.
 */
COleObject * CTxtEdit::ObjectFromIOB(LONG iob)
{
	COleObject * pobj = NULL;
	CObjectMgr * pobjmgr = NULL;

	pobjmgr = GetObjectMgr();

	if (!pobjmgr)
	{
		return NULL;
	}

	// Figure out the index of the selection
	if (iob == REO_IOB_SELECTION)
	{
		CTxtSelection * psel = GetSel();

		pobj = pobjmgr->GetFirstObjectInRange(psel->GetCpMin(),
			psel->GetCpMost());
	}
	else
	{
		// Make sure the IOB is in range
		if ((0 <= iob) && (iob < GetObjectCount()))
		{
			pobj = pobjmgr->GetObjectFromIndex(iob);
		}
	}

	return pobj;
}
void CObjectManager::HandleClientJoin(EntityId playerId)
{
	if(GetObjectCount() > 0)
	{
		CBitStream bsSend;

		for(EntityId x = 0; x < MAX_OBJECTS; x++)
		{
			if(m_bActive[x])
			{
				bsSend.WriteCompressed(x);
				bsSend.Write(m_Objects[x].dwModelHash);
				bsSend.Write(m_Objects[x].vecPosition);
				bsSend.Write(m_Objects[x].vecRotation);
				bsSend.Write(m_Objects[x].bAttached);
				bsSend.Write(m_Objects[x].bVehicleAttached);
				bsSend.Write(m_Objects[x].uiVehiclePlayerId);
				bsSend.Write(m_Objects[x].vecAttachPosition);
				bsSend.Write(m_Objects[x].vecAttachRotation);
				
				if(m_Objects[x].iBone == -1)
					bsSend.Write0();
				else
				{
					bsSend.Write1();
					bsSend.Write(m_Objects[x].iBone);
				}

				this->SetDimension(x, this->GetDimension(x));			
			}
		}

		g_pNetworkManager->RPC(RPC_NewObject, &bsSend, PRIORITY_HIGH, RELIABILITY_RELIABLE_ORDERED, playerId, false);
	}
}
CBaseEntity *CASW_Scanner_Objects_Enumerator::GetObject( int index )
{
	if ( index < 0 || index >= GetObjectCount() )
		return NULL;

	return m_Objects[ index ];
}
C_BaseEntity *CASW_UsableObjectsEnumerator::GetObject( int index )
{
	if ( index < 0 || index >= GetObjectCount() )
		return NULL;

	return m_Objects[ index ];
}
//---------------------------------------------------------------------
// isFileInFolder():
//---------------------------------------------------------------------
BOOL WPDIRECTORY::isFileInFolder(char *pszFilename)
{
   int index;

   for (index=0; index<GetObjectCount(); index++)
   {
      if (stricmp(pszFilename,GetObject(index)->GetTitle())==0)
         return (TRUE);
   }
   return (FALSE);
}
BOOL WPCONTAINER::WriteObjectProfile(int hProfile,WPCONTAINER *pwpcontainerParent)
{
   int                     index;
   FILE_CONTAINER_STRUCT   fcsData;

   // Save the number of child objects in this container object.                                          
   fcsData.m_nObjects = GetObjectCount();            
            
   // Read container extra information.
   if (write(hProfile,&fcsData,sizeof(FILE_CONTAINER_STRUCT))!=sizeof(FILE_CONTAINER_STRUCT)) 
      return (FALSE);
   
   // Depending on how many children components this container has...
   for (index=0; index<GetObjectCount(); index++)
   {
      // Write each child object.
      if (GetObject(index)->WriteObjectProfile(hProfile,(WPCONTAINER *)this)==FALSE) 
         return (FALSE);
   }

   return (TRUE);
}
Пример #10
0
void FormView::CreateObjectMenu(Bar& bar, int id)
{
	int selCount = GetSelected().GetCount();

	if (selCount > 1)
		bar.Add(t_("Align selected"), THISBACK(AlignObjectMenu));

	if (selCount != GetObjectCount())
		bar.Add(t_("Invert selection"), THISBACK(InvertSelection));
	
	if ((selCount != GetObjectCount()) || selCount > 1)
		bar.Separator();

	if (selCount == 1)
	{
		bar.Add(t_("Outline"), THISBACK1(ToggleOutlineDraw, id)).Check(IsOutlineDraw(id));
		bar.Separator();
	}

	if (selCount <= 1)
	{
		bar.Add(t_("Top"), THISBACK1(MoveToTopObject, id));
		bar.Add(t_("Up"), THISBACK1(MoveUpObject, id));
		bar.Add(t_("Down"), THISBACK1(MoveDownObject, id));
		bar.Add(t_("Bottom"), THISBACK1(MoveToBottomObject, id));
		bar.Separator();
	}

	bar.Add(t_("Delete"), THISBACK(RemoveSelection));

	if (selCount >= 1)
	{
		bar.Separator();
		bar.Add(t_("Properties"), THISBACK1(OpenObjectProperties, GetSelected()));
	}
}
//---------------------------------------------------------------------
// isAnyChildOpen():
//    Returns TRUE if object is "open" or any child objects (if 
// applicable) are in "open" state.  It returns FALSE otherwise.  Since 
// this is a virtual function, it can be overloaded by derived objects 
// which can actually have child objects.
//---------------------------------------------------------------------
BOOL WPCONTAINER::isAnyChildOpen(void)
{                              
   int index;
                    
   // First check if this directory folder is currently open...                    
   if (isOpen()==TRUE)                                         
      return (TRUE);
         
   // Loop through all children objects and test if any is currently open...         
   for (index=0; index<GetObjectCount(); index++)
      if (GetObject(index)->isAnyChildOpen()==TRUE)
         return (TRUE);
         
   // No children objects are currently opened, return FALSE.   
   return (FALSE);
}
//---------------------------------------------------------------------
// Initialize():
//    This function gets called only once during the desktop 
// initialization and its called by its parent conteiner object so that
// this object can resume the state in which it was saved.
//    We then call all our children objects so they can do the same.
//---------------------------------------------------------------------
void WPCONTAINER::Initialize(BOOL fIsShell)
{  
   int index;
      
   // If container object was originally open...         
   if (isOpen()==TRUE)
   {
      // Reset "opened" state bit (since we are not really open yet).
      SetState((GetState()&(~OBJSTATE_OPEN)));
      // Restore container object to open state.
      Open();               
   }

   // Intialize all of the container's children objects...
   for (index=0; index<GetObjectCount(); index++)
      GetObject(index)->Initialize(fIsShell);
}   
//---------------------------------------------------------------------
// CopyObjectToFileSystem():
//---------------------------------------------------------------------
BOOL WPCONTAINER::CopyObjectToFileSystem(char *pszDestPath)
{  
   int   index;
   char  szDirName[_MAX_PATH+1];
               
   // Create destination directory name fully qualified.       
   sprintf(szDirName,"%s\\%s",pszDestPath,MakeFATName((char *)GetTitleNoCRLF()));
   // Create directory in file system.
   if (CreateDirectory(szDirName)==TRUE)
   {                        
      // Copy all children objects to file system... 
      for (index=0; index<GetObjectCount(); index++)
         GetObject(index)->CopyObjectToFileSystem(szDirName);
      // Successfully copied all objects to file system.
      return (TRUE);
   }  
   
   // Failed to create directory or copy children objects.
   return (FALSE);
}
//---------------------------------------------------------------------
// Find():
//    This function finds an object or list of object(s) that match a
// specific search criteria specified by the function parameters.
// It can search for any object type and title text combination.  The
// object's title text can be searched for exactly or any occurrence
// of a substring.
//
// Parameters:
//    dwType      : Specifies the type of object to search.
//    pszTitle    : Object's title text string.
//    fExact      : Match title text exactly (TRUE) or 
//                  Match title text approximatedly (substring) (FALSE)
//    fStopOnMatch: Stop search on first match (default TRUE).
//    ppMatchList : Pointer to pointer to head of match list.
//                  This value is ignored if "fStopOnMatch" == TRUE.
//                                           
// Return value:               
// "fStopOnMatch" == TRUE:
//    Pointer to object found to match search criteria or NULL if no
// objects matching criteria are found.
// "fStopOnMatch" == FALSE:
//    Return value is undefined and must be ignored.
//---------------------------------------------------------------------
WPOBJECT *WPCONTAINER::Find(DWORD dwType,const char *pszTitle,BOOL fExact,BOOL fStopOnMatch,MATCH_RECORD **ppMatchList)
{          
   int      index;
   WPOBJECT *pwpobjFound;
                                                 
   // First, test if this object is meets criteria.
   pwpobjFound = WPOBJECT::Find(dwType,pszTitle,fExact,fStopOnMatch,ppMatchList);
   // If this container object matched criteria, then return object pointer.
   if ((fStopOnMatch==TRUE)&&(pwpobjFound!=NULL))
      return (this);
   
   // Search all child components of container object.                                              
   for (index=0; index<GetObjectCount(); index++)
   {     
      // Have child object test criteria.
      pwpobjFound = GetObject(index)->Find(dwType,pszTitle,fExact,fStopOnMatch,ppMatchList);
      // If object found while searching child component, then return object pointer.
      if ((fStopOnMatch==TRUE)&&(pwpobjFound!=NULL))
         return (pwpobjFound);
   }         
   // No matches found, return "none".   
   return (NULL);
}
//---------------------------------------------------------------------
// FreeDirectoryFiles():
//---------------------------------------------------------------------
void WPDIRECTORY::FreeDirectoryFiles(void)
{
   WPOBJECT    **apwpobjDirectory;
   HCURSOR     hcurOriginal;
   int         index,nObjectCount;

   // Load custom "wait" cursor (i.e. clock) and set current cursor to it.
   hcurOriginal = SetCursor(LoadCursor(g_wpEnvironment.hInst,MAKEINTRESOURCE(IDC_WAITCURSOR)));

   // Get number of objects in directory folder.
   nObjectCount = GetObjectCount();
   // Allocate enough memory to hold list of all objects.
   apwpobjDirectory = new WPOBJECT *[nObjectCount];

   // Get list of objects, and store them in local array...
   for (index=0; index<nObjectCount; index++)
      apwpobjDirectory[index] = GetObject(index);

   // Clear list of selected objects to "none" (do not invalidate them).
   ClearSelectedObjects(FALSE);

   // Do delete operation for all selected objects.
   for (index=0; index<nObjectCount; index++)
      // Call object's virtual key handler.
      apwpobjDirectory[index]->Destroy();

   // Deallocate memory used to hold copy of selected objects.
   delete[] apwpobjDirectory;

   // Set boolean flag to false since no files are current loaded.
   m_fFilesLoaded = FALSE;

   // Check if original cursor was not the same as our "wait" cursor...
   if (hcurOriginal!=GetCursor())
      // Restore original cursor and destroy custom wait cursor.
      DestroyCursor(SetCursor(hcurOriginal));
}
Пример #16
0
  Bool ExecuteAutoConnect()
  {
    ConnectOptions options;
    Bool addDynamicsTag = false, inheritDynamicsTag = true;
    GetInt32(CMB_FORCE, options.forcePluginId);
    GetInt32(CMB_TYPE, options.forceType);
    GetInt32(CMB_MODE, options.connectMode);
    GetInt32(EDT_MAXCONN, options.maxConnections);
    GetFloat(EDT_RADIUS, options.radius);
    GetBool(CHK_CLOSED, options.closedChain);
    GetBool(CHK_ADDDYNAMICS, addDynamicsTag);
    GetBool(CHK_COMPOUND, inheritDynamicsTag);

    // Create an InExcludeData for the selection object.
    GeData ge_selection(CUSTOMGUI_INEXCLUDE_LIST, DEFAULTVALUE);
    auto selectionList = static_cast<InExcludeData*>(
      ge_selection.GetCustomDataType(CUSTOMGUI_INEXCLUDE_LIST));
    if (!selectionList)
      return false;

    // Get the active document and object.
    BaseDocument* doc = GetActiveDocument();
    if (!doc)
      return false;
    BaseObject* op = doc->GetActiveObject();
    if (!op)
      return false;

    // Create the root object that will contain the connectors.
    AutoFree<BaseObject> root(BaseObject::Alloc(Onull));
    if (!root)
      return false;

    // Function to create a dynamics tag.
    auto fAddDynamicsTag = [doc] (BaseObject* op, Int32 mode)
    {
      // Create a dynamics tag for the root object if it
      // does not already exist.
      BaseTag* dyn = op->GetTag(ID_RIGIDBODY);
      if (!dyn)
      {
        dyn = op->MakeTag(ID_RIGIDBODY);
        if (dyn) doc->AddUndo(UNDOTYPE_NEW, dyn);
      }

      // Update the parameters.
      if (dyn)
      {
        dyn->SetParameter(RIGID_BODY_HIERARCHY, mode, DESCFLAGS_SET_0);
        doc->AddUndo(UNDOTYPE_CHANGE_SMALL, dyn);
      }
    };

    // This list will contain all objects that should be connected.
    // While collecting, create the dynamics tags.
    maxon::BaseArray<BaseObject*> objects;
    doc->StartUndo();
    for (BaseObject* child=op->GetDown(); child; child=child->GetNext())
    {
      objects.Append(child);
      if (addDynamicsTag && inheritDynamicsTag)
        fAddDynamicsTag(child, RIGID_BODY_HIERARCHY_COMPOUND);
    }
    if (addDynamicsTag && !inheritDynamicsTag)
      fAddDynamicsTag(op, RIGID_BODY_HIERARCHY_INHERIT);

    // If no objects where collected, quit already.
    if (objects.GetCount() <= 0)
    {
      doc->EndUndo();
      doc->DoUndo(false);
      return true;
    }

    // Create the connection objects.
    ConnectObjects(op->GetName() + ": ", objects, options);

    // Fill the selection list and insert the objects.
    for (auto it=options.output.Begin(); it != options.output.End(); ++it)
    {
      (*it)->InsertUnderLast(root);
      doc->AddUndo(UNDOTYPE_NEW, *it);
      selectionList->InsertObject(*it, 0);
    }

    root->SetName(op->GetName() + ": " + root->GetName() + " (" + options.forceName + ")");
    doc->InsertObject(root, nullptr, nullptr);
    doc->AddUndo(UNDOTYPE_NEW, root);

    // Create the selection object.
    if (selectionList->GetObjectCount() > 0)
    {
      BaseObject* selection = BaseObject::Alloc(Oselection);
      if (selection)
      {
        selection->SetParameter(SELECTIONOBJECT_LIST, ge_selection, DESCFLAGS_SET_0);
        selection->SetName(op->GetName() + ": " + options.forceName + " (" + selection->GetName() + ")");
        doc->InsertObject(selection, nullptr, nullptr);
        doc->AddUndo(UNDOTYPE_NEW, selection);
      }
      ActiveObjectManager_SetMode(ACTIVEOBJECTMODE_OBJECT, false);
      doc->SetActiveObject(selection);
    }
    else
      doc->SetActiveObject(root);

    root.Release();
    doc->EndUndo();
    EventAdd();
    return true;
  }
Пример #17
0
void IniSpawn::SpawnCreature(CritterEntry &critter) const
{
	if (!critter.creaturecount) {
		return;
	}

	ieDword specvar = CheckVariable(map, critter.SpecVar, critter.SpecContext);

	if (critter.SpecVar[0]) {
		if (critter.SpecVarOperator>=0) {
			// dunno if this should be negated
			if (!DiffCore(specvar, critter.SpecVarValue, critter.SpecVarOperator) ) {
				return;
			}
		} else {
			//ar0203 in PST seems to want the check this way.
			//if other areas conflict and you want to use (!specvar),
			//please research further
			//researched further - ar0203 respawns only if specvar is 1
			if (!specvar) {
				return;
			}
		}
	}

	if (!(critter.Flags&CF_IGNORECANSEE)) {
		if (map->IsVisible(critter.SpawnPoint, false) ) {
			return;
		}
	}

	if (critter.Flags&CF_NO_DIFF_MASK) {
		ieDword difficulty;
		ieDword diff_bit;

		core->GetDictionary()->Lookup("Difficulty Level", difficulty);
		switch (difficulty)
		{
		case 0:
			diff_bit = CF_NO_DIFF_1;
			break;
		case 1:
			diff_bit = CF_NO_DIFF_2;
			break;
		case 2:
			diff_bit = CF_NO_DIFF_3;
			break;
		default:
			diff_bit = 0;
		}
		if (critter.Flags&diff_bit) {
			return;
		}
	}

	if (critter.ScriptName[0] && (critter.Flags&CF_CHECK_NAME) ) {
		//maybe this one needs to be using getobjectcount as well
		//currently we cannot count objects with scriptname???
		if (map->GetActor( critter.ScriptName, 0 )) {
			return;
		}
	} else {
		//Object *object = new Object();
		Object object;
		//objectfields based on spec
		object.objectFields[0]=critter.Spec[0];
		object.objectFields[1]=critter.Spec[1];
		object.objectFields[2]=critter.Spec[2];
		object.objectFields[3]=critter.Spec[3];
		object.objectFields[4]=critter.Spec[4];
		object.objectFields[5]=critter.Spec[5];
		object.objectFields[6]=critter.Spec[6];
		object.objectFields[7]=critter.Spec[7];
		object.objectFields[8]=critter.Spec[8];
		int cnt = GetObjectCount(map, &object);
		if (cnt>=critter.TotalQuantity) {
			return;
		}
	}

	int x = core->Roll(1,critter.creaturecount,-1);
	Actor* cre = gamedata->GetCreature(critter.CreFile[x]);
	if (!cre) {
		return;
	}

	SetVariable(map, critter.SpecVar, critter.SpecContext, specvar+(ieDword) critter.SpecVarInc);
	map->AddActor(cre, true);
	for (x=0;x<9;x++) {
		if (critter.SetSpec[x]) {
			cre->SetBase(StatValues[x], critter.SetSpec[x]);
		}
	}
	cre->SetPosition( critter.SpawnPoint, 0, 0);//maybe critters could be repositioned
	cre->SetOrientation(critter.Orientation,false);
	if (critter.ScriptName[0]) {
		cre->SetScriptName(critter.ScriptName);
	}
	//increases death variable
	if (critter.Flags&CF_DEATHVAR) {
		cre->AppearanceFlags|=APP_DEATHVAR;
	}
	//increases faction specific variable
	if (critter.Flags&CF_FACTION) {
		cre->AppearanceFlags|=APP_FACTION;
	}
	//increases team specific variable
	if (critter.Flags&CF_TEAM) {
		cre->AppearanceFlags|=APP_TEAM;
	}
	//increases good variable
	if (critter.Flags&CF_GOOD) {
		cre->DeathCounters[DC_GOOD] = critter.DeathCounters[DC_GOOD];
		cre->AppearanceFlags|=APP_GOOD;
	}
	//increases law variable
	if (critter.Flags&CF_LAW) {
		cre->DeathCounters[DC_LAW] = critter.DeathCounters[DC_LAW];
		cre->AppearanceFlags|=APP_LAW;
	}
	//increases lady variable
	if (critter.Flags&CF_LADY) {
		cre->DeathCounters[DC_LADY] = critter.DeathCounters[DC_LADY];
		cre->AppearanceFlags|=APP_LADY;
	}
	//increases murder variable
	if (critter.Flags&CF_MURDER) {
		cre->DeathCounters[DC_MURDER] = critter.DeathCounters[DC_MURDER];
		cre->AppearanceFlags|=APP_MURDER;
	}
	//triggers help from same group
	if (critter.Flags&CF_BUDDY) {
		cre->AppearanceFlags|=APP_BUDDY;
	}

	if (critter.OverrideScript[0]) {
		cre->SetScript(critter.OverrideScript, SCR_OVERRIDE);
	}
	if (critter.ClassScript[0]) {
		cre->SetScript(critter.ClassScript, SCR_CLASS);
	}
	if (critter.RaceScript[0]) {
		cre->SetScript(critter.RaceScript, SCR_RACE);
	}
	if (critter.GeneralScript[0]) {
		cre->SetScript(critter.GeneralScript, SCR_GENERAL);
	}
	if (critter.DefaultScript[0]) {
		cre->SetScript(critter.DefaultScript, SCR_DEFAULT);
	}
	if (critter.AreaScript[0]) {
		cre->SetScript(critter.AreaScript, SCR_AREA);
	}
	if (critter.SpecificScript[0]) {
		cre->SetScript(critter.SpecificScript, SCR_SPECIFICS);
	}
	if (critter.Dialog[0]) {
		cre->SetDialog(critter.Dialog);
	}
}
Пример #18
0
const TMXMapObject* TMXMapObjectLayer::GetObject(size_t iIndex)const
{
    if (iIndex >= GetObjectCount())
        return nullptr;
    return m_vecObjects[iIndex];
}
Пример #19
0
void FormView::Paint(Draw& w)
{
	if (!IsLayout())
	{
		w.DrawRect(GetRect(), White());
		return;
	}

	Rect r = Zoom(GetPageRect());

	DrawGrid(w);
	DrawRect(w, r, 1, LtBlue());

	w.DrawRect(0, 0, r.left, 3000, White());
	w.DrawRect(r.right + 1, 0, 3000, 3000, White());
	w.DrawRect(r.left, 0, 5000, r.top, White());
	w.DrawRect(r.left, r.bottom + 1, 3000, 3000, White());

//	if (_showInfo)
//	{
//		r.SetSize( Zoom(Size(804, 604)) );
//		DrawRect(w, r.Offseted( Zoom(Size(-2, -2)) ), 1, LtMagenta());
//		r = Zoom(GetPageRect());
//	}

	if (GetObjectCount() > 0 && _showInfo == 2)
	{
		Rect b = Zoom(GetObjectsRect()).Offseted(1, 1);
		b.SetSize( b.GetSize() + Size(-2, -2) );
		DrawRect(w, b, 1, Yellow());
	}

	Vector<int> sel = GetSelected();

	bool coloring = GetBool("View.Coloring");
	int ci = 0;
	if (sel.GetCount() > 0)
	{
		if (sel.GetCount() == 1)
		{
			for (int i = 0; i < GetObjectCount(); ++i)
			{
				if (ci++ == _colors.GetCount() - 1) ci = 0;

				if (coloring && i != sel[0])
					DrawObject(w, i, _colors[ci], false);
				else
					DrawObject(w, i, (!coloring && (i == sel[0])) ? _colors[ci] : LtGray(),
						i == sel[0]);
			}
		}
		else
		{
			for (int i = 0; i < GetObjectCount(); ++i)
			{
				if (ci++ == _colors.GetCount() - 1) ci = 0;

				bool found = false;
				for (int j = 0; j < sel.GetCount(); ++j)
					if ( i == sel[j])
					{
						found = true;
						break;
					}
				if (coloring && !found)
					DrawObject(w, i, _colors[ci], false);
				else
					DrawObject(w, i, (!coloring && found) ? _colors[ci] : LtGray(), false);
			}

			Size g = GetGridSize();
			Rect s = GetSelectionRect().Offseted(-g.cx / 2, -g.cy / 2);
			s.SetSize(s.GetSize() + Size(g.cx, g.cy));

			Vector<int> sel = GetSelected();

			bool a1 = true;	// allow horz align
			bool a2 = true;	// allow vert align
			dword f1;		// first horz align
			dword f2;		// first vert align
	
			for (int i = 0; i < sel.GetCount(); ++i)
			{
				FormObject *pI = GetObject(sel[i]);
				if (!pI) continue;

				if (i == 0) { f1 = pI->GetHAlign(); f2 = pI->GetVAlign(); }

				if (f1 != pI->GetHAlign()) { a1 = false; }
				if (f2 != pI->GetVAlign()) { a2 = false; }
			}

			DrawSprings(w, Zoom(s), f1, f2, a1, a2, a1, a2, false);
			DrawRect(w, Zoom(s), 1, LtRed());

			s = GetSelectionRect().Offseted(-g.cx, -g.cy);
			s.SetSize(s.GetSize() + Size(g.cx * 2, g.cy * 2));

			DrawGroupTools(w, Zoom(s));
		}
		return;
	}

	for (int i = 0; i < GetObjectCount(); ++i)
	{
		if (ci++ == _colors.GetCount() - 1) ci = 0;
		DrawObject(w, i, coloring ? _colors[ci] : LtGray());
	}

	if (sel.GetCount() == 0)
		w.DrawImage(r.right, r.bottom, FormViewImg::SizerBR());
}
Пример #20
0
/*
 *	CRchTxtPtr::UnitCounter (Unit, &cUnit, cchMax)
 *
 *	@mfunc
 *		Helper function to count chars in <p cUnit> Units defined by <p Unit>
 *		<p cUnit> is a signed count.  If it extends beyond either end of the
 *		story, count up to that end and update <p cUnit> accordingly.  If
 *		<p cchMax> is nonzero, stop counting when the count exceeds <p cchMax>
 *		in magnitude.
 *
 *	@rdesc
 *		If unit is implemented, return cch corresponding to the units counted
 *		(up to a maximum magnitude of <p cchMax>) and update cUnit;
 *		else return tomForward to signal unit not implemented and cUnit = 0.
 *		If unit is implemented but unavailable, e.g., tomObject with no
 *		embedded objects, return tomBackward.
 *
 *	@devnote
 *		This is the basic engine used by the TOM CTxtRange::Move() and Index()
 *		methods.
 */
LONG CRchTxtPtr::UnitCounter (
	LONG	Unit,				//@parm Type of unit to count
	LONG &	cUnit,				//@parm Count of units to count chars for
	LONG	cchMax)				//@parm Maximum character count
{
	TRACEBEGIN(TRCSUBSYSTOM, TRCSCOPEINTERN, "CRchTxtPtr::UnitCounter");

	LONG	action;				// Gives direction and tomWord commands
	LONG	cch;				// Collects cch counted
	LONG	cchText = GetTextLength();
	LONG	cp = GetCp();
	LONG	iDir = cUnit > 0 ? 1 : -1;
	LONG	j;					// For-loop index
	CDisplay *pdp;				// Used for tomLine case

	if(!cUnit)									// Nothing to count
	{
		return ((DWORD)Unit > tomObject || !((IMPL >> Unit) & 1))
			? tomForward : 0;					// Indicate Unit not
	}											//  implemented
	if(cchMax <= 0)
		cchMax = tomForward;					// No cch limit

	switch(Unit)
	{
	case tomCharacter:							// Smallest Unit
		cp += cUnit;							// Requested new cp
		ValidateCp(cp);							// Make sure it's OK
		cch = cUnit = cp - GetCp();				// How many cch, cUnits
		break;									//  actually moved

	case tomStory:								// Largest Unit
		cch = (cUnit > 0) ? cchText - cp : -cp;	// cch to start of story
		cUnit = cch ? iDir : 0;					// If already at end/start,
		break;									//  of story, no count

	case tomCharFormat:							// Constant CHARFORMAT
		cch = _rpCF.CountRuns(cUnit, cchMax, cchText);
		break;

	case tomParaFormat:							// Constant PARAFORMAT
		cch = _rpPF.CountRuns(cUnit, cchMax, cchText);
		break;

	case tomObject:
		if(!GetObjectCount())					// No objects: can't move, so
		{
			cUnit = 0;							//  set cUnit = 0 and
			return tomBackward;					//  signal Unit unavailable
		}
		cch = GetPed()->_pobjmgr->CountObjects(cUnit, GetCp());
		break;

	case tomLine:
		pdp = GetPed()->_pdp;
		if(pdp)									// If this story has a display
		{										//  use a CLinePtr
			CLinePtr rp(pdp);
			pdp->WaitForRecalc(cp, -1);
			rp.RpSetCp(cp, FALSE);
			cch = rp.CountRuns(cUnit, cchMax, cchText);
			break;
		}										// Else fall thru to treat as
												//  tomPara
	default:									// tp dependent cases
	  {											// Block to contain tp() which
		CTxtPtr tp(_rpTX);						//  takes time to construct

		if (cUnit < 0)							// Counting backward
		{
			action = (Unit == tomWord)
				? WB_MOVEWORDLEFT : tomBackward;
		}
		else									// Counting forward
		{
			action = (Unit == tomWord)
				? WB_MOVEWORDRIGHT : tomForward;
		}
	
		for (cch = 0, j = cUnit; j && abs(cch) < cchMax; j -= iDir)
		{
			cp = tp.GetCp();					// Save starting cp for
			switch (Unit)						//  calculating cch for this
			{									//  Unit
			case tomWord:
				tp.FindWordBreak(action);
				break;
	
			case tomSentence:
				tp.FindBOSentence(action);
				break;
		
			case tomLine:						// Story has no line array:
			case tomParagraph:					//  treat as tomParagraph
				tp.FindEOP(action);
				break;
		
			default:
				cUnit = 0;
				return tomForward;				// Return error
			}
			if(tp.GetCp() - cp == 0)			// No count:
				break;							//  don't decrement cUnit
			cch += tp.GetCp() - cp;
		}
		cUnit -= j;								// Discount any runs not
	  }											//  counted if |cch| >= cchMax
	}

	if(abs(cch) > cchMax)						// Keep cch within requested
	{											//  limit
		cch = cch > 0 ? cchMax : -cchMax;
		if(Unit == tomCharacter)
			cUnit = cch;
	}		

	Advance(cch);								// Move to new position
	return cch;									// Total cch counted
}
Пример #21
0
/*
 *	CRchTxtPtr::ReplaceRange(cchOld, cchNew, *pch, pcpFirstRecalc, publdr,
 *							 iFormat)
 *	@mfunc
 *		Replace a range of text at this text pointer using CCharFormat iFormat
 *		and updating other text runs as needed
 *	
 *	@rdesc
 *		Count of new characters added
 *	
 *	@devnote
 *		Moves this text pointer to end of replaced text.
 *		May move text block and formatting arrays.
 */
LONG CRchTxtPtr::ReplaceRange(
	LONG		cchOld,		// @parm length of range to replace
							//		(<lt> 0 means to end of text)
	LONG		cchNew,		// @parm length of replacement text
	TCHAR const *pch,		// @parm replacement text
	IUndoBuilder *publdr,	// @parm CCharFormat iFormat to use for cchNew
	LONG		iFormat)
{
	TRACEBEGIN(TRCSUBSYSBACK, TRCSCOPEINTERN, "CRchTxtPtr::ReplaceRange");

	LONG		  cch;
	LONG		  cchEndEOP = 0;				// Default 0 final EOP fixup
	LONG		  cchMove = 0;					// Default nothing to move
	LONG		  cchNextEOP = cchOld;			// cch to next EOP
	LONG		  cchPrevEOP = 0;				// cch back to previous EOP
	LONG		  cpFR;							//  between PF runs
	LONG 		  cpSave = GetCp();
	LONG		  cpFormatMin = cpSave;			// Used for notifications
	LONG		  cpFormat = cpSave;			// Will add cchOld, maybe cchMove
	IAntiEvent *  paeCF = NULL;
	IAntiEvent *  paePF = NULL;
	CNotifyMgr *  pnm;
	CObjectMgr *  pobjmgr;

 	_TEST_INVARIANT_

	LONG cchEnd = GetTextLength() - GetCp();
	if(cchOld < 0)
		cchOld = cchEnd;

  	if(IsRich() && cchOld == cchEnd)			// Attempting to delete up
	{											//  thru final EOP
		cchEndEOP = (GetPed()->Get10Mode())		// Calc cch of final EOP
				  ? CCH_EOD_10 : CCH_EOD_20;

		if(cchEndEOP <= cchOld)					// Don't delete it unless
			cchOld -= cchEndEOP;				//  converting from 2.0
	}
	else if(_rpPF.IsValid() && cchOld)			// If PARAFORMATs are enabled,
	{											//  get tp and rp at end of 
		CFormatRunPtr rp(_rpPF);				//  range. Need bounding para
		CTxtPtr 	  tp(_rpTX);				//  counts to save valid PF
		BOOL		  fIsAtBOP;					//  for undo

		tp.AdvanceCp(cchOld);
		rp.AdvanceCp(cchOld);

		cch = 0;
		if(tp.IsAfterEOP())						// Range ends with an EOP:
		{										//  get EOP length by
			cch = -tp.BackupCpCRLF();			//  backing up over it
			tp.AdvanceCp(cch);					// Advance past EOP
		}
		cchNextEOP = tp.FindEOP(tomForward);	// Get cch up to next EOP

		fIsAtBOP = !GetCp() || _rpTX.IsAfterEOP();
		if (!fIsAtBOP && cch == cchOld &&		// Deleting EOP alone before
			!rp.GetIch())						//  new PARAFORMAT run start
		{										//  in para with more than EOP
			cchMove = cchNextEOP;				// Need to move chars up to
			cpFormat += cchMove;				//  end of next para for
		}
		
		cchNextEOP += cchOld;					// Count from GetCp() to EOP
			
		tp.SetCp(GetCp());						// Back to this ptr's _cp
		if(!fIsAtBOP)
			cchPrevEOP = tp.FindEOP(tomBackward);// Get cch to start of para

		// If deleting from within one format run up to or into another, set
		// up to move last para in starting format run into the run following
		// the deleted text
		if(rp.GetFormat() != _rpPF.GetFormat()	// Change of format during  
			&& !fIsAtBOP && !cchMove)			//  deleted text not starting
		{										//  at BOP
			cchMove = cchPrevEOP;				// Get cch to start of para
			cpFormatMin += cchMove;				//  in this ptr's run for
		}										//  moving into rp's run
	}
	
	Assert(cchNew >= 0 && cchOld >= 0);
	if(!(cchNew + cchOld))						// Nothing to do (note: all
		return 0;								//  these cch's are >= 0)

	// Handle pre-replace range notifications.  This method is very
	// useful for delayed rendering of data copied to the clipboard.

	pnm = GetPed()->GetNotifyMgr();
	if( pnm )
	{
		pnm->NotifyPreReplaceRange((ITxNotify *)this, cpSave, cchOld,
			cchNew, cpFormatMin, cpFormat + cchOld);
	}

	if(iFormat >= 0)
		Check_rpCF();

	// Get rid of objects first.  This let's us guarantee that when we
	// insert the objects as part of an undo, the objects themselves are
	// restored _after_ their corresponding WCH_EMBEDDINGs have been
	// added to the backing store.

	if(GetObjectCount())
	{
		pobjmgr = GetPed()->GetObjectMgr();

		Assert(pobjmgr);

		pobjmgr->ReplaceRange(cpSave, cchOld, publdr);
	}

	if( ( IsRich() || IsIMERich() ) && iFormat != tomUndefined)			// Rich text enabled
	{
		// The anti-events used below are a bit tricky (paeCF && paePF).
		// Essentially, this call, CRchTxtPtr::ReplaceRange generates one
		// 'combo' anti-event composed of up to two formatting AE's plus
		// the text anti-event.  These anti-events are combined together
		// to prevent ordering problems during undo/redo.
		cpFR = ReplaceRangeFormatting(cchOld + cchEndEOP, cchNew + cchEndEOP, 
			iFormat, publdr, &paeCF, &paePF, cchMove, cchPrevEOP, cchNextEOP);

		if (cchEndEOP)
		{
			// If we added in the EOP we need to back up by the EOP so
			// that the invariants don't get annoyed and the richtext object
			// doesn't get out of sync.
			_rpCF.AdvanceCp(-cchEndEOP);
			_rpPF.AdvanceCp(-cchEndEOP);
		}
				
		if(cpFR < 0)
		{
			Tracef(TRCSEVERR, "ReplaceRangeFormatting(%ld, %ld, %ld) failed", GetCp(), cchOld, cchNew);
			cch = 0;
			goto Exit;
		}
	}

	// As noted above in the call to ReplaceRangeFormatting, the anti-events
	// paeCF and paePF, if non-NULL, were generated by ReplaceRangeFormatting.
	// In order to solve ordering problems, the anti-event generated by this
	// method is actually a combo anti-event of text && formatting AE's.
	cch = _rpTX.ReplaceRange(cchOld, cchNew, pch, publdr, paeCF, paePF);
	if (cch != cchNew)
	{
		Tracef(TRCSEVERR, "_rpTX.ReplaceRange(%ld, %ld, ...) failed", cchOld, cchNew);

		// Boy, out of memory or something bad.  Dump our formatting and hope
		// for the best.  
		//
		// FUTURE: (alexgo) degrade more gracefully than loosing formatting
		// info.

		// Notify every interested party that they should dump their formatting
		if( pnm )
		{
			pnm->NotifyPreReplaceRange(NULL, CONVERT_TO_PLAIN, 0, 0, 0, 0);
		}

		// Tell document to dump its format runs
		GetPed()->GetTxtStory()->DeleteFormatRuns();
		goto Exit;
	}

	AssertSz(!_rpPF.IsValid() || _rpPF.GetIch() || !GetCp() || _rpTX.IsAfterEOP(),
		"CRchTxtPtr::ReplaceRange: EOP not at end of PF run");
			
	// BUGBUG!! (alexgo) doesn't handle correctly the case where things fail
	// (due to out of memory or whatever).  See also notes in CTxtPtr::HandleReplaceRange
	// Undo.  The assert below is therefore somewhat bogus, but if it fires, 
	// then our floating ranges are going to be in trouble until we fix
	// up the logic here.

	Assert(cch == cchNew);

Exit:

#ifdef DEBUG
	// test the invariant again before calling out to replace range notification;
	// in this way, we can catch bugs earlier. The invariant has its own
	// scope for convenience.
	if( 1 )
	{
		_TEST_INVARIANT_
	}
#endif

	if( pnm )
	{
		pnm->NotifyPostReplaceRange((ITxNotify *)this, cpSave, cchOld, cch,
			cpFormatMin, cpFormat + cchOld);
	}

	GetPed()->GetCallMgr()->SetChangeEvent(CN_TEXTCHANGED);

	return cch;
}
Пример #22
0
void ezWorld::Update()
{
  CheckForWriteAccess();

  EZ_LOG_BLOCK(m_Data.m_sName.GetData());

  {
    ezStringBuilder sStatName;
    sStatName.Format("World Update/{0}/Game Object Count", m_Data.m_sName);

    ezStringBuilder sStatValue;
    ezStats::SetStat(sStatName, GetObjectCount());
  }

  m_Data.m_Clock.SetPaused(!m_Data.m_bSimulateWorld);
  m_Data.m_Clock.Update();

  // initialize phase
  {
    EZ_PROFILE_SCOPE("Initialize Phase");
    ProcessComponentsToInitialize();
    ProcessUpdateFunctionsToRegister();

    ProcessQueuedMessages(ezObjectMsgQueueType::AfterInitialized);
  }

  // pre-async phase
  {
    EZ_PROFILE_SCOPE("Pre-Async Phase");
    ProcessQueuedMessages(ezObjectMsgQueueType::NextFrame);
    UpdateSynchronous(m_Data.m_UpdateFunctions[ezComponentManagerBase::UpdateFunctionDesc::Phase::PreAsync]);
  }

  // async phase
  {
    // remove write marker but keep the read marker. Thus no one can mark the world for writing now. Only reading is allowed in async phase.
    m_Data.m_WriteThreadID = (ezThreadID)0;

    EZ_PROFILE_SCOPE("Async Phase");
    UpdateAsynchronous();

    // restore write marker
    m_Data.m_WriteThreadID = ezThreadUtils::GetCurrentThreadID();
  }

  // post-async phase
  {
    EZ_PROFILE_SCOPE("Post-Async Phase");
    ProcessQueuedMessages(ezObjectMsgQueueType::PostAsync);
    UpdateSynchronous(m_Data.m_UpdateFunctions[ezComponentManagerBase::UpdateFunctionDesc::Phase::PostAsync]);
  }

  // delete dead objects and update the object hierarchy
  {
    EZ_PROFILE_SCOPE("Delete Dead Objects");
    DeleteDeadObjects();
    DeleteDeadComponents();
  }

  // update transforms
  {
    float fInvDelta = 0.0f;

    // when the clock is paused just use zero
    const float fDelta = (float)m_Data.m_Clock.GetTimeDiff().GetSeconds();
    if (fDelta > 0.0f)
      fInvDelta = 1.0f / fDelta;

    EZ_PROFILE_SCOPE("Update Transforms");
    m_Data.UpdateGlobalTransforms(fInvDelta);
  }

  // post-transform phase
  {
    EZ_PROFILE_SCOPE("Post-Transform Phase");
    ProcessQueuedMessages(ezObjectMsgQueueType::PostTransform);
    UpdateSynchronous(m_Data.m_UpdateFunctions[ezComponentManagerBase::UpdateFunctionDesc::Phase::PostTransform]);
  }

  // Process again so new component can receive render messages, otherwise we introduce a frame delay.
  {
    EZ_PROFILE_SCOPE("Initialize Phase 2");
    ProcessComponentsToInitialize();

    ProcessQueuedMessages(ezObjectMsgQueueType::AfterInitialized);
  }

  // Swap our double buffered stack allocator
  m_Data.m_StackAllocator.Swap();
}