diff --git a/src/lang/english.txt b/src/lang/english.txt index 96eb124257..3cd979a6e1 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1432,6 +1432,8 @@ STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Width of the li STR_CONFIG_SETTING_SHOW_NEWGRF_NAME :Show the NewGRF's name in the build vehicle window: {STRING2} STR_CONFIG_SETTING_SHOW_NEWGRF_NAME_HELPTEXT :Add a line to the build vehicle window, showing which NewGRF the selected vehicle comes from. +STR_CONFIG_SETTING_SHOW_CARGO_IN_LISTS :Show the cargoes the vehicles can carry in the list windows {STRING2} +STR_CONFIG_SETTING_SHOW_CARGO_IN_LISTS_HELPTEXT :If enabled, the vehicle's transportable load will appear above it in the vehicle lists STR_CONFIG_SETTING_LANDSCAPE :Landscape: {STRING2} STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Landscapes define basic gameplay scenarios with different cargoes and town growth requirements. NewGRF and Game Scripts allow finer control though @@ -3802,6 +3804,8 @@ STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP :{BLACK}Send ins STR_VEHICLE_LIST_REPLACE_VEHICLES :Replace vehicles STR_VEHICLE_LIST_SEND_FOR_SERVICING :Send for Servicing STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR :{TINY_FONT}{BLACK}Profit this year: {CURRENCY_LONG} (last year: {CURRENCY_LONG}) +STR_VEHICLE_LIST_CARGO :{TINY_FONT}{BLACK}[{CARGO_LIST}] +STR_VEHICLE_LIST_NAME_AND_CARGO :{TINY_FONT}{BLACK}{STRING1} {STRING1} STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Send to Depot STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Send to Depot diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index ac214fe6ea..dda359ca06 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1676,6 +1676,7 @@ static SettingsContainer &GetSettingsTree() interface->Add(new SettingEntry("gui.timetable_in_ticks")); interface->Add(new SettingEntry("gui.timetable_arrival_departure")); interface->Add(new SettingEntry("gui.show_newgrf_name")); + interface->Add(new SettingEntry("gui.show_cargo_in_vehicle_lists")); } SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS)); diff --git a/src/settings_type.h b/src/settings_type.h index 2033e746ab..a83384cdb3 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -170,6 +170,7 @@ struct GUISettings { uint8 osk_activation; ///< Mouse gesture to trigger the OSK. byte starting_colour; ///< default color scheme for the company to start a new game with bool show_newgrf_name; ///< Show the name of the NewGRF in the build vehicle window + bool show_cargo_in_vehicle_lists; ///< Show the cargoes the vehicles can carry in the list windows bool auto_remove_signals; ///< automatically remove signals when in the way during rail construction uint16 refresh_rate; ///< How often we refresh the screen (time between draw-ticks). uint16 fast_forward_speed_limit; ///< Game speed to use when fast-forward is enabled. diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 7e4f85ec67..a521408be7 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -728,6 +728,15 @@ strhelp = STR_CONFIG_SETTING_SHOW_NEWGRF_NAME_HELPTEXT post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_ADVANCED +[SDTC_BOOL] +var = gui.show_cargo_in_vehicle_lists +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC +def = false +str = STR_CONFIG_SETTING_SHOW_CARGO_IN_LISTS +strhelp = STR_CONFIG_SETTING_SHOW_CARGO_IN_LISTS_HELPTEXT +post_cb = [](auto) { MarkWholeScreenDirty(); } +cat = SC_ADVANCED + ; For the dedicated build we'll enable dates in logs by default. [SDTC_BOOL] ifdef = DEDICATED diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 3f3a761747..467f6731d2 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1669,7 +1669,36 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int DrawVehicleImage(v, {image_left, ir.top, image_right, ir.bottom}, selected_vehicle, EIT_IN_LIST, 0); - if (!v->name.empty()) { + if (_settings_client.gui.show_cargo_in_vehicle_lists) { + /* Get the cargoes the vehicle can carry */ + CargoTypes vehicle_cargoes = 0; + + for (auto u = v; u != nullptr; u = u->Next()) { + if (u->cargo_cap == 0) continue; + + SetBit(vehicle_cargoes, u->cargo_type); + } + + if (!v->name.empty()) { + /* The vehicle got a name so we will print it and the cargoes */ + SetDParam(0, STR_TINY_BLACK_VEHICLE); + SetDParam(1, v->index); + SetDParam(2, STR_VEHICLE_LIST_CARGO); + SetDParam(3, vehicle_cargoes); + DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_NAME_AND_CARGO); + } else if (v->group_id != DEFAULT_GROUP) { + /* The vehicle has no name, but is member of a group, so print group name and the cargoes */ + SetDParam(0, STR_TINY_GROUP); + SetDParam(1, v->group_id); + SetDParam(2, STR_VEHICLE_LIST_CARGO); + SetDParam(3, vehicle_cargoes); + DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_NAME_AND_CARGO); + } else { + /* The vehicle has no name, and is not a member of a group, so just print the cargoes */ + SetDParam(0, vehicle_cargoes); + DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_CARGO); + } + } else if (!v->name.empty()) { /* The vehicle got a name so we will print it */ SetDParam(0, v->index); DrawString(tr.left, tr.right, ir.top, STR_TINY_BLACK_VEHICLE);