Skip to content

Commit

Permalink
Updated Release v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
webermm committed Jul 26, 2023
1 parent 3098749 commit b13687b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 43 deletions.
3 changes: 2 additions & 1 deletion EditorApp/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ ads::CDockAreaWidget* createAndAddSceneGraphTree(MainWindow* mainWindow, const c
Skin::typeDescription.typeName};

auto* model = new raco::object_tree::model::ObjectTreeViewDefaultModel(racoApplication->activeRaCoProject().commandInterface(), racoApplication->dataChangeDispatcher(), racoApplication->externalProjects(), allowedCreateableUserTypes);
model->setAcceptableFileExtensions(QStringList{"lua"});
model->setAcceptableFileExtensions(QStringList{"lua", "gltf", "glb"});
model->setAcceptLuaScripts(true);
model->setAcceptLuaInterfaces(true);
model->setDropGltfOpensAssetImportDialog(true);
return createAndAddObjectTree(MainWindow::DockWidgetTypes::SCENE_GRAPH, dockObjName, model, new raco::object_tree::model::ObjectTreeViewDefaultSortFilterProxyModel(mainWindow, false),
ads::LeftDockWidgetArea, mainWindow, dockManager, treeDockManager, nullptr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace raco::common_widgets {

class MeshAssetImportDialog final : public QDialog {
public:
explicit MeshAssetImportDialog(raco::core::MeshScenegraph& sceneGraph, int projectFeatureLevel, QWidget* parent = nullptr);
explicit MeshAssetImportDialog(raco::core::MeshScenegraph& sceneGraph, int projectFeatureLevel, QString fileName, QWidget* parent = nullptr);

QGridLayout* layout_;
QTreeWidget* widget_;
Expand Down
4 changes: 2 additions & 2 deletions gui/libCommonWidgets/src/MeshAssetImportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

namespace raco::common_widgets {

MeshAssetImportDialog::MeshAssetImportDialog(raco::core::MeshScenegraph& sceneGraph, int projectFeatureLevel, QWidget* parent)
MeshAssetImportDialog::MeshAssetImportDialog(raco::core::MeshScenegraph& sceneGraph, int projectFeatureLevel, QString fileName, QWidget* parent)
: sceneGraph_{sceneGraph},
nodeTreeList_{sceneGraph_.nodes.size()},
meshTreeList_{sceneGraph_.meshes.size()},
animTreeList_{sceneGraph_.animations.size()} {
setWindowTitle("Import External Assets");
setWindowTitle("Import External Assets from '" + fileName + "'");

widget_ = new QTreeWidget(this);
widget_->setHeaderItem(new QTreeWidgetItem({"Name", "Type"}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public Q_SLOTS:

virtual QMenu* createCustomContextMenu(const QPoint &p);

void dropEvent(QDropEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ObjectTreeViewDefaultModel : public QAbstractItemModel {
void setAcceptLuaModules(bool accept);
void setAcceptLuaScripts(bool accept);
void setAcceptLuaInterfaces(bool accept);
void setDropGltfOpensAssetImportDialog(bool flag);

virtual Qt::TextElideMode textElideMode() const;

Expand Down Expand Up @@ -118,7 +119,7 @@ class ObjectTreeViewDefaultModel : public QAbstractItemModel {

public Q_SLOTS:
core::SEditorObject createNewObject(const std::string& typeName, const std::string& nodeName = "", const QModelIndex& parent = QModelIndex());
core::SEditorObject createNewObjectFromFile(const QFileInfo& fileInfo);
void dropFile(const QFileInfo& fileInfo, const QModelIndex& parent);
virtual size_t deleteObjectsAtIndices(const QModelIndexList& indices);
virtual void copyObjectsAtIndices(const QModelIndexList& indices, bool deepCopy);
virtual void cutObjectsAtIndices(const QModelIndexList& indices, bool deepCut);
Expand Down Expand Up @@ -198,6 +199,7 @@ public Q_SLOTS:
bool acceptLuaModules_ = false;
bool acceptLuaScripts_ = false;
bool acceptLuaInterfaces_ = false;
bool gltfDropOpensAssetImportDialog_ = false;

std::string getOriginPathFromMimeData(const QMimeData* data) const;
QMimeData* generateMimeData(const QModelIndexList& indexes, const std::string& originPath) const;
Expand Down
6 changes: 0 additions & 6 deletions gui/libObjectTree/src/object_tree_view/ObjectTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,6 @@ QMenu* ObjectTreeView::createCustomContextMenu(const QPoint &p) {
return treeViewMenu;
}

void ObjectTreeView::dropEvent(QDropEvent *event) {
for (const auto& fileInfo : treeModel_->getAcceptableFilesInfo(event->mimeData())) {
treeModel_->createNewObjectFromFile(fileInfo);
}
}

void ObjectTreeView::dragMoveEvent(QDragMoveEvent *event) {
setDropIndicatorShown(true);
QTreeView::dragMoveEvent(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,39 +373,43 @@ bool ObjectTreeViewDefaultModel::dropMimeData(const QMimeData* data, Qt::DropAct
return true;
}

if (!data->hasFormat(OBJECT_EDITOR_ID_MIME_TYPE)) {
return false;
}

auto originPath = getOriginPathFromMimeData(data);
auto mimeDataContainsLocalInstances = originPath == project()->currentPath();
auto movedItemIDs = decodeMimeData(data);
if (data->hasFormat(OBJECT_EDITOR_ID_MIME_TYPE)) {
auto originPath = getOriginPathFromMimeData(data);
auto mimeDataContainsLocalInstances = originPath == project()->currentPath();
auto movedItemIDs = decodeMimeData(data);

if (mimeDataContainsLocalInstances) {
std::vector<SEditorObject> objs;
for (const auto& movedItemID : movedItemIDs) {
if (auto childObj = project()->getInstanceByID(movedItemID.toStdString())) {
objs.emplace_back(childObj);
if (mimeDataContainsLocalInstances) {
std::vector<SEditorObject> objs;
for (const auto& movedItemID : movedItemIDs) {
if (auto childObj = project()->getInstanceByID(movedItemID.toStdString())) {
objs.emplace_back(childObj);
}
}
}

moveScenegraphChildren(objs, indexToSEditorObject(parent), row);
} else {
auto originCommandInterface = externalProjectStore_->getExternalProjectCommandInterface(originPath);
std::vector<SEditorObject> objs;
for (const auto& movedItemID : movedItemIDs) {
if (auto externalProjectObj = originCommandInterface->project()->getInstanceByID(movedItemID.toStdString())) {
objs.emplace_back(externalProjectObj);
moveScenegraphChildren(objs, indexToSEditorObject(parent), row);
} else {
auto originCommandInterface = externalProjectStore_->getExternalProjectCommandInterface(originPath);
std::vector<SEditorObject> objs;
for (const auto& movedItemID : movedItemIDs) {
if (auto externalProjectObj = originCommandInterface->project()->getInstanceByID(movedItemID.toStdString())) {
objs.emplace_back(externalProjectObj);
}
}
auto serializedObjects = originCommandInterface->copyObjects(objs, true);

auto pressedKeys = QGuiApplication::queryKeyboardModifiers();
auto pasteAsExtRef = pressedKeys.testFlag(Qt::KeyboardModifier::AltModifier) || indexToTreeNode(parent)->getType() == ObjectTreeNodeType::ExtRefGroup;
pasteObjectAtIndex(parent, pasteAsExtRef, nullptr, serializedObjects);
return true;
}
auto serializedObjects = originCommandInterface->copyObjects(objs, true);

auto pressedKeys = QGuiApplication::queryKeyboardModifiers();
auto pasteAsExtRef = pressedKeys.testFlag(Qt::KeyboardModifier::AltModifier) || indexToTreeNode(parent)->getType() == ObjectTreeNodeType::ExtRefGroup;
pasteObjectAtIndex(parent, pasteAsExtRef, nullptr, serializedObjects);
} else if (!acceptableFileExtensions_.empty() && !getAcceptableFilesInfo(data).empty()) {
for (const auto& fileInfo : getAcceptableFilesInfo(data)) {
dropFile(fileInfo, parent);
}
return true;
}

return true;
return false;
}

Qt::ItemFlags ObjectTreeViewDefaultModel::flags(const QModelIndex& index) const {
Expand Down Expand Up @@ -530,9 +534,13 @@ SEditorObject ObjectTreeViewDefaultModel::createNewObject(const std::string& typ
return newObj;
}

SEditorObject ObjectTreeViewDefaultModel::createNewObjectFromFile(const QFileInfo& fileInfo) {
object_creator::ObjectCreator objCreator(commandInterface_, acceptLuaModules_, acceptLuaInterfaces_, acceptLuaScripts_);
return objCreator.createNewObjectFromFile(fileInfo);
void ObjectTreeViewDefaultModel::dropFile(const QFileInfo& fileInfo, const QModelIndex& parent) {
if (gltfDropOpensAssetImportDialog_ && (fileInfo.suffix().toLower() == "glb" || fileInfo.suffix().toLower() == "gltf")) {
importMeshScenegraph(fileInfo.absoluteFilePath(), parent);
} else {
object_creator::ObjectCreator objCreator(commandInterface_, acceptLuaModules_, acceptLuaInterfaces_, acceptLuaScripts_);
objCreator.createNewObjectFromFile(fileInfo);
}
}

bool ObjectTreeViewDefaultModel::canCopyAtIndices(const QModelIndexList& indices) const {
Expand Down Expand Up @@ -685,7 +693,7 @@ void ObjectTreeViewDefaultModel::importMeshScenegraph(const QString& filePath, c
auto dummyCacheEntry = commandInterface_->meshCache()->registerFileChangedHandler(absPath, {nullptr, nullptr});
if (auto sceneGraphPtr = commandInterface_->meshCache()->getMeshScenegraph(absPath)) {
MeshScenegraph sceneGraph{*sceneGraphPtr};
auto importStatus = raco::common_widgets::MeshAssetImportDialog(sceneGraph, project()->featureLevel(), nullptr).exec();
auto importStatus = raco::common_widgets::MeshAssetImportDialog(sceneGraph, project()->featureLevel(), QFileInfo(filePath).fileName(), nullptr).exec();
if (importStatus == QDialog::Accepted) {
commandInterface_->insertAssetScenegraph(sceneGraph, absPath, selectedObject);
}
Expand Down Expand Up @@ -823,6 +831,10 @@ void ObjectTreeViewDefaultModel::setAcceptLuaInterfaces(bool accept) {
acceptLuaInterfaces_ = accept;
}

void ObjectTreeViewDefaultModel::setDropGltfOpensAssetImportDialog(bool flag) {
gltfDropOpensAssetImportDialog_ = flag;
}

bool ObjectTreeViewDefaultModel::setData(const QModelIndex& index, const QVariant& value, int role) {
bool success{false};

Expand Down
7 changes: 6 additions & 1 deletion gui/libPropertyBrowser/src/PropertyBrowserItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,12 @@ std::string PropertyBrowserItem::errorMessage() const {
if (messages.size() == 1) {
return *messages.begin();
} else if (messages.size() > 1) {
return "Multiple Errors";
std::map<core::ErrorLevel, std::string> levelDesc = {
{core::ErrorLevel::NONE, ""},
{core::ErrorLevel::INFORMATION, "Information Items"},
{core::ErrorLevel::WARNING, "Warnings"},
{core::ErrorLevel::ERROR, "Errors"}};
return "Multiple " + levelDesc[maxErrorLevel()];
}
return {};
}
Expand Down

0 comments on commit b13687b

Please sign in to comment.