Skip to content

Commit f8af912

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

File tree

8 files changed

+109
-69
lines changed

8 files changed

+109
-69
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: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,22 +2677,17 @@ 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+
healthBoxHeight *= TheInGameUI->getUnitHealthbarScaleFactor();
26892685

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;
2686+
// do this so health bar doesn't get too skinny after scaling
2687+
healthBoxHeight = max(defaultHealthBoxHeight, healthBoxHeight);
26932688

26942689
// figure out the final region for the health box
2695-
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
2690+
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
26962691
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
26972692
region.hi.x = region.lo.x + healthBoxWidth;
26982693
region.hi.y = region.lo.y + healthBoxHeight;
@@ -2829,10 +2824,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28292824
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
28302825
{
28312826
//Draw the emoticon.
2832-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
2827+
Int barWidth = healthBarRegion->width();
28332828
//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();
2829+
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
2830+
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
28362831

28372832
#ifdef SCALE_ICONS_WITH_ZOOM_ML
28382833
// adjust the width to be a % of the health bar region size
@@ -2883,9 +2878,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
28832878
Real scale = 1.0f;
28842879
#endif
28852880

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;
2881+
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2882+
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2883+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
28892884
//Int totalWidth = (boxWidth+SPACING)*numTotal;
28902885

28912886
ICoord2D screenCenter;
@@ -2950,9 +2945,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29502945
#else
29512946
Real scale = 1.0f;
29522947
#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;
2948+
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2949+
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2950+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
29562951
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29572952

29582953
ICoord2D screenCenter;
@@ -3003,8 +2998,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30032998
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
30042999
}
30053000
//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();
3001+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3002+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30083003

30093004
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30103005
// adjust the width to be a % of the health bar region size
@@ -3031,8 +3026,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30313026
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
30323027
}
30333028
// draw the icon
3034-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
3035-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
3029+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3030+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30363031

30373032
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30383033
// adjust the width to be a % of the health bar region size
@@ -3059,8 +3054,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30593054
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
30603055
}
30613056
// draw the icon
3062-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
3063-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
3057+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3058+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30643059

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

3276-
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
3277-
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
3271+
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3272+
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
32783273

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

33393334
// based on our own kind of we have certain icons to display at a size scale
33403335
Real scale;
@@ -3345,8 +3340,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33453340
else
33463341
scale = 0.5f;
33473342

3348-
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
3349-
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
3343+
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
3344+
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
33503345

33513346
#ifdef SCALE_ICONS_WITH_ZOOM_ML
33523347
// adjust the width to be a % of the health bar region size
@@ -3635,10 +3630,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36353630
// draw the icon
36363631
if( healthBarRegion )
36373632
{
3638-
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
3633+
Int barHeight = healthBarRegion->height();
36393634

3640-
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
3641-
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
3635+
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3636+
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
36423637

36433638
#ifdef SCALE_ICONS_WITH_ZOOM_ML
36443639
// adjust the width to be a % of the health bar region size
@@ -3784,19 +3779,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37843779
if (!image)
37853780
return;
37863781

3787-
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37883782
#ifdef SCALE_ICONS_WITH_ZOOM_ML
3783+
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37893784
Real objScale = scale * 1.55f;
37903785
#else
37913786
Real objScale = 1.0f;
37923787
#endif
37933788

37943789

3795-
Real vetBoxWidth = image->getImageWidth()*objScale;
3796-
Real vetBoxHeight = image->getImageHeight()*objScale;
3790+
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
3791+
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();
37973792

37983793
//
3799-
// take the center position of the object, go down to it's bottom extent, and project
3794+
// take the center position of the health region, go down to it's bottom extent, and project
38003795
// that point to the screen, that will be the "center" of our veterancy box
38013796
//
38023797

@@ -3806,11 +3801,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38063801
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
38073802
return;
38083803

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

38153806
// draw the image
38163807
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
@@ -3918,23 +3909,32 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39183909

39193910
}
39203911

3912+
Real healthBoxWidth = healthBarRegion->width();
3913+
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3914+
Real healthBoxOutlineSize = floorf(1.0f * TheInGameUI->getUnitHealthbarScaleFactor());
39213915

3916+
// draw a filled bar for the health
3917+
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
3918+
// This simplifies the handling of the health bar
3919+
TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3920+
healthBoxWidth * healthRatio, healthBoxHeight,
3921+
color );
39223922

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;
3923+
// draw the health blend line but only for intermediate resolutions
3924+
// TheSuperHackers @info we adjust the line down by the thickness of the border to keep it with one line of exposed pixels
3925+
if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3926+
Color outlineBlendColor = outlineColor - 0x77000000;
3927+
TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3928+
healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3929+
healthBoxOutlineSize + 1.0f, outlineBlendColor);
3930+
}
39293931

39303932
// draw the health box outline
3931-
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
3933+
// TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region
3934+
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3935+
healthBoxWidth, healthBoxHeight,
39323936
healthBoxOutlineSize, outlineColor );
39333937

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 );
39383938
}
39393939

39403940
}

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)