fix scripts to use new API

This commit is contained in:
Brad Hefta-Gaub 2016-02-19 17:57:49 -08:00
parent 1fa6e294e7
commit 2810be8787
4 changed files with 18 additions and 21 deletions

View file

@ -158,10 +158,7 @@ Mouse.prototype.startRotateDrag = function() {
x: this.current.x,
y: this.current.y
};
this.cursorRestore = {
x: Window.getCursorPositionX(),
y: Window.getCursorPositionY()
};
this.cursorRestore = Reticle.getPosition();
}
Mouse.prototype.getDrag = function() {
@ -177,7 +174,7 @@ Mouse.prototype.getDrag = function() {
}
Mouse.prototype.restoreRotateCursor = function() {
Window.setCursorPosition(this.cursorRestore.x, this.cursorRestore.y);
Reticle.setPosition(this.cursorRestore);
this.current = {
x: this.rotateStart.x,
y: this.rotateStart.y

View file

@ -54,8 +54,8 @@ var velocity = { x: 0, y: 0, z: 0 };
var velocityVertical = 0;
var enabled = false;
var lastX = Window.getCursorPositionX();
var lastY = Window.getCursorPositionY();
var lastX = Reticle.getPosition().x;
var lastY = Reticle.getPosition().y;
var yawFromMouse = 0;
var pitchFromMouse = 0;
@ -109,8 +109,8 @@ function update(dt) {
}
if (enabled && Window.hasFocus()) {
var x = Window.getCursorPositionX();
var y = Window.getCursorPositionY();
var x = Reticle.getPosition().x;
var y = Reticle.getPosition().y;
yawFromMouse += ((x - lastX) * movementParameters.MOUSE_YAW_SCALE * movementParameters.MOUSE_SENSITIVITY);
pitchFromMouse += ((y - lastY) * movementParameters.MOUSE_PITCH_SCALE * movementParameters.MOUSE_SENSITIVITY);
@ -173,7 +173,7 @@ function scriptEnding() {
function resetCursorPosition() {
var newX = Window.x + Window.innerWidth / 2;
var newY = Window.y + Window.innerHeight / 2;
Window.setCursorPosition(newX, newY);
Reticle.setPosition({ x: newX, y: newY});
lastX = newX;
lastY = newY;
}
@ -194,7 +194,7 @@ function enable() {
for (var i = 0; i < CAPTURED_KEYS.length; i++) {
Controller.captureKeyEvents({ text: CAPTURED_KEYS[i] });
}
Window.setCursorVisible(false);
Reticle.setVisible(false);
Script.update.connect(update);
}
}
@ -205,7 +205,7 @@ function disable() {
for (var i = 0; i < CAPTURED_KEYS.length; i++) {
Controller.releaseKeyEvents({ text: CAPTURED_KEYS[i] });
}
Window.setCursorVisible(true);
Reticle.setVisible(true);
Script.update.disconnect(update);
}
}

View file

@ -281,8 +281,8 @@ CameraManager = function() {
that.mouseMoveEvent = function(event) {
if (that.enabled && that.mode != MODE_INACTIVE) {
var x = Window.getCursorPositionX();
var y = Window.getCursorPositionY();
var x = Reticle.getPosition().x;
var y = Reticle.getPosition().y;
if (!hasDragged) {
that.lastMousePosition.x = x;
that.lastMousePosition.y = y;
@ -337,7 +337,7 @@ CameraManager = function() {
}
if (updatePosition) {
Window.setCursorPosition(newX, newY);
Reticle.setPosition({ x: newX, y: newY});
}
that.lastMousePosition.x = newX;
@ -384,7 +384,7 @@ CameraManager = function() {
if (!that.enabled) return;
that.mode = MODE_INACTIVE;
Window.setCursorVisible(true);
Reticle.setVisible(true);
}

View file

@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var lastX = Window.getCursorPositionX();
var lastY = Window.getCursorPositionY();
var lastX = Reticle.getPosition().x;
var lastY = Reticle.getPosition().y;
var yawFromMouse = 0;
var pitchFromMouse = 0;
@ -121,9 +121,9 @@ var mouseLook = (function () {
function onScriptUpdate(dt) {
if (active && Window.hasFocus()) {
var x = Window.getCursorPositionX();
var x = Reticle.getPosition().x;
// I'm not sure why this + 0.5 is necessary?
var y = Window.getCursorPositionY() + 0.5;
var y = Reticle.getPosition().y; + 0.5;
yawFromMouse += ((x - lastX) * movementParameters.MOUSE_YAW_SCALE * movementParameters.MOUSE_SENSITIVITY);
pitchFromMouse += ((y - lastY) * movementParameters.MOUSE_PITCH_SCALE * movementParameters.MOUSE_SENSITIVITY);
@ -155,7 +155,7 @@ var mouseLook = (function () {
function resetCursorPosition() {
var newX = Window.x + Window.innerWidth / 2.0;
var newY = Window.y + Window.innerHeight / 2.0;
Window.setCursorPosition(newX, newY);
Reticle.setPosition({ x: newX, y: newY});
lastX = newX;
lastY = newY;
}