Avoid unnecessary redrawing of vehicle list windows

Redraw info section every tick if values have changed
This commit is contained in:
Jonathan G Rennison
2020-10-03 22:28:20 +01:00
parent 2c4808e239
commit bd2649c19e
15 changed files with 79 additions and 52 deletions

View File

@@ -2287,6 +2287,24 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileInde
ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
}
void DirtyVehicleListWindowForVehicle(const Vehicle *v)
{
WindowClass cls = static_cast<WindowClass>(WC_TRAINS_LIST + v->type);
WindowClass cls2 = (v->type == VEH_TRAIN) ? WC_TRACE_RESTRICT_SLOTS : cls;
Window *w;
FOR_ALL_WINDOWS_FROM_BACK(w) {
if (w->window_class == cls || w->window_class == cls2) {
BaseVehicleListWindow *listwin = static_cast<BaseVehicleListWindow *>(w);
uint max = min(listwin->vscroll->GetPosition() + listwin->vscroll->GetCapacity(), (uint)listwin->vehicles.size());
for (uint i = listwin->vscroll->GetPosition(); i < max; ++i) {
if (v == listwin->vehicles[i]) {
listwin->SetWidgetDirty(0);
break;
}
}
}
}
}
/* Unified vehicle GUI - Vehicle Details Window */