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); }
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(); }
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); }
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()); }