diff options
| -rw-r--r-- | maps/Makefile | 20 | ||||
| -rwxr-xr-x | scripts/generate_map_img.py | 10 |
2 files changed, 28 insertions, 2 deletions
diff --git a/maps/Makefile b/maps/Makefile new file mode 100644 index 00000000..45254c04 --- /dev/null +++ b/maps/Makefile @@ -0,0 +1,20 @@ +.PHONY: all clean + +.DEFAULT_GOAL = all + +MAPS = $(shell find . -name "*.map") + +VERBOSE = @ + +PNGS = $(MAPS:.map=.png) + +MAKEFILE_LIST = Makefile + +all: $(PNGS) + +%.png : %.map $(MAKEFILE_LIST) + @echo "generate map › $@" + $(VERBOSE) python3 ../scripts/generate_map_img.py $< + +clean: + rm -f $(PNGS) diff --git a/scripts/generate_map_img.py b/scripts/generate_map_img.py index 608c1fe6..bb6925bc 100755 --- a/scripts/generate_map_img.py +++ b/scripts/generate_map_img.py @@ -8,6 +8,7 @@ from typing import MutableMapping MAP_ROOT = pathlib.Path(os.getcwd()) TILES_DIR = MAP_ROOT / 'tiles' +SHOW_MAP = False def get_tile_path(tile: str) -> pathlib.Path: """Return the corresponding image file name for a tile""" @@ -111,8 +112,9 @@ def generate_img(map_path: pathlib.Path): rows_imgs.append(row_img) map_img = cv2.vconcat(rows_imgs) - cv2.imshow(f'{map_path.stem}.png', map_img) - cv2.waitKey(0) + if SHOW_MAP: + cv2.imshow(f'{map_path.stem}.png', map_img) + cv2.waitKey(0) cv2.imwrite(f'{map_path.stem}.png', map_img) def main(): @@ -121,6 +123,7 @@ def main(): parser = argparse.ArgumentParser(description='generate latex standalone cards') parser.add_argument('map_input', help='map file or directory containing map files') parser.add_argument('--map-root', help='path to the map root directory') + parser.add_argument('--show-map', help='show the generated map', action='store_true') args = parser.parse_args() @@ -130,6 +133,9 @@ def main(): global TILES_DIR TILES_DIR = MAP_ROOT / 'tiles' + if args.show_map: + global SHOW_MAP + SHOW_MAP = True map_path = pathlib.Path(args.map_input) map_files = [map_path] |
