diff --git a/armoury/include/settingswindow.h b/armoury/include/settingswindow.h index a78878e..28cf568 100644 --- a/armoury/include/settingswindow.h +++ b/armoury/include/settingswindow.h @@ -14,5 +14,6 @@ public: private: void applySettings(); + QLineEdit *m_sourcesLineEdit = nullptr; QLineEdit *m_outputLineEdit = nullptr; }; \ No newline at end of file diff --git a/armoury/src/fullmodelviewer.cpp b/armoury/src/fullmodelviewer.cpp index 7e440c9..1c8886f 100644 --- a/armoury/src/fullmodelviewer.cpp +++ b/armoury/src/fullmodelviewer.cpp @@ -192,7 +192,7 @@ void FullModelViewer::reloadGear() } else { // smallclothes body GearInfo info = {}; - info.name = "Smallclothes Body"; + info.name = "SmallClothes Body"; info.slot = Slot::Body; gearView->addGear(info); @@ -203,7 +203,7 @@ void FullModelViewer::reloadGear() } else { // smallclothes legs GearInfo info = {}; - info.name = "Smallclothes Legs"; + info.name = "SmallClothes Legs"; info.slot = Slot::Legs; gearView->addGear(info); @@ -212,7 +212,7 @@ void FullModelViewer::reloadGear() // smallclothes hands { GearInfo info = {}; - info.name = "Smallclothes Hands"; + info.name = "SmallClothes Hands"; info.slot = Slot::Hands; gearView->addGear(info); @@ -221,7 +221,7 @@ void FullModelViewer::reloadGear() // smallclothes hands { GearInfo info = {}; - info.name = "Smallclothes Feet"; + info.name = "SmallClothes Feet"; info.slot = Slot::Feet; gearView->addGear(info); diff --git a/armoury/src/gearlistmodel.cpp b/armoury/src/gearlistmodel.cpp index c2175e0..341b4d4 100644 --- a/armoury/src/gearlistmodel.cpp +++ b/armoury/src/gearlistmodel.cpp @@ -13,7 +13,7 @@ GearListModel::GearListModel(GameData *data, QObject *parent) // smallclothes body { GearInfo info = {}; - info.name = "Smallclothes Body"; + info.name = "SmallClothes Body"; info.slot = Slot::Body; gears.push_back(info); @@ -22,7 +22,7 @@ GearListModel::GearListModel(GameData *data, QObject *parent) // smallclothes legs { GearInfo info = {}; - info.name = "Smallclothes Legs"; + info.name = "SmallClothes Legs"; info.slot = Slot::Legs; gears.push_back(info); diff --git a/armoury/src/settingswindow.cpp b/armoury/src/settingswindow.cpp index c510f10..26f2405 100644 --- a/armoury/src/settingswindow.cpp +++ b/armoury/src/settingswindow.cpp @@ -19,6 +19,35 @@ SettingsWindow::SettingsWindow(QWidget *parent) auto layout = new QVBoxLayout(); 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")); layout->addWidget(penumbraBox); @@ -29,9 +58,6 @@ SettingsWindow::SettingsWindow(QWidget *parent) auto outputBoxLayout = new QHBoxLayout(outputBoxLayoutContainer); outputBoxLayout->setContentsMargins(0, 0, 0, 0); - KConfig config(QStringLiteral("novusrc")); - KConfigGroup game = config.group(QStringLiteral("Armoury")); - m_outputLineEdit = new QLineEdit(); m_outputLineEdit->setText(game.readEntry("PenumbraOutputDirectory")); m_outputLineEdit->setClearButtonEnabled(true); @@ -69,4 +95,5 @@ void SettingsWindow::applySettings() KConfig config(QStringLiteral("novusrc")); KConfigGroup game = config.group(QStringLiteral("Armoury")); game.writeEntry("PenumbraOutputDirectory", m_outputLineEdit->text()); + game.writeEntry("SourcesOutputDirectory", m_sourcesLineEdit->text()); } diff --git a/armoury/src/singlegearview.cpp b/armoury/src/singlegearview.cpp index c9f3e7c..e3e55f4 100644 --- a/armoury/src/singlegearview.cpp +++ b/armoury/src/singlegearview.cpp @@ -98,10 +98,21 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl")); }; - const QString fileName = QFileDialog::getOpenFileName(this, - tr("Import Model"), - QStringLiteral("%1.glb").arg(sanitizeMdlPath(gearView->getLoadedGearPath())), - tr("glTF Binary File (*.glb)")); + KConfig config(QStringLiteral("novusrc")); + KConfigGroup game = config.group(QStringLiteral("Armoury")); + QString sourceDirectory = game.readEntry(QStringLiteral("SourcesOutputDirectory")); + + // 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()) { importModel(fileName); } @@ -118,10 +129,22 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent return QString(mdlPath).section(QLatin1Char('/'), -1).remove(QStringLiteral(".mdl")); }; - const QString fileName = QFileDialog::getSaveFileName(this, - tr("Save Model"), - QStringLiteral("%1.glb").arg(sanitizeMdlPath(gearView->getLoadedGearPath())), - tr("glTF Binary File (*.glb)")); + KConfig config(QStringLiteral("novusrc")); + KConfigGroup game = config.group(QStringLiteral("Armoury")); + QString sourceDirectory = game.readEntry(QStringLiteral("SourcesOutputDirectory")); + 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); }