mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-23 12:37:45 +00:00
Allow easy exporting of the original MDL
This commit is contained in:
parent
605e2f7e60
commit
5c0524ea8d
1 changed files with 28 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -120,9 +121,9 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent
|
||||||
});
|
});
|
||||||
topControlLayout->addWidget(importButton);
|
topControlLayout->addWidget(importButton);
|
||||||
|
|
||||||
exportButton = new QPushButton(QStringLiteral("Export..."));
|
auto testMenu = new QMenu();
|
||||||
exportButton->setIcon(QIcon::fromTheme(QStringLiteral("document-export")));
|
auto gltfAction = testMenu->addAction(QStringLiteral("glTF"));
|
||||||
connect(exportButton, &QPushButton::clicked, this, [this](bool) {
|
connect(gltfAction, &QAction::triggered, this, [this](bool) {
|
||||||
if (currentGear.has_value()) {
|
if (currentGear.has_value()) {
|
||||||
// TODO: deduplicate
|
// TODO: deduplicate
|
||||||
const auto sanitizeMdlPath = [](const QString &mdlPath) -> QString {
|
const auto sanitizeMdlPath = [](const QString &mdlPath) -> QString {
|
||||||
|
@ -149,6 +150,30 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent
|
||||||
gearView->exportModel(fileName);
|
gearView->exportModel(fileName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
auto mdlAction = testMenu->addAction(QStringLiteral("MDL"));
|
||||||
|
connect(mdlAction, &QAction::triggered, this, [this, data](bool) {
|
||||||
|
if (currentGear.has_value()) {
|
||||||
|
// TODO: deduplicate
|
||||||
|
const auto sanitizeMdlPath = [](const QString &mdlPath) -> QString {
|
||||||
|
return QString(mdlPath).section(QLatin1Char('/'), -1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const QString fileName =
|
||||||
|
QFileDialog::getSaveFileName(this, tr("Export Model"), sanitizeMdlPath(gearView->getLoadedGearPath()), tr("MDL File (*.mdl)"));
|
||||||
|
|
||||||
|
auto buffer = physis_gamedata_extract_file(data, gearView->getLoadedGearPath().toStdString().c_str());
|
||||||
|
|
||||||
|
QFile file(fileName);
|
||||||
|
file.open(QIODevice::WriteOnly);
|
||||||
|
file.write(reinterpret_cast<char *>(buffer.data), buffer.size);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
exportButton = new QPushButton(QStringLiteral("Export"));
|
||||||
|
exportButton->setMenu(testMenu);
|
||||||
|
exportButton->setIcon(QIcon::fromTheme(QStringLiteral("document-export")));
|
||||||
|
|
||||||
topControlLayout->addWidget(exportButton);
|
topControlLayout->addWidget(exportButton);
|
||||||
topControlLayout->addWidget(addToFMVButton);
|
topControlLayout->addWidget(addToFMVButton);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue