flatpak-gog icon indicating copy to clipboard operation
flatpak-gog copied to clipboard

Add basic support for running Windows games

Open V02460 opened this issue 4 years ago • 3 comments

There are still a lot of GOG games not released natively for Linux. This PR adds basic support for running those inside a Flatpak.

For Windows games, GOG uses InnoSetup as installer whose files can be read by innoextract. I build and use this tool to install the game files into the Flatpak. These actions are added to the process for Windows games:

  • Add all installer files (*.exe and *.bin)
  • Build innoextract (32- and 64-bit)
  • Build and install wine (32- and 64-bit)
  • Use a starter script which finds the correct executable

At its current state, no metadata is scraped from the installer while running json-maker.py and generic defaults are used. Those missing metadata, most important the game's name, can be given via command line parameters, eg. like this:

$ ./json-maker.py ~/Downloads/Games/Stronghold\ HD/setup_stronghold_hd_1.41_\(20341\).exe --arch=i386 --name="Stronghold HD"

Also, currently only pure 32-bit or 64-bit Wine is supported (no mix of both).

A lot of refactoring changes to the code came due to the need to support different arch and installer combinations. I hope this is alright.

For the future I plan to add metadata scraping from the InnoSetup files (current progress can be found at my own branch) and use the work done over at Winepak to help with satisfying all the picky Wine-needs of different games.

V02460 avatar Feb 22 '20 21:02 V02460

Supporting WINE will be hard to get right eventually. That's why Lutris has scripts for every game. You also want things like FAudio, DXVK, and other WINE additions (winetricks) for most games. Also some games set things in the registry at install time which are missing when you just extract the setup file. Additional to that some games come with a special LanguageSetup.exe or other graphics setup tools you need to call manually. And last but not least (many) old games spread files all around the game directory (config files, save files, temp files) so they don't work correctly when the game directory is not writable. i.e. the game Kathy Rain places the save files alongside the .exe file. Also you may want to change some game files after installation (i.e. add the missing music to Mafia 1) or add missing translations to the game.

So while basic WINE support may be quite nice I don't think that it is pretty usable in practice in the way flatpak-gog works.

Pixelnarium avatar Mar 10 '20 12:03 Pixelnarium

Yeah -- while having a good flatpak for wine with the various bits needed for individual games would be a pretty awesome thing, the scope is so big I'm not sure if it makes sense to merge it with flatpak-gog.

A version of lutris/something similar that uses flatpak-ed wine versions and then installs games into persistent storage could be worth looking into.

kujeger avatar Mar 12 '20 22:03 kujeger

Yes. :smile:

Your points are very valid, but I think I have reason for cautious optimism here.

The InnoSetup (Windows) versions of the games contain goggame-*.info and goggame-*.script files in the game directory, which describe the tasks to run after installation (executing additional files, adding registry entries) and the additional launcher exes (for settings, editor, multiplayer, etc.). Those files look pretty tidy and easy to parse. Iff there is a good way to have a solid base runtime for all those games, I think there is a good chance to have lots of games running without further customization. How likely it is to get such a runtime is something I don't know and probably will only find out with a bit more of experimentation.

I think the other issues you raised are not specific to Wine/Windows versions of the game. The problem with a writeable game directory applies to many games, Linux or Windows, in the same way; many of the current overrides tackle exactly this problem. For the case of Mafia and related games: That's what the overrides are for – to allow game-specific changes (and I would generally consider them bugs on GOGs side then).

The current version of this code does support some games without customization already. I tested it with Stronghold HD and Donut County for example; Limbo only required a workaround to prevent writing to the game directory. “Bigger” games I had in my library all required a mixed 32/64-bit wine and so I didn’t got my hands on them yet.

Lutris runners are definitively something I am interested in. Depending on how this discussion and further experimentation goes, I do consider working on a Lutris runner (integrated with flatpak-gog, or maybe without). I don't know what the thoughts of the Lutris folks are on this as I didn't have talked with any of them yet.

@kujeger What are your thoughts on the general direction flatpak-gog should move? Keep it a single-file Python script only requiring the standard lib?

V02460 avatar Mar 16 '20 13:03 V02460