mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Android - Radar mode implemented.
This commit is contained in:
parent
b6ce3409d8
commit
e8312c72be
3 changed files with 1293 additions and 2 deletions
|
@ -20,6 +20,9 @@ var MODE_VR = "VR", MODE_RADAR = "RADAR", MODE_MY_VIEW = "MY VIEW";
|
|||
var DEFAULT_MODE = MODE_RADAR;
|
||||
var logEnabled = true;
|
||||
|
||||
var radar = Script.require('./radar.js');
|
||||
var uniqueColor = Script.require('./uniqueColor.js');
|
||||
|
||||
function printd(str) {
|
||||
if (logEnabled) {
|
||||
print("[modes.js] " + str);
|
||||
|
@ -27,7 +30,10 @@ function printd(str) {
|
|||
}
|
||||
|
||||
function init() {
|
||||
radar.setUniqueColor(uniqueColor);
|
||||
radar.init();
|
||||
setupModesBar();
|
||||
radar.isTouchValid = isRadarModeValidTouch;
|
||||
}
|
||||
|
||||
function shutdown() {
|
||||
|
@ -85,7 +91,7 @@ function setupModesBar() {
|
|||
saveCurrentModeSetting(MODE_RADAR);
|
||||
printd("Radar clicked");
|
||||
onButtonClicked(buttonRadarMode, function() {
|
||||
//radar.startRadarMode();
|
||||
radar.startRadarMode();
|
||||
});
|
||||
});
|
||||
buttonMyViewMode.clicked.connect(function() {
|
||||
|
@ -94,7 +100,7 @@ function setupModesBar() {
|
|||
printd("My View clicked");
|
||||
onButtonClicked(buttonMyViewMode, function() {
|
||||
if (currentSelectedBtn == buttonRadarMode) {
|
||||
//radar.endRadarMode();
|
||||
radar.endRadarMode();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -177,6 +183,33 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) {
|
|||
}
|
||||
}
|
||||
|
||||
function isRadarModeValidTouch(coords) {
|
||||
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
|
||||
) {
|
||||
printd("godViewModeTouchValid- 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
|
||||
) {
|
||||
printd("godViewModeTouchValid- false because of windows!?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
printd("godViewModeTouchValid- true by default ");
|
||||
return true;
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
shutdown();
|
||||
|
|
1212
scripts/system/+android/radar.js
Normal file
1212
scripts/system/+android/radar.js
Normal file
File diff suppressed because it is too large
Load diff
46
scripts/system/+android/uniqueColor.js
Normal file
46
scripts/system/+android/uniqueColor.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
"use strict";
|
||||
//
|
||||
// uniqueColor.js
|
||||
// scripts/system/
|
||||
//
|
||||
// Created by Gabriel Calero & Cristian Duarte on 17 Oct 2017
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
var colorsMap = {};
|
||||
var colorsCount = 0;
|
||||
// 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'magenta'
|
||||
var baseColors = [ '#EB3345', '#F0851F', '#FFCD29', '#94C338', '#11A6C5', '#294C9F', '#C01D84' ];
|
||||
|
||||
function getNextColor(n) {
|
||||
var N = baseColors.length;
|
||||
/*if (n < baseColors.length) {
|
||||
return baseColors[n];
|
||||
} else {
|
||||
var baseColor = baseColors[n % N];
|
||||
var d = (n / N) % 10;
|
||||
var c2 = "" + Qt.lighter(baseColor, 1 + d / 10);
|
||||
return c2;
|
||||
}*/
|
||||
return baseColors[n%N];
|
||||
}
|
||||
|
||||
function getColorForId(uuid) {
|
||||
if (colorsMap == undefined) {
|
||||
colorsMap = {};
|
||||
}
|
||||
if (!colorsMap.hasOwnProperty(uuid)) {
|
||||
colorsMap[uuid] = getNextColor(colorsCount);
|
||||
colorsCount = colorsCount + 1;
|
||||
}
|
||||
return colorsMap[uuid];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getColor: function(id) {
|
||||
return getColorForId(id);
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue