Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 0156234

Browse files
committed
Fix TextPrimitive getting cut off if not left aligned when drawing blended or rotating
1 parent c3d551c commit 0156234

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

System/GraphicalPrimitive.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,23 @@ namespace RTE {
461461
AllegroBitmap playerGUIBitmap(drawScreen);
462462
GUIFont *font = m_IsSmall ? g_FrameMan.GetSmallFont() : g_FrameMan.GetLargeFont();
463463
Matrix rotation = Matrix(m_RotAngle);
464+
Vector targetPosAdjustment = Vector();
464465

465466
BITMAP *tempDrawBitmap = nullptr;
466467
if (m_BlendMode > DrawBlendMode::NoBlend || m_RotAngle != 0) {
467-
tempDrawBitmap = create_bitmap_ex(8, font->CalculateWidth(m_Text), font->CalculateHeight(m_Text));
468+
int textWidth = font->CalculateWidth(m_Text);
469+
int textHeight = font->CalculateHeight(m_Text);
470+
471+
tempDrawBitmap = create_bitmap_ex(8, textWidth * 2, textHeight);
468472
clear_to_color(tempDrawBitmap, ColorKeys::g_MaskColor);
469473
AllegroBitmap tempDrawAllegroBitmap(tempDrawBitmap);
470-
font->DrawAligned(&tempDrawAllegroBitmap, 0, 0, m_Text, m_Alignment);
474+
font->DrawAligned(&tempDrawAllegroBitmap, textWidth, 0, m_Text, m_Alignment);
475+
476+
targetPosAdjustment = Vector(static_cast<float>(textWidth), 0);
471477
}
472478

473479
if (!g_SceneMan.SceneWrapsX() && !g_SceneMan.SceneWrapsY()) {
474-
Vector drawStart = m_StartPos - targetPos;
480+
Vector drawStart = m_StartPos - targetPos - targetPosAdjustment;
475481

476482
if (m_BlendMode > DrawBlendMode::NoBlend) {
477483
if (m_RotAngle != 0) {
@@ -490,7 +496,7 @@ namespace RTE {
490496
Vector drawStartLeft;
491497
Vector drawStartRight;
492498

493-
TranslateCoordinates(targetPos, m_StartPos, drawStartLeft, drawStartRight);
499+
TranslateCoordinates(targetPos - targetPosAdjustment, m_StartPos, drawStartLeft, drawStartRight);
494500

495501
if (m_BlendMode > DrawBlendMode::NoBlend) {
496502
if (m_RotAngle != 0) {

0 commit comments

Comments
 (0)