ebiten: Rename imageDumperGameWithDraw -> imageDumperGame

This commit is contained in:
Hajime Hoshi 2020-10-17 18:11:50 +09:00
parent f39f80c7c3
commit 294f4364da

14
run.go
View File

@ -96,13 +96,13 @@ func IsScreenClearedEveryFrame() bool {
return atomic.LoadInt32(&isScreenClearedEveryFrame) != 0 return atomic.LoadInt32(&isScreenClearedEveryFrame) != 0
} }
type imageDumperGameWithDraw struct { type imageDumperGame struct {
game Game game Game
d *imageDumper d *imageDumper
err error err error
} }
func (i *imageDumperGameWithDraw) Update() error { func (i *imageDumperGame) Update() error {
if i.err != nil { if i.err != nil {
return i.err return i.err
} }
@ -112,7 +112,7 @@ func (i *imageDumperGameWithDraw) Update() error {
return i.d.update() return i.d.update()
} }
func (i *imageDumperGameWithDraw) Draw(screen *Image) { func (i *imageDumperGame) Draw(screen *Image) {
if i.err != nil { if i.err != nil {
return return
} }
@ -121,7 +121,7 @@ func (i *imageDumperGameWithDraw) Draw(screen *Image) {
i.err = i.d.dump(screen) i.err = i.d.dump(screen)
} }
func (i *imageDumperGameWithDraw) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { func (i *imageDumperGame) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
return i.game.Layout(outsideWidth, outsideHeight) return i.game.Layout(outsideWidth, outsideHeight)
} }
@ -161,7 +161,7 @@ func (i *imageDumperGameWithDraw) Layout(outsideWidth, outsideHeight int) (scree
// Don't call RunGame twice or more in one process. // Don't call RunGame twice or more in one process.
func RunGame(game Game) error { func RunGame(game Game) error {
fixWindowPosition(WindowSize()) fixWindowPosition(WindowSize())
theUIContext.set(&imageDumperGameWithDraw{ theUIContext.set(&imageDumperGame{
game: game, game: game,
}) })
if err := uiDriver().Run(theUIContext); err != nil { if err := uiDriver().Run(theUIContext); err != nil {
@ -178,9 +178,11 @@ func RunGame(game Game) error {
// //
// Ebiten users should NOT call RunGameWithoutMainLoop. // Ebiten users should NOT call RunGameWithoutMainLoop.
// Instead, functions in github.com/hajimehoshi/ebiten/v2/mobile package calls this. // Instead, functions in github.com/hajimehoshi/ebiten/v2/mobile package calls this.
//
// TODO: Remove this. In order to remove this, the uiContext should be in another package.
func RunGameWithoutMainLoop(game Game) { func RunGameWithoutMainLoop(game Game) {
fixWindowPosition(WindowSize()) fixWindowPosition(WindowSize())
theUIContext.set(&imageDumperGameWithDraw{ theUIContext.set(&imageDumperGame{
game: game, game: game,
}) })
uiDriver().RunWithoutMainLoop(theUIContext) uiDriver().RunWithoutMainLoop(theUIContext)