From ab790a5f08a8a2bc496e3bb30c55811978975131 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 17 Feb 2016 03:48:01 +0100 Subject: [PATCH] Show asset database tree for last opened file --HG-- branch : feature-material-editor --- .../nel/include/nel/pipeline/project_config.h | 2 ++ code/nel/src/pipeline/project_config.cpp | 14 ++++++++ .../tools/3d/mesh_editor/graphics_config.cpp | 2 ++ code/nel/tools/3d/mesh_editor/main_window.cpp | 36 ++++++++++++++++++- code/nel/tools/3d/mesh_editor/main_window.h | 2 ++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/pipeline/project_config.h b/code/nel/include/nel/pipeline/project_config.h index a63cbda20..1cf080fea 100644 --- a/code/nel/include/nel/pipeline/project_config.h +++ b/code/nel/include/nel/pipeline/project_config.h @@ -53,6 +53,8 @@ public: /// Undo init static void release(); + static std::string databaseRoot(); + private: static void cleanup(); static void searchDirectories(const char *var); diff --git a/code/nel/src/pipeline/project_config.cpp b/code/nel/src/pipeline/project_config.cpp index 995f92fd4..2cb4568f5 100644 --- a/code/nel/src/pipeline/project_config.cpp +++ b/code/nel/src/pipeline/project_config.cpp @@ -233,6 +233,20 @@ void CProjectConfig::release() cleanup(); } +std::string CProjectConfig::databaseRoot() +{ + for (uint i = 0; i < s_ConfigFiles.size(); ++i) + { + CConfigFile *cfg = s_ConfigFiles[i]; + const TPathString &dir = s_ConfigPaths[i]; + CConfigFile::CVar *path = cfg->getVarPtr("DatabaseRoot"); + if (path && CFile::isExists(dir + path->asString())) + return CPath::standardizePath(dir + path->asString()); + } + + return ""; +} + } /* namespace NLPIPELINE */ /* end of file */ diff --git a/code/nel/tools/3d/mesh_editor/graphics_config.cpp b/code/nel/tools/3d/mesh_editor/graphics_config.cpp index 31b782264..14f0e5e28 100644 --- a/code/nel/tools/3d/mesh_editor/graphics_config.cpp +++ b/code/nel/tools/3d/mesh_editor/graphics_config.cpp @@ -135,6 +135,8 @@ CGraphicsConfig::CGraphicsConfig(QWidget *parent, CConfiguration *configuration, m_ScreenshotGroup->setLayout(groupVboxLayout); vboxLayout->addWidget(m_ScreenshotGroup); + + m_ScreenshotGroup->setVisible(false); } vboxLayout->addStretch(); diff --git a/code/nel/tools/3d/mesh_editor/main_window.cpp b/code/nel/tools/3d/mesh_editor/main_window.cpp index b21994dde..27a62a793 100644 --- a/code/nel/tools/3d/mesh_editor/main_window.cpp +++ b/code/nel/tools/3d/mesh_editor/main_window.cpp @@ -35,6 +35,8 @@ // NeL includes // #include #include +#include +#include // Project includes #include "../shared_widgets/command_log.h" @@ -87,6 +89,18 @@ CMainWindow::CMainWindow(QWidget *parent, Qt::WindowFlags flags) connect(m_GraphicsConfig, SIGNAL(applyGraphicsConfig()), this, SLOT(applyGraphicsConfig())); m_Configuration.setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled)); + NLMISC::CConfigFile::CVar *lastFiles = m_Configuration.getConfigFile().getVarPtr("LastFiles"); + if (lastFiles) + { + for (uint i = 0; i < lastFiles->size(); ++i) + { + if (NLMISC::CFile::isExists(lastFiles->asString())) + { + initProjectConfig(lastFiles->asString()); + break; + } + } + } } CMainWindow::~CMainWindow() @@ -102,6 +116,17 @@ CMainWindow::~CMainWindow() m_Configuration.release(); } +void CMainWindow::initProjectConfig(const std::string &asset) +{ + NLPIPELINE::CProjectConfig::init(asset, + NLPIPELINE::CProjectConfig::DatabaseTextureSearchPaths, + true); + + std::string databaseRoot = NLPIPELINE::CProjectConfig::databaseRoot(); + if (!databaseRoot.empty()) m_AssetTreeView->setRootIndex(m_AssetTreeModel->index(QString::fromStdString(databaseRoot))); + else m_AssetTreeView->setRootIndex(m_AssetTreeModel->index("")); +} + void CMainWindow::closeEvent(QCloseEvent *e) { m_Timer->stop(); @@ -336,6 +361,15 @@ void CMainWindow::createDockWindows() m_AssetTreeDock->setAllowedAreas(Qt::AllDockWidgetAreas); m_AssetTreeView = new QTreeView(m_AssetTreeDock); m_AssetTreeModel = new QDirModel(); + /* + QStringList filters; + filters.push_back("*.nelmat"); + filters.push_back("*.dae"); + filters.push_back("*.3ds"); + filters.push_back("*.fbx"); + filters.push_back("*.blend"); + m_AssetTreeModel->setNameFilters(filters); + */ m_AssetTreeView->setModel(m_AssetTreeModel); m_AssetTreeView->setSortingEnabled(true); m_AssetTreeDock->setWidget(m_AssetTreeView); @@ -348,7 +382,7 @@ void CMainWindow::translateDockWindows() { m_CommandLogDock->setWindowTitle(tr("Console")); m_GraphicsConfigDock->setWindowTitle(tr("Graphics Configuration")); - m_AssetTreeDock->setWindowTitle(tr("Asset Tree")); + m_AssetTreeDock->setWindowTitle(tr("Asset Database")); } void CMainWindow::recalculateMinimumWidth() diff --git a/code/nel/tools/3d/mesh_editor/main_window.h b/code/nel/tools/3d/mesh_editor/main_window.h index 4e063cd36..74ecae5a1 100644 --- a/code/nel/tools/3d/mesh_editor/main_window.h +++ b/code/nel/tools/3d/mesh_editor/main_window.h @@ -98,6 +98,8 @@ protected: private: void updateInitialization(bool visible); + void initProjectConfig(const std::string &asset); + void createActions(); void translateActions(); void createMenus();