Update to 1.10.3

This commit is contained in:
dP
2020-08-09 21:34:52 +03:00
parent 5ff4fa4bc0
commit d3c06c25c8
80 changed files with 799 additions and 454 deletions

View File

@@ -615,28 +615,6 @@ private:
ShowDropDownList(this, std::move(list), sel, widget);
}
static bool GroupNameSorter(const Group * const &a, const Group * const &b)
{
static const Group *last_group[2] = { nullptr, nullptr };
static char last_name[2][64] = { "", "" };
if (a != last_group[0]) {
last_group[0] = a;
SetDParam(0, a->index);
GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
}
if (b != last_group[1]) {
last_group[1] = b;
SetDParam(0, b->index);
GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1]));
}
int r = strnatcmp(last_name[0], last_name[1]); // Sort by name (natural sorting).
if (r == 0) return a->index < b->index;
return r < 0;
}
void AddChildren(GUIGroupList *source, GroupID parent, int indent)
{
for (const Group *g : *source) {
@@ -665,7 +643,27 @@ private:
}
list.ForceResort();
list.Sort(&GroupNameSorter);
/* Sort the groups by their name */
const Group *last_group[2] = { nullptr, nullptr };
char last_name[2][64] = { "", "" };
list.Sort([&](const Group * const &a, const Group * const &b) -> bool {
if (a != last_group[0]) {
last_group[0] = a;
SetDParam(0, a->index);
GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0]));
}
if (b != last_group[1]) {
last_group[1] = b;
SetDParam(0, b->index);
GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1]));
}
int r = strnatcmp(last_name[0], last_name[1]); // Sort by name (natural sorting).
if (r == 0) return a->index < b->index;
return r < 0;
});
AddChildren(&list, INVALID_GROUP, 0);
}
@@ -1884,7 +1882,7 @@ struct CompanyInfrastructureWindow : Window
switch (widget) {
case WID_CI_RAIL_DESC: {
uint lines = 1;
uint lines = 1; // Starts at 1 because a line is also required for the section title
size->width = max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width);
@@ -1907,7 +1905,7 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_ROAD_DESC:
case WID_CI_TRAM_DESC: {
uint lines = 0;
uint lines = 1; // Starts at 1 because a line is also required for the section title
size->width = max(size->width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width);