1
0
Fork 0

Made minetest directory handling, platform indiependent

patch_skins
James David Clarke 2024-01-10 08:36:48 +00:00 committed by the-real-herowl
parent ddfbd331c9
commit 0da8428eef
3 changed files with 24 additions and 3 deletions

View File

@ -1,9 +1,30 @@
import os import os
import platform
def get_minetest_directory():
system = platform.system()
# Windows
if system == 'Windows':
return os.environ.get('MINETEST_USER_PATH', os.path.expandvars('%APPDATA%\\Minetest'))
# Linux
elif system == 'Linux':
return os.environ.get('MINETEST_USER_PATH', os.path.expanduser('~/.minetest'))
# macOS
elif system == 'Darwin': # Darwin is the system name for macOS
return os.environ.get('MINETEST_USER_PATH', os.path.expanduser('~/Library/Application Support/minetest'))
# Unsupported system
else:
return None
# Constants # Constants
SUPPORTED_MINECRAFT_VERSION = "1.20" SUPPORTED_MINECRAFT_VERSION = "1.20"
# Helper vars # Helper vars
home = os.environ["HOME"] home = os.environ["HOME"]
mineclone2_path = home + "/.minetest/games/mineclone2" mineclone2_path = os.path.join(get_minetest_directory(),"games","mineclone2")
working_dir = os.getcwd() working_dir = os.getcwd()
appname = "Texture_Converter.py" appname = "Texture_Converter.py"

View File

@ -130,7 +130,7 @@ class TextureConverterGUI:
pixelsize = None pixelsize = None
dry_run = False dry_run = False
verbose = False verbose = False
output_dir = os.path.join(home, ".minetest", "textures") output_dir = os.path.join(get_minetest_directory(), "textures")
make_texture_pack = True make_texture_pack = True
# Determine the resource packs to convert based on the option # Determine the resource packs to convert based on the option

View File

@ -10,7 +10,7 @@ import zipfile
from .config import SUPPORTED_MINECRAFT_VERSION, home from .config import SUPPORTED_MINECRAFT_VERSION, home
from PIL import Image from PIL import Image
from collections import Counter from collections import Counter
import platform
def detect_pixel_size(directory): def detect_pixel_size(directory):
sizes = [] sizes = []