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

    • JackFarmer

      @joebarnin
      Jeff, I sent you PM a few weeks back but you did not respond. Maybe your inbox is full?
      · 5 replies
    • The Black Arrow

      I was playing Skyrim, got bored fast. Got back to The Dark Mod just for one mission, played "Somewhere above the City" which is not really a great mission but still good, as in above-average.
      My biggest regret is living in this country, where there's a heat wave, I am sweating at 20c and I really wish for temperatures below 5c.
      · 10 replies
    • Skaruts

      Is there something wrong with the forums lately, or is it my browser? I've been having trouble formatting posts, and just now I couldn't format anything at all.
      I'm using Vivaldi.
      Usually I have to: select text, click bold, nothing happens, select again, click bold, then it works. 
      Same for other stuff, like creating spoilers, bullet points, links. Nothing works the first time. 
      · 1 reply
    • STiFU

      Back from a spontaneous 1-week trip to Lanzarote with wife and son. I hope beta testing has been going well...
      · 1 reply
    • datiswous

      Whenever I eat fried chicken these days I think of this scene in The Black Mage..

      · 1 reply
×
×
  • Create New...