@@ -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}
0 commit comments