void CASW_VGUI_Computer_Splash::OnThink()
{	
	if (!m_bPlayedSound && m_fSoundTime <= gpGlobals->curtime)
	{
		CLocalPlayerFilter filter;
		if (IsPDA())
			C_BaseEntity::EmitSound( filter, -1 /*SOUND_FROM_LOCAL_PLAYER*/, "ASWComputer.SyntekPDA" );
		else
			C_BaseEntity::EmitSound( filter, -1 /*SOUND_FROM_LOCAL_PLAYER*/, "ASWComputer.Startup" );
		m_bPlayedSound = true;
	}

	int x,y,w,t;
	GetBounds(x,y,w,t);	
	if (!m_bSlidOut && m_fSlideOutTime <= gpGlobals->curtime)
	{
		m_bSlidOut = true;
		// slide/fade out our elements		
		vgui::GetAnimationController()->RunAnimationCommand(m_pLogoImage, "xpos", w*0.05f, 0.0f, 0.8f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pLogoImage, "ypos", t*0.05f, 0.0f, 0.8f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pLogoImage, "wide", w*0.13f, 0.0f, 0.8f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pLogoImage, "tall", t*0.13f, 0.0f, 0.8f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pSynTekLabel, "ypos", 0, 0.0f, 0.8f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		vgui::GetAnimationController()->RunAnimationCommand(m_pSloganLabel, "Alpha", 0, 0.0f, 0.4f, vgui::AnimationController::INTERPOLATOR_LINEAR);
	}

	if (m_iNumLines < ASW_SPLASH_SCROLL_LINES && m_fStartScrollingTime <= gpGlobals->curtime)
	{
		m_iNumLines++;
		//m_iNumLines = clamp(((gpGlobals->curtime - m_fStartScrollingTime) / ASW_SPLASH_SCROLL_INTERVAL) + 1, 0, ASW_SPLASH_SCROLL_LINES);
		if (m_iNumLines == ASW_SPLASH_SCROLL_LINES)
			m_fFadeScrollerOutTime = gpGlobals->curtime + 0.8f;
		float font_tall = vgui::surface()->GetFontTall(m_pScrollLine[0]->GetFont());
		for (int i=0;i<m_iNumLines;i++)
		{
			m_pScrollLine[i]->SetAlpha(128);			
			m_pScrollLine[i]->SetPos(0.02f * w, t - ((m_iNumLines - i) * font_tall + 0.02f * w));
		}
		m_fStartScrollingTime = gpGlobals->curtime + ASW_SPLASH_SCROLL_INTERVAL * (random->RandomInt(1,5));
	}
	if (m_fFadeScrollerOutTime != 0 && gpGlobals->curtime >= m_fFadeScrollerOutTime)
	{
		m_fFadeScrollerOutTime = 0;
		for (int i=0;i<ASW_SPLASH_SCROLL_LINES;i++)
		{
			vgui::GetAnimationController()->RunAnimationCommand(m_pScrollLine[i], "Alpha", 0, 0.0f, 0.4f, vgui::AnimationController::INTERPOLATOR_LINEAR);
		}
		// notify the main frame we're done
		CASW_VGUI_Computer_Frame *pFrame = dynamic_cast<CASW_VGUI_Computer_Frame*>(GetParent());
		if (pFrame && !IsPDA())
			pFrame->SplashFinished();
	}

	m_pLogoImage->GetBounds(x,y,w,t);
	// make our glitch less bright
	if (m_bSlidOut || gpGlobals->curtime > m_fShowGlitchTime)
	{
		m_pLogoGlitchImage->SetAlpha(0);

		if (gpGlobals->curtime > m_fNextGlitchTime)
		{
			if (random->RandomFloat() < 0.03f)
				m_fShowGlitchTime = gpGlobals->curtime + 0.4f;
			m_fNextGlitchTime += ASW_COMPUTER_GLITCH_INTERVAL;
		}
	}
	else
	{
		m_pLogoGlitchImage->SetAlpha(m_pLogoImage->GetAlpha() * 0.07f);
		// scale it randomly
		if (gpGlobals->curtime > m_fNextGlitchTime)
		{
			float x_scale = random->RandomFloat(0.7f, 1.3f);
			float y_scale = random->RandomFloat(0.7f, 1.3f);
			m_pLogoGlitchImage->SetSize(w * x_scale, t * y_scale);
			m_pLogoGlitchImage->SetPos(x - w * 0.5f * x_scale + w * 0.5f, y - t * 0.5f * y_scale + t * 0.5f);
			m_fNextGlitchTime += ASW_COMPUTER_GLITCH_INTERVAL;
		}
	}

	//float deltatime = gpGlobals->curtime - m_fLastThinkTime;
	m_fLastThinkTime = gpGlobals->curtime;
}
Example #2
0
/************************************************************************************************
 * CRMBSPInstance::Spawn
 *	spawns a bsp into the world using the previously aquired origin
 *
 * inputs:
 *  none
 *
 * return:
 *	none
 *
 ************************************************************************************************/
bool CRMBSPInstance::Spawn ( CRandomTerrain* terrain, qboolean IsServer)
{
#ifndef PRE_RELEASE_DEMO
//	TEntity*	ent;
    float		yaw;
    char		temp[10000];
    char		*savePtr;
    vec3_t		origin;
    vec3_t		notmirrored;
    float	water_level = terrain->GetLandScape()->GetWaterHeight();

    const vec3_t&	  terxelSize = terrain->GetLandScape()->GetTerxelSize ( );
    const vec3pair_t& bounds     = terrain->GetLandScape()->GetBounds();

    // If this entity somehow lost its collision flag then boot it
    if ( !GetArea().IsCollisionEnabled ( ) )
    {
        return false;
    }

    // copy out the unmirrored version
    VectorCopy(GetOrigin(), notmirrored);

    // we want to mirror it before determining the Z value just in case the landscape isn't perfectly mirrored
    if (mMirror)
    {
        GetOrigin()[0] = TheRandomMissionManager->GetLandScape()->GetBounds()[0][0] + TheRandomMissionManager->GetLandScape()->GetBounds()[1][0] - GetOrigin()[0];
        GetOrigin()[1] = TheRandomMissionManager->GetLandScape()->GetBounds()[0][1] + TheRandomMissionManager->GetLandScape()->GetBounds()[1][1] - GetOrigin()[1];
    }

    // Align the instance to the center of a terxel
    GetOrigin ( )[0] = bounds[0][0] + (int)((GetOrigin ( )[0] - bounds[0][0] + terxelSize[0] / 2) / terxelSize[0]) * terxelSize[0];
    GetOrigin ( )[1] = bounds[0][1] + (int)((GetOrigin ( )[1] - bounds[0][1] + terxelSize[1] / 2) / terxelSize[1]) * terxelSize[1];

    // Make sure the bsp is resting on the ground, not below or above it
    // NOTE: This check is basically saying "is this instance not a bridge", because when instances are created they are all
    // placed above the world's Z boundary, EXCEPT FOR BRIDGES. So this call to GetWorldHeight will move all other instances down to
    // ground level except bridges
    if ( GetOrigin()[2] > terrain->GetBounds()[1][2] )
    {
        if( GetFlattenRadius() )
        {
            terrain->GetLandScape()->GetWorldHeight ( GetOrigin(), GetBounds ( ), false );
            GetOrigin()[2] += 5;
        }
        else if (IsServer)
        {   // if this instance does not flatten the ground around it, do a trace to more accurately determine its Z value
            trace_t		tr;
            vec3_t		end;
            vec3_t		start;

            VectorCopy(GetOrigin(), end);
            VectorCopy(GetOrigin(), start);
            // start the trace below the top height of the landscape
            start[2] = TheRandomMissionManager->GetLandScape()->GetBounds()[1][2] - 1;
            // end the trace at the bottom of the world
            end[2] = MIN_WORLD_COORD;

            memset ( &tr, 0, sizeof ( tr ) );
            SV_Trace( &tr, start, vec3_origin, vec3_origin, end, ENTITYNUM_NONE, CONTENTS_TERRAIN|CONTENTS_SOLID, G2_NOCOLLIDE, 0); //qfalse, 0, 10 );

            if( !(tr.contents & CONTENTS_TERRAIN) || (tr.fraction == 1.0) )
            {
                if ( 0 )
                    assert(0); // this should never happen

                // restore the unmirrored origin
                VectorCopy( notmirrored, GetOrigin() );
                // don't spawn
                return false;
            }
            // assign the Z-value to wherever it hit the terrain
            GetOrigin()[2] = tr.endpos[2];
            // lower it a little, otherwise the bottom of the instance might be exposed if on some weird sloped terrain
            GetOrigin()[2] -= 16; // FIXME: would it be better to use a number related to the instance itself like 1/5 it's height or something...
        }

    }
    else
    {
        terrain->GetLandScape()->GetWorldHeight ( GetOrigin(), GetBounds ( ), true );
    }

    // save away the origin
    VectorCopy(GetOrigin(), origin);
    // make sure not to spawn if in water
    if (!HasObjective() && GetOrigin()[2] < water_level)
        return false;
    // restore the origin
    VectorCopy(origin, GetOrigin());

    if (mMirror)
    {   // change blue things to red for symmetric maps
        if (strlen(mFilter) > 0)
        {
            char * blue = strstr(mFilter,"blue");
            if (blue)
            {
                blue[0] = (char) 0;
                strcat(mFilter, "red");
                SetSide(SIDE_RED);
            }
        }
        if (strlen(mTeamFilter) > 0)
        {
            char * blue = strstr(mTeamFilter,"blue");
            if (blue)
            {
                strcpy(mTeamFilter, "red");
                SetSide(SIDE_RED);
            }
        }
        yaw = RAD2DEG(mArea->GetAngle() + mBaseAngle) + 180;
    }
    else
    {
        yaw = RAD2DEG(mArea->GetAngle() + mBaseAngle);
    }

    /*
    	if( TheRandomMissionManager->GetMission()->GetSymmetric() )
    	{
    		vec3_t	diagonal;
    		vec3_t	lineToPoint;
    		vec3_t	mins;
    		vec3_t	maxs;
    		vec3_t	point;
    		vec3_t	vProj;
    		vec3_t	vec;
    		float	distance;

    		VectorCopy( TheRandomMissionManager->GetLandScape()->GetBounds()[1], maxs );
    		VectorCopy( TheRandomMissionManager->GetLandScape()->GetBounds()[0], mins );
    		VectorCopy( GetOrigin(), point );
    		mins[2] = maxs[2] = point[2] = 0;
    		VectorSubtract( point, mins, lineToPoint );
    		VectorSubtract( maxs, mins, diagonal);


    		VectorNormalize(diagonal);
    		VectorMA( mins, DotProduct(lineToPoint, diagonal), diagonal, vProj);
    		VectorSubtract(point, vProj, vec );
    		distance = VectorLength(vec);

    		// if an instance is too close to the imaginary diagonal that cuts the world in half, don't spawn it
    		// otherwise you can get overlapping instances
    		if( distance < GetSpacingRadius() )
    		{
    #ifdef _DEBUG
    			mAutomapSymbol = AUTOMAP_END;
    #endif
    			if( !HasObjective() )
    			{
    				return false;
    			}
    		}
    	}
    */

    // Spawn in the bsp model
    sprintf(temp,
            "{\n"
            "\"classname\"   \"misc_bsp\"\n"
            "\"bspmodel\"    \"%s\"\n"
            "\"origin\"      \"%f %f %f\"\n"
            "\"angles\"      \"0 %f 0\"\n"
            "\"filter\"      \"%s\"\n"
            "\"teamfilter\"  \"%s\"\n"
            "\"spacing\"	 \"%d\"\n"
            "\"flatten\"	 \"%d\"\n"
            "}\n",
            mBsp,
            GetOrigin()[0], GetOrigin()[1], GetOrigin()[2],
            AngleNormalize360(yaw),
            mFilter,
            mTeamFilter,
            (int)GetSpacingRadius(),
            (int)GetFlattenRadius()
           );

    if (IsServer)
    {   // only allow for true spawning on the server
        savePtr = sv.entityParsePoint;
        sv.entityParsePoint = temp;
//		VM_Call( cgvm, GAME_SPAWN_RMG_ENTITY );
        //	char *s;
        int bufferSize = 1024;
        char buffer[1024];

        //	s = COM_Parse( (const char **)&sv.entityParsePoint );
        Q_strncpyz( buffer, sv.entityParsePoint, bufferSize );
        if ( sv.entityParsePoint && sv.entityParsePoint[0] )
        {
            ge->GameSpawnRMGEntity(sv.entityParsePoint);
        }
        sv.entityParsePoint = savePtr;
    }


#ifndef DEDICATED
    DrawAutomapSymbol();
#endif
    Com_DPrintf( "RMG:  Building '%s' spawned at (%f %f %f)\n", mBsp, GetOrigin()[0], GetOrigin()[1], GetOrigin()[2] );
    // now restore the instances un-mirrored origin
    // NOTE: all this origin flipping, setting the side etc... should be done when mMirror is set
    // because right after this function is called, mMirror is set to 0 but all the instance data is STILL MIRRORED -- not good
    VectorCopy(notmirrored, GetOrigin());

#endif  // PRE_RELEASE_DEMO

    return true;
}
Example #3
0
//----------------------------------------------------------------//
USBox MOAIDeck::GetBounds () {
	return GetBounds ( 0, NULL );
}
 virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
 {
   aAttrs = ColorLayerAttributes(GetColor(), GetBounds());
 }
Example #5
0
nsRect nsRegion::GetLargestRectangle (const nsRect& aContainingRect) const {
  nsRect bestRect;

  if (GetNumRects() <= 1) {
    bestRect = GetBounds();
    return bestRect;
  }

  AxisPartition xaxis, yaxis;

  // Step 1: Calculate the grid lines
  nsRegionRectIterator iter(*this);
  const nsRect *currentRect;
  while ((currentRect = iter.Next())) {
    xaxis.InsertCoord(currentRect->x);
    xaxis.InsertCoord(currentRect->XMost());
    yaxis.InsertCoord(currentRect->y);
    yaxis.InsertCoord(currentRect->YMost());
  }
  if (!aContainingRect.IsEmpty()) {
    xaxis.InsertCoord(aContainingRect.x);
    xaxis.InsertCoord(aContainingRect.XMost());
    yaxis.InsertCoord(aContainingRect.y);
    yaxis.InsertCoord(aContainingRect.YMost());
  }

  // Step 2: Fill out the grid with the areas
  // Note: due to the ordering of rectangles in the region, it is not always
  // possible to combine steps 2 and 3 so we don't try to be clever.
  int32_t matrixHeight = yaxis.GetNumStops() - 1;
  int32_t matrixWidth = xaxis.GetNumStops() - 1;
  int32_t matrixSize = matrixHeight * matrixWidth;
  nsTArray<SizePair> areas(matrixSize);
  areas.SetLength(matrixSize);

  iter.Reset();
  while ((currentRect = iter.Next())) {
    int32_t xstart = xaxis.IndexOf(currentRect->x);
    int32_t xend = xaxis.IndexOf(currentRect->XMost());
    int32_t y = yaxis.IndexOf(currentRect->y);
    int32_t yend = yaxis.IndexOf(currentRect->YMost());

    for (; y < yend; y++) {
      nscoord height = yaxis.StopSize(y);
      for (int32_t x = xstart; x < xend; x++) {
        nscoord width = xaxis.StopSize(x);
        int64_t size = width*int64_t(height);
        if (currentRect->Intersects(aContainingRect)) {
          areas[y*matrixWidth+x].mSizeContainingRect = size;
        }
        areas[y*matrixWidth+x].mSize = size;
      }
    }
  }

  // Step 3: Find the maximum submatrix sum that does not contain a rectangle
  {
    // First get the prefix sum array
    int32_t m = matrixHeight + 1;
    int32_t n = matrixWidth + 1;
    nsTArray<SizePair> pareas(m*n);
    pareas.SetLength(m*n);
    for (int32_t y = 1; y < m; y++) {
      for (int32_t x = 1; x < n; x++) {
        SizePair area = areas[(y-1)*matrixWidth+x-1];
        if (!area.mSize) {
          area = SizePair::VeryLargeNegative();
        }
        area = area + pareas[    y*n+x-1]
                    + pareas[(y-1)*n+x  ]
                    - pareas[(y-1)*n+x-1];
        pareas[y*n+x] = area;
      }
    }

    // No longer need the grid
    areas.SetLength(0);

    SizePair bestArea;
    struct {
      int32_t left, top, right, bottom;
    } bestRectIndices = { 0, 0, 0, 0 };
    for (int32_t m1 = 0; m1 < m; m1++) {
      for (int32_t m2 = m1+1; m2 < m; m2++) {
        nsTArray<SizePair> B;
        B.SetLength(n);
        for (int32_t i = 0; i < n; i++) {
          B[i] = pareas[m2*n+i] - pareas[m1*n+i];
        }
        int32_t minIdx, maxIdx;
        SizePair area = MaxSum1D(B, n, &minIdx, &maxIdx);
        if (area > bestArea) {
          bestRectIndices.left = minIdx;
          bestRectIndices.top = m1;
          bestRectIndices.right = maxIdx;
          bestRectIndices.bottom = m2;
          bestArea = area;
        }
      }
    }

    bestRect.MoveTo(xaxis.StopAt(bestRectIndices.left),
                    yaxis.StopAt(bestRectIndices.top));
    bestRect.SizeTo(xaxis.StopAt(bestRectIndices.right) - bestRect.x,
                    yaxis.StopAt(bestRectIndices.bottom) - bestRect.y);
  }

  return bestRect;
}
Example #6
0
void TView::Draw(TCanvas& canvas) const
	{
	TRect bounds = GetBounds();
	canvas.SetCursor(bounds.x_,bounds.y_);
	TDraw::Rect(canvas,bounds.w_,bounds.h_,' ',GetForeground(),GetBackground());
	}
Example #7
0
/** 
 * 
 * Extracts details pertaining to a window
 * 
 * @param       WindowObj - Window data
 * @return      void
 * @exception   Nil
 * @see         Nil
 * @since       1.0
 */
void Window::ExtractWindowDetails( const HWND hWnd_i )
{
    // Set window handle
    SetHandle( hWnd_i );

    // Set thread id of window
    SetThreadId( ::GetWindowThreadProcessId( GetHandle(), 0 ));

    // Get class name of window
    TCHAR szBuffer[MAX_PATH] = { 0 };
    ::GetClassName( GetHandle(), szBuffer, MAX_PATH );
    GetClassName() = szBuffer;

    GetClass().cbSize = sizeof( GetClass() );
    GetClassInfoEx( AfxGetInstanceHandle(), szBuffer, &GetClass() );

    // Get window text if any
    InternalGetWindowText( GetHandle(), GetTitle().GetBufferSetLength( MAX_PATH ), MAX_PATH );
    GetTitle().ReleaseBuffer();

    // Get normal style
    SetStyle( GetWindowLong( GetHandle(), GWL_STYLE ));

    // Get extended style
    SetStyleEx( GetWindowLong( GetHandle(), GWL_EXSTYLE ));

    // Get window id
    SetId( GetWindowLong( GetHandle(), GWL_ID ));

    // Get parent window
    SetParentHandle( RCAST( HWND, GetWindowLong( GetHandle(), GWL_HWNDPARENT )));

    // Window state i.e. window is maximized, minimized or restored
    GetStateAsString( GetState() );

    // For style parsing
    RetrieveWndStyles();

    // Window bounds
    CRect crBounds;
    GetWindowRect( GetHandle(), &crBounds );
    if( crBounds.Width() || crBounds.Height() )
    {
        GetBounds().Format( _T( "L:%d T:%d R:%d B:%d" ), crBounds.left, 
                                                         crBounds.top, 
                                                         crBounds.right, 
                                                         crBounds.bottom );
    }// End if

    // Retrieves unicode support status for windows
    SetUnicode( IsWindowUnicode( GetHandle() ));

    // Get window icon
    DWORD dwResult = 0;
    Utils::SndMsgTimeOutHelper( GetHandle(), 
                                WM_GETICON, 
                                ICON_SMALL, 
                                0,
                                dwResult );
    // Get window icon
    SetIcon( RCAST( HICON, dwResult ));

    // Get enabled status of window
    SetEnabled( IsWindowEnabled( GetHandle() ));
}// End ExtractWindowDetails
Example #8
0
 gcc_pure
 GeoPoint GetMapCenter() const {
   return GetBounds().GetCenter();
 }
Example #9
0
void gxViewElement::SetSize( const gxSize& aNewSize )
{
    gxRect iBounds = GetBounds();
    iBounds.SetSize( aNewSize );
    SetBounds( iBounds );
}
Example #10
0
void gxViewElement::SetSize( const gxPix aNewSize, bool aOnMajorAxis )
{
    gxRect iBounds = GetBounds();
    iBounds.SetSize( aNewSize, aOnMajorAxis );
    SetBounds( iBounds );
}
Example #11
0
void gxViewElement::Transform( gxRect& aRect )
{
    aRect += GetBounds().GetPosition();
}
Example #12
0
void gxViewElement::SetPosition( const gxPix aNewPosition, bool aOnMajorAxis )
{
    gxRect iBounds = GetBounds();
    iBounds.SetPosition( aNewPosition, aOnMajorAxis );
    SetBounds( iBounds );
}
Example #13
0
void gxViewElement::SetPosition( const gxPoint& aNewPosition )
{
    gxRect iBounds = GetBounds();
    iBounds.SetPosition( aNewPosition );
    SetBounds( iBounds );
}
void FGeometryCacheSceneProxy::GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const
{
	SCOPE_CYCLE_COUNTER(STAT_GeometryCacheSceneProxy_GetMeshElements);

	// Set up wireframe material (if needed)
	const bool bWireframe = AllowDebugViewmodes() && ViewFamily.EngineShowFlags.Wireframe;

	FColoredMaterialRenderProxy* WireframeMaterialInstance = NULL;
	if (bWireframe)
	{
		WireframeMaterialInstance = new FColoredMaterialRenderProxy(
			GEngine->WireframeMaterial ? GEngine->WireframeMaterial->GetRenderProxy(IsSelected()) : NULL,
			FLinearColor(0, 0.5f, 1.f)
			);

		Collector.RegisterOneFrameMaterialProxy(WireframeMaterialInstance);
	}
	
	// Iterate over sections	
	for (const FGeomCacheTrackProxy* TrackProxy : Sections )
	{
		// QQQ
		if (TrackProxy != nullptr)
		{
			INC_DWORD_STAT_BY(STAT_GeometryCacheSceneProxy_MeshBatchCount, TrackProxy->MeshData->BatchesInfo.Num());

			int32 BatchIndex = 0;
			for (FGeometryCacheMeshBatchInfo& BatchInfo : TrackProxy->MeshData->BatchesInfo)
			{
				FMaterialRenderProxy* MaterialProxy = bWireframe ? WireframeMaterialInstance : TrackProxy->Materials[BatchIndex]->GetRenderProxy(IsSelected());

				for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
				{
					if (VisibilityMap & (1 << ViewIndex))
					{
						const FSceneView* View = Views[ViewIndex];
						// Draw the mesh.
						FMeshBatch& Mesh = Collector.AllocateMesh();
						FMeshBatchElement& BatchElement = Mesh.Elements[0];
						BatchElement.IndexBuffer = &TrackProxy->IndexBuffer;
						Mesh.bWireframe = bWireframe;
						Mesh.VertexFactory = &TrackProxy->VertexFactory;
						Mesh.MaterialRenderProxy = MaterialProxy;
						BatchElement.PrimitiveUniformBuffer = CreatePrimitiveUniformBufferImmediate(TrackProxy->WorldMatrix * GetLocalToWorld(), GetBounds(), GetLocalBounds(), true, UseEditorDepthTest());
						BatchElement.FirstIndex = BatchInfo.StartIndex;
						BatchElement.NumPrimitives = BatchInfo.NumTriangles;
						BatchElement.MinVertexIndex = 0;
						BatchElement.MaxVertexIndex = TrackProxy->VertexBuffer.Vertices.Num() - 1;
						Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative();
						Mesh.Type = PT_TriangleList;
						Mesh.DepthPriorityGroup = SDPG_World;
						Mesh.bCanApplyViewModeOverrides = false;
						Collector.AddMesh(ViewIndex, Mesh);

						INC_DWORD_STAT_BY(STAT_GeometryCacheSceneProxy_TriangleCount, BatchElement.NumPrimitives);
					}
				}

				++BatchIndex;
			}			
		}
		
	}

	// Draw bounds
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
	for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
	{
		if (VisibilityMap & (1 << ViewIndex))
		{
			// Render bounds
			RenderBounds(Collector.GetPDI(ViewIndex), ViewFamily.EngineShowFlags, GetBounds(), IsSelected());
		}
	}
#endif
}
void FPaperTileMapRenderSceneProxy::GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const
{
	SCOPE_CYCLE_COUNTER(STAT_TileMap_GetDynamicMeshElements);
	checkSlow(IsInRenderingThread());

	for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
	{
		SCOPE_CYCLE_COUNTER(STAT_TileMap_EditorWireDrawing);

		if (VisibilityMap & (1 << ViewIndex))
		{
			const FSceneView* View = Views[ViewIndex];
			FPrimitiveDrawInterface* PDI = Collector.GetPDI(ViewIndex);

			// Draw the tile maps
			//@TODO: RenderThread race condition
			if (TileMap != nullptr)
			{
				if ((View->Family->EngineShowFlags.Collision /*@TODO: && bIsCollisionEnabled*/) && AllowDebugViewmodes())
				{
					if (UBodySetup2D* BodySetup2D = Cast<UBodySetup2D>(TileMap->BodySetup))
					{
						//@TODO: Draw 2D debugging geometry
					}
					else if (UBodySetup* BodySetup = TileMap->BodySetup)
					{
						if (FMath::Abs(GetLocalToWorld().Determinant()) < SMALL_NUMBER)
						{
							// Catch this here or otherwise GeomTransform below will assert
							// This spams so commented out
							//UE_LOG(LogStaticMesh, Log, TEXT("Zero scaling not supported (%s)"), *StaticMesh->GetPathName());
						}
						else
						{
							// Make a material for drawing solid collision stuff
							const UMaterial* LevelColorationMaterial = View->Family->EngineShowFlags.Lighting
								? GEngine->ShadedLevelColorationLitMaterial : GEngine->ShadedLevelColorationUnlitMaterial;

							auto CollisionMaterialInstance = new FColoredMaterialRenderProxy(
								LevelColorationMaterial->GetRenderProxy(IsSelected(), IsHovered()),
								WireframeColor
								);

							// Draw the static mesh's body setup.

							// Get transform without scaling.
							FTransform GeomTransform(GetLocalToWorld());

							// In old wireframe collision mode, always draw the wireframe highlighted (selected or not).
							bool bDrawWireSelected = IsSelected();
							if (View->Family->EngineShowFlags.Collision)
							{
								bDrawWireSelected = true;
							}

							// Differentiate the color based on bBlockNonZeroExtent.  Helps greatly with skimming a level for optimization opportunities.
							FColor CollisionColor = FColor(157, 149, 223, 255);

							const bool bPerHullColor = false;
							const bool bDrawSimpleSolid = false;
							BodySetup->AggGeom.GetAggGeom(GeomTransform, GetSelectionColor(CollisionColor, bDrawWireSelected, IsHovered()).ToFColor(true), CollisionMaterialInstance, bPerHullColor, bDrawSimpleSolid, UseEditorDepthTest(), ViewIndex, Collector);
						}
					}
				}

				// Draw the bounds
				RenderBounds(PDI, View->Family->EngineShowFlags, GetBounds(), IsSelected());

#if WITH_EDITOR
				const bool bShowAsSelected = IsSelected();
				const bool bEffectivelySelected = bShowAsSelected || IsHovered();

				const uint8 DPG = SDPG_Foreground;//GetDepthPriorityGroup(View);

				// Draw separation wires if selected
				const FLinearColor OverrideColor = GetSelectionColor(FLinearColor::White, bShowAsSelected, IsHovered(), /*bUseOverlayIntensity=*/ false);

				// Draw the debug outline
				if (bEffectivelySelected)
				{
					const int32 SelectedLayerIndex = (OnlyLayerIndex != INDEX_NONE) ? OnlyLayerIndex : TileMap->SelectedLayerIndex;

					if (bShowPerLayerGrid)
					{
						if (OnlyLayerIndex == INDEX_NONE)
						{
							// Draw a bound for every layer but the selected one (and even that one if the per-tile grid is off)
							for (int32 LayerIndex = 0; LayerIndex < TileMap->TileLayers.Num(); ++LayerIndex)
							{
								if ((LayerIndex != SelectedLayerIndex) || !bShowPerTileGrid)
								{
									DrawBoundsForLayer(PDI, OverrideColor, LayerIndex);
								}
							}
						}
						else if (!bShowPerTileGrid)
						{
							DrawBoundsForLayer(PDI, OverrideColor, OnlyLayerIndex);
						}
					}

					if (bShowPerTileGrid && (SelectedLayerIndex != INDEX_NONE))
					{
						switch (TileMap->ProjectionMode)
						{
						default:
						case ETileMapProjectionMode::Orthogonal:
						case ETileMapProjectionMode::IsometricDiamond:
							DrawNormalGridLines(PDI, OverrideColor, SelectedLayerIndex);
							break;
						case ETileMapProjectionMode::IsometricStaggered:
							DrawStaggeredGridLines(PDI, OverrideColor, SelectedLayerIndex);
							break;
						case ETileMapProjectionMode::HexagonalStaggered:
							DrawHexagonalGridLines(PDI, OverrideColor, SelectedLayerIndex);
							break;
						}
					}
				}
				else if (View->Family->EngineShowFlags.Grid && bShowOutlineWhenUnselected)
				{
					// Draw a layer rectangle even when not selected, so you can see where the tile map is in the editor
					DrawBoundsForLayer(PDI, WireframeColor, /*LayerIndex=*/ (OnlyLayerIndex != INDEX_NONE) ? OnlyLayerIndex : 0);
				}
#endif
			}
		}
	}

	// Draw all of the queued up sprites
	FPaperRenderSceneProxy::GetDynamicMeshElements(Views, ViewFamily, VisibilityMap, Collector);
}
Example #16
0
 gcc_pure
 bool IsInside(const GeoPoint &pt) const {
   return GetBounds().IsInside(pt);
 }
// 窗口事件处理
Boolean TUserInfoDetailForm::EventHandler(TApplication * pApp, EventType * pEvent)
{
	Boolean bHandled = FALSE;

	switch (pEvent->eType)
	{
	case EVENT_WinInit:
		{
			_OnWinInitEvent(pApp, pEvent);
			bHandled = TRUE;
			break;
		}

	case EVENT_WinClose:
		{
			_OnWinClose(pApp, pEvent);
			break;
		}
	case EVENT_WinEraseClient:
		{
			TDC 	   dc(this);
			WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent );
			TRectangle rc(pEraseEvent->rc);
			TRectangle rcBack(5, 142, 310, 314);
			GetBounds(&rcBack);

			// 擦除
			dc.EraseRectangle(&rc, 0);

			dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT);

			//dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-44, 
			//320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); 


			pEraseEvent->result = 1;				
			bHandled = TRUE;
		}
		break;
	case EVENT_CtrlSelect:
		{
			bHandled = _OnCtrlSelectEvent(pApp, pEvent);
			break;
		}
		//下载完成消息
	case MSG_DL_THREAD_NOTIFY:
		{
			NotifyMsgDataType notifyData;
			Sys_GetMessageBody((MESSAGE_t *)pEvent, &notifyData, sizeof(NotifyMsgDataType));

			switch(notifyData.nAccessType)
			{
			case KX_PhotoDownload:
				{
					if(pPhotoBmp != NULL)
					{
						pPhotoBmp->Destroy();
						pPhotoBmp = NULL;
					}

					TBitmap* pDownLoadBitmap = NULL;
					pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath);

					TMaskButton* pHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton));
					if(pDownLoadBitmap)
					{
						TRectangle rc;		
						pHeadMBtn->GetBounds(&rc);

						pPhotoBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth());
						pPhotoBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));	
			
						pHeadMBtn->SetImage(pPhotoBmp,(rc.Width()-pPhotoBmp->GetWidth())/2, (rc.Height()-pPhotoBmp->GetHeight())/2);		
						pHeadMBtn->Draw();

						//释放图片
						pDownLoadBitmap->Destroy();
						pDownLoadBitmap = NULL;						
					}

					break;
				}
			default:
				break;
			}
			bHandled = TRUE;
			break;			
		}
	case EVENT_KeyCommand: 
		{ 
			// 抓取右软键事件 
			if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP  
				|| pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) 
			{ 
				// 模拟退出按钮选中消息 
				HitControl(m_BackBtn); 
				bHandled = TRUE; 
			} 
		} 
		break;
	default:
		break;
	}

	if (!bHandled)
	{
		bHandled = TWindow::EventHandler(pApp, pEvent);
	}

	return bHandled;
}
Example #18
0
void Graphic::Align (Alignment falign, Graphic* moved, Alignment malign) {
    float fx0, fy0, fx1, fy1, mx0, my0, mx1, my1, dx = 0, dy = 0;

    GetBounds(fx0, fy0, fx1, fy1);
    moved->GetBounds(mx0, my0, mx1, my1);
    
    switch (falign) {
	case BottomLeft:
	case CenterLeft:
	case TopLeft:
	case Left:
	    dx = fx0;
	    break;
	case BottomCenter:
	case Center:
	case TopCenter:
	case HorizCenter:
	    dx = (fx0 + fx1 + 1)/2;
	    break;
	case BottomRight:
	case CenterRight:
	case TopRight:
	case Right:
	    dx = fx1 + 1;
	    break;
    }
    switch (falign) {
	case BottomLeft:
	case BottomCenter:
	case BottomRight:
	case Bottom:
	    dy = fy0;
	    break;
	case CenterLeft:
	case Center:
	case CenterRight:
	case VertCenter:
	    dy = (fy0 + fy1 + 1)/2;
	    break;
	case TopLeft:
	case TopCenter:
	case TopRight:
	case Top:
	    dy = fy1 + 1;
	    break;
    }
    
    switch (malign) {
	case BottomLeft:
	case CenterLeft:
	case TopLeft:
	case Left:
	    dx -= mx0;
	    break;	
	case BottomCenter:
	case Center:
	case TopCenter:
	case HorizCenter:
	    dx -= (mx0 + mx1 + 1)/2;
	    break;
	case BottomRight:
	case CenterRight:
	case TopRight:
	case Right:
	    dx -= (mx1 + 1);
	    break;
    }
    switch (malign) {
	case BottomLeft:
	case BottomCenter:
	case BottomRight:
	case Bottom:
	    dy -= my0;
	    break;
	case CenterLeft:
	case Center:
	case CenterRight:
	case VertCenter:
	    dy -= (my0 + my1 + 1)/2;
	    break;
	case TopLeft:
	case TopCenter:
	case TopRight:
	case Top:
	    dy -= (my1 + 1);
	    break;
    }
    if (dx != 0 || dy != 0) {
        Transformer parents;
	moved->parentXform(parents);

        parents.Invert();
	parents.Transform(0.0, 0.0, fx0, fy0);
	parents.Transform(dx, dy, mx0, my0);

	moved->Translate(mx0-fx0, my0-fy0);
    }
}
Example #19
0
OutboundView::OutboundView( Rect cFrame, Identity *pcIdentity, Handler *pcMainWindow ) : SettingsView( cFrame, "outbound", pcIdentity )
{
	m_pcIdentity = pcIdentity;

	Server cOutboundServer;
	bool bOutboundValid = false;
	if( m_pcIdentity->GetServer( cOutboundServer, SERVER_OUTBOUND, 0 ) == EOK )
		bOutboundValid = true;

	const uint32 nInputLabelWidth = 90;
	Rect cBounds = GetBounds();

	m_pcOutboundView = new View( cBounds, "outbound_view", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );

	Rect cInputFrame = cBounds;
	cInputFrame.top = 5;
	cInputFrame.bottom = cInputFrame.top + INPUT_HEIGHT;

	/* Server */
	m_pcServerInput = new InputView( cInputFrame, MSG_CFGWND_SENDINGEMAIL_SETTINGS_SMTPSERVER, nInputLabelWidth );
	if( bOutboundValid )
		m_pcServerInput->SetText( cOutboundServer.GetServer() );
	m_pcOutboundView->AddChild( m_pcServerInput );

	/* Does this SMTP server require a authentication? */
	Rect cAuthFrame = cBounds;
	cAuthFrame.top = cInputFrame.bottom + 5;
	cAuthFrame.bottom = cAuthFrame.top + INPUT_HEIGHT;

	m_pcRequiresAuth = new CheckBox( cAuthFrame, "outbound_auth1", MSG_CFGWND_SENDINGEMAIL_SETTINGS_REQUIRESAUTH, new Message( ID_REQUIRES_AUTH ) );
	cAuthFrame.right = m_pcRequiresAuth->GetPreferredSize( false ).x;
	m_pcRequiresAuth->SetFrame( cAuthFrame );
	m_pcOutboundView->AddChild( m_pcRequiresAuth );

	/* Username */
	cInputFrame.top = cAuthFrame.bottom + 5;
	cInputFrame.bottom = cInputFrame.top + INPUT_HEIGHT;
	m_pcUsernameInput = new InputView( cInputFrame, MSG_CFGWND_SENDINGEMAIL_SETTINGS_USERNAME, nInputLabelWidth );
	m_pcOutboundView->AddChild( m_pcUsernameInput );

	/* Password */
	cInputFrame.top = cInputFrame.bottom + 5;
	cInputFrame.bottom = cInputFrame.top + INPUT_HEIGHT;
	m_pcPasswordInput = new InputView( cInputFrame, MSG_CFGWND_SENDINGEMAIL_SETTINGS_PASSWORD, nInputLabelWidth );
	m_pcPasswordInput->SetPasswordMode();
	m_pcOutboundView->AddChild( m_pcPasswordInput );

	Rect cPortFrame = cBounds;
	cPortFrame.top = cInputFrame.bottom + 5;
	cPortFrame.bottom = cPortFrame.top + INPUT_HEIGHT;

	StringView *pcPortLabel = new StringView( cPortFrame, "outbound_port_label", MSG_CFGWND_SENDINGEMAIL_SETTINGS_SRVERPORT );
	cPortFrame.right = pcPortLabel->GetPreferredSize( false ).x;
	pcPortLabel->SetFrame( cPortFrame );
	m_pcOutboundView->AddChild( pcPortLabel );

	cPortFrame.left = cPortFrame.right + 5;
	cPortFrame.right = cBounds.right - 5;

	m_pcPort = new Spinner( cPortFrame, "outbound_port", 25, NULL );
	if( bOutboundValid )
		m_pcPort->SetValue( cOutboundServer.GetPort() );
	m_pcPort->SetMinValue( 1 );
	m_pcPort->SetMaxValue( 65535 );
	m_pcPort->SetStep( 1.0 );
	m_pcPort->SetFormat( "%.0f" );

	/* XXXKV: Spinner doesn't produce a usable width */
	//cPortFrame.right = cPortFrame.left + m_pcPort->GetPreferredSize( false ).x + 1;
	cPortFrame.right = cPortFrame.left + 70;
	cPortFrame.bottom = cPortFrame.top + m_pcPort->GetPreferredSize( false ).y + 1;
	m_pcPort->SetFrame( cPortFrame );
	m_pcOutboundView->AddChild( m_pcPort );

	cAuthFrame = cBounds;
	cAuthFrame.top = cPortFrame.bottom + 5;
	cAuthFrame.bottom = cAuthFrame.top + INPUT_HEIGHT;

	m_pcPopBeforeSmtp = new CheckBox( cAuthFrame, "outbound_auth2", MSG_CFGWND_SENDINGEMAIL_SETTINGS_POPBEFORESMTP, new Message( ID_POP3_AUTH ) );
	cAuthFrame.right = m_pcPopBeforeSmtp->GetPreferredSize( false ).x;
	m_pcPopBeforeSmtp->SetFrame( cAuthFrame );
	m_pcOutboundView->AddChild( m_pcPopBeforeSmtp );

	cAuthFrame.top = cAuthFrame.bottom + 5;
	cAuthFrame.bottom += INPUT_HEIGHT;

	StringView *pcAuthLabel = new StringView( cAuthFrame, "outbound_auth_label", MSG_CFGWND_SENDINGEMAIL_SETTINGS_SMTPAUTH );
	cAuthFrame.right = pcAuthLabel->GetPreferredSize( false ).x;
	pcAuthLabel->SetFrame( cAuthFrame );
	m_pcOutboundView->AddChild( pcAuthLabel );

	cAuthFrame.left = cAuthFrame.right + 5;
	cAuthFrame.right = cBounds.right - 5;

	m_pcPop3Account = new DropdownMenu( cAuthFrame, "outbound_pop3_auth_instance", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT );
	m_pcPop3Account->SetTabOrder( NEXT_TAB_ORDER );

	cAuthFrame.bottom = cAuthFrame.top + m_pcPop3Account->GetPreferredSize( false ).y + 1;
	m_pcPop3Account->SetFrame( cAuthFrame );

	int i = 0;
	Server cInboundServer;
	while( m_pcIdentity->GetServer( cInboundServer, SERVER_INBOUND, i++ ) == EOK )
		m_pcPop3Account->AppendItem( cInboundServer.GetServer() );

	m_pcOutboundView->AddChild( m_pcPop3Account );

	if( bOutboundValid && cOutboundServer.GetFlags() & AUTH_SMTP )
	{
		m_pcRequiresAuth->SetValue( true );
		m_pcUsernameInput->SetEnable( true );
		m_pcUsernameInput->SetText( cOutboundServer.GetUsername() );
		m_pcPasswordInput->SetEnable( true );
		m_pcPasswordInput->SetText( cOutboundServer.GetPassword() );
	}
	else
	{
		m_pcRequiresAuth->SetValue( false );
		m_pcUsernameInput->SetEnable( false );
		m_pcPasswordInput->SetEnable( false );
	}

	if( bOutboundValid && cOutboundServer.GetFlags() & AUTH_POP3_BEFORE )
	{
		m_pcPopBeforeSmtp->SetValue( true );
		m_pcPop3Account->SetEnable( true );
		m_pcPop3Account->SetSelection( cOutboundServer.GetData().AsInt32() );
	}
	else
	{
		m_pcPopBeforeSmtp->SetValue( false );
		m_pcPop3Account->SetEnable( false );
	}

	AddChild( m_pcOutboundView );
}
Example #20
0
void nsRegion::SimplifyOutwardByArea(uint32_t aThreshold)
{

  pixman_box32_t *boxes;
  int n;
  boxes = pixman_region32_rectangles(&mImpl, &n);

  // if we have no rectangles then we're done
  if (!n)
    return;

  pixman_box32_t *end = boxes + n;
  pixman_box32_t *topRectsEnd = boxes+1;
  pixman_box32_t *topRects = boxes;

  // we need some temporary storage for merging both rows of rectangles
  nsAutoTArray<pixman_box32_t, 10> tmpStorage;
  tmpStorage.SetCapacity(n);
  pixman_box32_t *tmpRect = tmpStorage.Elements();

  pixman_box32_t *destRect = boxes;
  pixman_box32_t *rect = tmpRect;
  // find the end of the first span of rectangles
  while (topRectsEnd < end && topRectsEnd->y1 == topRects->y1) {
    topRectsEnd++;
  }

  // if we only have one row we are done
  if (topRectsEnd == end)
    return;

  pixman_box32_t *bottomRects = topRectsEnd;
  pixman_box32_t *bottomRectsEnd = bottomRects+1;
  do {
    // find the end of the bottom span of rectangles
    while (bottomRectsEnd < end && bottomRectsEnd->y1 == bottomRects->y1) {
      bottomRectsEnd++;
    }
    uint32_t totalArea = ComputeMergedAreaIncrease(topRects, topRectsEnd,
                                                   bottomRects, bottomRectsEnd);

    if (totalArea <= aThreshold) {
      // merge the rects into tmpRect
      rect = MergeRects(topRects, topRectsEnd, bottomRects, bottomRectsEnd, tmpRect);

      // set topRects to where the newly merged rects will be so that we use them
      // as our next set of topRects
      topRects = destRect;
      // copy the merged rects back into the destination
      topRectsEnd = CopyRow(destRect, tmpRect, rect);
    } else {
      // copy the unmerged rects
      destRect = CopyRow(destRect, topRects, topRectsEnd);

      topRects = bottomRects;
      topRectsEnd = bottomRectsEnd;
      if (bottomRectsEnd == end) {
        // copy the last row when we are done
        topRectsEnd = CopyRow(destRect, topRects, topRectsEnd);
      }
    }
    bottomRects = bottomRectsEnd;
  } while (bottomRectsEnd != end);


  uint32_t reducedCount = topRectsEnd - pixman_region32_rectangles(&this->mImpl, &n);
  // pixman has a special representation for
  // regions of 1 rectangle. So just use the
  // bounds in that case
  if (reducedCount > 1) {
    // reach into pixman and lower the number
    // of rects stored in data.
    this->mImpl.data->numRects = reducedCount;
  } else {
    *this = GetBounds();
  }
}
Example #21
0
Rect4i WindowWorld::GetCameraBounds() const
{
    return m_world ? m_world->GetCamera()->Frame(GetBounds()) : Rect4i();
}