mirror of
https://github.com/redstrate/Novus.git
synced 2025-04-26 13:47:46 +00:00
Gear Editor: General code cleanup
Boring stuff... removing unnecessary lambdas, variables and more.
This commit is contained in:
parent
0cf37355cb
commit
0a488807f6
11 changed files with 34 additions and 75 deletions
|
@ -13,7 +13,4 @@ class BoneEditor : public SklbPart
|
|||
|
||||
public:
|
||||
explicit BoneEditor(GearView *gearView, QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
GearView *gearView = nullptr;
|
||||
};
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "boneeditor.h"
|
||||
#include "gearview.h"
|
||||
|
||||
struct GameData;
|
||||
class FileCache;
|
||||
class QGroupBox;
|
||||
class BoneEditor;
|
||||
|
||||
class FullModelViewer : public QMainWindow
|
||||
{
|
||||
|
|
|
@ -27,14 +27,14 @@ class GearListModel : public QAbstractItemModel
|
|||
public:
|
||||
explicit GearListModel(GameData *data, QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
|
||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
|
||||
QModelIndex parent(const QModelIndex &child) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
std::optional<GearInfo> getGearFromIndex(const QModelIndex &index);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ class SingleGearView : public QWidget
|
|||
public:
|
||||
explicit SingleGearView(GameData *data, FileCache &cache, QWidget *parent = nullptr);
|
||||
|
||||
QString getLoadedGearPath() const;
|
||||
QList<physis_Material> getLoadedMaterials() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -62,7 +61,6 @@ private:
|
|||
QComboBox *raceCombo, *subraceCombo, *genderCombo, *lodCombo;
|
||||
QPushButton *addToFMVButton, *editButton, *importButton, *exportButton;
|
||||
|
||||
bool loadingComboData = false;
|
||||
bool fmvAvailable = false;
|
||||
|
||||
GameData *data = nullptr;
|
||||
|
|
|
@ -7,15 +7,12 @@
|
|||
|
||||
BoneEditor::BoneEditor(GearView *gearView, QWidget *parent)
|
||||
: SklbPart(parent)
|
||||
, gearView(gearView)
|
||||
{
|
||||
connect(&gearView->part(), &MDLPart::skeletonChanged, this, [this, gearView] {
|
||||
load(*gearView->part().skeleton);
|
||||
});
|
||||
|
||||
connect(this, &SklbPart::valueChanged, this, [gearView] {
|
||||
gearView->part().reloadRenderer();
|
||||
});
|
||||
connect(this, &SklbPart::valueChanged, &gearView->part(), &MDLPart::reloadRenderer);
|
||||
|
||||
if (gearView->part().skeleton) {
|
||||
load(*gearView->part().skeleton);
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "fullmodelviewer.h"
|
||||
|
||||
#include "boneeditor.h"
|
||||
#include "magic_enum.hpp"
|
||||
#include <KLocalizedString>
|
||||
#include <QCheckBox>
|
||||
#include <QCloseEvent>
|
||||
|
@ -15,6 +13,9 @@
|
|||
#include <QRadioButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "boneeditor.h"
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
FullModelViewer::FullModelViewer(GameData *data, FileCache &cache, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, data(data)
|
||||
|
|
|
@ -35,7 +35,7 @@ GearListModel::GearListModel(GameData *data, QObject *parent)
|
|||
connect(exdFuture, &QFutureWatcher<physis_EXD>::resultReadyAt, this, &GearListModel::exdFinished);
|
||||
connect(exdFuture, &QFutureWatcher<physis_EXD>::finished, this, &GearListModel::finished);
|
||||
|
||||
QVector<int> pages;
|
||||
QVector<uint32_t> pages;
|
||||
for (uint32_t i = 0; i < exh->page_count; i++) {
|
||||
pages.push_back(i);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ int GearListModel::rowCount(const QModelIndex &parent) const
|
|||
else
|
||||
parentItem = static_cast<TreeInformation *>(parent.internalPointer());
|
||||
|
||||
return parentItem->children.size();
|
||||
return static_cast<int>(parentItem->children.size());
|
||||
}
|
||||
|
||||
int GearListModel::columnCount(const QModelIndex &parent) const
|
||||
|
@ -134,7 +134,7 @@ QVariant GearListModel::data(const QModelIndex &index, int role) const
|
|||
if (texFile.data != nullptr) {
|
||||
auto tex = physis_texture_parse(texFile);
|
||||
if (tex.rgba != nullptr) {
|
||||
QImage image(tex.rgba, tex.width, tex.height, QImage::Format_RGBA8888);
|
||||
QImage image(tex.rgba, static_cast<int>(tex.width), static_cast<int>(tex.height), QImage::Format_RGBA8888);
|
||||
|
||||
QPixmap pixmap;
|
||||
pixmap.convertFromImage(image);
|
||||
|
|
|
@ -28,9 +28,7 @@ GearListWidget::GearListWidget(GameData *data, QWidget *parent)
|
|||
searchEdit->setPlaceholderText(i18nc("@info:placeholder Search through items", "Search…"));
|
||||
searchEdit->setClearButtonEnabled(true);
|
||||
searchEdit->setProperty("_breeze_borders_sides", QVariant::fromValue(QFlags{Qt::BottomEdge}));
|
||||
connect(searchEdit, &QLineEdit::textChanged, this, [=](const QString &text) {
|
||||
searchModel->setFilterRegularExpression(text);
|
||||
});
|
||||
connect(searchEdit, &QLineEdit::textChanged, searchModel, qOverload<const QString &>(&QSortFilterProxyModel::setFilterRegularExpression));
|
||||
layout->addWidget(searchEdit);
|
||||
|
||||
auto originalModel = new GearListModel(data);
|
||||
|
|
|
@ -108,7 +108,7 @@ void GearView::addGear(GearInfo &gear)
|
|||
|
||||
queuedGearAdditions.emplace_back(gear);
|
||||
|
||||
for (auto loadedGear : loadedGears) {
|
||||
for (const auto &loadedGear : loadedGears) {
|
||||
if (loadedGear.info.slot == gear.slot) {
|
||||
queuedGearRemovals.push_back(loadedGear);
|
||||
}
|
||||
|
@ -265,7 +265,6 @@ void GearView::reloadRaceDeforms()
|
|||
qDebug() << "Loading race deform matrices for " << magic_enum::enum_name(currentRace).data() << magic_enum::enum_name(currentSubrace).data()
|
||||
<< magic_enum::enum_name(currentGender).data();
|
||||
const int raceCode = physis_get_race_code(currentRace, currentSubrace, currentGender);
|
||||
qDebug() << "Race code: " << raceCode;
|
||||
|
||||
QString skelName = QStringLiteral("chara/human/c%1/skeleton/base/b0001/skl_c%1b0001.sklb").arg(raceCode, 4, 10, QLatin1Char{'0'});
|
||||
std::string skelNameStd = skelName.toStdString();
|
||||
|
@ -297,7 +296,6 @@ void GearView::updatePart()
|
|||
auto 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);
|
||||
auto mdl_data = cache.lookupFile(mdlPath);
|
||||
|
||||
// attempt to load the next best race
|
||||
|
@ -313,11 +311,11 @@ void GearView::updatePart()
|
|||
}
|
||||
|
||||
if (fallbackRace != currentRace) {
|
||||
qInfo() << "Fell back to hyur race for" << mdlPath;
|
||||
qDebug() << "Fell back to hyur race for" << mdlPath;
|
||||
}
|
||||
|
||||
if (fallbackSubrace != currentSubrace) {
|
||||
qInfo() << "Fell back to midlander subrace for" << mdlPath;
|
||||
qDebug() << "Fell back to midlander subrace for" << mdlPath;
|
||||
}
|
||||
|
||||
if (mdl_data.size > 0) {
|
||||
|
|
|
@ -38,16 +38,11 @@ MainWindow::MainWindow(GameData *in_data)
|
|||
|
||||
auto gearListWidget = new GearListWidget(&data);
|
||||
gearListWidget->setMaximumWidth(350);
|
||||
connect(gearListWidget, &GearListWidget::gearSelected, this, [this](const GearInfo &gear) {
|
||||
gearView->setGear(gear);
|
||||
});
|
||||
dummyWidget->addWidget(gearListWidget);
|
||||
|
||||
gearView = new SingleGearView(&data, cache);
|
||||
connect(gearView, &SingleGearView::addToFullModelViewer, this, [this](GearInfo &info) {
|
||||
fullModelViewer->addGear(info);
|
||||
});
|
||||
connect(gearView, &SingleGearView::importedModel, m_api, &PenumbraApi::redrawAll);
|
||||
connect(gearListWidget, &GearListWidget::gearSelected, gearView, &SingleGearView::setGear);
|
||||
|
||||
materialsView = new QTabWidget();
|
||||
|
||||
|
@ -65,6 +60,7 @@ MainWindow::MainWindow(GameData *in_data)
|
|||
connect(fullModelViewer, &FullModelViewer::loadingChanged, this, [this](const bool loading) {
|
||||
gearView->setFMVAvailable(!loading);
|
||||
});
|
||||
connect(gearView, &SingleGearView::addToFullModelViewer, fullModelViewer, &FullModelViewer::addGear);
|
||||
|
||||
connect(gearView, &SingleGearView::doneLoadingModel, this, [this, in_data] {
|
||||
materialsView->clear();
|
||||
|
@ -125,15 +121,11 @@ void MainWindow::setupActions()
|
|||
actionCollection()->addAction(QStringLiteral("cmp_editor"), cmpEditorAction);
|
||||
|
||||
auto redrawAction = new QAction(i18nc("@action:inmenu", "Redraw All"));
|
||||
connect(redrawAction, &QAction::triggered, [this] {
|
||||
m_api->redrawAll();
|
||||
});
|
||||
connect(redrawAction, &QAction::triggered, m_api, &PenumbraApi::redrawAll);
|
||||
actionCollection()->addAction(QStringLiteral("redraw_all"), redrawAction);
|
||||
|
||||
auto openWindowAction = new QAction(i18nc("@action:inmenu", "Open Window"));
|
||||
connect(openWindowAction, &QAction::triggered, [this] {
|
||||
m_api->openWindow();
|
||||
});
|
||||
connect(openWindowAction, &QAction::triggered, m_api, &PenumbraApi::openWindow);
|
||||
actionCollection()->addAction(QStringLiteral("open_window"), openWindowAction);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
|
@ -20,17 +19,15 @@
|
|||
|
||||
SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, gearView(new GearView(data, cache))
|
||||
, data(data)
|
||||
{
|
||||
gearView = new GearView(data, cache);
|
||||
|
||||
// We don't want to see the face in this view
|
||||
gearView->setHair(-1);
|
||||
gearView->setEar(-1);
|
||||
gearView->setFace(-1);
|
||||
|
||||
auto layout = new QVBoxLayout();
|
||||
// layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(layout);
|
||||
|
||||
auto mdlPathEdit = new QLineEdit();
|
||||
|
@ -51,36 +48,24 @@ SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent
|
|||
|
||||
raceCombo = new QComboBox();
|
||||
connect(raceCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if (loadingComboData)
|
||||
return;
|
||||
|
||||
setRace(static_cast<Race>(raceCombo->itemData(index).toInt()));
|
||||
});
|
||||
controlLayout->addWidget(raceCombo);
|
||||
|
||||
subraceCombo = new QComboBox();
|
||||
connect(subraceCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if (loadingComboData)
|
||||
return;
|
||||
|
||||
setSubrace(static_cast<Subrace>(subraceCombo->itemData(index).toInt()));
|
||||
});
|
||||
controlLayout->addWidget(subraceCombo);
|
||||
|
||||
genderCombo = new QComboBox();
|
||||
connect(genderCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if (loadingComboData)
|
||||
return;
|
||||
|
||||
setGender(static_cast<Gender>(genderCombo->itemData(index).toInt()));
|
||||
});
|
||||
controlLayout->addWidget(genderCombo);
|
||||
|
||||
lodCombo = new QComboBox();
|
||||
connect(lodCombo, qOverload<int>(&QComboBox::currentIndexChanged), [this](int index) {
|
||||
if (loadingComboData)
|
||||
return;
|
||||
|
||||
setLevelOfDetail(index);
|
||||
});
|
||||
controlLayout->addWidget(lodCombo);
|
||||
|
@ -282,8 +267,6 @@ void SingleGearView::setSubrace(Subrace subrace)
|
|||
return;
|
||||
}
|
||||
|
||||
qInfo() << "Setting subrace to" << magic_enum::enum_name(subrace);
|
||||
|
||||
currentSubrace = subrace;
|
||||
Q_EMIT subraceChanged();
|
||||
}
|
||||
|
@ -321,7 +304,10 @@ void SingleGearView::reloadGear()
|
|||
editButton->setEnabled(currentGear.has_value());
|
||||
|
||||
if (currentGear.has_value()) {
|
||||
loadingComboData = true;
|
||||
QSignalBlocker raceBlocker(raceCombo);
|
||||
QSignalBlocker subraceBlocker(subraceCombo);
|
||||
QSignalBlocker genderBlocker(genderCombo);
|
||||
QSignalBlocker lodBlocker(lodCombo);
|
||||
|
||||
const auto oldRace = static_cast<Race>(raceCombo->itemData(raceCombo->currentIndex()).toInt());
|
||||
const auto oldSubrace = static_cast<Subrace>(subraceCombo->itemData(subraceCombo->currentIndex()).toInt());
|
||||
|
@ -392,8 +378,6 @@ void SingleGearView::reloadGear()
|
|||
if (oldLod < gearView->lodCount()) {
|
||||
lodCombo->setCurrentIndex(oldLod);
|
||||
}
|
||||
|
||||
loadingComboData = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,11 +389,6 @@ void SingleGearView::setFMVAvailable(const bool available)
|
|||
}
|
||||
}
|
||||
|
||||
QString SingleGearView::getLoadedGearPath() const
|
||||
{
|
||||
return gearView->getLoadedGearPath();
|
||||
}
|
||||
|
||||
void SingleGearView::importModel(const QString &filename)
|
||||
{
|
||||
auto &mdl = gearView->part().getModel(0);
|
||||
|
@ -418,14 +397,14 @@ void SingleGearView::importModel(const QString &filename)
|
|||
|
||||
gearView->part().reloadModel(0);
|
||||
|
||||
KConfig config(QStringLiteral("novusrc"));
|
||||
KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||
QString outputDirectory = game.readEntry(QStringLiteral("PenumbraOutputDirectory"));
|
||||
const KConfig config(QStringLiteral("novusrc"));
|
||||
const KConfigGroup game = config.group(QStringLiteral("Armoury"));
|
||||
const QDir outputDirectory = game.readEntry(QStringLiteral("PenumbraOutputDirectory"));
|
||||
|
||||
QFileInfo info(QStringLiteral("%1/%2").arg(outputDirectory, gearView->getLoadedGearPath()));
|
||||
const QFileInfo info(outputDirectory.absoluteFilePath(gearView->getLoadedGearPath()));
|
||||
|
||||
auto buffer = physis_mdl_write(&mdl.model);
|
||||
QFile file(QStringLiteral("%1/%2").arg(outputDirectory, gearView->getLoadedGearPath()));
|
||||
QFile file(info.absoluteFilePath());
|
||||
|
||||
if (!QDir().exists(info.absolutePath()))
|
||||
QDir().mkpath(info.absolutePath());
|
||||
|
@ -434,7 +413,6 @@ void SingleGearView::importModel(const QString &filename)
|
|||
file.write(reinterpret_cast<char *>(buffer.data), buffer.size);
|
||||
file.close();
|
||||
|
||||
qInfo() << "Successfully imported model!";
|
||||
Q_EMIT importedModel();
|
||||
}
|
||||
|
||||
|
@ -443,8 +421,8 @@ QList<physis_Material> SingleGearView::getLoadedMaterials() const
|
|||
QList<physis_Material> materialPaths;
|
||||
|
||||
for (int i = 0; i < gearView->part().numModels(); i++) {
|
||||
auto model = gearView->part().getModel(i);
|
||||
for (auto material : model.materials) {
|
||||
const auto &model = gearView->part().getModel(i);
|
||||
for (const auto &material : model.materials) {
|
||||
materialPaths.push_back(material.mat);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue