Example #1
0
void CFontMaterial::DrawString( CDrawContext * pDrawContext, std::string text, float x, float y, float r, float g, float b, float a, int type ) {
 
    float xtrans = 0.0f, ytrans = 0.0f;
    float xoffset = 0.0f, yoffset = 0.0f;
    
    pDrawContext->SetTexture( m_FontSheet.GetTexture() );
    pDrawContext->SetDrawColor( r, g, b, a );
    
    if( type & ( DRAW_TEXT_HORIZ_CENTER | DRAW_TEXT_VERT_CENTER ) ) {
     
        Vector2< int > size = GetStringSize( text );
        
        if( type & DRAW_TEXT_HORIZ_CENTER ) {
         
            xoffset = ( float )-size.GetX() * .5f;
            
        }

        if( type & DRAW_TEXT_VERT_CENTER ) {
            
            yoffset = ( float )-size.GetY() * .5f;
            
        }
        
    }
    
    
    for( int i = 0; i < text.length(); i++ ) {
        
        bool newline = false;
        
        if( text[i] == '\n' )
            newline = true;

        if( !newline ) {
        
            int c = text[i];
            CFontCharacter fchar = m_Characters[c];
            Vector2< float > size = fchar.m_Size;
            Vector2< float > v1 = fchar.m_UpperLeftST;
            Vector2< float > v2 = fchar.m_LowerRightST;
            
            pDrawContext->StartDraw();
                pDrawContext->SetPos( x + xoffset + xtrans + fchar.m_Left, y + yoffset + ytrans - fchar.m_Down + m_LargestBearingY );
                pDrawContext->SetScale( size.GetX() , size.GetY() );
                pDrawContext->SetTexCoord( v1.GetX(), v1.GetY(), v2.GetX(), v1.GetY(), v2.GetX(), v2.GetY(), v1.GetX(), v2.GetY() );
            pDrawContext->EndDraw();
            
            xtrans += fchar.m_Trans;
            
        } else {
         
            xtrans = 0;
            ytrans += m_FontSize;
            
        }
        
    }
    
}
Example #2
0
    Rectangle::Rectangle(float height, float width, Vector2 center)
    {
		a.Set(center.GetX() - width / 2, center.GetY() - height / 2);
		b.Set(center.GetX() + width / 2, center.GetY() - height / 2);
		c.Set(center.GetX() + width / 2, center.GetY() + height / 2);
		d.Set(center.GetX() - width / 2, center.GetY() + height / 2);
    }
Example #3
0
    Rectangle::Rectangle(const Vector2 &min, const Vector2 &max)
    {
        a = min;
		b = Vector2(max.GetX(), min.GetY());
        c = max;
		d = Vector2(min.GetX(), max.GetY());
    }
Example #4
0
Vector2 AABB::GetOverlap(AABB other, bool makeIntegral) const
{
	Vector2 overlap;
	const AABB *left = _x < other._x ? this : &other;
	const AABB *right = left == this ? &other : this;
	overlap.SetX(left->_x + left->_width - right->_x);
	if (left == this) overlap.SetX(overlap.GetX() * -1);
	
	const AABB *top = _y < other._y ? this : &other;
	const AABB *bottom = top == this ? &other : this;
	overlap.SetY(top->_y + top->_height - bottom->_y);
	if (top == this) overlap.SetY(overlap.GetY() * -1);

	if (makeIntegral)
	{
		float x = overlap.GetX();
		float y = overlap.GetY();
		x = x < 0 ? ::floorf(x) : ::ceilf(x);
		y = y < 0 ? ::floorf(y) : ::ceilf(y);
		overlap.SetX(x);
		overlap.SetY(y);
	}

	return overlap;
}
bool CircleCollider::CollisionCheck(Vector2& a_vPointOne,Vector2& a_vPointTwo)
{	
	Vector2 newCenter(m_vCenter.GetX() - a_vPointOne.GetX() ,m_vCenter.GetY() - a_vPointOne.GetY() );
	Vector2 newPointTwo(a_vPointTwo.GetX() - a_vPointOne.GetX() ,a_vPointTwo.GetY() - a_vPointOne.GetY() );


	float projection  = newCenter.Norm().Dot(newPointTwo.Norm());
	float sinofAngle = sqrt(1 - (projection * projection)); 
	float lhs, rhs;
	lhs = m_fRadius *m_fRadius; 
	rhs = newCenter.SqMagnatude() * sinofAngle;
	return lhs >= rhs;


}
Example #6
0
Matrix3 Matrix3::Translate(const Vector2& pos)
{
    Matrix3 m;
    m.m_[2] = pos.GetX();
    m.m_[5] = pos.GetY();
    return m;
}
Example #7
0
int CFontMaterial::GetStringWidth( std::string text ) {
    
    Vector2< int > v = GetStringSize( text );
    
    return v.GetX();
    
}
Example #8
0
	bool Vector2::operator==(const Vector2& v)
	{
		if(x != v.GetX()) return false;
		if(y != v.GetY()) return false;
	
		return true;
	}
Example #9
0
Matrix3 Matrix3::Scale(const Vector2& scale)
{
    Matrix3 m;
    m.m_[0] = scale.GetX();
    m.m_[1] = scale.GetY();
    return m;
}
Example #10
0
File: Grid.cpp Project: Bugro/SLAM
Vector2 Grid::PosGrid(Vector2 point)
{
	int x = (int)((point.GetX() / CELL_SIZE));
	int y = (int)((point.GetY() / CELL_SIZE));

	return Vector2(x, y);
}
void PromptOverlay::Draw()
{
    pDarkeningImage->Draw(Vector2(0, 0), Color(fadeOpacity * 0.75, 1, 1, 1));

    if (allowsTextEntry)
    {
        Vector2 textEnteredPosition = Vector2((gScreenWidth - pTextEntryFont->GetWidth(textEntered)) / 2, (gScreenHeight - pTextEntryFont->GetLineHeight()) / 2 + yOffset);
        pTextEntryFont->Draw(textEntered, textEnteredPosition, Color(fadeOpacity, 1, 1, 1));

        if (TextInputHelper::GetIsCaretShowing())
        {
            SDL_Rect rect = { (int)(textEnteredPosition.GetX() + pTextEntryFont->GetWidth(textEntered.substr(0, TextInputHelper::GetCaretPosition()))), (int)textEnteredPosition.GetY(), 2, (int)pTextEntryFont->GetLineHeight() };
            SDL_SetRenderDrawColor(gpRenderer, 255, 255, 255, (Uint8)(fadeOpacity * 255));
            SDL_SetRenderDrawBlendMode(gpRenderer, SDL_BLENDMODE_BLEND);
            SDL_RenderFillRect(gpRenderer, &rect);
        }
    }

    int textLineTop = gScreenHeight / 2 - pTextFont->GetLineHeight() * (1 + headerTextLines.size()) - (allowsTextEntry ? 2 * pTextEntryFont->GetLineHeight() / 3 : 0) + yOffset;

    for (unsigned int i = 0; i < headerTextLines.size(); i++)
    {
        pTextFont->Draw(headerTextLines[i], Vector2((gScreenWidth - pTextFont->GetWidth(headerTextLines[i])) / 2, textLineTop + pTextFont->GetLineHeight() * i), Color(fadeOpacity, 1, 1, 1));
    }

    for (unsigned int i = 0; i < buttonList.size(); i++)
    {
        buttonList[i]->Draw(fadeOpacity);
    }
}
Example #12
0
Vector2 Matrix3::operator*(const Vector2& rhs) const
{
    float vector[3] = { m_[0]*m_[1]*m_[1]*rhs.GetX(),
                        m_[2]*m_[3]*m_[4]*rhs.GetY(), 
                        m_[5]*m_[6]*m_[7]            };

    return Vector2(vector[0] / vector[2], vector[1] / vector[2]);
}
Example #13
0
Ivy::Math::Matrix Ivy::Math::Matrix::Scale(Vector2 scale)
{
	glm::mat4 scaled = glm::scale(values, Vector3(scale.GetX(), scale.GetY(), 
		0.0f).GetRawData());
	return Matrix(scaled[0][0], scaled[0][1], scaled[0][2], scaled[0][3],
		scaled[1][0], scaled[1][1], scaled[1][2], scaled[1][3],
		scaled[2][0], scaled[2][1], scaled[2][2], scaled[2][3],
		scaled[3][0], scaled[3][1], scaled[3][2], scaled[3][3]);
}
void FieldCharacter::UpdateDirection(Vector2 directionVector)
{
    directionVector = directionVector.Normalize();

    // We'll snap the player's direction vector according to
    // the nearest direction for which we have an animation.
    double angleToHorizontal = acos(directionVector.GetX());

    // acos() only returns values from 0 to pi,
    // so to get the full circle we need to check
    // whether we're in the bottom two quandrants,
    // and change the angle to account for this if so.
    if (directionVector.GetY() > 0)
    {
        angleToHorizontal = 2 * M_PI - angleToHorizontal;
    }

    if (angleToHorizontal <= M_PI / 8 || angleToHorizontal > M_PI * 15 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionSide);
        SetDirection(CharacterDirectionRight);
    }
    else if (angleToHorizontal > M_PI / 8 && angleToHorizontal <= M_PI * 3 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
        SetDirection(CharacterDirectionRight);
    }
    else if (angleToHorizontal > 3 * M_PI / 8 && angleToHorizontal <= M_PI * 5 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionUp);
    }
    else if (angleToHorizontal > 5 * M_PI / 8 && angleToHorizontal <= M_PI * 7 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 7 * M_PI / 8 && angleToHorizontal <= M_PI * 9 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionSide);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 9 * M_PI / 8 && angleToHorizontal <= M_PI * 11 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
        SetDirection(CharacterDirectionLeft);
    }
    else if (angleToHorizontal > 11 * M_PI / 8 && angleToHorizontal <= M_PI * 13 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDown);
    }
    else if (angleToHorizontal > 13 * M_PI / 8 && angleToHorizontal <= M_PI * 15 / 8)
    {
        SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
        SetDirection(CharacterDirectionRight);
    }
}
Example #15
0
bool Shader::SetShaderVec2Parameter(const char* name, Vector2 vec2)
{
	int locID = glGetUniformLocation(m_programID, name);

	if (locID >= 0)
	{
		glUniform2f(locID, vec2.GetX(), vec2.GetY());
	}
	return true;
}
void MouseHelper::MouseOverText::Draw(Vector2 cursorPosition)
{
    MLIFont *pMouseOverFont = CommonCaseResources::GetInstance()->GetFontManager()->GetFontFromId("MouseOverFont");
    Vector2 cursorSize = GetCursorSize();
    Vector2 mouseOverTextPosition = cursorPosition + Vector2(cursorSize.GetX() / 2, cursorSize.GetY()) - Vector2(pMouseOverFont->GetWidth(text) / 2, 0);

    if (mouseOverTextPosition.GetX() < MouseOverTextMarginPx)
    {
        mouseOverTextPosition.SetX(MouseOverTextMarginPx);
    }
    else if (mouseOverTextPosition.GetX() + pMouseOverFont->GetWidth(text) > gScreenWidth - MouseOverTextMarginPx)
    {
        mouseOverTextPosition.SetX(gScreenWidth - MouseOverTextMarginPx - pMouseOverFont->GetWidth(text));
    }

    if (mouseOverTextPosition.GetY() + pMouseOverFont->GetHeight(text) > gScreenHeight - TabHeight - MouseOverTextMarginPx)
    {
        mouseOverTextPosition.SetY(mouseOverTextPosition.GetY() - cursorSize.GetY() - pMouseOverFont->GetHeight(text));
    }

    if (mouseOverTextPosition.GetY() + pMouseOverFont->GetHeight(text) > gScreenHeight - TabHeight - MouseOverTextMarginPx)
    {
        mouseOverTextPosition.SetY(gScreenHeight - TabHeight - MouseOverTextMarginPx - pMouseOverFont->GetHeight(text));
    }

    // We don't want the mouse over text to continue to follow the mouse cursor in the y-direction
    // after it starts fading out, so we'll set the current mouse over text position such that
    // we can retrieve the last y-position prior to fading out as its permanent y-position
    // until the fade-out has completed.
    if (!isFadingOut)
    {
        fadeOutMousePosition = mouseOverTextPosition;
    }
    else
    {
        mouseOverTextPosition.SetY(fadeOutMousePosition.GetY());
    }

    mouseOverTextPosition += Vector2(0, currentOffset);

    pMouseOverFont->Draw(text, mouseOverTextPosition, Color(currentOpacity, 1.0, 1.0, 1.0));
}
void EvidenceDescription::Draw(Vector2 position)
{
    EnsureEvidenceInformation();
    pBackgroundImage->Draw(position);

    if (pEvidenceSprite != NULL)
    {
        pEvidenceSprite->Draw(Vector2(position.GetX() + 3, position.GetY() + 3));
        pNameFont->Draw(evidenceName, Vector2(position.GetX() + 128 + 10, position.GetY() + 3 + 5));

        int totalDescriptionHeight = (int)(evidenceDescriptionLines.size() * pDescriptionFont->GetLineHeight() + (evidenceDescriptionLines.size() - 1) * descriptionLineSeparationHeight);
        int currentY = (int)(position.GetY() + (5 + pNameFont->GetLineHeight() + 130 - totalDescriptionHeight) / 2);

        for (unsigned int i = 0; i < evidenceDescriptionLines.size(); i++)
        {
            pDescriptionFont->Draw(evidenceDescriptionLines[i], Vector2(position.GetX() + 128 + 20, currentY));
            currentY += pDescriptionFont->GetLineHeight() + descriptionLineSeparationHeight;
        }
    }
}
bool CircleCollider::CollisionCheck(Vector2& a_vPoint)
{
	float lhs = (m_fRadius * m_fRadius);
	float rhsX = (a_vPoint.GetX() - m_vCenter.GetX());
	float rhsY = (a_vPoint.GetY() - m_vCenter.GetY());

	if(lhs > ((rhsX*rhsX)+(rhsY*rhsY)))
		return true;
	return false;

}	
RectangleWH HitBox::GetBoundingBox() const
{
    double left = numeric_limits<double>::infinity();
    double top = numeric_limits<double>::infinity();
    double right = -numeric_limits<double>::infinity();
    double bottom = -numeric_limits<double>::infinity();

    for (unsigned int i = 0; i < collidableObjectList.size(); i++)
    {
        vector<Vector2> *pVertices = collidableObjectList[i]->GetVertices();

        for (unsigned int j = 0; j < pVertices->size(); j++)
        {
            Vector2 vertex = (*pVertices)[j];

            if (vertex.GetX() < left)
            {
                left = vertex.GetX();
            }

            if (vertex.GetX() > right)
            {
                right = vertex.GetX();
            }

            if (vertex.GetY() < top)
            {
                top = vertex.GetY();
            }

            if (vertex.GetY() > bottom)
            {
                bottom = vertex.GetY();
            }
        }
    }

    return RectangleWH(left, top, right - left, bottom - top);
}
void Notification::Draw(double yOffset)
{
    if (pInEaseText->GetIsFinished() && pInEasePartner->GetIsFinished() && pInEaseEvidence->GetIsFinished() && !pOutEaseText->GetIsStarted() && !pOutEasePartner->GetIsStarted() && !pOutEaseEvidence->GetIsStarted())
    {
        pDownArrow->Draw(yOffset);
    }

    for (unsigned int i = 0; i < textLines.size(); i++)
    {
        Vector2 textLinePosition = textLinePositions[i];

        pTextFont->Draw(textLines[i], Vector2(textLinePosition.GetX() + animationOffsetText, textLinePosition.GetY() + yOffset));
    }

    if (pPartnerInformation != NULL)
    {
        pPartnerInformation->Draw(animationOffsetPartner, (int)yOffset);
    }

    if (pNewEvidenceDescription != NULL)
    {
        if (pOldEvidenceDescription != NULL)
        {
            pOldEvidenceDescription->Draw(
                Vector2(
                    evidenceCenterPoint.GetX() - pOldEvidenceDescription->GetWidth() / 2 + animationOffsetEvidence,
                    evidenceCenterPoint.GetY() - pOldEvidenceDescription->GetHeight() - pDirectionArrow->height / 3));

            pNewEvidenceDescription->Draw(
                Vector2(
                    evidenceCenterPoint.GetX() - pNewEvidenceDescription->GetWidth() / 2 + animationOffsetEvidence,
                    evidenceCenterPoint.GetY() + pDirectionArrow->height / 3));

            pDirectionArrow->Draw(
                Vector2(
                    evidenceCenterPoint.GetX() - pDirectionArrow->width / 2 + animationOffsetEvidence,
                    evidenceCenterPoint.GetY() - pDirectionArrow->height / 2 - 5 + arrowOffset));
        }
        else
        {
            pNewEvidenceDescription->Draw(
                Vector2(
                    evidenceCenterPoint.GetX() - pNewEvidenceDescription->GetWidth() / 2 + animationOffsetEvidence,
                    evidenceCenterPoint.GetY() - pNewEvidenceDescription->GetHeight() / 2));
        }
    }
}
void Sprite::DrawClipped(Vector2 position, RectangleWH clipRect, bool flipHorizontally, Color color)
{
    if (GetSpriteSheetImage() == NULL)
    {
        return;
    }

    // Adjust the clip rect to account for the fact that we've eliminated blank space
    // that was around the source image.
    if (spriteDrawOffset.GetX() > 0 || spriteDrawOffset.GetY() > 0)
    {
        Vector2 oldClipRectPosition(clipRect.GetX(), clipRect.GetY());

        clipRect.SetX(clipRect.GetX() - spriteDrawOffset.GetX());
        clipRect.SetY(clipRect.GetY() - spriteDrawOffset.GetY());

        position += Vector2(clipRect.GetX(), clipRect.GetY()) - oldClipRectPosition;

        if (clipRect.GetX() + clipRect.GetWidth() > GetWidth())
        {
            clipRect.SetWidth(GetWidth() - clipRect.GetX());
        }

        if (clipRect.GetY() + clipRect.GetHeight() > GetHeight())
        {
            clipRect.SetHeight(GetHeight() - clipRect.GetY());
        }
    }

    Vector2 pixelSnappedPosition =
        Vector2(
            (int)(position.GetX() + (originalSize.GetX() > 0 && flipHorizontally ? originalSize.GetX() - GetWidth() - spriteDrawOffset.GetX() : spriteDrawOffset.GetX())),
            (int)(position.GetY() + spriteDrawOffset.GetY()));

    GetSpriteSheetImage()->Draw(
        pixelSnappedPosition,
        RectangleWH(
            spriteClipRect.GetX() + clipRect.GetX(),
            spriteClipRect.GetY() + clipRect.GetY(),
            clipRect.GetWidth(),
            clipRect.GetHeight()),
        flipHorizontally,
        false /* flipVertically */,
        1.0,
        color);
}
Example #22
0
void PlayerActor::ProjectileHit(Actor *prj)
{
	if (_shieldActive)
	{
        if (((ProjectileActor*)prj)->IsReflectable())
        {
            Vector2 vel = prj->GetSpeed();
            vel.SetX(vel.GetX() * -1);
            vel.SetY(vel.GetY() * -1);
            prj->SetSpeed(vel);
        }
	}
	else
	{
		SetHealth(0);
	}
}
void Sprite::Draw(Vector2 position, Color color, double scale, bool flipHorizontally)
{
    if (GetSpriteSheetImage() == NULL)
    {
        return;
    }

    Vector2 pixelSnappedPosition = Vector2((int)position.GetX(), (int)position.GetY());

    GetSpriteSheetImage()->Draw(
        pixelSnappedPosition,
        spriteClipRect,
        flipHorizontally,
        false /* flipVertically */,
        scale,
        color);
}
void Sprite::Draw(Vector2 position, Color color, double scale, bool flipHorizontally)
{
    if (GetSpriteSheetImage() == NULL)
    {
        return;
    }

    Vector2 pixelSnappedPosition =
        Vector2(
            (int)(position.GetX() + (originalSize.GetX() > 0 && flipHorizontally ? originalSize.GetX() - GetWidth() - spriteDrawOffset.GetX() : spriteDrawOffset.GetX())),
            (int)(position.GetY() + spriteDrawOffset.GetY()));

    GetSpriteSheetImage()->Draw(
        pixelSnappedPosition,
        spriteClipRect,
        flipHorizontally,
        false /* flipVertically */,
        scale,
        color);
}
void Sprite::DrawClipped(Vector2 position, RectangleWH clipRect, bool flipHorizontally, Color color)
{
    if (GetSpriteSheetImage() == NULL)
    {
        return;
    }

    Vector2 pixelSnappedPosition = Vector2((int)position.GetX(), (int)position.GetY());

    GetSpriteSheetImage()->Draw(
        pixelSnappedPosition,
        RectangleWH(
            spriteClipRect.GetX() + clipRect.GetX(),
            spriteClipRect.GetY() + clipRect.GetY(),
            clipRect.GetWidth(),
            clipRect.GetHeight()),
        flipHorizontally,
        false /* flipVertically */,
        1.0,
        color);
}
void PartnerInformation::Draw(int animationOffsetPartner, int yOffset)
{
    if (GetPartner() == NULL)
    {
        return;
    }

    Vector2 offsetVector = Vector2(animationOffsetPartner, yOffset);
    Vector2 partnerNamePosition =
       Vector2(
            partnerNameRectangle.GetX() + partnerNameRectangle.GetWidth() / 2 - pHeadingFont->GetWidth(GetPartner()->GetName()) / 2,
            partnerNameRectangle.GetY() + partnerNameRectangle.GetHeight() / 2 - pHeadingFont->GetHeight(GetPartner()->GetName()) / 2 - 1);
    partnerNamePosition = Vector2(floor(0.5 + partnerNamePosition.GetX()), floor(0.5 + partnerNamePosition.GetY()));

    pBackgroundImage->Draw(backgroundImagePosition + offsetVector);
    pHeadingFont->Draw(GetPartner()->GetName(), partnerNamePosition + offsetVector);
    GetPartner()->GetProfileImageSprite()->Draw(profileImagePosition + offsetVector);

    double currentYOffset = (AbilityDescriptionHeight - (double)passiveAbilityDescriptionLines.size() * pBodyFont->GetLineHeight() - ((double)passiveAbilityDescriptionLines.size() - 1) * AbilityDescriptionExtraLineHeight) / 2;

    for (unsigned int i = 0; i < passiveAbilityDescriptionLines.size(); i++)
    {
        pBodyFont->Draw(passiveAbilityDescriptionLines[i], passiveAbilityDescriptionPosition + offsetVector + Vector2(0, currentYOffset));
        currentYOffset += pBodyFont->GetLineHeight() + AbilityDescriptionExtraLineHeight;
    }

    currentYOffset = (AbilityDescriptionHeight - activeAbilityDescriptionLines.size() * pBodyFont->GetLineHeight() - ((double)activeAbilityDescriptionLines.size() - 1) * AbilityDescriptionExtraLineHeight) / 2;

    for (unsigned int i = 0; i < activeAbilityDescriptionLines.size(); i++)
    {
        pBodyFont->Draw(activeAbilityDescriptionLines[i], activeAbilityDescriptionPosition + offsetVector + Vector2(0, currentYOffset));
        currentYOffset += pBodyFont->GetLineHeight() + AbilityDescriptionExtraLineHeight;
    }

    pHeadingFont->Draw("Passive ability", passiveAbilityHeadingPosition + offsetVector);
    pHeadingFont->Draw("Active ability", activeAbilityHeadingPosition + offsetVector);
}
void Button::Draw(double xOffset, double yOffset)
{
    Color textColor;

    if (GetIsDisabled())
    {
        textColor = DisabledTextColor;
    }
    else if (isMouseDown)
    {
        textColor = MouseDownTextColor;
    }
    else if (isMouseOver)
    {
        textColor = MouseOverTextColor;
    }
    else
    {
        textColor = NormalTextColor;
    }

    Vector2 textPosition = Vector2(
            GetXPosition() + animationOffset + xOffset,
            GetYPosition() + yOffset);

    pTextFont->Draw(GetText(), textPosition, textColor);

    if (pCustomIconSprite != NULL)
    {
        Vector2 spritePosition =
            Vector2(
                textPosition.GetX() - pCustomIconSprite->GetWidth() - 4,
                textPosition.GetY() - 4 + (36 - pCustomIconSprite->GetHeight()) / 2);

        pCustomIconSprite->Draw(spritePosition);
    }
    else if (GetLockCount() > 0 || GetUnlockedLockCount() > 0)
    {
        int lockPositionOffset = 0;

        for (int i = 0; i < GetLockCount(); i++)
        {
            lockPositionOffset += pLockSprite->GetWidth() + 2;

            Vector2 lockPosition =
                Vector2(
                    textPosition.GetX() - lockPositionOffset,
                    textPosition.GetY() - 9);

            pLockSprite->Draw(lockPosition);
        }

        for (int i = 0; i < GetUnlockedLockCount(); i++)
        {
            lockPositionOffset += pUnlockingAnimation->GetSize().GetX() + 2;

            Vector2 lockPosition =
                Vector2(
                    textPosition.GetX() - lockPositionOffset,
                    textPosition.GetY() - 9);

            pUnlockingAnimation->Draw(lockPosition);
        }
    }
    else if (GetShowCheckMark())
    {
        Vector2 checkMarkPosition =
            Vector2(
                textPosition.GetX() - pCheckMarkImage->width,
                textPosition.GetY() - 4);

        pCheckMarkImage->Draw(checkMarkPosition);
    }
}
Example #28
0
Vector2 Vector2::operator+(const Vector2 &rhs)
{
	Vector2 result;
	result.SetValues(_x + rhs.GetX(), _y + rhs.GetY()); 
	return result;
}
Example #29
0
void CgEffect::SetVector(const char* name, Vector2& v)
{
    cgSetParameter2f(this->retrieveParameter(name), v.GetX(), v.GetY());
}
void Dialog::Draw(double xOffset, double yOffset)
{
#ifdef ENABLE_DEBUG_MODE
    if (gEnableDebugMode && filePath.length() > 0)
    {
        MLIFont *pFont = CommonCaseResources::GetInstance()->GetFontManager()->GetFontFromId("MouseOverFont");
        pFont->Draw(GetFileNameFromFilePath(ConvertSeparatorsInPath(filePath + ".ogg")), Vector2(xOffset, yOffset + gScreenHeight - Dialog::Height - TabHeight + 3 - pFont->GetLineHeight()));
    }
#endif

    if (isInterrogation)
    {
        if (!pEvidenceSelector->GetIsShowing() && !evidencePresented && !pState->WasInterjectionOngoing())
        {
            if (!isPassive)
            {
                pPressForInfoTab->Draw(xOffset, yOffset);
                pPresentEvidenceTab->Draw(xOffset, yOffset);

                if (Case::GetInstance()->GetPartnerManager()->GetCurrentPartnerId().length() > 0 && pCurrentPartner->GetConversationAbilityName().length() > 0)
                {
                    pUsePartnerTab->Draw(0, yOffset);
                }
            }

            if (!isConfrontation || Confrontation::GetEnabledConfrontationTopicCount() > 1)
            {
                pEndInterrogationTab->Draw(xOffset, yOffset);
            }
        }
    }
    else if (pEvidenceSelector->GetIsShowing())
    {
        pEvidenceSelector->Draw(yOffset);
    }

    if (GetIsStarted())
    {
        Vector2 lineScreenPosition = Vector2(textAreaRect.GetX() + desiredPadding, textAreaRect.GetY() + desiredPadding);
        int curTextPosition = 0;
        TextColor curTextColor = TextColorNormal;
        deque<string> lines = split(GetString(), '\n');

        list<Interval>::iterator textIntervalEnumerator = textIntervalList.begin();
        Interval *pCurrentTextInterval = NULL;

        if (textIntervalEnumerator != textIntervalList.end())
        {
            pCurrentTextInterval = &(*textIntervalEnumerator);
            curTextColor = pCurrentTextInterval->Color;
            ++textIntervalEnumerator;
        }

        for (unsigned int i = 0; i < lines.size(); i++)
        {
            string line = lines[i];
            int curLineTextPosition = 0;
            Vector2 curScreenPosition = Vector2(lineScreenPosition.GetX(), lineScreenPosition.GetY());
            string lineRemainder = line;

            while (pCurrentTextInterval != NULL && pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition <= (int)lineRemainder.length())
            {
                string linePortionToDraw = lineRemainder.substr(0, pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition);
                lineRemainder = lineRemainder.substr(pCurrentTextInterval->EndIndex - curTextPosition - curLineTextPosition);
                pDialogFont->Draw(linePortionToDraw, Vector2(curScreenPosition.GetX() + xOffset, curScreenPosition.GetY() + yOffset), GetColorFromTextColor(curTextColor));
                curScreenPosition.SetX(curScreenPosition.GetX() + pDialogFont->GetWidth(linePortionToDraw));
                curLineTextPosition += linePortionToDraw.length();

                if (textIntervalEnumerator != textIntervalList.end())
                {
                    pCurrentTextInterval = &(*textIntervalEnumerator);
                    curTextColor = pCurrentTextInterval->Color;
                    ++textIntervalEnumerator;
                }
                else
                {
                    curTextColor = TextColorNormal;
                    pCurrentTextInterval = NULL;
                }
            }

            pDialogFont->Draw(lineRemainder, Vector2(curScreenPosition.GetX() + xOffset, curScreenPosition.GetY() + yOffset), GetColorFromTextColor(curTextColor));
            lineScreenPosition.SetY(lineScreenPosition.GetY() + pDialogFont->GetLineHeight());

            // Add one for the carriage return character.
            curTextPosition += line.length() + 1;
        }
    }

    if (GetIsReadyToProgress() && !evidencePresented)
    {
        if (isInterrogation)
        {
            if (!pEvidenceSelector->GetIsShowing())
            {
                pInterrogationUpArrow->Draw(xOffset, yOffset);
                pInterrogationDownArrow->Draw(xOffset, yOffset);
            }
        }
        else if (!pEvidenceSelector->GetIsShowing() && !GetIsAutomatic() && !isStatic)
        {
            pConversationDownArrow->Draw(xOffset, yOffset);
        }
    }
}