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

armoury: Reformat code, misc cleanup

This commit is contained in:
Joshua Goins 2023-10-12 23:44:48 -04:00
parent 4c3a9795d2
commit 0711ec24ca
21 changed files with 339 additions and 256 deletions

View file

@ -3,8 +3,6 @@
#pragma once
#include "quaternionedit.h"
#include "vec3edit.h"
#include <QSpinBox>
#include <QTreeWidgetItem>
#include <QWidget>
@ -12,18 +10,22 @@
#include <glm/glm.hpp>
#include <physis.hpp>
#include "quaternionedit.h"
#include "vec3edit.h"
class GearView;
class BoneEditor : public QWidget {
class BoneEditor : public QWidget
{
Q_OBJECT
public:
explicit BoneEditor(GearView* gearView, QWidget* parent = nullptr);
explicit BoneEditor(GearView *gearView, QWidget *parent = nullptr);
private:
void treeItemClicked(QTreeWidgetItem* item, int column);
void treeItemClicked(QTreeWidgetItem *item, int column);
GearView* gearView;
GearView *gearView;
glm::vec3 currentPosition;
glm::quat currentRotation;
@ -33,13 +35,13 @@ private:
glm::quat currentRaceRotation;
glm::vec3 currentRaceScale;
physis_Bone* currentEditedBone;
physis_Bone *currentEditedBone = nullptr;
Vector3Edit* posEdit;
QuaternionEdit* rotationEdit;
Vector3Edit* scaleEdit;
Vector3Edit *posEdit = nullptr;
QuaternionEdit *rotationEdit = nullptr;
Vector3Edit *scaleEdit = nullptr;
Vector3Edit* raceDeformPosEdit;
QuaternionEdit* raceDeformRotationEdit;
Vector3Edit* raceDeformScaleEdit;
Vector3Edit *raceDeformPosEdit = nullptr;
QuaternionEdit *raceDeformRotationEdit = nullptr;
Vector3Edit *raceDeformScaleEdit = nullptr;
};

View file

@ -7,44 +7,51 @@
#include <QWidget>
#include <physis.hpp>
class RaceTreeData : public QObject {
class RaceTreeData : public QObject
{
Q_OBJECT
public:
RaceTreeData(Race race, Subrace subrace) : race(race), subrace(subrace) {}
RaceTreeData(Race race, Subrace subrace)
: race(race)
, subrace(subrace)
{
}
Race race;
Subrace subrace;
};
class CmpEditor : public QWidget {
class CmpEditor : public QWidget
{
Q_OBJECT
public:
explicit CmpEditor(GameData* data);
explicit CmpEditor(GameData *data, QWidget *parent = nullptr);
private:
void loadRaceData(Race race, Subrace subrace);
GameData* data;
GameData *data = nullptr;
physis_CMP cmp;
QDoubleSpinBox* maleMinSize;
QDoubleSpinBox* maleMaxSize;
QDoubleSpinBox *maleMinSize = nullptr;
QDoubleSpinBox *maleMaxSize = nullptr;
QDoubleSpinBox* maleMinTail;
QDoubleSpinBox* maleMaxTail;
QDoubleSpinBox *maleMinTail = nullptr;
QDoubleSpinBox *maleMaxTail = nullptr;
QDoubleSpinBox* femaleMinSize;
QDoubleSpinBox* femaleMaxSize;
QDoubleSpinBox *femaleMinSize = nullptr;
QDoubleSpinBox *femaleMaxSize = nullptr;
QDoubleSpinBox* femaleMinTail;
QDoubleSpinBox* femaleMaxTail;
QDoubleSpinBox *femaleMinTail = nullptr;
QDoubleSpinBox *femaleMaxTail = nullptr;
QDoubleSpinBox* bustMinX;
QDoubleSpinBox* bustMinY;
QDoubleSpinBox* bustMinZ;
QDoubleSpinBox *bustMinX = nullptr;
QDoubleSpinBox *bustMinY = nullptr;
QDoubleSpinBox *bustMinZ = nullptr;
QDoubleSpinBox* bustMaxX;
QDoubleSpinBox* bustMaxY;
QDoubleSpinBox* bustMaxZ;
QDoubleSpinBox *bustMaxX = nullptr;
QDoubleSpinBox *bustMaxY = nullptr;
QDoubleSpinBox *bustMaxZ = nullptr;
};

View file

@ -11,10 +11,12 @@
struct GameData;
class FileCache;
class FullModelViewer : public QMainWindow {
class FullModelViewer : public QMainWindow
{
Q_OBJECT
public:
explicit FullModelViewer(GameData* data, FileCache& cache);
explicit FullModelViewer(GameData *data, FileCache &cache, QWidget *parent = nullptr);
Q_SIGNALS:
void gearChanged();
@ -22,7 +24,7 @@ Q_SIGNALS:
public Q_SLOTS:
void clear();
void addGear(GearInfo& info);
void addGear(GearInfo &info);
private Q_SLOTS:
void reloadGear();
@ -33,18 +35,18 @@ private:
void updateCharacterParameters();
void updateSupportedSubraces();
QGroupBox* addFaceGroup();
QGroupBox* addHairGroup();
QGroupBox* addEarGroup();
QGroupBox* addTailGroup();
QGroupBox *addFaceGroup();
QGroupBox *addHairGroup();
QGroupBox *addEarGroup();
QGroupBox *addTailGroup();
std::optional<GearInfo> topSlot;
std::optional<GearInfo> bottomSlot;
GearView* gearView = nullptr;
QComboBox *raceCombo, *subraceCombo, *genderCombo;
GearView *gearView = nullptr;
QComboBox *raceCombo = nullptr, *subraceCombo = nullptr, *genderCombo = nullptr;
GameData* data = nullptr;
GameData *data = nullptr;
physis_CMP cmp;
float heightScale = 0.5f;

View file

@ -8,48 +8,45 @@
#include "gearview.h"
enum class TreeType {
Root,
Category,
Item
};
enum class TreeType { Root, Category, Item };
struct TreeInformation {
TreeType type;
std::optional<Slot> slotType;
TreeInformation* parent = nullptr;
TreeInformation *parent = nullptr;
std::optional<GearInfo> gear;
int row = 0;
std::vector<TreeInformation*> children;
std::vector<TreeInformation *> children;
};
class GearListModel : public QAbstractItemModel {
class GearListModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit GearListModel(GameData* data);
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 = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& child) const override;
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) 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;
std::optional<GearInfo> getGearFromIndex(const QModelIndex& index);
std::optional<GearInfo> getGearFromIndex(const QModelIndex &index);
private:
void exdFinished(int index);
void finished();
QFutureWatcher<physis_EXD>* exdFuture;
QFutureWatcher<physis_EXD> *exdFuture;
std::vector<GearInfo> gears;
QStringList slotNames;
GameData* gameData = nullptr;
TreeInformation* rootItem = nullptr;
GameData *gameData = nullptr;
TreeInformation *rootItem = nullptr;
};

View file

@ -9,17 +9,18 @@
#include "gearview.h"
class GearListWidget : public QWidget {
class GearListWidget : public QWidget
{
Q_OBJECT
public:
explicit GearListWidget(GameData* data, QWidget* parent = nullptr);
explicit GearListWidget(GameData *data, QWidget *parent = nullptr);
Q_SIGNALS:
void gearSelected(const GearInfo& gear);
void gearSelected(const GearInfo &gear);
private:
QTreeView* listWidget = nullptr;
QTreeView *listWidget = nullptr;
GameData* data = nullptr;
GameData *data = nullptr;
};

View file

@ -19,7 +19,8 @@ struct GearInfo {
Slot slot;
ModelInfo modelInfo;
std::string getMtrlPath(const std::string_view material_name) const {
std::string getMtrlPath(const std::string_view material_name) const
{
return physis_build_gear_material_path(modelInfo.primaryID, modelInfo.gearVersion, material_name.data());
}
};
@ -31,10 +32,12 @@ inline bool operator==(const GearInfo &a, const GearInfo &b)
struct GameData;
class GearView : public QWidget {
class GearView : public QWidget
{
Q_OBJECT
public:
explicit GearView(GameData* data, FileCache& cache);
explicit GearView(GameData *data, FileCache &cache, QWidget *parent = nullptr);
/// Returns an inclusive list of races supported by the current gearset.
std::vector<std::pair<Race, Subrace>> supportedRaces() const;
@ -45,9 +48,9 @@ public:
/// Returns an inclusive list of LoDs supported by the current gearset.
int lodCount() const;
void exportModel(const QString& fileName);
void exportModel(const QString &fileName);
MDLPart& part() const;
MDLPart &part() const;
Race currentRace = Race::Hyur;
Subrace currentSubrace = Subrace::Midlander;
@ -71,7 +74,7 @@ Q_SIGNALS:
void tailChanged();
public Q_SLOTS:
void addGear(GearInfo& gear);
void addGear(GearInfo &gear);
void removeGear(GearInfo &gear);
void setRace(Race race);
@ -106,15 +109,12 @@ private:
bool faceDirty = false, hairDirty = false, earDirty = false, tailDirty = false;
bool raceDirty = false;
MDLPart* mdlPart = nullptr;
MDLPart *mdlPart = nullptr;
GameData* data;
FileCache& cache;
GameData *data;
FileCache &cache;
bool updating = false;
void updatePart();
bool needsUpdate() const;
void gearUpdate(LoadedGear &gear);
void queueGearUpdate(LoadedGear &gear);
};

View file

@ -17,16 +17,18 @@ class FileCache;
class MainWindow : public NovusMainWindow
{
Q_OBJECT
public:
explicit MainWindow(GameData* data);
explicit MainWindow(GameData *data);
protected:
void setupAdditionalMenus(QMenuBar *menuBar) override;
private:
SingleGearView* gearView = nullptr;
FullModelViewer* fullModelViewer = nullptr;
SingleGearView *gearView = nullptr;
FullModelViewer *fullModelViewer = nullptr;
GameData& data;
GameData &data;
FileCache cache;
};

View file

@ -8,12 +8,14 @@
#include <glm/glm.hpp>
class QuaternionEdit : public QWidget {
class QuaternionEdit : public QWidget
{
Q_OBJECT
public:
explicit QuaternionEdit(glm::quat& quat, QWidget* parent = nullptr);
void setQuat(glm::quat& quat);
public:
explicit QuaternionEdit(glm::quat &quat, QWidget *parent = nullptr);
void setQuat(glm::quat &quat);
Q_SIGNALS:
void onValueChanged();
@ -23,5 +25,5 @@ private:
QDoubleSpinBox *x, *y, *z;
} spinBoxes;
glm::quat& quat;
glm::quat &quat;
};

View file

@ -10,11 +10,12 @@
struct GameData;
class SingleGearView : public QWidget {
class SingleGearView : public QWidget
{
Q_OBJECT
public:
explicit SingleGearView(GameData* data, FileCache& cache);
explicit SingleGearView(GameData *data, FileCache &cache, QWidget *parent = nullptr);
QString getLoadedGearPath() const;
@ -27,11 +28,11 @@ Q_SIGNALS:
void genderChanged();
void levelOfDetailChanged();
void addToFullModelViewer(GearInfo& info);
void addToFullModelViewer(GearInfo &info);
public Q_SLOTS:
void clear();
void setGear(const GearInfo& info);
void setGear(const GearInfo &info);
void setRace(Race race);
void setSubrace(Subrace subrace);
@ -51,12 +52,12 @@ private:
Gender currentGender = Gender::Male;
int currentLod = 0;
GearView* gearView = nullptr;
GearView *gearView = nullptr;
QComboBox *raceCombo, *subraceCombo, *genderCombo, *lodCombo;
QPushButton *addToFMVButton, *importButton, *exportButton;
bool loadingComboData = false;
bool fmvAvailable = false;
GameData* data = nullptr;
GameData *data = nullptr;
};

View file

@ -7,13 +7,15 @@
#include <QWidget>
#include <glm/glm.hpp>
class Vector3Edit : public QWidget {
class Vector3Edit : public QWidget
{
Q_OBJECT
public:
explicit Vector3Edit(glm::vec3& vec, QWidget* parent = nullptr);
explicit Vector3Edit(glm::vec3 &vec, QWidget *parent = nullptr);
~Vector3Edit();
void setVector(glm::vec3& vec);
void setVector(glm::vec3 &vec);
Q_SIGNALS:
void onValueChanged();
@ -23,6 +25,6 @@ private:
QDoubleSpinBox *x, *y, *z;
} spinBoxes;
glm::vec3& vec;
QTimer* updateTimer;
glm::vec3 &vec;
QTimer *updateTimer;
};

View file

@ -14,11 +14,8 @@
#include "quaternionedit.h"
#include "vec3edit.h"
void addItem(
physis_Skeleton& skeleton,
physis_Bone& bone,
QTreeWidget* widget,
QTreeWidgetItem* parent_item = nullptr) {
void addItem(physis_Skeleton &skeleton, physis_Bone &bone, QTreeWidget *widget, QTreeWidgetItem *parent_item = nullptr)
{
auto item = new QTreeWidgetItem();
item->setText(0, QLatin1String(bone.name));
@ -34,7 +31,9 @@ void addItem(
}
}
BoneEditor::BoneEditor(GearView* gearView, QWidget* parent) : gearView(gearView) {
BoneEditor::BoneEditor(GearView *gearView, QWidget *parent)
: gearView(gearView)
{
auto layout = new QHBoxLayout();
setLayout(layout);
@ -96,8 +95,9 @@ BoneEditor::BoneEditor(GearView* gearView, QWidget* parent) : gearView(gearView)
raceDeformGroupLayout->addRow(QStringLiteral("Scale"), raceDeformScaleEdit);
}
void BoneEditor::treeItemClicked(QTreeWidgetItem* item, int column) {
auto& skeleton = *gearView->part().skeleton;
void BoneEditor::treeItemClicked(QTreeWidgetItem *item, int column)
{
auto &skeleton = *gearView->part().skeleton;
for (int i = 0; i < skeleton.num_bones; i++) {
if (strcmp(skeleton.bones[i].name, item->text(column).toStdString().c_str()) == 0) {
currentPosition = glm::make_vec3(skeleton.bones[i].position);
@ -115,8 +115,7 @@ void BoneEditor::treeItemClicked(QTreeWidgetItem* item, int column) {
glm::vec3 translation;
glm::vec3 skew;
glm::vec4 perspective;
glm::decompose(
gearView->part().boneData[i].deformRaceMatrix, scale, rotation, translation, skew, perspective);
glm::decompose(gearView->part().boneData[i].deformRaceMatrix, scale, rotation, translation, skew, perspective);
currentRacePosition = translation;
currentRaceRotation = rotation;

View file

@ -16,8 +16,7 @@ struct RaceTree {
std::vector<Subrace> subRaces;
};
std::vector<RaceTree> raceTree = {
{Race::Hyur, {Subrace::Midlander, Subrace::Highlander}},
std::vector<RaceTree> raceTree = {{Race::Hyur, {Subrace::Midlander, Subrace::Highlander}},
{Race::Elezen, {Subrace::Wildwood, Subrace::Duskwight}},
{Race::Miqote, {Subrace::Seeker, Subrace::Keeper}},
{Race::Roegadyn, {Subrace::SeaWolf, Subrace::Hellion}},
@ -26,7 +25,10 @@ std::vector<RaceTree> raceTree = {
{Race::Hrothgar, {Subrace::Hellion, Subrace::Lost}},
{Race::Viera, {Subrace::Rava, Subrace::Veena}}};
CmpEditor::CmpEditor(GameData* data) : data(data) {
CmpEditor::CmpEditor(GameData *data, QWidget *parent)
: QWidget(parent)
, data(data)
{
setWindowTitle(QStringLiteral("CMP Editor"));
auto layout = new QHBoxLayout();
@ -53,8 +55,8 @@ CmpEditor::CmpEditor(GameData* data) : data(data) {
raceListWidget->expandAll();
connect(raceListWidget, &QTreeWidget::itemClicked, [this](QTreeWidgetItem* item, int column) {
if (auto treeData = qvariant_cast<RaceTreeData*>(item->data(0, Qt::UserRole))) {
connect(raceListWidget, &QTreeWidget::itemClicked, [this](QTreeWidgetItem *item, int column) {
if (auto treeData = qvariant_cast<RaceTreeData *>(item->data(0, Qt::UserRole))) {
loadRaceData(treeData->race, treeData->subrace);
}
});
@ -109,7 +111,8 @@ CmpEditor::CmpEditor(GameData* data) : data(data) {
loadRaceData(Race::Hyur, Subrace::Midlander);
}
void CmpEditor::loadRaceData(Race race, Subrace subrace) {
void CmpEditor::loadRaceData(Race race, Subrace subrace)
{
auto raceData = physis_cmp_get_racial_scaling_parameters(cmp, race, subrace);
maleMinSize->setValue(raceData.male_min_size);

View file

@ -12,7 +12,10 @@
#include <QRadioButton>
#include <QVBoxLayout>
FullModelViewer::FullModelViewer(GameData* data, FileCache& cache) : data(data) {
FullModelViewer::FullModelViewer(GameData *data, FileCache &cache, QWidget *parent)
: QMainWindow(parent)
, data(data)
{
setWindowTitle(QStringLiteral("Full Model Viewer"));
setMinimumWidth(1280);
setMinimumHeight(720);
@ -37,7 +40,7 @@ FullModelViewer::FullModelViewer(GameData* data, FileCache& cache) : data(data)
gearView->setRace(charDat.race);
gearView->setGender(charDat.gender);
//gearView->setSubrace(charDat.subrace);
// gearView->setSubrace(charDat.subrace);
gearView->setFace(charDat.head);
gearView->setHair(charDat.hair);
updateBustScaling((float)charDat.bust / 100.0f);
@ -133,14 +136,16 @@ FullModelViewer::FullModelViewer(GameData* data, FileCache& cache) : data(data)
reloadGear();
}
void FullModelViewer::clear() {
void FullModelViewer::clear()
{
topSlot.reset();
bottomSlot.reset();
Q_EMIT gearChanged();
}
void FullModelViewer::addGear(GearInfo& info) {
void FullModelViewer::addGear(GearInfo &info)
{
switch (info.slot) {
case Slot::Body:
if (topSlot ? *topSlot != info : true) {
@ -202,18 +207,16 @@ void FullModelViewer::reloadGear()
}
}
void FullModelViewer::updateHeightScaling(float scale) {
auto& boneData = *gearView->part().skeleton;
void FullModelViewer::updateHeightScaling(float scale)
{
auto &boneData = *gearView->part().skeleton;
for (int i = 0; i < boneData.num_bones; i++) {
const std::string_view name{boneData.bones[i].name};
if (name == "n_root") {
auto racialScaling =
physis_cmp_get_racial_scaling_parameters(cmp, gearView->currentRace, gearView->currentSubrace);
auto racialScaling = physis_cmp_get_racial_scaling_parameters(cmp, gearView->currentRace, gearView->currentSubrace);
const float minSize =
gearView->currentGender == Gender::Male ? racialScaling.male_min_size : racialScaling.female_min_size;
const float maxSize =
gearView->currentGender == Gender::Male ? racialScaling.male_max_size : racialScaling.female_max_size;
const float minSize = gearView->currentGender == Gender::Male ? racialScaling.male_min_size : racialScaling.female_min_size;
const float maxSize = gearView->currentGender == Gender::Male ? racialScaling.male_max_size : racialScaling.female_max_size;
const float size = glm::mix(minSize, maxSize, scale);
@ -228,13 +231,13 @@ void FullModelViewer::updateHeightScaling(float scale) {
heightScale = scale;
}
void FullModelViewer::updateBustScaling(float scale) {
auto& boneData = *gearView->part().skeleton;
void FullModelViewer::updateBustScaling(float scale)
{
auto &boneData = *gearView->part().skeleton;
for (int i = 0; i < boneData.num_bones; i++) {
const std::string_view name{boneData.bones[i].name};
if (name == "j_mune_l" || name == "j_mune_r") {
auto racialScaling =
physis_cmp_get_racial_scaling_parameters(cmp, gearView->currentRace, gearView->currentSubrace);
auto racialScaling = physis_cmp_get_racial_scaling_parameters(cmp, gearView->currentRace, gearView->currentSubrace);
const float rangeX = glm::mix(racialScaling.bust_min_x, racialScaling.bust_max_x, scale);
const float rangeY = glm::mix(racialScaling.bust_min_y, racialScaling.bust_max_y, scale);
@ -251,19 +254,22 @@ void FullModelViewer::updateBustScaling(float scale) {
bustScale = scale;
}
void FullModelViewer::updateCharacterParameters() {
void FullModelViewer::updateCharacterParameters()
{
updateHeightScaling(heightScale);
updateBustScaling(bustScale);
}
void FullModelViewer::updateSupportedSubraces() {
void FullModelViewer::updateSupportedSubraces()
{
subraceCombo->clear();
for (auto subrace : physis_get_supported_subraces(gearView->currentRace).subraces) {
subraceCombo->addItem(QLatin1String(magic_enum::enum_name(subrace).data()), (int)subrace);
}
}
QGroupBox* FullModelViewer::addFaceGroup() {
QGroupBox *FullModelViewer::addFaceGroup()
{
auto faceGroup = new QGroupBox(QStringLiteral("Face"));
auto faceGroupLayout = new QVBoxLayout();
faceGroup->setLayout(faceGroupLayout);
@ -289,7 +295,8 @@ QGroupBox* FullModelViewer::addFaceGroup() {
return faceGroup;
}
QGroupBox* FullModelViewer::addHairGroup() {
QGroupBox *FullModelViewer::addHairGroup()
{
auto hairGroup = new QGroupBox(QStringLiteral("Hair"));
auto hairGroupLayout = new QVBoxLayout();
hairGroup->setLayout(hairGroupLayout);
@ -315,7 +322,8 @@ QGroupBox* FullModelViewer::addHairGroup() {
return hairGroup;
}
QGroupBox* FullModelViewer::addEarGroup() {
QGroupBox *FullModelViewer::addEarGroup()
{
auto earGroup = new QGroupBox(QStringLiteral("Ears"));
auto earGroupLayout = new QVBoxLayout();
earGroup->setLayout(earGroupLayout);
@ -341,7 +349,8 @@ QGroupBox* FullModelViewer::addEarGroup() {
return earGroup;
}
QGroupBox* FullModelViewer::addTailGroup() {
QGroupBox *FullModelViewer::addTailGroup()
{
auto tailGroup = new QGroupBox(QStringLiteral("Tail"));
auto tailGroupLayout = new QVBoxLayout();
tailGroup->setLayout(tailGroupLayout);

View file

@ -7,7 +7,10 @@
#include <QtConcurrent>
#include <magic_enum.hpp>
GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemModel() {
GearListModel::GearListModel(GameData *data, QObject *parent)
: QAbstractItemModel(parent)
, gameData(data)
{
// smallclothes body
{
GearInfo info = {};
@ -26,14 +29,14 @@ GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemMode
gears.push_back(info);
}
auto exh = physis_gamedata_read_excel_sheet_header(data, "Item");
auto exh = physis_parse_excel_sheet_header(physis_gamedata_extract_file(data, "exd/item.exh"));
exdFuture = new QFutureWatcher<physis_EXD>(this);
connect(exdFuture, &QFutureWatcher<physis_EXD>::resultReadyAt, this, &GearListModel::exdFinished);
connect(exdFuture, &QFutureWatcher<physis_EXD>::finished, this, &GearListModel::finished);
QVector<int> pages;
for(int i = 0; i < exh->page_count; i++) {
for (int i = 0; i < exh->page_count; i++) {
pages.push_back(i);
}
@ -51,46 +54,50 @@ GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemMode
rootItem->type = TreeType::Root;
}
int GearListModel::rowCount(const QModelIndex& parent) const {
TreeInformation* parentItem;
int GearListModel::rowCount(const QModelIndex &parent) const
{
TreeInformation *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeInformation*>(parent.internalPointer());
parentItem = static_cast<TreeInformation *>(parent.internalPointer());
return parentItem->children.size();
}
int GearListModel::columnCount(const QModelIndex& parent) const {
int GearListModel::columnCount(const QModelIndex &parent) const
{
return 1;
}
QModelIndex GearListModel::index(int row, int column, const QModelIndex& parent) const {
QModelIndex GearListModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
TreeInformation* parentItem;
TreeInformation *parentItem;
if (!parent.isValid())
parentItem = rootItem;
else
parentItem = static_cast<TreeInformation*>(parent.internalPointer());
parentItem = static_cast<TreeInformation *>(parent.internalPointer());
TreeInformation* childItem = parentItem->children[row];
TreeInformation *childItem = parentItem->children[row];
if (childItem)
return createIndex(row, column, childItem);
return QModelIndex();
}
QModelIndex GearListModel::parent(const QModelIndex& index) const {
QModelIndex GearListModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
TreeInformation* childItem = static_cast<TreeInformation*>(index.internalPointer());
TreeInformation* parentItem = childItem->parent;
TreeInformation *childItem = static_cast<TreeInformation *>(index.internalPointer());
TreeInformation *parentItem = childItem->parent;
if (parentItem == rootItem)
return QModelIndex();
@ -98,7 +105,8 @@ QModelIndex GearListModel::parent(const QModelIndex& index) const {
return createIndex(parentItem->row, 0, parentItem);
}
QVariant GearListModel::data(const QModelIndex& index, int role) const {
QVariant GearListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return {};
if (!index.isValid())
@ -107,7 +115,7 @@ QVariant GearListModel::data(const QModelIndex& index, int role) const {
if (role != Qt::DisplayRole)
return QVariant();
TreeInformation* item = static_cast<TreeInformation*>(index.internalPointer());
TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer());
if (item->type == TreeType::Category) {
return QLatin1String(magic_enum::enum_name(*item->slotType).data());
@ -118,7 +126,8 @@ QVariant GearListModel::data(const QModelIndex& index, int role) const {
return {};
}
QVariant GearListModel::headerData(int section, Qt::Orientation orientation, int role) const {
QVariant GearListModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
if (section == 0) {
return QStringLiteral("Name");
@ -128,15 +137,17 @@ QVariant GearListModel::headerData(int section, Qt::Orientation orientation, int
return QAbstractItemModel::headerData(section, orientation, role);
}
std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex& index) {
TreeInformation* item = static_cast<TreeInformation*>(index.internalPointer());
std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex &index)
{
TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer());
if (item->type == TreeType::Item) {
return item->gear;
}
return {};
}
void GearListModel::exdFinished(int index) {
void GearListModel::exdFinished(int index)
{
auto exd = exdFuture->resultAt(index);
for (int i = 0; i < exd.row_count; i++) {
@ -156,12 +167,13 @@ void GearListModel::exdFinished(int index) {
}
}
void GearListModel::finished() {
void GearListModel::finished()
{
beginResetModel();
int i = 0;
for (auto slot : magic_enum::enum_values<Slot>()) {
TreeInformation* categoryItem = new TreeInformation();
TreeInformation *categoryItem = new TreeInformation();
categoryItem->type = TreeType::Category;
categoryItem->slotType = slot;
categoryItem->parent = rootItem;
@ -171,7 +183,7 @@ void GearListModel::finished() {
int j = 0;
for (auto gear : gears) {
if (gear.slot == slot) {
TreeInformation* item = new TreeInformation();
TreeInformation *item = new TreeInformation();
item->type = TreeType::Item;
item->gear = gear;
item->parent = categoryItem;

View file

@ -10,7 +10,10 @@
#include "gearlistmodel.h"
GearListWidget::GearListWidget(GameData* data, QWidget* parent) : data(data) {
GearListWidget::GearListWidget(GameData *data, QWidget *parent)
: QWidget(parent)
, data(data)
{
auto layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout);
@ -22,7 +25,7 @@ GearListWidget::GearListWidget(GameData* data, QWidget* parent) : data(data) {
auto searchEdit = new QLineEdit();
searchEdit->setPlaceholderText(QStringLiteral("Search..."));
searchEdit->setClearButtonEnabled(true);
connect(searchEdit, &QLineEdit::textChanged, this, [=](const QString& text) {
connect(searchEdit, &QLineEdit::textChanged, this, [=](const QString &text) {
searchModel->setFilterRegularExpression(text);
});
layout->addWidget(searchEdit);
@ -33,7 +36,7 @@ GearListWidget::GearListWidget(GameData* data, QWidget* parent) : data(data) {
listWidget = new QTreeView();
listWidget->setModel(searchModel);
connect(listWidget, &QTreeView::clicked, [this, searchModel, originalModel](const QModelIndex& item) {
connect(listWidget, &QTreeView::clicked, [this, searchModel, originalModel](const QModelIndex &item) {
if (auto gear = originalModel->getGearFromIndex(searchModel->mapToSource(item))) {
Q_EMIT gearSelected(*gear);
}

View file

@ -13,7 +13,11 @@
#include "magic_enum.hpp"
#include "utility.h"
GearView::GearView(GameData* data, FileCache& cache) : data(data), cache(cache) {
GearView::GearView(GameData *data, FileCache &cache, QWidget *parent)
: QWidget(parent)
, data(data)
, cache(cache)
{
mdlPart = new MDLPart(data, cache);
reloadRaceDeforms();
@ -55,7 +59,8 @@ GearView::GearView(GameData* data, FileCache& cache) : data(data), cache(cache)
};
}
std::vector<std::pair<Race, Subrace>> GearView::supportedRaces() const {
std::vector<std::pair<Race, Subrace>> GearView::supportedRaces() const
{
std::vector<std::pair<Race, Subrace>> races;
for (const auto &gear : loadedGears) {
for (const auto [race, race_name] : magic_enum::enum_entries<Race>()) {
@ -71,7 +76,8 @@ std::vector<std::pair<Race, Subrace>> GearView::supportedRaces() const {
return races;
}
std::vector<Gender> GearView::supportedGenders() const {
std::vector<Gender> GearView::supportedGenders() const
{
std::vector<Gender> genders;
for (const auto &gear : loadedGears) {
for (auto [gender, gender_name] : magic_enum::enum_entries<Gender>()) {
@ -85,11 +91,13 @@ std::vector<Gender> GearView::supportedGenders() const {
return genders;
}
int GearView::lodCount() const {
int GearView::lodCount() const
{
return maxLod;
}
void GearView::exportModel(const QString& fileName) {
void GearView::exportModel(const QString &fileName)
{
mdlPart->exportModel(fileName);
}
@ -113,7 +121,8 @@ void GearView::removeGear(GearInfo &gear)
Q_EMIT gearChanged();
}
void GearView::setRace(Race race) {
void GearView::setRace(Race race)
{
if (currentRace == race) {
return;
}
@ -136,7 +145,8 @@ void GearView::setRace(Race race) {
Q_EMIT raceChanged();
}
void GearView::setSubrace(Subrace subrace) {
void GearView::setSubrace(Subrace subrace)
{
if (currentSubrace == subrace) {
return;
}
@ -151,7 +161,8 @@ void GearView::setSubrace(Subrace subrace) {
Q_EMIT subraceChanged();
}
void GearView::setGender(Gender gender) {
void GearView::setGender(Gender gender)
{
if (currentGender == gender) {
return;
}
@ -163,7 +174,8 @@ void GearView::setGender(Gender gender) {
Q_EMIT genderChanged();
}
void GearView::setLevelOfDetail(int lod) {
void GearView::setLevelOfDetail(int lod)
{
if (currentLod == lod) {
return;
}
@ -352,8 +364,9 @@ void GearView::updatePart()
std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_face_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *face, material_name);
const char *material_name = mdl.material_names[i];
const std::string skinmtrl_path =
physis_build_face_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *face, material_name);
if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -374,8 +387,9 @@ void GearView::updatePart()
std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_hair_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *hair, material_name);
const char *material_name = mdl.material_names[i];
const std::string skinmtrl_path =
physis_build_hair_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *hair, material_name);
if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -396,8 +410,9 @@ void GearView::updatePart()
std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) {
const char* material_name = mdl.material_names[i];
const std::string skinmtrl_path = physis_build_ear_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *ear, material_name);
const char *material_name = mdl.material_names[i];
const std::string skinmtrl_path =
physis_build_ear_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *ear, material_name);
if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -416,8 +431,9 @@ void GearView::updatePart()
if (mdl_data.size > 0) {
auto mdl = physis_mdl_parse(mdl_data.size, mdl_data.data);
const char* material_name = mdl.material_names[0];
const std::string skinmtrl_path = physis_build_tail_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *tail, material_name);
const char *material_name = mdl.material_names[0];
const std::string skinmtrl_path =
physis_build_tail_material_path(physis_get_race_code(currentRace, currentSubrace, currentGender), *tail, material_name);
if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));

View file

@ -9,11 +9,11 @@
#include "physis_logger.h"
#include "settings.h"
int main(int argc, char* argv[]) {
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
customizeAboutData(
QStringLiteral("armoury"), QStringLiteral("Armoury"), QStringLiteral("Program to view FFXIV gear."));
customizeAboutData(QStringLiteral("armoury"), QStringLiteral("Armoury"), QStringLiteral("Program to view FFXIV gear."));
// Default to a sensible message pattern
if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) {

View file

@ -42,13 +42,13 @@ MainWindow::MainWindow(GameData *in_data)
auto gearListWidget = new GearListWidget(&data);
gearListWidget->setMaximumWidth(350);
connect(gearListWidget, &GearListWidget::gearSelected, this, [=](const GearInfo& gear) {
connect(gearListWidget, &GearListWidget::gearSelected, this, [=](const GearInfo &gear) {
gearView->setGear(gear);
});
layout->addWidget(gearListWidget);
gearView = new SingleGearView(&data, cache);
connect(gearView, &SingleGearView::addToFullModelViewer, this, [=](GearInfo& info) {
connect(gearView, &SingleGearView::addToFullModelViewer, this, [=](GearInfo &info) {
fullModelViewer->addGear(info);
});
@ -74,3 +74,5 @@ void MainWindow::setupAdditionalMenus(QMenuBar *menuBar)
cmpEditor->show();
});
}
#include "moc_mainwindow.cpp"

View file

@ -7,7 +7,10 @@
#include <QTimer>
#include <glm/gtc/quaternion.hpp>
QuaternionEdit::QuaternionEdit(glm::quat& quat, QWidget* parent) : QWidget(parent), quat(quat) {
QuaternionEdit::QuaternionEdit(glm::quat &quat, QWidget *parent)
: QWidget(parent)
, quat(quat)
{
auto itemsLayout = new QHBoxLayout(this);
spinBoxes.x = new QDoubleSpinBox();
@ -36,8 +39,7 @@ QuaternionEdit::QuaternionEdit(glm::quat& quat, QWidget* parent) : QWidget(paren
spinBoxes.y->setValue(euler.y);
spinBoxes.z->setValue(euler.z);
connect(
spinBoxes.x, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
connect(spinBoxes.x, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
auto euler = glm::eulerAngles(this->quat);
euler.x = glm::radians(d);
@ -45,8 +47,7 @@ QuaternionEdit::QuaternionEdit(glm::quat& quat, QWidget* parent) : QWidget(paren
Q_EMIT onValueChanged();
});
connect(
spinBoxes.y, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
connect(spinBoxes.y, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
auto euler = glm::eulerAngles(this->quat);
euler.y = glm::radians(d);
@ -54,8 +55,7 @@ QuaternionEdit::QuaternionEdit(glm::quat& quat, QWidget* parent) : QWidget(paren
Q_EMIT onValueChanged();
});
connect(
spinBoxes.z, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
connect(spinBoxes.z, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this](double d) {
auto euler = glm::eulerAngles(this->quat);
euler.z = glm::radians(d);
@ -65,7 +65,8 @@ QuaternionEdit::QuaternionEdit(glm::quat& quat, QWidget* parent) : QWidget(paren
});
}
void QuaternionEdit::setQuat(glm::quat& quat) {
void QuaternionEdit::setQuat(glm::quat &quat)
{
this->quat = quat;
auto euler = glm::eulerAngles(quat);
euler.x = glm::degrees(euler.x);

View file

@ -12,7 +12,10 @@
#include "filecache.h"
#include "magic_enum.hpp"
SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
SingleGearView::SingleGearView(GameData *data, FileCache &cache, QWidget *parent)
: QWidget(parent)
, data(data)
{
gearView = new GearView(data, cache);
// We don't want to see the face in this view
@ -129,7 +132,8 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
reloadGear();
}
void SingleGearView::clear() {
void SingleGearView::clear()
{
if (currentGear) {
gearView->removeGear(*currentGear);
}
@ -138,7 +142,8 @@ void SingleGearView::clear() {
Q_EMIT gearChanged();
}
void SingleGearView::setGear(const GearInfo& info) {
void SingleGearView::setGear(const GearInfo &info)
{
if (info != currentGear) {
if (currentGear) {
gearView->removeGear(*currentGear);
@ -151,7 +156,8 @@ void SingleGearView::setGear(const GearInfo& info) {
}
}
void SingleGearView::setRace(Race race) {
void SingleGearView::setRace(Race race)
{
if (currentRace == race) {
return;
}
@ -160,7 +166,8 @@ void SingleGearView::setRace(Race race) {
Q_EMIT raceChanged();
}
void SingleGearView::setSubrace(Subrace subrace) {
void SingleGearView::setSubrace(Subrace subrace)
{
if (currentSubrace == subrace) {
return;
}
@ -171,7 +178,8 @@ void SingleGearView::setSubrace(Subrace subrace) {
Q_EMIT subraceChanged();
}
void SingleGearView::setGender(Gender gender) {
void SingleGearView::setGender(Gender gender)
{
if (currentGender == gender) {
return;
}
@ -180,7 +188,8 @@ void SingleGearView::setGender(Gender gender) {
Q_EMIT genderChanged();
}
void SingleGearView::setLevelOfDetail(int lod) {
void SingleGearView::setLevelOfDetail(int lod)
{
if (currentLod == lod) {
return;
}
@ -221,7 +230,12 @@ void SingleGearView::reloadGear()
}
}
if (auto it = std::find_if(supportedRaces.begin(), supportedRaces.end(), [oldRace](auto p) { return std::get<0>(p) == oldRace; }); it != supportedRaces.end()) {
if (auto it = std::find_if(supportedRaces.begin(),
supportedRaces.end(),
[oldRace](auto p) {
return std::get<0>(p) == oldRace;
});
it != supportedRaces.end()) {
raceCombo->setCurrentIndex(std::distance(supportedRaces.begin(), it));
}
@ -232,7 +246,12 @@ void SingleGearView::reloadGear()
}
}
if (auto it = std::find_if(supportedRaces.begin(), supportedRaces.end(), [oldSubrace](auto p) { return std::get<1>(p) == oldSubrace; }); it != supportedRaces.end()) {
if (auto it = std::find_if(supportedRaces.begin(),
supportedRaces.end(),
[oldSubrace](auto p) {
return std::get<1>(p) == oldSubrace;
});
it != supportedRaces.end()) {
subraceCombo->setCurrentIndex(std::distance(supportedRaces.begin(), it));
}
@ -244,7 +263,12 @@ void SingleGearView::reloadGear()
genderCombo->addItem(QLatin1String(magic_enum::enum_name(gender).data()), static_cast<int>(gender));
}
if (auto it = std::find_if(supportedGenders.begin(), supportedGenders.end(), [oldGender](auto p) { return p == oldGender; }); it != supportedGenders.end()) {
if (auto it = std::find_if(supportedGenders.begin(),
supportedGenders.end(),
[oldGender](auto p) {
return p == oldGender;
});
it != supportedGenders.end()) {
genderCombo->setCurrentIndex(std::distance(supportedGenders.begin(), it));
}

View file

@ -6,8 +6,11 @@
#include <QHBoxLayout>
#include <QTimer>
Vector3Edit::Vector3Edit(glm::vec3& vec, QWidget* parent) : QWidget(parent), vec(vec) {
QHBoxLayout* itemsLayout = new QHBoxLayout(this);
Vector3Edit::Vector3Edit(glm::vec3 &vec, QWidget *parent)
: QWidget(parent)
, vec(vec)
{
QHBoxLayout *itemsLayout = new QHBoxLayout(this);
spinBoxes.x = new QDoubleSpinBox();
spinBoxes.y = new QDoubleSpinBox();
@ -30,36 +33,31 @@ Vector3Edit::Vector3Edit(glm::vec3& vec, QWidget* parent) : QWidget(parent), vec
spinBoxes.y->setValue(vec.y);
spinBoxes.z->setValue(vec.z);
connect(
spinBoxes.x,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this, &vec](double d) {
connect(spinBoxes.x, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this, &vec](double d) {
vec.x = d;
Q_EMIT onValueChanged();
});
connect(
spinBoxes.y,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this, &vec](double d) {
connect(spinBoxes.y, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this, &vec](double d) {
vec.y = d;
Q_EMIT onValueChanged();
});
connect(
spinBoxes.z,
static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this, &vec](double d) {
connect(spinBoxes.z, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [this, &vec](double d) {
vec.z = d;
Q_EMIT onValueChanged();
});
}
Vector3Edit::~Vector3Edit() {
Vector3Edit::~Vector3Edit()
{
updateTimer->stop();
}
void Vector3Edit::setVector(glm::vec3& vec) {
void Vector3Edit::setVector(glm::vec3 &vec)
{
this->vec = vec;
spinBoxes.x->setValue(vec.x);
spinBoxes.y->setValue(vec.y);
spinBoxes.z->setValue(vec.z);
}
#include "moc_vec3edit.cpp"