Prevent Go To and Avatar windows to move Radar Mode's camera when touched or interacted with

This commit is contained in:
Cristian Duarte 2018-03-20 17:24:38 -03:00
parent 47437c9564
commit 0d6bfada40
5 changed files with 86 additions and 11 deletions

View file

@ -14,9 +14,10 @@
var DEFAULT_SCRIPTS_COMBINED = [
"system/progress.js",
"system/+android/touchscreenvirtualpad.js",
"system/+android/audio.js",
"system/+android/androidCombined.js"/*,
"system/+android/bottombar.js",
"system/+android/audio.js" ,
"system/+android/modes.js"/*,
"system/+android/modes.js",
"system/away.js",
"system/controllers/controllerDisplayManager.js",
"system/controllers/handControllerGrabAndroid.js",

View file

@ -0,0 +1,24 @@
"use strict";
//
// androidCombined.js
// scripts/system/
//
// Created by Gabriel Calero & Cristian Duarte on Mar 20, 2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function() { // BEGIN LOCAL_SCOPE
var modesInterface = Script.require('./modes.js');
var bottombarInterface = Script.require('./bottombar.js');
function init() {
modesInterface.isRadarModeValidTouch = bottombarInterface.isRadarModeValidTouch;// set new function
}
init();
}()); // END LOCAL_SCOPE

View file

@ -35,6 +35,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
break;
case 'hide':
Controller.setVPadHidden(false);
module.exports.hide();
module.exports.onHidden();
break;
default:

View file

@ -21,7 +21,9 @@ var loginBtn;
var gotoScript = Script.require('./goto.js');
var avatarSelection = Script.require('./avatarSelection.js');
var logEnabled = false;
var bottombarInterface = [];
var logEnabled = true;
function printd(str) {
if (logEnabled) {
@ -262,6 +264,40 @@ Script.scriptEnding.connect(function () {
GlobalServices.disconnected.disconnect(handleLogout);
});
function isRadarModeValidTouch(coords) {
var qmlFragments = [bottombar, bottomHudOptionsBar.qmlFragment];
var windows = [gotoScript, avatarSelection];
for (var i=0; i < qmlFragments.length; i++) {
var aQmlFrag = qmlFragments[i];
if (aQmlFrag != null && aQmlFrag.isVisible() &&
coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x &&
coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y
) {
printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i);
return false;
}
}
for (var i=0; i < windows.length; i++) {
var aWin = windows[i];
if (aWin != null && aWin.position() != null && aWin.isVisible() &&
coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() &&
coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height()
) {
printd("isRadarModeValidTouch- false because of windows!? idx " + i);
return false;
} else {
printd("isRadarModeValidTouch- discarded of window idx " + i + " visible= " + aWin.isVisible());
}
}
printd("isRadarModeValidTouch- true by default ");
return true;
}
bottombarInterface.isRadarModeValidTouch = isRadarModeValidTouch;
module.exports = bottombarInterface;
init();
}()); // END LOCAL_SCOPE

View file

@ -23,6 +23,8 @@ var logEnabled = true;
var radar = Script.require('./radar.js');
var uniqueColor = Script.require('./uniqueColor.js');
var modesInterface = {};
function printd(str) {
if (logEnabled) {
print("[modes.js] " + str);
@ -184,33 +186,44 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) {
}
function isRadarModeValidTouch(coords) {
if (!modesInterface.isRadarModeValidTouch(coords)) {
printd("isRadarModeValidTouch- false because of modesInterface");
return false;
}
printd("isRadarModeValidTouch- modesInterface is true, evaluating modesbar qmls..");
var qmlFragments = [modesbar.qmlFragment];
var windows = [];
for (var i=0; i < qmlFragments.length; i++) {
var aQmlFrag = qmlFragments[i];
if (aQmlFrag != null && aQmlFrag.isVisible() &&
coords.x >= aQmlFrag.position.x * 3 && coords.x <= aQmlFrag.position.x * 3 + aQmlFrag.size.x * 3 &&
coords.y >= aQmlFrag.position.y * 3 && coords.y <= aQmlFrag.position.y * 3 + aQmlFrag.size.y * 3
coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x &&
coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y
) {
printd("godViewModeTouchValid- false because of qmlFragments!? idx " + i);
printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i);
return false;
}
}
for (var i=0; i < windows.length; i++) {
var aWin = windows[i];
if (aWin != null && aWin.position() != null &&
coords.x >= aWin.position().x * 3 && coords.x <= aWin.position().x * 3 + aWin.width() * 3 &&
coords.y >= aWin.position().y * 3 && coords.y <= aWin.position().y * 3 + aWin.height() * 3
if (aWin != null && aWin.position() != null && aWin.isVisible() &&
coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() &&
coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height()
) {
printd("godViewModeTouchValid- false because of windows!?");
printd("isRadarModeValidTouch- false because of windows!? idx " + i);
return false;
}
}
printd("godViewModeTouchValid- true by default ");
printd("isRadarModeValidTouch- true by default ");
return true;
}
// default
modesInterface.isRadarModeValidTouch = function(coords) {return true;};
module.exports = modesInterface;
Script.scriptEnding.connect(function () {
shutdown();
});