More clearly delineate the different cases for the text label.
The preferences in order are: value passed by flag, value read from config, and value read from stdin.
This commit is contained in:
parent
a3a970a22f
commit
21bdcf3e17
1 changed files with 21 additions and 11 deletions
32
dcc/text.py
32
dcc/text.py
|
|
@ -60,21 +60,19 @@ 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)
|
||||||
parser.add_argument("--nomap", action="store_true")
|
parser.add_argument("--nomap", action="store_true")
|
||||||
|
parser.add_argument("--nomapname", action="store_true")
|
||||||
|
parser.add_argument("--mapname", "-m", default="")
|
||||||
parser.add_argument("--demotype", default="UV-Max Demo")
|
parser.add_argument("--demotype", default="UV-Max Demo")
|
||||||
parser.add_argument("--stdin", "--stdin-only", action="store_true")
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
text = None
|
text = ""
|
||||||
if not parsed_args.stdin:
|
if not parsed_args.nomapname:
|
||||||
map_names = self._config.get("map_names")
|
if not parsed_args.nomap:
|
||||||
if map_names is not None:
|
text = f"MAP{parsed_args.map}: "
|
||||||
text = map_names.get(f"map{parsed_args.map}")
|
text += self.map_name(parsed_args.mapname, parsed_args.map)
|
||||||
if text is None:
|
text += "\n"
|
||||||
text = input("Map Name? ")
|
text = "{}{}".format(text, parsed_args.demotype)
|
||||||
if not parsed_args.nomap:
|
|
||||||
text = "MAP{}: {}".format(parsed_args.map, text)
|
|
||||||
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_width
|
||||||
|
|
@ -85,3 +83,15 @@ class Text(dcc.doom_base.WadMap):
|
||||||
img.trim()
|
img.trim()
|
||||||
img.reset_coords()
|
img.reset_coords()
|
||||||
img.save(filename=self.text_thumb_path())
|
img.save(filename=self.text_thumb_path())
|
||||||
|
|
||||||
|
def map_name(self, mapname, mapnum):
|
||||||
|
if mapname != "":
|
||||||
|
return mapname
|
||||||
|
|
||||||
|
map_names = self._config.get("map_names")
|
||||||
|
if map_names is not None:
|
||||||
|
text = map_names.get(f"map{mapnum}")
|
||||||
|
if text != "":
|
||||||
|
return text
|
||||||
|
|
||||||
|
return input("Map Name? ")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue