ui: Remove UserInterface interface

This commit is contained in:
Hajime Hoshi 2016-09-03 00:20:05 +09:00
parent f204c14f90
commit db782ff0d9
5 changed files with 7 additions and 20 deletions

View File

@ -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
}

View File

@ -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 {
}

View File

@ -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

View File

@ -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)

View File

@ -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