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