diff --git a/src/editor.py b/src/editor.py index 88dcd69..b2fea52 100644 --- a/src/editor.py +++ b/src/editor.py @@ -1,6 +1,8 @@ +import os from math import floor from typing import Optional +import platformdirs import pygame from src.image_handler import ImageHandler @@ -10,7 +12,7 @@ class Editor: WIDTH: int = 800 HEIGHT: int = 600 MAP_SIZE: int = 1024 - MAPS_DIR: str = "/tmp/lycacraft_maps" + MAPS_DIR: str = os.path.join(platformdirs.user_cache_dir(appname="lycacraft-paths", appauthor="Lycacraft"), "maps") ZOOMS: tuple[float] = (0.25, 0.5, 1, 2, 4) CROSSHAIR_SIZE: int = 10 diff --git a/utils/map_splitter.py b/utils/map_splitter.py index 11c2686..002b9e3 100644 --- a/utils/map_splitter.py +++ b/utils/map_splitter.py @@ -2,10 +2,11 @@ from math import ceil, log10 import os.path from PIL import Image +import platformdirs Image.MAX_IMAGE_PIXELS = 200000000 MAP_SIZE = 1024 - +DEFAULT_PATH = os.path.join(platformdirs.user_cache_dir(appname="lycacraft-paths", appauthor="Lycacraft"), "maps") def clamp(mn, value, mx): return max(mn, min(mx, value)) @@ -15,12 +16,12 @@ def main(): # 2024-06-27_21.01.45_Lycacraft_minecraft~overworld_day.png # 6144,10240 input_path = input("Input image: ") - output_path = input("Output dir (default: /tmp/lycacraft_maps/): ") + output_path = input(f"Output dir (default: {DEFAULT_PATH}): ") if output_path.strip() == "": - output_path = "/tmp/lycacraft_maps" + output_path = DEFAULT_PATH if not os.path.exists(output_path): - os.mkdir(output_path) + os.makedirs(output_path) elif not os.path.isdir(output_path): print("Output path must be a directory") return