Skip to content

Commit f7f2ee4

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

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
@@ -2685,22 +2685,17 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
26852685
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
26862686
return FALSE;
26872687

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

2695-
healthBoxWidth *= widthScale;
2696-
healthBoxHeight *= heightScale;
2691+
healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor();
2692+
healthBoxHeight *= TheInGameUI->getUnitHealthbarScaleFactor();
26972693

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

27022697
// figure out the final region for the health box
2703-
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
2698+
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
27042699
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
27052700
region.hi.x = region.lo.x + healthBoxWidth;
27062701
region.hi.y = region.lo.y + healthBoxHeight;
@@ -2837,10 +2832,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
28372832
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
28382833
{
28392834
//Draw the emoticon.
2840-
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
2835+
Int barWidth = healthBarRegion->width();
28412836
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
2842-
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth();
2843-
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight();
2837+
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
2838+
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
28442839

28452840
#ifdef SCALE_ICONS_WITH_ZOOM_ML
28462841
// adjust the width to be a % of the health bar region size
@@ -2891,9 +2886,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
28912886
Real scale = 1.0f;
28922887
#endif
28932888

2894-
Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale);
2895-
Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale);
2896-
const Int SPACING = 1;
2889+
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2890+
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2891+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
28972892
//Int totalWidth = (boxWidth+SPACING)*numTotal;
28982893

28992894
ICoord2D screenCenter;
@@ -2958,9 +2953,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
29582953
#else
29592954
Real scale = 1.0f;
29602955
#endif
2961-
Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale);
2962-
Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale);
2963-
const Int SPACING = 1;
2956+
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
2957+
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
2958+
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
29642959
//Int totalWidth = (boxWidth+SPACING)*numTotal;
29652960

29662961
ICoord2D screenCenter;
@@ -3011,8 +3006,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30113006
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
30123007
}
30133008
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
3014-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth();
3015-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight();
3009+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3010+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30163011

30173012
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30183013
// adjust the width to be a % of the health bar region size
@@ -3039,8 +3034,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30393034
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
30403035
}
30413036
// draw the icon
3042-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
3043-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
3037+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3038+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30443039

30453040
#ifdef SCALE_ICONS_WITH_ZOOM_ML
30463041
// adjust the width to be a % of the health bar region size
@@ -3067,8 +3062,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
30673062
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
30683063
}
30693064
// draw the icon
3070-
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
3071-
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
3065+
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3066+
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
30723067

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

3284-
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
3285-
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
3279+
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3280+
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
32863281

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

33473342
// based on our own kind of we have certain icons to display at a size scale
33483343
Real scale;
@@ -3353,8 +3348,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
33533348
else
33543349
scale = 0.5f;
33553350

3356-
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
3357-
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
3351+
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
3352+
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
33583353

33593354
#ifdef SCALE_ICONS_WITH_ZOOM_ML
33603355
// adjust the width to be a % of the health bar region size
@@ -3643,10 +3638,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
36433638
// draw the icon
36443639
if( healthBarRegion )
36453640
{
3646-
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
3641+
Int barHeight = healthBarRegion->height();
36473642

3648-
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
3649-
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
3643+
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
3644+
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();
36503645

36513646
#ifdef SCALE_ICONS_WITH_ZOOM_ML
36523647
// adjust the width to be a % of the health bar region size
@@ -3792,19 +3787,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
37923787
if (!image)
37933788
return;
37943789

3795-
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37963790
#ifdef SCALE_ICONS_WITH_ZOOM_ML
3791+
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
37973792
Real objScale = scale * 1.55f;
37983793
#else
37993794
Real objScale = 1.0f;
38003795
#endif
38013796

38023797

3803-
Real vetBoxWidth = image->getImageWidth()*objScale;
3804-
Real vetBoxHeight = image->getImageHeight()*objScale;
3798+
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
3799+
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();
38053800

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

@@ -3814,11 +3809,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
38143809
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
38153810
return;
38163811

3817-
Real healthBoxWidth, healthBoxHeight;
3818-
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
3819-
return;
3820-
3821-
screenCenter.x += healthBoxWidth * scale * 0.5f;
3812+
screenCenter.x += healthBarRegion->width() * 0.65f;
38223813

38233814
// draw the image
38243815
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
@@ -3926,23 +3917,32 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
39263917

39273918
}
39283919

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

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

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

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

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

39483948
}

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
@@ -1622,6 +1622,7 @@ static void saveOptions( void )
16221622

16231623
TheInGameUI->recreateControlBar();
16241624
TheInGameUI->refreshCustomUiResources();
1625+
TheInGameUI->calcUnitInfoScaleFactor();
16251626
}
16261627
}
16271628
}

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

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

11711171
m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID;
11721172

1173+
m_unitInfoResolutionScaleFactor = 1.0f;
1174+
m_healthResolutionScaleFactor = 1.0f;
1175+
11731176
}
11741177

11751178
//-------------------------------------------------------------------------------------------------
@@ -1303,6 +1306,9 @@ void InGameUI::init( void )
13031306
setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor);
13041307
setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor);
13051308

1309+
// TheSuperHackers @todo implement option to retrieve user based scaling options
1310+
calcUnitInfoScaleFactor();
1311+
13061312
}
13071313

13081314
//-------------------------------------------------------------------------------------------------
@@ -6173,3 +6179,19 @@ void InGameUI::drawGameTime()
61736179
m_gameTimeString->draw(horizontalTimerOffset, m_gameTimePosition.y, m_gameTimeColor, m_gameTimeDropColor);
61746180
m_gameTimeFrameString->draw(horizontalFrameOffset, m_gameTimePosition.y, GameMakeColor(180,180,180,255), m_gameTimeDropColor);
61756181
}
6182+
6183+
void InGameUI::calcUnitInfoScaleFactor()
6184+
{
6185+
m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6186+
m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
6187+
}
6188+
6189+
Real InGameUI::getUnitInfoScaleFactor()
6190+
{
6191+
return m_unitInfoResolutionScaleFactor;
6192+
}
6193+
6194+
Real InGameUI::getUnitHealthbarScaleFactor()
6195+
{
6196+
return m_healthResolutionScaleFactor;
6197+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3397,15 +3397,15 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
33973397
if( isKindOf( KINDOF_STRUCTURE ) )
33983398
{
33993399
//enforce healthBoxHeightMinimum/Maximum
3400-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3400+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34013401
//enforce healthBoxWidthMinimum/Maximum
34023402
healthBoxWidth = min(150.0f, max(100.0f, maxHP/10));
34033403
return true;
34043404
}
34053405
else if ( isKindOf(KINDOF_MOB_NEXUS) )
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(100.0f, max(66.0f, maxHP/10));
34113411
return true;
@@ -3419,7 +3419,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34193419
else
34203420
{
34213421
//enforce healthBoxHeightMinimum/Maximum
3422-
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
3422+
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
34233423
//enforce healthBoxWidthMinimum/Maximum
34243424
healthBoxWidth = min(150.0f, max(35.0f, maxHP/10));
34253425
return true;
@@ -3435,7 +3435,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
34353435

34363436
//just add the major and minor axes
34373437
Real size = MAX(20.0f, MIN(150.0f, (getGeometryInfo().getMajorRadius() + getGeometryInfo().getMinorRadius())) );
3438-
healthBoxHeight = 3.0f;
3438+
healthBoxHeight = defaultHealthBoxHeight;
34393439
healthBoxWidth = MAX(20.0f, size * 2.0f);
34403440
return TRUE;
34413441

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)