Skip to content

Conversation

Mauller
Copy link

@Mauller Mauller commented Sep 19, 2025

This PR implements raw resolution and aspect ratio scaling for the unit health bar and other info icons.
This PR also adds functions to the display for calculating the display width and height relative to the default resolutions. And a function to calculate the diference in the current aspect ratio from the default.

Zoom based scaling to keep unit info scaled relative to units will be looked at in another PR.

There is also a small fix for the veterancy icon positioning as this was not implemented properly in the original code and broke when the health bar is scaled properly.

The only thing not scaled in this at the moment is the bombed icons, these will be dealt with in another PR.
This is due to icon placement changes being required so the icon is placed on the target instead of at the feet of the unit placing the bomb.


// 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.

@Mauller Mauller self-assigned this Sep 19, 2025
@Mauller Mauller added Bug Something is not working right, typically is user facing GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Major Severity: Minor < Major < Critical < Blocker and removed Minor Severity: Minor < Major < Critical < Blocker labels Sep 19, 2025
@xezon
Copy link

xezon commented Sep 20, 2025

Is this a piece split off of #1573 ?

@Mauller
Copy link
Author

Mauller commented Sep 20, 2025

Is this a piece split off of #1573 ?

Yes, this only implements the resolution scaling of the UI elements and some small fixes to the veterancy icon and compute health region code.

I did not close the original as I will build the zoom scaling off this pr when finalised and merged.

@@ -2959,8 +2954,8 @@ 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.

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from 20904b1 to 09d6dae Compare September 20, 2025 16:17
@Mauller
Copy link
Author

Mauller commented Sep 20, 2025

Quick Rebase

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from 09d6dae to d068267 Compare September 20, 2025 17:11
@Mauller
Copy link
Author

Mauller commented Sep 20, 2025

Tweaked this now so the followup can implement user based options within InGameUI.

This version also reduces the overhead a little since the scaling factor is only calculated once at initialisation and when the resolution gets changed.

So with this, the unit info acts the same as with retail, but scales all the unit gui elements properly with resolution.

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from d068267 to a64a7ee Compare September 21, 2025 09:45
@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

Moved the scale variable into the SCALE_ICONS_WITH_ZOOM_ML for the draw veterancy function

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from a64a7ee to c172cfe Compare September 21, 2025 10:00
@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

Tweaked veterancy icon position, it should be in exactly the same place now, it might look slightly offset but that's actually the health bar being marginally shifted left due to the above mentioned change.

@xezon
Copy link

xezon commented Sep 21, 2025

Health bar size is not correct on higher solution.

In 800x600, health bar is 1 pixel high. In 1600x1200 it is 4 pixels high.

healthbar

@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

Health bar size is not correct on higher solution.

In 800x600, health bar is 1 pixel high. In 1600x1200 it is 4 pixels high.

healthbar

Yes because it's scaling with the resolution, it's proportions are the same compared to 800x600

If the health bar remaind the same thickness as it is at 800x600 then you will barely see anything of it at higher resolutions.

@xezon
Copy link

xezon commented Sep 21, 2025

I think it is wrong. If health bar is 1px at 800x600, then it should be 2px at 1600x1200.

@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

I think it is wrong. If health bar is 1px at 800x600, then it should be 2px at 1600x1200.

Its not wrong, it's because of the way the health bar is setup. The border does not scale with the health bar and remains at only 1 pixel in height.

The health bar region is 6 pixels high, which is double the default of 3 at 800x600, but there is always a 1 pixel border.

This means that at 800x600 there is only a single pixel for the health bar info itself while theres 4 at 1600x1200

So overall the health bar is scaled properly, it's just that relatively more of the health bar is taken up by the border at 800x600

@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

The other way to work this would be to also scale the health bar border at higher resolutions, it would also make the health bar more visible when health is getting depleted and should keep the health info itself scaled similar to 800x600

@xezon
Copy link

xezon commented Sep 21, 2025

I think it is wrong. If health bar is 1px at 800x600, then it should be 2px at 1600x1200.

Its not wrong, it's because of the way the health bar is setup. The border does not scale with the health bar and remains at only 1 pixel in height.

The health bar region is 6 pixels high, which is double the default of 3 at 800x600, but there is always a 1 pixel border.

This means that at 800x600 there is only a single pixel for the health bar info itself while theres 4 at 1600x1200

So overall the health bar is scaled properly, it's just that relatively more of the health bar is taken up by the border at 800x600

I think visually it should look twice as big. Right now it looks 4 times as big.

@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

I think it is wrong. If health bar is 1px at 800x600, then it should be 2px at 1600x1200.

Its not wrong, it's because of the way the health bar is setup. The border does not scale with the health bar and remains at only 1 pixel in height.
The health bar region is 6 pixels high, which is double the default of 3 at 800x600, but there is always a 1 pixel border.
This means that at 800x600 there is only a single pixel for the health bar info itself while theres 4 at 1600x1200
So overall the health bar is scaled properly, it's just that relatively more of the health bar is taken up by the border at 800x600

I think visually it should look twice as big. Right now it looks 4 times as big.

I am working on something that should do that, some of the functions aren't working quite right for drawing rectangles with outlines so just currently investigating that.

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from c172cfe to 6ca0750 Compare September 21, 2025 18:08
@Mauller
Copy link
Author

Mauller commented Sep 21, 2025

Well that was a pain to dig through and find the bottom of the border drawing issue, but this should literally be looking good now.

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Looks promising, but there are still some things.

@@ -3925,23 +3916,23 @@ 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.

@@ -3925,23 +3916,23 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)

}

Real healthBoxWidth = healthBarRegion->width();
Real healthBoxHeight = max(3, healthBarRegion->height());
Copy link

Choose a reason for hiding this comment

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

With 1280x720 the scaling of the health bar will be fractionized. This creates an unfortunate coloring with washed greens in the center.

Can the positioning or rounding be optimized in a way to preserve finer details on fractional scale, for example by moving the pixels by 0.5 in both x and y ?

1280x720 at 300% zoom

1280x720

Copy link
Author

Choose a reason for hiding this comment

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

Okay to correct this i have to floor the scaled thickness of the border, this then makes sure that the border does not grow too large in intermediate resolutions.

800x600
image

1280x720
image

1600x1200
image

Copy link

Choose a reason for hiding this comment

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

Are the lines integer? If we could have float coords for the bars then the intermediate center green bar for example could cover 1 full pixel line + 2x 0.5 pixel line above and below. This should then scale nicely from 800x600 towards 1600x1200 and beyond.

Technically a half pixel line means a line with 50% opacity.

Copy link

@xezon xezon Sep 24, 2025

Choose a reason for hiding this comment

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

I tested 1280x720 and the health looks too big (the center green part). I suggest explore fractionalized drawing.

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.

We could integer scale the height of the health bar, this way it always looks clear and sharp.

Then the health bar region is only ever multiples of 3 high then the green bit scales as 1, 2, 3 pixels high etc.

Keeping the sharp look makes it clearer to see, i think having any kind of blending will make it less distinct, considering we are dealing with something only a few pixels in size.

Copy link
Author

Choose a reason for hiding this comment

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

tweaked it so the border part is less transparent and decreases with the health

Copy link

Choose a reason for hiding this comment

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

It does not scale correctly:

healthbars1400

I think the health bar scaling will be easier to test in combination with the zoom scaling. So for testing, perhaps enable the zoom scaling. I think it is important to have fractional scale, especially on the health bars, not just for resolution, but also for zoom. We do not want blocky transitions, but smooth transitions. Try to get rid of the integer positions and only lock the pixels on the screen pixel grid, not on the health bar itself.

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 itself is already scaled in pixels, the underlying functions that draw to the screen deal in screen coordinates of pixels. This includes the line and rect drawing functions.

I can enable the zoom scaling for the vertical axis of the health bar if you want to look more at that.

Copy link

Choose a reason for hiding this comment

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

I think the bar needs to be scaled in fractions of pixels, and positioned in pixels.

Do you need help with the implementation for it?

Copy link
Author

Choose a reason for hiding this comment

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

I should be alright for the minute, need to experiment with getting rect and line functions working that don't use whole pixel coordinates.

@xezon xezon added Enhancement Is new feature or request and removed Bug Something is not working right, typically is user facing labels Sep 23, 2025
@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from 6ca0750 to bdca8c3 Compare September 23, 2025 19:23
@Mauller
Copy link
Author

Mauller commented Sep 23, 2025

Should be looking better now, ho ho ho.

@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch 2 times, most recently from db916a5 to 4b5bfae Compare September 25, 2025 19:14
@Mauller Mauller force-pushed the fix-unit-info-res-scaling branch from 4b5bfae to 542f98b Compare September 26, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals GUI For graphical user interface Major Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants