sethudsize and aspect ratios

Moderator: GZDoom Developers

Post Reply
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

sethudsize and aspect ratios

Post by Isle »

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.
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: sethudsize and aspect ratios

Post by bagheadspidey »

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]?
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: sethudsize and aspect ratios

Post by Isle »

that doesn't work, i was doing the same math while testing. it just winds up with a squashed box.
User avatar
Xenaero
Posts: 397
Joined: Wed May 05, 2004 8:14 am
Location: Knee-Deep in ACS
Contact:

Re: sethudsize and aspect ratios

Post by Xenaero »

I've used this to help adjust my hudmessages when I want to pin them to a specific place.
User avatar
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

Post by Macil »

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):
Spoiler: fround and support
Then, 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 );
...
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.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”