@@ -124,6 +124,15 @@ type appmanifest_vdf = {
124124 },
125125}
126126
127+ type compat_vdf = {
128+ platform_overrides : {
129+ [number ]: {
130+ dest : "windows" | "linux" ,
131+ src : "windows" | "linux" ,
132+ },
133+ },
134+ }
135+
127136-- STweaker
128137
129138-- TODO
@@ -161,6 +170,18 @@ function Configuration.Public.getSteamConfiguration(): string?
161170 Logging .write ("info" , "User game configurations loaded." )
162171 Logging .separator ()
163172
173+ --[[
174+ Chapter 2.5 : We recover compat.vdf to know if a game has ever used its Windows version.
175+ We can't use it directly to get the platform details, as games that have previously used Proton will still be set to "windows" here.
176+ Logically, a game completely absent from this list is a native Linux game.
177+ ]]
178+ local compat_vdf : compat_vdf = Configuration .Private .VDFHandler (
179+ process .env .HOME .. "/.local/share/Steam/userdata/" .. activeUserSteamID3 .. "/config/compat.vdf" ,
180+ "Failed to parse compat.vdf file."
181+ )
182+ Logging .write ("info" , "Compatibility data loaded." )
183+ Logging .separator ()
184+
164185 --[[
165186 Chapter 3 : We recover the Steam library config to get the list of games.
166187 We can't use just libraryfolders.vdf to get the game IDs, as Steam seems to not always update it immediately.
@@ -170,14 +191,13 @@ function Configuration.Public.getSteamConfiguration(): string?
170191 Logging .write ("info" , "Steam libraries loaded." )
171192 Logging .separator ()
172193
173- --print(userGameConfigurations, libraries)
174-
175194 local steamApps = {}
195+ local steamAppCount = 0
176196
177197 Async .asyncForEach (libraries .libraryfolders , function (_ , library )
178198 -- We check if the folder exists
179199 if not fs .metadata (library .path ).exists then
180- Logging .write ("warning " , "Steam library " .. library .path .. " doesn't exist. Skipping..." )
200+ Logging .write ("warn " , "Steam library " .. library .path .. " doesn't exist. Skipping..." )
181201 else
182202 Logging .write ("data" , "Checking library " .. library .path )
183203 local appManifestFilenames = Filesystem .getFilenamePatternInDirectory (library .path .. "/steamapps" , "appmanifest_" )
@@ -188,22 +208,39 @@ function Configuration.Public.getSteamConfiguration(): string?
188208
189209 Logging .write ("info" , "Found " .. appManifest .AppState .appid .. " : " .. appManifest .AppState .name )
190210
211+ local location = library .path .. "/steamapps/common/" .. appManifest .AppState .installdir
212+
213+ -- Does the game have launch options set ?
191214 local configuration = userGameConfigurations [appManifest .AppState .appid ]
192215 local launchOptions
193216 if configuration then
194217 launchOptions = configuration .LaunchOptions
195218 end
196219
197- local steamApp = SteamApp .new (
198- appManifest .AppState .appid ,
199- appManifest .AppState .name ,
200- library .path ,
201- library .path .. "/steamapps/common/" .. appManifest .AppState .installdir ,
202- appManifest .AppState .MountedConfig .platform_override_source ,
203- launchOptions
204- )
220+ -- Do we know the game's platform
221+ local osPlatform : ("windows" | "linux" )? = appManifest .AppState .MountedConfig .platform_override_source
222+ if not osPlatform then
223+ local compat = compat_vdf .platform_overrides [appManifest .AppState .appid ]
224+ -- The app being absent from the compat.vdf list means it can only be a native Linux game
225+ if not compat then
226+ osPlatform = "linux"
227+ else
228+ -- Gah ! We still don't have the platform... time to check manually.
229+ Logging .write (
230+ "warn" ,
231+ "Platform not found for " .. appManifest .AppState .appid .. " : " .. appManifest .AppState .name .. ". Using manual check..."
232+ )
233+ if not Filesystem .directoryContainsLinuxData (location ) then
234+ osPlatform = "windows"
235+ else
236+ osPlatform = "linux"
237+ end
238+ end
239+ end
205240
206- table.insert (steamApps , steamApp )
241+ local steamApp = SteamApp .new (appManifest .AppState .appid , appManifest .AppState .name , library .path , location , osPlatform , launchOptions )
242+ steamApps [steamApp .appID ] = steamApp
243+ steamAppCount += 1
207244 end )
208245 end
209246 end )
@@ -212,6 +249,8 @@ function Configuration.Public.getSteamConfiguration(): string?
212249
213250 print (steamApps )
214251
252+ Logging .write ("info" , "Loaded " .. steamAppCount .. " Steam apps." )
253+
215254 return
216255end
217256
0 commit comments