change encounterRate slider to a spin box
This commit is contained in:
parent
6fa715db09
commit
96020c21dd
4 changed files with 8 additions and 19 deletions
|
@ -23,6 +23,6 @@ typedef QVector<QPair<QString, QVector<int>>> Fields;
|
|||
typedef QPair<QString, QVector<int>> Field;
|
||||
|
||||
WildMonInfo getDefaultMonInfo(Field field);
|
||||
WildMonInfo copyMonInfoFromTab(QTableWidget *table, Field field);
|
||||
WildMonInfo copyMonInfoFromTab(QTableWidget *table);
|
||||
|
||||
#endif // GUARD_WILDMONINFO_H
|
||||
|
|
|
@ -15,7 +15,7 @@ WildMonInfo getDefaultMonInfo(Field field) {
|
|||
return newInfo;
|
||||
}
|
||||
|
||||
WildMonInfo copyMonInfoFromTab(QTableWidget *monTable, Field field) {
|
||||
WildMonInfo copyMonInfoFromTab(QTableWidget *monTable) {
|
||||
WildMonInfo newInfo;
|
||||
QVector<WildPokemon> newWildMons;
|
||||
|
||||
|
@ -28,7 +28,7 @@ WildMonInfo copyMonInfoFromTab(QTableWidget *monTable, Field field) {
|
|||
}
|
||||
newInfo.active = true;
|
||||
newInfo.wildPokemon = newWildMons;
|
||||
newInfo.encounterRate = monTable->findChild<QSlider *>()->value();
|
||||
newInfo.encounterRate = monTable->findChild<QSpinBox *>()->value();
|
||||
|
||||
return newInfo;
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ void Editor::addNewWildMonGroup() {
|
|||
if (copyCheckbox->isChecked()) {
|
||||
MonTabWidget *copyFrom = static_cast<MonTabWidget *>(stack->widget(stackIndex));
|
||||
if (copyFrom->isTabEnabled(tabIndex))
|
||||
header.wildMons.insert(fieldName, copyMonInfoFromTab(copyFrom->tableAt(tabIndex), monField));
|
||||
header.wildMons.insert(fieldName, copyMonInfoFromTab(copyFrom->tableAt(tabIndex)));
|
||||
else
|
||||
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
||||
} else {
|
||||
|
@ -341,7 +341,7 @@ void Editor::configureEncounterJSON() {
|
|||
chanceSpinner->setValue(chance);
|
||||
chanceSpinner->setMinimum(0);
|
||||
chanceSpinner->setMaximum(9999);
|
||||
connect(chanceSpinner, QOverload<int>::of(&QSpinBox::valueChanged), [&chanceSpinner, &updateTotal, ¤tField](int val) {
|
||||
connect(chanceSpinner, QOverload<int>::of(&QSpinBox::valueChanged), [&chanceSpinner, &updateTotal, ¤tField](int) {
|
||||
updateTotal(currentField);
|
||||
});
|
||||
|
||||
|
@ -492,7 +492,7 @@ void Editor::saveEncounterTabData() {
|
|||
|
||||
QTableWidget *monTable = static_cast<QTableWidget *>(tabWidget->widget(fieldIndex - 1));
|
||||
QVector<WildPokemon> newWildMons;
|
||||
encounterHeader.wildMons[fieldName] = copyMonInfoFromTab(monTable, monField);
|
||||
encounterHeader.wildMons[fieldName] = copyMonInfoFromTab(monTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,23 +78,12 @@ void MonTabWidget::populateTab(int tabIndex, WildMonInfo monInfo, QString fieldN
|
|||
QFrame *encounterFrame = new QFrame;
|
||||
QHBoxLayout *encounterLayout = new QHBoxLayout;
|
||||
|
||||
QSlider *encounterRate = new QSlider(Qt::Horizontal);
|
||||
QSpinBox *encounterRate = new QSpinBox;
|
||||
encounterRate->setMinimum(0);
|
||||
encounterRate->setMaximum(100);
|
||||
|
||||
QLabel *encounterLabel = new QLabel;
|
||||
connect(encounterRate, &QSlider::valueChanged, [=](int value){
|
||||
encounterLabel->setText(QString("%1%").arg(QString::number(value)));
|
||||
});
|
||||
encounterRate->setMaximum(180);
|
||||
encounterRate->setValue(monInfo.encounterRate);
|
||||
// for some reason the signal is not being emitted above
|
||||
encounterLabel->setText(QString("%1%").arg(QString::number(monInfo.encounterRate)));
|
||||
|
||||
encounterLayout->addWidget(encounterLabel);
|
||||
encounterLayout->addWidget(encounterRate);
|
||||
|
||||
encounterFrame->setLayout(encounterLayout);
|
||||
|
||||
speciesTable->setCellWidget(0, 5, encounterFrame);
|
||||
|
||||
int i = 0;
|
||||
|
|
Loading…
Reference in a new issue