mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use GetVisibleRangeIterators when drawing airport specs.
parent
b9c44b29be
commit
2199543fbc
|
@ -384,13 +384,14 @@ public:
|
||||||
case WID_AP_AIRPORT_LIST: {
|
case WID_AP_AIRPORT_LIST: {
|
||||||
Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
|
Rect row = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.bevel);
|
||||||
Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
|
Rect text = r.WithHeight(this->line_height).Shrink(WidgetDimensions::scaled.matrix);
|
||||||
AirportClass *apclass = AirportClass::Get(_selected_airport_class);
|
const auto specs = AirportClass::Get(_selected_airport_class)->Specs();
|
||||||
for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < apclass->GetSpecCount(); i++) {
|
auto [first, last] = this->vscroll->GetVisibleRangeIterators(specs);
|
||||||
const AirportSpec *as = apclass->GetSpec(i);
|
for (auto it = first; it != last; ++it) {
|
||||||
|
const AirportSpec *as = *it;
|
||||||
if (!as->IsAvailable()) {
|
if (!as->IsAvailable()) {
|
||||||
GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
|
GfxFillRect(row, PC_BLACK, FILLRECT_CHECKER);
|
||||||
}
|
}
|
||||||
DrawString(text, as->name, ((int)i == _selected_airport_index) ? TC_WHITE : TC_BLACK);
|
DrawString(text, as->name, (static_cast<int>(as->index) == _selected_airport_index) ? TC_WHITE : TC_BLACK);
|
||||||
row = row.Translate(0, this->line_height);
|
row = row.Translate(0, this->line_height);
|
||||||
text = text.Translate(0, this->line_height);
|
text = text.Translate(0, this->line_height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue