Skip to content

Commit 542f98b

Browse files
committed
fix(gui): implement resolution scaling for unit health bar and info icons
1 parent 5ef9232 commit 542f98b

8 files changed

Lines changed: 109 additions & 69 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( void );
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
@@ -155,6 +155,7 @@ enum CrushSquishTestType CPP_11(: Int)
155155
TEST_CRUSH_OR_SQUISH
156156
};
157157

158+
const Real defaultHealthBoxHeight = 3.0f;
158159

159160
// ---------------------------------------------------
160161
/**

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

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,22 +2687,17 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
26872687
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
26882688
return FALSE;
26892689

2690-
// scale the health bars according to the zoom
2691-
Real zoom = TheTacticalView->getZoom();
2692-
//Real widthScale = 1.3f / zoom;
2693-
Real widthScale = 1.0f / zoom;
2694-
//Real heightScale = 0.8f / zoom;
2695-
Real heightScale = 1.0f;
2690+
// scale the health bars according to the zoom and resolution
2691+
Real zoomScale = 1.0f / TheTacticalView->getZoom();
26962692

2697-
healthBoxWidth *= widthScale;
2698-
healthBoxHeight *= heightScale;
2693+
healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor();
2694+
healthBoxHeight *= TheInGameUI->getUnitHealthbarScaleFactor();
26992695

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

27042699
// figure out the final region for the health box
2705-
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
2700+
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
27062701
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
27072702
region.hi.x = region.lo.x + healthBoxWidth;
27082703
region.hi.y = region.lo.y + healthBoxHeight;
@@ -2839,10 +2834,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28392834
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
28402835
{
28412836
//Draw the emoticon.
2842-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
2837+
Int barWidth = healthBarRegion->width();
28432838
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
2844-
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth();
2845-
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight();
2839+
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
2840+
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
28462841

28472842
#ifdef SCALE_ICONS_WITH_ZOOM_ML
28482843
// adjust the width to be a % of the health bar region size
@@ -2893,9 +2888,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
28932888
Real scale = 1.0f;
28942889
#endif
28952890

2896-
Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale);
2897-
Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale);
2898-
const Int SPACING = 1;
2891+
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2892+
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2893+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
28992894
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29002895

29012896
ICoord2D screenCenter;
@@ -2960,9 +2955,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29602955
#else
29612956
Real scale = 1.0f;
29622957
#endif
2963-
Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale);
2964-
Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale);
2965-
const Int SPACING = 1;
2958+
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2959+
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2960+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
29662961
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29672962

29682963
ICoord2D screenCenter;
@@ -3013,8 +3008,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30133008
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
30143009
}
30153010
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
3016-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth();
3017-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight();
3011+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3012+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30183013

30193014
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30203015
// adjust the width to be a % of the health bar region size
@@ -3041,8 +3036,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30413036
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
30423037
}
30433038
// draw the icon
3044-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
3045-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
3039+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3040+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30463041

30473042
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30483043
// adjust the width to be a % of the health bar region size
@@ -3069,8 +3064,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30693064
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
30703065
}
30713066
// draw the icon
3072-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
3073-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
3067+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3068+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30743069

30753070
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30763071
// adjust the width to be a % of the health bar region size
@@ -3281,10 +3276,10 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
32813276
// we are going to draw the healing icon relative to the size of the health bar region
32823277
// since that region takes into account hit point size and zoom factor of the camera too
32833278
//
3284-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3279+
Int barWidth = healthBarRegion->width();
32853280

3286-
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
3287-
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
3281+
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3282+
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
32883283

32893284
#ifdef SCALE_ICONS_WITH_ZOOM_ML
32903285
// adjust the width to be a % of the health bar region size
@@ -3344,7 +3339,7 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33443339
// we are going to draw the healing icon relative to the size of the health bar region
33453340
// since that region takes into account hit point size and zoom factor of the camera too
33463341
//
3347-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;// used for position
3342+
Int barWidth = healthBarRegion->width();// used for position
33483343

33493344
// based on our own kind of we have certain icons to display at a size scale
33503345
Real scale;
@@ -3355,8 +3350,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33553350
else
33563351
scale = 0.5f;
33573352

3358-
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
3359-
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
3353+
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
3354+
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
33603355

33613356
#ifdef SCALE_ICONS_WITH_ZOOM_ML
33623357
// adjust the width to be a % of the health bar region size
@@ -3645,10 +3640,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36453640
// draw the icon
36463641
if( healthBarRegion )
36473642
{
3648-
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
3643+
Int barHeight = healthBarRegion->height();
36493644

3650-
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
3651-
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
3645+
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3646+
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
36523647

36533648
#ifdef SCALE_ICONS_WITH_ZOOM_ML
36543649
// adjust the width to be a % of the health bar region size
@@ -3794,19 +3789,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37943789
if (!image)
37953790
return;
37963791

3797-
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37983792
#ifdef SCALE_ICONS_WITH_ZOOM_ML
3793+
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37993794
Real objScale = scale * 1.55f;
38003795
#else
38013796
Real objScale = 1.0f;
38023797
#endif
38033798

38043799

3805-
Real vetBoxWidth = image->getImageWidth()*objScale;
3806-
Real vetBoxHeight = image->getImageHeight()*objScale;
3800+
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
3801+
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();
38073802

38083803
//
3809-
// take the center position of the object, go down to it's bottom extent, and project
3804+
// take the center position of the health region, go down to it's bottom extent, and project
38103805
// that point to the screen, that will be the "center" of our veterancy box
38113806
//
38123807

@@ -3816,11 +3811,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38163811
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
38173812
return;
38183813

3819-
Real healthBoxWidth, healthBoxHeight;
3820-
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
3821-
return;
3822-
3823-
screenCenter.x += healthBoxWidth * scale * 0.5f;
3814+
screenCenter.x += healthBarRegion->width() * 0.65f;
38243815

38253816
// draw the image
38263817
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
@@ -3925,23 +3916,32 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39253916

39263917
}
39273918

3919+
Real healthBoxWidth = healthBarRegion->width();
3920+
Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
3921+
Real healthBoxOutlineSize = floorf(1.0f * TheInGameUI->getUnitHealthbarScaleFactor());
39283922

3923+
// draw a filled bar for the health
3924+
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
3925+
// This simplifies the handling of the health bar
3926+
TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3927+
healthBoxWidth * healthRatio, healthBoxHeight,
3928+
color );
39293929

3930-
3931-
/// Real scale = 1.3f / TheTacticalView->getZoom();
3932-
Real healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
3933-
3934-
Real healthBoxHeight = max(3, healthBarRegion->hi.y - healthBarRegion->lo.y);
3935-
Real healthBoxOutlineSize = 1.0f;
3930+
// draw the health blend line but only for intermediate resolutions
3931+
// TheSuperHackers @info we adjust the line down by the thickness of the border to keep it with one line of exposed pixels
3932+
if (fmod(healthBoxHeight, defaultHealthBoxHeight) > 0.0f) {
3933+
Color outlineBlendColor = outlineColor - 0x77000000;
3934+
TheDisplay->drawLine( healthBarRegion->lo.x, healthBarRegion->lo.y + healthBoxOutlineSize,
3935+
healthBarRegion->lo.x + healthBoxWidth * healthRatio, healthBarRegion->lo.y + healthBoxOutlineSize,
3936+
healthBoxOutlineSize + 1.0f, outlineBlendColor);
3937+
}
39363938

39373939
// draw the health box outline
3938-
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y, healthBoxWidth, healthBoxHeight,
3940+
// TheSuperHackers @info when drawing the outline, the underlying function grows the outline towards the center of the region
3941+
TheDisplay->drawOpenRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
3942+
healthBoxWidth, healthBoxHeight,
39393943
healthBoxOutlineSize, outlineColor );
39403944

3941-
// draw a filled bar for the health
3942-
TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, healthBarRegion->lo.y + 1,
3943-
(healthBoxWidth - 2) * healthRatio, healthBoxHeight - 2,
3944-
color );
39453945
}
39463946

39473947
}

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

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

767767
TheInGameUI->recreateControlBar();
768+
TheInGameUI->refreshCustomUiResources();
769+
TheInGameUI->calcUnitInfoScaleFactor();
768770
}
769771
}
770772

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

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

15071507
TheInGameUI->recreateControlBar();
15081508
TheInGameUI->refreshCustomUiResources();
1509+
TheInGameUI->calcUnitInfoScaleFactor();
15091510
}
15101511
}
15111512
}

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

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

10871087
m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID;
10881088

1089+
m_unitInfoResolutionScaleFactor = 1.0f;
1090+
m_healthResolutionScaleFactor = 1.0f;
1091+
10891092
}
10901093

10911094
//-------------------------------------------------------------------------------------------------
@@ -1219,6 +1222,9 @@ void InGameUI::init( void )
12191222
setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor);
12201223
setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor);
12211224

1225+
// TheSuperHackers @todo implement option to retrieve user based scaling options
1226+
calcUnitInfoScaleFactor();
1227+
12221228
}
12231229

12241230
//-------------------------------------------------------------------------------------------------
@@ -5909,3 +5915,19 @@ void InGameUI::drawGameTime()
59095915
m_gameTimeString->draw(horizontalTimerOffset, m_gameTimePosition.y, m_gameTimeColor, m_gameTimeDropColor);
59105916
m_gameTimeFrameString->draw(horizontalFrameOffset, m_gameTimePosition.y, GameMakeColor(180,180,180,255), m_gameTimeDropColor);
59115917
}
5918+
5919+
void InGameUI::calcUnitInfoScaleFactor()
5920+
{
5921+
m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
5922+
m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
5923+
}
5924+
5925+
Real InGameUI::getUnitInfoScaleFactor()
5926+
{
5927+
return m_unitInfoResolutionScaleFactor;
5928+
}
5929+
5930+
Real InGameUI::getUnitHealthbarScaleFactor()
5931+
{
5932+
return m_healthResolutionScaleFactor;
5933+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,15 +3379,15 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
33793379
if( isKindOf( KINDOF_STRUCTURE ) )
33803380
{
33813381
//enforce healthBoxHeightMinimum/Maximum
3382-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3382+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
33833383
//enforce healthBoxWidthMinimum/Maximum
33843384
healthBoxWidth = min(150.0f, max(100.0f, maxHP/10));
33853385
return true;
33863386
}
33873387
else if ( isKindOf(KINDOF_MOB_NEXUS) )
33883388
{
33893389
//enforce healthBoxHeightMinimum/Maximum
3390-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3390+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
33913391
//enforce healthBoxWidthMinimum/Maximum
33923392
healthBoxWidth = min(100.0f, max(66.0f, maxHP/10));
33933393
return true;
@@ -3401,7 +3401,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34013401
else
34023402
{
34033403
//enforce healthBoxHeightMinimum/Maximum
3404-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3404+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34053405
//enforce healthBoxWidthMinimum/Maximum
34063406
healthBoxWidth = min(150.0f, max(35.0f, maxHP/10));
34073407
return true;
@@ -3417,7 +3417,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34173417

34183418
//just add the major and minor axes
34193419
Real size = MAX(20.0f, MIN(150.0f, (getGeometryInfo().getMajorRadius() + getGeometryInfo().getMinorRadius())) );
3420-
healthBoxHeight = 3.0f;
3420+
healthBoxHeight = defaultHealthBoxHeight;
34213421
healthBoxWidth = MAX(20.0f, size * 2.0f);
34223422
return TRUE;
34233423

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

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

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

604609
void Render2DClass::Render(void)

0 commit comments

Comments
 (0)