Add "Freight" type to vehicle list cargo type filter
This commit is contained in:
@@ -3995,6 +3995,8 @@ STR_PURCHASE_INFO_MAX_TE :{BLACK}Max. Tra
|
|||||||
STR_PURCHASE_INFO_AIRCRAFT_RANGE :{BLACK}Range: {GOLD}{COMMA} tiles
|
STR_PURCHASE_INFO_AIRCRAFT_RANGE :{BLACK}Range: {GOLD}{COMMA} tiles
|
||||||
STR_PURCHASE_INFO_AIRCRAFT_TYPE :{BLACK}Aircraft type: {GOLD}{STRING}
|
STR_PURCHASE_INFO_AIRCRAFT_TYPE :{BLACK}Aircraft type: {GOLD}{STRING}
|
||||||
|
|
||||||
|
STR_CARGO_TYPE_FREIGHT :Freight
|
||||||
|
|
||||||
STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP :{BLACK}Train vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type
|
STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP :{BLACK}Train vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type
|
||||||
STR_BUY_VEHICLE_ROAD_VEHICLE_LIST_TOOLTIP :{BLACK}Road vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type
|
STR_BUY_VEHICLE_ROAD_VEHICLE_LIST_TOOLTIP :{BLACK}Road vehicle selection list. Click on vehicle for information. Ctrl+Click for toggling hiding of the vehicle type
|
||||||
STR_BUY_VEHICLE_SHIP_LIST_TOOLTIP :{BLACK}Ship selection list. Click on ship for information. Ctrl+Click for toggling hiding of the ship type
|
STR_BUY_VEHICLE_SHIP_LIST_TOOLTIP :{BLACK}Ship selection list. Click on ship for information. Ctrl+Click for toggling hiding of the ship type
|
||||||
|
@@ -162,6 +162,18 @@ static bool CDECL CargoFilter(const Vehicle * const *vid, const CargoID cid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (cid == BaseVehicleListWindow::CF_FREIGHT) {
|
||||||
|
bool have_capacity = false;
|
||||||
|
for (const Vehicle *w = (*vid); w != NULL; w = w->Next()) {
|
||||||
|
if (w->cargo_cap) {
|
||||||
|
if (IsCargoInClass(w->cargo_type, CC_PASSENGERS)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
have_capacity = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return have_capacity;
|
||||||
} else {
|
} else {
|
||||||
for (const Vehicle *w = (*vid); w != NULL; w = w->Next()) {
|
for (const Vehicle *w = (*vid); w != NULL; w = w->Next()) {
|
||||||
if (w->cargo_cap > 0 && w->cargo_type == cid) {
|
if (w->cargo_cap > 0 && w->cargo_type == cid) {
|
||||||
@@ -199,6 +211,11 @@ void BaseVehicleListWindow::SetCargoFilterArray()
|
|||||||
this->cargo_filter_criteria = filter_items;
|
this->cargo_filter_criteria = filter_items;
|
||||||
filter_items++;
|
filter_items++;
|
||||||
|
|
||||||
|
/* Add item for freight (i.e. vehicles with cargo capacity and with no passenger capacity) */
|
||||||
|
this->cargo_filter[filter_items] = CF_FREIGHT;
|
||||||
|
this->cargo_filter_texts[filter_items] = STR_CARGO_TYPE_FREIGHT;
|
||||||
|
filter_items++;
|
||||||
|
|
||||||
/* Add item for vehicles not carrying anything, e.g. train engines.
|
/* Add item for vehicles not carrying anything, e.g. train engines.
|
||||||
* This could also be useful for eyecandy vehicles of other types, but is likely too confusing for joe, */
|
* This could also be useful for eyecandy vehicles of other types, but is likely too confusing for joe, */
|
||||||
this->cargo_filter[filter_items] = CF_NONE;
|
this->cargo_filter[filter_items] = CF_NONE;
|
||||||
|
@@ -32,10 +32,11 @@ struct BaseVehicleListWindow : public Window {
|
|||||||
enum CargoFilterSpecialType {
|
enum CargoFilterSpecialType {
|
||||||
CF_ANY = CT_NO_REFIT, ///< Show all vehicles independent of carried cargo (i.e. no filtering)
|
CF_ANY = CT_NO_REFIT, ///< Show all vehicles independent of carried cargo (i.e. no filtering)
|
||||||
CF_NONE = CT_INVALID, ///< Show only vehicles which do not carry cargo (e.g. train engines)
|
CF_NONE = CT_INVALID, ///< Show only vehicles which do not carry cargo (e.g. train engines)
|
||||||
|
CF_FREIGHT = CT_AUTO_REFIT, ///< Show only vehicles which carry any freight (non-passenger) cargo
|
||||||
};
|
};
|
||||||
|
|
||||||
CargoID cargo_filter[NUM_CARGO + 2]; ///< Available cargo filters; CargoID or CF_ANY or CF_NONE
|
CargoID cargo_filter[NUM_CARGO + 3]; ///< Available cargo filters; CargoID or CF_ANY or CF_NONE
|
||||||
StringID cargo_filter_texts[NUM_CARGO + 3]; ///< Texts for filter_cargo, terminated by INVALID_STRING_ID
|
StringID cargo_filter_texts[NUM_CARGO + 4]; ///< Texts for filter_cargo, terminated by INVALID_STRING_ID
|
||||||
byte cargo_filter_criteria; ///< Selected cargo filter
|
byte cargo_filter_criteria; ///< Selected cargo filter
|
||||||
|
|
||||||
enum ActionDropdownItem {
|
enum ActionDropdownItem {
|
||||||
|
Reference in New Issue
Block a user