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

117 lines
2.7 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 <QWidget>
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;
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);
/// 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-07-07 16:16:21 -04:00
void exportModel(const QString& fileName);
2023-07-07 16:16:21 -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;
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:
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();
2023-07-07 16:16:21 -04:00
private:
int currentLod = 0;
uint32_t maxLod = 0;
struct LoadedGear {
GearInfo info;
physis_MDL mdl;
};
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;
void gearUpdate(LoadedGear &gear);
void queueGearUpdate(LoadedGear &gear);
};