Fix GUI instance counts and launcher tmp paths
This commit is contained in:
@@ -4,8 +4,10 @@ import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"vrc_osc_go/internal/buildinfo"
|
||||
"vrc_osc_go/internal/common"
|
||||
@@ -31,12 +33,18 @@ func main() {
|
||||
if _, err := mgr.CheckAndUpdate(); err != nil {
|
||||
log.Printf("auto update skipped: %v", err)
|
||||
}
|
||||
exe := filepath.Join(common.RootDir(), "vrc_osc.exe")
|
||||
base := runtimeBaseDir()
|
||||
exe := filepath.Join(base, "vrc_osc.exe")
|
||||
gui := filepath.Join(base, "vrc_osc_gui.exe")
|
||||
if _, err := os.Stat(exe); err != nil {
|
||||
showError("vrc_osc_launcher", "missing exe: "+err.Error())
|
||||
log.Fatalf("missing exe: %v", err)
|
||||
}
|
||||
if err := update.Launch(exe, os.Args[1:]); err != nil {
|
||||
if _, err := os.Stat(gui); err == nil {
|
||||
_ = exec.Command(gui).Start()
|
||||
}
|
||||
args := append([]string{"--no-gui"}, os.Args[1:]...)
|
||||
if err := update.Launch(exe, args); err != nil {
|
||||
showError("vrc_osc_launcher", "launch failed: "+err.Error())
|
||||
log.Fatalf("launch failed: %v", err)
|
||||
}
|
||||
@@ -49,8 +57,19 @@ func showError(title, message string) {
|
||||
const mbIconError = 0x00000010
|
||||
_, _, _ = msgBox.Call(
|
||||
0,
|
||||
uintptr(syscall.StringToUTF16Ptr(message)),
|
||||
uintptr(syscall.StringToUTF16Ptr(title)),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(message))),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(title))),
|
||||
uintptr(mbOK|mbIconError),
|
||||
)
|
||||
}
|
||||
|
||||
func runtimeBaseDir() string {
|
||||
root := common.RootDir()
|
||||
if _, err := os.Stat(filepath.Join(root, "vrc_osc.exe")); err == nil {
|
||||
return root
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(root, "tmp", "vrc_osc.exe")); err == nil {
|
||||
return filepath.Join(root, "tmp")
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user