add Encounter Chance column to mon tables

This commit is contained in:
garak 2019-09-21 21:13:54 -04:00 committed by huderlem
parent 91b498ee62
commit 09dd9380bb

View file

@ -63,10 +63,11 @@ void MonTabWidget::populateTab(int tabIndex, WildMonInfo monInfo, QString fieldN
QTableWidget *speciesTable = tableAt(tabIndex); QTableWidget *speciesTable = tableAt(tabIndex);
speciesTable->setRowCount(monInfo.wildPokemon.size()); speciesTable->setRowCount(monInfo.wildPokemon.size());
speciesTable->setColumnCount(6); speciesTable->setColumnCount(7);
QStringList landMonTableHeaders; QStringList landMonTableHeaders;
landMonTableHeaders << "Slot" << "Species" << "Min Level" << "Max Level" << "Slot Ratio" << "Encounter Rate"; landMonTableHeaders << "Slot" << "Species" << "Min Level" << "Max Level"
<< "Encounter Chance" << "Slot Ratio" << "Encounter Rate";
speciesTable->setHorizontalHeaderLabels(landMonTableHeaders); speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
speciesTable->horizontalHeader()->show(); speciesTable->horizontalHeader()->show();
speciesTable->verticalHeader()->hide(); speciesTable->verticalHeader()->hide();
@ -84,7 +85,7 @@ void MonTabWidget::populateTab(int tabIndex, WildMonInfo monInfo, QString fieldN
encounterRate->setValue(monInfo.encounterRate); encounterRate->setValue(monInfo.encounterRate);
encounterLayout->addWidget(encounterRate); encounterLayout->addWidget(encounterRate);
encounterFrame->setLayout(encounterLayout); encounterFrame->setLayout(encounterLayout);
speciesTable->setCellWidget(0, 5, encounterFrame); speciesTable->setCellWidget(0, 6, encounterFrame);
int i = 0; int i = 0;
for (WildPokemon mon : monInfo.wildPokemon) { for (WildPokemon mon : monInfo.wildPokemon) {
@ -130,7 +131,14 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
if (field.first == fieldName) break; if (field.first == fieldName) break;
fieldIndex++; fieldIndex++;
} }
QLabel *percentLabel = new QLabel(QString("%1").arg( double slotChanceTotal = 0;
for (auto chance : project->wildMonFields[fieldIndex].second) {
slotChanceTotal += static_cast<double>(chance);
}
QLabel *percentLabel = new QLabel(QString("%1%").arg(
QString::number(project->wildMonFields[fieldIndex].second[index] / slotChanceTotal * 100.0, 'f', 2)
));
QLabel *ratioLabel = new QLabel(QString("%1").arg(
QString::number(project->wildMonFields[fieldIndex].second[index] QString::number(project->wildMonFields[fieldIndex].second[index]
))); )));
@ -155,6 +163,7 @@ void MonTabWidget::createSpeciesTableRow(QTableWidget *table, WildPokemon mon, i
table->setCellWidget(index, 2, minLevelFrame); table->setCellWidget(index, 2, minLevelFrame);
table->setCellWidget(index, 3, maxLevelFrame); table->setCellWidget(index, 3, maxLevelFrame);
table->setCellWidget(index, 4, percentLabel); table->setCellWidget(index, 4, percentLabel);
table->setCellWidget(index, 5, ratioLabel);
} }
QTableWidget *MonTabWidget::tableAt(int tabIndex) { QTableWidget *MonTabWidget::tableAt(int tabIndex) {