From b2f92a8774943507343723625a72703403f4833c Mon Sep 17 00:00:00 2001 From: aomizu Date: Sat, 21 Jun 2025 09:40:34 +0900 Subject: [PATCH] added autodelete WDB option --- pkg/launcher/launcher.go | 17 +++++++++++++++++ pkg/ui/components.go | 11 +++++++++++ pkg/ui/popup.go | 3 ++- pkg/ui/variables.go | 1 + pkg/utils/prefs.go | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pkg/launcher/launcher.go b/pkg/launcher/launcher.go index 0831fc8..49de93b 100644 --- a/pkg/launcher/launcher.go +++ b/pkg/launcher/launcher.go @@ -19,6 +19,7 @@ import ( var EnableMetalHud = true // Default to enabled var CustomEnvVars = "" // Custom environment variables var EnableVanillaTweaks = false // Default to disabled +var AutoDeleteWdb = false // Default to disabled // Terminal state management var ( @@ -177,6 +178,22 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) { return } + // Auto-delete WDB directory if enabled + if AutoDeleteWdb { + wdbPath := filepath.Join(paths.TurtlewowPath, "WDB") + if utils.DirExists(wdbPath) { + debug.Printf("Auto-deleting WDB directory: %s", wdbPath) + if err := os.RemoveAll(wdbPath); err != nil { + debug.Printf("Warning: failed to auto-delete WDB directory: %v", err) + // Don't block the launch, just log the error + } else { + debug.Printf("Successfully auto-deleted WDB directory") + } + } else { + debug.Printf("WDB directory not found, nothing to delete") + } + } + // Since RosettaX87 service is already running, we can directly launch WoW debug.Println("RosettaX87 service is running. Proceeding to launch WoW.") diff --git a/pkg/ui/components.go b/pkg/ui/components.go index 021cc07..9cf5aae 100644 --- a/pkg/ui/components.go +++ b/pkg/ui/components.go @@ -49,6 +49,17 @@ func createOptionsComponents() { vanillaTweaksCheckbox.SetChecked(prefs.EnableVanillaTweaks) launcher.EnableVanillaTweaks = prefs.EnableVanillaTweaks + autoDeleteWdbCheckbox = widget.NewCheck("Auto-delete WDB directory on launch", func(checked bool) { + launcher.AutoDeleteWdb = checked + // Save to preferences + prefs, _ := utils.LoadPrefs() + prefs.AutoDeleteWdb = checked + utils.SavePrefs(prefs) + debug.Printf("Auto-delete WDB enabled: %v", launcher.AutoDeleteWdb) + }) + autoDeleteWdbCheckbox.SetChecked(prefs.AutoDeleteWdb) + launcher.AutoDeleteWdb = prefs.AutoDeleteWdb + // Create recommended settings button with help icon applyRecommendedSettingsButton = widget.NewButton("Apply recommended settings", func() { err := launcher.ApplyRecommendedSettings() diff --git a/pkg/ui/popup.go b/pkg/ui/popup.go index d94c24d..0c9b509 100644 --- a/pkg/ui/popup.go +++ b/pkg/ui/popup.go @@ -35,6 +35,7 @@ func showOptionsPopup() { metalHudCheckbox, showTerminalCheckbox, vanillaTweaksCheckbox, + autoDeleteWdbCheckbox, widget.NewSeparator(), container.NewBorder(nil, nil, recommendedSettingsLabel, container.NewHBox(applyRecommendedSettingsButton, recommendedSettingsHelpButton), nil), widget.NewSeparator(), @@ -74,7 +75,7 @@ func showOptionsPopup() { // Get the window size and calculate 2/3 size windowSize := currentWindow.Content().Size() popupWidth := windowSize.Width * 5 / 6 - popupHeight := windowSize.Height * 5 / 6 + popupHeight := windowSize.Height * 9 / 10 // Create a modal popup popup := widget.NewModalPopUp(popupContent, currentWindow.Canvas()) diff --git a/pkg/ui/variables.go b/pkg/ui/variables.go index 141f31e..75c2114 100644 --- a/pkg/ui/variables.go +++ b/pkg/ui/variables.go @@ -31,6 +31,7 @@ var ( metalHudCheckbox *widget.Check showTerminalCheckbox *widget.Check vanillaTweaksCheckbox *widget.Check + autoDeleteWdbCheckbox *widget.Check // Recommended settings button applyRecommendedSettingsButton *widget.Button diff --git a/pkg/utils/prefs.go b/pkg/utils/prefs.go index 5bd0f4b..9f53661 100644 --- a/pkg/utils/prefs.go +++ b/pkg/utils/prefs.go @@ -15,6 +15,7 @@ type UserPrefs struct { ShowTerminalNormally bool `json:"show_terminal_normally"` EnableVanillaTweaks bool `json:"enable_vanilla_tweaks"` RemapOptionAsAlt bool `json:"remap_option_as_alt"` + AutoDeleteWdb bool `json:"auto_delete_wdb"` } func getPrefsPath() (string, error) {