-
Notifications
You must be signed in to change notification settings - Fork 104
bugfix(gui): implement resolution scaling for unit health and info #1607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
||
// do this so health bar doesn't get too skinny or fat after scaling | ||
//healthBoxHeight = max(3.0f, healthBoxHeight); | ||
healthBoxHeight = 3.0f; |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
20904b1
to
09d6dae
Compare
Quick Rebase |
09d6dae
to
d068267
Compare
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. |
d068267
to
a64a7ee
Compare
Moved the scale variable into the SCALE_ICONS_WITH_ZOOM_ML for the draw veterancy function |
a64a7ee
to
c172cfe
Compare
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. |
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. |
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 |
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 |
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. |
c172cfe
to
6ca0750
Compare
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. |
There was a problem hiding this 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.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Show resolved
Hide resolved
@@ -3925,23 +3916,23 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion) | |||
|
|||
} | |||
|
|||
Real healthBoxWidth = healthBarRegion->width(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…ns relative to defaults
6ca0750
to
bdca8c3
Compare
Should be looking better now, ho ho ho. |
db916a5
to
4b5bfae
Compare
4b5bfae
to
542f98b
Compare
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.