2025-04-07 02:19:25 -04:00
|
|
|
import io
|
|
|
|
import pathlib
|
|
|
|
import os
|
|
|
|
import re
|
2025-05-17 11:50:59 -04:00
|
|
|
import tomlkit
|
2025-04-07 02:19:25 -04:00
|
|
|
|
2025-05-17 11:50:59 -04:00
|
|
|
from cliff.command import Command
|
2025-04-07 02:19:25 -04:00
|
|
|
|
2025-04-16 02:55:14 -04:00
|
|
|
THUMB_WIDTH=1280
|
|
|
|
THUMB_HEIGHT=720
|
2025-04-20 14:16:44 -04:00
|
|
|
FONT="League-Spartan-Bold"
|
|
|
|
TEXT_FILL_COLOR="white"
|
|
|
|
TEXT_STROKE_COLOR="srgb(176,0,0)"
|
2025-04-16 02:55:14 -04:00
|
|
|
|
2025-04-19 23:05:38 -04:00
|
|
|
MIRROR="https://youfailit.net/pub/idgames" # NYC
|
|
|
|
|
2025-04-28 18:31:36 -04:00
|
|
|
|
2025-05-17 11:50:59 -04:00
|
|
|
class Base(Command):
|
|
|
|
def get_parser(self, prog_name):
|
|
|
|
parser = super().get_parser(prog_name)
|
|
|
|
parser.add_argument('--doom', default=pathlib.Path.home().joinpath("doom"))
|
|
|
|
parser.add_argument('--config-name', default='config.toml')
|
|
|
|
return parser
|
|
|
|
|
|
|
|
def run(self, parsed_args):
|
|
|
|
self._doom = pathlib.Path(parsed_args.doom)
|
|
|
|
self._config_name = parsed_args.config_name
|
|
|
|
self._config = tomlkit.toml_file.TOMLFile(self.doom.joinpath(self.config_name)).read()
|
|
|
|
self._dsda = self._config.get("dsda")
|
|
|
|
if self.dsda is None:
|
|
|
|
raise Exception(f"required key 'dsda' not set in config {self.doom.joinpath(self.config_name)}.")
|
|
|
|
for d in ("iwads", "pwads", "demos", "fabricate"):
|
|
|
|
self._init_path(d)
|
|
|
|
|
|
|
|
self.take_action(parsed_args)
|
|
|
|
|
|
|
|
def _init_path(self, what):
|
|
|
|
setattr(self, f"_{what}", self.doom.joinpath(self._config.get(what, what)))
|
|
|
|
setattr(type(self), what, property(lambda self: getattr(self, f"_{what}")))
|
|
|
|
|
|
|
|
@property
|
|
|
|
def doom(self):
|
|
|
|
return self._doom
|
|
|
|
|
|
|
|
@property
|
|
|
|
def config_name(self):
|
|
|
|
return self._config_name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def dsda(self):
|
|
|
|
return self._doom.joinpath(self._dsda)
|
|
|
|
|
|
|
|
def iwad_path(self, wad):
|
|
|
|
iwad = self.iwads.joinpath(self._config.get("default_iwad"))
|
|
|
|
iwadpath = self.pwads.joinpath("iwad")
|
|
|
|
if iwadpath.exists():
|
|
|
|
with io.open(iwadpath) as f:
|
|
|
|
iwad = self.iwads.joinpath(f.read().strip() + ".WAD")
|
|
|
|
return iwad
|
2025-04-28 18:31:36 -04:00
|
|
|
|