examples/windowsize: Add -autorestore

Closes #1610
This commit is contained in:
Hajime Hoshi 2021-09-19 17:50:53 +09:00
parent 69300f0c4e
commit 39dc58658f

View File

@ -46,6 +46,7 @@ var (
flagFloating = flag.Bool("floating", false, "make the window floating")
flagMaximize = flag.Bool("maximize", false, "maximize the window")
flagVsync = flag.Bool("vsync", true, "enable vsync")
flagAutoRestore = flag.Bool("autorestore", false, "restore the window automatically")
flagInitFocused = flag.Bool("initfocused", true, "whether the window is focused on start")
flagMinWindowSize = flag.String("minwindowsize", "", "minimum window size (e.g., 100x200)")
flagMaxWindowSize = flag.String("maxwindowsize", "", "maximium window size (e.g., 1920x1080)")
@ -246,7 +247,11 @@ func (g *game) Update() error {
minimize := inpututil.IsKeyJustPressed(ebiten.KeyN)
restore := false
if ebiten.IsWindowMaximized() || ebiten.IsWindowMinimized() {
restore = inpututil.IsKeyJustPressed(ebiten.KeyE)
if *flagAutoRestore {
restore = g.count%ebiten.MaxTPS() == 0
} else {
restore = inpututil.IsKeyJustPressed(ebiten.KeyE)
}
}
if toUpdateWindowSize {