Actually load the values for screenshot text, etc. correctly from the config. Pass them into draw_text which doesn't have them readily available.

This commit is contained in:
yrriban 2025-07-04 11:50:10 -04:00
parent b14c12c609
commit 1ac3851065
4 changed files with 42 additions and 19 deletions

View file

@ -26,25 +26,36 @@ class Base(Command):
"required key 'dsda' not set in config "
+ f"{self.doom.joinpath(self.config_name)}.")
for d in ("iwads", "pwads", "demos", "fabricate"):
self._init_attr(d, d, fn=self.doom.joinpath)
self._init_attr([d], d, fn=self.doom.joinpath)
self._init_attr("thumbnail.height", 1280)
self._init_attr("thumbnail.width", 720)
self._init_attr("thumbnail.font", None)
self._init_attr("thumbnail.text_fill", "white")
self._init_attr("thumbnail.text_stroke", "red")
self._init_attr("fetch.mirror", "https://youfailit.net/pub/idgames")
self._init_attr(["thumbnail", "height"], 720)
self._init_attr(["thumbnail", "width"], 1280)
self._init_attr(["thumbnail", "font"], None)
self._init_attr(["thumbnail", "text_fill"], "white")
self._init_attr(["thumbnail", "text_stroke"], "red")
self._init_attr(
["fetch", "mirror"],
"https://youfailit.net/pub/idgames"
)
def run(self, parsed_args):
self.init_base(parsed_args)
self.take_action(parsed_args)
def _init_attr(self, what, default, fn=lambda x: x):
what = what.replace(".", "_")
propname = "_".join(what)
val = self._config
for w in what:
val = val[w]
if val is None:
val = default
break
setattr(self, f"_{propname}", fn(val))
setattr(
self, f"_{what}", fn(self._config.get(what, default)))
setattr(
type(self), what, property(lambda self: getattr(self, f"_{what}")))
type(self), propname,
property(lambda self: getattr(self, f"_{propname}"))
)
@property
def doom(self):