Skip to content

Commit a482938

Browse files
committed
fix(gui): implement resolution scaling for unit health bar and info icons
1 parent 1fdfee6 commit a482938

8 files changed

Lines changed: 106 additions & 70 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,15 @@ friend class Drawable; // for selection/deselection transactions
584584
void setDrawRMBScrollAnchor(Bool b) { m_drawRMBScrollAnchor = b; }
585585
void setMoveRMBScrollAnchor(Bool b) { m_moveRMBScrollAnchor = b; }
586586

587+
// UI scaling function methods
588+
Real m_unitInfoResolutionScaleFactor;
589+
Real m_healthResolutionScaleFactor;
590+
591+
void calcUnitInfoScaleFactor();
592+
593+
Real getUnitInfoScaleFactor();
594+
Real getUnitHealthbarScaleFactor();
595+
587596
private:
588597
virtual Int getIdleWorkerCount();
589598
virtual Object *findIdleWorker( Object *obj);

GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ enum CrushSquishTestType CPP_11(: Int)
150150
TEST_CRUSH_OR_SQUISH
151151
};
152152

153+
const Real defaultHealthBoxHeight = 3.0f;
153154

154155
// ---------------------------------------------------
155156
/**

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,22 +2683,21 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
26832683
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
26842684
return FALSE;
26852685

2686-
// scale the health bars according to the zoom
2687-
Real zoom = TheTacticalView->getZoom();
2688-
//Real widthScale = 1.3f / zoom;
2689-
Real widthScale = 1.0f / zoom;
2690-
//Real heightScale = 0.8f / zoom;
2691-
Real heightScale = 1.0f;
2686+
// scale the health bars according to the zoom and resolution
2687+
// TheSuperHacker @info Original zoom at default height had a value of ~1.35
2688+
// Recent changes rebased the zoom to be 1.0 at default height, therefore 1.0 / 1.35 = ~0.74
2689+
Real zoomScale = 0.74f / TheTacticalView->getZoom();
26922690

2693-
healthBoxWidth *= widthScale;
2694-
healthBoxHeight *= heightScale;
2691+
healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor();
2692+
// TheSuperHackers @info For now we are integer scaling the health box height
2693+
healthBoxHeight *= floorf(TheDisplay->getHeightScale());
26952694

2696-
// do this so health bar doesn't get too skinny or fat after scaling
2697-
//healthBoxHeight = max(3.0f, healthBoxHeight);
2698-
healthBoxHeight = 3.0f;
2695+
2696+
// do this so health bar doesn't get too skinny after scaling
2697+
healthBoxHeight = max(defaultHealthBoxHeight, healthBoxHeight);
26992698

27002699
// figure out the final region for the health box
2701-
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
2700+
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
27022701
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
27032702
region.hi.x = region.lo.x + healthBoxWidth;
27042703
region.hi.y = region.lo.y + healthBoxHeight;
@@ -2831,10 +2830,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28312830
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
28322831
{
28332832
//Draw the emoticon.
2834-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
2833+
Int barWidth = healthBarRegion->width();
28352834
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
2836-
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth();
2837-
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight();
2835+
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
2836+
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
28382837

28392838
#ifdef SCALE_ICONS_WITH_ZOOM_ML
28402839
// adjust the width to be a % of the health bar region size
@@ -2885,9 +2884,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
28852884
Real scale = 1.0f;
28862885
#endif
28872886

2888-
Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale);
2889-
Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale);
2890-
const Int SPACING = 1;
2887+
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2888+
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2889+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
28912890
//Int totalWidth = (boxWidth+SPACING)*numTotal;
28922891

28932892
ICoord2D screenCenter;
@@ -2952,9 +2951,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29522951
#else
29532952
Real scale = 1.0f;
29542953
#endif
2955-
Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale);
2956-
Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale);
2957-
const Int SPACING = 1;
2954+
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2955+
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2956+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
29582957
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29592958

29602959
ICoord2D screenCenter;
@@ -3005,8 +3004,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30053004
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
30063005
}
30073006
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
3008-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth();
3009-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight();
3007+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3008+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30103009

30113010
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30123011
// adjust the width to be a % of the health bar region size
@@ -3033,8 +3032,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30333032
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
30343033
}
30353034
// draw the icon
3036-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
3037-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
3035+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3036+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30383037

30393038
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30403039
// adjust the width to be a % of the health bar region size
@@ -3061,8 +3060,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30613060
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
30623061
}
30633062
// draw the icon
3064-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
3065-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
3063+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3064+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30663065

30673066
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30683067
// adjust the width to be a % of the health bar region size
@@ -3231,10 +3230,10 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
32313230
// we are going to draw the healing icon relative to the size of the health bar region
32323231
// since that region takes into account hit point size and zoom factor of the camera too
32333232
//
3234-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3233+
Int barWidth = healthBarRegion->width();
32353234

3236-
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
3237-
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
3235+
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3236+
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
32383237

32393238
#ifdef SCALE_ICONS_WITH_ZOOM_ML
32403239
// adjust the width to be a % of the health bar region size
@@ -3294,7 +3293,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
32943293
// we are going to draw the healing icon relative to the size of the health bar region
32953294
// since that region takes into account hit point size and zoom factor of the camera too
32963295
//
3297-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;// used for position
3296+
Int barWidth = healthBarRegion->width();// used for position
32983297

32993298
// based on our own kind of we have certain icons to display at a size scale
33003299
Real scale;
@@ -3305,8 +3304,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33053304
else
33063305
scale = 0.5f;
33073306

3308-
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
3309-
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
3307+
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
3308+
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
33103309

33113310
#ifdef SCALE_ICONS_WITH_ZOOM_ML
33123311
// adjust the width to be a % of the health bar region size
@@ -3595,10 +3594,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
35953594
// draw the icon
35963595
if( healthBarRegion )
35973596
{
3598-
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
3597+
Int barHeight = healthBarRegion->height();
35993598

3600-
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
3601-
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
3599+
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3600+
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
36023601

36033602
#ifdef SCALE_ICONS_WITH_ZOOM_ML
36043603
// adjust the width to be a % of the health bar region size
@@ -3744,19 +3743,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37443743
if (!image)
37453744
return;
37463745

3747-
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37483746
#ifdef SCALE_ICONS_WITH_ZOOM_ML
3747+
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37493748
Real objScale = scale * 1.55f;
37503749
#else
37513750
Real objScale = 1.0f;
37523751
#endif
37533752

37543753

3755-
Real vetBoxWidth = image->getImageWidth()*objScale;
3756-
Real vetBoxHeight = image->getImageHeight()*objScale;
3754+
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
3755+
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();
37573756

37583757
//
3759-
// take the center position of the object, go down to it's bottom extent, and project
3758+
// take the center position of the health region, go down to it's bottom extent, and project
37603759
// that point to the screen, that will be the "center" of our veterancy box
37613760
//
37623761

@@ -3766,11 +3765,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37663765
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
37673766
return;
37683767

3769-
Real healthBoxWidth, healthBoxHeight;
3770-
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
3771-
return;
3772-
3773-
screenCenter.x += healthBoxWidth * scale * 0.5f;
3768+
screenCenter.x += healthBarRegion->width() * 0.65f;
37743769

37753770
// draw the image
37763771
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
@@ -3878,23 +3873,24 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
38783873

38793874
}
38803875

3876+
Real healthBoxWidth = healthBarRegion->width();
3877+
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3878+
// TheSuperHackers @info For now we are integer scaling the health box height so we do the same for the health box outline
3879+
Real healthBoxOutlineSize = floorf( (healthBarRegion->height() / (Int)defaultHealthBoxHeight) );
38813880

3882-
3883-
3884-
/// Real scale = 1.3f / TheTacticalView->getZoom();
3885-
Real healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3886-
3887-
Real healthBoxHeight = max(3, healthBarRegion->hi.y - healthBarRegion->lo.y);
3888-
Real healthBoxOutlineSize = 1.0f;
3881+
// draw a filled bar for the health
3882+
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
3883+
// This simplifies the handling of the health bar
3884+
TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3885+
healthBoxWidth * healthRatio, healthBoxHeight,
3886+
color );
38893887

38903888
// draw the health box outline
3891-
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
3889+
// TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region
3890+
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3891+
healthBoxWidth, healthBoxHeight,
38923892
healthBoxOutlineSize, outlineColor );
38933893

3894-
// draw a filled bar for the health
3895-
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,
3896-
(healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2,
3897-
color );
38983894
}
38993895

39003896
}

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ void DeclineResolution()
725725
TheShell->recreateWindowLayouts();
726726

727727
TheInGameUI->recreateControlBar();
728+
TheInGameUI->refreshCustomUiResources();
729+
TheInGameUI->calcUnitInfoScaleFactor();
728730
}
729731
}
730732

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ static void saveOptions()
848848

849849
TheInGameUI->recreateControlBar();
850850
TheInGameUI->refreshCustomUiResources();
851+
TheInGameUI->calcUnitInfoScaleFactor();
851852
}
852853
}
853854
}

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,9 @@ InGameUI::InGameUI()
12651265

12661266
m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID;
12671267

1268+
m_unitInfoResolutionScaleFactor = 1.0f;
1269+
m_healthResolutionScaleFactor = 1.0f;
1270+
12681271
}
12691272

12701273
//-------------------------------------------------------------------------------------------------
@@ -1401,6 +1404,9 @@ void InGameUI::init()
14011404
setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor);
14021405
setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor);
14031406

1407+
// TheSuperHackers @todo implement option to retrieve user based scaling options
1408+
calcUnitInfoScaleFactor();
1409+
14041410
}
14051411

14061412
//-------------------------------------------------------------------------------------------------
@@ -6374,3 +6380,19 @@ void InGameUI::drawPlayerInfoList()
63746380
drawY += lineH;
63756381
}
63766382
}
6383+
6384+
void InGameUI::calcUnitInfoScaleFactor()
6385+
{
6386+
m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6387+
m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6388+
}
6389+
6390+
Real InGameUI::getUnitInfoScaleFactor()
6391+
{
6392+
return m_unitInfoResolutionScaleFactor;
6393+
}
6394+
6395+
Real InGameUI::getUnitHealthbarScaleFactor()
6396+
{
6397+
return m_healthResolutionScaleFactor;
6398+
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,15 +3432,15 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34323432
if( isKindOf( KINDOF_STRUCTURE ) )
34333433
{
34343434
//enforce healthBoxHeightMinimum/Maximum
3435-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3435+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34363436
//enforce healthBoxWidthMinimum/Maximum
34373437
healthBoxWidth = min(150.0f, max(100.0f, maxHP/10));
34383438
return true;
34393439
}
34403440
else if ( isKindOf(KINDOF_MOB_NEXUS) )
34413441
{
34423442
//enforce healthBoxHeightMinimum/Maximum
3443-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3443+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34443444
//enforce healthBoxWidthMinimum/Maximum
34453445
healthBoxWidth = min(100.0f, max(66.0f, maxHP/10));
34463446
return true;
@@ -3454,7 +3454,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34543454
else
34553455
{
34563456
//enforce healthBoxHeightMinimum/Maximum
3457-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3457+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34583458
//enforce healthBoxWidthMinimum/Maximum
34593459
healthBoxWidth = min(150.0f, max(35.0f, maxHP/10));
34603460
return true;
@@ -3470,7 +3470,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34703470

34713471
//just add the major and minor axes
34723472
Real size = MAX(20.0f, MIN(150.0f, (getGeometryInfo().getMajorRadius() + getGeometryInfo().getMinorRadius())) );
3473-
healthBoxHeight = 3.0f;
3473+
healthBoxHeight = defaultHealthBoxHeight;
34743474
healthBoxWidth = MAX(20.0f, size * 2.0f);
34753475
return TRUE;
34763476

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,20 @@ void Render2DClass::Add_Outline( const RectClass & rect, float width, unsigned l
587587

588588
void Render2DClass::Add_Outline( const RectClass & rect, float width, const RectClass & uv, unsigned long color )
589589
{
590-
//
591-
// Pretty straight forward, simply add the four side of the rectangle as lines.
592-
//
593-
/** @todo colin, I had to tweak these to get precise line drawing, as we want
594-
the UV bias on, but it just isn't lining up */
595-
Add_Line (Vector2 (rect.Left + 1, rect.Bottom), Vector2 (rect.Left + 1, rect.Top + 1), width, color);
596-
Add_Line (Vector2 (rect.Left, rect.Top + 1), Vector2 (rect.Right - 1, rect.Top + 1), width, color);
597-
Add_Line (Vector2 (rect.Right, rect.Top), Vector2 (rect.Right, rect.Bottom - 1), width, color);
598-
Add_Line (Vector2 (rect.Right, rect.Bottom), Vector2 (rect.Left + 1, rect.Bottom), width, color);
590+
// Pretty straight forward, add the four side of the rectangle as lines.
591+
float lineWidthOffset = (width / 2);
592+
593+
// TheSuperHackers @bugfix fixed the lines so they overlap eachother in the corners making a full rectangle
594+
// Also offset the lines by half of their thickness so the border grows into the center of the rectangle
595+
596+
// Draw left
597+
Add_Line (Vector2 (rect.Left + lineWidthOffset, rect.Bottom), Vector2 (rect.Left + lineWidthOffset, rect.Top), width, color);
598+
// Draw top
599+
Add_Line (Vector2 (rect.Left, rect.Top + lineWidthOffset), Vector2 (rect.Right, rect.Top + lineWidthOffset), width, color);
600+
// Draw right
601+
Add_Line (Vector2 (rect.Right - lineWidthOffset, rect.Top), Vector2 (rect.Right - lineWidthOffset, rect.Bottom), width, color);
602+
// Draw bottom
603+
Add_Line (Vector2 (rect.Right, rect.Bottom - lineWidthOffset), Vector2 (rect.Left, rect.Bottom - lineWidthOffset), width, color);
599604
}
600605

601606
void Render2DClass::Render()

0 commit comments

Comments
 (0)