From 29d2e8e09c30a0da6241ed9e89964eab469794e2 Mon Sep 17 00:00:00 2001 From: aomizu Date: Thu, 29 May 2025 17:04:34 +0900 Subject: [PATCH] added field for environment variables --- FyneApp.toml | 2 +- main.go | 4 ++-- pkg/launcher/launcher.go | 16 ++++++++++++---- pkg/ui/ui.go | 20 ++++++++++++++++++++ pkg/utils/prefs.go | 1 + 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/FyneApp.toml b/FyneApp.toml index 41c5356..1896a61 100644 --- a/FyneApp.toml +++ b/FyneApp.toml @@ -2,5 +2,5 @@ Icon = "Icon.png" Name = "TurtleSilicon" ID = "com.tairasu.turtlesilicon" - Version = "1.0.6" + Version = "1.0.7" Build = 12 diff --git a/main.go b/main.go index 0ed935e..d9b0579 100644 --- a/main.go +++ b/main.go @@ -14,12 +14,12 @@ import ( "fyne.io/fyne/v2/widget" ) -const appVersion = "1.0.6" +const appVersion = "1.0.7" func main() { myApp := app.NewWithID("com.tairasu.turtlesilicon") myWindow := myApp.NewWindow("TurtleSilicon v" + appVersion) - myWindow.Resize(fyne.NewSize(650, 450)) + myWindow.Resize(fyne.NewSize(650, 500)) myWindow.SetFixedSize(true) // Check for updates diff --git a/pkg/launcher/launcher.go b/pkg/launcher/launcher.go index b3a33aa..0534113 100644 --- a/pkg/launcher/launcher.go +++ b/pkg/launcher/launcher.go @@ -5,13 +5,15 @@ import ( "log" "path/filepath" - "fyne.io/fyne/v2" - "fyne.io/fyne/v2/dialog" "turtlesilicon/pkg/paths" // Corrected import path "turtlesilicon/pkg/utils" // Corrected import path + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/dialog" ) var EnableMetalHud = true // Default to enabled +var CustomEnvVars = "" // Custom environment variables func LaunchGame(myWindow fyne.Window) { log.Println("Launch Game button clicked") @@ -81,9 +83,15 @@ func LaunchGame(myWindow fyne.Window) { mtlHudValue = "1" } - shellCmd := fmt.Sprintf(`cd %s && WINEDLLOVERRIDES="d3d9=n,b" MTL_HUD_ENABLED=%s %s %s %s`, + // Prepare environment variables + envVars := fmt.Sprintf(`WINEDLLOVERRIDES="d3d9=n,b" MTL_HUD_ENABLED=%s`, mtlHudValue) + if CustomEnvVars != "" { + envVars = CustomEnvVars + " " + envVars + } + + shellCmd := fmt.Sprintf(`cd %s && %s %s %s %s`, utils.QuotePathForShell(paths.TurtlewowPath), - mtlHudValue, + envVars, utils.QuotePathForShell(rosettaExecutable), utils.QuotePathForShell(wineloader2Path), utils.QuotePathForShell(wowExePath)) diff --git a/pkg/ui/ui.go b/pkg/ui/ui.go index d41714f..5e62639 100644 --- a/pkg/ui/ui.go +++ b/pkg/ui/ui.go @@ -30,6 +30,7 @@ var ( unpatchTurtleWoWButton *widget.Button unpatchCrossOverButton *widget.Button metalHudCheckbox *widget.Check + envVarsEntry *widget.Entry ) func UpdateAllStatuses() { @@ -182,6 +183,23 @@ func CreateUI(myWindow fyne.Window) fyne.CanvasObject { }) metalHudCheckbox.SetChecked(launcher.EnableMetalHud) + // Load environment variables from preferences + if prefs.EnvironmentVariables != "" { + launcher.CustomEnvVars = prefs.EnvironmentVariables + } + + envVarsEntry = widget.NewEntry() + envVarsEntry.SetPlaceHolder(`Custom environment variables`) + envVarsEntry.SetText(launcher.CustomEnvVars) + envVarsEntry.OnChanged = func(text string) { + launcher.CustomEnvVars = text + // Save to preferences + prefs, _ := utils.LoadPrefs() + prefs.EnvironmentVariables = text + utils.SavePrefs(prefs) + log.Printf("Environment variables updated: %v", launcher.CustomEnvVars) + } + patchTurtleWoWButton = widget.NewButton("Patch TurtleWoW", func() { patching.PatchTurtleWoW(myWindow, UpdateAllStatuses) }) @@ -236,6 +254,8 @@ func CreateUI(myWindow fyne.Window) fyne.CanvasObject { pathSelectionForm, patchOperationsLayout, metalHudCheckbox, + widget.NewLabel("Environment Variables:"), + envVarsEntry, container.NewPadded(launchButton), widget.NewSeparator(), githubContainer, diff --git a/pkg/utils/prefs.go b/pkg/utils/prefs.go index d5d11a6..64be7f4 100644 --- a/pkg/utils/prefs.go +++ b/pkg/utils/prefs.go @@ -10,6 +10,7 @@ type UserPrefs struct { SuppressedUpdateVersion string `json:"suppressed_update_version"` TurtleWoWPath string `json:"turtlewow_path"` CrossOverPath string `json:"crossover_path"` + EnvironmentVariables string `json:"environment_variables"` } func getPrefsPath() (string, error) {