Show asset database tree for last opened file

--HG--
branch : feature-material-editor
hg/feature/material-editor
kaetemi 9 years ago
parent 697299d61b
commit ab790a5f08

@ -53,6 +53,8 @@ public:
/// Undo init /// Undo init
static void release(); static void release();
static std::string databaseRoot();
private: private:
static void cleanup(); static void cleanup();
static void searchDirectories(const char *var); static void searchDirectories(const char *var);

@ -233,6 +233,20 @@ void CProjectConfig::release()
cleanup(); 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 */ } /* namespace NLPIPELINE */
/* end of file */ /* end of file */

@ -135,6 +135,8 @@ CGraphicsConfig::CGraphicsConfig(QWidget *parent, CConfiguration *configuration,
m_ScreenshotGroup->setLayout(groupVboxLayout); m_ScreenshotGroup->setLayout(groupVboxLayout);
vboxLayout->addWidget(m_ScreenshotGroup); vboxLayout->addWidget(m_ScreenshotGroup);
m_ScreenshotGroup->setVisible(false);
} }
vboxLayout->addStretch(); vboxLayout->addStretch();

@ -35,6 +35,8 @@
// NeL includes // NeL includes
// #include <nel/misc/debug.h> // #include <nel/misc/debug.h>
#include <nel/3d/u_driver.h> #include <nel/3d/u_driver.h>
#include <nel/misc/path.h>
#include <nel/pipeline/project_config.h>
// Project includes // Project includes
#include "../shared_widgets/command_log.h" #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())); connect(m_GraphicsConfig, SIGNAL(applyGraphicsConfig()), this, SLOT(applyGraphicsConfig()));
m_Configuration.setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled)); 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() CMainWindow::~CMainWindow()
@ -102,6 +116,17 @@ CMainWindow::~CMainWindow()
m_Configuration.release(); 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) void CMainWindow::closeEvent(QCloseEvent *e)
{ {
m_Timer->stop(); m_Timer->stop();
@ -336,6 +361,15 @@ void CMainWindow::createDockWindows()
m_AssetTreeDock->setAllowedAreas(Qt::AllDockWidgetAreas); m_AssetTreeDock->setAllowedAreas(Qt::AllDockWidgetAreas);
m_AssetTreeView = new QTreeView(m_AssetTreeDock); m_AssetTreeView = new QTreeView(m_AssetTreeDock);
m_AssetTreeModel = new QDirModel(); 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->setModel(m_AssetTreeModel);
m_AssetTreeView->setSortingEnabled(true); m_AssetTreeView->setSortingEnabled(true);
m_AssetTreeDock->setWidget(m_AssetTreeView); m_AssetTreeDock->setWidget(m_AssetTreeView);
@ -348,7 +382,7 @@ void CMainWindow::translateDockWindows()
{ {
m_CommandLogDock->setWindowTitle(tr("Console")); m_CommandLogDock->setWindowTitle(tr("Console"));
m_GraphicsConfigDock->setWindowTitle(tr("Graphics Configuration")); m_GraphicsConfigDock->setWindowTitle(tr("Graphics Configuration"));
m_AssetTreeDock->setWindowTitle(tr("Asset Tree")); m_AssetTreeDock->setWindowTitle(tr("Asset Database"));
} }
void CMainWindow::recalculateMinimumWidth() void CMainWindow::recalculateMinimumWidth()

@ -98,6 +98,8 @@ protected:
private: private:
void updateInitialization(bool visible); void updateInitialization(bool visible);
void initProjectConfig(const std::string &asset);
void createActions(); void createActions();
void translateActions(); void translateActions();
void createMenus(); void createMenus();

Loading…
Cancel
Save