mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
uidriver/glfw: Use invalidPos instead of pointers
This commit is contained in:
parent
e463f9e611
commit
6cd0b44baa
@ -60,8 +60,8 @@ type UserInterface struct {
|
|||||||
initCursorVisible bool
|
initCursorVisible bool
|
||||||
initWindowDecorated bool
|
initWindowDecorated bool
|
||||||
initWindowResizable bool
|
initWindowResizable bool
|
||||||
initWindowPositionX *int
|
initWindowPositionX int
|
||||||
initWindowPositionY *int
|
initWindowPositionY int
|
||||||
initIconImages []image.Image
|
initIconImages []image.Image
|
||||||
|
|
||||||
reqWidth int
|
reqWidth int
|
||||||
@ -86,6 +86,8 @@ var (
|
|||||||
origPosY: invalidPos,
|
origPosY: invalidPos,
|
||||||
initCursorVisible: true,
|
initCursorVisible: true,
|
||||||
initWindowDecorated: true,
|
initWindowDecorated: true,
|
||||||
|
initWindowPositionX: invalidPos,
|
||||||
|
initWindowPositionY: invalidPos,
|
||||||
vsync: true,
|
vsync: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -271,27 +273,21 @@ func (u *UserInterface) setInitIconImages(iconImages []image.Image) {
|
|||||||
u.m.Unlock()
|
u.m.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) getInitWindowPosition() (int, int, bool) {
|
func (u *UserInterface) getInitWindowPosition() (int, int) {
|
||||||
u.m.RLock()
|
u.m.RLock()
|
||||||
defer u.m.RUnlock()
|
defer u.m.RUnlock()
|
||||||
if u.initWindowPositionX != nil && u.initWindowPositionY != nil {
|
if u.initWindowPositionX != invalidPos && u.initWindowPositionY != invalidPos {
|
||||||
return *u.initWindowPositionX, *u.initWindowPositionY, true
|
return u.initWindowPositionX, u.initWindowPositionY
|
||||||
}
|
}
|
||||||
return 0, 0, false
|
return invalidPos, invalidPos
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) setInitWindowPosition(x, y int) {
|
func (u *UserInterface) setInitWindowPosition(x, y int) {
|
||||||
u.m.Lock()
|
u.m.Lock()
|
||||||
defer u.m.Unlock()
|
defer u.m.Unlock()
|
||||||
|
|
||||||
if u.initWindowPositionX == nil {
|
u.initWindowPositionX = x
|
||||||
u.initWindowPositionX = new(int)
|
u.initWindowPositionY = y
|
||||||
}
|
|
||||||
if u.initWindowPositionY == nil {
|
|
||||||
u.initWindowPositionY = new(int)
|
|
||||||
}
|
|
||||||
*u.initWindowPositionX = x
|
|
||||||
*u.initWindowPositionY = y
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
|
func (u *UserInterface) ScreenSizeInFullscreen() (int, int) {
|
||||||
@ -691,8 +687,8 @@ func (u *UserInterface) run(width, height int, scale float64, title string, cont
|
|||||||
u.window.SetTitle(title)
|
u.window.SetTitle(title)
|
||||||
u.window.Show()
|
u.window.Show()
|
||||||
|
|
||||||
x, y, ok := u.getInitWindowPosition()
|
x, y := u.getInitWindowPosition()
|
||||||
if !ok {
|
if x == invalidPos || y == invalidPos {
|
||||||
x = mx + (v.Width-w)/2
|
x = mx + (v.Width-w)/2
|
||||||
y = my + (v.Height-h)/3
|
y = my + (v.Height-h)/3
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user