From 7f397f352f073aabfea4c5a531478ea59af2a6f1 Mon Sep 17 00:00:00 2001 From: yrriban Date: Mon, 28 Apr 2025 18:31:36 -0400 Subject: [PATCH] Add a command to invoke eureka for the given wad and map. --- dcc/config.py | 28 +++++++++++++++++++--------- dcc/eureka.py | 19 +++++++++++++++++++ setup.py | 1 + 3 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 dcc/eureka.py diff --git a/dcc/config.py b/dcc/config.py index fc0d6ba..0ef4146 100644 --- a/dcc/config.py +++ b/dcc/config.py @@ -23,15 +23,9 @@ TEXT_STROKE_COLOR="srgb(176,0,0)" MIRROR="https://youfailit.net/pub/idgames" # NYC def DsdaPreamble(wad, mapstr): - args = [] - pwadpath = PWADS.joinpath(wad) - iwad = DEFAULT_IWAD - iwadpath = pwadpath.joinpath("iwad") - if iwadpath.exists(): - with io.open(iwadpath) as f: - iwad = IWADS.joinpath(f.read().strip() + ".WAD") - args = args + ["-iwad", iwad] + args = ["-iwad", IwadPath(wad)] + pwadpath = PWADS.joinpath(wad) wads = sorted(pwadpath.glob('*.wad', case_sensitive=False)) if len(wads) > 0: args = args + ["-file"] + wads @@ -45,7 +39,7 @@ def DsdaPreamble(wad, mapstr): raise Exception("No complevel set in PWAD dir {}.".format(pwadpath)) with io.open(complevel) as f: - args = args + ["-complevel", f.read().strip()] + args = args + ["-complevel", Complevel(wad)] args = args + ["-skill", "4"] args = args + ["-warp", mapstr] # TODO: UDoom @@ -68,6 +62,22 @@ def DemoOutPath(wad, mapstr): def DemoName(wad, mapstr): return "{}_map{}.lmp".format(wad, mapstr) +def Complevel(wad): + complevel = PwadPath(wad).joinpath("complevel") + if not complevel.exists(): + raise Exception("No complevel set in PWAD dir {}.".format(pwadpath)) + + with io.open(complevel) as f: + return f.read().strip() + +def IwadPath(wad): + iwad = DEFAULT_IWAD + iwadpath = PwadPath(wad).joinpath("iwad") + if iwadpath.exists(): + with io.open(iwadpath) as f: + iwad = IWADS.joinpath(f.read().strip() + ".WAD") + return iwad + def PwadPath(wad): return Ensure(PWADS.joinpath(wad)) diff --git a/dcc/eureka.py b/dcc/eureka.py new file mode 100644 index 0000000..1b5a6d8 --- /dev/null +++ b/dcc/eureka.py @@ -0,0 +1,19 @@ +import dcc.doom_base +import dcc.config +import subprocess + +class Eureka(dcc.doom_base.WadMap): + def take_action(self, parsed_args): + iwad = dcc.config.IwadPath(parsed_args.wad) + pwadpath = dcc.config.PwadPath(parsed_args.wad) + mw = list(pwadpath.glob('*{}*.wad'.format(parsed_args.wad), case_sensitive=False)) + if len(mw) != 1: + raise Exception("Unable to guess at main pwad for wad {}.".format(parsed_args.wad)) + complevel = dcc.config.Complevel(parsed_args.wad) + port = "vanilla" + if complevel == "9": + port = "boom" + if complevel == "11" or complevel == "21": + port = "mbf" + + subprocess.run(["eureka"] + ["-iwad", iwad] + ["-w", parsed_args.map] + ["-p", port] + [mw[0]]) diff --git a/setup.py b/setup.py index bc2ae78..85b1218 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ setup( 'text = dcc.text:Text', 'thumb = dcc.thumb:Thumb', 'dsda = dcc.dsda:DSDA', + 'eureka = dcc.eureka:Eureka', ], }, zip_safe=False,