moved maps to cache dir

This commit is contained in:
Louis Heredero 2024-06-29 00:53:05 +02:00
parent ca74986b82
commit bbb248da16
Signed by: HEL
GPG Key ID: 8D83DE470F8544E7
2 changed files with 8 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import os
from math import floor from math import floor
from typing import Optional from typing import Optional
import platformdirs
import pygame import pygame
from src.image_handler import ImageHandler from src.image_handler import ImageHandler
@ -10,7 +12,7 @@ class Editor:
WIDTH: int = 800 WIDTH: int = 800
HEIGHT: int = 600 HEIGHT: int = 600
MAP_SIZE: int = 1024 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) ZOOMS: tuple[float] = (0.25, 0.5, 1, 2, 4)
CROSSHAIR_SIZE: int = 10 CROSSHAIR_SIZE: int = 10

View File

@ -2,10 +2,11 @@ from math import ceil, log10
import os.path import os.path
from PIL import Image from PIL import Image
import platformdirs
Image.MAX_IMAGE_PIXELS = 200000000 Image.MAX_IMAGE_PIXELS = 200000000
MAP_SIZE = 1024 MAP_SIZE = 1024
DEFAULT_PATH = os.path.join(platformdirs.user_cache_dir(appname="lycacraft-paths", appauthor="Lycacraft"), "maps")
def clamp(mn, value, mx): def clamp(mn, value, mx):
return max(mn, min(mx, value)) return max(mn, min(mx, value))
@ -15,12 +16,12 @@ def main():
# 2024-06-27_21.01.45_Lycacraft_minecraft~overworld_day.png # 2024-06-27_21.01.45_Lycacraft_minecraft~overworld_day.png
# 6144,10240 # 6144,10240
input_path = input("Input image: ") 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() == "": if output_path.strip() == "":
output_path = "/tmp/lycacraft_maps" output_path = DEFAULT_PATH
if not os.path.exists(output_path): if not os.path.exists(output_path):
os.mkdir(output_path) os.makedirs(output_path)
elif not os.path.isdir(output_path): elif not os.path.isdir(output_path):
print("Output path must be a directory") print("Output path must be a directory")
return return