Codechange: Remove TKM from vehicle list sorting dropdowns.

This commit is contained in:
frosch 2024-01-24 22:31:19 +01:00 committed by frosch
parent 9741510396
commit 69f47caf3f
4 changed files with 65 additions and 25 deletions

View File

@ -418,8 +418,10 @@ public:
break;
case WID_GL_SORT_BY_DROPDOWN:
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names));
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock));
size->width += padding.width;
break;

View File

@ -331,8 +331,10 @@ STR_SORT_BY_PRODUCTION :Production
STR_SORT_BY_TYPE :Type
STR_SORT_BY_TRANSPORTED :Transported
STR_SORT_BY_NUMBER :Number
STR_SORT_BY_PROFIT_LAST_YEAR :Profit last {TKM year period}
STR_SORT_BY_PROFIT_THIS_YEAR :Profit this {TKM year period}
STR_SORT_BY_PROFIT_LAST_YEAR :Profit last year
STR_SORT_BY_PROFIT_LAST_PERIOD :Profit last period
STR_SORT_BY_PROFIT_THIS_YEAR :Profit this year
STR_SORT_BY_PROFIT_THIS_PERIOD :Profit this period
STR_SORT_BY_AGE :Age
STR_SORT_BY_RELIABILITY :Reliability
STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE :Total capacity per cargo type
@ -359,10 +361,14 @@ STR_SORT_BY_RANGE :Range
STR_SORT_BY_POPULATION :Population
STR_SORT_BY_RATING :Rating
STR_SORT_BY_NUM_VEHICLES :Number of vehicles
STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR :Total profit last {TKM year period}
STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR :Total profit this {TKM year period}
STR_SORT_BY_AVERAGE_PROFIT_LAST_YEAR :Average profit last {TKM year period}
STR_SORT_BY_AVERAGE_PROFIT_THIS_YEAR :Average profit this {TKM year period}
STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR :Total profit last year
STR_SORT_BY_TOTAL_PROFIT_LAST_PERIOD :Total profit last period
STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR :Total profit this year
STR_SORT_BY_TOTAL_PROFIT_THIS_PERIOD :Total profit this period
STR_SORT_BY_AVERAGE_PROFIT_LAST_YEAR :Average profit last year
STR_SORT_BY_AVERAGE_PROFIT_LAST_PERIOD :Average profit last period
STR_SORT_BY_AVERAGE_PROFIT_THIS_YEAR :Average profit this year
STR_SORT_BY_AVERAGE_PROFIT_THIS_PERIOD :Average profit this period
# Group by options for vehicle list
STR_GROUP_BY_NONE :None

View File

@ -93,7 +93,7 @@ BaseVehicleListWindow::VehicleGroupSortFunction * const BaseVehicleListWindow::v
&VehicleIndividualToGroupSorterWrapper<VehicleTimetableDelaySorter>,
};
const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names[] = {
const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names_calendar[] = {
STR_SORT_BY_NUMBER,
STR_SORT_BY_NAME,
STR_SORT_BY_AGE,
@ -110,6 +110,23 @@ const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names[] = {
INVALID_STRING_ID
};
const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names_wallclock[] = {
STR_SORT_BY_NUMBER,
STR_SORT_BY_NAME,
STR_SORT_BY_AGE,
STR_SORT_BY_PROFIT_THIS_PERIOD,
STR_SORT_BY_PROFIT_LAST_PERIOD,
STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE,
STR_SORT_BY_RELIABILITY,
STR_SORT_BY_MAX_SPEED,
STR_SORT_BY_MODEL,
STR_SORT_BY_VALUE,
STR_SORT_BY_LENGTH,
STR_SORT_BY_LIFE_TIME,
STR_SORT_BY_TIMETABLE_DELAY,
INVALID_STRING_ID
};
BaseVehicleListWindow::VehicleGroupSortFunction * const BaseVehicleListWindow::vehicle_group_shared_orders_sorter_funcs[] = {
&VehicleGroupLengthSorter,
&VehicleGroupTotalProfitThisYearSorter,
@ -118,7 +135,7 @@ BaseVehicleListWindow::VehicleGroupSortFunction * const BaseVehicleListWindow::v
&VehicleGroupAverageProfitLastYearSorter,
};
const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names[] = {
const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names_calendar[] = {
STR_SORT_BY_NUM_VEHICLES,
STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR,
STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR,
@ -127,6 +144,15 @@ const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names[]
INVALID_STRING_ID
};
const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names_wallclock[] = {
STR_SORT_BY_NUM_VEHICLES,
STR_SORT_BY_TOTAL_PROFIT_THIS_PERIOD,
STR_SORT_BY_TOTAL_PROFIT_LAST_PERIOD,
STR_SORT_BY_AVERAGE_PROFIT_THIS_PERIOD,
STR_SORT_BY_AVERAGE_PROFIT_LAST_PERIOD,
INVALID_STRING_ID
};
const StringID BaseVehicleListWindow::vehicle_group_by_names[] = {
STR_GROUP_BY_NONE,
STR_GROUP_BY_SHARED_ORDERS,
@ -147,6 +173,18 @@ BaseVehicleListWindow::BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno)
this->UpdateSortingFromGrouping();
}
const StringID *BaseVehicleListWindow::GetVehicleSorterNames()
{
switch (this->grouping) {
case GB_NONE:
return TimerGameEconomy::UsingWallclockUnits() ? vehicle_group_none_sorter_names_wallclock : vehicle_group_none_sorter_names_calendar;
case GB_SHARED_ORDERS:
return TimerGameEconomy::UsingWallclockUnits() ? vehicle_group_shared_orders_sorter_names_wallclock : vehicle_group_shared_orders_sorter_names_calendar;
default:
NOT_REACHED();
}
}
/**
* Get the number of digits of space required for the given number.
* @param number The number.
@ -1885,8 +1923,10 @@ public:
break;
case WID_VL_SORT_BY_PULLDOWN:
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names));
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock));
size->width += padding.width;
break;

View File

@ -99,8 +99,10 @@ struct BaseVehicleListWindow : public Window {
static const StringID vehicle_depot_name[];
static const StringID vehicle_group_by_names[];
static const StringID vehicle_group_none_sorter_names[];
static const StringID vehicle_group_shared_orders_sorter_names[];
static const StringID vehicle_group_none_sorter_names_calendar[];
static const StringID vehicle_group_none_sorter_names_wallclock[];
static const StringID vehicle_group_shared_orders_sorter_names_calendar[];
static const StringID vehicle_group_shared_orders_sorter_names_wallclock[];
static VehicleGroupSortFunction * const vehicle_group_none_sorter_funcs[];
static VehicleGroupSortFunction * const vehicle_group_shared_orders_sorter_funcs[];
@ -122,17 +124,7 @@ struct BaseVehicleListWindow : public Window {
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_create);
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_create);
const StringID *GetVehicleSorterNames()
{
switch (this->grouping) {
case GB_NONE:
return vehicle_group_none_sorter_names;
case GB_SHARED_ORDERS:
return vehicle_group_shared_orders_sorter_names;
default:
NOT_REACHED();
}
}
const StringID *GetVehicleSorterNames();
VehicleGroupSortFunction * const *GetVehicleSorterFuncs()
{