mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
parent
3fe59e75cb
commit
72d5002e72
@ -19,10 +19,6 @@ import (
|
||||
)
|
||||
|
||||
func impl(x, y int) float64 {
|
||||
if go2cpp := js.Global().Get("go2cpp"); go2cpp.Truthy() {
|
||||
return go2cpp.Get("devicePixelRatio").Float()
|
||||
}
|
||||
|
||||
window := js.Global().Get("window")
|
||||
if !window.Truthy() {
|
||||
return 1
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
|
||||
var (
|
||||
object = js.Global().Get("Object")
|
||||
go2cpp = js.Global().Get("go2cpp")
|
||||
)
|
||||
|
||||
type nativeGamepadsImpl struct {
|
||||
@ -38,7 +37,7 @@ func (g *nativeGamepadsImpl) init(gamepads *gamepads) error {
|
||||
}
|
||||
|
||||
func (g *nativeGamepadsImpl) update(gamepads *gamepads) error {
|
||||
// TODO: Use the gamepad events instead of navigator.getGamepads after go2cpp is removed.
|
||||
// TODO: Use the gamepad events instead of navigator.getGamepads.
|
||||
|
||||
defer func() {
|
||||
for k := range g.indices {
|
||||
@ -112,10 +111,6 @@ type nativeGamepadImpl struct {
|
||||
}
|
||||
|
||||
func (g *nativeGamepadImpl) hasOwnStandardLayoutMapping() bool {
|
||||
// With go2cpp, the controller must have the standard
|
||||
if go2cpp.Truthy() {
|
||||
return true
|
||||
}
|
||||
return g.mapping == "standard"
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy() || js.Global().Get("go2cpp").Truthy())
|
||||
webGL2MightBeAvailable = !forceWebGL1 && (js.Global().Get("WebGL2RenderingContext").Truthy())
|
||||
)
|
||||
|
||||
func uint8ArrayToSlice(value js.Value, length int) []byte {
|
||||
@ -152,9 +152,6 @@ func (c *context) initGL() error {
|
||||
if !gl.Truthy() {
|
||||
return fmt.Errorf("opengl: getContext failed")
|
||||
}
|
||||
} else if go2cpp := js.Global().Get("go2cpp"); go2cpp.Truthy() {
|
||||
gl = go2cpp.Get("gl")
|
||||
c.webGLVersion = webGLVersion2
|
||||
}
|
||||
|
||||
c.gl = c.newGL(gl)
|
||||
|
@ -277,29 +277,6 @@ func (in *Input) updateTouchesFromEvent(e js.Value) {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Input) updateForGo2Cpp() {
|
||||
if !go2cpp.Truthy() {
|
||||
return
|
||||
}
|
||||
|
||||
for k := range i.touches {
|
||||
delete(i.touches, k)
|
||||
}
|
||||
touchCount := go2cpp.Get("touchCount").Int()
|
||||
for idx := 0; idx < touchCount; idx++ {
|
||||
id := go2cpp.Call("getTouchId", idx)
|
||||
x := go2cpp.Call("getTouchX", idx)
|
||||
y := go2cpp.Call("getTouchY", idx)
|
||||
if i.touches == nil {
|
||||
i.touches = map[TouchID]pos{}
|
||||
}
|
||||
i.touches[TouchID(id.Int())] = pos{
|
||||
X: x.Int(),
|
||||
Y: y.Int(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isKeyString(str string) bool {
|
||||
// From https://www.w3.org/TR/uievents-key/#keys-unicode,
|
||||
//
|
||||
|
@ -100,7 +100,6 @@ var (
|
||||
canvas js.Value
|
||||
requestAnimationFrame = js.Global().Get("requestAnimationFrame")
|
||||
setTimeout = js.Global().Get("setTimeout")
|
||||
go2cpp = js.Global().Get("go2cpp")
|
||||
)
|
||||
|
||||
var (
|
||||
@ -109,9 +108,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
if go2cpp.Truthy() {
|
||||
return
|
||||
}
|
||||
documentHasFocus = document.Get("hasFocus").Call("bind", document)
|
||||
documentHidden = js.Global().Get("Object").Call("getOwnPropertyDescriptor", js.Global().Get("Document").Get("prototype"), "hidden").Get("get").Call("bind", document)
|
||||
}
|
||||
@ -238,20 +234,15 @@ func (u *userInterfaceImpl) DeviceScaleFactor() float64 {
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) outsideSize() (float64, float64) {
|
||||
switch {
|
||||
case document.Truthy():
|
||||
if document.Truthy() {
|
||||
body := document.Get("body")
|
||||
bw := body.Get("clientWidth").Float()
|
||||
bh := body.Get("clientHeight").Float()
|
||||
return bw, bh
|
||||
case go2cpp.Truthy():
|
||||
w := go2cpp.Get("screenWidth").Float()
|
||||
h := go2cpp.Get("screenHeight").Float()
|
||||
return w, h
|
||||
default:
|
||||
// Node.js
|
||||
return 640, 480
|
||||
}
|
||||
|
||||
// Node.js
|
||||
return 640, 480
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) suspended() bool {
|
||||
@ -262,10 +253,6 @@ func (u *userInterfaceImpl) suspended() bool {
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) isFocused() bool {
|
||||
if go2cpp.Truthy() {
|
||||
return true
|
||||
}
|
||||
|
||||
if !documentHasFocus.Invoke().Bool() {
|
||||
return false
|
||||
}
|
||||
@ -294,7 +281,6 @@ func (u *userInterfaceImpl) updateImpl(force bool) error {
|
||||
if err := gamepad.Update(); err != nil {
|
||||
return err
|
||||
}
|
||||
u.input.updateForGo2Cpp()
|
||||
|
||||
a := u.DeviceScaleFactor()
|
||||
if u.lastDeviceScaleFactor != a {
|
||||
@ -618,15 +604,12 @@ func (u *userInterfaceImpl) Run(game Game) error {
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) updateScreenSize() {
|
||||
switch {
|
||||
case document.Truthy():
|
||||
if document.Truthy() {
|
||||
body := document.Get("body")
|
||||
bw := int(body.Get("clientWidth").Float() * u.DeviceScaleFactor())
|
||||
bh := int(body.Get("clientHeight").Float() * u.DeviceScaleFactor())
|
||||
canvas.Set("width", bw)
|
||||
canvas.Set("height", bh)
|
||||
case go2cpp.Truthy():
|
||||
// TODO: Implement this
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user