Skip to content
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

3.6.0: enhanced gfx mode config #1428

Merged

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Oct 7, 2021

This is another attempt at improving the way graphics mode is defined in user config. The existing one was made for AGS 3.4.0, and while it allows to freely setup (almost) any mode, there are annoying issues:

  1. It's overloaded with config options; there are several options that have to be set, and which combination determines gfx mode: screen_def, screen_width, screen_height, less used match_device_ratio, and if you want to get window of xN size of the game then you also have to put proper number in the game_scale_win option.
  2. It allows for inconsistent or redundant option combinations, for example if screen_def is scaling then screen_width and screen_height have to be ignored. If screen_def is explicit then it uses screen_width and screen_height, but if at the same time game_scale_* option is set to the scaling number, then the game may end up shown in a rectangle of smaller size inside the larger window.
  3. Engine now supports toggle between windowed and fullscreen modes, but the config only allows to set up the initial one, and the other will be deduced using engine defaults, which is not necessarily what user wants.

The new config style is meant to fix these issues. There are three changes:

  1. The graphic mode is now defined by a single option that contains all possible variants in one string.
  2. There are two options, one for windowed and another for fullscreen mode, called window and fullscreen respectively. Both are read by the engine and used as defaults when the user toggles between the modes at runtime.
  3. game_scale_* options now only define the scaling style (round, stretch and proportional), but no longer define the scaling factor - that is derived from the window size.

In [graphics] section fullscreen mode is defined by the option "fullscreen" while the windowed mode is defined by the option "window". These option may have following values:

  • WxH - explicit window size (e.g. "1280x720");
  • xS - integer game scaling factor (e.g. "x4");
  • default -
    • in fullscreen mode that uses current desktop's resolution;
    • in windowed mode that tries to create largest possible window (for the current desktop size), while keeping game scaling style (max stretch, proportional stretch or max integer multiplier).

The example of new config:

[graphics]
fullscreen=1280x720
window=x2
game_scale_fs=proportional
game_scale_win=round

TODO:
Note that I called the windowed mode option "window", but that's mostly for backward compatibility with old configs which have "windowed" defining initial mode, that is "windowed=1/0".

But there's also a need to dinstinguish "desktop fullscreen" (a borderless window covering whole desktop) and "exclusive fullscreen" (for systems that support one), so that old option no longer suits us either. This is going to be changed next.

@rofl0r
Copy link
Contributor

rofl0r commented Oct 7, 2021

this sounds like the perfect opportunity to implement the distinction between
SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP
https://wiki.libsdl.org/SDL_SetWindowFullscreen

@ivan-mogilko
Copy link
Contributor Author

That is true.

@ivan-mogilko ivan-mogilko force-pushed the sdl2--gfxmodeconfig branch 4 times, most recently from f936434 to 8759352 Compare October 12, 2021 01:54
@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Oct 12, 2021

Added a distinction between SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP to the graphic drivers.

In terms of config, I imagine that when user wants "fullscreen desktop" they likely want it to use current desktop setting without changing resolution. So we might save on number of options and use same one for everything:

  • if config string sais fullscreen=desktop - this means "fullscreen desktop" mode;
  • if it has explicit resolution (e.g. fullscreen=1920x1080) - this means real fullscreen mode of that resolution.
  • default will now be equivalent to desktop for fullscreen mode, as my impression was this is a preferred option today.

@rofl0r
Copy link
Contributor

rofl0r commented Oct 12, 2021

if it has explicit resolution (e.g. fullscreen=1920x1080) - this means real fullscreen mode of that resolution.

how about fullscreen=native or similar to use the mode automatically that the game wants to run at ?
it's probably quite difficult to figure this resolution out as a user.

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Oct 13, 2021

how about fullscreen=native or similar to use the mode automatically that the game wants to run at ?

I added this because it's only an extra value parsing, although I don't know how much this will be useful, as it seems that people mostly like to run games scaled to the largest resolutions more suitable for contemporary monitors.

In regards to the new code, it seems generally working; I think applying legacy config need to be corrected, for compatibility, and winsetup program has to be adjusted.

@rofl0r
Copy link
Contributor

rofl0r commented Oct 17, 2021

i see you've added some code to parse legacy config, which made me think about the plausible scenario that a user might want to use ags 3.5.x and 3.6.x in parallel (for example one engine version might have some issue with a specific game). ags 3.5. will probably not be happy if it encounters config in new format. would it make sense to give a new filename to new-style config ? such as acsetup2.cfg

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Oct 17, 2021

ags 3.5. will probably not be happy if it encounters config in new format

Currently I'm not reusing previously existing options, and the way engine reads config it ignores anything it is not interested in.

But i guess that changing to a different filename remains an opportunity for the future if there's a bigger config remake (or we want to cleanup config).

Leave only simple scaling styles that tell how to fill provided window (max integer, stretch to fill, etc).

This does not cancel the scaling number in config, that is still valid and will be used to determine window size based on the game size.
Instead have a struct with just Size and Scale, and the actual mode will depend on what is set.
This is to allow users setting up and using explicit configs, rather than guessing what the preference for another may be based on the initial one.
@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Oct 18, 2021

I have one irritating issue left here; since I added "native" value which defines game's resolution, I've been thinking that it could make sense to also use special value to define current desktop resolution for window or exclusive fullscreen mode. Previously I used "desktop" to define the "FULLSCREEN_DESKTOP" mode. Now I wonder if there may be another good name for it, while "desktop" could be used to create desktop-sized exclusive mode or max fitting windowed mode. Or other way around - keep "desktop" for virtual fullscreen, but introduce new word for windowed/exclusive fullscreen mode.

In the previous config there was "max" word used for that, but idk if it's convenient: then you'll have "max" for exclusive mode and "desktop" for the borderless window, which kind of look strange imo.

@rofl0r
Copy link
Contributor

rofl0r commented Oct 18, 2021

maybe "stretch", "maxwin", "full" ?

@AlanDrake
Copy link
Contributor

"borderless" for bordeless fullscreen?

@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented Oct 19, 2021

So, I did this: "desktop" value is used to define the window resolution, similar to "native", and "full_window" means the borderless window covering whole desktop. I'll leave it at that for now, but since 3.6.0 is still wip, this may change if nicer alternatives are found or this proves to be confusing to users.

Note: had to rebase because there were bugs in the master.

Instead of having several detached options that combined would result in a window size definition, there's now only 1 option (per mode) that contains all possible variants in a single string:

 * WxH - explicit window size (e.g. "1280x720");
 * xS - integer game scaling factor (e.g. "x4");
 * desktop - use current system's desktop resolution;
    ** in windowed mode will try to create largest possible resizing window, while keeping game scaling style (max stretch, proportional stretch or max integer multiplier);
 * native - use game's native resolution;
 * full_window - special option for the fullscreen mode, this means a borderless window covering whole desktop;
 * default - currently we default to (this is also a fallback option in case config parsing went wrong):
    ** in fullscreen mode to "full_window";
    ** in windowed mode to "desktop";

In [graphics] section fullscreen mode is defined by the option "fullscreen" while the windowed mode is defined by the option "window".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants