current_menu = 'main' while True: game.clear_screen() print( Utils.cyan_bright("HAC-GAME-LIB - EDITOR v" + Constants.HAC_GAME_LIB_VERSION)) print('Looking for existing maps in selected directories...', end='') with open('directories.json') as paths: directories = json.load(paths) hmaps = [] try: for directory in directories: files = [f'{directory}/{f}' for f in os.listdir(directory)] hmaps += files print(Utils.green('OK')) except FileNotFoundError as e: print(Utils.red('KO')) if len(hmaps) > 0: map_num = 0 game.add_menu_entry('boards_list', None, "Choose a map to edit") for m in hmaps: print(f"{map_num} - edit {m}") game.add_menu_entry('boards_list', str(map_num), f"edit {m}", f"{m}") map_num += 1 game.add_menu_entry('boards_list', 'B', "Go Back to main menu") else: print('No pre-existing map found.') print('n - create a new map')
if os.path.exists(test_dir): directory = test_dir # Utils.debug(f"Setting directory to: {directory}") if os.path.exists(directory): if default_map_dir is None: default_map_dir = directory for f in os.listdir(directory): if os.path.isabs(f): hmaps.append(f) else: if os.path.exists(f): hmaps.append(f) elif os.path.exists(os.path.join(directory, f)): hmaps.append(os.path.join(directory, f)) if len(hmaps) > 0: print(Utils.green("OK")) else: print(Utils.red_bright("KO")) if len(hmaps) > 0: map_num = 0 game.add_menu_entry("boards_list", None, "Choose a map to edit") for m in hmaps: print(f"{map_num} - edit {m}") game.add_menu_entry("boards_list", str(map_num), f"edit {m}", f"{m}") map_num += 1 game.add_menu_entry("boards_list", "B", "Go Back to main menu") else: print("No pre-existing map found.") print("n - create a new map")