mirror of
https://github.com/lubosz/overte.git
synced 2025-08-13 06:14:12 +02:00
Ported an some currently not used code
This commit is contained in:
parent
2e930b823c
commit
616f15864a
1 changed files with 88 additions and 50 deletions
|
@ -47,6 +47,37 @@ void ATPAssetMigrator::loadEntityServerFile() {
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
qCDebug(asset_migrator) << "Selected filename for ATP asset migration: " << filename;
|
qCDebug(asset_migrator) << "Selected filename for ATP asset migration: " << filename;
|
||||||
|
|
||||||
|
auto migrateResources = [=](QUrl migrationURL, QJsonValueRef jsonValue, bool isModelURL) {
|
||||||
|
auto request =
|
||||||
|
DependencyManager::get<ResourceManager>()->createResourceRequest(this, migrationURL);
|
||||||
|
|
||||||
|
if (request) {
|
||||||
|
qCDebug(asset_migrator) << "Requesting" << migrationURL << "for ATP asset migration";
|
||||||
|
|
||||||
|
// add this combination of QUrl and QJsonValueRef to our multi hash so we can change the URL
|
||||||
|
// to an ATP one once ready
|
||||||
|
_pendingReplacements.insert(migrationURL, { jsonValue, (isModelURL ? 0 : 1)});
|
||||||
|
|
||||||
|
connect(request, &ResourceRequest::finished, this, [=]() {
|
||||||
|
if (request->getResult() == ResourceRequest::Success) {
|
||||||
|
migrateResource(request);
|
||||||
|
} else {
|
||||||
|
++_errorCount;
|
||||||
|
_pendingReplacements.remove(migrationURL);
|
||||||
|
qWarning() << "Could not retrieve asset at" << migrationURL.toString();
|
||||||
|
|
||||||
|
checkIfFinished();
|
||||||
|
}
|
||||||
|
request->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
|
request->send();
|
||||||
|
} else {
|
||||||
|
++_errorCount;
|
||||||
|
qWarning() << "Count not create request for asset at" << migrationURL.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
static const QString MIGRATION_CONFIRMATION_TEXT {
|
static const QString MIGRATION_CONFIRMATION_TEXT {
|
||||||
"The ATP Asset Migration process will scan the selected entity-server file,\nupload discovered resources to the"\
|
"The ATP Asset Migration process will scan the selected entity-server file,\nupload discovered resources to the"\
|
||||||
" current asset-server\nand then save a new entity-server file with the ATP URLs.\n\nAre you ready to"\
|
" current asset-server\nand then save a new entity-server file with the ATP URLs.\n\nAre you ready to"\
|
||||||
|
@ -54,7 +85,6 @@ void ATPAssetMigrator::loadEntityServerFile() {
|
||||||
};
|
};
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
|
||||||
QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) {
|
QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr);
|
QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr);
|
||||||
|
@ -105,44 +135,52 @@ void ATPAssetMigrator::loadEntityServerFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonValue = entityObject;
|
jsonValue = entityObject;
|
||||||
} else if (wantsToMigrateResource(migrationURL)) {
|
|
||||||
auto request =
|
|
||||||
DependencyManager::get<ResourceManager>()->createResourceRequest(this, migrationURL);
|
|
||||||
|
|
||||||
if (request) {
|
|
||||||
qCDebug(asset_migrator) << "Requesting" << migrationURL << "for ATP asset migration";
|
|
||||||
|
|
||||||
// add this combination of QUrl and QJsonValueRef to our multi hash so we can change the URL
|
|
||||||
// to an ATP one once ready
|
|
||||||
_pendingReplacements.insert(migrationURL, { jsonValue, (isModelURL ? 0 : 1)});
|
|
||||||
|
|
||||||
connect(request, &ResourceRequest::finished, this, [=]() {
|
|
||||||
if (request->getResult() == ResourceRequest::Success) {
|
|
||||||
migrateResource(request);
|
|
||||||
} else {
|
} else {
|
||||||
++_errorCount;
|
|
||||||
_pendingReplacements.remove(migrationURL);
|
|
||||||
qWarning() << "Could not retrieve asset at" << migrationURL.toString();
|
|
||||||
|
|
||||||
checkIfFinished();
|
static bool hasAskedForCompleteMigration { false };
|
||||||
}
|
static bool wantsCompleteMigration { false };
|
||||||
request->deleteLater();
|
|
||||||
});
|
|
||||||
|
|
||||||
request->send();
|
if (!hasAskedForCompleteMigration) {
|
||||||
|
// this is the first resource migration - ask the user if they just want to migrate everything
|
||||||
|
static const QString COMPLETE_MIGRATION_TEXT { "Do you want to migrate all assets found in this entity-server file?\n"\
|
||||||
|
"Select \"Yes\" to upload all discovered assets to the current asset-server immediately.\n"\
|
||||||
|
"Select \"No\" to be prompted for each discovered asset."
|
||||||
|
};
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr);
|
||||||
|
if (answer == QMessageBox::Yes) {
|
||||||
|
wantsCompleteMigration = true;
|
||||||
|
migrateResources(migrationURL, jsonValue, isModelURL);
|
||||||
} else {
|
} else {
|
||||||
++_errorCount;
|
QObject::connect(offscreenUi.data(), &OffscreenUi::response, this, [=] (QMessageBox::StandardButton answer) {
|
||||||
qWarning() << "Count not create request for asset at" << migrationURL.toString();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
}
|
QObject::disconnect(offscreenUi.data(), &OffscreenUi::response, this, nullptr);
|
||||||
|
if (answer == QMessageBox::Yes) {
|
||||||
|
migrateResources(migrationURL, jsonValue, isModelURL);
|
||||||
} else {
|
} else {
|
||||||
_ignoredUrls.insert(migrationURL);
|
_ignoredUrls.insert(migrationURL);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
OffscreenUi::asyncQuestion(_dialogParent, MESSAGE_BOX_TITLE,
|
||||||
}
|
"Would you like to migrate the following resource?\n" + migrationURL.toString(),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
OffscreenUi::asyncQuestion(_dialogParent, MESSAGE_BOX_TITLE, COMPLETE_MIGRATION_TEXT,
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
|
hasAskedForCompleteMigration = true;
|
||||||
|
}
|
||||||
|
if (wantsCompleteMigration) {
|
||||||
|
migrateResources(migrationURL, jsonValue, isModelURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_doneReading = true;
|
_doneReading = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue