sonic2kk / steamtinkerlaunch

Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs
GNU General Public License v3.0
2.11k stars 71 forks source link

Add Non-Steam Game: Implement Artwork Selection Paths #903

Closed sonic2kk closed 12 months ago

sonic2kk commented 12 months ago

Implements #738. Salvages #576.

Overview

This PR adds the ability to select artwork (hero, logo, boxart, tenfoot) for a Non-Steam Game from the Add Non-Steam Game GUI. Thanks to #902 we properly generate and write out a Non-Steam Game AppID, so this feature request is now possible after over a year of investigation work!

image

I tested this with adding Bad Piggies with some grids I downloaded from SteamGrid, and it worked like a charm.

image

Implementation

Thanks to #902, we can now generate a correct AppID. This made implementation of this feature trivial, essentially moving over most of the work from #576 for the GUI portion (including the headings, etc).

The GUI was changed to allow users to select Non-Steam Game artwork. This opens a file selection dialogue where they can select their images. These are stored as paths. This UI portion was also essentially copied from the Set Game Artwork functionality from #757, the language strings were directly re-used and the variable names were made to match.

The addNonSteamGameGui function takes in all these parameters, and passes them to addNonSteamGame, which is a function also used for the steamtinkerlaunch addnonsteamgame command. The work done in this PR to allow Non-Steam Game artwork selection also applies to the commandline usage as a result! We simply call addNonSteamGame and pass it some extra flags now: -hr, -lg, -ba, -tf -- By design, identical to how we implemented Set Game Artwork, for consistency and easier maintenance.

The addNonSteamGame function was updated to parse these new arguments, and uses them to call setGameArt. We basically just take in the paths from the user in addNonSteamGameGui, send them to addNonSteamGame, and this in turn sends them (with the generated AppID) to setGameArtwork. This function can manage whether the images exist or not, so we don't have to worry about vetting this here -- Woohoo, abstraction!

This PR more or less brings the functionality of setGameArtGui and puts it into addNonSteamGameGui, where each of these functions' respective commandline functions handles the rest.

There were a couple of other minor tweaks and discoveries made along the way, like how we can pass a string "--flag" to functions and they'll parse this as a flag. This means we can get rid of some nasty if blocks around the codebase (I think One-Time Run and Custom Command logic may benefit here, but setGameArt will benefit a lot too). This can all go in a separate PR, though :slightly_smiling_face:


In my testing, this PR is feature-complete, and only has a couple of things left:

sonic2kk commented 12 months ago

Version bumped, langfiles updated, code changes are ready, and shellcheck is good. Ready to merge!