Merge branch 'edit-entity-filter' of https://github.com/highfidelity/hifi into minimum-edit-entity-filter

This commit is contained in:
howard-stearns 2017-01-23 13:52:39 -08:00
commit 24a9cf1f23
7 changed files with 79 additions and 65 deletions

View file

@ -9,9 +9,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "AudioInjectorOptions.h"
#include <QScriptValueIterator>
#include <RegisteredMetaTypes.h> #include <RegisteredMetaTypes.h>
#include "AudioInjectorOptions.h" #include "AudioLogging.h"
AudioInjectorOptions::AudioInjectorOptions() : AudioInjectorOptions::AudioInjectorOptions() :
position(0.0f, 0.0f, 0.0f), position(0.0f, 0.0f, 0.0f),
@ -22,7 +26,7 @@ AudioInjectorOptions::AudioInjectorOptions() :
ambisonic(false), ambisonic(false),
ignorePenumbra(false), ignorePenumbra(false),
localOnly(false), localOnly(false),
secondOffset(0.0) secondOffset(0.0f)
{ {
} }
@ -40,31 +44,51 @@ QScriptValue injectorOptionsToScriptValue(QScriptEngine* engine, const AudioInje
} }
void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOptions& injectorOptions) { void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOptions& injectorOptions) {
if (object.property("position").isValid()) { if (!object.isObject()) {
qWarning() << "Audio injector options is not an object.";
return;
}
QScriptValueIterator it(object);
while (it.hasNext()) {
it.next();
if (it.name() == "position") {
vec3FromScriptValue(object.property("position"), injectorOptions.position); vec3FromScriptValue(object.property("position"), injectorOptions.position);
} } else if (it.name() == "orientation") {
if (object.property("volume").isValid()) {
injectorOptions.volume = object.property("volume").toNumber();
}
if (object.property("loop").isValid()) {
injectorOptions.loop = object.property("loop").toBool();
}
if (object.property("orientation").isValid()) {
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation); quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
} else if (it.name() == "volume") {
if (it.value().isNumber()) {
injectorOptions.volume = it.value().toNumber();
} else {
qCWarning(audio) << "Audio injector options: volume is not a number";
} }
} else if (it.name() == "loop") {
if (object.property("ignorePenumbra").isValid()) { if (it.value().isBool()) {
injectorOptions.ignorePenumbra = object.property("ignorePenumbra").toBool(); injectorOptions.loop = it.value().toBool();
} else {
qCWarning(audio) << "Audio injector options: loop is not a boolean";
} }
} else if (it.name() == "ignorePenumbra") {
if (object.property("localOnly").isValid()) { if (it.value().isBool()) {
injectorOptions.localOnly = object.property("localOnly").toBool(); injectorOptions.ignorePenumbra = it.value().toBool();
} else {
qCWarning(audio) << "Audio injector options: ignorePenumbra is not a boolean";
}
} else if (it.name() == "localOnly") {
if (it.value().isBool()) {
injectorOptions.localOnly = it.value().toBool();
} else {
qCWarning(audio) << "Audio injector options: localOnly is not a boolean";
}
} else if (it.name() == "secondOffset") {
if (it.value().isNumber()) {
injectorOptions.secondOffset = it.value().toNumber();
} else {
qCWarning(audio) << "Audio injector options: secondOffset is not a number";
}
} else {
qCWarning(audio) << "Unknown audio injector option:" << it.name();
} }
if (object.property("secondOffset").isValid()) {
injectorOptions.secondOffset = object.property("secondOffset").toNumber();
} }
} }

View file

@ -246,16 +246,16 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
} }
void RenderableWebEntityItem::setSourceUrl(const QString& value) { void RenderableWebEntityItem::setSourceUrl(const QString& value) {
if (_sourceUrl != value) { auto valueBeforeSuperclassSet = _sourceUrl;
qCDebug(entities) << "Setting web entity source URL to " << value;
_sourceUrl = value; WebEntityItem::setSourceUrl(value);
if (_webSurface) {
if (_sourceUrl != valueBeforeSuperclassSet && _webSurface) {
AbstractViewStateInterface::instance()->postLambdaEvent([this] { AbstractViewStateInterface::instance()->postLambdaEvent([this] {
_webSurface->getRootItem()->setProperty("url", _sourceUrl); _webSurface->getRootItem()->setProperty("url", _sourceUrl);
}); });
} }
} }
}
void RenderableWebEntityItem::setProxyWindow(QWindow* proxyWindow) { void RenderableWebEntityItem::setProxyWindow(QWindow* proxyWindow) {
if (_webSurface) { if (_webSurface) {

View file

@ -125,7 +125,14 @@ bool WebEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const g
void WebEntityItem::setSourceUrl(const QString& value) { void WebEntityItem::setSourceUrl(const QString& value) {
if (_sourceUrl != value) { if (_sourceUrl != value) {
_sourceUrl = value; auto newURL = QUrl::fromUserInput(value);
if (newURL.isValid()) {
_sourceUrl = newURL.toDisplayString();
qCDebug(entities) << "Changed web entity source URL to " << _sourceUrl;
} else {
qCDebug(entities) << "Clearing web entity source URL since" << value << "cannot be parsed to a valid URL.";
}
} }
} }

View file

@ -45,8 +45,6 @@ var DEFAULT_GRABBABLE_DATA = {
var ACTION_TTL = 10; // seconds var ACTION_TTL = 10; // seconds
var enabled = true;
function getTag() { function getTag() {
return "grab-" + MyAvatar.sessionUUID; return "grab-" + MyAvatar.sessionUUID;
} }
@ -321,7 +319,7 @@ Grabber.prototype.computeNewGrabPlane = function() {
} }
Grabber.prototype.pressEvent = function(event) { Grabber.prototype.pressEvent = function(event) {
if (!enabled) { if (isInEditMode()) {
return; return;
} }
@ -633,31 +631,10 @@ function keyReleaseEvent(event) {
grabber.keyReleaseEvent(event); grabber.keyReleaseEvent(event);
} }
function editEvent(channel, message, sender, localOnly) {
if (channel != "edit-events") {
return;
}
if (sender != MyAvatar.sessionUUID) {
return;
}
if (!localOnly) {
return;
}
try {
var data = JSON.parse(message);
if ("enabled" in data) {
enabled = !data["enabled"];
}
} catch(e) {
}
}
Controller.mousePressEvent.connect(pressEvent); Controller.mousePressEvent.connect(pressEvent);
Controller.mouseMoveEvent.connect(moveEvent); Controller.mouseMoveEvent.connect(moveEvent);
Controller.mouseReleaseEvent.connect(releaseEvent); Controller.mouseReleaseEvent.connect(releaseEvent);
Controller.keyPressEvent.connect(keyPressEvent); Controller.keyPressEvent.connect(keyPressEvent);
Controller.keyReleaseEvent.connect(keyReleaseEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent);
Messages.subscribe("edit-events");
Messages.messageReceived.connect(editEvent);
}()); // END LOCAL_SCOPE }()); // END LOCAL_SCOPE

View file

@ -493,11 +493,9 @@ function removeMyAvatarFromCollidesWith(origCollidesWith) {
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here, // If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode. // and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true; var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
var EDIT_SETTING = "io.highfidelity.isEditting";
function isEditing() { function isEditing() {
var actualSettingValue = Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING); return EXTERNALLY_MANAGED_2D_MINOR_MODE && isInEditMode();
return EXTERNALLY_MANAGED_2D_MINOR_MODE && actualSettingValue;
} }
function isIn2DMode() { function isIn2DMode() {
@ -849,6 +847,9 @@ function MyController(hand) {
}; };
this.setState = function(newState, reason) { this.setState = function(newState, reason) {
if (isInEditMode() && newState !== STATE_OFF && newState !== STATE_SEARCHING) {
return;
}
setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING)); setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING));
if (WANT_DEBUG || WANT_DEBUG_STATE) { if (WANT_DEBUG || WANT_DEBUG_STATE) {
var oldStateName = stateToName(this.state); var oldStateName = stateToName(this.state);

View file

@ -429,7 +429,6 @@ var toolBar = (function () {
}); });
}); });
that.setActive(false); that.setActive(false);
} }
@ -446,6 +445,7 @@ var toolBar = (function () {
}; };
that.setActive = function (active) { that.setActive = function (active) {
Settings.setValue(EDIT_SETTING, active);
if (active === isActive) { if (active === isActive) {
return; return;
} }
@ -457,7 +457,6 @@ var toolBar = (function () {
enabled: active enabled: active
})); }));
isActive = active; isActive = active;
Settings.setValue(EDIT_SETTING, active);
if (!isActive) { if (!isActive) {
entityListTool.setVisible(false); entityListTool.setVisible(false);
gridTool.setVisible(false); gridTool.setVisible(false);

View file

@ -6,6 +6,12 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
// note: this constant is currently duplicated in edit.js
EDIT_SETTING = "io.highfidelity.isEditting";
isInEditMode = function isInEditMode() {
return Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
};
if (!Function.prototype.bind) { if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) { Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') { if (typeof this !== 'function') {