mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
4ef3b3e804
commit
56358fd0c4
@ -287,7 +287,7 @@ func (g *game) Update(screen *ebiten.Image) error {
|
|||||||
msgR = "Press R key to switch the window resizable state (only for desktops)\n"
|
msgR = "Press R key to switch the window resizable state (only for desktops)\n"
|
||||||
}
|
}
|
||||||
fg := "Yes"
|
fg := "Yes"
|
||||||
if !ebiten.IsForeground() {
|
if !ebiten.IsFocused() {
|
||||||
fg = "No"
|
fg = "No"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ Press T key to switch TPS (ticks per second)
|
|||||||
Press D key to switch the window decoration (only for desktops)
|
Press D key to switch the window decoration (only for desktops)
|
||||||
Press L key to switch the window floating state (only for desktops)
|
Press L key to switch the window floating state (only for desktops)
|
||||||
%s
|
%s
|
||||||
IsForeground?: %s
|
IsFocused?: %s
|
||||||
Windows Position: (%d, %d)
|
Windows Position: (%d, %d)
|
||||||
Cursor: (%d, %d)
|
Cursor: (%d, %d)
|
||||||
TPS: Current: %0.2f / Max: %s
|
TPS: Current: %0.2f / Max: %s
|
||||||
|
@ -37,7 +37,7 @@ type UI interface {
|
|||||||
DeviceScaleFactor() float64
|
DeviceScaleFactor() float64
|
||||||
CursorMode() CursorMode
|
CursorMode() CursorMode
|
||||||
IsFullscreen() bool
|
IsFullscreen() bool
|
||||||
IsForeground() bool
|
IsFocused() bool
|
||||||
IsRunnableInBackground() bool
|
IsRunnableInBackground() bool
|
||||||
IsVsyncEnabled() bool
|
IsVsyncEnabled() bool
|
||||||
ScreenSizeInFullscreen() (int, int)
|
ScreenSizeInFullscreen() (int, int)
|
||||||
|
@ -416,17 +416,17 @@ 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 {
|
func (u *UserInterface) IsFocused() bool {
|
||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var foreground bool
|
var focused bool
|
||||||
_ = u.t.Call(func() error {
|
_ = u.t.Call(func() error {
|
||||||
foreground = u.window.GetAttrib(glfw.Focused) == glfw.True
|
focused = u.window.GetAttrib(glfw.Focused) == glfw.True
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return foreground
|
return focused
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||||
|
@ -76,8 +76,8 @@ func (u *UserInterface) IsFullscreen() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) IsForeground() bool {
|
func (u *UserInterface) IsFocused() bool {
|
||||||
return u.isForeground()
|
return u.isFocused()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
func (u *UserInterface) SetRunnableInBackground(runnableInBackground bool) {
|
||||||
@ -145,10 +145,10 @@ func (u *UserInterface) suspended() bool {
|
|||||||
if u.runnableInBackground {
|
if u.runnableInBackground {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !u.isForeground()
|
return !u.isFocused()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) isForeground() bool {
|
func (u *UserInterface) isFocused() bool {
|
||||||
if !document.Call("hasFocus").Bool() {
|
if !document.Call("hasFocus").Bool() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func (u *UserInterface) Update() error {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if !u.IsForeground() {
|
if !u.IsFocused() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ func (u *UserInterface) SetFullscreen(fullscreen bool) {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) IsForeground() bool {
|
func (u *UserInterface) IsFocused() bool {
|
||||||
u.m.Lock()
|
u.m.Lock()
|
||||||
fg := u.foreground
|
fg := u.foreground
|
||||||
u.m.Unlock()
|
u.m.Unlock()
|
||||||
|
10
run.go
10
run.go
@ -359,14 +359,14 @@ func SetFullscreen(fullscreen bool) {
|
|||||||
uiDriver().SetFullscreen(fullscreen)
|
uiDriver().SetFullscreen(fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsForeground returns a boolean value indicating whether
|
// IsFocused returns a boolean value indicating whether
|
||||||
// the game is in focus or in the foreground.
|
// the game is in focus or in the foreground.
|
||||||
//
|
//
|
||||||
// IsForeground will only return true if IsRunnableInBackground is false.
|
// IsFocused will only return true if IsRunnableInBackground is false.
|
||||||
//
|
//
|
||||||
// IsForeground is concurrent-safe.
|
// IsFocused is concurrent-safe.
|
||||||
func IsForeground() bool {
|
func IsFocused() bool {
|
||||||
return uiDriver().IsForeground()
|
return uiDriver().IsFocused()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRunnableInBackground returns a boolean value indicating whether
|
// IsRunnableInBackground returns a boolean value indicating whether
|
||||||
|
Loading…
Reference in New Issue
Block a user