mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 22:39:18 +02:00
Couple bug fixes
This commit is contained in:
parent
7d7a683b18
commit
548d826a4e
5 changed files with 10 additions and 16 deletions
|
@ -217,7 +217,7 @@ Window {
|
||||||
var addToWorld = addToWorldCheckBox.checked
|
var addToWorld = addToWorldCheckBox.checked
|
||||||
|
|
||||||
var path = assetProxyModel.data(treeView.currentIndex, 0x100);
|
var path = assetProxyModel.data(treeView.currentIndex, 0x100);
|
||||||
var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "";
|
var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "/";
|
||||||
var filename = fileUrl.slice(fileUrl.lastIndexOf('/') + 1);
|
var filename = fileUrl.slice(fileUrl.lastIndexOf('/') + 1);
|
||||||
|
|
||||||
Assets.uploadFile(fileUrl, directory + filename, function(err) {
|
Assets.uploadFile(fileUrl, directory + filename, function(err) {
|
||||||
|
@ -227,6 +227,8 @@ Window {
|
||||||
} else {
|
} else {
|
||||||
console.log("Finished uploading: ", fileUrl);
|
console.log("Finished uploading: ", fileUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,7 +426,6 @@ bool setupEssentials(int& argc, char** argv) {
|
||||||
DependencyManager::set<MessagesClient>();
|
DependencyManager::set<MessagesClient>();
|
||||||
DependencyManager::set<UserInputMapper>();
|
DependencyManager::set<UserInputMapper>();
|
||||||
DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
|
DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
|
||||||
DependencyManager::set<AssetMappingsScriptingInterface>();
|
|
||||||
DependencyManager::set<InterfaceParentFinder>();
|
DependencyManager::set<InterfaceParentFinder>();
|
||||||
DependencyManager::set<EntityTreeRenderer>(true, qApp, qApp);
|
DependencyManager::set<EntityTreeRenderer>(true, qApp, qApp);
|
||||||
DependencyManager::set<CompositorHelper>();
|
DependencyManager::set<CompositorHelper>();
|
||||||
|
@ -1296,7 +1295,7 @@ void Application::initializeUi() {
|
||||||
rootContext->setContextProperty("Quat", new Quat());
|
rootContext->setContextProperty("Quat", new Quat());
|
||||||
rootContext->setContextProperty("Vec3", new Vec3());
|
rootContext->setContextProperty("Vec3", new Vec3());
|
||||||
rootContext->setContextProperty("Uuid", new ScriptUUID());
|
rootContext->setContextProperty("Uuid", new ScriptUUID());
|
||||||
rootContext->setContextProperty("Assets", DependencyManager::get<AssetMappingsScriptingInterface>().data());
|
rootContext->setContextProperty("Assets", new AssetMappingsScriptingInterface());
|
||||||
|
|
||||||
rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
|
rootContext->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
|
||||||
|
|
||||||
|
|
|
@ -81,22 +81,15 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) {
|
void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) {
|
||||||
QFile file(path);
|
|
||||||
if (!file.open(QFile::ReadOnly)) {
|
|
||||||
qCWarning(asset_client) << "Error uploading file to asset server:\n"
|
|
||||||
<< "Could not open" << qPrintable(path);
|
|
||||||
OffscreenUi::warning("File Error", "Could not open file: " + path, QMessageBox::Ok);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);
|
auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping);
|
||||||
if (!result.isValid()) {
|
if (!result.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mapping = result.toString();
|
||||||
|
|
||||||
// Check for override
|
// Check for override
|
||||||
if (isKnownMapping(result.toString())) {
|
if (isKnownMapping(mapping)) {
|
||||||
auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";
|
auto message = "The following file already exists:\n" + path + "\nDo you want to override it?";
|
||||||
auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,
|
auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "", message,
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
|
@ -105,7 +98,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(file.readAll());
|
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) {
|
||||||
if (callback.isCallable()) {
|
if (callback.isCallable()) {
|
||||||
|
@ -242,7 +235,7 @@ void AssetMappingModel::refresh() {
|
||||||
auto it = existingPaths.begin();
|
auto it = existingPaths.begin();
|
||||||
while (it != existingPaths.end()) {
|
while (it != existingPaths.end()) {
|
||||||
auto item = _pathToItemMap[*it];
|
auto item = _pathToItemMap[*it];
|
||||||
if (item->data(Qt::UserRole + 1).toBool()) {
|
if (item && item->data(Qt::UserRole + 1).toBool()) {
|
||||||
it = existingPaths.erase(it);
|
it = existingPaths.erase(it);
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class AssetMappingsScriptingInterface : public QObject, public Dependency {
|
class AssetMappingsScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(AssetMappingModel* mappingModel READ getAssetMappingModel CONSTANT)
|
Q_PROPERTY(AssetMappingModel* mappingModel READ getAssetMappingModel CONSTANT)
|
||||||
Q_PROPERTY(QAbstractProxyModel* proxyModel READ getProxyModel CONSTANT)
|
Q_PROPERTY(QAbstractProxyModel* proxyModel READ getProxyModel CONSTANT)
|
||||||
|
|
|
@ -109,7 +109,7 @@ void SetMappingRequest::doStart() {
|
||||||
auto validPath = isValidPath(_path);
|
auto validPath = isValidPath(_path);
|
||||||
auto validHash = isValidHash(_hash);
|
auto validHash = isValidHash(_hash);
|
||||||
if (!validPath || !validHash) {
|
if (!validPath || !validHash) {
|
||||||
_error = validPath ? MappingRequest::InvalidPath : MappingRequest::InvalidHash;
|
_error = !validPath ? MappingRequest::InvalidPath : MappingRequest::InvalidHash;
|
||||||
emit finished(this);
|
emit finished(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue