1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-26 13:47:46 +00:00

armoury: Fix race and subrace selection for single gear view

This commit is contained in:
Joshua Goins 2023-09-26 19:48:59 -04:00
parent a5b758f1f4
commit 71007249b6
2 changed files with 23 additions and 7 deletions

View file

@ -56,8 +56,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 (auto [race, race_name] : magic_enum::enum_entries<Race>()) { for (const auto [race, race_name] : magic_enum::enum_entries<Race>()) {
for (auto subrace : physis_get_supported_subraces(race).subraces) { for (const auto subrace : physis_get_supported_subraces(race).subraces) {
auto equip_path = physis_build_equipment_path(gear.info.modelInfo.primaryID, race, subrace, currentGender, gear.info.slot); auto equip_path = physis_build_equipment_path(gear.info.modelInfo.primaryID, race, subrace, currentGender, gear.info.slot);
if (cache.fileExists(QLatin1String(equip_path))) if (cache.fileExists(QLatin1String(equip_path)))
@ -277,6 +277,7 @@ void GearView::updatePart()
if (gearDirty) { if (gearDirty) {
for (auto &gearAddition : queuedGearAdditions) { for (auto &gearAddition : queuedGearAdditions) {
qInfo() << "Looking up" << magic_enum::enum_name(currentRace) << magic_enum::enum_name(currentSubrace) << magic_enum::enum_name(currentGender);
auto mdl_data = cache.lookupFile(QLatin1String( auto mdl_data = cache.lookupFile(QLatin1String(
physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, currentRace, currentSubrace, currentGender, gearAddition.info.slot))); physis_build_equipment_path(gearAddition.info.modelInfo.primaryID, currentRace, currentSubrace, currentGender, gearAddition.info.slot)));

View file

@ -41,7 +41,7 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
if (loadingComboData) if (loadingComboData)
return; return;
setSubrace(static_cast<Subrace>(raceCombo->itemData(index).toInt())); setSubrace(static_cast<Subrace>(subraceCombo->itemData(index).toInt()));
}); });
controlLayout->addWidget(subraceCombo); controlLayout->addWidget(subraceCombo);
@ -81,7 +81,11 @@ SingleGearView::SingleGearView(GameData* data, FileCache& cache) : data(data) {
}); });
controlLayout->addWidget(exportButton); controlLayout->addWidget(exportButton);
connect(this, &SingleGearView::gearChanged, this, &SingleGearView::reloadGear); connect(gearView, &GearView::loadingChanged, this, [this](const bool loading) {
if (!loading) {
reloadGear();
}
});
connect(this, &SingleGearView::raceChanged, this, [=] { connect(this, &SingleGearView::raceChanged, this, [=] {
gearView->setRace(currentRace); gearView->setRace(currentRace);
}); });
@ -134,6 +138,8 @@ void SingleGearView::setSubrace(Subrace subrace) {
return; return;
} }
qInfo() << "Setting subrace to" << magic_enum::enum_name(subrace);
currentSubrace = subrace; currentSubrace = subrace;
Q_EMIT subraceChanged(); Q_EMIT subraceChanged();
} }
@ -183,16 +189,22 @@ void SingleGearView::reloadGear()
for (auto [race, subrace] : supportedRaces) { for (auto [race, subrace] : supportedRaces) {
// TODO: supportedRaces should be designed better // TODO: supportedRaces should be designed better
if (!addedRaces.contains(race)) { if (!addedRaces.contains(race)) {
raceCombo->addItem(QLatin1String(magic_enum::enum_name(race).data(), static_cast<int>(race))); raceCombo->addItem(QLatin1String(magic_enum::enum_name(race).data()), static_cast<int>(race));
addedRaces.push_back(race); addedRaces.push_back(race);
} }
subraceCombo->addItem(QLatin1String(magic_enum::enum_name(subrace).data(), static_cast<int>(subrace)));
} }
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));
} }
const Race selectedRace = static_cast<Race>(raceCombo->currentData().toInt());
for (auto [race, subrace] : supportedRaces) {
if (race == selectedRace) {
subraceCombo->addItem(QLatin1String(magic_enum::enum_name(subrace).data()), static_cast<int>(subrace));
}
}
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));
} }
@ -202,7 +214,7 @@ void SingleGearView::reloadGear()
const auto supportedGenders = gearView->supportedGenders(); const auto supportedGenders = gearView->supportedGenders();
for (auto gender : supportedGenders) { for (auto gender : supportedGenders) {
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()) {
@ -213,6 +225,9 @@ void SingleGearView::reloadGear()
for (int i = 0; i < gearView->lodCount(); i++) { for (int i = 0; i < gearView->lodCount(); i++) {
lodCombo->addItem(QStringLiteral("LOD %1").arg(i), i); lodCombo->addItem(QStringLiteral("LOD %1").arg(i), i);
} }
if (oldLod < gearView->lodCount()) {
lodCombo->setCurrentIndex(oldLod);
}
loadingComboData = false; loadingComboData = false;
} }