@@ -8,9 +8,9 @@ import (
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"turtlesilicon/pkg/debug"
|
||||
"turtlesilicon/pkg/paths" // Corrected import path
|
||||
"turtlesilicon/pkg/utils" // Corrected import path
|
||||
"epochsilicon/pkg/debug"
|
||||
"epochsilicon/pkg/paths" // Corrected import path
|
||||
"epochsilicon/pkg/utils" // Corrected import path
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
@@ -109,11 +109,11 @@ func LaunchGame(myWindow fyne.Window) {
|
||||
dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it in the patcher."), myWindow)
|
||||
return
|
||||
}
|
||||
if paths.TurtlewowPath == "" {
|
||||
dialog.ShowError(fmt.Errorf("TurtleWoW path not set. Please set it in the patcher."), myWindow)
|
||||
if paths.EpochPath == "" {
|
||||
dialog.ShowError(fmt.Errorf("Epoch path not set. Please set it in the patcher."), myWindow)
|
||||
return
|
||||
}
|
||||
if !paths.PatchesAppliedTurtleWoW || !paths.PatchesAppliedCrossOver {
|
||||
if !paths.PatchesAppliedEpoch || !paths.PatchesAppliedCrossOver {
|
||||
confirmed := false
|
||||
dialog.ShowConfirm("Warning", "Not all patches confirmed applied. Continue with launch?", func(c bool) {
|
||||
confirmed = c
|
||||
@@ -132,28 +132,9 @@ func LaunchGame(myWindow fyne.Window) {
|
||||
}
|
||||
gameMutex.Unlock()
|
||||
|
||||
debug.Println("Preparing to launch TurtleSilicon...")
|
||||
debug.Println("Preparing to launch EpochSilicon...")
|
||||
|
||||
// Determine which WoW executable to use based on vanilla-tweaks preference
|
||||
var wowExePath string
|
||||
if EnableVanillaTweaks {
|
||||
if !CheckForWoWTweakedExecutable() {
|
||||
// Show dialog asking if user wants us to apply vanilla-tweaks
|
||||
HandleVanillaTweaksRequest(myWindow, func() {
|
||||
// After successful patching, continue with launch using the tweaked executable
|
||||
wowTweakedExePath := GetWoWTweakedExecutablePath()
|
||||
if wowTweakedExePath != "" {
|
||||
continueLaunch(myWindow, wowTweakedExePath)
|
||||
} else {
|
||||
dialog.ShowError(fmt.Errorf("failed to find WoW-tweaked.exe after patching"), myWindow)
|
||||
}
|
||||
})
|
||||
return // Exit early since dialog will handle the continuation
|
||||
}
|
||||
wowExePath = GetWoWTweakedExecutablePath()
|
||||
} else {
|
||||
wowExePath = filepath.Join(paths.TurtlewowPath, "WoW.exe")
|
||||
}
|
||||
wowExePath := filepath.Join(paths.EpochPath, "Project-Epoch.exe")
|
||||
|
||||
// Continue with normal launch process
|
||||
continueLaunch(myWindow, wowExePath)
|
||||
@@ -161,12 +142,12 @@ func LaunchGame(myWindow fyne.Window) {
|
||||
|
||||
// continueLaunch continues the game launch process with the specified executable
|
||||
func continueLaunch(myWindow fyne.Window, wowExePath string) {
|
||||
rosettaInTurtlePath := filepath.Join(paths.TurtlewowPath, "rosettax87")
|
||||
rosettaExecutable := filepath.Join(rosettaInTurtlePath, "rosettax87")
|
||||
rosettaInEpochPath := filepath.Join(paths.EpochPath, "rosettax87")
|
||||
rosettaExecutable := filepath.Join(rosettaInEpochPath, "rosettax87")
|
||||
wineloader2Path := filepath.Join(paths.CrossoverPath, "Contents", "SharedSupport", "CrossOver", "CrossOver-Hosted Application", "wineloader2")
|
||||
|
||||
if !utils.PathExists(rosettaExecutable) {
|
||||
dialog.ShowError(fmt.Errorf("rosetta executable not found at %s. Ensure TurtleWoW patching was successful", rosettaExecutable), myWindow)
|
||||
dialog.ShowError(fmt.Errorf("rosetta executable not found at %s. Ensure Epoch patching was successful", rosettaExecutable), myWindow)
|
||||
return
|
||||
}
|
||||
if !utils.PathExists(wineloader2Path) {
|
||||
@@ -174,13 +155,13 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
|
||||
return
|
||||
}
|
||||
if !utils.PathExists(wowExePath) {
|
||||
dialog.ShowError(fmt.Errorf("WoW executable not found at %s. Ensure your TurtleWoW directory is correct", wowExePath), myWindow)
|
||||
dialog.ShowError(fmt.Errorf("WoW executable not found at %s. Ensure your Epoch directory is correct", wowExePath), myWindow)
|
||||
return
|
||||
}
|
||||
|
||||
// Auto-delete WDB directory if enabled
|
||||
if AutoDeleteWdb {
|
||||
wdbPath := filepath.Join(paths.TurtlewowPath, "WDB")
|
||||
wdbPath := filepath.Join(paths.EpochPath, "WDB")
|
||||
if utils.DirExists(wdbPath) {
|
||||
debug.Printf("Auto-deleting WDB directory: %s", wdbPath)
|
||||
if err := os.RemoveAll(wdbPath); err != nil {
|
||||
@@ -197,8 +178,8 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
|
||||
// Since RosettaX87 service is already running, we can directly launch WoW
|
||||
debug.Println("RosettaX87 service is running. Proceeding to launch WoW.")
|
||||
|
||||
if paths.CrossoverPath == "" || paths.TurtlewowPath == "" {
|
||||
dialog.ShowError(fmt.Errorf("CrossOver path or TurtleWoW path is not set. Cannot launch WoW."), myWindow)
|
||||
if paths.CrossoverPath == "" || paths.EpochPath == "" {
|
||||
dialog.ShowError(fmt.Errorf("CrossOver path or Epoch path is not set. Cannot launch WoW."), myWindow)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -214,7 +195,7 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
|
||||
}
|
||||
|
||||
shellCmd := fmt.Sprintf(`cd %s && %s %s %s %s`,
|
||||
utils.QuotePathForShell(paths.TurtlewowPath),
|
||||
utils.QuotePathForShell(paths.EpochPath),
|
||||
envVars,
|
||||
utils.QuotePathForShell(rosettaExecutable),
|
||||
utils.QuotePathForShell(wineloader2Path),
|
||||
|
@@ -7,8 +7,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"turtlesilicon/pkg/debug"
|
||||
"turtlesilicon/pkg/paths"
|
||||
"epochsilicon/pkg/debug"
|
||||
"epochsilicon/pkg/paths"
|
||||
)
|
||||
|
||||
// RecommendedSettings contains the recommended graphics settings for optimal performance
|
||||
@@ -24,12 +24,12 @@ var RecommendedSettings = map[string]string{
|
||||
// CheckRecommendedSettings reads the Config.wtf file and checks if all recommended settings are applied
|
||||
// Returns true if all settings are correctly applied, false otherwise
|
||||
func CheckRecommendedSettings() bool {
|
||||
if paths.TurtlewowPath == "" {
|
||||
debug.Printf("TurtleWoW path not set, cannot check Config.wtf")
|
||||
if paths.EpochPath == "" {
|
||||
debug.Printf("Epoch path not set, cannot check Config.wtf")
|
||||
return false
|
||||
}
|
||||
|
||||
configPath := filepath.Join(paths.TurtlewowPath, "WTF", "Config.wtf")
|
||||
configPath := filepath.Join(paths.EpochPath, "WTF", "Config.wtf")
|
||||
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
debug.Printf("Config.wtf not found at %s", configPath)
|
||||
@@ -73,11 +73,11 @@ func isSettingCorrect(configText, setting, expectedValue string) bool {
|
||||
|
||||
// ApplyRecommendedSettings applies all recommended graphics settings to Config.wtf
|
||||
func ApplyRecommendedSettings() error {
|
||||
if paths.TurtlewowPath == "" {
|
||||
return fmt.Errorf("TurtleWoW path not set")
|
||||
if paths.EpochPath == "" {
|
||||
return fmt.Errorf("Epoch path not set")
|
||||
}
|
||||
|
||||
configPath := filepath.Join(paths.TurtlewowPath, "WTF", "Config.wtf")
|
||||
configPath := filepath.Join(paths.EpochPath, "WTF", "Config.wtf")
|
||||
|
||||
// Create WTF directory if it doesn't exist
|
||||
wtfDir := filepath.Dir(configPath)
|
||||
|
@@ -1,205 +0,0 @@
|
||||
package launcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"turtlesilicon/pkg/debug"
|
||||
"turtlesilicon/pkg/paths"
|
||||
"turtlesilicon/pkg/utils"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
)
|
||||
|
||||
// ApplyVanillaTweaks applies vanilla-tweaks to WoW.exe to create WoW-tweaked.exe
|
||||
func ApplyVanillaTweaks(myWindow fyne.Window) error {
|
||||
if paths.TurtlewowPath == "" {
|
||||
return fmt.Errorf("TurtleWoW path not set")
|
||||
}
|
||||
if paths.CrossoverPath == "" {
|
||||
return fmt.Errorf("CrossOver path not set")
|
||||
}
|
||||
|
||||
// Get the current working directory (where the app executable is located)
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get executable path: %v", err)
|
||||
}
|
||||
appDir := filepath.Dir(execPath)
|
||||
|
||||
// Check if we're in development mode
|
||||
vanillaTweaksPath := filepath.Join(appDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
if !utils.PathExists(vanillaTweaksPath) {
|
||||
// Try relative path from current working directory (for development)
|
||||
workingDir, _ := os.Getwd()
|
||||
vanillaTweaksPath = filepath.Join(workingDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
if !utils.PathExists(vanillaTweaksPath) {
|
||||
return fmt.Errorf("vanilla-tweaks.exe not found")
|
||||
}
|
||||
}
|
||||
|
||||
wowExePath := filepath.Join(paths.TurtlewowPath, "WoW.exe")
|
||||
wineloader2Path := filepath.Join(paths.CrossoverPath, "Contents", "SharedSupport", "CrossOver", "CrossOver-Hosted Application", "wineloader2")
|
||||
|
||||
if !utils.PathExists(wowExePath) {
|
||||
return fmt.Errorf("WoW.exe not found at %s", wowExePath)
|
||||
}
|
||||
if !utils.PathExists(wineloader2Path) {
|
||||
return fmt.Errorf("wineloader2 not found at %s", wineloader2Path)
|
||||
}
|
||||
|
||||
// First, copy vanilla-tweaks.exe to the TurtleWoW directory temporarily
|
||||
tempVanillaTweaksPath := filepath.Join(paths.TurtlewowPath, "vanilla-tweaks.exe")
|
||||
|
||||
// Copy vanilla-tweaks.exe to TurtleWoW directory
|
||||
debug.Printf("Copying vanilla-tweaks.exe from %s to %s", vanillaTweaksPath, tempVanillaTweaksPath)
|
||||
sourceFile, err := os.Open(vanillaTweaksPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open vanilla-tweaks.exe: %v", err)
|
||||
}
|
||||
defer sourceFile.Close()
|
||||
|
||||
destFile, err := os.Create(tempVanillaTweaksPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create temporary vanilla-tweaks.exe: %v", err)
|
||||
}
|
||||
defer destFile.Close()
|
||||
|
||||
_, err = destFile.ReadFrom(sourceFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to copy vanilla-tweaks.exe: %v", err)
|
||||
}
|
||||
|
||||
// Ensure the copied file is executable
|
||||
if err := os.Chmod(tempVanillaTweaksPath, 0755); err != nil {
|
||||
debug.Printf("Warning: failed to set executable permission on vanilla-tweaks.exe: %v", err)
|
||||
}
|
||||
|
||||
// Build the command to apply vanilla-tweaks using the correct format:
|
||||
// cd "path" && "wineloader2" ./vanilla-tweaks.exe --no-frilldistance -no-farclip ./WoW.exe
|
||||
shellCmd := fmt.Sprintf(`cd %s && %s ./vanilla-tweaks.exe --no-frilldistance --no-farclip ./WoW.exe`,
|
||||
utils.QuotePathForShell(paths.TurtlewowPath),
|
||||
utils.QuotePathForShell(wineloader2Path))
|
||||
|
||||
debug.Printf("Applying vanilla-tweaks with command: %s", shellCmd)
|
||||
|
||||
// Execute the command
|
||||
cmd := exec.Command("sh", "-c", shellCmd)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
||||
debug.Printf("vanilla-tweaks command output: %s", string(output))
|
||||
|
||||
// Clean up the temporary vanilla-tweaks.exe file
|
||||
if cleanupErr := os.Remove(tempVanillaTweaksPath); cleanupErr != nil {
|
||||
debug.Printf("Warning: failed to clean up temporary vanilla-tweaks.exe: %v", cleanupErr)
|
||||
}
|
||||
|
||||
// Always check if the output file was created, regardless of exit code
|
||||
// Some Wine programs report error exit codes even when they succeed
|
||||
foundPath := GetWoWTweakedExecutablePath()
|
||||
if foundPath == "" {
|
||||
// Only report error if no output file was created
|
||||
if err != nil {
|
||||
debug.Printf("vanilla-tweaks command failed: %v", err)
|
||||
return fmt.Errorf("failed to apply vanilla-tweaks: %v\nOutput: %s", err, string(output))
|
||||
} else {
|
||||
return fmt.Errorf("vanilla-tweaks completed but WoW-tweaked.exe was not created\nOutput: %s", string(output))
|
||||
}
|
||||
}
|
||||
|
||||
// If we found the file but there was an error code, log it as a warning
|
||||
if err != nil {
|
||||
debug.Printf("vanilla-tweaks reported error but output file was created: %v", err)
|
||||
}
|
||||
|
||||
debug.Println("vanilla-tweaks applied successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckForVanillaTweaksExecutable checks if vanilla-tweaks.exe exists and is accessible
|
||||
func CheckForVanillaTweaksExecutable() bool {
|
||||
// Get the current working directory (where the app executable is located)
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
appDir := filepath.Dir(execPath)
|
||||
|
||||
// Check if we're in development mode (running from VSCode)
|
||||
vanillaTweaksPath := filepath.Join(appDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
if utils.PathExists(vanillaTweaksPath) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Try relative path from current working directory (for development)
|
||||
workingDir, _ := os.Getwd()
|
||||
vanillaTweaksPath = filepath.Join(workingDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
return utils.PathExists(vanillaTweaksPath)
|
||||
}
|
||||
|
||||
// GetVanillaTweaksExecutablePath returns the path to vanilla-tweaks.exe if it exists
|
||||
func GetVanillaTweaksExecutablePath() (string, error) {
|
||||
// Get the current working directory (where the app executable is located)
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get executable path: %v", err)
|
||||
}
|
||||
appDir := filepath.Dir(execPath)
|
||||
|
||||
// Check if we're in development mode (running from VSCode)
|
||||
vanillaTweaksPath := filepath.Join(appDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
if utils.PathExists(vanillaTweaksPath) {
|
||||
return vanillaTweaksPath, nil
|
||||
}
|
||||
|
||||
// Try relative path from current working directory (for development)
|
||||
workingDir, _ := os.Getwd()
|
||||
vanillaTweaksPath = filepath.Join(workingDir, "winerosetta", "vanilla-tweaks.exe")
|
||||
if utils.PathExists(vanillaTweaksPath) {
|
||||
return vanillaTweaksPath, nil
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("vanilla-tweaks.exe not found")
|
||||
}
|
||||
|
||||
// CheckForWoWTweakedExecutable checks if WoW_tweaked.exe exists in the TurtleWoW directory
|
||||
func CheckForWoWTweakedExecutable() bool {
|
||||
if paths.TurtlewowPath == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
testPath := filepath.Join(paths.TurtlewowPath, "WoW_tweaked.exe")
|
||||
return utils.PathExists(testPath)
|
||||
}
|
||||
|
||||
// GetWoWTweakedExecutablePath returns the path to the WoW_tweaked.exe file if it exists
|
||||
func GetWoWTweakedExecutablePath() string {
|
||||
if paths.TurtlewowPath == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
testPath := filepath.Join(paths.TurtlewowPath, "WoW_tweaked.exe")
|
||||
if utils.PathExists(testPath) {
|
||||
return testPath
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// HandleVanillaTweaksRequest handles the case when vanilla-tweaks is enabled but WoW-tweaked.exe doesn't exist
|
||||
func HandleVanillaTweaksRequest(myWindow fyne.Window, callback func()) {
|
||||
dialog.ShowConfirm("Vanilla-tweaks not found",
|
||||
"WoW-tweaked.exe was not found in your TurtleWoW directory.\n\nWould you like TurtleSilicon to automatically apply vanilla-tweaks for you?",
|
||||
func(confirmed bool) {
|
||||
if confirmed {
|
||||
if err := ApplyVanillaTweaks(myWindow); err != nil {
|
||||
dialog.ShowError(fmt.Errorf("failed to apply vanilla-tweaks: %v", err), myWindow)
|
||||
return
|
||||
}
|
||||
// After successful patching, execute the callback
|
||||
callback()
|
||||
}
|
||||
}, myWindow)
|
||||
}
|
Reference in New Issue
Block a user