Town directory window: Only resort on population change if necessary

This commit is contained in:
Jonathan G Rennison
2020-01-06 20:19:50 +00:00
parent 68fa46d351
commit b868ce8605
3 changed files with 7 additions and 1 deletions

View File

@@ -204,6 +204,7 @@ enum TownRatingCheckType {
enum TownDirectoryInvalidateWindowData {
TDIWD_FORCE_REBUILD,
TDIWD_FILTER_CHANGES, ///< The filename filter has changed (via the editbox)
TDIWD_POPULATION_CHANGE,
TDIWD_FORCE_RESORT,
};

View File

@@ -548,7 +548,7 @@ static void ChangePopulation(Town *t, int mod)
InvalidateWindowData(WC_TOWN_VIEW, t->index); // Cargo requirements may appear/vanish for small populations
if (_settings_client.gui.population_in_label) t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_FORCE_RESORT);
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, TDIWD_POPULATION_CHANGE);
}
/**

View File

@@ -1001,6 +1001,11 @@ public:
this->vscroll->SetCount((int)this->towns.size()); // Update scrollbar as well.
}
break;
case TDIWD_POPULATION_CHANGE:
if (this->towns.SortType() == 1) this->towns.ForceResort();
break;
default:
this->towns.ForceResort();
}