mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 14:29:35 +02:00
Blocks drag does not work yet
This commit is contained in:
parent
9cfc4dc91b
commit
acb088b263
4 changed files with 34 additions and 18 deletions
|
@ -6200,12 +6200,21 @@ void Application::addAssetToWorldUnzipFailure(QString filePath) {
|
|||
addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
|
||||
}
|
||||
|
||||
void Application::addAssetToWorld(QString filePath) {
|
||||
void Application::addAssetToWorld(QString filePath, QString zipFile, bool isBlocks) {
|
||||
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
|
||||
|
||||
qCDebug(interfaceapp) << "File about to be uploaded: " << filePath;
|
||||
qCDebug(interfaceapp) << "Original zip folder: " << zipFile;
|
||||
QString path = QUrl(filePath).toLocalFile();
|
||||
QString filename = filenameFromPath(path);
|
||||
QString mapping = "/" + filename;
|
||||
QString mapping;
|
||||
if (isBlocks) {
|
||||
QString assetFolder = zipFile.section("/", -1);
|
||||
assetFolder.remove(".zip");
|
||||
mapping = "/" + assetFolder + "/" + filename;
|
||||
} else {
|
||||
mapping = "/" + filename;
|
||||
}
|
||||
|
||||
// Test repeated because possibly different code paths.
|
||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||
|
@ -6576,15 +6585,19 @@ void Application::onAssetToWorldMessageBoxClosed() {
|
|||
}
|
||||
|
||||
|
||||
void Application::handleUnzip(QString zipFile, QString unzipFile, bool autoAdd) {
|
||||
void Application::handleUnzip(QString zipFile, QStringList unzipFile, bool autoAdd, bool isBlocks) {
|
||||
if (autoAdd) {
|
||||
if (!unzipFile.isEmpty()) {
|
||||
addAssetToWorld(unzipFile);
|
||||
qCDebug(interfaceapp) << "My folder contents: " << unzipFile;
|
||||
for (int i = 0; i < unzipFile.length(); i++) {
|
||||
qCDebug(interfaceapp) << "Preparing file for asset server: " << unzipFile.at(i);
|
||||
addAssetToWorld(unzipFile.at(i), zipFile, isBlocks);
|
||||
}
|
||||
} else {
|
||||
addAssetToWorldUnzipFailure(zipFile);
|
||||
}
|
||||
} else {
|
||||
showAssetServerWidget(unzipFile);
|
||||
showAssetServerWidget(unzipFile.first());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -331,14 +331,14 @@ public slots:
|
|||
// FIXME: Move addAssetToWorld* methods to own class?
|
||||
void addAssetToWorldFromURL(QString url);
|
||||
void addAssetToWorldFromURLRequestFinished();
|
||||
void addAssetToWorld(QString filePath);
|
||||
void addAssetToWorld(QString filePath, QString zipFile, bool isBlocks);
|
||||
void addAssetToWorldUnzipFailure(QString filePath);
|
||||
void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy);
|
||||
void addAssetToWorldUpload(QString filePath, QString mapping);
|
||||
void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash);
|
||||
void addAssetToWorldAddEntity(QString filePath, QString mapping);
|
||||
|
||||
void handleUnzip(QString sourceFile, QString destinationFile, bool autoAdd);
|
||||
void handleUnzip(QString sourceFile, QStringList destinationFile, bool autoAdd, bool isBlocks);
|
||||
|
||||
FileScriptingInterface* getFileDownloadInterface() { return _fileDownload; }
|
||||
|
||||
|
|
|
@ -51,18 +51,21 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
|
|||
return;
|
||||
}
|
||||
|
||||
QString file = unzipFile(path, tempDir);
|
||||
qCDebug(scriptengine) << "Unzipped file: " << file;
|
||||
QString filename = QUrl::fromLocalFile(file).toString();
|
||||
if (file != "") {
|
||||
QStringList fileList = unzipFile(path, tempDir);
|
||||
qCDebug(scriptengine) << "Unzipped file list: " << fileList;
|
||||
QString filename = QUrl::fromLocalFile(fileList.first()).toString();
|
||||
|
||||
if (filename != "") {
|
||||
qCDebug(scriptengine) << "File to upload: " + filename;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qCDebug(scriptengine) << "Unzip failed";
|
||||
}
|
||||
emit unzipResult(path, filename, autoAdd);
|
||||
emit unzipResult(path, fileList, autoAdd, isBlocks);
|
||||
|
||||
}
|
||||
|
||||
QString FileScriptingInterface::unzipFile(QString path, QString tempDir) {
|
||||
QStringList FileScriptingInterface::unzipFile(QString path, QString tempDir) {
|
||||
|
||||
QDir dir(path);
|
||||
QString dirName = dir.path();
|
||||
|
@ -73,11 +76,11 @@ QString FileScriptingInterface::unzipFile(QString path, QString tempDir) {
|
|||
qCDebug(scriptengine) << list;
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
return list.front();
|
||||
return list;
|
||||
}
|
||||
else {
|
||||
qCDebug(scriptengine) << "Extraction failed";
|
||||
return "";
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ public slots:
|
|||
QString getTempDir();
|
||||
|
||||
signals:
|
||||
void unzipResult(QString zipFile, QString unzipFile, bool autoAdd);
|
||||
void unzipResult(QString zipFile, QStringList unzipFile, bool autoAdd, bool isBlocks);
|
||||
|
||||
private:
|
||||
bool isTempDir(QString tempDir);
|
||||
QString unzipFile(QString path, QString tempDir);
|
||||
QStringList unzipFile(QString path, QString tempDir);
|
||||
void recursiveFileScan(QFileInfo file, QString* dirName);
|
||||
void downloadZip(QString path, const QString link);
|
||||
|
||||
|
|
Loading…
Reference in a new issue