sharkwouter / minigalaxy

A simple GOG client for Linux
https://sharkwouter.github.io/minigalaxy/
GNU General Public License v3.0
1.1k stars 71 forks source link

Allow using the system's wine version instead of the bundled one #38

Open sharkwouter opened 4 years ago

sharkwouter commented 4 years ago

This may improve compatibility and performance, but it also has the potential to break games in unexpected ways, so it might be good to make it configurable.

Currently a gametile will compile a command to execute when starting a game based on which files are in the game's directory. It does already support native scummvm and dosbox installations. Wine games are already detected right now, but they aren't launched in a different way from other games.

The wine prefix is always in a directory called prefix from what I've seen. The location of the game's binary is probably best to retrieve by parsing the start.sh script.

Examples of wine packaged games being sold on GOG:

namandixit commented 4 years ago

A better alternative (though a bit more complicated to implement) might be to add support for Steam Play's compatibilitytools.d. This way, not only Windows games would be playable with up-to-date Proton/Wine but community-made tools such as Boxtron, luxtorpeda, Roberta could also be used for games that ship with outdated versions of DOSBox, SCUMM, etc.

sharkwouter commented 4 years ago

It's true that proton is better than standard wine, but I wouldn't want the client to depend upon Steam. Using the system wide installation is also a bit easier and less likely to break with future releases of wine in some ways (Valve might change how proton is launched in the future, for wine the cli is stable).

Dosbox and SCUMMVM games launched through Minigalaxy already use the versions installed on the system if available. This was added in 0.9.2.

namandixit commented 4 years ago

It's true that proton is better than standard wine, but I wouldn't want the client to depend upon Steam.

It won't have to depend upon Steam, see here. The software will have to parse the VDF files that describe the tool itself.

Valve might change how proton is launched in the future, for wine the cli is stable

That is true. One would hope that since third party tools have cropped up that use the Steam Play interface, they will not break compatibility, but there are obviously no guarantees.

Dosbox and SCUMMVM games launched through Minigalaxy already use the versions installed on the system if available. This was added in 0.9.2.

Right, but support for these had to be added manually, while supporting the Steam Play interface will mean that minigalaxy will automatically support any other similar tools in the future (given they are compatible with Steam Play), see luxtorpeda for example.

namandixit commented 4 years ago

I am documenting what I have figured out in regards to this:

There are two files in a Steam Play compatible tool: compatibilitytool.vdf and toolmanifest.vdf.

Sample `compatibilitytool.vdf:

"compatibilitytools"
{  // C++ style comments seem to be supported
  "compat_tools"
  {
    "Tool_s_Internal_Name"
    {
      "install_path" "." // The directory in which the commands mentioned in `toolmanifest.vdf` exist.
      "display_name" "Fancy Name for fancy people"
      "from_oslist"  "windows" // Boilerplate?
      "to_oslist"    "linux" // Boilerplate?
    }
  }
}

Sample `toolmanifest.vdf:

"manifest"
{ // `/run_command` below stands for whatever script/executable the tool consists of
  "commandline" "/run_command" // To simply run the game (exists relative to `install_path` above)
  "commandline_waitforexitandrun" "/run_command --wait-for-exit-and-run" // Wait for the process to quit?
  "commandline_getnativepath" "/run_command --get-native-path" // Return Unix-style path of game executable mounted inside Wine bottle (only applicable for Proton)
  "commandline_getcompatpath" "/run_command --get-compat-path" // Return Windows style path of game executable mounted inside Wine bottle (only applicable for Proton)
}

A usual command takes the form of:

STEAM_COMPAT_DATA_PATH="${ProtonPrefix}" "${install_path}/${commandline}" getnativepath "${ExecutableFile}"

For example,

STEAM_COMPAT_DATA_PATH="${HOME}/.local/share/Steam/steamapps/compatdata/3830/" ./proton getnativepath "${HOME}/.local/share/Steam/steamapps/common/Psychonauts/Psychonauts.exe"

STEAM_COMPAT_DATA_PATH holds the path to the directory with Proton prefix with some extra metadata. This should be different for each game.

What do we need to implement?

For simple use cases, all that needs to be done is to parse the two vdf files, find the full path of run_command above, create a unique directory for the executable passed to it (maybe hash the EXE) to be set as STEAM_COMPAT_DATA_PATH, and then run a command like the above example to launch the game.

Pinging @dreamer, is the above correct?

@sharkwouter, will you be interested in taking PR for this?

dreamer commented 4 years ago

@namandixit You are 99% correct. Few tiny (but important) details:

  "from_oslist"  "windows" // Boilerplate?
  "to_oslist"    "linux" // Boilerplate?

These are not boilerplate, they actually instruct Steam which depots to use for installing game resources (so theoretically it's possible to write a compatibility tool, that runs macOS games on Linux or the other way around). In context of non-Steam launchers - it might be relevant only for installation/post-installation steps.

manifest file:

"commandline" "/run_command" // To simply run the game (exists relative to `install_path` above)
"commandline_waitforexitandrun" "/run_command --wait-for-exit-and-run" // Wait for the process to quit?

commandline can be used for running the game, but usually Steam uses it to trigger various installation steps (like triggering installation of DirectX for some old Windows games or injecting some values into the Wine registry). It would be advisable for non-Steam launchers to not use it for starting the games.

commandline_waitforexitandrun Steam uses this command to run the game. "wait for exit and run" is there to accomodate usecases like:

(there are more details about how SteamAppId is passed from Steam to compatibility tool to accomodate these usecases)

getnativepath and getcompatpath - I've never actually found the exact purpose of these commands.

Supporting this interface would assure that tools like Boxtron, Luxtorpeda or various Proton forks will work "out of the box", without launcher having to support them explicitly.

@sharkwouter Supporting this interface does not mean depending on Steam - but it'll allow for supporting community-developed Proton forks and other compat. tools. The annoying part is parsing Valve's VDF format, I guess.

Dosbox and SCUMMVM games launched through Minigalaxy already use the versions installed on the system if available. This was added in 0.9.2.

For ScummVM it is perfectly reasonable; I have developed Roberta to have Steam compat. tool, for this usecase, but ScummVM offers nice interface for autodetection and running the games on its own.

For DOSBox, unfortunately, it is not enough :( Simply invoking dosbox command with parameters supplied by Steam or GOG will fail in an overwhelmingly large number of cases. There are many reasons for that (I can explain in detail if needed) - in Boxtron I tried to work around as many issues as I could, but eventually I hit the wall - that's why I am working on fixing the remaining ones in dosbox-staging (but I suspect my improvements will never be merged into upstream).

sharkwouter commented 4 years ago

@dreamer could you be a bit more specific on the issues with DOSBox? All the games I have tested have worked with the version in Debian 10, but barely any of them are able to launch with the GOG supplied DOSBox version(expected library versions don't match). Do you know some examples of games which do not work like this?

To clarify how it currently works. I use the same command to launch DOSBox the start.sh script would use but with the system's DOSBox instead. I do make sure the working directory is set to the game's directory as well. So far I haven't received any bug reports about it yet.

@sharkwouter, will you be interested in taking PR for this?

@namandixit I will take a PR, but since I want to make sure to not change the user experience too much, it would need to meet the following requirements:

I think it's a very interesting concept, but I'm not sure if it is implementable without adding dependencies which aren't widely available. If it turns out using the system's DOSBox doesn't work like expected I'm even more interested, though, since what GOG ships doesn't work on a lot of systems.

dreamer commented 4 years ago

@sharkwouter sure:

So these were DOSBox issues… now publisher bugs - these are common only for DOSBox games distributed via Steam:

(probably like 10 smaller issues I forgot about) ;)

sharkwouter commented 4 years ago

Oh wow, that makes the DOSBox upstream sound like quite a pain. Have you had no success getting patches into DOSBox at all?

So if I understand correctly DOSBox configurations are portable, but only between systems which run the same operating system? That would mean the current solution should always work, since Minigalaxy only installs Linux games at the moment.

If we want to make Windows games installable as well, this solution will not work.

dreamer commented 4 years ago

Oh wow, that makes the DOSBox upstream sound like quite a pain. Have you had no success getting patches into DOSBox at all?

I am trying for several months now (link) :( So far out of 78 patches upstream accepted only few trivial ones (some patches got completely rewritten). There is no estabilished review nor contributing process… Co-maintainer of dosbox-staging tried his patches for several years without proper feedback from upstream.

So if I understand correctly DOSBox configurations are portable, but only between systems which run the same operating system? That would mean the current solution should always work, since Minigalaxy only installs Linux games at the moment.

That is correct. If minigalaxy installs only Linux games, then many (not all) problems I mentioned go away (generally all SDL 1.2 - related issues are still present). There are very rare cases of games which provide Linux version and broken .conf file (e.g. Megarace 2), but they are exceptions.

Sometimes DOS games are not published for Linux at all. On Steam it depends on publisher - e.g. Bethesda never publishes on Linux (even classic id games like Doom).

On GOG, lack of Linux version of DOS game usually signifies that DOSBox had some non-obvious bugs preventing the game from being playable (e.g. Mortal Kombat 3 had game-breaking performance problems, but only after 1-2 rounds - in Boxtron+dosbox-staging it works without serious issues) or publisher bundled some Windows software (Warcraft 1; works great in Boxtron).

If we want to make Windows games installable as well, this solution will not work.

From Steam: nope - Steam will always install the game according to user settings inside the Steam client.

From GOG: I have implemented a script to help me install Windows versions of DOS games from GOG (after manual download) - it seems like a good fit for minigalaxy (after some changes, I believe); this script is not part of main Boxtron functionality, only a helper script to help me with testing; if I could replace it with minigalaxy for my usecase I would be quite happy :).

I was also cooperating with maintainer of GameHub for a while to enable integration of that launcher with Boxtron/Roberta/Luxtorpeda, but that effort stalled.

namandixit commented 4 years ago

@sharkwouter There shouldn't really be any dependencies. Only new component we need is a VDF parser; however, the relevant VDF files don't use a whole lot of features of the format, so writing a rough-and-ready parser is pretty easy.

Since I am not very familiar with GTK, I can write up the logic first (making sure that it stays compatible with the present GUI) and submit it as a PR, then work on the exposing the functionality through GUI later. Will that be acceptable?

sharkwouter commented 4 years ago

@namandixit that sound pretty good.

If it helps, I did start writing some developer documentation, but it still needs a lot of work. I'll see if I can write a part of adding a setting to the preferences windows next weekend. Honestly, I was not expecting more people would use this code when I started the project 😅. It is really cool to see people investing into it.

@dreamer thanks for the detailed description! That gives some great insight into DOSBox. It makes a lot of sense to me now that you started DOSBox-Staging.

kekonn commented 3 years ago

I just ran into wanting this feature and I might be able to offer an idea. GloriousEggroll makes a wine version that has all his proton stuff packed into a wine prefix. If you package that version by default, that will basically make a lot more games compatible.

EDIT: link to the version