mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: SetScreenSize/Scale no longer returns error
This commit is contained in:
parent
b6b61fc003
commit
e11bc62059
@ -120,30 +120,30 @@ func (u *userInterface) runOnMainThread(f func() error) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenSize(width, height int) (bool, error) {
|
func SetScreenSize(width, height int) bool {
|
||||||
u := currentUI
|
u := currentUI
|
||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
return false, errors.New("ui: Run is not called yet")
|
panic("ui: Run is not called yet")
|
||||||
}
|
}
|
||||||
r := false
|
r := false
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
u.setScreenSize(width, height, u.scale)
|
u.setScreenSize(width, height, u.scale)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return r, nil
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenScale(scale float64) (bool, error) {
|
func SetScreenScale(scale float64) bool {
|
||||||
u := currentUI
|
u := currentUI
|
||||||
if !u.isRunning() {
|
if !u.isRunning() {
|
||||||
return false, errors.New("ui: Run is not called yet")
|
panic("ui: Run is not called yet")
|
||||||
}
|
}
|
||||||
r := false
|
r := false
|
||||||
_ = u.runOnMainThread(func() error {
|
_ = u.runOnMainThread(func() error {
|
||||||
u.setScreenSize(u.width, u.height, scale)
|
u.setScreenSize(u.width, u.height, scale)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return r, nil
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScreenScale() float64 {
|
func ScreenScale() float64 {
|
||||||
|
@ -43,13 +43,13 @@ func shown() bool {
|
|||||||
return !js.Global.Get("document").Get("hidden").Bool()
|
return !js.Global.Get("document").Get("hidden").Bool()
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenSize(width, height int) (bool, error) {
|
func SetScreenSize(width, height int) bool {
|
||||||
return currentUI.setScreenSize(width, height, currentUI.scale), nil
|
return currentUI.setScreenSize(width, height, currentUI.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenScale(scale float64) (bool, error) {
|
func SetScreenScale(scale float64) bool {
|
||||||
width, height := currentUI.size()
|
width, height := currentUI.size()
|
||||||
return currentUI.setScreenSize(width, height, scale), nil
|
return currentUI.setScreenSize(width, height, scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScreenScale() float64 {
|
func ScreenScale() float64 {
|
||||||
|
@ -98,14 +98,14 @@ func (u *userInterface) update(g GraphicsContext) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenSize(width, height int) (bool, error) {
|
func SetScreenSize(width, height int) bool {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return false, nil
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetScreenScale(scale float64) (bool, error) {
|
func SetScreenScale(scale float64) bool {
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return false, nil
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScreenScale() float64 {
|
func ScreenScale() float64 {
|
||||||
|
8
run.go
8
run.go
@ -119,9 +119,7 @@ func SetScreenSize(width, height int) {
|
|||||||
if width <= 0 || height <= 0 {
|
if width <= 0 || height <= 0 {
|
||||||
panic("ebiten: width and height must be positive")
|
panic("ebiten: width and height must be positive")
|
||||||
}
|
}
|
||||||
if _, err := ui.SetScreenSize(width, height); err != nil {
|
ui.SetScreenSize(width, height)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetScreenScale changes the scale of the screen.
|
// SetScreenScale changes the scale of the screen.
|
||||||
@ -131,9 +129,7 @@ func SetScreenScale(scale float64) {
|
|||||||
if scale <= 0 {
|
if scale <= 0 {
|
||||||
panic("ebiten: scale must be positive")
|
panic("ebiten: scale must be positive")
|
||||||
}
|
}
|
||||||
if _, err := ui.SetScreenScale(scale); err != nil {
|
ui.SetScreenScale(scale)
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScreenScale returns the current screen scale.
|
// ScreenScale returns the current screen scale.
|
||||||
|
Loading…
Reference in New Issue
Block a user