mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-15 22:08:43 +00:00
Changed: Added 'data directory' box and re-arranged filters.
This commit is contained in:
parent
884f74b01e
commit
d0c381ed94
3 changed files with 137 additions and 36 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QDirIterator>
|
||||||
|
|
||||||
#include "../core/icore.h"
|
#include "../core/icore.h"
|
||||||
#include "../core/imenu_manager.h"
|
#include "../core/imenu_manager.h"
|
||||||
|
@ -27,6 +29,7 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_lastDir = ".";
|
||||||
m_compileLog = "";
|
m_compileLog = "";
|
||||||
updateCompileLog();
|
updateCompileLog();
|
||||||
|
|
||||||
|
@ -35,24 +38,11 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
|
||||||
|
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
// Populate the "all" primitives box.
|
|
||||||
QStringList list;
|
|
||||||
std::vector<std::string> paths;
|
|
||||||
NLMISC::CPath::getFileList("primitive", paths);
|
|
||||||
|
|
||||||
std::vector<std::string>::iterator itr = paths.begin();
|
|
||||||
while( itr != paths.end() )
|
|
||||||
{
|
|
||||||
const char *path2 = (*itr).c_str();
|
|
||||||
list << path2;
|
|
||||||
++itr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_regexpFilter = new QRegExp();
|
m_regexpFilter = new QRegExp();
|
||||||
m_regexpFilter->setPatternSyntax(QRegExp::FixedString);
|
m_regexpFilter->setPatternSyntax(QRegExp::FixedString);
|
||||||
m_regexpFilter->setCaseSensitivity(Qt::CaseInsensitive);
|
m_regexpFilter->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
||||||
m_allPrimitivesModel = new QStringListModel(list, this);
|
m_allPrimitivesModel = new QStringListModel(this);
|
||||||
m_filteredProxyModel = new QSortFilterProxyModel(this);
|
m_filteredProxyModel = new QSortFilterProxyModel(this);
|
||||||
m_filteredProxyModel->setSourceModel(m_allPrimitivesModel);
|
m_filteredProxyModel->setSourceModel(m_allPrimitivesModel);
|
||||||
m_filteredProxyModel->setDynamicSortFilter(true);
|
m_filteredProxyModel->setDynamicSortFilter(true);
|
||||||
|
@ -65,12 +55,63 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) :
|
||||||
connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation()));
|
connect(ui->actionValidate, SIGNAL(triggered()), this, SLOT(handleValidation()));
|
||||||
connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile()));
|
connect(ui->actionCompile, SIGNAL(triggered()), this, SLOT(handleCompile()));
|
||||||
connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish()));
|
connect(ui->actionPublish, SIGNAL(triggered()), this, SLOT(handlePublish()));
|
||||||
|
connect(ui->allPrimitivesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(handleAllDoubleClick(const QModelIndex &)));
|
||||||
|
connect(ui->dataDirButton, SIGNAL(clicked()), this, SLOT(handleDataDirButton()));
|
||||||
|
connect(ui->dataDirEdit, SIGNAL(textChanged(const QString &)), this, SLOT(handleDataDirChanged(const QString &)));
|
||||||
|
|
||||||
|
// Set the default data dir to the primitives path.
|
||||||
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
settings->beginGroup(Core::Constants::DATA_PATH_SECTION);
|
||||||
|
m_lastDir = settings->value(Core::Constants::PRIMITIVES_PATH).toString();
|
||||||
|
ui->dataDirEdit->setText(m_lastDir);
|
||||||
|
populateAllPrimitives(m_lastDir);
|
||||||
|
settings->endGroup();
|
||||||
|
|
||||||
NLLIGO::Register();
|
NLLIGO::Register();
|
||||||
m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false);
|
m_ligoConfig.readPrimitiveClass(NLMISC::CPath::lookup("world_editor_classes.xml").c_str(), false);
|
||||||
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
NLLIGO::CPrimitiveContext::instance().CurrentLigoConfig = &m_ligoConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MissionCompilerMainWindow::populateAllPrimitives(const QString &dataDir)
|
||||||
|
{
|
||||||
|
// First we need to clear out the models entirely.
|
||||||
|
QStringList emptyList;
|
||||||
|
m_selectedPrimitivesModel->setStringList(emptyList);
|
||||||
|
m_allPrimitivesModel->setStringList(emptyList);
|
||||||
|
|
||||||
|
|
||||||
|
// Populate the "all" primitives box.
|
||||||
|
QStringList list;
|
||||||
|
|
||||||
|
// Filter for only primitive files.
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.primitive";
|
||||||
|
|
||||||
|
QDirIterator it(dataDir, filters, QDir::Files, QDirIterator::Subdirectories|QDirIterator::FollowSymlinks);
|
||||||
|
while(it.hasNext())
|
||||||
|
{
|
||||||
|
it.next();
|
||||||
|
list << it.fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_allPrimitivesModel->setStringList(list);
|
||||||
|
}
|
||||||
|
void MissionCompilerMainWindow::handleDataDirChanged(const QString &text)
|
||||||
|
{
|
||||||
|
populateAllPrimitives(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MissionCompilerMainWindow::handleDataDirButton()
|
||||||
|
{
|
||||||
|
QString newPath = QFileDialog::getExistingDirectory(this, "", m_lastDir);
|
||||||
|
if(!newPath.isEmpty())
|
||||||
|
{
|
||||||
|
ui->dataDirEdit->setText(newPath);
|
||||||
|
m_lastDir = newPath;
|
||||||
|
populateAllPrimitives(newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MissionCompilerMainWindow::handleFilterChanged(const QString &text)
|
void MissionCompilerMainWindow::handleFilterChanged(const QString &text)
|
||||||
{
|
{
|
||||||
m_regexpFilter->setPattern(text);
|
m_regexpFilter->setPattern(text);
|
||||||
|
@ -87,6 +128,19 @@ void MissionCompilerMainWindow::handlePublish()
|
||||||
compileMission(true);
|
compileMission(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MissionCompilerMainWindow::handleAllDoubleClick(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
const QAbstractItemModel *model = index.model();
|
||||||
|
QString item = model->data(index).toString();
|
||||||
|
nlinfo("all primitives was double clicked: %s", item.toAscii().data());
|
||||||
|
|
||||||
|
m_filteredProxyModel->removeRows(index.row(),1);
|
||||||
|
|
||||||
|
QStringList list = m_selectedPrimitivesModel->stringList();
|
||||||
|
list << item;
|
||||||
|
m_selectedPrimitivesModel->setStringList(list);
|
||||||
|
}
|
||||||
|
|
||||||
void MissionCompilerMainWindow::compileMission(bool publish)
|
void MissionCompilerMainWindow::compileMission(bool publish)
|
||||||
{
|
{
|
||||||
uint nbMission = 0;
|
uint nbMission = 0;
|
||||||
|
|
|
@ -38,11 +38,15 @@ public Q_SLOTS:
|
||||||
void handleValidation();
|
void handleValidation();
|
||||||
void handleCompile();
|
void handleCompile();
|
||||||
void handlePublish();
|
void handlePublish();
|
||||||
|
void handleAllDoubleClick(const QModelIndex &index);
|
||||||
|
void handleDataDirButton();
|
||||||
|
void handleDataDirChanged(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MissionCompilerMainWindow *ui;
|
Ui::MissionCompilerMainWindow *ui;
|
||||||
|
|
||||||
void updateCompileLog();
|
void updateCompileLog();
|
||||||
|
void populateAllPrimitives(const QString &dataDir = QString());
|
||||||
bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions);
|
bool parsePrimForMissions(NLLIGO::IPrimitive const *prim, TMissionContainer &missions);
|
||||||
void compileMission(bool publish=false);
|
void compileMission(bool publish=false);
|
||||||
|
|
||||||
|
@ -53,6 +57,7 @@ private:
|
||||||
QSortFilterProxyModel *m_filteredProxyModel;
|
QSortFilterProxyModel *m_filteredProxyModel;
|
||||||
QRegExp *m_regexpFilter;
|
QRegExp *m_regexpFilter;
|
||||||
QString m_compileLog;
|
QString m_compileLog;
|
||||||
|
QString m_lastDir;
|
||||||
|
|
||||||
NLLIGO::CLigoConfig m_ligoConfig;
|
NLLIGO::CLigoConfig m_ligoConfig;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<string>Mission Compiler Options</string>
|
<string>Mission Compiler Options</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="4">
|
<item row="5" column="4">
|
||||||
<layout class="QVBoxLayout" name="addRemoveLayout">
|
<layout class="QVBoxLayout" name="addRemoveLayout">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_3">
|
<spacer name="verticalSpacer_3">
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="5" column="3">
|
||||||
<widget class="QListView" name="allPrimitivesList">
|
<widget class="QListView" name="allPrimitivesList">
|
||||||
<property name="acceptDrops">
|
<property name="acceptDrops">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="5">
|
<item row="5" column="5">
|
||||||
<widget class="QListView" name="selectedPrimitivesList">
|
<widget class="QListView" name="selectedPrimitivesList">
|
||||||
<property name="acceptDrops">
|
<property name="acceptDrops">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -182,41 +182,83 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="4" column="3">
|
||||||
<widget class="QLabel" name="allPrimitivesLabel">
|
<widget class="QLabel" name="allPrimitivesLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>All Primitives</string>
|
<string>All Primitives</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="5">
|
<item row="4" column="5">
|
||||||
<widget class="QLabel" name="selectedPrimitivesLabel">
|
<widget class="QLabel" name="selectedPrimitivesLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Selected Primitives</string>
|
<string>Selected Primitives</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
<item row="0" column="3" colspan="3">
|
||||||
<layout class="QHBoxLayout" name="filterLayout">
|
<widget class="QGroupBox" name="filterGroupBox">
|
||||||
<item>
|
<property name="title">
|
||||||
<widget class="QLabel" name="filterLabel">
|
<string>Filter Criteria</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Filter</string>
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
</widget>
|
<layout class="QHBoxLayout" name="dataDirLayout">
|
||||||
</item>
|
<item>
|
||||||
<item>
|
<widget class="QLabel" name="dataDirLabel">
|
||||||
<widget class="QLineEdit" name="filterEdit">
|
<property name="text">
|
||||||
<property name="placeholderText">
|
<string>Data Directory</string>
|
||||||
<string>type filter here</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
</item>
|
<item>
|
||||||
</layout>
|
<widget class="QLineEdit" name="dataDirEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="dataDirButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="filterLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="filterLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Filter</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="filterEdit">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>type filter here</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<zorder>horizontalLayoutWidget</zorder>
|
||||||
|
<zorder>dataDirLabel</zorder>
|
||||||
|
<zorder>horizontalLayoutWidget</zorder>
|
||||||
|
<zorder></zorder>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="publishOptionsPage">
|
<widget class="QWidget" name="publishOptionsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>776</width>
|
||||||
|
<height>426</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Publish Options</string>
|
<string>Publish Options</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
|
Loading…
Reference in a new issue