handle canViewAssetURLs better in create

This commit is contained in:
HifiExperiments 2024-03-17 21:28:38 -07:00
parent bf03847549
commit f3cb4e2ca9
5 changed files with 49 additions and 8 deletions

View file

@ -2023,6 +2023,7 @@ public:
// Don't substitute verify-fail: // Don't substitute verify-fail:
virtual const QUrl& getSkeletonModelURL() const override { return _skeletonModelURL; } 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); void debugDrawPose(controller::Action action, const char* channelName, float size);

View file

@ -1357,7 +1357,7 @@ public:
*/ */
Q_INVOKABLE virtual void detachAll(const QString& modelURL, const QString& jointName = QString()); 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 setSkeletonModelURLFromScript(const QString& skeletonModelString) { setSkeletonModelURL(QUrl(skeletonModelString)); }
void setOwningAvatarMixer(const QWeakPointer<Node>& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; } void setOwningAvatarMixer(const QWeakPointer<Node>& owningAvatarMixer) { _owningAvatarMixer = owningAvatarMixer; }

View file

@ -218,11 +218,17 @@ inline ScriptValue convertScriptValue(ScriptEngine* e, const AACube& v) { return
properties.setProperty(#P, V); \ properties.setProperty(#P, V); \
} }
#define COPY_PROPERTY_TO_QSCRIPTVALUE_IF_URL_PERMISSION(p, P) \ #define COPY_PROPERTY_TO_QSCRIPTVALUE_IF_URL_PERMISSION(p, P) \
if (nodeList->getThisNodeCanViewAssetURLs() && ((!returnNothingOnEmptyPropertyFlags && _desiredProperties.isEmpty()) || _desiredProperties.getHasProperty(p)) && \ if (((!returnNothingOnEmptyPropertyFlags && _desiredProperties.isEmpty()) || _desiredProperties.getHasProperty(p)) && \
(!skipDefaults || defaultEntityProperties._##P != _##P)) { \ (!skipDefaults || defaultEntityProperties._##P != _##P)) { \
ScriptValue V = convertScriptValue(engine, _##P); \ if (nodeList->getThisNodeCanViewAssetURLs()) { \
properties.setProperty(#P, V); \ ScriptValue V = convertScriptValue(engine, _##P); \
properties.setProperty(#P, V); \
} else { \
const QString emptyURL = ""; \
ScriptValue V = convertScriptValue(engine, emptyURL); \
properties.setProperty(#P, V); \
} \
} }
typedef QVector<glm::vec3> qVectorVec3; typedef QVector<glm::vec3> qVectorVec3;

View file

@ -2786,6 +2786,10 @@
} }
} }
} else if (data.type === "propertiesPageReady") { } else if (data.type === "propertiesPageReady") {
emitScriptEvent({
type: 'urlPermissionChanged',
canViewAssetURLs: Entities.canViewAssetURLs(),
});
updateSelections(true); updateSelections(true);
} else if (data.type === "tooltipsRequest") { } else if (data.type === "tooltipsRequest") {
emitScriptEvent({ emitScriptEvent({
@ -2901,6 +2905,13 @@
}); });
}); });
Entities.canViewAssetURLsChanged.connect((value) => {
emitScriptEvent({
type: 'urlPermissionChanged',
canViewAssetURLs: value,
});
});
createToolsWindow.webEventReceived.addListener(this, onWebEventReceived); createToolsWindow.webEventReceived.addListener(this, onWebEventReceived);
webView.webEventReceived.connect(this, onWebEventReceived); webView.webEventReceived.connect(this, onWebEventReceived);

View file

@ -303,6 +303,7 @@ const GROUPS = [
type: "string", type: "string",
propertyID: "zoneCompoundShapeURL", propertyID: "zoneCompoundShapeURL",
propertyName: "compoundShapeURL", // actual entity property name propertyName: "compoundShapeURL", // actual entity property name
placeholder: "URL",
}, },
{ {
label: "Flying Allowed", label: "Flying Allowed",
@ -318,6 +319,7 @@ const GROUPS = [
label: "Filter", label: "Filter",
type: "string", type: "string",
propertyID: "filterURL", propertyID: "filterURL",
placeholder: "URL",
} }
] ]
}, },
@ -417,6 +419,7 @@ const GROUPS = [
type: "string", type: "string",
propertyID: "skybox.url", propertyID: "skybox.url",
showPropertyRule: { "skyboxMode": "enabled" }, showPropertyRule: { "skyboxMode": "enabled" },
placeholder: "URL",
} }
] ]
}, },
@ -445,6 +448,7 @@ const GROUPS = [
type: "string", type: "string",
propertyID: "ambientLight.ambientURL", propertyID: "ambientLight.ambientURL",
showPropertyRule: { "ambientLightMode": "enabled" }, showPropertyRule: { "ambientLightMode": "enabled" },
placeholder: "URL",
}, },
{ {
type: "buttons", type: "buttons",
@ -626,6 +630,7 @@ const GROUPS = [
label: "Compound Shape", label: "Compound Shape",
type: "string", type: "string",
propertyID: "compoundShapeURL", propertyID: "compoundShapeURL",
placeholder: "URL",
}, },
{ {
label: "Use Original Pivot", label: "Use Original Pivot",
@ -636,6 +641,7 @@ const GROUPS = [
label: "Animation", label: "Animation",
type: "string", type: "string",
propertyID: "animation.url", propertyID: "animation.url",
placeholder: "URL",
}, },
{ {
label: "Play Automatically", label: "Play Automatically",
@ -749,6 +755,7 @@ const GROUPS = [
label: "Source", label: "Source",
type: "string", type: "string",
propertyID: "sourceUrl", propertyID: "sourceUrl",
placeholder: "URL",
}, },
{ {
label: "Source Resolution", label: "Source Resolution",
@ -870,6 +877,7 @@ const GROUPS = [
label: "Material URL", label: "Material URL",
type: "string", type: "string",
propertyID: "materialURL", propertyID: "materialURL",
placeholder: "URL",
}, },
{ {
label: "Material Data", label: "Material Data",
@ -1038,6 +1046,7 @@ const GROUPS = [
type: "string", type: "string",
propertyID: "particleCompoundShapeURL", propertyID: "particleCompoundShapeURL",
propertyName: "compoundShapeURL", propertyName: "compoundShapeURL",
placeholder: "URL",
}, },
{ {
label: "Emit Dimensions", label: "Emit Dimensions",
@ -1360,18 +1369,21 @@ const GROUPS = [
type: "string", type: "string",
propertyID: "xTextureURL", propertyID: "xTextureURL",
propertyName: "xTextureURL", propertyName: "xTextureURL",
placeholder: "URL",
}, },
{ {
label: "Y Texture URL", label: "Y Texture URL",
type: "string", type: "string",
propertyID: "yTextureURL", propertyID: "yTextureURL",
propertyName: "yTextureURL", propertyName: "yTextureURL",
placeholder: "URL",
}, },
{ {
label: "Z Texture URL", label: "Z Texture URL",
type: "string", type: "string",
propertyID: "zTextureURL", propertyID: "zTextureURL",
propertyName: "zTextureURL", propertyName: "zTextureURL",
placeholder: "URL",
}, },
] ]
}, },
@ -1828,6 +1840,7 @@ let currentSelections = [];
let createAppTooltip = new CreateAppTooltip(); let createAppTooltip = new CreateAppTooltip();
let currentSpaceMode = PROPERTY_SPACE_MODE.LOCAL; let currentSpaceMode = PROPERTY_SPACE_MODE.LOCAL;
let zonesList = []; let zonesList = [];
let canViewAssetURLs = false;
function createElementFromHTML(htmlString) { function createElementFromHTML(htmlString) {
let elTemplate = document.createElement('template'); let elTemplate = document.createElement('template');
@ -2497,7 +2510,7 @@ function createStringProperty(property, elProperty) {
let elInput = createElementFromHTML(` let elInput = createElementFromHTML(`
<input id="${elementID}" <input id="${elementID}"
type="text" type="text"
${propertyData.placeholder ? 'placeholder="' + propertyData.placeholder + '"' : ''} ${propertyData.placeholder ? 'placeholder="' + ((propertyData.placeholder === "URL" && !canViewAssetURLs) ? "You don't have permission to view this URL" : propertyData.placeholder) + '"' : ''}
${propertyData.readOnly ? 'readonly' : ''}/> ${propertyData.readOnly ? 'readonly' : ''}/>
`); `);
@ -4714,7 +4727,7 @@ function loaded() {
break; break;
case 'vec3rgb': case 'vec3rgb':
updateVectorMinMax(properties[property]); updateVectorMinMax(properties[property]);
break; break;
case 'rect': case 'rect':
updateRectMinMax(properties[property]); updateRectMinMax(properties[property]);
break; break;
@ -4727,6 +4740,16 @@ function loaded() {
} }
} else if (data.type === 'zoneListRequest') { } else if (data.type === 'zoneListRequest') {
zonesList = data.zones; 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";
}
});
} }
}); });