mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/ui: merge init functions
The Go specification doesn't determine the order of init functions. In order to reduce unexpected behavior, merge some init functions.
This commit is contained in:
parent
567e2fa04c
commit
2a8d8d71fc
@ -121,6 +121,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// Lock the main thread.
|
||||||
|
runtime.LockOSThread()
|
||||||
|
|
||||||
theUI.userInterfaceImpl = userInterfaceImpl{
|
theUI.userInterfaceImpl = userInterfaceImpl{
|
||||||
runnableOnUnfocused: true,
|
runnableOnUnfocused: true,
|
||||||
minWindowWidthInDIP: glfw.DontCare,
|
minWindowWidthInDIP: glfw.DontCare,
|
||||||
@ -140,9 +143,7 @@ func init() {
|
|||||||
savedCursorY: math.NaN(),
|
savedCursorY: math.NaN(),
|
||||||
}
|
}
|
||||||
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
hideConsoleWindowOnWindows()
|
hideConsoleWindowOnWindows()
|
||||||
|
|
||||||
if err := initialize(); err != nil {
|
if err := initialize(); err != nil {
|
||||||
@ -869,11 +870,6 @@ func (u *userInterfaceImpl) DeviceScaleFactor() float64 {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
// Lock the main thread.
|
|
||||||
runtime.LockOSThread()
|
|
||||||
}
|
|
||||||
|
|
||||||
// createWindow creates a GLFW window.
|
// createWindow creates a GLFW window.
|
||||||
//
|
//
|
||||||
// createWindow must be called from the main thread.
|
// createWindow must be called from the main thread.
|
||||||
|
@ -116,14 +116,6 @@ type userInterfaceImpl struct {
|
|||||||
dropFileM sync.Mutex
|
dropFileM sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
theUI.userInterfaceImpl = userInterfaceImpl{
|
|
||||||
runnableOnUnfocused: true,
|
|
||||||
savedCursorX: math.NaN(),
|
|
||||||
savedCursorY: math.NaN(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
window = js.Global().Get("window")
|
window = js.Global().Get("window")
|
||||||
document = js.Global().Get("document")
|
document = js.Global().Get("document")
|
||||||
@ -133,14 +125,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
documentHasFocus js.Value
|
|
||||||
documentHidden js.Value
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
documentHasFocus = document.Get("hasFocus").Call("bind", document)
|
documentHasFocus = document.Get("hasFocus").Call("bind", document)
|
||||||
documentHidden = js.Global().Get("Object").Call("getOwnPropertyDescriptor", js.Global().Get("Document").Get("prototype"), "hidden").Get("get").Call("bind", document)
|
documentHidden = js.Global().Get("Object").Call("getOwnPropertyDescriptor", js.Global().Get("Document").Get("prototype"), "hidden").Get("get").Call("bind", document)
|
||||||
}
|
)
|
||||||
|
|
||||||
func (u *userInterfaceImpl) ScreenSizeInFullscreen() (int, int) {
|
func (u *userInterfaceImpl) ScreenSizeInFullscreen() (int, int) {
|
||||||
return window.Get("innerWidth").Int(), window.Get("innerHeight").Int()
|
return window.Get("innerWidth").Int(), window.Get("innerHeight").Int()
|
||||||
@ -485,6 +472,12 @@ func (u *userInterfaceImpl) loop(game Game) <-chan error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
theUI.userInterfaceImpl = userInterfaceImpl{
|
||||||
|
runnableOnUnfocused: true,
|
||||||
|
savedCursorX: math.NaN(),
|
||||||
|
savedCursorY: math.NaN(),
|
||||||
|
}
|
||||||
|
|
||||||
// docuemnt is undefined on node.js
|
// docuemnt is undefined on node.js
|
||||||
if !document.Truthy() {
|
if !document.Truthy() {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user