mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +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
|
||||
|
||||
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 {
|
||||
return nil
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ type GraphicsContext interface {
|
||||
Update() error
|
||||
}
|
||||
|
||||
type UserInterface interface {
|
||||
Run(width, height int, scale float64, title string, g GraphicsContext) error
|
||||
}
|
||||
|
||||
type RegularTermination struct {
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,6 @@ type userInterface struct {
|
||||
|
||||
var currentUI *userInterface
|
||||
|
||||
func CurrentUI() UserInterface {
|
||||
return currentUI
|
||||
}
|
||||
|
||||
func init() {
|
||||
if err := initialize(); err != nil {
|
||||
panic(err)
|
||||
@ -146,7 +142,8 @@ func ScreenScale() float64 {
|
||||
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
|
||||
// swapping buffers.
|
||||
var err error
|
||||
|
@ -39,10 +39,6 @@ var currentUI = &userInterface{
|
||||
windowFocus: true,
|
||||
}
|
||||
|
||||
func CurrentUI() UserInterface {
|
||||
return currentUI
|
||||
}
|
||||
|
||||
// NOTE: This returns true even when the browser is not active.
|
||||
func shown() bool {
|
||||
return !js.Global.Get("document").Get("hidden").Bool()
|
||||
@ -262,7 +258,8 @@ func RunMainThreadLoop(ch <-chan error) error {
|
||||
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.Set("title", title)
|
||||
u.setScreenSize(width, height, scale)
|
||||
|
@ -60,11 +60,8 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func CurrentUI() UserInterface {
|
||||
return currentUI
|
||||
}
|
||||
|
||||
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
|
||||
u.width = width
|
||||
u.height = height
|
||||
u.scale = scale
|
||||
|
Loading…
Reference in New Issue
Block a user