void CustomColorsSystem::UpdateBrushTool(float32 timeElapsed)
{
	Sprite* colorSprite = drawSystem->GetCustomColorsProxy()->GetSprite();
	
	RenderManager::Instance()->SetRenderTarget(colorSprite);

	RenderManager::Instance()->SetColor(drawColor);

	Vector2 spriteSize = Vector2(cursorSize, cursorSize);
	Vector2 spritePos = cursorPosition - spriteSize / 2.f;
	
    Sprite::DrawState drawState;
	drawState.SetScaleSize(spriteSize.x / Core::GetVirtualToPhysicalFactor(),
                           spriteSize.y / Core::GetVirtualToPhysicalFactor(),
                           toolImageSprite->GetWidth(),
                           toolImageSprite->GetHeight());
	drawState.SetPosition(spritePos / Core::GetVirtualToPhysicalFactor());
	toolImageSprite->Draw(&drawState);
	
	RenderManager::Instance()->RestoreRenderTarget();
	RenderManager::Instance()->SetColor(Color::White);
	
	drawSystem->GetLandscapeProxy()->SetCustomColorsTexture(colorSprite->GetTexture());
	
	Rect updatedRect;
	updatedRect.SetCenter(spritePos);
	updatedRect.SetSize(spriteSize);
    
	AddRectToAccumulator(updatedRect);
}
Beispiel #2
0
void ResultScreen::PrepareSprite()
{
    Rect r(0, 0, resultSprite->GetWidth(), resultSprite->GetHeight());

    RenderManager::Instance()->SetRenderTarget(resultSprite);

    Sprite::DrawState state;
    state.SetScale(RESULT_TEXTURE_SCALE, RESULT_TEXTURE_SCALE);
    textureSprite->Draw(&state);
    DrawStatImage(r);
    RenderManager::Instance()->RestoreRenderTarget();
}
Beispiel #3
0
void ResultScreen::Draw(const UIGeometricData &geometricData)
{
    Core *core=DAVA::Core::Instance();

    Vector2 screenSize(core->GetVirtualScreenWidth(), core->GetVirtualScreenHeight());

    float32 drawSize = Min(screenSize.x, screenSize.y);
    float32 scale = Min(drawSize / resultSprite->GetWidth(), drawSize / resultSprite->GetHeight());

    Sprite::DrawState state;
    state.SetPosition(0, 0);
    state.SetScale(scale, scale);

    resultSprite->Draw(&state);

    UIScreen::Draw(geometricData);
}
void UILoadingTransition::Draw(const UIGeometricData &geometricData)
{
    
	if (backgroundSprite)
    {
        Sprite::DrawState drawState;
        drawState.SetRenderState(RenderState::RENDERSTATE_2D_BLEND);
        drawState.SetPosition(geometricData.position);
 		backgroundSprite->Draw(&drawState);
    }

	if (animationSprite)
	{
		int frame = (int32)((animationTime/animationDuration) * animationSprite->GetFrameCount());
		if (frame > animationSprite->GetFrameCount() - 1)
			frame = animationSprite->GetFrameCount() - 1;
		
        Sprite::DrawState drawState;
        drawState.SetRenderState(RenderState::RENDERSTATE_2D_BLEND);
        drawState.SetFrame(frame);
        drawState.SetPosition(geometricData.position);
        
		animationSprite->Draw(&drawState);
	}
}
void UIScreenTransition::Draw(const UIGeometricData &geometricData)
{
    Sprite::DrawState drawState;
    drawState.SetRenderState(RenderState::RENDERSTATE_2D_BLEND);
    
	drawState.SetScale(0.5f, 1.0f);
	drawState.SetPosition(0, 0);
    
	renderTargetPrevScreen->Draw(&drawState);

    
	drawState.SetScale(0.5f, 1.0f);
	drawState.SetPosition((Core::Instance()->GetVirtualScreenXMax() - Core::Instance()->GetVirtualScreenXMin()) / 2.0f, 0);
    
	renderTargetNextScreen->Draw(&drawState);
}
Beispiel #6
0
void PVRTest::Draw(const DAVA::UIGeometricData &geometricData)
{
    RenderManager::Instance()->ClearWithColor(0.f, 0.0f, 0.f, 1.f);
    
    Sprite::DrawState state;
    state.SetFrame(0);

    if(pngSprite)
    {
        state.SetPosition(0.f, 0.f);
        state.SetScaleSize(256.f, 256.f, pngSprite->GetWidth(), pngSprite->GetHeight());
        pngSprite->Draw(&state);
    }
    
    if(pvrSprite)
    {
        state.SetPosition(260.f, 0.f);
        state.SetScaleSize(256.f, 256.f, pvrSprite->GetWidth(), pvrSprite->GetHeight());
        pvrSprite->Draw(&state);
    }
    
    TestTemplate<PVRTest>::Draw(geometricData);
}
Beispiel #7
0
Size2i GraphicsFont::DrawString(float32 x, float32 y, const WideString & string, int32 justifyWidth)
{
    uint32 length = (uint32)string.length();
    if(length==0) return Size2i();

    uint16 prevChIndex = GraphicsFontDefinition::INVALID_CHARACTER_INDEX;
    Sprite::DrawState state;

    state.SetPerPixelAccuracyUsage(true);

    float32 currentX = x;
    float32 currentY = y;
    float32 sizeFix = 0.0f;
    //Logger::Debug("%S startX:%f", string.c_str(), currentX);
    RenderManager::Instance()->SetColor(color);
    for (uint32 indexInString = 0; indexInString < length; ++indexInString)
    {
        char16 c = string[indexInString];
        uint16 chIndex = fdef->CharacterToIndex(c);

        if (indexInString == 0)
        {
            sizeFix = fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff;
            currentX -= sizeFix;
        }

        if (chIndex == GraphicsFontDefinition::INVALID_CHARACTER_INDEX)
        {
            if(c != '\n')
                Logger::Debug("*** Error: can't find character %c in font", c);
            continue;
        }

        if (prevChIndex != GraphicsFontDefinition::INVALID_CHARACTER_INDEX)
        {
            //Logger::Debug("kern: %c-%c = %f", string[indexInString - 1], c,  GetDistanceFromAtoB(prevChIndex, chIndex));
            currentX += GetDistanceFromAtoB(prevChIndex, chIndex);
        }

        state.SetFrame(chIndex);
        // draw on baseline Y = currentY - fontSprite->GetHeight() + charTopBottomPadding + fontDescent

        float32 drawX = currentX;
        float32 drawY = currentY - fontSprite->GetHeight() * fontScaleCoeff + (fdef->charTopBottomPadding + fdef->fontDescent + fdef->fontAscent) * fontScaleCoeff;


        //if (indexInString != 0)
        drawX += fdef->characterPreShift[chIndex] * fontScaleCoeff;


        state.SetScale(fontScaleCoeff, fontScaleCoeff);
        state.SetPosition(drawX, drawY);

        fontSprite->Draw(&state);

//		RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
//		RenderManager::Instance()->DrawRect(Rect(drawX + fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff, drawY + fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::Y_OFFSET_TO_ACTIVE) * fontScaleCoeff, fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::ACTIVE_WIDTH), fontSprite->GetHeight() * fontScaleCoeff));
//		RenderManager::Instance()->ResetColor();

        currentX += (fdef->characterWidthTable[chIndex] + horizontalSpacing) * fontScaleCoeff;
//		Logger::Debug("%c w:%f pos: %f\n", c, fdef->characterWidthTable[chIndex] * fontScaleCoeff, currentX);
//		if (c == ' ')currentX += fdef->characterWidthTable[chIndex] * fontScaleCoeff;
//		else currentX += fontSprite->GetRectOffsetValueForFrame(chIndex, Sprite::ACTIVE_WIDTH) * fontScaleCoeff;

        prevChIndex = chIndex;
    }
    RenderManager::Instance()->ResetColor();

    currentX -= (fdef->characterWidthTable[prevChIndex] + horizontalSpacing) * fontScaleCoeff;
    currentX += (fdef->characterPreShift[prevChIndex] + fontSprite->GetRectOffsetValueForFrame(prevChIndex, Sprite::ACTIVE_WIDTH)) * fontScaleCoeff; // characterWidthTable[prevChIndex];

//	Sprite::DrawState drwState;
//	float32 drawX = 100;
//	float32 drawY = 100;
//	drwState.SetFrame(1);
//	drwState.SetPosition(drawX, drawY);
//	fontSprite->Draw(&drwState);
//
//	RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
//	RenderManager::Instance()->DrawRect(Rect(drawX + fontSprite->GetRectOffsetValueForFrame(1, Sprite::X_OFFSET_TO_ACTIVE) * fontScaleCoeff
//											 , drawY + fontSprite->GetRectOffsetValueForFrame(1, Sprite::Y_OFFSET_TO_ACTIVE) * fontScaleCoeff
//											 , fdef->characterWidthTable[1]
//											 , fontSprite->GetHeight() * fontScaleCoeff));
//	RenderManager::Instance()->ResetColor();


    return Size2i((int32)(currentX + sizeFix + 1.5f - x), GetFontHeight());
}