MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetNumberRowsLegend

Method GetNumberRowsLegend

src/smallmap_gui.cpp:775–781  ·  view source on GitHub ↗

* Get the number of rows in the legend from the number of columns. Those * are at least min_number_of_fixed_rows and possibly more if there are so * many cargoes, industry types or companies that they won't fit in the * available space. * @param columns Number of columns in the legend. * @return Number of rows needed for everything to fit in. */

Source from the content-addressed store, hash-verified

773 * @return Number of rows needed for everything to fit in.
774 */
775 uint GetNumberRowsLegend(uint columns) const
776 {
777 /* Reserve one column for link colours */
778 uint num_rows_linkstats = CeilDiv(_smallmap_cargo_count, columns - 1);
779 uint num_rows_others = CeilDiv(std::max(_smallmap_industry_count, _smallmap_company_count), columns);
780 return std::max({this->min_number_of_fixed_rows, num_rows_linkstats, num_rows_others});
781 }
782
783 /**
784 * Select and toggle a legend item. When CTRL is pressed, disable all other

Callers 3

GetLegendHeightMethod · 0.95
GetPositionOnLegendMethod · 0.95
DrawWidgetMethod · 0.95

Calls 1

CeilDivFunction · 0.85

Tested by

no test coverage detected