Skip to content

[ZH] Center Window on Startup #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

helmutbuhler
Copy link

This PR centers the window after loading on the screen (not including taskbar).
It also adds code to pump window messages during startup to avoid "(Not responding)" in the title. (That was necessary because Windows otherwise ignores the Move Call in debug builds, and maybe also on slower machines)

Also note that I needed to #define WINVER 0x0500, because the Monitor API didn't exist in Win 95 yet. This causes the compiler to emit a message when compiling dx8wrapper.cpp, but generates no error or warning. The game will also no longer run on Win95, but I think we can live with that.

Change list

  • fix: In windowed mode, the game now starts centered on the screen.

@helmutbuhler helmutbuhler changed the title Center Window on Startup [ZH] Center Window on Startup Mar 29, 2025
@xezon xezon added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker labels Mar 29, 2025
@DevGeniusCode DevGeniusCode added the ZeroHour Relates to Zero Hour label Mar 29, 2025
@tintinhamans
Copy link

While this is neat, how do we want to handle cases where the user does not want this functionality.

@tomsons26
Copy link

tomsons26 commented Apr 3, 2025

I'm gonna also ruin this and say, you will likely only center the initial window, the game makes two, one to show splash other for game,
we tried this in Thyme but if the splash window doesn't match the res of the game, result was only splash window got centered

@helmutbuhler
Copy link
Author

While this is neat, how do we want to handle cases where the user does not want this functionality.

The current behavior is that the window starts in the bottom right corner. The bottom right part for the window is usually not visible. Tell me who wants this behavior?
Also, Gentool changes the behavior to what this PR implements, did anyone complain about that?

I'm gonna also ruin this and say, you will likely only center the initial window, the game makes two, one to show splash other for game, we tried this in Thyme but if the splash window doesn't match the res of the game, result was only splash window got centered

Are you saying that this PR is wrong because you didn't get this feature to work in Thyme? If you look at the code or try out the build, you'll see that it works.

@xezon
Copy link

xezon commented Apr 4, 2025

Also, Gentool changes the behavior to what this PR implements, did anyone complain about that?

No complaints over 15 years. Many users use the "Full" window preset in GenTool together with windowed mode.

@tintinhamans
Copy link

Something doesn't seem to be quite right.. there seems to be a gap present below the window despite the correct height of 1440 being set in options.ini.

NVIDIA_Overlay_4NI2GDvNVx(1)

@tintinhamans
Copy link

tintinhamans commented Apr 4, 2025

No complaints over 15 years. Many users use the "Full" window preset in GenTool together with windowed mode.

I can't use Full, it pulls the window to the left of my monitor 😢 :

image

Also, I can think of a use case for other ultrawide users that may actually want the window on the left so that they can have another full-size window (Discord, OBS, etc.) on the right.

@tomsons26
Copy link

While this is neat, how do we want to handle cases where the user does not want this functionality.

The current behavior is that the window starts in the bottom right corner. The bottom right part for the window is usually not visible. Tell me who wants this behavior? Also, Gentool changes the behavior to what this PR implements, did anyone complain about that?

I'm gonna also ruin this and say, you will likely only center the initial window, the game makes two, one to show splash other for game, we tried this in Thyme but if the splash window doesn't match the res of the game, result was only splash window got centered

Are you saying that this PR is wrong because you didn't get this feature to work in Thyme? If you look at the code or try out the build, you'll see that it works.

I'm saying there may be unexpected behavior that may not always manifest due to the game making and destroying multiple windows during its startup

@willherzog
Copy link

The new official patch (1.05) adds window centering. I have no idea whether it's done in the same way as this PR, but certainly for me it's much appreciated after having to deal for so long with the game window starting out not only off-centered but also partially off-screen.

Technically what appeared to happen originally is that the splash screen was centered but then the actual game window used the exact same top+left coordinates as the splash screen - so any game resolution besides 800x600 (which would be the same as the splash screen) necessarily resulted in it being off-centered.

@helmutbuhler
Copy link
Author

Something doesn't seem to be quite right.. there seems to be a gap present below the window despite the correct height of 1440 being set in options.ini.

NVIDIA_Overlay_4NI2GDvNVx(1)

This does indeed look wrong, but sadly I cannot reproduce it. But I also don't have such a wide monitor or Windows 11.

Did you disable DPI Scaling in the Compatibility Settings?
Can you please select a smaller resolution ingame and make another screenshot? Select a resolution such that the titlebar of the window is visible.

Thanks!

@helmutbuhler
Copy link
Author

Never mind, I found the issue. I center the window in the workarea (area not occupied by taskbar and similar), but if the resolution is bigger than the workarea, it's better to center in the whole monitorarea. I just pushed a commit to fix this.
While I was at it, I also changed the codepath that repositions the window after changing the resolution to do the same. I also added some more comments.

@tintinhamans Can you check if the behavior is now fixed?

Copy link

@OmniBlade OmniBlade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the previous issues reported are confirmed fixed I'm happy to approve this?

@helmutbuhler
Copy link
Author

Yes, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker ZeroHour Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants