Merge branch 'tracerestrict-sx' into jgrpp
# Conflicts: # src/group_cmd.cpp # src/group_gui.cpp # src/lang/english.txt # src/saveload/extended_ver_sl.cpp # src/tracerestrict.cpp # src/tracerestrict.h # src/tracerestrict_gui.cpp
This commit is contained in:
@@ -103,6 +103,29 @@ static const NWidgetPart _nested_group_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
/** Sort the groups by their name */
|
||||
int CDECL GroupNameSorter(const Group * const *a, const Group * const *b)
|
||||
{
|
||||
static const Group *last_group[2] = { NULL, NULL };
|
||||
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;
|
||||
}
|
||||
|
||||
class VehicleGroupWindow : public BaseVehicleListWindow {
|
||||
private:
|
||||
/* Columns in the group list */
|
||||
@@ -151,29 +174,6 @@ private:
|
||||
return has_children;
|
||||
}
|
||||
|
||||
/** Sort the groups by their name */
|
||||
static int CDECL GroupNameSorter(const Group * const *a, const Group * const *b)
|
||||
{
|
||||
static const Group *last_group[2] = { NULL, NULL };
|
||||
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;
|
||||
}
|
||||
|
||||
void ToogleGroupCollapse(GroupID group)
|
||||
{
|
||||
GroupID *item = this->collapsed_groups.Find(group);
|
||||
|
Reference in New Issue
Block a user