2017-07-19 23:44:43 +03:00
#!/usr/bin/env python
2018-06-05 02:58:40 +03:00
# -*- coding: utf-8 -*-
2024-01-10 10:03:16 +03:00
# cli.py
2017-07-19 23:44:43 +03:00
2024-01-10 10:03:16 +03:00
import argparse
import sys
2024-01-10 09:50:04 +03:00
from libtextureconverter . gui import main as launch_gui
2024-01-10 10:03:16 +03: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-05-02 07:04:41 +03:00
parser = argparse . ArgumentParser ( description = f " This is the official VoxeLibre Texture Converter. This will convert textures from Minecraft resource packs to a Minetest texture pack. Supported Minecraft version: { SUPPORTED_MINECRAFT_VERSION } (Java Edition) " )
2024-01-10 10:03:16 +03:00
parser . add_argument ( " -i " , " --input " , help = " Directory of Minecraft resource pack to convert " )
parser . add_argument ( " -o " , " --output " , default = working_dir , help = " Directory in which to put the resulting Minetest texture pack " )
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 05:40:29 +03:00
2024-01-10 09:50:04 +03:00
if len ( sys . argv ) == 1 :
launch_gui ( )
else :
resource_packs = [ ]
2024-01-10 10:03:16 +03: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 09:50:04 +03:00
resource_packs . append ( args . input )
2017-07-28 15:20:50 +03:00
2024-01-10 10:03:16 +03:00
if not resource_packs :
print ( f " ERROR: No valid resource packs specified. Use ' { appname } -h ' for help. " )
sys . exit ( 2 )
2017-07-28 15:20:50 +03:00
2024-01-10 11:16:36 +03:00
convert_resource_packs ( resource_packs , args . output , args . pixel_size , args . dry_run , args . verbose , make_texture_pack )
2017-07-28 15:20:50 +03:00
2024-01-10 10:03:16 +03:00
if __name__ == " __main__ " :
main ( )