fix copy from existing encounter group function
This commit is contained in:
parent
f7022fc3d2
commit
3c2b7a8df7
3 changed files with 41 additions and 1 deletions
|
@ -34,5 +34,6 @@ void clearTabWidget(QLayout *tab);
|
||||||
//void populateWildMonTabWidget(MonTabWidget *tabWidget, Fields /* QVector<QPair<QString, QVector<int>>> */ fields);
|
//void populateWildMonTabWidget(MonTabWidget *tabWidget, Fields /* QVector<QPair<QString, QVector<int>>> */ fields);
|
||||||
|
|
||||||
WildMonInfo getDefaultMonInfo(Field field);
|
WildMonInfo getDefaultMonInfo(Field field);
|
||||||
|
WildMonInfo copyMonInfoFromTab(QTableWidget *table, Field field);
|
||||||
|
|
||||||
#endif // GUARD_WILDMONINFO_H
|
#endif // GUARD_WILDMONINFO_H
|
||||||
|
|
|
@ -31,4 +31,21 @@ WildMonInfo getDefaultMonInfo(Field field) {
|
||||||
return newInfo;
|
return newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WildMonInfo copyMonInfoFromTab(QTableWidget *monTable, Field field) {
|
||||||
|
WildMonInfo newInfo;
|
||||||
|
QVector<WildPokemon> newWildMons;
|
||||||
|
|
||||||
|
for (int row = 0; row < monTable->rowCount(); row++) {
|
||||||
|
WildPokemon newWildMon;
|
||||||
|
newWildMon.species = monTable->cellWidget(row, 1)->findChild<QComboBox *>()->currentText();
|
||||||
|
newWildMon.minLevel = monTable->cellWidget(row, 2)->findChild<QSpinBox *>()->value();
|
||||||
|
newWildMon.maxLevel = monTable->cellWidget(row, 3)->findChild<QSpinBox *>()->value();
|
||||||
|
newWildMons.append(newWildMon);
|
||||||
|
}
|
||||||
|
newInfo.active = true;
|
||||||
|
newInfo.wildPokemon = newWildMons;
|
||||||
|
newInfo.encounterRate = monTable->findChild<QSlider *>()->value();
|
||||||
|
|
||||||
|
return newInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,8 @@ void Editor::addNewWildMonGroup() {
|
||||||
QStackedWidget *stack = ui->stackedWidget_WildMons;
|
QStackedWidget *stack = ui->stackedWidget_WildMons;
|
||||||
QComboBox *labelCombo = ui->comboBox_EncounterGroupLabel;
|
QComboBox *labelCombo = ui->comboBox_EncounterGroupLabel;
|
||||||
|
|
||||||
|
int stackIndex = stack->currentIndex();
|
||||||
|
|
||||||
QDialog dialog(nullptr, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
QDialog dialog(nullptr, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||||
dialog.setWindowTitle("New Wild Encounter Group Label");
|
dialog.setWindowTitle("New Wild Encounter Group Label");
|
||||||
dialog.setWindowModality(Qt::NonModal);
|
dialog.setWindowModality(Qt::NonModal);
|
||||||
|
@ -309,6 +311,13 @@ void Editor::addNewWildMonGroup() {
|
||||||
MonTabWidget *monWidget = static_cast<MonTabWidget *>(stack->widget(stack->currentIndex()));
|
MonTabWidget *monWidget = static_cast<MonTabWidget *>(stack->widget(stack->currentIndex()));
|
||||||
for (Field monField : project->wildMonFields) {
|
for (Field monField : project->wildMonFields) {
|
||||||
fieldCheckboxes[fieldIndex]->setChecked(monWidget->isTabEnabled(fieldIndex));//header.wildMons.value(monField.first).active);
|
fieldCheckboxes[fieldIndex]->setChecked(monWidget->isTabEnabled(fieldIndex));//header.wildMons.value(monField.first).active);
|
||||||
|
fieldCheckboxes[fieldIndex]->setEnabled(false);
|
||||||
|
fieldIndex++;
|
||||||
|
}
|
||||||
|
} else if (state == Qt::Unchecked) {
|
||||||
|
int fieldIndex = 0;
|
||||||
|
for (Field monField : project->wildMonFields) {
|
||||||
|
fieldCheckboxes[fieldIndex]->setEnabled(true);
|
||||||
fieldIndex++;
|
fieldIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +364,16 @@ void Editor::addNewWildMonGroup() {
|
||||||
tabWidget->clearTableAt(tabIndex);
|
tabWidget->clearTableAt(tabIndex);
|
||||||
if (fieldCheckboxes[tabIndex]->isChecked()) {//(header.wildMons[fieldName].active) {
|
if (fieldCheckboxes[tabIndex]->isChecked()) {//(header.wildMons[fieldName].active) {
|
||||||
qDebug() << "checked" << fieldName;
|
qDebug() << "checked" << fieldName;
|
||||||
|
if (copyCheckbox->isChecked()) {
|
||||||
|
qDebug() << "copying mons from current group";
|
||||||
|
MonTabWidget *copyFrom = static_cast<MonTabWidget *>(stack->widget(stackIndex));
|
||||||
|
if (copyFrom->isTabEnabled(tabIndex))
|
||||||
|
header.wildMons.insert(fieldName, copyMonInfoFromTab(copyFrom->tableAt(tabIndex), monField));
|
||||||
|
else
|
||||||
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
||||||
|
} else {
|
||||||
|
header.wildMons.insert(fieldName, getDefaultMonInfo(monField));
|
||||||
|
}
|
||||||
tabWidget->populateTab(tabIndex, header.wildMons[fieldName], fieldName);
|
tabWidget->populateTab(tabIndex, header.wildMons[fieldName], fieldName);
|
||||||
} else {
|
} else {
|
||||||
tabWidget->setTabActive(tabIndex, false);
|
tabWidget->setTabActive(tabIndex, false);
|
||||||
|
@ -413,7 +431,10 @@ void Editor::saveEncounterTabData() {
|
||||||
|
|
||||||
QVector<WildPokemon> newWildMons;
|
QVector<WildPokemon> newWildMons;
|
||||||
|
|
||||||
|
encounterHeader.wildMons[fieldName] = copyMonInfoFromTab(monTable, monField);
|
||||||
|
|
||||||
//for (auto *speciesCombo : monTable->findChildren<QComboBox *>()) {
|
//for (auto *speciesCombo : monTable->findChildren<QComboBox *>()) {
|
||||||
|
/*
|
||||||
for (int row = 0; row < monTable->rowCount(); row++) {
|
for (int row = 0; row < monTable->rowCount(); row++) {
|
||||||
// cellWidget(row, column)
|
// cellWidget(row, column)
|
||||||
WildPokemon newWildMon;
|
WildPokemon newWildMon;
|
||||||
|
@ -427,6 +448,7 @@ void Editor::saveEncounterTabData() {
|
||||||
encounterHeader.wildMons[fieldName].wildPokemon = newWildMons;
|
encounterHeader.wildMons[fieldName].wildPokemon = newWildMons;
|
||||||
encounterHeader.wildMons[fieldName].encounterRate = monTable->findChild<QSlider *>()->value();
|
encounterHeader.wildMons[fieldName].encounterRate = monTable->findChild<QSlider *>()->value();
|
||||||
//fieldIndex++;
|
//fieldIndex++;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue