Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class Display : public SubsystemInterface
virtual void dumpAssetUsage(const char* mapname) = 0;
#endif

//---------------------------------------------------------------------------------------
// Display scaling methods
Real getWidthScale();
Real getHeightScale();

//---------------------------------------------------------------------------------------
// View management
virtual void attachView( View *view ); ///< Attach the given view to the world
Expand Down
9 changes: 9 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,15 @@ friend class Drawable; // for selection/deselection transactions
void setDrawRMBScrollAnchor(Bool b) { m_drawRMBScrollAnchor = b; }
void setMoveRMBScrollAnchor(Bool b) { m_moveRMBScrollAnchor = b; }

// UI scaling function methods
Real m_unitInfoResolutionScaleFactor;
Real m_healthResolutionScaleFactor;

void calcUnitInfoScaleFactor();

Real getUnitInfoScaleFactor();
Real getUnitHealthbarScaleFactor();

private:
virtual Int getIdleWorkerCount( void );
virtual Object *findIdleWorker( Object *obj);
Expand Down
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ enum CrushSquishTestType CPP_11(: Int)
TEST_CRUSH_OR_SQUISH
};

const Real defaultHealthBoxHeight = 3.0f;

// ---------------------------------------------------
/**
Expand Down
12 changes: 12 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ void Display::setHeight( UnsignedInt height )

}

// Return the ratio of the current display width relative to the default resolution
Real Display::getWidthScale(void)
{
return (Real)m_width / DEFAULT_DISPLAY_WIDTH;
}

// Return the ratio of the current display height relative to the default resolution
Real Display::getHeightScale(void)
{
return (Real)m_height / DEFAULT_DISPLAY_HEIGHT;
}

//============================================================================
// Display::playLogoMovie
// minMovieLength is in milliseconds
Expand Down
108 changes: 51 additions & 57 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2677,22 +2677,19 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
return FALSE;

// scale the health bars according to the zoom
Real zoom = TheTacticalView->getZoom();
//Real widthScale = 1.3f / zoom;
Real widthScale = 1.0f / zoom;
//Real heightScale = 0.8f / zoom;
Real heightScale = 1.0f;
// scale the health bars according to the zoom and resolution
Real zoomScale = 1.0f / TheTacticalView->getZoom();

healthBoxWidth *= widthScale;
healthBoxHeight *= heightScale;
healthBoxWidth *= zoomScale * TheInGameUI->getUnitInfoScaleFactor();
// TheSuperHackers @info For now we are integer scaling the health box height
healthBoxHeight *= floorf(TheDisplay->getHeightScale());

// do this so health bar doesn't get too skinny or fat after scaling
//healthBoxHeight = max(3.0f, healthBoxHeight);
healthBoxHeight = 3.0f;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retrieved health box height from the object is already 3.0f, at higher resoutions this code prevents the health box from scaling relative to the vehicles and looks wrong. Which is why i removed it.

I reinstated the clamp on the max size of the health bar to prevent it shrinking too much when the resolution is scaled. This will also come into play more when zoom scaling is added.


// do this so health bar doesn't get too skinny after scaling
healthBoxHeight = max(defaultHealthBoxHeight, healthBoxHeight);

// figure out the final region for the health box
region.lo.x = screenCenter.x - healthBoxWidth * 0.45f;
region.lo.x = screenCenter.x - healthBoxWidth * 0.5f;
region.lo.y = screenCenter.y - healthBoxHeight * 0.5f;
region.hi.x = region.lo.x + healthBoxWidth;
region.hi.y = region.lo.y + healthBoxHeight;
Expand Down Expand Up @@ -2829,10 +2826,10 @@ void Drawable::drawEmoticon( const IRegion2D *healthBarRegion )
if( healthBarRegion && getIconInfo()->m_keepTillFrame[ ICON_EMOTICON ] >= now )
{
//Draw the emoticon.
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
Int barWidth = healthBarRegion->width();
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ ICON_EMOTICON ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand Down Expand Up @@ -2883,9 +2880,9 @@ void Drawable::drawAmmo( const IRegion2D *healthBarRegion )
Real scale = 1.0f;
#endif

Int boxWidth = REAL_TO_INT(s_emptyAmmo->getImageWidth() * scale);
Int boxHeight = REAL_TO_INT(s_emptyAmmo->getImageHeight() * scale);
const Int SPACING = 1;
Int boxWidth = s_emptyAmmo->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
Int boxHeight = s_emptyAmmo->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
//Int totalWidth = (boxWidth+SPACING)*numTotal;

ICoord2D screenCenter;
Expand Down Expand Up @@ -2950,9 +2947,9 @@ void Drawable::drawContained( const IRegion2D *healthBarRegion )
#else
Real scale = 1.0f;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like EA already tried to do some scaling here with TheGlobalData->m_ammoPipScaleFactor in SCALE_ICONS_WITH_ZOOM_ML. Does SCALE_ICONS_WITH_ZOOM_ML still have any relevance? What does it do? If it is not useful, can that be removed before we add a new scaling for it?

Copy link
Author

@Mauller Mauller Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scale icons with zoom does not have any real relevance once I properly implement the zoom scaling.

But the idea was to rescale the info icons as you zoomed into units so their size was kept uniform relative to the health bar. Which is what I reimplemented.

We could still make use of the pipscale factor though.

#endif
Int boxWidth = REAL_TO_INT(s_emptyContainer->getImageWidth() * scale);
Int boxHeight = REAL_TO_INT(s_emptyContainer->getImageHeight() * scale);
const Int SPACING = 1;
Int boxWidth = s_emptyContainer->getImageWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
Int boxHeight = s_emptyContainer->getImageHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();
const Real SPACING = 1.0f * TheInGameUI->getUnitInfoScaleFactor();
//Int totalWidth = (boxWidth+SPACING)*numTotal;

ICoord2D screenCenter;
Expand Down Expand Up @@ -3003,8 +3000,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_BOMBARD ], TheAnim2DCollection );
}
//Int barHeight = healthBarRegion.hi.y - healthBarRegion.lo.y;
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_BOMBARD ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand All @@ -3031,8 +3028,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_HOLDTHELINE ], TheAnim2DCollection );
}
// draw the icon
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_HOLDTHELINE ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand All @@ -3059,8 +3056,8 @@ void Drawable::drawBattlePlans( const IRegion2D *healthBarRegion )
getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ] = newInstance(Anim2D)( s_animationTemplates[ ICON_BATTLEPLAN_SEARCHANDDESTROY ], TheAnim2DCollection );
}
// draw the icon
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ ICON_BATTLEPLAN_SEARCHANDDESTROY ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand Down Expand Up @@ -3271,10 +3268,10 @@ void Drawable::drawHealing(const IRegion2D* healthBarRegion)
// we are going to draw the healing icon relative to the size of the health bar region
// since that region takes into account hit point size and zoom factor of the camera too
//
Int barWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;
Int barWidth = healthBarRegion->width();

Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ typeIndex ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

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

// based on our own kind of we have certain icons to display at a size scale
Real scale;
Expand All @@ -3345,8 +3342,8 @@ void Drawable::drawEnthusiastic(const IRegion2D* healthBarRegion)
else
scale = 0.5f;

Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale;
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale;
Int frameWidth = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameWidth() * scale * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ iconIndex ]->getCurrentFrameHeight() * scale * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand Down Expand Up @@ -3635,10 +3632,10 @@ void Drawable::drawDisabled(const IRegion2D* healthBarRegion)
// draw the icon
if( healthBarRegion )
{
Int barHeight = healthBarRegion->hi.y - healthBarRegion->lo.y;
Int barHeight = healthBarRegion->height();

Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth();
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight();
Int frameWidth = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameWidth() * TheInGameUI->getUnitInfoScaleFactor();
Int frameHeight = getIconInfo()->m_icon[ ICON_DISABLED ]->getCurrentFrameHeight() * TheInGameUI->getUnitInfoScaleFactor();

#ifdef SCALE_ICONS_WITH_ZOOM_ML
// adjust the width to be a % of the health bar region size
Expand Down Expand Up @@ -3784,19 +3781,19 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
if (!image)
return;

Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
#ifdef SCALE_ICONS_WITH_ZOOM_ML
Real scale = 1.3f/CLAMP_ICON_ZOOM_FACTOR( TheTacticalView->getZoom() );
Real objScale = scale * 1.55f;
#else
Real objScale = 1.0f;
#endif


Real vetBoxWidth = image->getImageWidth()*objScale;
Real vetBoxHeight = image->getImageHeight()*objScale;
Real vetBoxWidth = image->getImageWidth() * objScale * TheInGameUI->getUnitInfoScaleFactor();
Real vetBoxHeight = image->getImageHeight() * objScale * TheInGameUI->getUnitInfoScaleFactor();

//
// take the center position of the object, go down to it's bottom extent, and project
// take the center position of the health region, go down to it's bottom extent, and project
// that point to the screen, that will be the "center" of our veterancy box
//

Expand All @@ -3806,11 +3803,7 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )
if( !TheTacticalView->worldToScreen( &p, &screenCenter ) )
return;

Real healthBoxWidth, healthBoxHeight;
if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))
return;

screenCenter.x += healthBoxWidth * scale * 0.5f;
screenCenter.x += healthBarRegion->width() * 0.65f;

// draw the image
TheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);
Expand Down Expand Up @@ -3918,23 +3911,24 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)

}

Real healthBoxWidth = healthBarRegion->width();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Health bar width looks a bit different, noticeable on Troopcrawler. See right side.

image

Copy link
Author

@Mauller Mauller Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IT looks like it comes up to the black viewport to me in both, the thing that makes it look significnatly bigger is the placement of the contained pips.

Something i noticed is that the contained pips seem to integer scale and have a fixed seperation.#
So they will pop sideways at times in different resolutions or zoom levels.
When zooming with zoom scaling enabled they would often pop and move about by nearly an entire pip to the left or right

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 800x600
image

at 1600x1200
image

i think like with the health bar border, i might need to also scale the pip spacing

Copy link
Author

@Mauller Mauller Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes scaling the pip spacing made it match
1600x1200
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will make sure to do the same for ammo pips

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 1280x720 the discrepancy still occurs. Maybe is inevitable because of integer rounding?

Copy link
Author

@Mauller Mauller Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The images themselves are integer rounded within the image draw functions. so you then have that compounding loss over every extra pip while there is only a single rounding on the health bars width.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The health bar is significantly wider than originally - at 16:9 aspect. Maybe more than twice as wide.

In principle widening is ok, because the original bar indeed looks narrow, but it looks too much in comparison. I expect this will cause complaints from long time players. I see this is mainly as pronounced in Wide Screen, so it looks like something was fixed that disproportionally affects Wide Screen Resolution. Perhaps make the default width closer to the original at 4:3 aspect (currently is a bit wider at 4:3) and then provide a User Option to scale the width, from 0 to N. This way user can fine the width to his preference, which likely will be required to satisfy taste.

Also, the fixed health bar shows a proper outline on damage, whereas the original was just one color. But this means visibility on the right side is a bit reduced. Maybe fill the right side of the health bar side with less transparency to somewhat preserve the original look more, but still show the outline. You can also play with the opacity of the outline to fine tune and compensate for visibility changes.

Left side is Original 1920x1080
Right side in Patched 1920x1080

Compared at about the same height.

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The health bar is wider because it is scaled to how it looks compared to 800x600

In the original health bar, the drawOpenRect function was broken meaning it was not properly drawing a rectangular border when it should have been. This is shown by the weird extra pixels under the bottom of the health bar and it not being perfectly rectangular.

The fixed outline makes it easier to see the amount of damage taken and gives it a much cleaner look.

Copy link

@xezon xezon Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is fixed, which is good, but it is also now much different than the original in 16:9. And in 4:3 it is a bit wider than it used to be. This means we need to do something to give users the option to return to the original look, if they prefer it that way.

I say this, because this change would upset me to some degree and so I expect it can also cause upset for other players. And I am not even part of the super conservative group of people.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you compare 800x600 and 1600x1200 the width of the health bar is the same as retail compared to retail 800x600.

It is slightly shifted to the right due to fixes in the drawing of the health bar.

For scaling the UI elements, we were going to add the ability to change those in a followup PR, this PR was just to get things to scale up properly at higher resolutions in relation to 800x600 retail.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you force scale it to retail now and unlock rescale with option in follow up change?

Copy link
Author

@Mauller Mauller Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep the scaling relative to what it was meant to look like at 800x600 in this change as originally discussed.
It would make the code awkward when trying to scale it to 1080p in this change.
I can add the user option to rescale things in one of the folloup PR's, that way users can adjust it and we can adjust the default scale value.

I still need to add zoom scaling and fix the bombed icon stuff after this PR as well as add the user scaling options.

Real healthBoxHeight = max((Int)defaultHealthBoxHeight, healthBarRegion->height());
// TheSuperHackers @info For now we are integer scaling the health box height so we do the same for the health box outline
Real healthBoxOutlineSize = floorf( (healthBarRegion->height() / (Int)defaultHealthBoxHeight) );



/// Real scale = 1.3f / TheTacticalView->getZoom();
Real healthBoxWidth = healthBarRegion->hi.x - healthBarRegion->lo.x;

Real healthBoxHeight = max(3, healthBarRegion->hi.y - healthBarRegion->lo.y);
Real healthBoxOutlineSize = 1.0f;
// draw a filled bar for the health
// TheSuperHackers @info this takes up the whole size of the health rect area, the border is drawn over the top
// This simplifies the handling of the health bar
TheDisplay->drawFillRect( healthBarRegion->lo.x, healthBarRegion->lo.y,
healthBoxWidth * healthRatio, healthBoxHeight,
color );

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

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

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,8 @@ void DeclineResolution()
TheShell->recreateWindowLayouts();

TheInGameUI->recreateControlBar();
TheInGameUI->refreshCustomUiResources();
TheInGameUI->calcUnitInfoScaleFactor();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,7 @@ static void saveOptions( void )

TheInGameUI->recreateControlBar();
TheInGameUI->refreshCustomUiResources();
TheInGameUI->calcUnitInfoScaleFactor();
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,9 @@ InGameUI::InGameUI()

m_soloNexusSelectedDrawableID = INVALID_DRAWABLE_ID;

m_unitInfoResolutionScaleFactor = 1.0f;
m_healthResolutionScaleFactor = 1.0f;

}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1301,6 +1304,9 @@ void InGameUI::init( void )
setDrawRMBScrollAnchor(TheGlobalData->m_drawScrollAnchor);
setMoveRMBScrollAnchor(TheGlobalData->m_moveScrollAnchor);

// TheSuperHackers @todo implement option to retrieve user based scaling options
calcUnitInfoScaleFactor();

}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -6168,3 +6174,19 @@ void InGameUI::drawGameTime()
m_gameTimeString->draw(horizontalTimerOffset, m_gameTimePosition.y, m_gameTimeColor, m_gameTimeDropColor);
m_gameTimeFrameString->draw(horizontalFrameOffset, m_gameTimePosition.y, GameMakeColor(180,180,180,255), m_gameTimeDropColor);
}

void InGameUI::calcUnitInfoScaleFactor()
{
m_unitInfoResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
m_healthResolutionScaleFactor = max(TheDisplay->getWidthScale(), TheDisplay->getHeightScale());
}

Real InGameUI::getUnitInfoScaleFactor()
{
return m_unitInfoResolutionScaleFactor;
}

Real InGameUI::getUnitHealthbarScaleFactor()
{
return m_healthResolutionScaleFactor;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These scale factors are the preliminary work for adding user based scaling options, but i might tweak them a bit further in a followup PR when implementing that.

}
8 changes: 4 additions & 4 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3405,15 +3405,15 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
if( isKindOf( KINDOF_STRUCTURE ) )
{
//enforce healthBoxHeightMinimum/Maximum
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
//enforce healthBoxWidthMinimum/Maximum
healthBoxWidth = min(150.0f, max(100.0f, maxHP/10));
return true;
}
else if ( isKindOf(KINDOF_MOB_NEXUS) )
{
//enforce healthBoxHeightMinimum/Maximum
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
//enforce healthBoxWidthMinimum/Maximum
healthBoxWidth = min(100.0f, max(66.0f, maxHP/10));
return true;
Expand All @@ -3427,7 +3427,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)
else
{
//enforce healthBoxHeightMinimum/Maximum
healthBoxHeight = min(3.0f, max(5.0f, maxHP/50));
healthBoxHeight = min(defaultHealthBoxHeight, max(5.0f, maxHP/50));
//enforce healthBoxWidthMinimum/Maximum
healthBoxWidth = min(150.0f, max(35.0f, maxHP/10));
return true;
Expand All @@ -3443,7 +3443,7 @@ Bool Object::getHealthBoxDimensions(Real &healthBoxHeight, Real &healthBoxWidth)

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

Expand Down
Loading
Loading