order wild encounter json reading
This commit is contained in:
parent
a997fb69da
commit
6c3ee3c46d
7 changed files with 95 additions and 57 deletions
|
@ -53,6 +53,7 @@ public:
|
||||||
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
||||||
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
||||||
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath);
|
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath);
|
||||||
|
bool tryParseOrderedJsonFile(poryjson::Json::object *out, const QString &filepath);
|
||||||
bool ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields);
|
bool ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields);
|
||||||
|
|
||||||
// Returns the 1-indexed line number for the definition of scriptLabel in the scripts file at filePath.
|
// Returns the 1-indexed line number for the definition of scriptLabel in the scripts file at filePath.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#define GUARD_WILDMONINFO_H
|
#define GUARD_WILDMONINFO_H
|
||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
#include "orderedmap.h"
|
||||||
|
|
||||||
struct WildPokemon {
|
struct WildPokemon {
|
||||||
int minLevel = 5;
|
int minLevel = 5;
|
||||||
|
@ -17,13 +18,13 @@ struct WildMonInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WildPokemonHeader {
|
struct WildPokemonHeader {
|
||||||
QHash<QString, WildMonInfo> wildMons;
|
tsl::ordered_map<QString, WildMonInfo> wildMons;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EncounterField {
|
struct EncounterField {
|
||||||
QString name;
|
QString name;
|
||||||
QVector<int> encounterRates;
|
QVector<int> encounterRates;
|
||||||
QMap<QString, QVector<int>> groups;
|
tsl::ordered_map<QString, QVector<int>> groups;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QVector<EncounterField> EncounterFields;
|
typedef QVector<EncounterField> EncounterFields;
|
||||||
|
|
|
@ -404,6 +404,17 @@ bool ParseUtil::tryParseJsonFile(QJsonDocument *out, const QString &filepath) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ParseUtil::tryParseOrderedJsonFile(poryjson::Json::object *out, const QString &filepath) {
|
||||||
|
QString err;
|
||||||
|
QString jsonTxt = readTextFile(filepath);
|
||||||
|
*out = OrderedJson::parse(jsonTxt, err).object_items();
|
||||||
|
if (!err.isEmpty()) {
|
||||||
|
logError(QString("Error: Failed to parse json file %1: %2").arg(filepath).arg(err));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ParseUtil::ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields) {
|
bool ParseUtil::ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields) {
|
||||||
for (QString field : fields) {
|
for (QString field : fields) {
|
||||||
if (!obj.contains(field)) {
|
if (!obj.contains(field)) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ WildMonInfo copyMonInfoFromTab(QTableWidget *monTable, EncounterField monField)
|
||||||
WildMonInfo newInfo;
|
WildMonInfo newInfo;
|
||||||
QVector<WildPokemon> newWildMons;
|
QVector<WildPokemon> newWildMons;
|
||||||
|
|
||||||
bool extraColumn = !monField.groups.isEmpty();
|
bool extraColumn = !monField.groups.empty();
|
||||||
for (int row = 0; row < monTable->rowCount(); row++) {
|
for (int row = 0; row < monTable->rowCount(); row++) {
|
||||||
WildPokemon newWildMon;
|
WildPokemon newWildMon;
|
||||||
newWildMon.species = monTable->cellWidget(row, extraColumn ? 2 : 1)->findChild<QComboBox *>()->currentText();
|
newWildMon.species = monTable->cellWidget(row, extraColumn ? 2 : 1)->findChild<QComboBox *>()->currentText();
|
||||||
|
|
|
@ -340,12 +340,14 @@ void Editor::addNewWildMonGroup(QWidget *window) {
|
||||||
if (fieldCheckboxes[tabIndex]->isChecked()) {
|
if (fieldCheckboxes[tabIndex]->isChecked()) {
|
||||||
if (copyCheckbox->isChecked()) {
|
if (copyCheckbox->isChecked()) {
|
||||||
MonTabWidget *copyFrom = static_cast<MonTabWidget *>(stack->widget(stackIndex));
|
MonTabWidget *copyFrom = static_cast<MonTabWidget *>(stack->widget(stackIndex));
|
||||||
if (copyFrom->isTabEnabled(tabIndex))
|
if (copyFrom->isTabEnabled(tabIndex)) {
|
||||||
header.wildMons.insert(fieldName, copyMonInfoFromTab(copyFrom->tableAt(tabIndex), monField));
|
header.wildMons[fieldName] = copyMonInfoFromTab(copyFrom->tableAt(tabIndex), monField);
|
||||||
else
|
}
|
||||||
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
else {
|
||||||
|
header.wildMons[fieldName] = getDefaultMonInfo(monField);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
header.wildMons[fieldName] = getDefaultMonInfo(monField);
|
||||||
}
|
}
|
||||||
tabWidget->populateTab(tabIndex, header.wildMons[fieldName], fieldName);
|
tabWidget->populateTab(tabIndex, header.wildMons[fieldName], fieldName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,14 +411,16 @@ void Editor::configureEncounterJSON(QWidget *window) {
|
||||||
int total = 0, spinnerIndex = 0;
|
int total = 0, spinnerIndex = 0;
|
||||||
QString groupTotalMessage;
|
QString groupTotalMessage;
|
||||||
QMap<QString, int> groupTotals;
|
QMap<QString, int> groupTotals;
|
||||||
for (QString key : currentField.groups.keys())
|
for (auto keyPair : currentField.groups) {
|
||||||
groupTotals.insert(key, 0);// add to group map and initialize total to zero
|
groupTotals.insert(keyPair.first, 0);// add to group map and initialize total to zero
|
||||||
|
}
|
||||||
for (auto slot : fieldSlots) {
|
for (auto slot : fieldSlots) {
|
||||||
QSpinBox *spinner = slot->findChild<QSpinBox *>();
|
QSpinBox *spinner = slot->findChild<QSpinBox *>();
|
||||||
int val = spinner->value();
|
int val = spinner->value();
|
||||||
currentField.encounterRates[spinnerIndex] = val;
|
currentField.encounterRates[spinnerIndex] = val;
|
||||||
if (!currentField.groups.isEmpty()) {
|
if (!currentField.groups.empty()) {
|
||||||
for (QString key : currentField.groups.keys()) {
|
for (auto keyPair : currentField.groups) {
|
||||||
|
QString key = keyPair.first;
|
||||||
if (currentField.groups[key].contains(spinnerIndex)) {
|
if (currentField.groups[key].contains(spinnerIndex)) {
|
||||||
groupTotals[key] += val;
|
groupTotals[key] += val;
|
||||||
break;
|
break;
|
||||||
|
@ -427,9 +431,10 @@ void Editor::configureEncounterJSON(QWidget *window) {
|
||||||
}
|
}
|
||||||
spinnerIndex++;
|
spinnerIndex++;
|
||||||
}
|
}
|
||||||
if (!currentField.groups.isEmpty()) {
|
if (!currentField.groups.empty()) {
|
||||||
groupTotalMessage += "Totals: ";
|
groupTotalMessage += "Totals: ";
|
||||||
for (QString key : currentField.groups.keys()) {
|
for (auto keyPair : currentField.groups) {
|
||||||
|
QString key = keyPair.first;
|
||||||
groupTotalMessage += QString("%1 (%2),\t").arg(groupTotals[key]).arg(key);
|
groupTotalMessage += QString("%1 (%2),\t").arg(groupTotals[key]).arg(key);
|
||||||
}
|
}
|
||||||
groupTotalMessage.chop(2);
|
groupTotalMessage.chop(2);
|
||||||
|
@ -456,7 +461,7 @@ void Editor::configureEncounterJSON(QWidget *window) {
|
||||||
updateTotal(currentField);
|
updateTotal(currentField);
|
||||||
});
|
});
|
||||||
|
|
||||||
bool useGroups = !currentField.groups.isEmpty();
|
bool useGroups = !currentField.groups.empty();
|
||||||
|
|
||||||
QFrame *slotChoiceFrame = new QFrame;
|
QFrame *slotChoiceFrame = new QFrame;
|
||||||
QVBoxLayout *slotChoiceLayout = new QVBoxLayout;
|
QVBoxLayout *slotChoiceLayout = new QVBoxLayout;
|
||||||
|
@ -465,22 +470,27 @@ void Editor::configureEncounterJSON(QWidget *window) {
|
||||||
connect(groupCombo, QOverload<const QString &>::of(&QComboBox::textActivated), [&tempFields, ¤tField, index](QString newGroupName) {
|
connect(groupCombo, QOverload<const QString &>::of(&QComboBox::textActivated), [&tempFields, ¤tField, index](QString newGroupName) {
|
||||||
for (EncounterField &field : tempFields) {
|
for (EncounterField &field : tempFields) {
|
||||||
if (field.name == currentField.name) {
|
if (field.name == currentField.name) {
|
||||||
for (QString groupName : field.groups.keys()) {
|
for (auto groupNameIterator : field.groups) {
|
||||||
|
QString groupName = groupNameIterator.first;
|
||||||
if (field.groups[groupName].contains(index)) {
|
if (field.groups[groupName].contains(index)) {
|
||||||
field.groups[groupName].removeAll(index);
|
field.groups[groupName].removeAll(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QString groupName : field.groups.keys()) {
|
for (auto groupNameIterator : field.groups) {
|
||||||
|
QString groupName = groupNameIterator.first;
|
||||||
if (groupName == newGroupName) field.groups[newGroupName].append(index);
|
if (groupName == newGroupName) field.groups[newGroupName].append(index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
groupCombo->addItems(currentField.groups.keys());
|
for (auto groupNameIterator : currentField.groups) {
|
||||||
|
groupCombo->addItem(groupNameIterator.first);
|
||||||
|
}
|
||||||
QString currentGroupName;
|
QString currentGroupName;
|
||||||
for (QString groupName : currentField.groups.keys()) {
|
for (auto groupNameIterator : currentField.groups) {
|
||||||
|
QString groupName = groupNameIterator.first;
|
||||||
if (currentField.groups[groupName].contains(index)) {
|
if (currentField.groups[groupName].contains(index)) {
|
||||||
currentGroupName = groupName;
|
currentGroupName = groupName;
|
||||||
break;
|
break;
|
||||||
|
@ -676,7 +686,8 @@ void Editor::updateEncounterFields(EncounterFields newFields) {
|
||||||
for (auto groupNamePair : project->wildMonData[map]) {
|
for (auto groupNamePair : project->wildMonData[map]) {
|
||||||
QString groupName = groupNamePair.first;
|
QString groupName = groupNamePair.first;
|
||||||
WildPokemonHeader &monHeader = project->wildMonData[map][groupName];
|
WildPokemonHeader &monHeader = project->wildMonData[map][groupName];
|
||||||
for (QString fieldName : monHeader.wildMons.keys()) {
|
for (auto fieldNamePair : monHeader.wildMons) {
|
||||||
|
QString fieldName = fieldNamePair.first;
|
||||||
if (fieldName == oldFieldName) {
|
if (fieldName == oldFieldName) {
|
||||||
monHeader.wildMons[fieldName].wildPokemon.resize(newField.encounterRates.size());
|
monHeader.wildMons[fieldName].wildPokemon.resize(newField.encounterRates.size());
|
||||||
}
|
}
|
||||||
|
@ -692,9 +703,10 @@ void Editor::updateEncounterFields(EncounterFields newFields) {
|
||||||
for (auto groupNamePair : project->wildMonData[map]) {
|
for (auto groupNamePair : project->wildMonData[map]) {
|
||||||
QString groupName = groupNamePair.first;
|
QString groupName = groupNamePair.first;
|
||||||
WildPokemonHeader &monHeader = project->wildMonData[map][groupName];
|
WildPokemonHeader &monHeader = project->wildMonData[map][groupName];
|
||||||
for (QString fieldName : monHeader.wildMons.keys()) {
|
for (auto fieldNamePair : monHeader.wildMons) {
|
||||||
|
QString fieldName = fieldNamePair.first;
|
||||||
if (fieldName == oldFieldName) {
|
if (fieldName == oldFieldName) {
|
||||||
monHeader.wildMons.remove(fieldName);
|
monHeader.wildMons.erase(fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,7 +730,8 @@ void Project::saveWildMonData() {
|
||||||
fieldObject["encounter_rates"] = rateArray;
|
fieldObject["encounter_rates"] = rateArray;
|
||||||
|
|
||||||
OrderedJson::object groupsObject;
|
OrderedJson::object groupsObject;
|
||||||
for (QString groupName : fieldInfo.groups.keys()) {
|
for (auto groupNamePair : fieldInfo.groups) {
|
||||||
|
QString groupName = groupNamePair.first;
|
||||||
OrderedJson::array subGroupIndices;
|
OrderedJson::array subGroupIndices;
|
||||||
std::sort(fieldInfo.groups[groupName].begin(), fieldInfo.groups[groupName].end());
|
std::sort(fieldInfo.groups[groupName].begin(), fieldInfo.groups[groupName].end());
|
||||||
for (int slotIndex : fieldInfo.groups[groupName]) {
|
for (int slotIndex : fieldInfo.groups[groupName]) {
|
||||||
|
@ -754,9 +755,10 @@ void Project::saveWildMonData() {
|
||||||
encounterObject["base_label"] = groupLabel;
|
encounterObject["base_label"] = groupLabel;
|
||||||
|
|
||||||
WildPokemonHeader encounterHeader = wildMonData[key][groupLabel];
|
WildPokemonHeader encounterHeader = wildMonData[key][groupLabel];
|
||||||
for (QString fieldName : encounterHeader.wildMons.keys()) {
|
for (auto fieldNamePair : encounterHeader.wildMons) {
|
||||||
|
QString fieldName = fieldNamePair.first;
|
||||||
OrderedJson::object fieldObject;
|
OrderedJson::object fieldObject;
|
||||||
WildMonInfo monInfo = encounterHeader.wildMons.value(fieldName);
|
WildMonInfo monInfo = encounterHeader.wildMons[fieldName];
|
||||||
fieldObject["encounter_rate"] = monInfo.encounterRate;
|
fieldObject["encounter_rate"] = monInfo.encounterRate;
|
||||||
OrderedJson::array monArray;
|
OrderedJson::array monArray;
|
||||||
for (WildPokemon wildMon : monInfo.wildPokemon) {
|
for (WildPokemon wildMon : monInfo.wildPokemon) {
|
||||||
|
@ -1726,20 +1728,18 @@ bool Project::readWildMonData() {
|
||||||
|
|
||||||
QString wildMonJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
QString wildMonJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
||||||
fileWatcher.addPath(wildMonJsonFilepath);
|
fileWatcher.addPath(wildMonJsonFilepath);
|
||||||
QJsonDocument wildMonsJsonDoc;
|
|
||||||
if (!parser.tryParseJsonFile(&wildMonsJsonDoc, wildMonJsonFilepath)) {
|
OrderedJson::object wildMonObj;
|
||||||
|
if (!parser.tryParseOrderedJsonFile(&wildMonObj, wildMonJsonFilepath)) {
|
||||||
logError(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
logError(QString("Failed to read wild encounters from %1").arg(wildMonJsonFilepath));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject wildMonObj = wildMonsJsonDoc.object();
|
for (OrderedJson subObjectRef : wildMonObj["wild_encounter_groups"].array_items()) {
|
||||||
|
OrderedJson::object subObject = subObjectRef.object_items();
|
||||||
for (auto subObjectRef : wildMonObj["wild_encounter_groups"].toArray()) {
|
if (!subObject["for_maps"].bool_value()) {
|
||||||
QJsonObject subObject = subObjectRef.toObject();
|
|
||||||
if (!subObject["for_maps"].toBool()) {
|
|
||||||
QString err;
|
QString err;
|
||||||
QString subObjson = QJsonDocument(subObject).toJson();
|
OrderedJson::object orderedSubObject = OrderedJson::parse(OrderedJson(subObject).dump(), err).object_items();
|
||||||
OrderedJson::object orderedSubObject = OrderedJson::parse(subObjson, err).object_items();
|
|
||||||
extraEncounterGroups.push_back(orderedSubObject);
|
extraEncounterGroups.push_back(orderedSubObject);
|
||||||
if (!err.isEmpty()) {
|
if (!err.isEmpty()) {
|
||||||
logWarn(QString("Encountered a problem while parsing extra encounter groups: %1").arg(err));
|
logWarn(QString("Encountered a problem while parsing extra encounter groups: %1").arg(err));
|
||||||
|
@ -1747,44 +1747,55 @@ bool Project::readWildMonData() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto field : subObject["fields"].toArray()) {
|
for (OrderedJson field : subObject["fields"].array_items()) {
|
||||||
EncounterField encounterField;
|
EncounterField encounterField;
|
||||||
encounterField.name = field.toObject()["type"].toString();
|
OrderedJson::object fieldObj = field.object_items();
|
||||||
for (auto val : field.toObject()["encounter_rates"].toArray()) {
|
encounterField.name = fieldObj["type"].string_value();
|
||||||
encounterField.encounterRates.append(val.toInt());
|
for (auto val : fieldObj["encounter_rates"].array_items()) {
|
||||||
|
encounterField.encounterRates.append(val.int_value());
|
||||||
}
|
}
|
||||||
for (QString group : field.toObject()["groups"].toObject().keys()) {
|
|
||||||
for (auto slotNum : field.toObject()["groups"].toObject()[group].toArray()) {
|
QList<QString> subGroups;
|
||||||
encounterField.groups[group].append(slotNum.toInt());
|
for (auto groupPair : fieldObj["groups"].object_items()) {
|
||||||
|
subGroups.append(groupPair.first);
|
||||||
|
}
|
||||||
|
for (QString group : subGroups) {
|
||||||
|
OrderedJson::object groupsObj = fieldObj["groups"].object_items();
|
||||||
|
for (auto slotNum : groupsObj[group].array_items()) {
|
||||||
|
encounterField.groups[group].append(slotNum.int_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wildMonFields.append(encounterField);
|
wildMonFields.append(encounterField);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray encounters = subObject["encounters"].toArray();
|
auto encounters = subObject["encounters"].array_items();
|
||||||
for (QJsonValue encounter : encounters) {
|
for (auto encounter : encounters) {
|
||||||
QString mapConstant = encounter.toObject().value("map").toString();
|
OrderedJson::object encounterObj = encounter.object_items();
|
||||||
|
QString mapConstant = encounterObj["map"].string_value();
|
||||||
|
|
||||||
WildPokemonHeader header;
|
WildPokemonHeader header;
|
||||||
|
|
||||||
for (EncounterField monField : wildMonFields) {
|
for (EncounterField monField : wildMonFields) {
|
||||||
QString field = monField.name;
|
QString field = monField.name;
|
||||||
if (encounter.toObject().value(field) != QJsonValue::Undefined) {
|
if (!encounterObj[field].is_null()) {
|
||||||
|
OrderedJson::object encounterFieldObj = encounterObj[field].object_items();
|
||||||
header.wildMons[field].active = true;
|
header.wildMons[field].active = true;
|
||||||
header.wildMons[field].encounterRate = encounter.toObject().value(field).toObject().value("encounter_rate").toInt();
|
header.wildMons[field].encounterRate = encounterFieldObj["encounter_rate"].int_value();
|
||||||
for (QJsonValue mon : encounter.toObject().value(field).toObject().value("mons").toArray()) {
|
for (auto mon : encounterFieldObj["mons"].array_items()) {
|
||||||
WildPokemon newMon;
|
WildPokemon newMon;
|
||||||
newMon.minLevel = mon.toObject().value("min_level").toInt();
|
OrderedJson::object monObj = mon.object_items();
|
||||||
newMon.maxLevel = mon.toObject().value("max_level").toInt();
|
newMon.minLevel = monObj["min_level"].int_value();
|
||||||
newMon.species = mon.toObject().value("species").toString();
|
newMon.maxLevel = monObj["max_level"].int_value();
|
||||||
|
newMon.species = monObj["species"].string_value();
|
||||||
header.wildMons[field].wildPokemon.append(newMon);
|
header.wildMons[field].wildPokemon.append(newMon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wildMonData[mapConstant].insert({encounter.toObject().value("base_label").toString(), header});
|
wildMonData[mapConstant].insert({encounterObj["base_label"].string_value(), header});
|
||||||
encounterGroupLabels.append(encounter.toObject().value("base_label").toString());
|
encounterGroupLabels.append(encounterObj["base_label"].string_value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ void MonTabWidget::populateTab(int tabIndex, WildMonInfo monInfo, QString fieldN
|
||||||
fieldIndex++;
|
fieldIndex++;
|
||||||
}
|
}
|
||||||
bool insertGroupLabel = false;
|
bool insertGroupLabel = false;
|
||||||
if (!editor->project->wildMonFields[fieldIndex].groups.isEmpty()) insertGroupLabel = true;
|
if (!editor->project->wildMonFields[fieldIndex].groups.empty()) insertGroupLabel = true;
|
||||||
|
|
||||||
speciesTable->setRowCount(monInfo.wildPokemon.size());
|
speciesTable->setRowCount(monInfo.wildPokemon.size());
|
||||||
speciesTable->setColumnCount(insertGroupLabel ? 8 : 7);
|
speciesTable->setColumnCount(insertGroupLabel ? 8 : 7);
|
||||||
|
@ -159,8 +159,9 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
|
||||||
}
|
}
|
||||||
|
|
||||||
double slotChanceTotal = 0.0;
|
double slotChanceTotal = 0.0;
|
||||||
if (!editor->project->wildMonFields[fieldIndex].groups.isEmpty()) {
|
if (!editor->project->wildMonFields[fieldIndex].groups.empty()) {
|
||||||
for (QString groupKey : editor->project->wildMonFields[fieldIndex].groups.keys()) {
|
for (auto groupKeyPair : editor->project->wildMonFields[fieldIndex].groups) {
|
||||||
|
QString groupKey = groupKeyPair.first;
|
||||||
if (editor->project->wildMonFields[fieldIndex].groups[groupKey].contains(index)) {
|
if (editor->project->wildMonFields[fieldIndex].groups[groupKey].contains(index)) {
|
||||||
for (int chanceIndex : editor->project->wildMonFields[fieldIndex].groups[groupKey]) {
|
for (int chanceIndex : editor->project->wildMonFields[fieldIndex].groups[groupKey]) {
|
||||||
slotChanceTotal += static_cast<double>(editor->project->wildMonFields[fieldIndex].encounterRates[chanceIndex]);
|
slotChanceTotal += static_cast<double>(editor->project->wildMonFields[fieldIndex].encounterRates[chanceIndex]);
|
||||||
|
@ -198,11 +199,12 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
|
||||||
maxLevelFrame->setLayout(maxLevelSpinboxLayout);
|
maxLevelFrame->setLayout(maxLevelSpinboxLayout);
|
||||||
|
|
||||||
bool insertGroupLabel = false;
|
bool insertGroupLabel = false;
|
||||||
if (!editor->project->wildMonFields[fieldIndex].groups.isEmpty()) insertGroupLabel = true;
|
if (!editor->project->wildMonFields[fieldIndex].groups.empty()) insertGroupLabel = true;
|
||||||
table->setCellWidget(index, 0, monNum);
|
table->setCellWidget(index, 0, monNum);
|
||||||
if (insertGroupLabel) {
|
if (insertGroupLabel) {
|
||||||
QString groupName = QString();
|
QString groupName = QString();
|
||||||
for (QString groupKey : editor->project->wildMonFields[fieldIndex].groups.keys()) {
|
for (auto groupKeyPair : editor->project->wildMonFields[fieldIndex].groups) {
|
||||||
|
QString groupKey = groupKeyPair.first;
|
||||||
if (editor->project->wildMonFields[fieldIndex].groups[groupKey].contains(index)) {
|
if (editor->project->wildMonFields[fieldIndex].groups[groupKey].contains(index)) {
|
||||||
groupName = groupKey;
|
groupName = groupKey;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue