while messing around with hudmessage and camera textures i found out that the only way to get a non 4:3 hud was to set it to the same size as the screen. IE: if the screen is 640x360 (16:9), using sethudsize(640, 360, 1) will fill the screen. but any other resolution will get a 4:3 box.
I'd like to suggest adding an option to sethudsize to force the ratio to the current screen ratio. it would make it easier when covering the screen in hudmessages to not have to worry about screen ratios.
sethudsize and aspect ratios
Moderator: GZDoom Developers
- bagheadspidey
- Posts: 1490
- Joined: Sat Oct 20, 2007 10:31 pm
- Contact:
Re: sethudsize and aspect ratios
I think you would still have to detect the aspect ratio and use a camera texture matching that, otherwise it will look squished if you fill the screen with it... Not that that's completely related, I guess.
Couldn't you use something like [wiki=Adjustedhudwidth]this[/wiki]?
Couldn't you use something like [wiki=Adjustedhudwidth]this[/wiki]?
Re: sethudsize and aspect ratios
that doesn't work, i was doing the same math while testing. it just winds up with a squashed box.
Re: sethudsize and aspect ratios
I've used this to help adjust my hudmessages when I want to pin them to a specific place.
- bagheadspidey
- Posts: 1490
- Joined: Sat Oct 20, 2007 10:31 pm
- Contact:
- Macil
- Posts: 2529
- Joined: Mon Mar 22, 2004 7:00 pm
- Preferred Pronouns: He/Him
- Location: California, USA. Previously known as "Agent ME".
- Contact:
Re: sethudsize and aspect ratios
Here's some code from a project I've been working on that aligns parts of the HUD to the left and right sides of the screen, and works correctly on all aspect ratios and settings that I knew about and could test.
Have the [wiki]Getaspectratio[/wiki] function and the fround function in your code (this one given below):
I also recommend to put the parts of the Hud that get updated regularly inside a do-while block inside the main while block, and only jump outside of the do-while block when the aspect ratio changes so that way the aspect ratio isn't recalculated every frame.
Also note that the script is marked clientside. If you don't do this, it won't work in Skulltag, because then the script would be running on the server, which rightly doesn't know or care about the client's aspect ratio.
Have the [wiki]Getaspectratio[/wiki] function and the fround function in your code (this one given below):
Spoiler: fround and supportThen, make your HUD code look like this:
Code: Select all
script 500 OPEN clientside
{
// If you want to use some other size instead of (640,480), make sure
// to change 640.0 and 480 values found later too.
SetHudSize(640,480,1);
int aspect, adjWidth, left, right;
while(true)
{
aspect = getaspectratio();
adjWidth = aspect * 480;
left = fround((640.0-adjWidth)/2);
right = fround((adjWidth+640.0)/2);
// This next hudmessage is aligned along the left side. The left+0.1 means the message is aligned to left side.
SetFont("HUDLEFT");
HudMessageBold(s:"A"; HUDMSG_PLAIN, HUDLeftHID, CR_UNTRANSLATED,
left+0.1, 0.1,
0.0 );
// This next hudmessage is aligned along the right side. The right+0.2 means the message is aligned to right side.
SetFont("HUDRIGHT");
HudMessageBold(s:"A"; HUDMSG_PLAIN, HUDRightHID, CR_UNTRANSLATED,
right+0.2, 0.1,
0.0 );
...Also note that the script is marked clientside. If you don't do this, it won't work in Skulltag, because then the script would be running on the server, which rightly doesn't know or care about the client's aspect ratio.