1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-24 21:07:46 +00:00
novus/mdlviewer/src/fullmodelviewer.cpp
Joshua Goins 7407d26247 Overhaul mdlviewer to use the MDL part, and add the full model viewer
This is a major code overhaul for mdlviewer, which will make it easier
to extend and modify in the future (trust me, the old code was garbage).

The different views are now split up (SingleGearView, FullModelViewer,
and MDLPart) which makes the functionality easier to handle, and less
error-prone.

Right now bone debugging is disabled (not that it worked that well
anyway) but will be brought back in a future commit.
2023-04-09 15:31:19 -04:00

93 lines
No EOL
2.2 KiB
C++

#include "fullmodelviewer.h"
#include "magic_enum.hpp"
#include <QVBoxLayout>
FullModelViewer::FullModelViewer(GameData *data) : data(data) {
setWindowTitle("Full Model Viewer");
setMinimumWidth(640);
setMinimumHeight(480);
auto layout = new QVBoxLayout();
setLayout(layout);
gearView = new GearView(data);
layout->addWidget(gearView);
auto controlLayout = new QHBoxLayout();
layout->addLayout(controlLayout);
raceCombo = new QComboBox();
connect(raceCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
gearView->setRace((Race)index);
});
controlLayout->addWidget(raceCombo);
for (auto [race, race_name] : magic_enum::enum_entries<Race>()) {
raceCombo->addItem(race_name.data());
}
genderCombo = new QComboBox();
connect(genderCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
gearView->setGender((Gender)index);
});
controlLayout->addWidget(genderCombo);
for (auto [gender, gender_name] : magic_enum::enum_entries<Gender>()) {
genderCombo->addItem(gender_name.data());
}
connect(this, &FullModelViewer::gearChanged, this, &FullModelViewer::reloadGear);
reloadGear();
}
void FullModelViewer::clear() {
topSlot.reset();
bottomSlot.reset();
Q_EMIT gearChanged();
}
void FullModelViewer::addGear(GearInfo &info) {
switch(info.slot) {
case Slot::Body:
topSlot = info;
break;
case Slot::Legs:
bottomSlot = info;
break;
default:
break;
}
Q_EMIT gearChanged();
}
void FullModelViewer::reloadGear() {
gearView->clear();
if (topSlot.has_value()) {
gearView->addGear(*topSlot);
} else {
// smallclothes body
GearInfo info = {};
info.name = "Smallclothes Body";
info.slot = Slot::Body;
gearView->addGear(info);
}
if (bottomSlot.has_value()) {
gearView->addGear(*bottomSlot);
} else {
// smallclothes legs
GearInfo info = {};
info.name = "Smallclothes Legs";
info.slot = Slot::Legs;
gearView->addGear(info);
}
}
#include "moc_fullmodelviewer.cpp"