mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
Inform user if can't do Clara.io download because can't write to ATP
This commit is contained in:
parent
d546b69daf
commit
2b0529bcea
3 changed files with 81 additions and 17 deletions
|
@ -5530,17 +5530,24 @@ void Application::showAssetServerWidget(QString filePath) {
|
||||||
void Application::addAssetToWorldFromURL(QString url) {
|
void Application::addAssetToWorldFromURL(QString url) {
|
||||||
qInfo(interfaceapp) << "Download asset and add to world from" << url;
|
qInfo(interfaceapp) << "Download asset and add to world from" << url;
|
||||||
|
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
|
||||||
|
"Downloading Asset", "Downloading asset file " + url.section("filename=", 1, 1),
|
||||||
|
QMessageBox::Cancel, QMessageBox::NoButton);
|
||||||
|
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||||
|
QString errorInfo = "You do not have permissions to write to the Asset Server.";
|
||||||
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
|
addAssetToWorldError(errorInfo);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QUrl urlURL = QUrl(url);
|
QUrl urlURL = QUrl(url);
|
||||||
auto request = ResourceManager::createResourceRequest(nullptr, urlURL);
|
auto request = ResourceManager::createResourceRequest(nullptr, urlURL);
|
||||||
connect(request, &ResourceRequest::finished, this, &Application::addAssetToWorldFromURLRequestFinished);
|
connect(request, &ResourceRequest::finished, this, &Application::addAssetToWorldFromURLRequestFinished);
|
||||||
request->send();
|
request->send();
|
||||||
|
|
||||||
if (!_addAssetToWorldMessageBox) {
|
|
||||||
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
|
|
||||||
"Downloading Asset", "Downloading asset file " + url.section("filename=", 1, 1),
|
|
||||||
QMessageBox::Cancel, QMessageBox::NoButton);
|
|
||||||
}
|
|
||||||
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldFromURLRequestFinished() {
|
void Application::addAssetToWorldFromURLRequestFinished() {
|
||||||
|
@ -5598,8 +5605,9 @@ void Application::addAssetToWorld(QString filePath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test repeated because possibly different code paths.
|
||||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||||
QString errorInfo = "Do not have permissions to write to asset server.";
|
QString errorInfo = "You do not have permissions to write to the Asset Server.";
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
return;
|
return;
|
||||||
|
@ -5608,7 +5616,7 @@ void Application::addAssetToWorld(QString filePath) {
|
||||||
QString path = QUrl(filePath).toLocalFile();
|
QString path = QUrl(filePath).toLocalFile();
|
||||||
QString mapping = path.right(path.length() - path.lastIndexOf("/"));
|
QString mapping = path.right(path.length() - path.lastIndexOf("/"));
|
||||||
|
|
||||||
_addAssetToWorldMessageBox->setProperty("text", "Adding " + mapping.mid(1) + " to Asset Server.");
|
_addAssetToWorldMessageBox->setProperty("text", "Adding " + mapping.mid(1) + " to the Asset Server.");
|
||||||
|
|
||||||
addAssetToWorldWithNewMapping(path, mapping, 0);
|
addAssetToWorldWithNewMapping(path, mapping, 0);
|
||||||
}
|
}
|
||||||
|
@ -5656,7 +5664,7 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
||||||
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
||||||
if (upload->getError() != AssetUpload::NoError) {
|
if (upload->getError() != AssetUpload::NoError) {
|
||||||
QString errorInfo = "Could not upload asset to asset server.";
|
QString errorInfo = "Could not upload asset to the Asset Server.";
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,6 +12,15 @@
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
|
// Event bridge messages.
|
||||||
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
|
var GOTO_DIRECTORY = "GOTO_DIRECTORY";
|
||||||
|
var QUERY_CAN_WRITE_ASSETS = "QUERY_CAN_WRITE_ASSETS";
|
||||||
|
var CAN_WRITE_ASSETS = "CAN_WRITE_ASSETS";
|
||||||
|
var WARN_USER_NO_PERMISSIONS = "WARN_USER_NO_PERMISSIONS";
|
||||||
|
|
||||||
|
var canWriteAssets = false;
|
||||||
|
|
||||||
function injectCommonCode(isDirectoryPage) {
|
function injectCommonCode(isDirectoryPage) {
|
||||||
|
|
||||||
// Supporting styles from marketplaces.css.
|
// Supporting styles from marketplaces.css.
|
||||||
|
@ -54,7 +63,7 @@
|
||||||
window.history.back();
|
window.history.back();
|
||||||
});
|
});
|
||||||
$("#all-markets").on("click", function () {
|
$("#all-markets").on("click", function () {
|
||||||
EventBridge.emitWebEvent("GOTO_DIRECTORY");
|
EventBridge.emitWebEvent(GOTO_DIRECTORY);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +127,13 @@
|
||||||
|
|
||||||
// Automatic download to High Fidelity.
|
// Automatic download to High Fidelity.
|
||||||
var downloadTimer;
|
var downloadTimer;
|
||||||
function startAutoDownload() {
|
function startAutoDownload(event) {
|
||||||
|
if (!canWriteAssets) {
|
||||||
|
console.log("Clara.io FBX file download cancelled because no permissions to write to Asset Server");
|
||||||
|
EventBridge.emitWebEvent(WARN_USER_NO_PERMISSIONS);
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
window.scrollTo(0, 0); // Scroll to top ready for history.back().
|
window.scrollTo(0, 0); // Scroll to top ready for history.back().
|
||||||
if (!downloadTimer) {
|
if (!downloadTimer) {
|
||||||
downloadTimer = setInterval(autoDownload, 1000);
|
downloadTimer = setInterval(autoDownload, 1000);
|
||||||
|
@ -131,7 +146,7 @@
|
||||||
clearInterval(downloadTimer);
|
clearInterval(downloadTimer);
|
||||||
downloadTimer = null;
|
downloadTimer = null;
|
||||||
var href = downloadButton[0].href;
|
var href = downloadButton[0].href;
|
||||||
EventBridge.emitWebEvent("CLARA.IO DOWNLOAD " + href);
|
EventBridge.emitWebEvent(CLARA_IO_DOWNLOAD + " " + href);
|
||||||
console.log("Clara.io FBX file download initiated for " + href);
|
console.log("Clara.io FBX file download initiated for " + href);
|
||||||
$("a.btn.cancel").click();
|
$("a.btn.cancel").click();
|
||||||
history.back(); // Remove history item created by clicking "download".
|
history.back(); // Remove history item created by clicking "download".
|
||||||
|
@ -170,9 +185,18 @@
|
||||||
checkLocationInterval = undefined;
|
checkLocationInterval = undefined;
|
||||||
currentLocation = "";
|
currentLocation = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EventBridge.emitWebEvent(QUERY_CAN_WRITE_ASSETS);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
|
|
||||||
|
EventBridge.scriptEventReceived.connect(function (message) {
|
||||||
|
if (message.slice(0, CAN_WRITE_ASSETS.length) === CAN_WRITE_ASSETS) {
|
||||||
|
canWriteAssets = message.slice(-4) === "true";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var DIRECTORY = 0;
|
var DIRECTORY = 0;
|
||||||
var HIFI = 1;
|
var HIFI = 1;
|
||||||
var CLARA = 2;
|
var CLARA = 2;
|
||||||
|
|
|
@ -20,6 +20,14 @@ var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal in
|
||||||
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||||
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||||
|
|
||||||
|
// Event bridge messages.
|
||||||
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
|
var GOTO_DIRECTORY = "GOTO_DIRECTORY";
|
||||||
|
var QUERY_CAN_WRITE_ASSETS = "QUERY_CAN_WRITE_ASSETS";
|
||||||
|
var CAN_WRITE_ASSETS = "CAN_WRITE_ASSETS";
|
||||||
|
var WARN_USER_NO_PERMISSIONS = "WARN_USER_NO_PERMISSIONS";
|
||||||
|
var NO_PERMISSIONS_ERROR_MESSAGE = "Cannot download model because you can't write to \nthe domain's Asset Server.";
|
||||||
|
|
||||||
var marketplaceWindow = new OverlayWebWindow({
|
var marketplaceWindow = new OverlayWebWindow({
|
||||||
title: "Marketplace",
|
title: "Marketplace",
|
||||||
source: "about:blank",
|
source: "about:blank",
|
||||||
|
@ -28,10 +36,16 @@ var marketplaceWindow = new OverlayWebWindow({
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
marketplaceWindow.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
marketplaceWindow.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
marketplaceWindow.webEventReceived.connect(function (data) {
|
marketplaceWindow.webEventReceived.connect(function (message) {
|
||||||
if (data === "GOTO_DIRECTORY") {
|
if (message === GOTO_DIRECTORY) {
|
||||||
marketplaceWindow.setURL(MARKETPLACES_URL);
|
marketplaceWindow.setURL(MARKETPLACES_URL);
|
||||||
}
|
}
|
||||||
|
if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||||
|
marketplaceWindow.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||||
|
}
|
||||||
|
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||||
|
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var toolHeight = 50;
|
var toolHeight = 50;
|
||||||
|
@ -57,10 +71,16 @@ function showMarketplace() {
|
||||||
marketplaceWebTablet = new WebTablet(MARKETPLACE_URL_INITIAL, null, null, true);
|
marketplaceWebTablet = new WebTablet(MARKETPLACE_URL_INITIAL, null, null, true);
|
||||||
Settings.setValue(persistenceKey, marketplaceWebTablet.pickle());
|
Settings.setValue(persistenceKey, marketplaceWebTablet.pickle());
|
||||||
marketplaceWebTablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
marketplaceWebTablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
marketplaceWebTablet.getOverlayObject().webEventReceived.connect(function (data) {
|
marketplaceWebTablet.getOverlayObject().webEventReceived.connect(function (message) {
|
||||||
if (data === "GOTO_DIRECTORY") {
|
if (message === GOTO_DIRECTORY) {
|
||||||
marketplaceWebTablet.setURL(MARKETPLACES_URL);
|
marketplaceWebTablet.setURL(MARKETPLACES_URL);
|
||||||
}
|
}
|
||||||
|
if (message === QUERY_CAN_WRITE_ASSETS) {
|
||||||
|
marketplaceWebTablet.getOverlayObject().emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
|
||||||
|
}
|
||||||
|
if (message === WARN_USER_NO_PERMISSIONS) {
|
||||||
|
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
marketplaceWindow.setURL(MARKETPLACE_URL_INITIAL);
|
marketplaceWindow.setURL(MARKETPLACE_URL_INITIAL);
|
||||||
|
@ -123,12 +143,23 @@ function onMarketplaceWindowVisibilityChanged() {
|
||||||
marketplaceVisible = marketplaceWindow.visible;
|
marketplaceVisible = marketplaceWindow.visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onCanWriteAssetsChanged() {
|
||||||
|
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
|
||||||
|
if (marketplaceWindow.visible) {
|
||||||
|
marketplaceWindow.emitScriptEvent(message);
|
||||||
|
}
|
||||||
|
if (marketplaceWebTablet) {
|
||||||
|
marketplaceWebTablet.getOverlayObject().emitScriptEvent(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
toggleMarketplace();
|
toggleMarketplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
browseExamplesButton.clicked.connect(onClick);
|
browseExamplesButton.clicked.connect(onClick);
|
||||||
marketplaceWindow.visibleChanged.connect(onMarketplaceWindowVisibilityChanged);
|
marketplaceWindow.visibleChanged.connect(onMarketplaceWindowVisibilityChanged);
|
||||||
|
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||||
|
|
||||||
clearOldTablet(); // Run once at startup, in case there's anything laying around from a crash.
|
clearOldTablet(); // Run once at startup, in case there's anything laying around from a crash.
|
||||||
// We could also optionally do something like Window.domainChanged.connect(function () {Script.setTimeout(clearOldTablet, 2000)}),
|
// We could also optionally do something like Window.domainChanged.connect(function () {Script.setTimeout(clearOldTablet, 2000)}),
|
||||||
|
@ -138,6 +169,7 @@ Script.scriptEnding.connect(function () {
|
||||||
toolBar.removeButton("marketplace");
|
toolBar.removeButton("marketplace");
|
||||||
browseExamplesButton.clicked.disconnect(onClick);
|
browseExamplesButton.clicked.disconnect(onClick);
|
||||||
marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged);
|
marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged);
|
||||||
|
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||||
});
|
});
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue