FIX: Fail to start game
This commit is contained in:
@@ -80,7 +80,7 @@ export function RemoveFile(path) {
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {$CancellablePromise<boolean>}
|
||||
* @returns {$CancellablePromise<[boolean, string]>}
|
||||
*/
|
||||
export function StartApp(path) {
|
||||
return $Call.ByID(1267568402, path);
|
||||
@@ -88,7 +88,7 @@ export function StartApp(path) {
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {$CancellablePromise<boolean>}
|
||||
* @returns {$CancellablePromise<[boolean, string]>}
|
||||
*/
|
||||
export function StartWithConsole(path) {
|
||||
return $Call.ByID(3249271428, path);
|
||||
|
||||
@@ -190,18 +190,18 @@ export default function LauncherPage() {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
if (!proxyRunning && !gamePath.endsWith("launcher.exe")) {
|
||||
const resultProxy = await FSService.StartWithConsole(proxyPath)
|
||||
const [resultProxy, error] = await FSService.StartWithConsole(proxyPath)
|
||||
if (!resultProxy) {
|
||||
toast.error('Failed to start proxy')
|
||||
toast.error('Failed to start proxy: ' + error)
|
||||
return
|
||||
}
|
||||
setProxyRunning(true)
|
||||
}
|
||||
await sleep(500)
|
||||
if (!serverRunning) {
|
||||
const resultServer = await FSService.StartWithConsole(serverPath)
|
||||
const [resultServer, error] = await FSService.StartWithConsole(serverPath)
|
||||
if (!resultServer) {
|
||||
toast.error('Failed to start server')
|
||||
toast.error('Failed to start server: ' + error)
|
||||
return
|
||||
}
|
||||
setServerRunning(true)
|
||||
@@ -209,23 +209,27 @@ export default function LauncherPage() {
|
||||
await sleep(1000)
|
||||
const gameFolder = await FSService.GetDir(gamePath)
|
||||
const fileNeedRemove = await FSService.Join(gameFolder, "StarRail_Data", "Plugins", "x86_64", "AccountPlatNative.dll")
|
||||
const fileExists = await FSService.FileExists(fileNeedRemove)
|
||||
if (fileExists) {
|
||||
await FSService.RemoveFile(fileNeedRemove)
|
||||
}
|
||||
if (gamePath.endsWith("launcher.exe")) {
|
||||
const resultGame = await FSService.StartWithConsole(gamePath)
|
||||
const [resultGame, error] = await FSService.StartWithConsole(gamePath)
|
||||
if (!resultGame) {
|
||||
toast.error('Failed to start game')
|
||||
toast.error('Failed to start game: ' + error)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const resultGame = await FSService.StartApp(gamePath)
|
||||
const [resultGame, error] = await FSService.StartApp(gamePath)
|
||||
if (!resultGame) {
|
||||
toast.error('Failed to start game')
|
||||
toast.error('Failed to start game: ' + error)
|
||||
return
|
||||
}
|
||||
}
|
||||
setGameRunning(true)
|
||||
|
||||
} catch (err: any) {
|
||||
console.log(err)
|
||||
toast.error('StartGame error:', err)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
|
||||
@@ -2,12 +2,12 @@ package fsService
|
||||
|
||||
import (
|
||||
"firefly-launcher/pkg/sevenzip"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
@@ -75,13 +75,13 @@ func (f *FSService) RemoveFile(path string) error {
|
||||
return os.Remove(path)
|
||||
}
|
||||
|
||||
|
||||
func (f *FSService) StartApp(path string) (bool, error) {
|
||||
func (f *FSService) StartApp(path string) (bool, string) {
|
||||
cmd := exec.Command(path)
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, err.Error()
|
||||
}
|
||||
|
||||
if strings.HasSuffix(path, "StarRail.exe") {
|
||||
go func() {
|
||||
_ = cmd.Wait()
|
||||
@@ -89,17 +89,17 @@ func (f *FSService) StartApp(path string) (bool, error) {
|
||||
}()
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func (f *FSService) StartWithConsole(path string) (bool, error) {
|
||||
func (f *FSService) StartWithConsole(path string) (bool, string) {
|
||||
absPath, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, err.Error()
|
||||
}
|
||||
|
||||
if _, err := os.Stat(absPath); os.IsNotExist(err) {
|
||||
return false, fmt.Errorf("file not found: %s", absPath)
|
||||
return false, "file not found: " + absPath
|
||||
}
|
||||
cmd := exec.Command(absPath)
|
||||
cmd.Dir = filepath.Dir(absPath)
|
||||
@@ -116,7 +116,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
|
||||
err = cmd.Start()
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
return false, err.Error()
|
||||
}
|
||||
|
||||
go func() {
|
||||
@@ -129,7 +129,7 @@ func (f *FSService) StartWithConsole(path string) (bool, error) {
|
||||
application.Get().Event.Emit("proxy:exit")
|
||||
}
|
||||
}()
|
||||
return true, nil
|
||||
return true, ""
|
||||
}
|
||||
|
||||
func (f *FSService) OpenFolder(path string) (bool, string) {
|
||||
@@ -155,4 +155,3 @@ func (f *FSService) FileExistsInZip(archivePath, fileInside string) (bool, strin
|
||||
}
|
||||
return exists, ""
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const ProxyZipFile = "64bit.zip"
|
||||
const LauncherFile = "firefly-launcher.exe"
|
||||
const TempUrl = "./temp"
|
||||
|
||||
const CurrentLauncherVersion = "2.3.0"
|
||||
const CurrentLauncherVersion = "2.3.1"
|
||||
|
||||
type ToolFile string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user