2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-04-09 15:31:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
2023-07-09 10:54:27 -04:00
|
|
|
#include "filecache.h"
|
2023-07-07 16:16:21 -04:00
|
|
|
#include "mdlpart.h"
|
|
|
|
#include <QComboBox>
|
2024-02-04 14:00:46 -05:00
|
|
|
#include <QFrame>
|
2023-07-07 16:16:21 -04:00
|
|
|
#include <physis.hpp>
|
2023-04-09 15:31:19 -04:00
|
|
|
|
|
|
|
struct ModelInfo {
|
|
|
|
int primaryID;
|
|
|
|
int gearVersion = 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GearInfo {
|
|
|
|
std::string name;
|
|
|
|
Slot slot;
|
|
|
|
ModelInfo modelInfo;
|
2024-04-20 15:11:02 -04:00
|
|
|
uint16_t icon;
|
2023-04-09 15:31:19 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
std::string getMtrlPath(const std::string_view material_name) const
|
|
|
|
{
|
2023-09-23 14:51:47 -04:00
|
|
|
return physis_build_gear_material_path(modelInfo.primaryID, modelInfo.gearVersion, material_name.data());
|
2023-04-09 15:31:19 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-09-25 23:48:03 -04:00
|
|
|
inline bool operator==(const GearInfo &a, const GearInfo &b)
|
|
|
|
{
|
|
|
|
return a.name == b.name && a.slot == b.slot;
|
|
|
|
}
|
|
|
|
|
2023-04-09 15:31:19 -04:00
|
|
|
struct GameData;
|
|
|
|
|
2024-02-04 14:00:46 -05:00
|
|
|
class GearView : public QFrame
|
2023-10-12 23:44:48 -04:00
|
|
|
{
|
2023-04-09 15:31:19 -04:00
|
|
|
Q_OBJECT
|
2023-10-12 23:44:48 -04:00
|
|
|
|
2023-04-09 15:31:19 -04:00
|
|
|
public:
|
2023-10-12 23:44:48 -04:00
|
|
|
explicit GearView(GameData *data, FileCache &cache, QWidget *parent = nullptr);
|
2023-04-09 15:31:19 -04:00
|
|
|
|
|
|
|
/// 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;
|
2023-04-09 15:31:19 -04:00
|
|
|
|
|
|
|
/// 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-04-09 15:31:19 -04:00
|
|
|
|
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;
|
|
|
|
|
2023-09-26 20:21:06 -04:00
|
|
|
QString getLoadedGearPath() const;
|
|
|
|
|
2023-07-07 16:16:21 -04:00
|
|
|
Q_SIGNALS:
|
2023-04-09 15:31:19 -04:00
|
|
|
void gearChanged();
|
2023-07-06 17:38:19 -04:00
|
|
|
void modelReloaded();
|
2023-09-25 23:48:03 -04:00
|
|
|
void loadingChanged(bool loading);
|
2023-04-09 15:31:19 -04:00
|
|
|
|
|
|
|
void raceChanged();
|
2023-07-07 16:01:39 -04:00
|
|
|
void subraceChanged();
|
2023-04-09 15:31:19 -04:00
|
|
|
void genderChanged();
|
|
|
|
void levelOfDetailChanged();
|
|
|
|
|
2023-07-08 11:58:38 -04:00
|
|
|
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);
|
2023-09-25 23:48:03 -04:00
|
|
|
void removeGear(GearInfo &gear);
|
2023-04-09 15:31:19 -04:00
|
|
|
|
|
|
|
void setRace(Race race);
|
2023-07-07 16:01:39 -04:00
|
|
|
void setSubrace(Subrace subrace);
|
2023-04-09 15:31:19 -04:00
|
|
|
void setGender(Gender gender);
|
|
|
|
void setLevelOfDetail(int lod);
|
|
|
|
|
2023-07-08 11:58:38 -04:00
|
|
|
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-04-09 15:31:19 -04:00
|
|
|
|
2024-02-04 14:54:37 -05:00
|
|
|
protected:
|
|
|
|
void changeEvent(QEvent *) override;
|
|
|
|
|
2023-07-07 16:16:21 -04:00
|
|
|
private:
|
2023-04-09 15:31:19 -04:00
|
|
|
int currentLod = 0;
|
|
|
|
|
|
|
|
uint32_t maxLod = 0;
|
|
|
|
|
2023-09-25 23:48:03 -04:00
|
|
|
struct LoadedGear {
|
|
|
|
GearInfo info;
|
2023-12-09 21:18:34 -05:00
|
|
|
physis_MDL mdl{};
|
2023-09-26 20:21:06 -04:00
|
|
|
QLatin1String path;
|
2023-12-09 21:18:34 -05:00
|
|
|
int bodyId = 0;
|
2023-09-25 23:48:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<LoadedGear> loadedGears;
|
|
|
|
std::vector<LoadedGear> queuedGearAdditions;
|
|
|
|
std::vector<LoadedGear> queuedGearRemovals;
|
|
|
|
bool gearDirty = false;
|
|
|
|
|
2023-07-08 11:58:38 -04:00
|
|
|
std::optional<int> face = 1, hair = 1, ear = 1, tail;
|
2023-09-25 23:48:03 -04:00
|
|
|
bool faceDirty = false, hairDirty = false, earDirty = false, tailDirty = false;
|
|
|
|
bool raceDirty = false;
|
2023-04-09 15:31:19 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
MDLPart *mdlPart = nullptr;
|
2023-04-09 15:31:19 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
GameData *data;
|
|
|
|
FileCache &cache;
|
2023-09-25 23:48:03 -04:00
|
|
|
|
|
|
|
bool updating = false;
|
|
|
|
void updatePart();
|
|
|
|
bool needsUpdate() const;
|
2023-04-09 15:31:19 -04:00
|
|
|
};
|