mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Change RegularTermination to a value
This commit is contained in:
parent
1815eec806
commit
e3023889ac
@ -14,15 +14,17 @@
|
||||
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type GraphicsContext interface {
|
||||
SetSize(width, height int, scale float64)
|
||||
Update(afterFrameUpdate func()) error
|
||||
Invalidate()
|
||||
}
|
||||
|
||||
type RegularTermination struct {
|
||||
}
|
||||
|
||||
func (*RegularTermination) Error() string {
|
||||
return "regular termination"
|
||||
}
|
||||
// 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.
|
||||
var RegularTermination = errors.New("regular termination")
|
||||
|
@ -446,7 +446,7 @@ func (u *userInterface) update(g GraphicsContext) error {
|
||||
return nil
|
||||
})
|
||||
if shouldClose {
|
||||
return &RegularTermination{}
|
||||
return RegularTermination
|
||||
}
|
||||
|
||||
_ = 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 {
|
||||
if err := ui.Run(width, height, scale, title, g); err != nil {
|
||||
if _, ok := err.(*ui.RegularTermination); ok {
|
||||
if err == ui.RegularTermination {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user