-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
HUD Customization #3836
HUD Customization #3836
Conversation
Nice, what about #3444 ? |
this is a patch for wide screens has nothing to do with customization |
This PR alters HUD component sizes, won't it conflict with wide screen HUD sizing PR? |
this is normal but we compare conflicts according to multitheftauto:master rely on which pr will be merged first other pr has to adjuct to the new changes |
UpdateProperties have been added for HUD texts (components under development). Possible properties for text components (clock, money, ammo, etc.):
setPlayerHudComponentProperty('clock', 'fillColor', tocolor(50, 168, 82, 255));
setPlayerHudComponentProperty('clock', 'dropColor', tocolor(94, 14, 7, 255));
setPlayerHudComponentProperty('clock', 'fontOutline', 1);
setPlayerHudComponentProperty('clock', 'fontStyle', 'subtitles');
setPlayerHudComponentProperty('clock', 'proportional', true);
setPlayerHudComponentProperty('money', 'fillColor', tocolor(11, 102, 158, 255));
setPlayerHudComponentProperty('money', 'fillColor_second', tocolor(176, 23, 130, 255));
setPlayerHudComponentProperty('money', 'fontOutline', 1);
setPlayerHudComponentProperty('money', 'fontStyle', 'subtitles'); |
This is one of the most game-changing features, literally, because the HUD is a big part of the game that has been disabled on servers in most cases to create custom ones instead. With this, devs will save computing resources to have the HUD edited within the game's engine. Very cool. |
DoneFinally, thanks to the holiday break, I found time to finish this PR. At this point, the main objectives have been achieved, and I consider the PR ready for review and complete. Check the main message on the top. |
It's a great job, but I'd like to emphasize that the radar is precisely the component that most needs this function. Programming a new radar with all the features of the original is not trivial, and the performance impact is always high. Being able to change its position and scale would be great |
I liked your comment. But let's get to the point, this pull is more focused on the HUD itself, in the future it will be a pull only for the radar, etc. |
@FileEX What about changing size or shape of the HUD radar minimap circle? |
I understand that the radar might be one of the most anticipated parts of this PR. However, implementing changes to the radar requires a tremendous amount of time and effort. The radar is not just a single image drawn on the screen at position x, y, with dimensions w, h. It consists of many components, some of which are not even visible to the naked eye. It is far more than a single sprite. We need to consider map tiles, the radar border, the radar mask, blips, radar areas, the altimeter, and more. The source code includes many functions responsible for drawing different parts of the radar, such as While I’m not ruling out the possibility of working on the radar in the future, it certainly won't be part of this PR. Including it would delay this PR for several more months, and reviewing such a large PR would be significantly more challenging. If I find that these functions are widely used and in high demand, I’ll be motivated to start working on the radar and create a separate PR specifically for it. |
if (!StringToEnum(std::get<std::string>(value), val)) | ||
return false; | ||
|
||
// I don't know why, but calling StringToEnum causes the "hud" pointer to become invalid, leading to a crash |
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.
Did you investigate with a debugger? Manually stepping through assembly code?
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.
No, I decided it’s not significant in the context of this PR. I resolved the crash as you can see. I can address it later and potentially fix EnumToString, but it shouldn’t have a major impact on this PR or, for example, block its merge.
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.
If you already have the branch and code in front of you, please invest a few minutes and debug the issue.
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 FindValue function for some reason overwrites the value of the variable on the stack. As seen here, outResult equals 0x0177dc13
, which is the variable val, but for some reason, 0x0177dc14
(the variable hud) is also overwritten, as shown by the breakpoint data. I don't know why this is happening; the ASM code doesn't indicate stack overwriting. Most likely, inlining this function is a bad idea but idk
I'm glad this PR got merged, nice work @FileEX Maybe In the future you could add a It would fix this issue: #3807 For e.g. currently the healthbar has a 0 minimum and 176 maximum value and because of that the excess hp is not shown. (not sure if i used the right words here sorry) The logic is already done in GTA, just take a look at lung capacity bar and armor bar. They share the same width but works with total different maximum values. |
Closes #3682
This PR adds customization for the default HUD in GTA.
Here is the full list of available properties:
General
fillColor
anddropColor
ignore the provided alpha value to preserve original fade-in/fade-out animations. Use this parameter to override that behavior.resetPlayerHudComponentProperty
.Bars
Texts
Components
Components like crosshair, radar, help_text, and vital_stats remain unchanged and are not supported by these functions. Adapting the radar to these functions would take significant time, and the same effect can be achieved by replacing textures with shaders or creating a custom radar.
It’s also possible to use all to reset all properties of a specific component or all properties of all components (the entire HUD).
Syntax
Colors are returned in the format r, g, b, a.
Example (from screenshoots)
Known Issues
Due to a rendering bug in GTA, setting transparency for text with outline or shadow causes a visual glitch, resulting in blurred/smudged text. Transparency only works correctly on text without outline and shadow.
