mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
driver: Move ui.RegularTermination to driver
This commit is contained in:
parent
1b8d4abfdb
commit
6b8516c7a5
@ -14,7 +14,16 @@
|
||||
|
||||
package driver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type GraphicsContext interface {
|
||||
SetSize(width, height int, scale float64)
|
||||
Update(afterFrameUpdate func()) error
|
||||
}
|
||||
|
||||
// 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")
|
||||
|
@ -1,24 +0,0 @@
|
||||
// Copyright 2015 Hajime Hoshi
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
// 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")
|
@ -745,7 +745,7 @@ func (u *userInterface) update(g driver.GraphicsContext) error {
|
||||
return nil
|
||||
})
|
||||
if shouldClose {
|
||||
return RegularTermination
|
||||
return driver.RegularTermination
|
||||
}
|
||||
|
||||
_ = mainthread.Run(func() error {
|
||||
|
3
run.go
3
run.go
@ -19,6 +19,7 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/input"
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
"github.com/hajimehoshi/ebiten/internal/web"
|
||||
@ -98,7 +99,7 @@ func run(width, height int, scale float64, title string, g *graphicsContext, mai
|
||||
defer atomic.StoreInt32(&isRunning, 0)
|
||||
}
|
||||
if err := ui.Run(width, height, scale, title, g, mainloop, graphicsDriver(), input.Get()); err != nil {
|
||||
if err == ui.RegularTermination {
|
||||
if err == driver.RegularTermination {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user