fix launching

This commit is contained in:
2025-07-10 15:38:22 -07:00
parent f916ba0059
commit d21e48c1c9
3 changed files with 60 additions and 19 deletions

View File

@ -13,6 +13,7 @@ import (
type Config struct {
WowDir string
LaunchCmd string
WinePrefix string
EnableLauncher bool
}
@ -46,15 +47,18 @@ func setupConfig(rerun bool) (*Config, error) {
}
newConfig.WowDir = strings.TrimSpace(s)
fmt.Println()
p, err := promptYesNo(fmt.Sprintf("Do you want to use epochcli to launch Wow? Select No if you plan on using a launcher tool like Lutris (y/n): "))
if err != nil {
return nil, err
}
fmt.Println()
if p {
newConfig.EnableLauncher = true
newConfig.LaunchCmd = path.Join(newConfig.WowDir, "Project-Epoch.exe")
if runtime.GOOS == "windows" {
newConfig.LaunchCmd = path.Join(newConfig.WowDir, "Project-Epoch.exe")
exePath, err := os.Executable()
if err != nil {
return nil, fmt.Errorf("unable to create desktop shortcut: %v", err)
@ -64,18 +68,22 @@ func setupConfig(rerun bool) (*Config, error) {
return nil, fmt.Errorf("unable to create desktop shortcut: %v", err)
}
} else {
fmt.Println("Enter your launch command to start Wow below. If you would rather configure this later in the configuration file, just press Enter")
fmt.Printf("> ")
_, err = fmt.Scanf("%s", &s)
s, err = input("Enter your wine prefix. Leave blank if you do not need to set WINEPREFIX")
if err != nil {
return nil, fmt.Errorf("unable to read input: %v", err)
return nil, err
}
s = strings.TrimSpace(s)
fmt.Println()
if s != "" {
newConfig.LaunchCmd = s
newConfig.WinePrefix = s
newConfig.LaunchCmd = "wine " + newConfig.LaunchCmd
fmt.Println("Your launch command has been set to the following:")
if s == "" {
fmt.Printf("wine %s\n", newConfig.LaunchCmd)
} else {
fmt.Printf("WINEPREFIX=%s wine %s\n", newConfig.WinePrefix, newConfig.LaunchCmd)
}
fmt.Printf("Modify the configuration file at %s if you need to customize it\n\n", cfgPath)
}
}
@ -95,7 +103,7 @@ func setupConfig(rerun bool) (*Config, error) {
return nil, fmt.Errorf("unable to encode config file: %v", err)
}
fmt.Println("Created new config at ", cfgPath)
fmt.Printf("Created new config at %s\n\n", cfgPath)
}
_, err = toml.DecodeFile(cfgPath, &newConfig)
@ -126,3 +134,15 @@ func promptYesNo(prompt string) (bool, error) {
fmt.Println("Please enter a valid value of either 'y' or 'n'")
}
}
func input(prompt string) (string, error) {
fmt.Println(prompt)
fmt.Printf("> ")
var s string
_, err := fmt.Scanf("%s", &s)
if err != nil {
return "", fmt.Errorf("unable to read input: %v", err)
}
return strings.TrimSpace(s), nil
}