Skip to content

Commit 335f413

Browse files
committed
fix(gui): implement resolution scaling for unit health bar and info icons
1 parent 45b687a commit 335f413

File tree

8 files changed

+104
-70
lines changed

8 files changed

+104
-70
lines changed

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

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

586+
// UI scaling function methods
587+
Real m_unitInfoResolutionScaleFactor;
588+
Real m_healthResolutionScaleFactor;
589+
590+
void calcUnitInfoScaleFactor();
591+
592+
Real getUnitInfoScaleFactor();
593+
Real getUnitHealthbarScaleFactor();
594+
586595
private:
587596
virtual Int getIdleWorkerCount( void );
588597
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: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,22 +2677,19 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
26772677
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
26782678
return FALSE;
26792679

2680-
// scale the health bars according to the zoom
2681-
Real zoom = TheTacticalView->getZoom();
2682-
//Real widthScale = 1.3f / zoom;
2683-
Real widthScale = 1.0f / zoom;
2684-
//Real heightScale = 0.8f / zoom;
2685-
Real heightScale = 1.0f;
2680+
// scale the health bars according to the zoom and resolution
2681+
Real zoomScale = 1.0f / TheTacticalView->getZoom();
26862682

2687-
healthBoxWidth *= widthScale;
2688-
healthBoxHeight *= heightScale;
2683+
healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor();
2684+
// TheSuperHackers @info For now we are integer scaling the health box height
2685+
healthBoxHeight *= floorf(TheDisplay->getHeightScale());
26892686

2690-
// do this so health bar doesn't get too skinny or fat after scaling
2691-
//healthBoxHeight = max(3.0f, healthBoxHeight);
2692-
healthBoxHeight = 3.0f;
2687+
2688+
// do this so health bar doesn't get too skinny after scaling
2689+
healthBoxHeight = max(defaultHealthBoxHeight, healthBoxHeight);
26932690

26942691
// figure out the final region for the health box
2695-
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
2692+
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
26962693
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
26972694
region.hi.x = region.lo.x + healthBoxWidth;
26982695
region.hi.y = region.lo.y + healthBoxHeight;
@@ -2829,10 +2826,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28292826
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
28302827
{
28312828
//Draw the emoticon.
2832-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
2829+
Int barWidth = healthBarRegion->width();
28332830
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
2834-
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth();
2835-
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight();
2831+
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
2832+
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
28362833

28372834
#ifdef SCALE_ICONS_WITH_ZOOM_ML
28382835
// adjust the width to be a % of the health bar region size
@@ -2883,9 +2880,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
28832880
Real scale = 1.0f;
28842881
#endif
28852882

2886-
Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale);
2887-
Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale);
2888-
const Int SPACING = 1;
2883+
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2884+
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2885+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
28892886
//Int totalWidth = (boxWidth+SPACING)*numTotal;
28902887

28912888
ICoord2D screenCenter;
@@ -2950,9 +2947,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29502947
#else
29512948
Real scale = 1.0f;
29522949
#endif
2953-
Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale);
2954-
Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale);
2955-
const Int SPACING = 1;
2950+
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2951+
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2952+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
29562953
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29572954

29582955
ICoord2D screenCenter;
@@ -3003,8 +3000,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30033000
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
30043001
}
30053002
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
3006-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth();
3007-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight();
3003+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3004+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30083005

30093006
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30103007
// adjust the width to be a % of the health bar region size
@@ -3031,8 +3028,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30313028
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
30323029
}
30333030
// draw the icon
3034-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
3035-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
3031+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3032+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30363033

30373034
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30383035
// adjust the width to be a % of the health bar region size
@@ -3059,8 +3056,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30593056
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
30603057
}
30613058
// draw the icon
3062-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
3063-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
3059+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3060+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30643061

30653062
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30663063
// adjust the width to be a % of the health bar region size
@@ -3271,10 +3268,10 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
32713268
// we are going to draw the healing icon relative to the size of the health bar region
32723269
// since that region takes into account hit point size and zoom factor of the camera too
32733270
//
3274-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3271+
Int barWidth = healthBarRegion->width();
32753272

3276-
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
3277-
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
3273+
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3274+
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
32783275

32793276
#ifdef SCALE_ICONS_WITH_ZOOM_ML
32803277
// adjust the width to be a % of the health bar region size
@@ -3334,7 +3331,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33343331
// we are going to draw the healing icon relative to the size of the health bar region
33353332
// since that region takes into account hit point size and zoom factor of the camera too
33363333
//
3337-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;// used for position
3334+
Int barWidth = healthBarRegion->width();// used for position
33383335

33393336
// based on our own kind of we have certain icons to display at a size scale
33403337
Real scale;
@@ -3345,8 +3342,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33453342
else
33463343
scale = 0.5f;
33473344

3348-
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
3349-
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
3345+
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
3346+
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
33503347

33513348
#ifdef SCALE_ICONS_WITH_ZOOM_ML
33523349
// adjust the width to be a % of the health bar region size
@@ -3635,10 +3632,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36353632
// draw the icon
36363633
if( healthBarRegion )
36373634
{
3638-
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
3635+
Int barHeight = healthBarRegion->height();
36393636

3640-
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
3641-
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
3637+
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3638+
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
36423639

36433640
#ifdef SCALE_ICONS_WITH_ZOOM_ML
36443641
// adjust the width to be a % of the health bar region size
@@ -3784,19 +3781,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37843781
if (!image)
37853782
return;
37863783

3787-
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37883784
#ifdef SCALE_ICONS_WITH_ZOOM_ML
3785+
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37893786
Real objScale = scale * 1.55f;
37903787
#else
37913788
Real objScale = 1.0f;
37923789
#endif
37933790

37943791

3795-
Real vetBoxWidth = image->getImageWidth()*objScale;
3796-
Real vetBoxHeight = image->getImageHeight()*objScale;
3792+
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
3793+
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();
37973794

37983795
//
3799-
// take the center position of the object, go down to it's bottom extent, and project
3796+
// take the center position of the health region, go down to it's bottom extent, and project
38003797
// that point to the screen, that will be the "center" of our veterancy box
38013798
//
38023799

@@ -3806,11 +3803,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38063803
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
38073804
return;
38083805

3809-
Real healthBoxWidth, healthBoxHeight;
3810-
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
3811-
return;
3812-
3813-
screenCenter.x += healthBoxWidth * scale * 0.5f;
3806+
screenCenter.x += healthBarRegion->width() * 0.65f;
38143807

38153808
// draw the image
38163809
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
@@ -3918,23 +3911,24 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39183911

39193912
}
39203913

3914+
Real healthBoxWidth = healthBarRegion->width();
3915+
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3916+
// TheSuperHackers @info For now we are integer scaling the health box height so we do the same for the health box outline
3917+
Real healthBoxOutlineSize = floorf( (healthBarRegion->height() / (Int)defaultHealthBoxHeight) );
39213918

3922-
3923-
3924-
/// Real scale = 1.3f / TheTacticalView->getZoom();
3925-
Real healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3926-
3927-
Real healthBoxHeight = max(3, healthBarRegion->hi.y - healthBarRegion->lo.y);
3928-
Real healthBoxOutlineSize = 1.0f;
3919+
// draw a filled bar for the health
3920+
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
3921+
// This simplifies the handling of the health bar
3922+
TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3923+
healthBoxWidth * healthRatio, healthBoxHeight,
3924+
color );
39293925

39303926
// draw the health box outline
3931-
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
3927+
// TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region
3928+
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3929+
healthBoxWidth, healthBoxHeight,
39323930
healthBoxOutlineSize, outlineColor );
39333931

3934-
// draw a filled bar for the health
3935-
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,
3936-
(healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2,
3937-
color );
39383932
}
39393933

39403934
}

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

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

760760
TheInGameUI->recreateControlBar();
761+
TheInGameUI->refreshCustomUiResources();
762+
TheInGameUI->calcUnitInfoScaleFactor();
761763
}
762764
}
763765

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

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

16181618
TheInGameUI->recreateControlBar();
16191619
TheInGameUI->refreshCustomUiResources();
1620+
TheInGameUI->calcUnitInfoScaleFactor();
16201621
}
16211622
}
16221623
}

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

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

11691169
m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID;
11701170

1171+
m_unitInfoResolutionScaleFactor = 1.0f;
1172+
m_healthResolutionScaleFactor = 1.0f;
1173+
11711174
}
11721175

11731176
//-------------------------------------------------------------------------------------------------
@@ -1301,6 +1304,9 @@ void InGameUI::init( void )
13011304
setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor);
13021305
setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor);
13031306

1307+
// TheSuperHackers @todo implement option to retrieve user based scaling options
1308+
calcUnitInfoScaleFactor();
1309+
13041310
}
13051311

13061312
//-------------------------------------------------------------------------------------------------
@@ -6168,3 +6174,19 @@ void InGameUI::drawGameTime()
61686174
m_gameTimeString->draw(horizontalTimerOffset, m_gameTimePosition.y, m_gameTimeColor, m_gameTimeDropColor);
61696175
m_gameTimeFrameString->draw(horizontalFrameOffset, m_gameTimePosition.y, GameMakeColor(180,180,180,255), m_gameTimeDropColor);
61706176
}
6177+
6178+
void InGameUI::calcUnitInfoScaleFactor()
6179+
{
6180+
m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6181+
m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6182+
}
6183+
6184+
Real InGameUI::getUnitInfoScaleFactor()
6185+
{
6186+
return m_unitInfoResolutionScaleFactor;
6187+
}
6188+
6189+
Real InGameUI::getUnitHealthbarScaleFactor()
6190+
{
6191+
return m_healthResolutionScaleFactor;
6192+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,15 +3405,15 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34053405
if( isKindOf( KINDOF_STRUCTURE ) )
34063406
{
34073407
//enforce healthBoxHeightMinimum/Maximum
3408-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3408+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34093409
//enforce healthBoxWidthMinimum/Maximum
34103410
healthBoxWidth = min(150.0f, max(100.0f, maxHP/10));
34113411
return true;
34123412
}
34133413
else if ( isKindOf(KINDOF_MOB_NEXUS) )
34143414
{
34153415
//enforce healthBoxHeightMinimum/Maximum
3416-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3416+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34173417
//enforce healthBoxWidthMinimum/Maximum
34183418
healthBoxWidth = min(100.0f, max(66.0f, maxHP/10));
34193419
return true;
@@ -3427,7 +3427,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34273427
else
34283428
{
34293429
//enforce healthBoxHeightMinimum/Maximum
3430-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3430+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34313431
//enforce healthBoxWidthMinimum/Maximum
34323432
healthBoxWidth = min(150.0f, max(35.0f, maxHP/10));
34333433
return true;
@@ -3443,7 +3443,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34433443

34443444
//just add the major and minor axes
34453445
Real size = MAX(20.0f, MIN(150.0f, (getGeometryInfo().getMajorRadius() + getGeometryInfo().getMinorRadius())) );
3446-
healthBoxHeight = 3.0f;
3446+
healthBoxHeight = defaultHealthBoxHeight;
34473447
healthBoxWidth = MAX(20.0f, size * 2.0f);
34483448
return TRUE;
34493449

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(void)

0 commit comments

Comments
 (0)