feat: remember position of game window
Solves #1228
Saves the position of the window in fheroes2.conf. The position is captured every time the window is moved, and saved to settings when the game exits. It's possible to capture only when the game exits, but then we might not save the correct position if the user swaps to Fullscreen mode before quitting.
We will merge this pull request after the upcoming release.
Hi @ihhub, could you take a look at this PR when you have the time? Is there more work to be done here?
@usidedown , many thanks for this feature!
Hi guys. Just a generic warning. In the past, I already had different cases with such functionality. The end user can mistakenly change the window position to a very pity one (e.g. far corner). Don't ask why, mainly it just happens. Generic user expectation that on the next run - the window will be restored properly.
Let's go through a very generic case
- End user works with multiple windows. By mistake fheroes2 window is moved to be bottom corner and the window title is barely visible
- The end user cannot find fheroes2 windows, so the game is forcefully closed
- On the next run the window is restored to the same position (e.g. not playable)
Typically it's handled by counting window size and in case endpoints (X/Y) have higher values than screen size - restore to the default screen and centered
Another typical case. An end user has 2 monitors (e.g. connected TV). On the next run, the TV (or any other second monitor) is disconnected. What will happen then? Was that test scenario checked?
Hi @Killbrum, thanks for your input!
We ended up with the following:
- The window is only saved on a proper exit.
- The game checks that the window is fully contained in the display, otherwise the default position is used
- If we failed to get the display information, the default position is used.
I believe the behavior is correct in the scenarios you outlined.