Compare commits
No commits in common. "35894c26142a3321b3ad769f5b149f32bb95991c" and "b14c12c609f7b6af4d0f7a76f0283e90f4311d4b" have entirely different histories.
35894c2614
...
b14c12c609
5 changed files with 23 additions and 42 deletions
|
@ -85,11 +85,7 @@ class Concat(dcc.doom_base.Wad):
|
||||||
)
|
)
|
||||||
mapstring = v.name[-6:-4]
|
mapstring = v.name[-6:-4]
|
||||||
text = self._config["map_names"][f"map{mapstring}"]
|
text = self._config["map_names"][f"map{mapstring}"]
|
||||||
self.draw_text(
|
dcc.text.draw_text(img, f"MAP{mapstring}: {text}", font_size=120)
|
||||||
img,
|
|
||||||
f"MAP{mapstring}: {text}",
|
|
||||||
font_size=120
|
|
||||||
)
|
|
||||||
img.trim(reset_coords=True)
|
img.trim(reset_coords=True)
|
||||||
img.border("graya(25%, 25%)", 10, 10)
|
img.border("graya(25%, 25%)", 10, 10)
|
||||||
img.border(dcc.config.TEXT_STROKE_COLOR, 16, 16)
|
img.border(dcc.config.TEXT_STROKE_COLOR, 16, 16)
|
||||||
|
|
|
@ -26,36 +26,25 @@ class Base(Command):
|
||||||
"required key 'dsda' not set in config "
|
"required key 'dsda' not set in config "
|
||||||
+ f"{self.doom.joinpath(self.config_name)}.")
|
+ f"{self.doom.joinpath(self.config_name)}.")
|
||||||
for d in ("iwads", "pwads", "demos", "fabricate"):
|
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"], 720)
|
self._init_attr("thumbnail.height", 1280)
|
||||||
self._init_attr(["thumbnail", "width"], 1280)
|
self._init_attr("thumbnail.width", 720)
|
||||||
self._init_attr(["thumbnail", "font"], None)
|
self._init_attr("thumbnail.font", None)
|
||||||
self._init_attr(["thumbnail", "text_fill"], "white")
|
self._init_attr("thumbnail.text_fill", "white")
|
||||||
self._init_attr(["thumbnail", "text_stroke"], "red")
|
self._init_attr("thumbnail.text_stroke", "red")
|
||||||
self._init_attr(
|
self._init_attr("fetch.mirror", "https://youfailit.net/pub/idgames")
|
||||||
["fetch", "mirror"],
|
|
||||||
"https://youfailit.net/pub/idgames"
|
|
||||||
)
|
|
||||||
|
|
||||||
def run(self, parsed_args):
|
def run(self, parsed_args):
|
||||||
self.init_base(parsed_args)
|
self.init_base(parsed_args)
|
||||||
self.take_action(parsed_args)
|
self.take_action(parsed_args)
|
||||||
|
|
||||||
def _init_attr(self, what, default, fn=lambda x: x):
|
def _init_attr(self, what, default, fn=lambda x: x):
|
||||||
propname = "_".join(what)
|
what = what.replace(".", "_")
|
||||||
val = self._config
|
|
||||||
for w in what:
|
|
||||||
val = val[w]
|
|
||||||
if val is None:
|
|
||||||
val = default
|
|
||||||
break
|
|
||||||
|
|
||||||
setattr(self, f"_{propname}", fn(val))
|
|
||||||
setattr(
|
setattr(
|
||||||
type(self), propname,
|
self, f"_{what}", fn(self._config.get(what, default)))
|
||||||
property(lambda self: getattr(self, f"_{propname}"))
|
setattr(
|
||||||
)
|
type(self), what, property(lambda self: getattr(self, f"_{what}")))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def doom(self):
|
def doom(self):
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import dcc.doom_base
|
import dcc.config
|
||||||
import tomlkit.toml_file
|
import tomlkit
|
||||||
|
from tomlkit.toml_file import TOMLFile
|
||||||
|
|
||||||
|
|
||||||
class Configure(dcc.doom_base.Wad):
|
class Configure(dcc.config.Base):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super().get_parser(prog_name)
|
parser = super().get_parser(prog_name)
|
||||||
|
parser.add_argument("wad")
|
||||||
parser.add_argument("complevel")
|
parser.add_argument("complevel")
|
||||||
parser.add_argument("--iwad")
|
parser.add_argument("--iwad")
|
||||||
return parser
|
return parser
|
||||||
|
@ -12,12 +14,12 @@ class Configure(dcc.doom_base.Wad):
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
new_config = self.pwad_path.joinpath(self.config_name)
|
new_config = self.pwad_path.joinpath(self.config_name)
|
||||||
if new_config.exists():
|
if new_config.exists():
|
||||||
raise Exception(f"Config {new_config} already exists.")
|
raise Exception("Config %s already exists.".format(new_config))
|
||||||
|
|
||||||
doc = tomlkit.document()
|
doc = tomlkit.document()
|
||||||
doc.add("complevel", parsed_args.complevel)
|
doc.add("complevel", parsed_args.complevel)
|
||||||
if parsed_args.iwad is not None:
|
if parsed_args.iwad is not None:
|
||||||
doc.add("iwad", parsed_args.iwad)
|
doc.add("iwad", parsed_args.iwad)
|
||||||
|
|
||||||
f = tomlkit.toml_file.TOMLFile(new_config)
|
f = TOMLFile(new_config)
|
||||||
f.write(doc)
|
f.write(doc)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class SS(dcc.doom_base.WadMap):
|
||||||
height = self.thumbnail_height
|
height = self.thumbnail_height
|
||||||
with wand.image.Image(width=width, height=height, pseudo="x:") as img:
|
with wand.image.Image(width=width, height=height, pseudo="x:") as img:
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
if (img.width < width or img.height < height):
|
if (img.size[0] < width or img.size[1] < height):
|
||||||
if not messagebox.askretrycancel(
|
if not messagebox.askretrycancel(
|
||||||
title="DCC",
|
title="DCC",
|
||||||
message=f"Image too small ({img.width}x{img.height})." +
|
message=f"Image too small ({img.width}x{img.height})." +
|
||||||
|
|
12
dcc/text.py
12
dcc/text.py
|
@ -1,11 +1,10 @@
|
||||||
import dcc.config
|
|
||||||
import dcc.doom_base
|
import dcc.doom_base
|
||||||
import sys
|
import sys
|
||||||
import wand.drawing
|
import wand.drawing
|
||||||
import wand.image
|
import wand.image
|
||||||
|
|
||||||
|
|
||||||
def draw_text(self, img, text, font_size=64):
|
def draw_text(img, text, font_size=64):
|
||||||
with wand.drawing.Drawing() as draw:
|
with wand.drawing.Drawing() as draw:
|
||||||
draw.font = self.thumbnail_font
|
draw.font = self.thumbnail_font
|
||||||
draw.font_size = font_size
|
draw.font_size = font_size
|
||||||
|
@ -21,9 +20,6 @@ def draw_text(self, img, text, font_size=64):
|
||||||
draw(img)
|
draw(img)
|
||||||
|
|
||||||
|
|
||||||
dcc.config.Base.draw_text = draw_text
|
|
||||||
|
|
||||||
|
|
||||||
class Text(dcc.doom_base.WadMap):
|
class Text(dcc.doom_base.WadMap):
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super().get_parser(prog_name)
|
parser = super().get_parser(prog_name)
|
||||||
|
@ -38,11 +34,9 @@ class Text(dcc.doom_base.WadMap):
|
||||||
text = "{}\n{}".format(text, parsed_args.demotype)
|
text = "{}\n{}".format(text, parsed_args.demotype)
|
||||||
with wand.image.Image(
|
with wand.image.Image(
|
||||||
height=self.thumbnail_height,
|
height=self.thumbnail_height,
|
||||||
width=self.thumbnail_width
|
width=self.thumbnail_height
|
||||||
) as img:
|
) as img:
|
||||||
self.draw_text(
|
draw_text(img, text)
|
||||||
img, text,
|
|
||||||
)
|
|
||||||
img.trim()
|
img.trim()
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
img.save(filename=self.text_thumb_path())
|
img.save(filename=self.text_thumb_path())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue