예제 #1
0
void GUIWindow::SetMinimized(bool minimized)
{
	m_bMinimized = minimized;

	if(m_bMinimized)
	{
		// Hide all our children components when we are minimized
		ComponentList::const_iterator iterator;

		for(iterator = m_vpComponentList.begin(); iterator != m_vpComponentList.end(); ++iterator)
		{
			(*iterator)->SetVisible(false);
			(*iterator)->SetEnabled(false);
		}
	}
	else
	{
		// Else show all our children components
		ComponentList::const_iterator iterator;

		for(iterator = m_vpComponentList.begin(); iterator != m_vpComponentList.end(); ++iterator)
		{
			(*iterator)->SetVisible(true);
			(*iterator)->SetEnabled(true);
		}
	}

	m_titleBar->SetVisible(true);
	m_titleBar->SetEnabled(true);

	SetLocation(GetLocation().m_x, GetLocation().m_y);
}
예제 #2
0
bool RoboCat::MoveToLocation( float inDeltaTime, const Vector3& inLocation )
{
	bool finishedMove = false;

	Vector3 toMoveVec = inLocation - GetLocation();
	float distToTarget = toMoveVec.Length();
	toMoveVec.Normalize2D();
	if( distToTarget > 0.1f )
	{
		if ( distToTarget > ( kMoveSpeed * inDeltaTime ) )
		{
			SetLocation( GetLocation() + toMoveVec * inDeltaTime * kMoveSpeed );
		}
		else
		{
			//we're basically almost there, so set it to move location
			SetLocation( inLocation );
			finishedMove = true;
		}
	}
	else
	{
		//since we're close, stop moving towards the target
		finishedMove = true;
	}

	return finishedMove;
}
예제 #3
0
void TextBox::RenderImpl()
{
    // create a buffer around the text
    auto location = GetLocation();
    location.x += TextOffsetX;

    // vertically center the text in the bounding rect
    location.y += (location.h - m_texture.GetHeight()) / 2;
    
    if (m_texture.GetHeight() <= location.h)
        location.h = m_texture.GetHeight();
    else
        assert(!"Font size is too tall for text box.");

    // if the text width is greater than the width of the text box the
    // text width will need to be clipped with respect to the position

    location.w -= (TextOffsetX * 2);
    SDL_Rect clip;

    clip.x = m_clipOffset;
    clip.y = 0;
    clip.h = location.h;
    clip.w = GetLocation().w - (TextOffsetX * 2);

    // if the portion of the texture being displayed doesn't completely fill
    // the location's width decrease the width so the texture isn't stretched

    auto deltaWidth = (clip.w - (m_texture.GetWidth() - m_clipOffset));
    if (deltaWidth > 0)
        location.w -= deltaWidth;

    GetWindow()->DrawRectangle(GetLocation(), GetBackgroundColor(), UINT8_MAX);
    GetWindow()->DrawTexture(location, m_texture, &clip);
}
예제 #4
0
bool King::LookNorth()
{
	Location temp = GetLocation();
	temp.MoveY(-1);

	return GetLocation().IsWall(temp.GetCoordinates(), GetMaze());
};
예제 #5
0
void CardButton::RecalculateHeldDestination()
{
    held_destination.x=GetLocation().x+GetLocation().w/4;
    held_destination.y= GetLocation().y;
    held_destination.w=GetLocation().w/2;
    held_destination.h=GetLocation().h/14;
}
예제 #6
0
void RoboCatServer::Update()
{
	RoboCat::Update();
	
	Vector3 oldLocation = GetLocation();
	Vector3 oldVelocity = GetVelocity();
	float oldRotation = GetRotation();

	ClientProxyPtr client = NetworkManagerServer::sInstance->GetClientProxy( GetPlayerId() );
	if( client )
	{
		MoveList& moveList = client->GetUnprocessedMoveList();
		for( const Move& unprocessedMove : moveList )
		{
			const InputState& currentState = unprocessedMove.GetInputState();
			float deltaTime = unprocessedMove.GetDeltaTime();
			ProcessInput( deltaTime, currentState );
			SimulateMovement( deltaTime );
		}

		moveList.Clear();
	}

	HandleShooting();

	if( !RoboMath::Is2DVectorEqual( oldLocation, GetLocation() ) ||
		!RoboMath::Is2DVectorEqual( oldVelocity, GetVelocity() ) ||
		oldRotation != GetRotation() )
	{
		NetworkManagerServer::sInstance->SetStateDirty( GetNetworkId(), ECRS_Pose );
	}
}
예제 #7
0
SampledTaskPoint::SampledTaskPoint(TaskPointType _type, const Waypoint & wp,
                                   const bool b_scored)
  :TaskWaypoint(_type, wp),
   boundary_scored(b_scored),
   search_max(GetLocation()),
   search_min(GetLocation()),
   search_reference(GetLocation())
{
  nominal_points.push_back(search_reference);
}
예제 #8
0
void WorldGen::Mapper::Generate()
{
	int u = rand() % Width_;
	int v = rand() % Height_;

	Data[ u ][ v ] = GUILTY;
	int z = 1;
	while ( UnsetLocationExists() )
	{
		Pair p = GetUnsetPair();
		Data[ p.X_ ][ p.Y_ ] = LOCKED;
		int match = UnusedColumn( p.Y_ );
		if ( match == -1 )
		{
			 int column = GetRandomSetColumn( p.Y_ );
			 Data[ p.X_ ][ p.Y_ ] = Data[ column ][ p.Y_ ];
		}
		else
		{
			int sameRoom = rand() % 2;
			int newVal = UNUSED;
			if ( sameRoom == 1 )
			{
				int newY1 = UNUSED;
				int newY2 = UNUSED;
				if ( p.Y_ > 0 )
				{
					newY1 = GetLocation( p.X_ , p.Y_ - 1 );
				}
				if ( p.Y_ < Height_ - 1 )
				{
					newY2 = GetLocation( p.X_, p.Y_ + 1 );
				}
				if ( ( newY1 > UNUSED ) && ( newY2 > UNUSED ) )
				{
					newVal = (rand() % 2 == 0) ? newY1 : newY2;
				}
				else if ( newY1 > UNUSED )
					newVal = newY1;
				else if ( newY2 > UNUSED )
					newVal = newY2;
			}
			if ( ( sameRoom == 0 ) || ( newVal == UNUSED ) )
			{
				newVal = z;
				++z;
			}
			Data[ p.X_ ][ p.Y_ ] = newVal;
			Data[ match ][ p.Y_ ] = newVal;
		}
	}
}
예제 #9
0
void
PrintHelper::contestmanager_print(const ContestManager &man,
                                  const Trace &trace_full,
                                  const Trace &trace_triangle,
                                  const Trace &trace_sprint)
{
  Directory::Create(_T("output/results"));

  {
    std::ofstream fs("output/results/res-olc-trace.txt");
    TracePointVector v;
    trace_full.GetPoints(v);

    for (auto it = v.begin(); it != v.end(); ++it)
      fs << it->GetLocation().longitude << " " << it->GetLocation().latitude
         << " " << it->GetAltitude() << " " << it->GetTime()
         << "\n";
  }

  {
    std::ofstream fs("output/results/res-olc-trace_triangle.txt");

    TracePointVector v;
    trace_triangle.GetPoints(v);

    for (auto it = v.begin(); it != v.end(); ++it)
      fs << it->GetLocation().longitude << " " << it->GetLocation().latitude
         << " " << it->GetAltitude() << " " << it->GetTime()
         << "\n";
  }

  {
    std::ofstream fs("output/results/res-olc-trace_sprint.txt");

    TracePointVector v;
    trace_sprint.GetPoints(v);

    for (auto it = v.begin(); it != v.end(); ++it)
      fs << it->GetLocation().longitude << " " << it->GetLocation().latitude
         << " " << it->GetAltitude() << " " << it->GetTime()
         << "\n";
  }

  std::ofstream fs("output/results/res-olc-solution.txt");

  if (man.stats.solution[0].empty()) {
    fs << "# no solution\n";
    return;
  }

  if (positive(man.stats.result[0].time)) {

    for (auto it = man.stats.solution[0].begin();
         it != man.stats.solution[0].end(); ++it) {
      fs << it->GetLocation().longitude << " " << it->GetLocation().latitude
         << " " << it->GetTime()
         << "\n";
    }
  }
}
예제 #10
0
void Entity::BuildAdjCross()
{
    adjFields.clear();
    adjFields.push_back({ GetLocation().x - 1, GetLocation().y });
    adjFields.push_back({ GetLocation().x + 1, GetLocation().y });
    adjFields.push_back({ GetLocation().x, GetLocation().y - 1 });
    adjFields.push_back({ GetLocation().x, GetLocation().y + 1 });
}
예제 #11
0
Variant WebBrowserObject::pget_Location(void)
{
    char *str = GetLocation();
    Variant v = anytovariant(str ? str : "");
    lmbox_free(str);
    return v;
}
예제 #12
0
// eats where it stands
// return value is not used
bool Rabbit::Eat()
{
    Grass* grassUnderMyFeet = World::GetWorld()->GetGrass(GetLocation());

    // check for wheat
    if (grassUnderMyFeet->HasWheat())
        metabolism.AddFood(grassUnderMyFeet->EatWheat());

    // make sure not to eat more than there is and no more than 5
    int food = grassUnderMyFeet->GetFoodLevel();
    if (food > 5)
        food = 5;

    // extra 1 for every 20 levels
    food += grassUnderMyFeet->GetFoodLevel() / 20;

    // dont eat more than you can
    if (metabolism.UntilFull() < food)
        food = metabolism.UntilFull();

    metabolism.AddFood(food);
    grassUnderMyFeet->SubFood(food);

	return true;
}
void CPMInternalTextPart::Draw(CDC* pDC, Gdiplus::Graphics* gdip)
{
	if (m_bTextEnabled) {
		CRect loc = GetLocation();
		DecoratorSDK::GdipFont* pFont = DecoratorSDK::getFacilities().GetFont(m_iFontKey);
		CSize size = GetTextSize(gdip, pFont);
		if (m_strText.GetLength())
		{
			DecoratorSDK::getFacilities().DrawString(gdip,
									   m_strText,
									   CRect(loc.left + m_textRelXPosition, loc.top + m_textRelYPosition - size.cy,
											 loc.right + m_textRelXPosition, loc.top + m_textRelYPosition),
									   pFont,
									   (m_bActive) ? m_crText : DecoratorSDK::COLOR_GREY,
									   TA_BOTTOM | TA_LEFT,
									   INT_MAX,
									   "",
									   "",
									   false);
		}
		else
		{
			DecoratorSDK::getFacilities().DrawRect(gdip, CRect(loc.left + m_textRelXPosition + 3 , loc.top + m_textRelYPosition - size.cy,
											 loc.left + m_textRelXPosition + size.cx - 3 - 1, loc.top + m_textRelYPosition - 1), DecoratorSDK::COLOR_GREY, 1);
		}
	}
	if (m_spFCO)
		resizeLogic.Draw(pDC, gdip);
}
예제 #14
0
static void
GetPolygonPoints(std::vector<RasterPoint> &pts,
                 const AirspacePolygon &airspace,
                 const RasterPoint pt, unsigned radius)
{
  GeoBounds bounds = airspace.GetGeoBounds();
  GeoPoint center = bounds.GetCenter();

  fixed geo_heigth = bounds.GetGeoHeight();
  fixed geo_width = bounds.GetGeoWidth();

  fixed geo_size = std::max(geo_heigth, geo_width);

  WindowProjection projection;
  projection.SetScreenSize({radius * 2, radius * 2});
  projection.SetScreenOrigin(pt.x, pt.y);
  projection.SetGeoLocation(center);
  projection.SetScale(fixed(radius * 2) / geo_size);
  projection.SetScreenAngle(Angle::Zero());
  projection.UpdateScreenBounds();

  const SearchPointVector &border = airspace.GetPoints();

  pts.reserve(border.size());
  for (auto it = border.begin(), it_end = border.end(); it != it_end; ++it)
    pts.push_back(projection.GeoToScreen(it->GetLocation()));
}
예제 #15
0
파일: MapCanvas.cpp 프로젝트: Advi42/XCSoar
void
MapCanvas::Project(const Projection &projection,
                   const SearchPointVector &points, BulkPixelPoint *screen)
{
  for (auto it = points.begin(); it != points.end(); ++it)
    *screen++ = projection.GeoToScreen(it->GetLocation());
}
예제 #16
0
TextPointer *
TextPointer::GetPositionAtOffset (int offset, LogicalDirection dir) const
{
	PositionAtOffsetIterator iter ((TextElement*)GetParent(), GetLocation(), GetLogicalDirection());

	return iter.GetTextPointer (offset, dir);
}
예제 #17
0
// Camera update function
void CameraObject::Update(float dT)
{
	bool bUpdateViewProj = false;

	if(bTransformDirty)
	{
		Matrix4x4::ConstructLookAtMatrix(&cachedViewMatrix, GetLocation(), GetOrientationQuat());
		bTransformDirty = false;
		bUpdateViewProj = true;
	}

	if(bProjectionDirty)
	{
		switch(projectionType)
		{
		case CameraObject::CLT_Perspective:	Matrix4x4::ConstructPerspectiveMatrix(&cachedProjectionMatrix, pParams.FOV, pParams.Aspect, pParams.Near, pParams.Far); break;
		case CameraObject::CLT_Orthographic:	Matrix4x4::ConstructOrthographicMatrix(&cachedProjectionMatrix, oParams.Width, oParams.Height, oParams.Near, oParams.Far); break;
		default: assert(false && "Unknown projection type");
		}

		bProjectionDirty = false;
		bUpdateViewProj = true;
	}

	if(bUpdateViewProj)
	{
		cachedViewProjectionMatrix = cachedViewMatrix * cachedProjectionMatrix;
	}
}
예제 #18
0
void Kill(Unit *unit) {
    Player *owner = GetPlayerFromColor(GetUnitColor(*unit));
    DelUnit(owner, unit);
    SetUnit(GetGrid(GetLocation(*unit)), 0);
    DestroyUnit(unit);
    SetUpkeep(owner, GetUpkeep(*owner) - 1);
}
//---------------------------------------------------------------------------
const boost::shared_ptr<Sprite> SimImmuneResponse::GrabSprite(
  const EnumLocation location,
  const int x,
  const int y)
{
  return GetLocation(location)->GrabSprite(x,y);
}
예제 #20
0
void
AATPoint::SetTarget(const fixed range, const fixed radial,
                    const TaskProjection &proj)
{
  fixed oldrange = fixed_zero;
  fixed oldradial = fixed_zero;
  GetTargetRangeRadial(oldrange, oldradial);

  const FlatPoint fprev =
    proj.ProjectFloat(GetPrevious()->GetLocationRemaining());
  const FlatPoint floc = proj.ProjectFloat(GetLocation());
  const FlatLine flb (fprev,floc);
  const FlatLine fradius (floc,proj.ProjectFloat(GetLocationMin()));
  const fixed bearing = fixed_minus_one * flb.angle().Degrees();
  const fixed radius = fradius.d();

  fixed swapquadrants = fixed_zero;
  if (positive(range) != positive(oldrange))
    swapquadrants = fixed(180);
  const FlatPoint ftarget1 (fabs(range) * radius *
        cos((bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi),
      fabs(range) * radius *
        sin( fixed_minus_one * (bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi));

  const FlatPoint ftarget2 = floc + ftarget1;
  const GeoPoint targetG = proj.Unproject(ftarget2);

  SetTarget(targetG, true);
}
예제 #21
0
    char16_t StringBuffer::NextChar() {
        auto current = GetChar();
        if (back_ptr >= 0) {
            back_ptr--;
        } else {
            if (buffer_list.size() == 0) {
                return 0x00;
            }

            auto buf = *buffer_list.begin();
            if (char_ptr + 1 >= buf->size()) { // end of buffer
                buffer_list.pop_front();
                char_ptr = 0;
            } else {
                char_ptr++;
            }

            back_buffer.push_back(
                std::make_pair(current, GetLocation())
            );
            check_back_buffer();
        }

        loc.pos++;
        // check utf 16
        if (current == ch_endofline) {
            loc.line++;
            loc.column = 0;
        } else {
            loc.column++;
        }
        return current;
    }
예제 #22
0
void PlayerServer::Update()
{
    Player::Update();

    Vector3 oldLocation = GetLocation();
    Vector3 oldVelocity = GetVelocity();

    if ( mControlType == PCT_HUMAN )
    {
        ClientProxyPtr client =
            NetworkManagerServer::sInstance->GetClientProxy( GetPlayerId() );

        if ( !client )
        {
            LOG( "NO HUMANC CONTROLING THIS, IT HAS BECOME SENTIENT RUN" );
            return;
        }

        MoveList& moveList = client->GetUnprocessedMoveList();
        for ( const Move& unprocessedMove : moveList )
        {
            const InputState& currentState = unprocessedMove.GetInputState();

            float deltaTime = unprocessedMove.GetDeltaTime();
            ProcessInput( deltaTime, currentState );
            SimulateMovement( TIME_STEP );
        }
        moveList.Clear();

        // TODO: Check if there velocity has actually changed before sending
        // update
        NetworkManagerServer::sInstance->SetStateDirty( GetNetworkId(),
                                                        PRS_POSI );
    }
}
예제 #23
0
void TextBox::MoveCaret(int offset)
{
    auto caretLoc = m_caret.GetLocation();
    caretLoc.x += offset;
    assert(caretLoc.x >= 0);

    // ensure the caret stays within bounds
    // the delta is the number of pixels past the boundary
    // of the text box.  if it's less than offset it means
    // there is part of a char being clipped, so instead of
    // adjusting m_clipOffset by the full offset adjust it
    // by the number of pixels being clipped.

    auto location = GetLocation();
    if (caretLoc.x > (location.x + location.w) - (TextOffsetX + (CaretWidth - 1)))
    {
        // caret tried to move past the right bound, adjust the offset based on the delta
        offset = caretLoc.x - ((location.x + location.w) - (TextOffsetX + (CaretWidth - 1)));
        caretLoc.x = (location.x + location.w) - (TextOffsetX + (CaretWidth - 1));

        m_clipOffset += offset;
    }
    else if (caretLoc.x < location.x + TextOffsetX)
    {
        // caret tried to move past the left bound, adjust the offset based on the delta
        offset = caretLoc.x - (location.x + TextOffsetX);
        caretLoc.x = location.x + TextOffsetX;

        if (m_clipOffset > 0)
            m_clipOffset += offset;
    }

    assert(m_clipOffset >= 0);
    m_caret.SetLocation(caretLoc);
}
예제 #24
0
// Get the player location
//
qboolean GetPlayerLocation (edict_t * self, char *buf)
{
	if (GetLocation((int)self->s.origin[0], (int)self->s.origin[1], (int)self->s.origin[2], 0, buf))
		return true;

	return false;
}
예제 #25
0
void PrintEnemies(Enemies enemies) {
    Unit enemy;
    char stringEnemyClass[11];
    char stringRetaliates[13];
    POINT enemyLocation;

    for (int i = 0; i < enemies.count; ++i) {
        enemy = *enemies.enemy[i].unit;
        UnitClassName(GetUnitClass(enemy), stringEnemyClass);

        if (enemies.enemy[i].canRetaliate) {
            strcpy(stringRetaliates, "(Retaliates)");
        } else {
            strcpy(stringRetaliates, "");
        }

        enemyLocation = GetLocation(enemy);

        printf("%d. %s (%d,%d) | Health %d/%d %s\n", 
            1+i, 
            stringEnemyClass, 
            enemyLocation.X, 
            enemyLocation.Y,
            GetHealth(enemy), 
            GetMaximumHealth(enemy),
            stringRetaliates
        );
    }
}
예제 #26
0
uint32_t TommyCoin::Write( OutgoingPacketBuffer& inPacket, uint32_t inDirtyState ) const 
{

	uint32_t writtenState = 0;

	uint32_t remainingBytes = inPacket.GetRemainingBytes();

	if( remainingBytes >= 3 * sizeof( float ) + sizeof( XMVECTOR ) )
	{
		bool poseDirty = inDirtyState & ETCRS_Pose;
		bool colorDirty = inDirtyState & ETCRS_Color;

		inPacket.Write(poseDirty);
		if (poseDirty) {
			XMVECTORF32 location; location.v = GetLocation();
			inPacket.Write(location.f[0]);
			inPacket.Write(location.f[1]);

			inPacket.Write(GetRotation());
		}

		inPacket.Write(colorDirty);
		if (colorDirty) {
			inPacket.Write(GetColor());
		}

		writtenState |= inDirtyState;
	}

	return writtenState;
}
예제 #27
0
void AttributePart::Draw(CDC* pDC, Gdiplus::Graphics* gdip)
{
	if (m_bTextEnabled) {
		CRect loc = GetLocation();
		DecoratorSDK::GdipFont* pFont = getFacilities().GetFont(m_iFontKey);
		CSize size = getFacilities().MeasureText(gdip, pFont, m_strText);
		getFacilities().DrawString(gdip,
								   m_strText + ATTRIBUTE_SEP,
								   CRect(loc.left + DECORATOR_MARGINX, loc.top + m_textRelYPosition - size.cy,
										 loc.right - DECORATOR_MARGINX, loc.top + m_textRelYPosition),
								   pFont,
								   (m_bActive) ? m_crText : COLOR_GREY,
								   TA_BOTTOM | TA_LEFT,
								   m_iMaxTextLength,
								   "",
								   "",
								   false);
		getFacilities().DrawString(gdip,
								   m_strType,
								   CRect(loc.left + DECORATOR_MARGINX, loc.top + m_textRelYPosition - size.cy,
										 loc.right - DECORATOR_MARGINX, loc.top + m_textRelYPosition),
								   pFont,
								   (m_bActive) ? m_crText : COLOR_GREY,
								   TA_BOTTOM | TA_RIGHT,
								   m_iMaxTextLength,
								   "",
								   "",
								   false);
	}
	if (m_spFCO)
		resizeLogic.Draw(pDC, gdip);
}
예제 #28
0
void Animal::BuildAdjSquare(int edge)
{
    adjFields.clear();
    for (int i = -edge; i <= edge; i++)
        for (int j = -edge; j <= edge; j++)
            adjFields.push_back(GetLocation() + sf::Vector2i(j, i));
}
예제 #29
0
// Get the sighted location
//
void
GetSightedLocation (edict_t * self, char *buf)
{
  vec3_t start, forward, right, end, up, offset;
  int xo, yo, zo;
  trace_t tr;

  AngleVectors (self->client->v_angle, forward, right, up);

  VectorSet (offset, 24, 8, self->viewheight);
  P_ProjectSource (self->client, self->s.origin, offset, forward, right,
		   start);
  VectorMA (start, 8192, forward, end);

  PRETRACE ();
  tr =
    gi.trace (start, NULL, NULL, end, self,
	      CONTENTS_SOLID | CONTENTS_MONSTER | CONTENTS_DEADMONSTER);
  POSTTRACE ();

  xo = tr.endpos[0];
  yo = tr.endpos[1];
  zo = tr.endpos[2];

  GetLocation (xo, yo, zo, 10, buf);
}
//---------------------------------------------------------------------------
const bool SimImmuneResponse::CanGrabSprite(
  const EnumLocation location,
  const int x,
  const int y) const
{
  return GetLocation(location)->CanGrabSprite(x,y);
}