GUI Now functional

This commit is contained in:
James David Clarke 2024-01-10 07:18:29 +00:00 committed by the-real-herowl
parent 16cdc9fd12
commit 47b6bd5539
2 changed files with 28 additions and 15 deletions

@ -5,7 +5,6 @@ from collections import Counter
from libtextureconverter.utils import detect_pixel_size, target_dir, colorize, colorize_alpha, handle_default_minecraft_texture, find_all_minecraft_resourcepacks from libtextureconverter.utils import detect_pixel_size, target_dir, colorize, colorize_alpha, handle_default_minecraft_texture, find_all_minecraft_resourcepacks
from libtextureconverter.convert import convert_textures from libtextureconverter.convert import convert_textures
from libtextureconverter.config import SUPPORTED_MINECRAFT_VERSION, working_dir, mineclone2_path, appname, home from libtextureconverter.config import SUPPORTED_MINECRAFT_VERSION, working_dir, mineclone2_path, appname, home
from libtextureconverter.gui import main as launch_gui
def convert_resource_packs(resource_packs, output_dir, PXSIZE, dry_run, verbose, make_texture_pack): def convert_resource_packs(resource_packs, output_dir, PXSIZE, dry_run, verbose, make_texture_pack):
for base_dir in resource_packs: for base_dir in resource_packs:

@ -1,7 +1,9 @@
import tkinter as tk import tkinter as tk
from tkinter import filedialog, messagebox, ttk, font from tkinter import filedialog, messagebox, ttk, font
import time from libtextureconverter.utils import handle_default_minecraft_texture, find_all_minecraft_resourcepacks
import threading from libtextureconverter.config import home
from libtextureconverter.common import convert_resource_packs
import time, os, threading
class TextureConverterGUI: class TextureConverterGUI:
def __init__(self, root): def __init__(self, root):
@ -111,24 +113,36 @@ class TextureConverterGUI:
self.cancel_button.config(state=tk.NORMAL) self.cancel_button.config(state=tk.NORMAL)
def perform_conversion(self, option): def perform_conversion(self, option):
# Example names, replace with actual texture pack names after conversion # Set default values for pixelsize, dry_run, and verbose
texture_pack_names = ["Texture Pack 1", "Texture Pack 2", "Texture Pack 3"] pixelsize = None
# Simulate a time-consuming process dry_run = False
verbose = False
# Perform the selected action output_dir = os.path.join(home, ".minetest", "textures")
make_texture_pack = True
# Determine the resource packs to convert based on the option
if option == 'all': if option == 'all':
self.convert_all() resource_packs = find_all_minecraft_resourcepacks()
elif option == 'default': elif option == 'default':
self.convert_default() resource_packs = [handle_default_minecraft_texture(home, output_dir)]
elif option == 'other': elif option == 'other':
self.open_folder_dialog() folder_selected = filedialog.askdirectory()
if folder_selected:
resource_packs = [folder_selected]
else:
# User canceled the folder selection
self.loading_label.pack_forget()
self.ok_button.config(state=tk.NORMAL)
return
# Remove the loading message and update the conversion status # Convert resource packs
convert_resource_packs(resource_packs, output_dir, pixelsize, dry_run, verbose, make_texture_pack)
# Update the GUI after conversion
self.loading_label.pack_forget() self.loading_label.pack_forget()
messagebox.showinfo("Conversion Complete", f"Resource Packs '{', '.join(texture_pack_names)}' converted.")
# Re-enable the OK button after the conversion is done
self.ok_button.config(state=tk.NORMAL) self.ok_button.config(state=tk.NORMAL)
messagebox.showinfo("Conversion Complete", f"Resource Packs '{', '.join(resource_packs)}' converted.")
def convert_all(self): def convert_all(self):
# Simulate a conversion process # Simulate a conversion process