diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 3d0ce02dd6..f053507a4b 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -1809,6 +1809,7 @@ struct CompanyInfrastructureWindow : Window RoadTypes roadtypes; ///< Valid roadtypes. uint total_width; ///< String width of the total cost line. + uint height_extra; ///< Default extra height above minimum. Scrollbar *vscroll; ///< Scrollbar @@ -1939,7 +1940,9 @@ struct CompanyInfrastructureWindow : Window this->vscroll->SetCount(total_height); - size->height = std::max(size->height, std::min(20 * FONT_HEIGHT_NORMAL, total_height)); + size->height = std::max(size->height, std::min(8 * FONT_HEIGHT_NORMAL, total_height)); + uint target_height = std::min(40 * FONT_HEIGHT_NORMAL, total_height); + this->height_extra = (target_height > size->height) ? (target_height - size->height) : 0; break; } @@ -2141,6 +2144,14 @@ struct CompanyInfrastructureWindow : Window this->vscroll->SetCapacityFromWidget(this, WID_CI_DESC); } + void FindWindowPlacementAndResize(int def_width, int def_height) override + { + if (this->window_desc->GetPreferences().pref_height == 0) { + def_height = this->nested_root->smallest_y + this->height_extra; + } + Window::FindWindowPlacementAndResize(def_width, def_height); + } + /** * Some data on this window has become invalid. * @param data Information about the changed data.