1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-21 19:57:44 +00:00

armoury: Add tabbed view, model path and currently non-functional import

This commit is contained in:
Joshua Goins 2023-09-26 20:21:06 -04:00
parent 1cd3f989df
commit 0efbc581e0
5 changed files with 59 additions and 12 deletions

View file

@ -53,6 +53,8 @@ public:
Subrace currentSubrace = Subrace::Midlander; Subrace currentSubrace = Subrace::Midlander;
Gender currentGender = Gender::Male; Gender currentGender = Gender::Male;
QString getLoadedGearPath() const;
Q_SIGNALS: Q_SIGNALS:
void gearChanged(); void gearChanged();
void modelReloaded(); void modelReloaded();
@ -92,6 +94,7 @@ private:
struct LoadedGear { struct LoadedGear {
GearInfo info; GearInfo info;
physis_MDL mdl; physis_MDL mdl;
QLatin1String path;
}; };
std::vector<LoadedGear> loadedGears; std::vector<LoadedGear> loadedGears;

View file

@ -12,11 +12,15 @@ struct GameData;
class SingleGearView : public QWidget { class SingleGearView : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit SingleGearView(GameData* data, FileCache& cache); explicit SingleGearView(GameData* data, FileCache& cache);
QString getLoadedGearPath() const;
Q_SIGNALS: Q_SIGNALS:
void gearChanged(); void gearChanged();
void gotMDLPath();
void raceChanged(); void raceChanged();
void subraceChanged(); void subraceChanged();
@ -49,7 +53,7 @@ private:
GearView* gearView = nullptr; GearView* gearView = nullptr;
QComboBox *raceCombo, *subraceCombo, *genderCombo, *lodCombo; QComboBox *raceCombo, *subraceCombo, *genderCombo, *lodCombo;
QPushButton *addToFMVButton, *exportButton; QPushButton *addToFMVButton, *importButton, *exportButton;
bool loadingComboData = false; bool loadingComboData = false;
bool fmvAvailable = false; bool fmvAvailable = false;

View file

@ -18,6 +18,7 @@ GearView::GearView(GameData* data, FileCache& cache) : data(data), cache(cache)
reloadRaceDeforms(); reloadRaceDeforms();
auto layout = new QVBoxLayout(); auto layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(mdlPart); layout->addWidget(mdlPart);
setLayout(layout); setLayout(layout);
@ -277,17 +278,20 @@ void GearView::updatePart()
if (gearDirty) { if (gearDirty) {
for (auto &gearAddition : queuedGearAdditions) { for (auto &gearAddition : queuedGearAdditions) {
QLatin1String mdlPath = QLatin1String(
physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, currentRace, currentSubrace, currentGender, gearAddition.info.slot));
qInfo() << "Looking up" << magic_enum::enum_name(currentRace) << magic_enum::enum_name(currentSubrace) << magic_enum::enum_name(currentGender); qInfo() << "Looking up" << magic_enum::enum_name(currentRace) << magic_enum::enum_name(currentSubrace) << magic_enum::enum_name(currentGender);
auto mdl_data = cache.lookupFile(QLatin1String( auto mdl_data = cache.lookupFile(mdlPath);
physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, currentRace, currentSubrace, currentGender, gearAddition.info.slot)));
// attempt to load the next best race // attempt to load the next best race
// currently hardcoded to hyur midlander // currently hardcoded to hyur midlander
Race fallbackRace = currentRace; Race fallbackRace = currentRace;
Subrace fallbackSubrace = currentSubrace; Subrace fallbackSubrace = currentSubrace;
if (mdl_data.size == 0) { if (mdl_data.size == 0) {
mdl_data = cache.lookupFile(QLatin1String( mdlPath = QLatin1String(
physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, Race::Hyur, Subrace::Midlander, currentGender, gearAddition.info.slot))); physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, Race::Hyur, Subrace::Midlander, currentGender, gearAddition.info.slot));
mdl_data = cache.lookupFile(mdlPath);
fallbackRace = Race::Hyur; fallbackRace = Race::Hyur;
fallbackSubrace = Subrace::Midlander; fallbackSubrace = Subrace::Midlander;
} }
@ -318,6 +322,7 @@ void GearView::updatePart()
mdlPart->addModel(mdl, materials, currentLod); mdlPart->addModel(mdl, materials, currentLod);
gearAddition.mdl = mdl; gearAddition.mdl = mdl;
gearAddition.path = mdlPath;
loadedGears.push_back(gearAddition); loadedGears.push_back(gearAddition);
} }
} }
@ -429,4 +434,12 @@ bool GearView::needsUpdate() const
return gearDirty || raceDirty || faceDirty || hairDirty || earDirty || tailDirty; return gearDirty || raceDirty || faceDirty || hairDirty || earDirty || tailDirty;
} }
QString GearView::getLoadedGearPath() const
{
if (loadedGears.empty()) {
return {};
}
return loadedGears[0].path;
}
#include "moc_gearview.cpp" #include "moc_gearview.cpp"

View file

@ -83,11 +83,14 @@ MainWindow::MainWindow(GameData* in_data) : data(*in_data), cache(FileCache{*in_
connect(gearView, &SingleGearView::addToFullModelViewer, this, [=](GearInfo& info) { connect(gearView, &SingleGearView::addToFullModelViewer, this, [=](GearInfo& info) {
fullModelViewer->addGear(info); fullModelViewer->addGear(info);
}); });
auto tabWidget = new QTabWidget();
tabWidget->addTab(gearView, QStringLiteral("Models"));
layout->addWidget(tabWidget);
fullModelViewer = new FullModelViewer(&data, cache);
connect(fullModelViewer, &FullModelViewer::loadingChanged, this, [=](const bool loading) { connect(fullModelViewer, &FullModelViewer::loadingChanged, this, [=](const bool loading) {
gearView->setFMVAvailable(!loading); gearView->setFMVAvailable(!loading);
}); });
layout->addWidget(gearView);
fullModelViewer = new FullModelViewer(&data, cache);
fullModelViewer->show(); fullModelViewer->show();
} }

View file

@ -3,10 +3,11 @@
#include "singlegearview.h" #include "singlegearview.h"
#include <QDebug>
#include <QFileDialog> #include <QFileDialog>
#include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDebug>
#include "filecache.h" #include "filecache.h"
#include "magic_enum.hpp" #include "magic_enum.hpp"
@ -21,11 +22,22 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
auto layout = new QVBoxLayout(); auto layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(gearView);
setLayout(layout); setLayout(layout);
auto mdlPathEdit = new QLineEdit();
mdlPathEdit->setReadOnly(true);
connect(this, &SingleGearView::gotMDLPath, this, [this, mdlPathEdit] {
mdlPathEdit->setText(gearView->getLoadedGearPath());
});
auto topControlLayout = new QHBoxLayout();
auto controlLayout = new QHBoxLayout(); auto controlLayout = new QHBoxLayout();
layout->addWidget(mdlPathEdit);
layout->addLayout(controlLayout); layout->addLayout(controlLayout);
layout->addWidget(gearView);
layout->addLayout(topControlLayout);
raceCombo = new QComboBox(); raceCombo = new QComboBox();
connect(raceCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) { connect(raceCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
@ -64,14 +76,19 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
controlLayout->addWidget(lodCombo); controlLayout->addWidget(lodCombo);
addToFMVButton = new QPushButton(QStringLiteral("Add to FMV")); addToFMVButton = new QPushButton(QStringLiteral("Add to FMV"));
addToFMVButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add-user")));
connect(addToFMVButton, &QPushButton::clicked, this, [this](bool) { connect(addToFMVButton, &QPushButton::clicked, this, [this](bool) {
if (currentGear.has_value()) { if (currentGear.has_value()) {
Q_EMIT addToFullModelViewer(*currentGear); Q_EMIT addToFullModelViewer(*currentGear);
} }
}); });
controlLayout->addWidget(addToFMVButton);
importButton = new QPushButton(QStringLiteral("Import..."));
importButton->setIcon(QIcon::fromTheme(QStringLiteral("document-import")));
topControlLayout->addWidget(importButton);
exportButton = new QPushButton(QStringLiteral("Export...")); exportButton = new QPushButton(QStringLiteral("Export..."));
exportButton->setIcon(QIcon::fromTheme(QStringLiteral("document-export")));
connect(exportButton, &QPushButton::clicked, this, [this](bool) { connect(exportButton, &QPushButton::clicked, this, [this](bool) {
if (currentGear.has_value()) { if (currentGear.has_value()) {
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Model"), QStringLiteral("model.glb"), tr("glTF Binary File (*.glb)")); QString fileName = QFileDialog::getSaveFileName(this, tr("Save Model"), QStringLiteral("model.glb"), tr("glTF Binary File (*.glb)"));
@ -79,11 +96,13 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
gearView->exportModel(fileName); gearView->exportModel(fileName);
} }
}); });
controlLayout->addWidget(exportButton); topControlLayout->addWidget(exportButton);
topControlLayout->addWidget(addToFMVButton);
connect(gearView, &GearView::loadingChanged, this, [this](const bool loading) { connect(gearView, &GearView::loadingChanged, this, [this](const bool loading) {
if (!loading) { if (!loading) {
reloadGear(); reloadGear();
Q_EMIT gotMDLPath();
} }
}); });
connect(this, &SingleGearView::raceChanged, this, [=] { connect(this, &SingleGearView::raceChanged, this, [=] {
@ -241,4 +260,9 @@ void SingleGearView::setFMVAvailable(const bool available)
} }
} }
QString SingleGearView::getLoadedGearPath() const
{
return gearView->getLoadedGearPath();
}
#include "moc_singlegearview.cpp" #include "moc_singlegearview.cpp"