From 39dc58658f1e072ff23e44c7d3ff2d8ff07c25df Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 19 Sep 2021 17:50:53 +0900 Subject: [PATCH] examples/windowsize: Add -autorestore Closes #1610 --- examples/windowsize/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/windowsize/main.go b/examples/windowsize/main.go index 732921da0..ac929a1e2 100644 --- a/examples/windowsize/main.go +++ b/examples/windowsize/main.go @@ -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 {