Feature: Show the cargoes the vehicles can carry in the vehicle list window (#8304)

This commit is contained in:
stormcone 2022-11-24 21:58:10 +01:00 committed by GitHub
parent d780ca74ed
commit e29547a3a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 1 deletions

View File

@ -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

View File

@ -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));

View File

@ -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.

View File

@ -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

View File

@ -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);