added field for environment variables

This commit is contained in:
aomizu
2025-05-29 17:04:34 +09:00
parent 096855f74b
commit 29d2e8e09c
5 changed files with 36 additions and 7 deletions

View File

@@ -2,5 +2,5 @@
Icon = "Icon.png"
Name = "TurtleSilicon"
ID = "com.tairasu.turtlesilicon"
Version = "1.0.6"
Version = "1.0.7"
Build = 12

View File

@@ -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

View File

@@ -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))

View File

@@ -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,

View File

@@ -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) {