mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 01:21:05 +01:00
Made minetest directory handling, platform indiependent
This commit is contained in:
parent
ddfbd331c9
commit
0da8428eef
3 changed files with 24 additions and 3 deletions
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 = []
|
||||||
|
|
Loading…
Reference in a new issue