mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
parent
6eb05a0203
commit
6686044452
@ -37,6 +37,7 @@ type UI interface {
|
|||||||
DeviceScaleFactor() float64
|
DeviceScaleFactor() float64
|
||||||
CursorMode() CursorMode
|
CursorMode() CursorMode
|
||||||
IsFullscreen() bool
|
IsFullscreen() bool
|
||||||
|
IsForeground() bool
|
||||||
IsRunnableInBackground() bool
|
IsRunnableInBackground() bool
|
||||||
IsVsyncEnabled() bool
|
IsVsyncEnabled() bool
|
||||||
ScreenSizeInFullscreen() (int, int)
|
ScreenSizeInFullscreen() (int, int)
|
||||||
|
@ -402,6 +402,19 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
|||||||
u.setWindowSize(w, h, fullscreen, u.vsync)
|
u.setWindowSize(w, h, fullscreen, u.vsync)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) IsForeground() bool {
|
||||||
|
if !u.isRunning() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var foreground bool
|
||||||
|
_ = u.t.Call(func() error {
|
||||||
|
foreground = u.window.GetAttrib(glfw.Focused) == glfw.True
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return foreground
|
||||||
|
}
|
||||||
|
|
||||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||||
u.setRunnableInBackground(runnableInBackground)
|
u.setRunnableInBackground(runnableInBackground)
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,11 @@ func (u *UserInterface) IsFullscreen() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) IsForeground() bool {
|
||||||
|
// TODO: implement this
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||||
u.runnableInBackground = runnableInBackground
|
u.runnableInBackground = runnableInBackground
|
||||||
}
|
}
|
||||||
|
@ -369,6 +369,11 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) IsForeground() {
|
||||||
|
// TODO: implement this
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (u *UserInterface) IsRunnableInBackground() bool {
|
func (u *UserInterface) IsRunnableInBackground() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
10
run.go
10
run.go
@ -346,6 +346,16 @@ func SetFullscreen(fullscreen bool) {
|
|||||||
uiDriver().SetFullscreen(fullscreen)
|
uiDriver().SetFullscreen(fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsForeground returns a boolean value indicating whether
|
||||||
|
// the game is in focus or in the foreground.
|
||||||
|
//
|
||||||
|
// IsForeground will only return true if IsRunnableInBackground is false.
|
||||||
|
//
|
||||||
|
// IsForeground is concurrent-safe.
|
||||||
|
func IsForeground() bool {
|
||||||
|
return uiDriver().IsForeground()
|
||||||
|
}
|
||||||
|
|
||||||
// IsRunnableInBackground returns a boolean value indicating whether
|
// IsRunnableInBackground returns a boolean value indicating whether
|
||||||
// the game runs even in background.
|
// the game runs even in background.
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user