add encounter rate slider to wild mon tables
This commit is contained in:
parent
ce002bcb4d
commit
1369113a1b
2 changed files with 31 additions and 16 deletions
|
@ -21,7 +21,10 @@ void clearTabWidget(QLayout *tab) {
|
||||||
|
|
||||||
void clearTable(QTableWidget *table) {
|
void clearTable(QTableWidget *table) {
|
||||||
//
|
//
|
||||||
if (table) table->clear();
|
if (table) {
|
||||||
|
table->clear();
|
||||||
|
table->horizontalHeader()->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSpeciesTableRow(Project *project, QTableWidget *table, WildPokemon mon, int index) {
|
void createSpeciesTableRow(Project *project, QTableWidget *table, WildPokemon mon, int index) {
|
||||||
|
@ -94,6 +97,7 @@ void populateWildMonTabWidget(QTabWidget *tabWidget, QVector<QString> fields) {
|
||||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
table->setFocusPolicy(Qt::NoFocus);
|
table->setFocusPolicy(Qt::NoFocus);
|
||||||
table->setSelectionMode(QAbstractItemView::NoSelection);
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
table->clearFocus();
|
||||||
tabWidget->addTab(table, field);
|
tabWidget->addTab(table, field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,32 +155,22 @@ void Editor::setEditingWildMons() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::displayWildMonTables() {
|
void Editor::displayWildMonTables() {
|
||||||
// clear tables
|
|
||||||
//int tabIndex = 0;
|
|
||||||
//for (; tabIndex < project->wildMonFields.size(); tabIndex++) {
|
|
||||||
// QTableWidget *speciesTable = static_cast<QTableWidget *>(ui->tabWidget_WildMons->widget(tabIndex));
|
|
||||||
// clearTable(speciesTable);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (!project->wildMonData.contains(map->constantName)) return;
|
|
||||||
|
|
||||||
WildPokemonHeader header = project->wildMonData.value(map->constantName);
|
WildPokemonHeader header = project->wildMonData.value(map->constantName);
|
||||||
|
|
||||||
int tabIndex = 0;
|
int tabIndex = 0;
|
||||||
for (QString field : project->wildMonFields) {
|
for (QString field : project->wildMonFields) {
|
||||||
QTableWidget *speciesTable = static_cast<QTableWidget *>(ui->tabWidget_WildMons->widget(tabIndex++));
|
QTableWidget *speciesTable = static_cast<QTableWidget *>(ui->tabWidget_WildMons->widget(tabIndex++));
|
||||||
clearTable(speciesTable);
|
clearTable(speciesTable);
|
||||||
//speciesTable->setFocusPolicy(Qt::NoFocus);
|
//speciesTable->horizontalHeader()->hide();
|
||||||
if (!project->wildMonData.contains(map->constantName)) continue;
|
|
||||||
|
|
||||||
if (header.wildMons[field].active) {//else,
|
if (project->wildMonData.contains(map->constantName) && header.wildMons[field].active) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
speciesTable->setRowCount(header.wildMons[field].wildPokemon.size());
|
speciesTable->setRowCount(header.wildMons[field].wildPokemon.size());
|
||||||
speciesTable->setColumnCount(5);// + 1 for last column stretch?
|
speciesTable->setColumnCount(6);// TODO: stretch last column?
|
||||||
|
|
||||||
QStringList landMonTableHeaders;
|
QStringList landMonTableHeaders;
|
||||||
landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Catch Percentage";
|
landMonTableHeaders << "Index" << "Species" << "Min Level" << "Max Level" << "Catch Percentage" << "Encounter Rate";
|
||||||
speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
|
speciesTable->setHorizontalHeaderLabels(landMonTableHeaders);
|
||||||
speciesTable->horizontalHeader()->show();
|
speciesTable->horizontalHeader()->show();
|
||||||
speciesTable->verticalHeader()->hide();
|
speciesTable->verticalHeader()->hide();
|
||||||
|
@ -189,12 +179,33 @@ void Editor::displayWildMonTables() {
|
||||||
|
|
||||||
speciesTable->setShowGrid(false);
|
speciesTable->setShowGrid(false);
|
||||||
|
|
||||||
|
// set encounter rate slider
|
||||||
|
// don't forget to add number label next to it
|
||||||
|
QFrame *encounterFrame = new QFrame;
|
||||||
|
QHBoxLayout *encounterLayout = new QHBoxLayout;
|
||||||
|
|
||||||
|
QSlider *encounterRate = new QSlider(Qt::Horizontal);
|
||||||
|
encounterRate->setMinimum(1);
|
||||||
|
encounterRate->setMaximum(100);
|
||||||
|
|
||||||
|
QLabel *encounterLabel = new QLabel;
|
||||||
|
connect(encounterRate, &QSlider::valueChanged, [=](int value){
|
||||||
|
encounterLabel->setText(QString::number(value));
|
||||||
|
});
|
||||||
|
encounterRate->setValue(header.wildMons[field].encounterRate);
|
||||||
|
|
||||||
|
encounterLayout->addWidget(encounterLabel);
|
||||||
|
encounterLayout->addWidget(encounterRate);
|
||||||
|
|
||||||
|
encounterFrame->setLayout(encounterLayout);
|
||||||
|
|
||||||
|
speciesTable->setCellWidget(0, 5, encounterFrame);
|
||||||
|
|
||||||
for (WildPokemon mon : header.wildMons[field].wildPokemon) {
|
for (WildPokemon mon : header.wildMons[field].wildPokemon) {
|
||||||
createSpeciesTableRow(project, speciesTable, mon, i);
|
createSpeciesTableRow(project, speciesTable, mon, i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
speciesTable->horizontalHeader()->hide();
|
|
||||||
// create button to add this field to this map
|
// create button to add this field to this map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue