fix(all): launch game fullscreen and hide debug overlay

This commit is contained in:
2026-10-03 11:14:03 +08:00
parent 8150ec3e80
commit db1eab764e
6 changed files with 163 additions and 7 deletions
+8
View File
@@ -0,0 +1,8 @@
package app
// gameLaunchArguments asks Unity for borderless fullscreen on both supported
// desktop platforms. The LocalIdentity plug-in applies the game's native
// fullscreen routine during initialization as a second line of defence.
func gameLaunchArguments() []string {
return []string{"-screen-fullscreen", "1", "-window-mode", "borderless"}
}
+2 -1
View File
@@ -25,5 +25,6 @@ func launchGame(target string) error {
if err := exec.Command("pgrep", "-x", "BrownDust II").Run(); err == nil {
return errGameAlreadyRunning
}
return exec.Command("open", target).Start()
args := append([]string{target, "--args"}, gameLaunchArguments()...)
return exec.Command("open", args...).Start()
}
+7 -3
View File
@@ -20,6 +20,7 @@ var (
enumWindowsProc = platformUser32DLL.NewProc("EnumWindows")
getWindowThreadProcessIDProc = platformUser32DLL.NewProc("GetWindowThreadProcessId")
isWindowVisibleProc = platformUser32DLL.NewProc("IsWindowVisible")
isIconicProc = platformUser32DLL.NewProc("IsIconic")
showWindowAsyncProc = platformUser32DLL.NewProc("ShowWindowAsync")
setForegroundWindowProc = platformUser32DLL.NewProc("SetForegroundWindow")
)
@@ -76,7 +77,7 @@ func launchGame(target string) error {
}
return errGameAlreadyRunning
}
command := visibleCommand(target)
command := visibleCommand(target, gameLaunchArguments()...)
command.Dir = filepath.Dir(target)
if err := command.Start(); err != nil {
return err
@@ -114,8 +115,11 @@ func activateProcessWindow(processID uint32, timeout time.Duration) bool {
deadline := time.Now().Add(timeout)
for {
if window := topLevelWindowForProcess(processID); window != 0 {
const swRestore = 9
showWindowAsyncProc.Call(window, swRestore)
iconic, _, _ := isIconicProc.Call(window)
if iconic != 0 {
const swRestore = 9
showWindowAsyncProc.Call(window, swRestore)
}
setForegroundWindowProc.Call(window)
return true
}
@@ -2,7 +2,10 @@
package app
import "testing"
import (
"reflect"
"testing"
)
func TestHiddenCommandNeverAllocatesVisibleConsole(t *testing.T) {
command := hiddenCommand("powershell.exe", "-NoProfile")
@@ -18,7 +21,7 @@ func TestHiddenCommandNeverAllocatesVisibleConsole(t *testing.T) {
}
func TestVisibleCommandDoesNotHideGUIWindow(t *testing.T) {
command := visibleCommand("Brown Dust II.exe")
command := visibleCommand("Brown Dust II.exe", gameLaunchArguments()...)
if command.SysProcAttr == nil {
t.Fatal("visible command has no Windows process attributes")
}
@@ -28,4 +31,12 @@ func TestVisibleCommandDoesNotHideGUIWindow(t *testing.T) {
if command.SysProcAttr.CreationFlags&createNoWindow == 0 {
t.Fatalf("visible command creation flags %#x omit CREATE_NO_WINDOW", command.SysProcAttr.CreationFlags)
}
want := []string{
"Brown Dust II.exe",
"-screen-fullscreen", "1",
"-window-mode", "borderless",
}
if !reflect.DeepEqual(command.Args, want) {
t.Fatalf("visible game command args = %#v, want %#v", command.Args, want)
}
}