18
18
from ..gui import (prompt_filesystem_access , select_steam_app_with_gui ,
19
19
select_steam_installation )
20
20
from ..steam import (find_legacy_steam_runtime_path , find_proton_app ,
21
- find_steam_installations , get_steam_apps ,
22
- get_steam_lib_paths )
21
+ find_steam_installations , get_app_launch_parameters ,
22
+ get_steam_apps , get_steam_lib_paths )
23
23
from ..util import run_command
24
24
from ..winetricks import get_winetricks_path
25
25
from .util import (CustomArgumentParser , cli_error_handler , enable_logging ,
@@ -144,7 +144,12 @@ def _find_proton_app_or_exit(steam_path, steam_apps, appid):
144
144
"The command is passed to the shell as-is without being escaped." )
145
145
parser .add_argument (
146
146
"--gui" , action = "store_true" ,
147
- help = "Launch the Protontricks GUI." )
147
+ help = "Launch the Protontricks GUI."
148
+ )
149
+ parser .add_argument (
150
+ "--game-launch" , action = "store_true" ,
151
+ help = "Launch the game"
152
+ )
148
153
parser .add_argument (
149
154
"--no-runtime" , action = "store_true" , default = False ,
150
155
help = "Disable Steam Runtime" )
@@ -207,6 +212,7 @@ def exit_(error):
207
212
do_command = bool (args .command )
208
213
do_list_apps = bool (args .search ) or bool (args .list )
209
214
do_gui = bool (args .gui )
215
+ do_game_launch = bool (args .game_launch )
210
216
do_winetricks = bool (args .appid and args .winetricks_command )
211
217
212
218
# Set 'use_bwrap' to opposite of args.no_bwrap if it was provided.
@@ -222,12 +228,16 @@ def exit_(error):
222
228
else use_bwrap
223
229
)
224
230
225
- if not do_command and not do_list_apps and not do_gui and not do_winetricks :
231
+ action_count = sum ([
232
+ do_command , do_list_apps , do_gui , do_game_launch , do_winetricks
233
+ ])
234
+
235
+ if action_count == 0 :
226
236
parser .print_help ()
227
237
return
228
238
229
239
# Don't allow more than one action
230
- if sum ([ do_list_apps , do_gui , do_winetricks , do_command ]) != 1 :
240
+ if action_count != 1 :
231
241
print ("Only one action can be performed at a time." )
232
242
parser .print_help ()
233
243
return
@@ -406,33 +416,40 @@ def exit_(error):
406
416
407
417
cwd = str (steam_app .install_path ) if args .cwd_app else None
408
418
419
+ command_kwargs = {
420
+ "winetricks_path" : winetricks_path ,
421
+ "proton_app" : proton_app ,
422
+ "steam_app" : steam_app ,
423
+ "use_steam_runtime" : use_steam_runtime ,
424
+ "legacy_steam_runtime_path" : legacy_steam_runtime_path ,
425
+ "use_bwrap" : use_bwrap ,
426
+ "start_wineserver" : start_background_wineserver ,
427
+ }
428
+
409
429
if args .winetricks_command :
410
430
returncode = run_command (
411
- winetricks_path = winetricks_path ,
412
- proton_app = proton_app ,
413
- steam_app = steam_app ,
414
- use_steam_runtime = use_steam_runtime ,
415
- legacy_steam_runtime_path = legacy_steam_runtime_path ,
416
- use_bwrap = use_bwrap ,
417
- start_wineserver = start_background_wineserver ,
431
+ ** command_kwargs ,
418
432
command = [str (winetricks_path )] + args .winetricks_command ,
419
433
cwd = cwd
420
434
)
421
435
elif args .command :
422
436
returncode = run_command (
423
- winetricks_path = winetricks_path ,
424
- proton_app = proton_app ,
425
- steam_app = steam_app ,
437
+ ** command_kwargs ,
426
438
command = args .command ,
427
- use_steam_runtime = use_steam_runtime ,
428
- legacy_steam_runtime_path = legacy_steam_runtime_path ,
429
- use_bwrap = use_bwrap ,
430
- start_wineserver = start_background_wineserver ,
431
439
# Pass the command directly into the shell *without*
432
440
# escaping it
433
441
shell = True ,
434
442
cwd = cwd ,
435
443
)
444
+ elif args .game_launch :
445
+ game_kwargs = get_app_launch_parameters (
446
+ steam_app = steam_app ,
447
+ steam_path = steam_path
448
+ )
449
+ returncode = run_command (
450
+ ** command_kwargs ,
451
+ ** game_kwargs
452
+ )
436
453
437
454
logger .info ("Command returned %d" , returncode )
438
455
0 commit comments