# HG changeset patch # User stormcone <48624099+stormcone@users.noreply.github.com> # Date 2022-11-24 20:58:10 # Node ID 3097b7dcf95368c7f3ed0b619bbafb995e151d0c # Parent 49657bfd5704239952475b8c361d034d3956d9e9 Feature: Show the cargoes the vehicles can carry in the vehicle list window (#8304) diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1432,6 +1432,8 @@ STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_ 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 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 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1676,6 +1676,7 @@ static SettingsContainer &GetSettingsTre 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 --- 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 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -728,6 +728,15 @@ strhelp = STR_CONFIG_SETTING_SHOW_NEWGR 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 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1669,7 +1669,36 @@ void BaseVehicleListWindow::DrawVehicleL 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);