This patch has been committed, so just get the latest nightly build if you want try this feature yourself.I managed to make HUD code that adapts the HUD to any resolution and aspect ratio correctly, without stretching. And it didn't require an overhaul.
Essentially, this code properly positions and scales HUD elements to suit the player's screen resolution and aspect ratio, whatever they happen to be, without the need for a custom HUD table. (And don't worry; existing custom HUDs should still work properly, but they won't fully benefit from my changes. It's possible to make a custom HUD that does, though.)
Here is the patch
and some Windows builds. Be sure to try out various resolutions and aspect ratios, including unusual ones. (And make sure you aren't loading a custom HUD layout, or else none of these changes will take effect!)
All files here are currently based on revision 10174 (November 27, 2013).
Patch (The contents of the patch don't fit in one post, unfortunately.)
Windows buildWindows Blue Planet buildNow for the documentation.
The primary change is the addition of
Origin: and
Offset: to most gauges in hud_gauges.tbl. As an example, here is what the entry for the default afterburner gauge looks like with these new parameters:
+Afterburner Energy:
Origin: (0.5, 0.5)
Offset: (-238, 40)
The
Origin: parameter, which takes two floating-point values between 0 and 1, specifies the resolution-independent point of the screen that the gauge should be positioned in relation to. For example, (0.0, 0.0) is the top-left, (0.5, 0.5) (used in the example above) is the center, and (1.0, 1.0) is the bottom-right. Any values from 0 to 1 may be used here, so an origin of, say, (0.316, 0.61) is valid.
The
Offset: parameter takes two integers and specifies in pixels where the top-left pixel of the gauge should be positioned in relation to the specified origin. The example above uses (-238, 40) as its offset, which indicates that the gauge should be positioned 238 pixels to the right of and 40 pixels below the specified origin (which is (0.5, 0.5) in this case). Note that this parameter uses the adjusted base resolution (discussed below), not the screen resolution, to determine positioning.
For compatibility reasons (and HUD designers who do not wish to use the new system), the
Position: parameter is still present and works the same as before. Any gauge using this parameter will not benefit from my patch and will thus potentially stretch.
Another change is the way the HUD's base resolution works for gauges that don't use the
Position: parameter. For such gauges, if the HUD resolution's aspect ratio is not the same as the screen resolution's aspect ratio, one of the HUD resolution's dimensions (width or height) will be enlarged so that both ratios match. So, for example, if the HUD resolution is 1024x768 (4:3) and the screen resolution is 1440x900 (16:10), the HUD resolution will be expanded to 1228x768 (approximately 16:10). This is done before determining where to actually place the gauge.
This patch completely adapts the internal HUD to this system, so a hud_gauges.tbl or *-hdg.tbm is no longer needed to prevent the retail HUD from stretching.
I hope this description is clear enough. If you have any questions or comments about this patch, post them here.
And now, here are tabled versions of the built-in HUD.
These are for reference and modding purposes only and should not be included with the MediaVPs.FreeSpace 2:
#Gauge Config
$Base: (1024, 768)
$Min: (1024, 600)
$Gauges:
+Messages:
Origin: (0.0, 0.0)
Offset: (8, 5)
+Training Messages:
Origin: (0.5, 0.5)
Offset: (-133, -259)
+Support:
Origin: (0.5, 0.5)
Offset: (-53, 150)
+Damage:
Origin: (0.5, 0.0)
Offset: (-72, 61)
+Wingman Status:
Origin: (1.0, 0.0)
Offset: (-92, 144)
+Auto Speed:
Origin: (1.0, 1.0)
Offset: (-64, -96)
+Auto Target:
Origin: (1.0, 1.0)
Offset: (-64, -120)
+Countermeasures:
Origin: (1.0, 1.0)
Offset: (-144, -166)
+Talking Head:
Origin: (0.0, 0.0)
Offset: (5, 56)
+Directives:
Origin: (0.0, 0.5)
Offset: (5, -106)
+Weapons:
Origin: (1.0, 1.0)
Offset: (-144, -257)
+Objective Notify:
Origin: (0.5, 0.5)
Offset: (-76, -200)
+Squad Message:
Origin: (1.0, 0.0)
Offset: (-197, 5)
+Lag:
Origin: (0.5, 0.5)
Offset: (115, 145)
+Mini Target Shields:
Origin: (0.5, 0.5)
Offset: (-15, 86)
+Player Shields:
Origin: (0.5, 1.0)
Offset: (112, -98)
+Target Shields:
Origin: (0.5, 1.0)
Offset: (-220, -98)
+Escort View:
Origin: (1.0, 0.5)
Offset: (-159, -54)
+Mission Time:
Origin: (1.0, 1.0)
Offset: (-55, -52)
+Target Monitor:
Origin: (0.0, 1.0)
Offset: (5, -178)
+Extra Target Data:
Origin: (0.0, 1.0)
Offset: (5, -216)
+Radar:
Origin: (0.5, 1.0)
Offset: (-101, -178)
+Afterburner Energy:
Origin: (0.5, 0.5)
Offset: (-238, 40)
+Weapon Energy:
Origin: (0.5, 0.5)
Offset: (154, 40)
+Text Warnings:
Origin: (0.5, 0.5)
Offset: (0, -109)
+Center Reticle:
Origin: (0.5, 0.5)
Offset: (-19, -14)
+Throttle:
Origin: (0.5, 0.5)
Offset: (-166, -115)
+Threat Indicator:
Origin: (0.5, 0.5)
Offset: (62, -115)
+Lead Indicator:
+Lock Indicator:
+Multiplayer Messages:
Origin: (0.0, 0.5)
Offset: (8, -144)
+Voice Status:
Origin: (0.0, 0.5)
Offset: (8, -129)
+Ping:
Origin: (1.0, 0.0)
Offset: (-128, 5)
+Supernova:
Origin: (0.5, 0.5)
Offset: (-342, -214)
+Offscreen Indicator:
+Target Brackets:
+Orientation Tee:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Hostile Triangle:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Target Triangle:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Missile Triangles:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Kills:
Origin: (1.0, 1.0)
Offset: (-144, -144)
+Fixed Messages:
+ETS Retail:
Origin: (1.0, 1.0)
Offset: (-144, -120)
$End Gauges
#End
FreeSpace Port:
$Reticle Style: FS1
#Gauge Config
$Base: (1024, 768)
$Min: (1024, 600)
$Gauges:
+Messages:
Origin: (0.0, 0.0)
Offset: (8, 5)
+Training Messages:
Origin: (0.5, 0.5)
Offset: (-133, -259)
+Support:
Origin: (0.5, 0.5)
Offset: (-53, 150)
+Damage:
Origin: (0.5, 0.0)
Offset: (-72, 61)
+Wingman Status:
Origin: (1.0, 0.0)
Offset: (-92, 144)
+Auto Speed:
Origin: (1.0, 1.0)
Offset: (-64, -96)
+Auto Target:
Origin: (1.0, 1.0)
Offset: (-64, -120)
+Countermeasures:
Origin: (1.0, 1.0)
Offset: (-144, -166)
+Talking Head:
Origin: (0.0, 0.0)
Offset: (5, 56)
+Directives:
Origin: (0.0, 0.5)
Offset: (5, -106)
+Weapons:
Origin: (1.0, 1.0)
Offset: (-144, -257)
+Objective Notify:
Origin: (0.5, 0.5)
Offset: (-76, -200)
+Squad Message:
Origin: (1.0, 0.0)
Offset: (-197, 5)
+Lag:
Origin: (0.5, 0.5)
Offset: (115, 145)
+Mini Target Shields:
Origin: (0.5, 0.5)
Offset: (-15, 86)
+Player Shields:
Origin: (0.5, 1.0)
Offset: (112, -98)
+Target Shields:
Origin: (0.5, 1.0)
Offset: (-220, -98)
+Escort View:
Origin: (1.0, 0.5)
Offset: (-159, -54)
+Mission Time:
Origin: (1.0, 1.0)
Offset: (-55, -52)
+Target Monitor:
Origin: (0.0, 1.0)
Offset: (5, -178)
+Extra Target Data:
Origin: (0.0, 1.0)
Offset: (5, -216)
+Radar:
Origin: (0.5, 1.0)
Offset: (-101, -178)
+Afterburner Energy:
Origin: (0.5, 0.5)
Offset: (-238, 40)
+Weapon Energy:
Origin: (0.5, 0.5)
Offset: (154, 40)
+Text Warnings:
Origin: (0.5, 0.5)
Offset: (0, -109)
+Center Reticle:
Origin: (0.5, 0.5)
Offset: (-19, -8)
+Throttle:
Origin: (0.5, 0.5)
Offset: (-165, 6)
+Threat Indicator:
Origin: (0.5, 0.5)
Offset: (-126, -165)
+Lead Indicator:
+Lock Indicator:
+Weapon Linking:
Origin: (0.5, 0.5)
Offset: (86, 3)
+Multiplayer Messages:
Origin: (0.0, 0.5)
Offset: (8, -144)
+Voice Status:
Origin: (0.0, 0.5)
Offset: (8, -129)
+Ping:
Origin: (1.0, 0.0)
Offset: (-128, 5)
+Supernova:
Origin: (0.5, 0.5)
Offset: (-342, -214)
+Offscreen Indicator:
+Target Brackets:
+Orientation Tee:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Hostile Triangle:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Target Triangle:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Missile Triangles:
Origin: (0.5, 0.5)
Offset: (0, 3)
+Kills:
Origin: (1.0, 1.0)
Offset: (-144, -144)
+Fixed Messages:
+ETS Retail:
Origin: (1.0, 1.0)
Offset: (-144, -120)
$End Gauges
#End
(Yes, I understand that we're in a feature freeze right now. I just wanted to make this patch available now.)