2017-07-19 22:44:43 +02:00
#!/usr/bin/env python
2018-06-05 01:58:40 +02:00
# -*- coding: utf-8 -*-
2024-01-10 08:03:16 +01:00
# cli.py
2017-07-19 22:44:43 +02:00
2024-01-10 08:03:16 +01:00
import argparse
import sys
2024-01-10 07:50:04 +01:00
from libtextureconverter . gui import main as launch_gui
2024-01-10 08:03:16 +01:00
from libtextureconverter . config import SUPPORTED_MINECRAFT_VERSION , working_dir , appname , home
from libtextureconverter . utils import handle_default_minecraft_texture , find_all_minecraft_resourcepacks
from libtextureconverter . common import convert_resource_packs
def main ( ) :
make_texture_pack = True
2024-11-28 20:55:48 +01:00
parser = argparse . ArgumentParser ( description = f " This is the official VoxeLibre Texture Converter. This will convert textures from Minecraft resource packs to a Luanti texture pack. Supported Minecraft version: { SUPPORTED_MINECRAFT_VERSION } (Java Edition) " )
2024-01-10 08:03:16 +01:00
parser . add_argument ( " -i " , " --input " , help = " Directory of Minecraft resource pack to convert " )
2024-11-28 20:55:48 +01:00
parser . add_argument ( " -o " , " --output " , default = working_dir , help = " Directory in which to put the resulting Luanti texture pack " )
2024-01-10 08:03:16 +01:00
parser . add_argument ( " -p " , " --pixel-size " , type = int , help = " Size (in pixels) of the original textures " )
parser . add_argument ( " -d " , " --dry-run " , action = " store_true " , help = " Pretend to convert textures without changing any files " )
parser . add_argument ( " -v " , " --verbose " , action = " store_true " , help = " Print out all copying actions " )
parser . add_argument ( " -def " , " --default " , action = " store_true " , help = " Use the default Minecraft texture pack " )
parser . add_argument ( " -a " , " --all " , action = " store_true " , help = " Convert all known Minecraft texturepacks " )
args = parser . parse_args ( )
2017-11-18 03:40:29 +01:00
2024-01-10 07:50:04 +01:00
if len ( sys . argv ) == 1 :
launch_gui ( )
else :
resource_packs = [ ]
2024-01-10 08:03:16 +01:00
if args . default :
resource_packs . append ( handle_default_minecraft_texture ( home , args . output ) )
elif args . all :
resource_packs . extend ( find_all_minecraft_resourcepacks ( ) )
elif args . input :
2024-01-10 07:50:04 +01:00
resource_packs . append ( args . input )
2017-07-28 14:20:50 +02:00
2024-01-10 08:03:16 +01:00
if not resource_packs :
print ( f " ERROR: No valid resource packs specified. Use ' { appname } -h ' for help. " )
sys . exit ( 2 )
2017-07-28 14:20:50 +02:00
2024-01-10 09:16:36 +01:00
convert_resource_packs ( resource_packs , args . output , args . pixel_size , args . dry_run , args . verbose , make_texture_pack )
2017-07-28 14:20:50 +02:00
2024-01-10 08:03:16 +01:00
if __name__ == " __main__ " :
main ( )