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