mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ui: Change RegularTermination to a value
This commit is contained in:
parent
1815eec806
commit
e3023889ac
@ -14,15 +14,17 @@
|
|||||||
|
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
type GraphicsContext interface {
|
type GraphicsContext interface {
|
||||||
SetSize(width, height int, scale float64)
|
SetSize(width, height int, scale float64)
|
||||||
Update(afterFrameUpdate func()) error
|
Update(afterFrameUpdate func()) error
|
||||||
Invalidate()
|
Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
type RegularTermination struct {
|
// RegularTermination represents a regular termination.
|
||||||
}
|
// Run can return this error, and if this error is received,
|
||||||
|
// the game loop should be terminated as soon as possible.
|
||||||
func (*RegularTermination) Error() string {
|
var RegularTermination = errors.New("regular termination")
|
||||||
return "regular termination"
|
|
||||||
}
|
|
||||||
|
@ -446,7 +446,7 @@ func (u *userInterface) update(g GraphicsContext) error {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if shouldClose {
|
if shouldClose {
|
||||||
return &RegularTermination{}
|
return RegularTermination
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
|
2
run.go
2
run.go
@ -80,7 +80,7 @@ var theGraphicsContext atomic.Value
|
|||||||
|
|
||||||
func run(width, height int, scale float64, title string, g *graphicsContext) error {
|
func run(width, height int, scale float64, title string, g *graphicsContext) error {
|
||||||
if err := ui.Run(width, height, scale, title, g); err != nil {
|
if err := ui.Run(width, height, scale, title, g); err != nil {
|
||||||
if _, ok := err.(*ui.RegularTermination); ok {
|
if err == ui.RegularTermination {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user