BizHawkClient: Add autostart setting (#2322)
This commit is contained in:
parent
38c9ee146d
commit
b707619aad
20
settings.py
20
settings.py
|
@ -694,6 +694,25 @@ does nothing if not found
|
||||||
snes_rom_start: Union[SnesRomStart, bool] = True
|
snes_rom_start: Union[SnesRomStart, bool] = True
|
||||||
|
|
||||||
|
|
||||||
|
class BizHawkClientOptions(Group):
|
||||||
|
class EmuHawkPath(UserFilePath):
|
||||||
|
"""
|
||||||
|
The location of the EmuHawk you want to auto launch patched ROMs with
|
||||||
|
"""
|
||||||
|
is_exe = True
|
||||||
|
description = "EmuHawk Executable"
|
||||||
|
|
||||||
|
class RomStart(str):
|
||||||
|
"""
|
||||||
|
Set this to true to autostart a patched ROM in BizHawk with the connector script,
|
||||||
|
to false to never open the patched rom automatically,
|
||||||
|
or to a path to an external program to open the ROM file with that instead.
|
||||||
|
"""
|
||||||
|
|
||||||
|
emuhawk_path: EmuHawkPath = EmuHawkPath(None)
|
||||||
|
rom_start: Union[RomStart, bool] = True
|
||||||
|
|
||||||
|
|
||||||
# Top-level group with lazy loading of worlds
|
# Top-level group with lazy loading of worlds
|
||||||
|
|
||||||
class Settings(Group):
|
class Settings(Group):
|
||||||
|
@ -701,6 +720,7 @@ class Settings(Group):
|
||||||
server_options: ServerOptions = ServerOptions()
|
server_options: ServerOptions = ServerOptions()
|
||||||
generator: GeneratorOptions = GeneratorOptions()
|
generator: GeneratorOptions = GeneratorOptions()
|
||||||
sni_options: SNIOptions = SNIOptions()
|
sni_options: SNIOptions = SNIOptions()
|
||||||
|
bizhawkclient_options: BizHawkClientOptions = BizHawkClientOptions()
|
||||||
|
|
||||||
_filename: Optional[str] = None
|
_filename: Optional[str] = None
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ checking or launching the client, otherwise it will probably cause circular impo
|
||||||
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import subprocess
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
@ -146,8 +147,24 @@ async def _game_watcher(ctx: BizHawkClientContext):
|
||||||
|
|
||||||
|
|
||||||
async def _run_game(rom: str):
|
async def _run_game(rom: str):
|
||||||
import webbrowser
|
import os
|
||||||
webbrowser.open(rom)
|
auto_start = Utils.get_settings().bizhawkclient_options.rom_start
|
||||||
|
|
||||||
|
if auto_start is True:
|
||||||
|
emuhawk_path = Utils.get_settings().bizhawkclient_options.emuhawk_path
|
||||||
|
subprocess.Popen([emuhawk_path, "--lua=data/lua/connector_bizhawk_generic.lua", os.path.realpath(rom)],
|
||||||
|
cwd=Utils.local_path("."),
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL)
|
||||||
|
elif isinstance(auto_start, str):
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
subprocess.Popen([*shlex.split(auto_start), os.path.realpath(rom)],
|
||||||
|
cwd=Utils.local_path("."),
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
async def _patch_and_run_game(patch_file: str):
|
async def _patch_and_run_game(patch_file: str):
|
||||||
|
|
Loading…
Reference in New Issue