From f3cb4e2ca91d577bfa46ad1b6c0db6c1161f3d1b Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Sun, 17 Mar 2024 21:28:38 -0700 Subject: [PATCH] handle canViewAssetURLs better in create --- interface/src/avatar/MyAvatar.h | 1 + libraries/avatars/src/AvatarData.h | 2 +- .../entities/src/EntityItemPropertiesMacros.h | 16 +++++++---- scripts/system/create/edit.js | 11 ++++++++ .../html/js/entityProperties.js | 27 +++++++++++++++++-- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 4198deba84..4d498b6b12 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -2023,6 +2023,7 @@ public: // Don't substitute verify-fail: virtual const QUrl& getSkeletonModelURL() const override { return _skeletonModelURL; } + virtual QString getSkeletonModelURLFromScript() const override { return _skeletonModelURL.toString(); }; void debugDrawPose(controller::Action action, const char* channelName, float size); diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index d3bf8a3282..6bf1b4149e 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -1357,7 +1357,7 @@ public: */ Q_INVOKABLE virtual void detachAll(const QString& modelURL, const QString& jointName = QString()); - QString getSkeletonModelURLFromScript() const; + virtual QString getSkeletonModelURLFromScript() const; void setSkeletonModelURLFromScript(const QString& skeletonModelString) { setSkeletonModelURL(QUrl(skeletonModelString)); } void setOwningAvatarMixer(const QWeakPointer& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; } diff --git a/libraries/entities/src/EntityItemPropertiesMacros.h b/libraries/entities/src/EntityItemPropertiesMacros.h index a55e775f34..c7bcc84ab6 100644 --- a/libraries/entities/src/EntityItemPropertiesMacros.h +++ b/libraries/entities/src/EntityItemPropertiesMacros.h @@ -218,11 +218,17 @@ inline ScriptValue convertScriptValue(ScriptEngine* e, const AACube& v) { return properties.setProperty(#P, V); \ } -#define COPY_PROPERTY_TO_QSCRIPTVALUE_IF_URL_PERMISSION(p, P) \ - if (nodeList->getThisNodeCanViewAssetURLs() && ((!returnNothingOnEmptyPropertyFlags && _desiredProperties.isEmpty()) || _desiredProperties.getHasProperty(p)) && \ - (!skipDefaults || defaultEntityProperties._##P != _##P)) { \ - ScriptValue V = convertScriptValue(engine, _##P); \ - properties.setProperty(#P, V); \ +#define COPY_PROPERTY_TO_QSCRIPTVALUE_IF_URL_PERMISSION(p, P) \ + if (((!returnNothingOnEmptyPropertyFlags && _desiredProperties.isEmpty()) || _desiredProperties.getHasProperty(p)) && \ + (!skipDefaults || defaultEntityProperties._##P != _##P)) { \ + if (nodeList->getThisNodeCanViewAssetURLs()) { \ + ScriptValue V = convertScriptValue(engine, _##P); \ + properties.setProperty(#P, V); \ + } else { \ + const QString emptyURL = ""; \ + ScriptValue V = convertScriptValue(engine, emptyURL); \ + properties.setProperty(#P, V); \ + } \ } typedef QVector qVectorVec3; diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 449d1d8222..be1ba053ab 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -2786,6 +2786,10 @@ } } } else if (data.type === "propertiesPageReady") { + emitScriptEvent({ + type: 'urlPermissionChanged', + canViewAssetURLs: Entities.canViewAssetURLs(), + }); updateSelections(true); } else if (data.type === "tooltipsRequest") { emitScriptEvent({ @@ -2901,6 +2905,13 @@ }); }); + Entities.canViewAssetURLsChanged.connect((value) => { + emitScriptEvent({ + type: 'urlPermissionChanged', + canViewAssetURLs: value, + }); + }); + createToolsWindow.webEventReceived.addListener(this, onWebEventReceived); webView.webEventReceived.connect(this, onWebEventReceived); diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 8b594d85b5..dd8d67e24d 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -303,6 +303,7 @@ const GROUPS = [ type: "string", propertyID: "zoneCompoundShapeURL", propertyName: "compoundShapeURL", // actual entity property name + placeholder: "URL", }, { label: "Flying Allowed", @@ -318,6 +319,7 @@ const GROUPS = [ label: "Filter", type: "string", propertyID: "filterURL", + placeholder: "URL", } ] }, @@ -417,6 +419,7 @@ const GROUPS = [ type: "string", propertyID: "skybox.url", showPropertyRule: { "skyboxMode": "enabled" }, + placeholder: "URL", } ] }, @@ -445,6 +448,7 @@ const GROUPS = [ type: "string", propertyID: "ambientLight.ambientURL", showPropertyRule: { "ambientLightMode": "enabled" }, + placeholder: "URL", }, { type: "buttons", @@ -626,6 +630,7 @@ const GROUPS = [ label: "Compound Shape", type: "string", propertyID: "compoundShapeURL", + placeholder: "URL", }, { label: "Use Original Pivot", @@ -636,6 +641,7 @@ const GROUPS = [ label: "Animation", type: "string", propertyID: "animation.url", + placeholder: "URL", }, { label: "Play Automatically", @@ -749,6 +755,7 @@ const GROUPS = [ label: "Source", type: "string", propertyID: "sourceUrl", + placeholder: "URL", }, { label: "Source Resolution", @@ -870,6 +877,7 @@ const GROUPS = [ label: "Material URL", type: "string", propertyID: "materialURL", + placeholder: "URL", }, { label: "Material Data", @@ -1038,6 +1046,7 @@ const GROUPS = [ type: "string", propertyID: "particleCompoundShapeURL", propertyName: "compoundShapeURL", + placeholder: "URL", }, { label: "Emit Dimensions", @@ -1360,18 +1369,21 @@ const GROUPS = [ type: "string", propertyID: "xTextureURL", propertyName: "xTextureURL", + placeholder: "URL", }, { label: "Y Texture URL", type: "string", propertyID: "yTextureURL", propertyName: "yTextureURL", + placeholder: "URL", }, { label: "Z Texture URL", type: "string", propertyID: "zTextureURL", propertyName: "zTextureURL", + placeholder: "URL", }, ] }, @@ -1828,6 +1840,7 @@ let currentSelections = []; let createAppTooltip = new CreateAppTooltip(); let currentSpaceMode = PROPERTY_SPACE_MODE.LOCAL; let zonesList = []; +let canViewAssetURLs = false; function createElementFromHTML(htmlString) { let elTemplate = document.createElement('template'); @@ -2497,7 +2510,7 @@ function createStringProperty(property, elProperty) { let elInput = createElementFromHTML(` `); @@ -4714,7 +4727,7 @@ function loaded() { break; case 'vec3rgb': updateVectorMinMax(properties[property]); - break; + break; case 'rect': updateRectMinMax(properties[property]); break; @@ -4727,6 +4740,16 @@ function loaded() { } } else if (data.type === 'zoneListRequest') { zonesList = data.zones; + } else if (data.type === 'urlPermissionChanged') { + canViewAssetURLs = data.canViewAssetURLs; + Object.entries(properties).forEach(function ([propertyID, property]) { + if (property.data.placeholder && property.data.placeholder === "URL") { + if (!canViewAssetURLs) { + property.elInput.value = ""; + } + property.elInput.placeholder = canViewAssetURLs ? property.data.placeholder : "You don't have permission to view this URL"; + } + }); } });