mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
ui: Refactoring
This commit is contained in:
parent
1566bb1cd3
commit
4c6006343e
17
run.go
17
run.go
@ -158,20 +158,11 @@ func Run(f func(*Image) error, width, height int, scale float64, title string) e
|
||||
width: width,
|
||||
height: height,
|
||||
}
|
||||
|
||||
theUIContext = newUIContext(game, scale)
|
||||
ww, wh := int(float64(width)*scale), int(float64(height)*scale)
|
||||
fixWindowPosition(ww, wh)
|
||||
SetWindowSize(ww, wh)
|
||||
SetWindowTitle(title)
|
||||
if err := uiDriver().Run(theUIContext, graphicsDriver()); err != nil {
|
||||
if err == driver.RegularTermination {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return runGame(game, scale)
|
||||
}
|
||||
|
||||
// RunGame starts the main loop and runs the game.
|
||||
@ -216,7 +207,11 @@ func RunGame(game Game) error {
|
||||
if uiDriver().CanHaveWindow() {
|
||||
fixWindowPosition(WindowSize())
|
||||
}
|
||||
theUIContext = newUIContext(game, 1)
|
||||
return runGame(game, 1)
|
||||
}
|
||||
|
||||
func runGame(game Game, scale float64) error {
|
||||
theUIContext = newUIContext(game, scale)
|
||||
if err := uiDriver().Run(theUIContext, graphicsDriver()); err != nil {
|
||||
if err == driver.RegularTermination {
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user