mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Forbid RestoreWindow when the window is not maximized nor minimized
Fixes #1124
This commit is contained in:
parent
b470dace1a
commit
161d8aae8f
@ -231,7 +231,10 @@ func (g *game) Update(screen *ebiten.Image) error {
|
|||||||
}
|
}
|
||||||
maximize := inpututil.IsKeyJustPressed(ebiten.KeyM)
|
maximize := inpututil.IsKeyJustPressed(ebiten.KeyM)
|
||||||
minimize := inpututil.IsKeyJustPressed(ebiten.KeyN)
|
minimize := inpututil.IsKeyJustPressed(ebiten.KeyN)
|
||||||
restore := inpututil.IsKeyJustPressed(ebiten.KeyE)
|
restore := false
|
||||||
|
if ebiten.IsWindowMaximized() || ebiten.IsWindowMinimized() {
|
||||||
|
restore = inpututil.IsKeyJustPressed(ebiten.KeyE)
|
||||||
|
}
|
||||||
|
|
||||||
if toUpdateWindowSize {
|
if toUpdateWindowSize {
|
||||||
if *flagLegacy {
|
if *flagLegacy {
|
||||||
|
10
window.go
10
window.go
@ -278,10 +278,15 @@ func MaximizeWindow() {
|
|||||||
|
|
||||||
// IsWindowMaximized reports whether the window is maximized or not.
|
// IsWindowMaximized reports whether the window is maximized or not.
|
||||||
//
|
//
|
||||||
|
// IsWindowMaximized returns false when the window is not resizable.
|
||||||
|
//
|
||||||
// IsWindowMaximized always returns false on browsers and mobiles.
|
// IsWindowMaximized always returns false on browsers and mobiles.
|
||||||
//
|
//
|
||||||
// IsWindowMaximized is concurrent-safe.
|
// IsWindowMaximized is concurrent-safe.
|
||||||
func IsWindowMaximized() bool {
|
func IsWindowMaximized() bool {
|
||||||
|
if !IsWindowResizable() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if w := uiDriver().Window(); w != nil {
|
if w := uiDriver().Window(); w != nil {
|
||||||
return w.IsMaximized()
|
return w.IsMaximized()
|
||||||
}
|
}
|
||||||
@ -315,8 +320,13 @@ func IsWindowMinimized() bool {
|
|||||||
|
|
||||||
// RestoreWindow restores the window from its maximized or minimized state.
|
// RestoreWindow restores the window from its maximized or minimized state.
|
||||||
//
|
//
|
||||||
|
// RestoreWindow panics when the window is not maximized nor minimized.
|
||||||
|
//
|
||||||
// RestoreWindow is concurrent-safe.
|
// RestoreWindow is concurrent-safe.
|
||||||
func RestoreWindow() {
|
func RestoreWindow() {
|
||||||
|
if !IsWindowMaximized() && !IsWindowMinimized() {
|
||||||
|
panic("ebiten: RestoreWindow must be called on a maximized or a minimized window")
|
||||||
|
}
|
||||||
if w := uiDriver().Window(); w != nil {
|
if w := uiDriver().Window(); w != nil {
|
||||||
w.Restore()
|
w.Restore()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user