mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/ui: refactoring: remove some exposed functions
This commit is contained in:
parent
08defeeded
commit
29382b424b
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/clock"
|
"github.com/hajimehoshi/ebiten/v2/internal/clock"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/debug"
|
"github.com/hajimehoshi/ebiten/v2/internal/debug"
|
||||||
graphicspkg "github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
graphicspkg "github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ const DefaultTPS = 60
|
|||||||
type Context interface {
|
type Context interface {
|
||||||
UpdateOffscreen(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int)
|
UpdateOffscreen(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int)
|
||||||
UpdateGame() error
|
UpdateGame() error
|
||||||
DrawGame(screenScale float64, offsetX, offsetY float64) error
|
DrawGame(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type contextImpl struct {
|
type contextImpl struct {
|
||||||
@ -99,7 +100,7 @@ func (c *contextImpl) updateFrameImpl(updateCount int, deviceScaleFactor float64
|
|||||||
|
|
||||||
// Draw the game.
|
// Draw the game.
|
||||||
screenScale, offsetX, offsetY := c.screenScaleAndOffsets(deviceScaleFactor)
|
screenScale, offsetX, offsetY := c.screenScaleAndOffsets(deviceScaleFactor)
|
||||||
if err := c.context.DrawGame(screenScale, offsetX, offsetY); err != nil {
|
if err := c.context.DrawGame(screenScale, offsetX, offsetY, graphics().NeedsClearingScreen(), graphics().FramebufferYDirection()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MouseButton int
|
type MouseButton int
|
||||||
@ -69,11 +67,3 @@ const (
|
|||||||
WindowResizingModeOnlyFullscreenEnabled
|
WindowResizingModeOnlyFullscreenEnabled
|
||||||
WindowResizingModeEnabled
|
WindowResizingModeEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
func NeedsClearingScreen() bool {
|
|
||||||
return graphics().NeedsClearingScreen()
|
|
||||||
}
|
|
||||||
|
|
||||||
func FramebufferYDirection() graphicsdriver.YDirection {
|
|
||||||
return graphics().FramebufferYDirection()
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type uiContext struct {
|
type uiContext struct {
|
||||||
@ -88,7 +87,7 @@ func (c *uiContext) UpdateGame() error {
|
|||||||
return c.game.Update()
|
return c.game.Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *uiContext) DrawGame(screenScale float64, offsetX, offsetY float64) error {
|
func (c *uiContext) DrawGame(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection) error {
|
||||||
// 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.
|
||||||
@ -97,7 +96,7 @@ func (c *uiContext) DrawGame(screenScale float64, offsetX, offsetY float64) erro
|
|||||||
}
|
}
|
||||||
c.game.Draw(c.offscreen)
|
c.game.Draw(c.offscreen)
|
||||||
|
|
||||||
if ui.NeedsClearingScreen() {
|
if needsClearingScreen {
|
||||||
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
||||||
c.screen.Clear()
|
c.screen.Clear()
|
||||||
}
|
}
|
||||||
@ -105,7 +104,7 @@ func (c *uiContext) DrawGame(screenScale float64, offsetX, offsetY float64) erro
|
|||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
|
|
||||||
s := screenScale
|
s := screenScale
|
||||||
switch vd := ui.FramebufferYDirection(); vd {
|
switch framebufferYDirection {
|
||||||
case graphicsdriver.Upward:
|
case graphicsdriver.Upward:
|
||||||
op.GeoM.Scale(s, -s)
|
op.GeoM.Scale(s, -s)
|
||||||
_, h := c.offscreen.Size()
|
_, h := c.offscreen.Size()
|
||||||
@ -113,7 +112,7 @@ func (c *uiContext) DrawGame(screenScale float64, offsetX, offsetY float64) erro
|
|||||||
case graphicsdriver.Downward:
|
case graphicsdriver.Downward:
|
||||||
op.GeoM.Scale(s, s)
|
op.GeoM.Scale(s, s)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))
|
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", framebufferYDirection))
|
||||||
}
|
}
|
||||||
|
|
||||||
op.GeoM.Translate(offsetX, offsetY)
|
op.GeoM.Translate(offsetX, offsetY)
|
||||||
|
Loading…
Reference in New Issue
Block a user