internal/ui: remove RunWithoutMainLoop in non-mobile environments

This commit is contained in:
Hajime Hoshi 2022-02-13 22:31:48 +09:00
parent 0529fa955e
commit b695cb928a
6 changed files with 9 additions and 17 deletions

View File

@ -72,13 +72,13 @@ func (c *gameForUI) Update() error {
return c.game.Update() return c.game.Update()
} }
func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, screenClearedEveryFrame bool) error { func (c *gameForUI) Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, clearScreenEveryFrame bool) error {
c.offscreen.mipmap.SetVolatile(screenClearedEveryFrame) c.offscreen.mipmap.SetVolatile(clearScreenEveryFrame)
// Even though updateCount == 0, the offscreen is cleared and Draw is called. // Even though updateCount == 0, the offscreen is cleared and Draw is called.
// Draw should not update the game state and then the screen should not be updated without Update, but // Draw should not update the game state and then the screen should not be updated without Update, but
// users might want to process something at Draw with the time intervals of FPS. // users might want to process something at Draw with the time intervals of FPS.
if screenClearedEveryFrame { if clearScreenEveryFrame {
c.offscreen.Clear() c.offscreen.Clear()
} }
c.game.Draw(c.offscreen) c.game.Draw(c.offscreen)

View File

@ -58,10 +58,6 @@ func (u *UserInterface) Run(game Game) error {
} }
} }
func (*UserInterface) RunWithoutMainLoop(game Game) {
panic("ui: RunWithoutMainLoop is not implemented")
}
func (*UserInterface) DeviceScaleFactor() float64 { func (*UserInterface) DeviceScaleFactor() float64 {
return deviceScaleFactor return deviceScaleFactor
} }

View File

@ -642,10 +642,6 @@ func init() {
runtime.LockOSThread() runtime.LockOSThread()
} }
func (u *UserInterface) RunWithoutMainLoop(game Game) {
panic("ui: RunWithoutMainLoop is not implemented")
}
// createWindow creates a GLFW window. // createWindow creates a GLFW window.
// //
// width and height are in GLFW pixels (not device-independent pixels). // width and height are in GLFW pixels (not device-independent pixels).

View File

@ -600,10 +600,6 @@ func (u *UserInterface) Run(game Game) error {
return <-u.loop(game) return <-u.loop(game)
} }
func (u *UserInterface) RunWithoutMainLoop(game Game) {
panic("ui: RunWithoutMainLoop is not implemented")
}
func (u *UserInterface) updateScreenSize() { func (u *UserInterface) updateScreenSize() {
switch { switch {
case document.Truthy(): case document.Truthy():

View File

@ -250,7 +250,11 @@ func (u *UserInterface) Run(game Game) error {
return nil return nil
} }
func (u *UserInterface) RunWithoutMainLoop(game Game) { func RunWithoutMainLoop(game Game) {
theUI.runWithoutMainLoop(game)
}
func (u *UserInterface) runWithoutMainLoop(game Game) {
go func() { go func() {
if err := u.run(game, false); err != nil { if err := u.run(game, false); err != nil {
u.errCh <- err u.errCh <- err

View File

@ -29,5 +29,5 @@ import (
// //
// TODO: Remove this. In order to remove this, the gameForUI should be in another package. // TODO: Remove this. In order to remove this, the gameForUI should be in another package.
func RunGameWithoutMainLoop(game Game) { func RunGameWithoutMainLoop(game Game) {
ui.Get().RunWithoutMainLoop(newGameForUI(game)) ui.RunWithoutMainLoop(newGameForUI(game))
} }