ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.69k stars 375 forks source link

Program, switching from full screen mode to windowed mode with the "F4" key reduces the size of other programs in use #7210

Open LeHerosInconnu opened 1 year ago

LeHerosInconnu commented 1 year ago

Preliminary checks

Platform

Windows

Describe the bug

Windows 7 SP1 - 64 bits

In fheroes2, switching from full screen mode to windowed mode with the "F4" key reduces the size of other programs in use.

Here with Google Chrome which is in full screen at the time of the manipulation, and which switches from full screen to windowed mode. The window is always positioned completely on the top left of the screen:

F4 switch reduce size other windows 001

Here with another execution of fheroes2 at the same time, which is in windowed mode (640 x 480) at the moment of the manipulation, and whose window is reduced. The window is also always positioned completely on the top left of the screen whatever its initial position:

F4 switch reduce size other windows 002

Save file

Not Needed.

Additional info

Windows 7 SP1 - 64 bits

This is not related to a recent version of fheroes2. This has always been the case since version 0.8.

oleg-derevenetz commented 1 year ago

Hi @LeHerosInconnu try to set the cursor soft rendering in fheroes2.cfg to on.

LeHerosInconnu commented 1 year ago

Hello @oleg-derevenetz,

Hi @LeHerosInconnu try to set the cursor soft rendering in fheroes2.cfg to on.

Indeed, this problem does not appear anymore when the cursor soft rendering in fheroes2.cfg is set to on. However, it is no longer a real full screen mode that stretches the surface to fill the screen completely. The ratio of the game surface is kept and black bands are added on each side of the screen. I use a 16/10 display and, for me, the slight deformation of the game surface resolving from the stretching of this surface is preferable to the black bands on each side of the screen. I must say that I even prefer this slight horizontal deformation in 16/10 than the original 4/3 ratio of the game, it gives it a certain charm that the more "square" 4/3 ration does not bring. :)

oleg-derevenetz commented 1 year ago

@LeHerosInconnu

However, it is no longer a real full screen mode that stretches the surface to fill the screen completely. The ratio of the game surface is kept and black bands are added on each side of the screen.

Well, you need to choose between two options:

  1. Real fullscreen mode that changes the screen resolution on the video card and therefore sizes of all these windows of other running apps may be reduced, because the new screen resolution is smaller;
  2. Emulated fullscreen mode that doesn't change the video card settings and keeps the ratio of in-game surface by adding the black bars.

In case 1, there is nothing that could be done with the reduced window sizes, because this behavior is controlled by the OS (due to the "real" resolution change on the video card) and not by fheroes2.

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

@LeHerosInconnu

However, it is no longer a real full screen mode that stretches the surface to fill the screen completely. The ratio of the game surface is kept and black bands are added on each side of the screen.

Well, you need to choose between two options:

  1. Real fullscreen mode that changes the screen resolution on the video card and therefore sizes of all these windows of other running apps may be reduced, because the new screen resolution is smaller;
  2. Emulated fullscreen mode that doesn't change the video card settings and keeps the ratio of in-game surface by adding the black bars.

In case 1, there is nothing that could be done with the reduced window sizes, because this behavior is controlled by the OS (due to the "real" resolution change on the video card) and not by fheroes2.

This problem does not appear with Heroes of Might and Magic 2 English version 1.3, nor with the Gold English version 2.1, nor with the GOG English version 2.1, nor with the Scenario Editor English version 2.1, the use of the "F4" key does not modify in any way the position or the dimension of the windows of the other programs in use.

oleg-derevenetz commented 1 year ago

@LeHerosInconnu

This problem does not appear with Heroes of Might and Magic 2 English version 1.3, nor with the Gold English version 2.1, nor with the GOG English version 2.1, nor with the Scenario Editor English version 2.1, the use of the "F4" key does not modify in any way the position or the dimension of the windows of the other programs in use.

I can easily reproduce this behavior with GoG HoMM2 version running in DOSBOX. Here are the steps:

  1. Launch GoG HOMM2 in DOSBOX;
  2. Press Alt+Tab to switch to other app (in my case it's Brave web browser) and expand this browser to full screen;
  3. Switch back to the HoMM2 DOSBOX window and press Alt+Enter to make it fullscreen;
  4. Press Alt+Tab once again and observe the Brave browser window with wrong size:

window

So no, it's a well-known natural consequence of the "real" fullscreen mode (which is created by altering the screen resolution directly on the video card).

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

@LeHerosInconnu

This problem does not appear with Heroes of Might and Magic 2 English version 1.3, nor with the Gold English version 2.1, nor with the GOG English version 2.1, nor with the Scenario Editor English version 2.1, the use of the "F4" key does not modify in any way the position or the dimension of the windows of the other programs in use.

I can easily reproduce this behavior with GoG HoMM2 version running in DOSBOX. Here are the steps:

  1. Launch GoG HOMM2 in DOSBOX;
  2. Press Alt+Tab to switch to other app (in my case it's Brave web browser) and expand this browser to full screen;
  3. Switch back to the HoMM2 DOSBOX window and press Alt+Enter to make it fullscreen;
  4. Press Alt+Tab once again and observe the Brave browser window with wrong size:

window

So no, it's a well-known natural consequence of the "real" fullscreen mode (which is created by altering the screen resolution directly on the video card).

I should have specified that the mentioned versions are all Windows versions. I do not use DOSBox for Heroes of Might and Magic 2.

oleg-derevenetz commented 1 year ago

I should have specified that the mentioned versions are all Windows versions.

Well, then they most likely don't use the "real" fullscreen mode, but some kind of emulation without changing the video card settings. But DOSBOX uses the "real" fullscreen mode (just like fheroes2 does on Windows by default) and therefore the results.

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

I should have specified that the mentioned versions are all Windows versions.

Well, then they most likely don't use the "real" fullscreen mode, but some kind of emulation without changing the video card settings. But DOSBOX uses the "real" fullscreen mode (just like fheroes2 does on Windows by default) and therefore the results.

I don't know how this is done in the original game, but couldn't this be reproduced so that the Windows version of fheroes2 works on Windows the same way the Windows versions of Heroes 2 do? Or is there a Magic behind it? Could someone become this Hero? :)

oleg-derevenetz commented 1 year ago

@LeHerosInconnu if you want the emulated full screen mode that will introduce distortions, then I doubt that it's a priority. The fact that some HoMM2 implementations introduce distortions is bad, and not good. Ratio of the selected resolution should be maintained in the full screen mode as is. If ever a decision is made to completely abandon the "real" full screen mode (Windows is the only platform where it is still used), we will be able to add "virtual" resolutions such as 960x540 (1920x1080 divided in half (or, more precisely, by four)) which will neither introduce distortions nor add the black bars in the full screen mode if native monitor resolution is used (1920x1080 in this case).

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

@LeHerosInconnu if you want the emulated full screen mode that will introduce distortions, then I doubt that it's a priority. The fact that some HoMM2 implementations introduce distortions is bad, and not good. Ratio of the selected resolution should be maintained in the full screen mode as is. If ever a decision is made to completely abandon the "real" full screen mode (Windows is the only platform where it is still used), we will be able to add "virtual" resolutions such as 960x540 (1920x1080 divided in half (or, more precisely, by four)) which will neither introduce distortions nor add the black bars in the full screen mode if native monitor resolution is used (1920x1080 in this case).

The real full screen mode of Windows with distortions is okay for me. And I wouldn't want it to disappear. I wouldn't want black bands to be imposed to the user.

Thinking about the problem. For example, would it be possible to memorize the size and position of the windows of the other programs in use when fheroes2 switches from windowed mode to full screen mode, and to restore them when fheroes2 switches from full screen mode to windowed mode? Or is it too complicated, or it would take too much time, or something else, etc., for the result obtained?

oleg-derevenetz commented 1 year ago

For example, would it be possible to memorize the size and position of the windows of the other programs in use when fheroes2 switches from windowed mode to full screen mode, and to restore them when fheroes2 switches from full screen mode to windowed mode? Or is it too complicated, or it would take too much time, or something else, etc., for the result obtained?

This is complicated, not portable and it will not work in all cases (for example this will not work with applications running in elevated mode, because fheroes2 will not be able to send window messages to such apps). A more perspective option is to abandon the "real" full screen mode and add virtual resolutions that do not require black bars and do not introduce distortions. I gave an example above: if your "native" monitor resolution is set to 1920x1080, then you can run the game in 960x540 resolution in a window and there will be neither distortions nor black bars if you switch between windowed mode and full screen mode in this resolution, because the ratio is the same in windowed mode and full screen mode.

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

For example, would it be possible to memorize the size and position of the windows of the other programs in use when fheroes2 switches from windowed mode to full screen mode, and to restore them when fheroes2 switches from full screen mode to windowed mode? Or is it too complicated, or it would take too much time, or something else, etc., for the result obtained?

This is complicated, not portable and it will not work in all cases (for example this will not work with applications running in elevated mode, because fheroes2 will not be able to send window messages to such apps). A more perspective option is to abandon the "real" full screen mode and add virtual resolutions that do not require black bars and do not introduce distortions. I gave an example above: if your "native" monitor resolution is set to 1920x1080, then you can run the game in 960x540 resolution in a window and there will be neither distortions nor black bars if you switch between windowed mode and full screen mode in this resolution, because the ratio is the same in windowed mode and full screen mode.

This means that the graphic frame that surrounds the game would be enlarged and the area of the displayed adventure map would be increased to "fill" the new resolution (e.g. 960 x 540) compared to the game's original resolution (640 x 480), and that without distortion.

Well, here the problem here is not really the distortion or the appearance of black bands but the fact that the program acts on the other programs in progress.

How did they do back then? Is there a rule that was applied in the development of Heroes 2 regarding compatibility with future versions of Windows that was omitted in the development of fheroes2? It seems a bit odd that a program made over 25 years ago still runs on an operating system that no one had a clue about at the time, and that today with knowledge of that operating system operation it is not possible to obtain a similar operation. What do you think?

oleg-derevenetz commented 1 year ago

This means that the graphic frame that surrounds the game would be enlarged and the area of the displayed adventure map would be increased to "fill" the new resolution (e.g. 960 x 540) compared to the game's original resolution (640 x 480), and that without distortion.

Yes.

Well, here the problem here is not really the distortion or the appearance of black bands but the fact that the program acts on the other programs in progress.

DOSBOX version does exactly the same.

It seems a bit odd that a program made over 25 years ago still runs on an operating system that no one had a clue about at the time, and that today with knowledge of that operating system operation it is not possible to obtain a similar operation.

It is possible to obtain a similar operation even in the "emulated" full screen mode, but I doubt that anyone will invest time intentionally reproducing the incorrect behavior expressed in introducing distortions in the full screen mode. Some are willing to put up with it, while others will complain that on-screen image is stretched (and they will be right). There is just no reason to reproduce this. While "real" full screen mode just not able to work any other way, it is better to throw it out altogether and not reproduce its incorrect behavior in the "emulated" full screen mode, because there are better options available which just weren't available 25 years ago.

LeHerosInconnu commented 1 year ago

Hello @oleg-derevenetz,

This means that the graphic frame that surrounds the game would be enlarged and the area of the displayed adventure map would be increased to "fill" the new resolution (e.g. 960 x 540) compared to the game's original resolution (640 x 480), and that without distortion.

Yes.

But in the case of the combat screen, town screen, etc., which have an initial resolution of 640 x 480 pixels, this will not be possible and they will end up in a "window" inside the game screen area (as is currently the case when the user chooses a higher resolution than the original game resolution).

From my point of view, it is essential that these screens are full screen. It's better in order to have the feeling of being on the battlefield, of being in a town, etc., and not of participating in a battle that takes place on the adventure map, or visiting a town somewhere on the adventure map. Also, having these screens in full screen mode makes it easier to distinguish things, whereas in "window" mode inside the game screen area everything is represented in smaller size.

Well, here the problem here is not really the distortion or the appearance of black bands but the fact that the program acts on the other programs in progress.

DOSBOX version does exactly the same.

DOSBox is an emulator that simulates an MS-DOS compatible environment in order to run, on a newer environment, video games developed in the past for MS-DOS.

Here, it is about Windows versions of programs, definitely ancient (although I don't know if GOG doesn't "update" some ancient programs a bit), and which still work correctly in a recent version of the operating system for which they were designed. In short, they are ancient, but they still work correctly.

It seems a bit odd that a program made over 25 years ago still runs on an operating system that no one had a clue about at the time, and that today with knowledge of that operating system operation it is not possible to obtain a similar operation.

It is possible to obtain a similar operation even in the "emulated" full screen mode, but I doubt that anyone will invest time intentionally reproducing the incorrect behavior expressed in introducing distortions in the full screen mode. Some are willing to put up with it, while others will complain that on-screen image is stretched (and they will be right). There is just no reason to reproduce this. While "real" full screen mode just not able to work any other way, it is better to throw it out altogether and not reproduce its incorrect behavior in the "emulated" full screen mode, because there are better options available which just weren't available 25 years ago.

For me, the user should always have the choice to play the way he wants, whether it is full screen with stretching or full screen with black bands. Also, the user should always be able to retrieve the sensations he had when playing the original game when playing the "remake" of the same game.

We should not despair, a "full screen guru" will certainly be interested in "playing" to correct this problem. :)

Branikolog commented 1 year ago

Hi, @LeHerosInconnu ! You should try 960x540 (in a case your native resolution is fHD) with linear filtering. It's the best pixel-perfect picture you can get for Heroes 2 in fullscreen and I can forgive the non-native 640x480 for the sake of precise pixelated image. I prefer it over native 640x480 in every aspect and would never switch back. :) I think running applications in 4:3 nowadays is kind of rudimental since you can hardly find any non-widescreen monitor, and playing with black borders is just... uncomfortable, when it's ~30% of unused monitor space.

LeHerosInconnu commented 1 year ago

Hello @Branikolog,

Hi, @LeHerosInconnu ! You should try 960x540 (in a case your native resolution is fHD) with linear filtering. It's the best pixel-perfect picture you can get for Heroes 2 in fullscreen and I can forgive the non-native 640x480 for the sake of precise pixelated image. I prefer it over native 640x480 in every aspect and would never switch back. :) I think running applications in 4:3 nowadays is kind of rudimental since you can hardly find any non-widescreen monitor, and playing with black borders is just... uncomfortable, when it's ~30% of unused monitor space.

My monitor's native resolution is 1920 x 1200 (16/10 ratio). I tested with the proposed resolution of "960x600 (x2.0)" in the list of resolutions. Does this correspond to what you mean by "linear filtering"?

This mode causes visual discomfort in my case. Anyway, town screens, combat screens, etc., are no longer full screen, which is not what I want. The mouse cursor also becomes a little too small for my taste.

In fheroes2:

Resolution 006

Resolution 001

Resolution 002

Resolution 005

Resolution 003

Resolution 004

Looking at these screenshots, I thought it would be a good idea to center windows for towns, combats, etc. in the adventure map display area in resolutions where they can be fully included in this area. In the example, they would no longer partially cover the hero list, and the centering of these windows in the adventure map display area would be visually more pleasing. I could open a discussion for that if necessary.

oleg-derevenetz commented 1 year ago

Does this correspond to what you mean by "linear filtering"?

Linear filtering means screen scaling type set to linear in the fheroes2.cfg. There are two options: linear and nearest.

LeHerosInconnu commented 1 year ago

@oleg-derevenetz.

Does this correspond to what you mean by "linear filtering"?

Linear filtering means screen scaling type set to linear in the fheroes2.cfg. There are two options: linear and nearest.

Thanks for the precision.

@Branikolog.

The screen scaling type setting is set to linear by default in the fheroes2.cfg. So yes, all my comments above are made in this mode.

Branikolog commented 1 year ago

Hi, @LeHerosInconnu .

You should try 960x540 (in a case your native resolution is fHD) with linear filtering

Oh, my mistake, I wanted to say "nearest". I'm always confused by those filtering terms. 😅 You should also switch to software cursor rendering to make cursor scaled with game. Also this mode and "nearest" filtering allows your monitor with 960x600 render game pixel with 2 physical pixels, making picture sharp as crusaders long sword. :)

Looking at these screenshots, I thought it would be a good idea to center windows for towns, combats, etc. in the adventure map display area in resolutions where they can be fully included in this area. In the example, they would no longer partially cover the hero list, and the centering of these windows in the adventure map display area would be visually more pleasing. I could open a discussion for that if necessary.

In my opinion it's not the only problem and the whole UI needs to be improved for some cases. For any resolutions with x480 there's no brown frame on the upper and bottom edges, but both sides are rendered with frames. Your suggestion is valid only for the resolutions, when adventure map is rendered wider than native 640px so the castle/battle windows won't overlap the right side of adventure map UI. Anyway, On extremely wide resolutions these windows won't touch game UI at all. But on mobile devices I suppose, showing castle/battle windows not centered on the screen could look weird... In my opinion...

ihhub commented 1 year ago

Hi @LeHerosInconnu , from the conversation above I can conclude that the existing mode covers all your needs except the fact that UI in >640x480 resolution UI needs a change. Is it correct?

LeHerosInconnu commented 1 year ago

Hello @ihhub,

Hi @LeHerosInconnu , from the conversation above I can conclude that the existing mode covers all your needs except the fact that UI in >640x480 resolution UI needs a change. Is it correct?

In fheroes2, with the default settings, in the native resolution of the original game, 640 x 480, in fullscreen mode, everything works as in the original game. The screen is fullscreen, slightly stretched (not a problem in my case), with no black bars. The screens for battles, cities, etc., with their native 640 x 480 resolution, are fullscreen. So, yes, the feeling of the original game in this aspect is there.

In other resolutions, screens with black bars are a no go for me. The screens for battles, cities, etc., that are not fullscreen are a no go for me. That's why I choose to play in 640 x 480 resolution.

Also, in this issue, the problem is that switching from fullscreen mode to windowed mode results in a modification of the windows of other programs currently running. Which is not the case with Windows versions of the original game.

apcsb commented 4 months ago

I have the same problem. Furthermore, I can't figure out, where is the fheroes2.cfg file supposed to be located and how to use it - such file does not exist in the master branch of the repo, and searching for it leads to various old forks of fHeroes2.. Could anyone please provide some explanations or a sample?

ihhub commented 4 months ago

@apcsb , I suggest to read the code. This file is only being generated on a first run.