Most of this is now in doom_base.py, which stores wad/map/name, exposes them as properties, and also takes care of most common tasks needed for building command lines and such.
97 lines
2.8 KiB
Python
97 lines
2.8 KiB
Python
from abc import abstractmethod
|
|
from cliff.command import Command
|
|
import dcc.config
|
|
import io
|
|
|
|
class WadMap(Command):
|
|
def get_parser(self, prog_name):
|
|
parser = super().get_parser(prog_name)
|
|
parser.add_argument('wad')
|
|
parser.add_argument('map')
|
|
parser.add_argument('-n','--name','--demo_name')
|
|
return parser
|
|
|
|
def run(self, parsed_args):
|
|
self._wad = parsed_args.wad
|
|
self._map = parsed_args.map
|
|
self._name = parsed_args.name
|
|
self.take_action(parsed_args)
|
|
|
|
@abstractmethod
|
|
def take_action(self, parsed_args):
|
|
pass
|
|
|
|
@property
|
|
def wad(self):
|
|
return self._wad
|
|
|
|
@property
|
|
def map(self):
|
|
return self._map
|
|
|
|
@property
|
|
def name_string(self):
|
|
return "" if self._name is None else "_" + self._name
|
|
|
|
def dsda_preamble(self):
|
|
args = ["-iwad", dcc.config.IwadPath(self.wad)]
|
|
|
|
pwadpath = dcc.config.PWADS.joinpath(self.wad)
|
|
wads = sorted(pwadpath.glob('*.wad', case_sensitive=False))
|
|
if len(wads) > 0:
|
|
args = args + ["-file"] + wads
|
|
|
|
dehs = sorted(pwadpath.glob('*.deh', case_sensitive=False))
|
|
if len(dehs) > 0:
|
|
args = args + ["-deh"] + dehs
|
|
|
|
complevel = pwadpath.joinpath("complevel")
|
|
if not complevel.exists():
|
|
raise Exception("No complevel set in PWAD dir {}.".format(pwadpath))
|
|
|
|
with io.open(complevel) as f:
|
|
args = args + ["-complevel", dcc.config.Complevel(self.wad)]
|
|
|
|
args = args + ["-skill", "4"]
|
|
args = args + ["-warp", self.map]
|
|
return args
|
|
|
|
def demo_in_path(self):
|
|
candidates = [x for x in dcc.config.DEMOS.joinpath(self.wad).glob(self._file_base("*.lmp"))]
|
|
if len(candidates) == 0:
|
|
raise Exception("no suitable demo candidates for WAD {} MAP {} name {}.".format(self.wad, self.map, self.name_string))
|
|
if len(candidates) == 1:
|
|
return candidates[0]
|
|
return sorted(filter(lambda s : re.search("-", str(s)), candidates))[-1]
|
|
|
|
def dsda_text_path(self):
|
|
return _ensure(dcc.config.DEMOS.joinpath(self.wad)).joinpath(self._file_base(".txt"))
|
|
|
|
def video_path(self):
|
|
return _ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(self._file_base(".mp4"))
|
|
|
|
def demo_out_path(self):
|
|
return _ensure(dcc.config.DEMOS.joinpath(self.wad)).joinpath(self._file_base(".lmp"))
|
|
|
|
def target_bucket(self):
|
|
return "doom/" + self._file_base(".lmp")
|
|
|
|
def base_thumb_path(self):
|
|
return _ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_base.png"))
|
|
|
|
def m_doom_path(self):
|
|
return _ensure(OUTPUT.joinpath(self.wad)).joinpath("M_DOOM_scaled.png")
|
|
|
|
def text_thumb_path(self):
|
|
return _ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_text.png"))
|
|
|
|
def thumb_path(self):
|
|
return _ensure(dcc.config.OUTPUT.joinpath(self.wad)).joinpath(_file_base("_thumb.png"))
|
|
|
|
def _file_base(self, ext):
|
|
return "{}_map{}{}{}".format(self.wad, self.map, self.name_string, ext)
|
|
|
|
def _ensure(path):
|
|
if not path.exists():
|
|
os.mkdir(path)
|
|
return path
|