mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +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() {
|
||||
// Lock the main thread.
|
||||
runtime.LockOSThread()
|
||||
|
||||
theUI.userInterfaceImpl = userInterfaceImpl{
|
||||
runnableOnUnfocused: true,
|
||||
minWindowWidthInDIP: glfw.DontCare,
|
||||
@ -140,9 +143,7 @@ func init() {
|
||||
savedCursorY: math.NaN(),
|
||||
}
|
||||
theUI.iwindow.ui = &theUI.userInterfaceImpl
|
||||
}
|
||||
|
||||
func init() {
|
||||
hideConsoleWindowOnWindows()
|
||||
|
||||
if err := initialize(); err != nil {
|
||||
@ -869,11 +870,6 @@ func (u *userInterfaceImpl) DeviceScaleFactor() float64 {
|
||||
return f
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Lock the main thread.
|
||||
runtime.LockOSThread()
|
||||
}
|
||||
|
||||
// createWindow creates a GLFW window.
|
||||
//
|
||||
// createWindow must be called from the main thread.
|
||||
|
@ -116,14 +116,6 @@ type userInterfaceImpl struct {
|
||||
dropFileM sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
theUI.userInterfaceImpl = userInterfaceImpl{
|
||||
runnableOnUnfocused: true,
|
||||
savedCursorX: math.NaN(),
|
||||
savedCursorY: math.NaN(),
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
window = js.Global().Get("window")
|
||||
document = js.Global().Get("document")
|
||||
@ -133,14 +125,9 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
documentHasFocus js.Value
|
||||
documentHidden js.Value
|
||||
)
|
||||
|
||||
func init() {
|
||||
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) {
|
||||
return window.Get("innerWidth").Int(), window.Get("innerHeight").Int()
|
||||
@ -485,6 +472,12 @@ func (u *userInterfaceImpl) loop(game Game) <-chan error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
theUI.userInterfaceImpl = userInterfaceImpl{
|
||||
runnableOnUnfocused: true,
|
||||
savedCursorX: math.NaN(),
|
||||
savedCursorY: math.NaN(),
|
||||
}
|
||||
|
||||
// docuemnt is undefined on node.js
|
||||
if !document.Truthy() {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user