Compare commits
4 commits
b14c12c609
...
35894c2614
Author | SHA1 | Date | |
---|---|---|---|
35894c2614 | |||
b56b0419e2 | |||
105be2c5fd | |||
1ac3851065 |
5 changed files with 42 additions and 23 deletions
|
@ -85,7 +85,11 @@ class Concat(dcc.doom_base.Wad):
|
|||
)
|
||||
mapstring = v.name[-6:-4]
|
||||
text = self._config["map_names"][f"map{mapstring}"]
|
||||
dcc.text.draw_text(img, f"MAP{mapstring}: {text}", font_size=120)
|
||||
self.draw_text(
|
||||
img,
|
||||
f"MAP{mapstring}: {text}",
|
||||
font_size=120
|
||||
)
|
||||
img.trim(reset_coords=True)
|
||||
img.border("graya(25%, 25%)", 10, 10)
|
||||
img.border(dcc.config.TEXT_STROKE_COLOR, 16, 16)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import dcc.config
|
||||
import tomlkit
|
||||
from tomlkit.toml_file import TOMLFile
|
||||
import dcc.doom_base
|
||||
import tomlkit.toml_file
|
||||
|
||||
|
||||
class Configure(dcc.config.Base):
|
||||
class Configure(dcc.doom_base.Wad):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument("wad")
|
||||
parser.add_argument("complevel")
|
||||
parser.add_argument("--iwad")
|
||||
return parser
|
||||
|
@ -14,12 +12,12 @@ class Configure(dcc.config.Base):
|
|||
def take_action(self, parsed_args):
|
||||
new_config = self.pwad_path.joinpath(self.config_name)
|
||||
if new_config.exists():
|
||||
raise Exception("Config %s already exists.".format(new_config))
|
||||
raise Exception(f"Config {new_config} already exists.")
|
||||
|
||||
doc = tomlkit.document()
|
||||
doc.add("complevel", parsed_args.complevel)
|
||||
if parsed_args.iwad is not None:
|
||||
doc.add("iwad", parsed_args.iwad)
|
||||
|
||||
f = TOMLFile(new_config)
|
||||
f = tomlkit.toml_file.TOMLFile(new_config)
|
||||
f.write(doc)
|
||||
|
|
|
@ -22,7 +22,7 @@ class SS(dcc.doom_base.WadMap):
|
|||
height = self.thumbnail_height
|
||||
with wand.image.Image(width=width, height=height, pseudo="x:") as img:
|
||||
img.reset_coords()
|
||||
if (img.size[0] < width or img.size[1] < height):
|
||||
if (img.width < width or img.height < height):
|
||||
if not messagebox.askretrycancel(
|
||||
title="DCC",
|
||||
message=f"Image too small ({img.width}x{img.height})." +
|
||||
|
|
12
dcc/text.py
12
dcc/text.py
|
@ -1,10 +1,11 @@
|
|||
import dcc.config
|
||||
import dcc.doom_base
|
||||
import sys
|
||||
import wand.drawing
|
||||
import wand.image
|
||||
|
||||
|
||||
def draw_text(img, text, font_size=64):
|
||||
def draw_text(self, img, text, font_size=64):
|
||||
with wand.drawing.Drawing() as draw:
|
||||
draw.font = self.thumbnail_font
|
||||
draw.font_size = font_size
|
||||
|
@ -20,6 +21,9 @@ def draw_text(img, text, font_size=64):
|
|||
draw(img)
|
||||
|
||||
|
||||
dcc.config.Base.draw_text = draw_text
|
||||
|
||||
|
||||
class Text(dcc.doom_base.WadMap):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
|
@ -34,9 +38,11 @@ class Text(dcc.doom_base.WadMap):
|
|||
text = "{}\n{}".format(text, parsed_args.demotype)
|
||||
with wand.image.Image(
|
||||
height=self.thumbnail_height,
|
||||
width=self.thumbnail_height
|
||||
width=self.thumbnail_width
|
||||
) as img:
|
||||
draw_text(img, text)
|
||||
self.draw_text(
|
||||
img, text,
|
||||
)
|
||||
img.trim()
|
||||
img.reset_coords()
|
||||
img.save(filename=self.text_thumb_path())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue