mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ebiten: Refactoring: Remove scaleForWindow
This commit is contained in:
parent
0aa98d3113
commit
d49d8db15d
13
run.go
13
run.go
@ -161,13 +161,9 @@ 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())
|
||||||
return runGame(&imageDumperGameWithDraw{
|
theUIContext.set(&imageDumperGameWithDraw{
|
||||||
game: game,
|
game: game,
|
||||||
}, 0)
|
})
|
||||||
}
|
|
||||||
|
|
||||||
func runGame(game Game, scale float64) error {
|
|
||||||
theUIContext.set(game, scale)
|
|
||||||
if err := uiDriver().Run(theUIContext); err != nil {
|
if err := uiDriver().Run(theUIContext); err != nil {
|
||||||
if err == driver.RegularTermination {
|
if err == driver.RegularTermination {
|
||||||
return nil
|
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.
|
// Instead, functions in github.com/hajimehoshi/ebiten/v2/mobile package calls this.
|
||||||
func RunGameWithoutMainLoop(game Game) {
|
func RunGameWithoutMainLoop(game Game) {
|
||||||
fixWindowPosition(WindowSize())
|
fixWindowPosition(WindowSize())
|
||||||
game = &imageDumperGameWithDraw{
|
theUIContext.set(&imageDumperGameWithDraw{
|
||||||
game: game,
|
game: game,
|
||||||
}
|
})
|
||||||
theUIContext.set(game, 0)
|
|
||||||
uiDriver().RunWithoutMainLoop(theUIContext)
|
uiDriver().RunWithoutMainLoop(theUIContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
uicontext.go
13
uicontext.go
@ -33,13 +33,6 @@ type uiContext struct {
|
|||||||
|
|
||||||
updateCalled bool
|
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
|
outsideSizeUpdated bool
|
||||||
outsideWidth float64
|
outsideWidth float64
|
||||||
outsideHeight float64
|
outsideHeight float64
|
||||||
@ -51,7 +44,7 @@ type uiContext struct {
|
|||||||
|
|
||||||
var theUIContext = &uiContext{}
|
var theUIContext = &uiContext{}
|
||||||
|
|
||||||
func (c *uiContext) set(game Game, scaleForWindow float64) {
|
func (c *uiContext) set(game Game) {
|
||||||
c.m.Lock()
|
c.m.Lock()
|
||||||
defer c.m.Unlock()
|
defer c.m.Unlock()
|
||||||
c.game = game
|
c.game = game
|
||||||
@ -99,10 +92,6 @@ func (c *uiContext) updateOffscreen() {
|
|||||||
// TODO: This is duplicated with mobile/ebitenmobileview/funcs.go. Refactor this.
|
// TODO: This is duplicated with mobile/ebitenmobileview/funcs.go. Refactor this.
|
||||||
d := uiDriver().DeviceScaleFactor()
|
d := uiDriver().DeviceScaleFactor()
|
||||||
c.screen = newScreenFramebufferImage(int(c.outsideWidth*d), int(c.outsideHeight*d))
|
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) {
|
func (c *uiContext) setScreenClearedEveryFrame(cleared bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user