1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-23 04:27:45 +00:00
novus/armoury/include/gearview.h
Joshua Goins 70cbd9672c armoury: Remove hardcoded skeleton and deform JSON, read them from game
Physis gained skeleton and deform file read support, so we can use that
and extract these directly from the game (without help of the Havok SDK
like TexTools.) The racial deform is still slightly off, but this is
still a pretty big milestone.
2023-10-13 15:03:17 -04:00

121 lines
No EOL
2.8 KiB
C++

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "filecache.h"
#include "mdlpart.h"
#include <QComboBox>
#include <QWidget>
#include <physis.hpp>
struct ModelInfo {
int primaryID;
int gearVersion = 1;
};
struct GearInfo {
std::string name;
Slot slot;
ModelInfo modelInfo;
std::string getMtrlPath(const std::string_view material_name) const
{
return physis_build_gear_material_path(modelInfo.primaryID, modelInfo.gearVersion, material_name.data());
}
};
inline bool operator==(const GearInfo &a, const GearInfo &b)
{
return a.name == b.name && a.slot == b.slot;
}
struct GameData;
class GearView : public QWidget
{
Q_OBJECT
public:
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;
/// Returns an inclusive list of genders supported by the current gearset.
std::vector<Gender> supportedGenders() const;
/// Returns an inclusive list of LoDs supported by the current gearset.
int lodCount() const;
void exportModel(const QString &fileName);
MDLPart &part() const;
Race currentRace = Race::Hyur;
Subrace currentSubrace = Subrace::Midlander;
Gender currentGender = Gender::Male;
QString getLoadedGearPath() const;
Q_SIGNALS:
void gearChanged();
void modelReloaded();
void loadingChanged(bool loading);
void raceChanged();
void subraceChanged();
void genderChanged();
void levelOfDetailChanged();
void faceChanged();
void hairChanged();
void earChanged();
void tailChanged();
public Q_SLOTS:
void addGear(GearInfo &gear);
void removeGear(GearInfo &gear);
void setRace(Race race);
void setSubrace(Subrace subrace);
void setGender(Gender gender);
void setLevelOfDetail(int lod);
void setFace(int bodyVer);
void setHair(int bodyVer);
void setEar(int bodyVer);
void setTail(int bodyVer);
void reloadRaceDeforms();
private:
int currentLod = 0;
uint32_t maxLod = 0;
struct LoadedGear {
GearInfo info;
physis_MDL mdl;
QLatin1String path;
int bodyId;
};
std::vector<LoadedGear> loadedGears;
std::vector<LoadedGear> queuedGearAdditions;
std::vector<LoadedGear> queuedGearRemovals;
bool gearDirty = false;
std::optional<int> face = 1, hair = 1, ear = 1, tail;
bool faceDirty = false, hairDirty = false, earDirty = false, tailDirty = false;
bool raceDirty = false;
MDLPart *mdlPart = nullptr;
GameData *data;
FileCache &cache;
bool updating = false;
void updatePart();
bool needsUpdate() const;
};