mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-24 13:07:44 +00:00
Add configurable source directory for model import/export
This commit is contained in:
parent
ae96efcc5e
commit
3217b04eea
5 changed files with 68 additions and 17 deletions
|
@ -14,5 +14,6 @@ public:
|
||||||
private:
|
private:
|
||||||
void applySettings();
|
void applySettings();
|
||||||
|
|
||||||
|
QLineEdit *m_sourcesLineEdit = nullptr;
|
||||||
QLineEdit *m_outputLineEdit = nullptr;
|
QLineEdit *m_outputLineEdit = nullptr;
|
||||||
};
|
};
|
|
@ -192,7 +192,7 @@ void FullModelViewer::reloadGear()
|
||||||
} else {
|
} else {
|
||||||
// smallclothes body
|
// smallclothes body
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Body";
|
info.name = "SmallClothes Body";
|
||||||
info.slot = Slot::Body;
|
info.slot = Slot::Body;
|
||||||
|
|
||||||
gearView->addGear(info);
|
gearView->addGear(info);
|
||||||
|
@ -203,7 +203,7 @@ void FullModelViewer::reloadGear()
|
||||||
} else {
|
} else {
|
||||||
// smallclothes legs
|
// smallclothes legs
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Legs";
|
info.name = "SmallClothes Legs";
|
||||||
info.slot = Slot::Legs;
|
info.slot = Slot::Legs;
|
||||||
|
|
||||||
gearView->addGear(info);
|
gearView->addGear(info);
|
||||||
|
@ -212,7 +212,7 @@ void FullModelViewer::reloadGear()
|
||||||
// smallclothes hands
|
// smallclothes hands
|
||||||
{
|
{
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Hands";
|
info.name = "SmallClothes Hands";
|
||||||
info.slot = Slot::Hands;
|
info.slot = Slot::Hands;
|
||||||
|
|
||||||
gearView->addGear(info);
|
gearView->addGear(info);
|
||||||
|
@ -221,7 +221,7 @@ void FullModelViewer::reloadGear()
|
||||||
// smallclothes hands
|
// smallclothes hands
|
||||||
{
|
{
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Feet";
|
info.name = "SmallClothes Feet";
|
||||||
info.slot = Slot::Feet;
|
info.slot = Slot::Feet;
|
||||||
|
|
||||||
gearView->addGear(info);
|
gearView->addGear(info);
|
||||||
|
|
|
@ -13,7 +13,7 @@ GearListModel::GearListModel(GameData *data, QObject *parent)
|
||||||
// smallclothes body
|
// smallclothes body
|
||||||
{
|
{
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Body";
|
info.name = "SmallClothes Body";
|
||||||
info.slot = Slot::Body;
|
info.slot = Slot::Body;
|
||||||
|
|
||||||
gears.push_back(info);
|
gears.push_back(info);
|
||||||
|
@ -22,7 +22,7 @@ GearListModel::GearListModel(GameData *data, QObject *parent)
|
||||||
// smallclothes legs
|
// smallclothes legs
|
||||||
{
|
{
|
||||||
GearInfo info = {};
|
GearInfo info = {};
|
||||||
info.name = "Smallclothes Legs";
|
info.name = "SmallClothes Legs";
|
||||||
info.slot = Slot::Legs;
|
info.slot = Slot::Legs;
|
||||||
|
|
||||||
gears.push_back(info);
|
gears.push_back(info);
|
||||||
|
|
|
@ -19,6 +19,35 @@ SettingsWindow::SettingsWindow(QWidget *parent)
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
auto sourcesBox = new QGroupBox(QStringLiteral("Sources Output"));
|
||||||
|
layout->addWidget(sourcesBox);
|
||||||
|
|
||||||
|
auto sourcesLayout = new QFormLayout();
|
||||||
|
sourcesBox->setLayout(sourcesLayout);
|
||||||
|
|
||||||
|
auto sourcesBoxLayoutContainer = new QWidget(this);
|
||||||
|
auto sourcesBoxLayout = new QHBoxLayout(sourcesBoxLayoutContainer);
|
||||||
|
sourcesBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
|
KConfig config(QStringLiteral("novusrc"));
|
||||||
|
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||||
|
|
||||||
|
m_sourcesLineEdit = new QLineEdit();
|
||||||
|
m_sourcesLineEdit->setText(game.readEntry("SourcesOutputDirectory"));
|
||||||
|
m_sourcesLineEdit->setClearButtonEnabled(true);
|
||||||
|
sourcesBoxLayout->addWidget(m_sourcesLineEdit);
|
||||||
|
|
||||||
|
auto selectSourceUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString());
|
||||||
|
connect(selectSourceUrlButton, &QPushButton::clicked, this, [this] {
|
||||||
|
QUrl url = QFileDialog::getExistingDirectoryUrl(this, QString());
|
||||||
|
if (!url.isEmpty()) {
|
||||||
|
m_sourcesLineEdit->setText(url.toDisplayString(QUrl::PreferLocalFile));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sourcesBoxLayout->addWidget(selectSourceUrlButton);
|
||||||
|
|
||||||
|
sourcesLayout->addRow(QStringLiteral("Sources Directory"), sourcesBoxLayoutContainer);
|
||||||
|
|
||||||
auto penumbraBox = new QGroupBox(QStringLiteral("Penumbra Output"));
|
auto penumbraBox = new QGroupBox(QStringLiteral("Penumbra Output"));
|
||||||
layout->addWidget(penumbraBox);
|
layout->addWidget(penumbraBox);
|
||||||
|
|
||||||
|
@ -29,9 +58,6 @@ SettingsWindow::SettingsWindow(QWidget *parent)
|
||||||
auto outputBoxLayout = new QHBoxLayout(outputBoxLayoutContainer);
|
auto outputBoxLayout = new QHBoxLayout(outputBoxLayoutContainer);
|
||||||
outputBoxLayout->setContentsMargins(0, 0, 0, 0);
|
outputBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
KConfig config(QStringLiteral("novusrc"));
|
|
||||||
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
|
||||||
|
|
||||||
m_outputLineEdit = new QLineEdit();
|
m_outputLineEdit = new QLineEdit();
|
||||||
m_outputLineEdit->setText(game.readEntry("PenumbraOutputDirectory"));
|
m_outputLineEdit->setText(game.readEntry("PenumbraOutputDirectory"));
|
||||||
m_outputLineEdit->setClearButtonEnabled(true);
|
m_outputLineEdit->setClearButtonEnabled(true);
|
||||||
|
@ -69,4 +95,5 @@ void SettingsWindow::applySettings()
|
||||||
KConfig config(QStringLiteral("novusrc"));
|
KConfig config(QStringLiteral("novusrc"));
|
||||||
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||||
game.writeEntry("PenumbraOutputDirectory", m_outputLineEdit->text());
|
game.writeEntry("PenumbraOutputDirectory", m_outputLineEdit->text());
|
||||||
|
game.writeEntry("SourcesOutputDirectory", m_sourcesLineEdit->text());
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,10 +98,21 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent
|
||||||
return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl"));
|
return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl"));
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString fileName = QFileDialog::getOpenFileName(this,
|
KConfig config(QStringLiteral("novusrc"));
|
||||||
tr("Import Model"),
|
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||||
QStringLiteral("%1.glb").arg(sanitizeMdlPath(gearView->getLoadedGearPath())),
|
QString sourceDirectory = game.readEntry(QStringLiteral("SourcesOutputDirectory"));
|
||||||
tr("glTF Binary File (*.glb)"));
|
|
||||||
|
// TODO: deduplicate
|
||||||
|
QString path = QStringLiteral("%1/%2/%3/%4")
|
||||||
|
.arg(sourceDirectory)
|
||||||
|
.arg(QString::fromStdString(magic_enum::enum_name(currentGear->slot).data()))
|
||||||
|
.arg(QString::fromStdString(currentGear->name))
|
||||||
|
.arg(QStringLiteral("3D"));
|
||||||
|
|
||||||
|
if (!QDir().exists(path))
|
||||||
|
QDir().mkpath(path);
|
||||||
|
|
||||||
|
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import Model"), path, tr("glTF Binary File (*.glb)"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
importModel(fileName);
|
importModel(fileName);
|
||||||
}
|
}
|
||||||
|
@ -118,10 +129,22 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent
|
||||||
return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl"));
|
return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl"));
|
||||||
};
|
};
|
||||||
|
|
||||||
const QString fileName = QFileDialog::getSaveFileName(this,
|
KConfig config(QStringLiteral("novusrc"));
|
||||||
tr("Save Model"),
|
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||||
QStringLiteral("%1.glb").arg(sanitizeMdlPath(gearView->getLoadedGearPath())),
|
QString sourceDirectory = game.readEntry(QStringLiteral("SourcesOutputDirectory"));
|
||||||
tr("glTF Binary File (*.glb)"));
|
QString newFilename = QStringLiteral("%1.glb").arg(sanitizeMdlPath(gearView->getLoadedGearPath()));
|
||||||
|
|
||||||
|
QString path = QStringLiteral("%1/%2/%3/%4")
|
||||||
|
.arg(sourceDirectory)
|
||||||
|
.arg(QString::fromStdString(magic_enum::enum_name(currentGear->slot).data()))
|
||||||
|
.arg(QString::fromStdString(currentGear->name))
|
||||||
|
.arg(QStringLiteral("3D"));
|
||||||
|
|
||||||
|
if (!QDir().exists(path))
|
||||||
|
QDir().mkpath(path);
|
||||||
|
|
||||||
|
const QString fileName =
|
||||||
|
QFileDialog::getSaveFileName(this, tr("Export Model"), QStringLiteral("%1/%2").arg(path, newFilename), tr("glTF Binary File (*.glb)"));
|
||||||
|
|
||||||
gearView->exportModel(fileName);
|
gearView->exportModel(fileName);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue