ebiten: Refactoring: Remove scaleForWindow

This commit is contained in:
Hajime Hoshi 2020-10-15 02:27:42 +09:00
parent 0aa98d3113
commit d49d8db15d
2 changed files with 5 additions and 21 deletions

13
run.go
View File

@ -161,13 +161,9 @@ func (i *imageDumperGameWithDraw) Layout(outsideWidth, outsideHeight int) (scree
// Don't call RunGame twice or more in one process.
func RunGame(game Game) error {
fixWindowPosition(WindowSize())
return runGame(&imageDumperGameWithDraw{
theUIContext.set(&imageDumperGameWithDraw{
game: game,
}, 0)
}
func runGame(game Game, scale float64) error {
theUIContext.set(game, scale)
})
if err := uiDriver().Run(theUIContext); err != nil {
if err == driver.RegularTermination {
return nil
@ -184,10 +180,9 @@ func runGame(game Game, scale float64) error {
// Instead, functions in github.com/hajimehoshi/ebiten/v2/mobile package calls this.
func RunGameWithoutMainLoop(game Game) {
fixWindowPosition(WindowSize())
game = &imageDumperGameWithDraw{
theUIContext.set(&imageDumperGameWithDraw{
game: game,
}
theUIContext.set(game, 0)
})
uiDriver().RunWithoutMainLoop(theUIContext)
}

View File

@ -33,13 +33,6 @@ type uiContext struct {
updateCalled bool
// scaleForWindow is the scale of a window. This doesn't represent the scale on fullscreen. This value works
// only on desktops.
//
// scaleForWindow is for backward compatibility and is used to calculate the window size when SetScreenSize
// is called.
scaleForWindow float64
outsideSizeUpdated bool
outsideWidth float64
outsideHeight float64
@ -51,7 +44,7 @@ type uiContext struct {
var theUIContext = &uiContext{}
func (c *uiContext) set(game Game, scaleForWindow float64) {
func (c *uiContext) set(game Game) {
c.m.Lock()
defer c.m.Unlock()
c.game = game
@ -99,10 +92,6 @@ func (c *uiContext) updateOffscreen() {
// TODO: This is duplicated with mobile/ebitenmobileview/funcs.go. Refactor this.
d := uiDriver().DeviceScaleFactor()
c.screen = newScreenFramebufferImage(int(c.outsideWidth*d), int(c.outsideHeight*d))
// Do not have to update scaleForWindow since this is used only for backward compatibility.
// Then, if a window is resizable, scaleForWindow (= ebiten.ScreenScale) might not match with the actual
// scale. This is fine since ebiten.ScreenScale will be deprecated.
}
func (c *uiContext) setScreenClearedEveryFrame(cleared bool) {