import os import tkinter as tk from tkinter import filedialog import configparser import Backend # Initialize a configparser object for managing the configuration file config = configparser.ConfigParser() config_file_path = 'config.ini' # Path to the configuration file def select_prism_instance_path(): global prism_instance_path_entry directory = filedialog.askdirectory() prism_instance_path_entry.delete(0, tk.END) prism_instance_path_entry.insert(0, directory) # Store the selected path in the configuration file config['PRISM'] = {'InstancePath': directory} with open(config_file_path, 'w') as configfile: config.write(configfile) def main(): global prism_instance_path_entry instance_name = "Familycraft Season 7" prism_command = "prismlauncher" # Default paths based on OS if os.name == 'nt': prism_command = os.getenv('LOCALAPPDATA') + "/Programs/PrismLauncher/prismlauncher.exe" default_prism_instance_path = os.getenv("APPDATA") + "/PrismLauncher/instances" else: prism_command = "prismlauncher" # Update with the correct path for Linux/Mac default_prism_instance_path = os.getenv("HOME") + "/.local/share/PrismLauncher/instances" # Load stored Prism instance path from the configuration file if os.path.exists(config_file_path): config.read(config_file_path) if 'PRISM' in config and 'InstancePath' in config['PRISM']: stored_prism_instance_path = config['PRISM']['InstancePath'] else: stored_prism_instance_path = default_prism_instance_path else: stored_prism_instance_path = default_prism_instance_path # GUI for selecting Prism instance path root = tk.Tk() root.title("Select Prism Instance Path") # Label for instructions label = tk.Label(root, text="Select Prism instance path:") label.pack(pady=10) # Entry widget for Prism instance path prism_instance_path_entry = tk.Entry(root, width=50) prism_instance_path_entry.pack(pady=5) # If a stored Prism instance path exists, pre-fill the entry widget if stored_prism_instance_path: prism_instance_path_entry.insert(0, stored_prism_instance_path) # Button to select directory select_button = tk.Button(root, text="Browse...", command=select_prism_instance_path) select_button.pack(pady=5) # Function to proceed with installation def start_installation(): prism_instance_path = prism_instance_path_entry.get() root.destroy() # Close the GUI window Backend.perform_installation(instance_name, prism_command, prism_instance_path) # Button to start installation install_button = tk.Button(root, text="Launch Minecraft", command=start_installation) install_button.pack(pady=10) root.mainloop() if __name__ == "__main__": main()