Skip to content

Commit

Permalink
Automatically adjust min/max encounter levels
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Jul 31, 2023
1 parent 0b293d2 commit 1ecb2cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
## [Unreleased]
### Changed
- The Palette Editor now remembers the Bit Depth setting.
- The min/max levels on the Wild Pokémon tab will now adjust automatically if they invalidate each other.

### Fixed
- Fix text boxes in the Palette Editor calculating color incorrectly.
Expand Down
6 changes: 1 addition & 5 deletions src/ui/encountertabledelegates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
editor->setFrame(false);

int col = index.column();
if (col == EncounterTableModel::ColumnType::MinLevel) {
if (col == EncounterTableModel::ColumnType::MinLevel || col == EncounterTableModel::ColumnType::MaxLevel) {
editor->setMinimum(this->project->miscConstants.value("min_level_define").toInt());
editor->setMaximum(index.siblingAtColumn(EncounterTableModel::ColumnType::MaxLevel).data(Qt::EditRole).toInt());
}
else if (col == EncounterTableModel::ColumnType::MaxLevel) {
editor->setMinimum(index.siblingAtColumn(EncounterTableModel::ColumnType::MinLevel).data(Qt::EditRole).toInt());
editor->setMaximum(this->project->miscConstants.value("max_level_define").toInt());
}
else if (col == EncounterTableModel::ColumnType::EncounterRate) {
Expand Down
16 changes: 12 additions & 4 deletions src/ui/encountertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,21 @@ bool EncounterTableModel::setData(const QModelIndex &index, const QVariant &valu
this->monInfo.wildPokemon[row].species = value.toString();
break;

case ColumnType::MinLevel:
this->monInfo.wildPokemon[row].minLevel = value.toInt();
case ColumnType::MinLevel: {
int minLevel = value.toInt();
this->monInfo.wildPokemon[row].minLevel = minLevel;
if (minLevel > this->monInfo.wildPokemon[row].maxLevel)
this->monInfo.wildPokemon[row].maxLevel = minLevel;
break;
}

case ColumnType::MaxLevel:
this->monInfo.wildPokemon[row].maxLevel = value.toInt();
case ColumnType::MaxLevel: {
int maxLevel = value.toInt();
this->monInfo.wildPokemon[row].maxLevel = maxLevel;
if (maxLevel < this->monInfo.wildPokemon[row].minLevel)
this->monInfo.wildPokemon[row].minLevel = maxLevel;
break;
}

case ColumnType::EncounterRate:
this->monInfo.encounterRate = value.toInt();
Expand Down

0 comments on commit 1ecb2cc

Please sign in to comment.