expand rom auto_start to be customizable

This commit is contained in:
Fabian Dill 2020-07-15 17:19:16 +02:00
parent 0ba2405bbc
commit 2338d25b39
3 changed files with 16 additions and 8 deletions

View File

@ -11,6 +11,8 @@ import multiprocessing
import socket
import sys
import typing
import os
import subprocess
from random import randrange
@ -378,7 +380,6 @@ SNES_ATTACHED = 3
def launch_qusb2snes(ctx: Context):
qusb2snes_path = Utils.get_options()["general_options"]["qusb2snes"]
import os
if not os.path.isfile(qusb2snes_path):
qusb2snes_path = Utils.local_path(qusb2snes_path)
@ -1229,8 +1230,13 @@ async def game_watcher(ctx : Context):
async def run_game(romfile):
import webbrowser
webbrowser.open(romfile)
auto_start = Utils.get_options()["general_options"].get("rom_start", True)
if auto_start is True:
import webbrowser
webbrowser.open(romfile)
elif os.path.isfile(auto_start):
subprocess.Popen([auto_start, romfile],
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
async def websocket_server(websocket: websockets.WebSocketServerProtocol, path, ctx: Context):
@ -1320,7 +1326,6 @@ async def main():
adjustedromfile, adjusted = Utils.get_adjuster_settings(romfile)
if adjusted:
try:
import os
os.replace(adjustedromfile, romfile)
adjustedromfile = romfile
except Exception as e:

View File

@ -125,11 +125,10 @@ if __name__ == "__main__":
if player_name:
for file in os.listdir(output_path):
if player_name in file:
import webbrowser
import MultiClient
import asyncio
romfilename = os.path.join(output_path, file)
print(f"Launching ROM file {romfilename}")
webbrowser.open(romfilename)
asyncio.run(MultiClient.run_game(os.path.join(output_path, file)))
break
if any((zip_roms, zip_multidata, zip_spoiler, zip_diffs)):

View File

@ -3,6 +3,10 @@ general_options:
rom_file: "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"
# set this to your (Q)Usb2Snes location if you want the MultiClient to attempt an auto start, does nothing if not found
qusb2snes: "QUsb2Snes\\QUsb2Snes.exe"
# Set this to false to never autostart a rom (such as after patching)
# true for operating system default program
# alternatively, a path to a program to open the .sfc file with
rom_start: true
#options for MultiServer
#null means nothing, for the server this means to default the value
#these overwrite command line arguments!