mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
ui: Remove UserInterface interface
This commit is contained in:
parent
f204c14f90
commit
db782ff0d9
@ -114,7 +114,7 @@ func Run(g GraphicsContext, width, height int, scale float64, title string, fps
|
|||||||
currentRunContext.lastFPSUpdated = n
|
currentRunContext.lastFPSUpdated = n
|
||||||
|
|
||||||
lg := &loopGraphicsContext{currentRunContext, g}
|
lg := &loopGraphicsContext{currentRunContext, g}
|
||||||
if err := ui.CurrentUI().Run(width, height, scale, title, lg); err != nil {
|
if err := ui.Run(width, height, scale, title, lg); err != nil {
|
||||||
if _, ok := err.(*ui.RegularTermination); ok {
|
if _, ok := err.(*ui.RegularTermination); ok {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,6 @@ type GraphicsContext interface {
|
|||||||
Update() error
|
Update() error
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserInterface interface {
|
|
||||||
Run(width, height int, scale float64, title string, g GraphicsContext) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegularTermination struct {
|
type RegularTermination struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,6 @@ type userInterface struct {
|
|||||||
|
|
||||||
var currentUI *userInterface
|
var currentUI *userInterface
|
||||||
|
|
||||||
func CurrentUI() UserInterface {
|
|
||||||
return currentUI
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if err := initialize(); err != nil {
|
if err := initialize(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -146,7 +142,8 @@ func ScreenScale() float64 {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
func Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
||||||
|
u := currentUI
|
||||||
// GLContext must be created before setting the screen size, which requires
|
// GLContext must be created before setting the screen size, which requires
|
||||||
// swapping buffers.
|
// swapping buffers.
|
||||||
var err error
|
var err error
|
||||||
|
@ -39,10 +39,6 @@ var currentUI = &userInterface{
|
|||||||
windowFocus: true,
|
windowFocus: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func CurrentUI() UserInterface {
|
|
||||||
return currentUI
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: This returns true even when the browser is not active.
|
// NOTE: This returns true even when the browser is not active.
|
||||||
func shown() bool {
|
func shown() bool {
|
||||||
return !js.Global.Get("document").Get("hidden").Bool()
|
return !js.Global.Get("document").Get("hidden").Bool()
|
||||||
@ -262,7 +258,8 @@ func RunMainThreadLoop(ch <-chan error) error {
|
|||||||
return <-ch
|
return <-ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterface) Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
func Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
||||||
|
u := currentUI
|
||||||
doc := js.Global.Get("document")
|
doc := js.Global.Get("document")
|
||||||
doc.Set("title", title)
|
doc.Set("title", title)
|
||||||
u.setScreenSize(width, height, scale)
|
u.setScreenSize(width, height, scale)
|
||||||
|
@ -60,11 +60,8 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func CurrentUI() UserInterface {
|
func Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
||||||
return currentUI
|
u := currentUI
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterface) Run(width, height int, scale float64, title string, g GraphicsContext) error {
|
|
||||||
u.width = width
|
u.width = width
|
||||||
u.height = height
|
u.height = height
|
||||||
u.scale = scale
|
u.scale = scale
|
||||||
|
Loading…
Reference in New Issue
Block a user