1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-22 03:57:45 +00:00
novus/armoury/include/gearview.h

124 lines
2.8 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "filecache.h"
2023-07-07 16:16:21 -04:00
#include "mdlpart.h"
#include <QComboBox>
#include <QFrame>
2023-07-07 16:16:21 -04:00
#include <physis.hpp>
struct ModelInfo {
int primaryID;
int gearVersion = 1;
};
struct GearInfo {
std::string name;
Slot slot;
ModelInfo modelInfo;
2023-10-12 23:44:48 -04:00
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 QFrame
2023-10-12 23:44:48 -04:00
{
Q_OBJECT
2023-10-12 23:44:48 -04:00
public:
2023-10-12 23:44:48 -04:00
explicit GearView(GameData *data, FileCache &cache, QWidget *parent = nullptr);
/// Returns an inclusive list of races supported by the current gearset.
2023-07-07 16:01:39 -04:00
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;
2023-10-12 23:44:48 -04:00
void exportModel(const QString &fileName);
2023-10-12 23:44:48 -04:00
MDLPart &part() const;
2023-07-06 17:38:19 -04:00
2023-07-07 16:01:39 -04:00
Race currentRace = Race::Hyur;
Subrace currentSubrace = Subrace::Midlander;
Gender currentGender = Gender::Male;
QString getLoadedGearPath() const;
2023-07-07 16:16:21 -04:00
Q_SIGNALS:
void gearChanged();
2023-07-06 17:38:19 -04:00
void modelReloaded();
void loadingChanged(bool loading);
void raceChanged();
2023-07-07 16:01:39 -04:00
void subraceChanged();
void genderChanged();
void levelOfDetailChanged();
void faceChanged();
void hairChanged();
void earChanged();
void tailChanged();
2023-07-07 16:16:21 -04:00
public Q_SLOTS:
2023-10-12 23:44:48 -04:00
void addGear(GearInfo &gear);
void removeGear(GearInfo &gear);
void setRace(Race race);
2023-07-07 16:01:39 -04:00
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);
2023-07-07 16:01:39 -04:00
void reloadRaceDeforms();
protected:
void changeEvent(QEvent *) override;
2023-07-07 16:16:21 -04:00
private:
int currentLod = 0;
uint32_t maxLod = 0;
struct LoadedGear {
GearInfo info;
2023-12-09 21:18:34 -05:00
physis_MDL mdl{};
QLatin1String path;
2023-12-09 21:18:34 -05:00
int bodyId = 0;
};
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;
2023-10-12 23:44:48 -04:00
MDLPart *mdlPart = nullptr;
2023-10-12 23:44:48 -04:00
GameData *data;
FileCache &cache;
bool updating = false;
void updatePart();
bool needsUpdate() const;
};