mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
6eb05a0203
commit
6686044452
@ -37,6 +37,7 @@ type UI interface {
|
||||
DeviceScaleFactor() float64
|
||||
CursorMode() CursorMode
|
||||
IsFullscreen() bool
|
||||
IsForeground() bool
|
||||
IsRunnableInBackground() bool
|
||||
IsVsyncEnabled() bool
|
||||
ScreenSizeInFullscreen() (int, int)
|
||||
|
@ -402,6 +402,19 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
||||
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) {
|
||||
u.setRunnableInBackground(runnableInBackground)
|
||||
}
|
||||
|
@ -76,6 +76,11 @@ func (u *UserInterface) IsFullscreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsForeground() bool {
|
||||
// TODO: implement this
|
||||
return true
|
||||
}
|
||||
|
||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||
u.runnableInBackground = runnableInBackground
|
||||
}
|
||||
|
@ -369,6 +369,11 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsForeground() {
|
||||
// TODO: implement this
|
||||
return true
|
||||
}
|
||||
|
||||
func (u *UserInterface) IsRunnableInBackground() bool {
|
||||
return false
|
||||
}
|
||||
|
10
run.go
10
run.go
@ -346,6 +346,16 @@ func SetFullscreen(fullscreen bool) {
|
||||
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
|
||||
// the game runs even in background.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user