1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-21 19: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 #pragma once
#include "quaternionedit.h"
#include "vec3edit.h"
#include <QSpinBox> #include <QSpinBox>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QWidget> #include <QWidget>
@ -12,9 +10,13 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <physis.hpp> #include <physis.hpp>
#include "quaternionedit.h"
#include "vec3edit.h"
class GearView; class GearView;
class BoneEditor : public QWidget { class BoneEditor : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
@ -33,13 +35,13 @@ private:
glm::quat currentRaceRotation; glm::quat currentRaceRotation;
glm::vec3 currentRaceScale; glm::vec3 currentRaceScale;
physis_Bone* currentEditedBone; physis_Bone *currentEditedBone = nullptr;
Vector3Edit* posEdit; Vector3Edit *posEdit = nullptr;
QuaternionEdit* rotationEdit; QuaternionEdit *rotationEdit = nullptr;
Vector3Edit* scaleEdit; Vector3Edit *scaleEdit = nullptr;
Vector3Edit* raceDeformPosEdit; Vector3Edit *raceDeformPosEdit = nullptr;
QuaternionEdit* raceDeformRotationEdit; QuaternionEdit *raceDeformRotationEdit = nullptr;
Vector3Edit* raceDeformScaleEdit; Vector3Edit *raceDeformScaleEdit = nullptr;
}; };

View file

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

View file

@ -11,10 +11,12 @@
struct GameData; struct GameData;
class FileCache; class FileCache;
class FullModelViewer : public QMainWindow { class FullModelViewer : public QMainWindow
{
Q_OBJECT Q_OBJECT
public: public:
explicit FullModelViewer(GameData* data, FileCache& cache); explicit FullModelViewer(GameData *data, FileCache &cache, QWidget *parent = nullptr);
Q_SIGNALS: Q_SIGNALS:
void gearChanged(); void gearChanged();
@ -42,7 +44,7 @@ private:
std::optional<GearInfo> bottomSlot; std::optional<GearInfo> bottomSlot;
GearView *gearView = nullptr; GearView *gearView = nullptr;
QComboBox *raceCombo, *subraceCombo, *genderCombo; QComboBox *raceCombo = nullptr, *subraceCombo = nullptr, *genderCombo = nullptr;
GameData *data = nullptr; GameData *data = nullptr;
physis_CMP cmp; physis_CMP cmp;

View file

@ -8,11 +8,7 @@
#include "gearview.h" #include "gearview.h"
enum class TreeType { enum class TreeType { Root, Category, Item };
Root,
Category,
Item
};
struct TreeInformation { struct TreeInformation {
TreeType type; TreeType type;
@ -24,11 +20,12 @@ struct TreeInformation {
std::vector<TreeInformation *> children; std::vector<TreeInformation *> children;
}; };
class GearListModel : public QAbstractItemModel { class GearListModel : public QAbstractItemModel
{
Q_OBJECT Q_OBJECT
public: public:
explicit GearListModel(GameData* data); explicit GearListModel(GameData *data, QObject *parent = nullptr);
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;

View file

@ -9,7 +9,8 @@
#include "gearview.h" #include "gearview.h"
class GearListWidget : public QWidget { class GearListWidget : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:

View file

@ -19,7 +19,8 @@ struct GearInfo {
Slot slot; Slot slot;
ModelInfo modelInfo; 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()); 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; struct GameData;
class GearView : public QWidget { class GearView : public QWidget
{
Q_OBJECT Q_OBJECT
public: 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. /// Returns an inclusive list of races supported by the current gearset.
std::vector<std::pair<Race, Subrace>> supportedRaces() const; std::vector<std::pair<Race, Subrace>> supportedRaces() const;
@ -114,7 +117,4 @@ private:
bool updating = false; bool updating = false;
void updatePart(); void updatePart();
bool needsUpdate() const; bool needsUpdate() const;
void gearUpdate(LoadedGear &gear);
void queueGearUpdate(LoadedGear &gear);
}; };

View file

@ -17,6 +17,8 @@ class FileCache;
class MainWindow : public NovusMainWindow class MainWindow : public NovusMainWindow
{ {
Q_OBJECT
public: public:
explicit MainWindow(GameData *data); explicit MainWindow(GameData *data);

View file

@ -8,8 +8,10 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
class QuaternionEdit : public QWidget { class QuaternionEdit : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
explicit QuaternionEdit(glm::quat &quat, QWidget *parent = nullptr); explicit QuaternionEdit(glm::quat &quat, QWidget *parent = nullptr);

View file

@ -10,11 +10,12 @@
struct GameData; 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, QWidget *parent = nullptr);
QString getLoadedGearPath() const; QString getLoadedGearPath() const;

View file

@ -7,8 +7,10 @@
#include <QWidget> #include <QWidget>
#include <glm/glm.hpp> #include <glm/glm.hpp>
class Vector3Edit : public QWidget { class Vector3Edit : public QWidget
{
Q_OBJECT Q_OBJECT
public: public:
explicit Vector3Edit(glm::vec3 &vec, QWidget *parent = nullptr); explicit Vector3Edit(glm::vec3 &vec, QWidget *parent = nullptr);
~Vector3Edit(); ~Vector3Edit();

View file

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

View file

@ -16,8 +16,7 @@ struct RaceTree {
std::vector<Subrace> subRaces; std::vector<Subrace> subRaces;
}; };
std::vector<RaceTree> raceTree = { std::vector<RaceTree> raceTree = {{Race::Hyur, {Subrace::Midlander, Subrace::Highlander}},
{Race::Hyur, {Subrace::Midlander, Subrace::Highlander}},
{Race::Elezen, {Subrace::Wildwood, Subrace::Duskwight}}, {Race::Elezen, {Subrace::Wildwood, Subrace::Duskwight}},
{Race::Miqote, {Subrace::Seeker, Subrace::Keeper}}, {Race::Miqote, {Subrace::Seeker, Subrace::Keeper}},
{Race::Roegadyn, {Subrace::SeaWolf, Subrace::Hellion}}, {Race::Roegadyn, {Subrace::SeaWolf, Subrace::Hellion}},
@ -26,7 +25,10 @@ std::vector<RaceTree> raceTree = {
{Race::Hrothgar, {Subrace::Hellion, Subrace::Lost}}, {Race::Hrothgar, {Subrace::Hellion, Subrace::Lost}},
{Race::Viera, {Subrace::Rava, Subrace::Veena}}}; {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")); setWindowTitle(QStringLiteral("CMP Editor"));
auto layout = new QHBoxLayout(); auto layout = new QHBoxLayout();
@ -109,7 +111,8 @@ CmpEditor::CmpEditor(GameData* data) : data(data) {
loadRaceData(Race::Hyur, Subrace::Midlander); 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); auto raceData = physis_cmp_get_racial_scaling_parameters(cmp, race, subrace);
maleMinSize->setValue(raceData.male_min_size); maleMinSize->setValue(raceData.male_min_size);

View file

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

View file

@ -7,7 +7,10 @@
#include <QtConcurrent> #include <QtConcurrent>
#include <magic_enum.hpp> #include <magic_enum.hpp>
GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemModel() { GearListModel::GearListModel(GameData *data, QObject *parent)
: QAbstractItemModel(parent)
, gameData(data)
{
// smallclothes body // smallclothes body
{ {
GearInfo info = {}; GearInfo info = {};
@ -26,7 +29,7 @@ GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemMode
gears.push_back(info); 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); exdFuture = new QFutureWatcher<physis_EXD>(this);
connect(exdFuture, &QFutureWatcher<physis_EXD>::resultReadyAt, this, &GearListModel::exdFinished); connect(exdFuture, &QFutureWatcher<physis_EXD>::resultReadyAt, this, &GearListModel::exdFinished);
@ -51,7 +54,8 @@ GearListModel::GearListModel(GameData* data) : gameData(data), QAbstractItemMode
rootItem->type = TreeType::Root; rootItem->type = TreeType::Root;
} }
int GearListModel::rowCount(const QModelIndex& parent) const { int GearListModel::rowCount(const QModelIndex &parent) const
{
TreeInformation *parentItem; TreeInformation *parentItem;
if (parent.column() > 0) if (parent.column() > 0)
return 0; return 0;
@ -64,11 +68,13 @@ int GearListModel::rowCount(const QModelIndex& parent) const {
return parentItem->children.size(); return parentItem->children.size();
} }
int GearListModel::columnCount(const QModelIndex& parent) const { int GearListModel::columnCount(const QModelIndex &parent) const
{
return 1; 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)) if (!hasIndex(row, column, parent))
return QModelIndex(); return QModelIndex();
@ -85,7 +91,8 @@ QModelIndex GearListModel::index(int row, int column, const QModelIndex& parent)
return QModelIndex(); return QModelIndex();
} }
QModelIndex GearListModel::parent(const QModelIndex& index) const { QModelIndex GearListModel::parent(const QModelIndex &index) const
{
if (!index.isValid()) if (!index.isValid())
return QModelIndex(); return QModelIndex();
@ -98,7 +105,8 @@ QModelIndex GearListModel::parent(const QModelIndex& index) const {
return createIndex(parentItem->row, 0, parentItem); 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()) if (!index.isValid())
return {}; return {};
if (!index.isValid()) if (!index.isValid())
@ -118,7 +126,8 @@ QVariant GearListModel::data(const QModelIndex& index, int role) const {
return {}; 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 (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
if (section == 0) { if (section == 0) {
return QStringLiteral("Name"); return QStringLiteral("Name");
@ -128,7 +137,8 @@ QVariant GearListModel::headerData(int section, Qt::Orientation orientation, int
return QAbstractItemModel::headerData(section, orientation, role); return QAbstractItemModel::headerData(section, orientation, role);
} }
std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex& index) { std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex &index)
{
TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer()); TreeInformation *item = static_cast<TreeInformation *>(index.internalPointer());
if (item->type == TreeType::Item) { if (item->type == TreeType::Item) {
return item->gear; return item->gear;
@ -136,7 +146,8 @@ std::optional<GearInfo> GearListModel::getGearFromIndex(const QModelIndex& index
return {}; return {};
} }
void GearListModel::exdFinished(int index) { void GearListModel::exdFinished(int index)
{
auto exd = exdFuture->resultAt(index); auto exd = exdFuture->resultAt(index);
for (int i = 0; i < exd.row_count; i++) { for (int i = 0; i < exd.row_count; i++) {
@ -156,7 +167,8 @@ void GearListModel::exdFinished(int index) {
} }
} }
void GearListModel::finished() { void GearListModel::finished()
{
beginResetModel(); beginResetModel();
int i = 0; int i = 0;

View file

@ -10,7 +10,10 @@
#include "gearlistmodel.h" #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(); auto layout = new QVBoxLayout();
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);

View file

@ -13,7 +13,11 @@
#include "magic_enum.hpp" #include "magic_enum.hpp"
#include "utility.h" #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); mdlPart = new MDLPart(data, cache);
reloadRaceDeforms(); 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; std::vector<std::pair<Race, Subrace>> races;
for (const auto &gear : loadedGears) { for (const auto &gear : loadedGears) {
for (const auto [race, race_name] : magic_enum::enum_entries<Race>()) { 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; return races;
} }
std::vector<Gender> GearView::supportedGenders() const { std::vector<Gender> GearView::supportedGenders() const
{
std::vector<Gender> genders; std::vector<Gender> genders;
for (const auto &gear : loadedGears) { for (const auto &gear : loadedGears) {
for (auto [gender, gender_name] : magic_enum::enum_entries<Gender>()) { for (auto [gender, gender_name] : magic_enum::enum_entries<Gender>()) {
@ -85,11 +91,13 @@ std::vector<Gender> GearView::supportedGenders() const {
return genders; return genders;
} }
int GearView::lodCount() const { int GearView::lodCount() const
{
return maxLod; return maxLod;
} }
void GearView::exportModel(const QString& fileName) { void GearView::exportModel(const QString &fileName)
{
mdlPart->exportModel(fileName); mdlPart->exportModel(fileName);
} }
@ -113,7 +121,8 @@ void GearView::removeGear(GearInfo &gear)
Q_EMIT gearChanged(); Q_EMIT gearChanged();
} }
void GearView::setRace(Race race) { void GearView::setRace(Race race)
{
if (currentRace == race) { if (currentRace == race) {
return; return;
} }
@ -136,7 +145,8 @@ void GearView::setRace(Race race) {
Q_EMIT raceChanged(); Q_EMIT raceChanged();
} }
void GearView::setSubrace(Subrace subrace) { void GearView::setSubrace(Subrace subrace)
{
if (currentSubrace == subrace) { if (currentSubrace == subrace) {
return; return;
} }
@ -151,7 +161,8 @@ void GearView::setSubrace(Subrace subrace) {
Q_EMIT subraceChanged(); Q_EMIT subraceChanged();
} }
void GearView::setGender(Gender gender) { void GearView::setGender(Gender gender)
{
if (currentGender == gender) { if (currentGender == gender) {
return; return;
} }
@ -163,7 +174,8 @@ void GearView::setGender(Gender gender) {
Q_EMIT genderChanged(); Q_EMIT genderChanged();
} }
void GearView::setLevelOfDetail(int lod) { void GearView::setLevelOfDetail(int lod)
{
if (currentLod == lod) { if (currentLod == lod) {
return; return;
} }
@ -353,7 +365,8 @@ void GearView::updatePart()
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char *material_name = mdl.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 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()))) { if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str()))); auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -375,7 +388,8 @@ void GearView::updatePart()
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char *material_name = mdl.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 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()))) { if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str()))); auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -397,7 +411,8 @@ void GearView::updatePart()
std::vector<physis_Material> materials; std::vector<physis_Material> materials;
for (int i = 0; i < mdl.num_material_names; i++) { for (int i = 0; i < mdl.num_material_names; i++) {
const char *material_name = mdl.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 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()))) { if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str()))); auto mat = physis_material_parse(cache.lookupFile(QLatin1String(skinmtrl_path.c_str())));
@ -417,7 +432,8 @@ void GearView::updatePart()
auto mdl = physis_mdl_parse(mdl_data.size, mdl_data.data); auto mdl = physis_mdl_parse(mdl_data.size, mdl_data.data);
const char *material_name = mdl.material_names[0]; 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 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()))) { if (cache.fileExists(QLatin1String(skinmtrl_path.c_str()))) {
auto mat = physis_material_parse(cache.lookupFile(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 "physis_logger.h"
#include "settings.h" #include "settings.h"
int main(int argc, char* argv[]) { int main(int argc, char *argv[])
{
QApplication app(argc, argv); QApplication app(argc, argv);
customizeAboutData( customizeAboutData(QStringLiteral("armoury"), QStringLiteral("Armoury"), QStringLiteral("Program to view FFXIV gear."));
QStringLiteral("armoury"), QStringLiteral("Armoury"), QStringLiteral("Program to view FFXIV gear."));
// Default to a sensible message pattern // Default to a sensible message pattern
if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) { if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) {

View file

@ -74,3 +74,5 @@ void MainWindow::setupAdditionalMenus(QMenuBar *menuBar)
cmpEditor->show(); cmpEditor->show();
}); });
} }
#include "moc_mainwindow.cpp"

View file

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

View file

@ -12,7 +12,10 @@
#include "filecache.h" #include "filecache.h"
#include "magic_enum.hpp" #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); gearView = new GearView(data, cache);
// We don't want to see the face in this view // We don't want to see the face in this view
@ -129,7 +132,8 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
reloadGear(); reloadGear();
} }
void SingleGearView::clear() { void SingleGearView::clear()
{
if (currentGear) { if (currentGear) {
gearView->removeGear(*currentGear); gearView->removeGear(*currentGear);
} }
@ -138,7 +142,8 @@ void SingleGearView::clear() {
Q_EMIT gearChanged(); Q_EMIT gearChanged();
} }
void SingleGearView::setGear(const GearInfo& info) { void SingleGearView::setGear(const GearInfo &info)
{
if (info != currentGear) { if (info != currentGear) {
if (currentGear) { if (currentGear) {
gearView->removeGear(*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) { if (currentRace == race) {
return; return;
} }
@ -160,7 +166,8 @@ void SingleGearView::setRace(Race race) {
Q_EMIT raceChanged(); Q_EMIT raceChanged();
} }
void SingleGearView::setSubrace(Subrace subrace) { void SingleGearView::setSubrace(Subrace subrace)
{
if (currentSubrace == subrace) { if (currentSubrace == subrace) {
return; return;
} }
@ -171,7 +178,8 @@ void SingleGearView::setSubrace(Subrace subrace) {
Q_EMIT subraceChanged(); Q_EMIT subraceChanged();
} }
void SingleGearView::setGender(Gender gender) { void SingleGearView::setGender(Gender gender)
{
if (currentGender == gender) { if (currentGender == gender) {
return; return;
} }
@ -180,7 +188,8 @@ void SingleGearView::setGender(Gender gender) {
Q_EMIT genderChanged(); Q_EMIT genderChanged();
} }
void SingleGearView::setLevelOfDetail(int lod) { void SingleGearView::setLevelOfDetail(int lod)
{
if (currentLod == lod) { if (currentLod == lod) {
return; 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)); 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)); 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)); 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)); genderCombo->setCurrentIndex(std::distance(supportedGenders.begin(), it));
} }

View file

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