MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / DrawElement

Method DrawElement

Sources/Jazz2/UI/Menu/InGameMenu.cpp:399–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397 }
398
399 void InGameMenu::DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, bool unaligned)
400 {
401 auto* res = _metadata->FindAnimation(state);
402 if (res == nullptr) {
403 return;
404 }
405
406 if (frame < 0) {
407 frame = res->FrameOffset + ((std::int32_t)(_canvasBackground->AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount);
408 }
409
410 Canvas* currentCanvas = GetActiveCanvas();
411 GenericGraphicResource* base = res->Base;
412 Vector2f size = Vector2f(base->FrameDimensions.X * scaleX, base->FrameDimensions.Y * scaleY);
413 Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size);
414 if (!unaligned) {
415 adjustedPos.X = std::round(adjustedPos.X);
416 adjustedPos.Y = std::round(adjustedPos.Y);
417 }
418
419 Vector2i texSize = base->TextureDiffuse->GetSize();
420 std::int32_t col = frame % base->FrameConfiguration.X;
421 std::int32_t row = frame / base->FrameConfiguration.X;
422 Vector4f texCoords = Vector4f(
423 float(base->FrameDimensions.X) / float(texSize.X),
424 float(base->FrameDimensions.X * col) / float(texSize.X),
425 float(base->FrameDimensions.Y) / float(texSize.Y),
426 float(base->FrameDimensions.Y * row) / float(texSize.Y)
427 );
428
429 currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending);
430 }
431
432 void InGameMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, Vector2f size, const Vector4f& texCoords, bool unaligned)
433 {

Callers 1

InGameMenu.cppFile · 0.45

Calls 4

FindAnimationMethod · 0.80
GetSizeMethod · 0.45
DrawTextureMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected