Fix calculating external resource paths

This commit is contained in:
David Rowe 2020-09-23 22:15:13 +12:00
parent ba7242f4dc
commit c6ba42b7d6
4 changed files with 16 additions and 10 deletions

View file

@ -68,7 +68,7 @@ bool TestScriptingInterface::loadTestScene(QString scene) {
}
static const QString TEST_ROOT = "https://raw.githubusercontent.com/hifi-archive/hifi_tests/master/";
static const QString TEST_BINARY_ROOT = NetworkingConstants::HF_CONTENT_CDN_URL + "/test_scene_data/";
static const QString TEST_BINARY_ROOT = NetworkingConstants::HF_CONTENT_CDN_URL + "test_scene_data/";
static const QString TEST_SCRIPTS_ROOT = TEST_ROOT + "scripts/";
static const QString TEST_SCENES_ROOT = TEST_ROOT + "scenes/";

View file

@ -45,11 +45,11 @@ namespace NetworkingConstants {
const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml");
// CDN URLs
const QString HF_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-content";
const QString HF_MPASSETS_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-mpassets";
const QString HF_PUBLIC_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-public";
const QString HF_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-content/";
const QString HF_MPASSETS_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-mpassets/";
const QString HF_PUBLIC_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-public/";
const QString HF_MARKETPLACE_CDN_HOSTNAME = "mpassets.highfidelity.com";
const QString VIRCADIA_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/us-e-1";
const QString VIRCADIA_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/us-e-1/";
#if USE_STABLE_GLOBAL_SERVICES
const QString ICE_SERVER_DEFAULT_HOSTNAME = "ice.vircadia.com";

View file

@ -2883,6 +2883,6 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS
}
}
QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath) {
return ExternalResource::getInstance()->getUrl(bucket, relativePath);
QString ScriptEngine::getExternalPath(ExternalResource::Bucket bucket, const QString& path) {
return ExternalResource::getInstance()->getUrl(bucket, path);
}

View file

@ -690,12 +690,18 @@ public:
* but this method will return the asset's current URL.)
* @function Script.getExternalPath
* @param {Script.ResourceBucket} bucket - The external resource bucket that the asset is in.
* @param {string} relativePath - The path within the external resource bucket where the asset is located.
* @param {string} path - The path within the external resource bucket where the asset is located.
* <p>Normally, this should start with a path or filename to be appended to the bucket URL.
* Alternatively, it can be a relative path starting with <code>./</code> or <code>../</code>, to navigate within the
* resource bucket's URL. Or it can be an absolute path starting with <code>/</code>, in which case the bucket's path
* is discarded when calculating the asset's URL.</p>
* @Returns {string} The URL of an external asset.
* @example <caption>Report the URL of a default particle.</caption>
* print(Script.getExternalPath(Script.ExternalPaths.Assets, "Bazaar/Assets/Textures/Defaults/Interface/default_particle.png"));
* @example <caption>Report the root directory where the Vircadia assets are located.</caption>
* print("Script.getExternalPath(Script.ExternalPaths.Assets, ""));
* print(Script.getExternalPath(Script.ExternalPaths.Assets, "."));
*/
Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& relativePath);
Q_INVOKABLE QString getExternalPath(ExternalResource::Bucket bucket, const QString& path);
public slots: