mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Add user feedback on download process
This commit is contained in:
parent
d33ac21aaa
commit
090065ee34
3 changed files with 70 additions and 6 deletions
|
@ -97,6 +97,7 @@ Rectangle {
|
|||
element.unbind("click");
|
||||
element.bind("click", function(event) {
|
||||
console.log("Initiate Clara.io FBX file download for {uuid}");
|
||||
EventBridge.emitWebEvent("CLARA.IO DOWNLOAD");
|
||||
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
||||
return false;
|
||||
});'
|
||||
|
@ -154,6 +155,16 @@ Rectangle {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onWebEventReceived(event) {
|
||||
if (event === "CLARA.IO DOWNLOAD") {
|
||||
ApplicationInterface.addAssetToWorldInitiate();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
eventBridge.webEventReceived.connect(onWebEventReceived);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
|
@ -5348,13 +5348,41 @@ void Application::showAssetServerWidget(QString filePath) {
|
|||
startUpload(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Application::addAssetToWorldInitiate() {
|
||||
qCDebug(interfaceapp) << "Start downloading asset file";
|
||||
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
|
||||
"Downloading Asset", "Preparing asset for download", QMessageBox::Cancel, QMessageBox::NoButton);
|
||||
}
|
||||
|
||||
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
|
||||
}
|
||||
|
||||
void Application::onAssetToWorldMessageBoxClosed() {
|
||||
disconnect(_addAssetToWorldMessageBox);
|
||||
_addAssetToWorldMessageBox = nullptr;
|
||||
}
|
||||
|
||||
void Application::addAssetToWorldError(QString errorText) {
|
||||
_addAssetToWorldMessageBox->setProperty("title", "Error Downloading Asset");
|
||||
_addAssetToWorldMessageBox->setProperty("icon", OffscreenUi::ICON_CRITICAL);
|
||||
_addAssetToWorldMessageBox->setProperty("text", errorText);
|
||||
}
|
||||
|
||||
void Application::addAssetToWorld(QString filePath) {
|
||||
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
|
||||
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
_addAssetToWorldMessageBox->setProperty("text", "Downloading asset file");
|
||||
|
||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||
QString errorInfo = "Do not have permissions to write to asset server.";
|
||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||
addAssetToWorldError(errorInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5365,6 +5393,10 @@ void Application::addAssetToWorld(QString filePath) {
|
|||
}
|
||||
|
||||
void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
||||
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
||||
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
||||
|
@ -5381,7 +5413,7 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i
|
|||
QString errorInfo = "Too many copies of asset name: "
|
||||
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||
addAssetToWorldError(errorInfo);
|
||||
}
|
||||
request->deleteLater();
|
||||
});
|
||||
|
@ -5390,12 +5422,16 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i
|
|||
}
|
||||
|
||||
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
||||
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
||||
if (upload->getError() != AssetUpload::NoError) {
|
||||
QString errorInfo = "Could not upload asset to asset server.";
|
||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||
addAssetToWorldError(errorInfo);
|
||||
} else {
|
||||
addAssetToWorldSetMapping(mapping, hash);
|
||||
}
|
||||
|
@ -5415,12 +5451,16 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
|||
}
|
||||
|
||||
void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
|
||||
connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
|
||||
if (request->getError() != SetMappingRequest::NoError) {
|
||||
QString errorInfo = "Could not set asset mapping.";
|
||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||
addAssetToWorldError(errorInfo);
|
||||
} else {
|
||||
addAssetToWorldAddEntity(mapping);
|
||||
}
|
||||
|
@ -5431,6 +5471,10 @@ void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
|||
}
|
||||
|
||||
void Application::addAssetToWorldAddEntity(QString mapping) {
|
||||
if (!_addAssetToWorldMessageBox) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityItemProperties properties;
|
||||
properties.setType(EntityTypes::Model);
|
||||
properties.setName(mapping.right(mapping.length() - 1));
|
||||
|
@ -5444,11 +5488,13 @@ void Application::addAssetToWorldAddEntity(QString mapping) {
|
|||
if (result == QUuid()) {
|
||||
QString errorInfo = "Could not add downloaded asset " + mapping + " to world.";
|
||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
||||
addAssetToWorldError(errorInfo);
|
||||
} else {
|
||||
QString successInfo = "Downloaded asset " + mapping + " added to world";
|
||||
qCDebug(interfaceapp) << "Downloading asset completed: " + successInfo;
|
||||
OffscreenUi::information("Downloading Asset Completed", successInfo);
|
||||
_addAssetToWorldMessageBox->setProperty("text", "Downloading asset completed");
|
||||
_addAssetToWorldMessageBox->setProperty("buttons", QMessageBox::Ok);
|
||||
_addAssetToWorldMessageBox->setProperty("defaultButton", QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtQuick/QQuickItem>
|
||||
|
||||
#include <QtGui/QImage>
|
||||
|
||||
|
@ -309,6 +310,7 @@ public slots:
|
|||
void toggleLogDialog();
|
||||
void toggleRunningScriptsWidget() const;
|
||||
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
||||
Q_INVOKABLE void addAssetToWorldInitiate();
|
||||
void addAssetToWorld(QString filePath);
|
||||
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
||||
void addAssetToWorldUpload(QString path, QString mapping);
|
||||
|
@ -398,6 +400,8 @@ private slots:
|
|||
void updateDisplayMode();
|
||||
void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo);
|
||||
|
||||
void onAssetToWorldMessageBoxClosed();
|
||||
|
||||
private:
|
||||
static void initDisplay();
|
||||
void init();
|
||||
|
@ -615,6 +619,9 @@ private:
|
|||
model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() } ;
|
||||
gpu::TexturePointer _defaultSkyboxTexture;
|
||||
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
||||
|
||||
QQuickItem* _addAssetToWorldMessageBox{ nullptr };
|
||||
void Application::addAssetToWorldError(QString errorText);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue