Jump to content
The Dark Mod Forums

I made a fix for UI display for non-16:9 resolution.


OnionKnight

Recommended Posts

Some time ago we added "forcescreenaspect" flag to GUI windows for this:

void idWindow::CalcClientRect(float xofs, float yofs) {
	drawRect = rect;

	if ( flags & WIN_INVERTRECT ) {
		drawRect.x = rect.x() - rect.w();
		drawRect.y = rect.y() - rect.h();
	}
	
	if (flags & WIN_SCREENASPECT) {
		float renderAspectRatio = float(renderSystem->GetScreenWidth()) / renderSystem->GetScreenHeight();
		float widthMultiplier = renderAspectRatio / (640.0f / 480.0f);
		drawRect.w /= widthMultiplier;
	}

Ideally, it should be combined with "hcenter" of course.

The plan was to go and add these flags to where they fit, but I did not return to this.

Link to comment
Share on other sites

Oh, I tried to apply forceaspectratio to Objectives, it seems to apply to single window only.
To make this flag useful, it should apply recursively to all children.

Also there are forceAspectWidth, forceAspectHeight, but they also seem to be non-recursive.

Link to comment
Share on other sites

I noticed those flags though pretty late in my exploration when I was looking at how the glasses worked. The aspect ratio is currently wrong on those galsses right now but I noticed the black transparency extends nicely onto the sides. Tried getting the spyglass looking as nice but adding a black background would also cover the spyglass lens.

I suppose the h/center and forceAspecWidth/Height have to be applied to every GUI file or at least the root windowDefs. My attempt goes for an automated approach and GUI authors can use flags to stop control it. Attaching all the stuff I did if you want to have a look.

  • Patch1.patch - Letterboxing for windowDefs. Menu cursor aspect rendering fix. Adds xOffset and yOffset to DeviceContext and a RestoreCoords() for reverse AdjustCoords() calculation.
  • Patch2.patch - Adjust clip rect coords so elements can render outside the letterbox like world books. Backgrounds will render fullscreen if the rect looks like a fullscreen rect.
  • Patch3.patch - Adds the aspectAware flag for making exceptions to rendering fullscreen rects so they become letterboxed instead.

Patch1.patch Patch2.patch Patch3.patch

  • Thanks 1
Link to comment
Share on other sites

Thank you!
I have linked this to 5282.

Yes, I think doing this at the lower level of idDeviceContext (where virtual resolution scaling happens) is the better approach than trying to do it on the idWindow level.

It seems that you assume current UIs were made for 16:9. I'm afraid the sad truth is that they were partly made for 16:9 (new ones) and partly made for 4:3 (old ones). And the old ones look stretched. I'm not even sure which kind of intended aspect ratio is more popular now.
I guess I'll try to make the scaling configurable depending on settings in the root window (aka "Desktop") of the UI.

Moreover, we already have some overlay images prepared for several aspect ratios (ultrawide not included). Ideally, I'd like to drop all the duplicates and have only one image with proper scaling/padding. A long story obviously.

Yeah, the special handling of full-screen windows feels hacky. I guess I'll need to avoid it somehow.

Link to comment
Share on other sites

Yep I assumed it was all 16:9. The code can be modified so referenceAspect is no longer const. It could use 16:9 as default and for other aspect ratios perhaps forceAspectWidth/Height can be set on those screens and the referenceAspect would be calculated based on those values.

I agree it would be nice to drop special images for different aspect ratios. I was able to change the spyglass & keyhole images to always use the 16:9 image and it worked nicely. The issue is just finding a way to have the black background continue outside the letterbox area so the game viewport is not leaking through.

With the fullscreen changes I was hoping to find some general way of correcting the UI without having to change the content too much, ideally so mission creators wouldn't have to go back and change their content to support different aspect ratios. I did however hit a roadblock because it seems that loading screens and briefing screens are copypasted for every mission so this content may need to be patched anyway.

If a whole pass on the GUI files is necessary anyway I would skip the fullscreen hack and aspectAware parameter and go with something else that makes sense.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 2 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 5 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...