2025-07-04 12:08:25 -04:00
|
|
|
import dcc.config
|
2025-04-20 14:16:44 -04:00
|
|
|
import dcc.doom_base
|
|
|
|
import sys
|
|
|
|
import wand.drawing
|
|
|
|
import wand.image
|
|
|
|
|
2025-06-15 13:31:32 -04:00
|
|
|
|
2025-07-06 14:33:42 -04:00
|
|
|
def draw_text(self, img, text, font_size=64):
|
2025-06-15 13:31:32 -04:00
|
|
|
with wand.drawing.Drawing() as draw:
|
2025-07-04 12:08:25 -04:00
|
|
|
draw.font = self.thumbnail_font
|
2025-06-15 13:31:32 -04:00
|
|
|
draw.font_size = font_size
|
2025-07-04 12:08:25 -04:00
|
|
|
draw.fill_color = wand.color.Color(self.thumbnail_text_fill)
|
|
|
|
draw.stroke_color = wand.color.Color(self.thumbnail_text_stroke)
|
2025-06-15 13:31:32 -04:00
|
|
|
draw.stroke_width = font_size * 5 / 32
|
|
|
|
draw.text_interline_spacing = -font_size / 4
|
|
|
|
draw.text(5, int(draw.font_size) + 5, text)
|
|
|
|
draw(img)
|
|
|
|
draw.stroke_color = wand.color.Color("none")
|
|
|
|
draw.stroke_width = 0
|
|
|
|
draw.text(5, int(draw.font_size)+5, text)
|
|
|
|
draw(img)
|
2025-06-02 02:23:54 -04:00
|
|
|
|
2025-07-06 14:33:42 -04:00
|
|
|
|
2025-07-04 12:08:25 -04:00
|
|
|
dcc.config.Base.draw_text = draw_text
|
2025-06-02 02:23:54 -04:00
|
|
|
|
2025-07-06 14:33:42 -04:00
|
|
|
|
2025-04-20 14:16:44 -04:00
|
|
|
class Text(dcc.doom_base.WadMap):
|
2025-06-15 13:31:32 -04:00
|
|
|
def get_parser(self, prog_name):
|
|
|
|
parser = super().get_parser(prog_name)
|
|
|
|
parser.add_argument("--nomap", action="store_true")
|
|
|
|
parser.add_argument("--demotype", default="UV-Max Demo")
|
|
|
|
return parser
|
2025-04-20 14:16:44 -04:00
|
|
|
|
2025-06-15 13:31:32 -04:00
|
|
|
def take_action(self, parsed_args):
|
|
|
|
text = sys.stdin.read().rstrip()
|
|
|
|
if not parsed_args.nomap:
|
|
|
|
text = "MAP{}: {}".format(parsed_args.map, text)
|
|
|
|
text = "{}\n{}".format(text, parsed_args.demotype)
|
|
|
|
with wand.image.Image(
|
2025-07-03 18:04:19 -04:00
|
|
|
height=self.thumbnail_height,
|
2025-07-04 11:50:10 -04:00
|
|
|
width=self.thumbnail_width
|
2025-06-15 13:31:32 -04:00
|
|
|
) as img:
|
2025-07-04 12:08:25 -04:00
|
|
|
self.draw_text(
|
2025-07-04 11:50:10 -04:00
|
|
|
img, text,
|
|
|
|
)
|
2025-06-15 13:31:32 -04:00
|
|
|
img.trim()
|
|
|
|
img.reset_coords()
|
|
|
|
img.save(filename=self.text_thumb_path())
|