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