diff --git a/loader-install.sh b/loader-install.sh index 3205084..29a39c9 100644 --- a/loader-install.sh +++ b/loader-install.sh @@ -1,7 +1,6 @@ #!/bin/bash -install_quilt() -{ +install_quilt() { mkdir installer cd installer curl -L -o quilt-installer.jar https://quiltmc.org/api/v1/download-latest-installer/java-universal @@ -13,5 +12,11 @@ install_quilt() echo "Quilt installation is complete in $INSTALL_DIR!" } +install_loader() { + if [ "$1" == "quilt" ]; then + install_quilt + fi +} - +# Aufruf der Funktion mit Parameter "quilt" +install_loader $1 diff --git a/main_GUI.py b/main_GUI.py index e475e01..30c25a7 100644 --- a/main_GUI.py +++ b/main_GUI.py @@ -36,16 +36,20 @@ def switch_setting(switch_var): config["settings"]["developer-mode"] = str(switch_var.get()) with open('config.ini', 'w') as configfile: - config.write(configfile) -button1 = ctk.CTkButton(tabview.tab("Manage Profiles"), text="Button 1", command=lambda:subprocess.Popen(["./loader-install.sh"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)) +button1 = ctk.CTkButton(tabview.tab("Manage Profiles"), text="Install Quilt", command=lambda:subprocess.Popen(["./loader-install.sh", "quilt"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)) button1.grid(row=1, column=0, sticky="nsew") -switch_var = ctk.IntVar(value=0) +try: + switch_var = ctk.IntVar(value=int(config["settings"]["developer-mode"])) +except: + switch_var = ctk.IntVar(value=int(config["settings"]["developer-mode"][1:-1])) + switch = ctk.CTkSwitch(tabview.tab("Settings"), text="Developer Mode", variable=switch_var, command=lambda:switch_setting(switch_var)) -switch.pack(padx=20) +switch.grid(row=0, column=0, padx=20, pady=10, sticky="nsew") + diff --git a/prepare.py b/prepare.py index ed2f1e3..7d4c21e 100644 --- a/prepare.py +++ b/prepare.py @@ -6,6 +6,12 @@ ctk = None +def create_config(trigger): + if trigger == True: + with open("config.ini", "w") as config: + config.write("[settings]\ndeveloper-mode = '0'") + + def ensure_customtkinter(): """Attempts to import customtkinter and installs it if necessary.""" global ctk @@ -81,15 +87,16 @@ def install_packages(packages, log_text_widget, progress_bar, install_window): progress_bar.set(1.0) show_finish_button(install_window) -def finish(install_window=None): +def finish(install_window=None, trigger=False): try: install_window.destroy() finally: + create_config(trigger) import main_GUI sys.exit(0) def show_finish_button(install_window): - finish_button = ctk.CTkButton(install_window, text="Finish", command=lambda: finish(install_window)) + finish_button = ctk.CTkButton(install_window, text="Finish", command=lambda: finish(install_window, True)) finish_button.grid(row=3, column=0, columnspan=2, pady=10) def start_installation(install_window): @@ -152,7 +159,7 @@ def show_installation_window(): install_window.mainloop() else: print("No packages need to be installed.") - finish() + finish(False) show_installation_window()