1
0
Fork 0

Add: Set a darker background in depot window for trains that cannot leave a depot.

pull/8480/head
J0anJosep 2021-03-30 12:11:10 +02:00
parent 328f0ab20e
commit a64aa22b67
2 changed files with 16 additions and 0 deletions

View File

@ -200,6 +200,7 @@ void Depot::AfterAddRemove(TileArea ta, bool adding)
this->RescanDepotTiles(); this->RescanDepotTiles();
assert(!this->depot_tiles.empty()); assert(!this->depot_tiles.empty());
this->xy = this->depot_tiles[0]; this->xy = this->depot_tiles[0];
InvalidateWindowData(WC_VEHICLE_DEPOT, this->index);
} else { } else {
assert(this->IsInUse()); assert(this->IsInUse());
this->Disuse(); this->Disuse();

View File

@ -34,6 +34,7 @@
#include "vehicle_cmd.h" #include "vehicle_cmd.h"
#include "core/geometry_func.hpp" #include "core/geometry_func.hpp"
#include "depot_func.h" #include "depot_func.h"
#include "train_placement.h"
#include "widgets/depot_widget.h" #include "widgets/depot_widget.h"
@ -262,6 +263,7 @@ struct DepotWindow : Window {
VehicleType type; VehicleType type;
bool generate_list; bool generate_list;
WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress. WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
std::vector<bool> problematic_vehicles; ///< Vector associated to vehicle_list, with a value of true for vehicles that cannot leave the depot.
VehicleList vehicle_list; VehicleList vehicle_list;
VehicleList wagon_list; VehicleList wagon_list;
uint unitnumber_digits; uint unitnumber_digits;
@ -411,6 +413,11 @@ struct DepotWindow : Window {
for (; num < maxval; ir = ir.Translate(0, this->resize.step_height)) { // Draw the rows for (; num < maxval; ir = ir.Translate(0, this->resize.step_height)) { // Draw the rows
Rect cell = ir; /* Keep track of horizontal cells */ Rect cell = ir; /* Keep track of horizontal cells */
for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) { for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) {
/* Draw a dark red background if train cannot be placed. */
if (this->type == VEH_TRAIN && this->problematic_vehicles[num] == 1) {
GfxFillRect(cell.left, cell.top, cell.right, cell.bottom, PC_DARK_GREY);
}
/* Draw all vehicles in the current row */ /* Draw all vehicles in the current row */
const Vehicle *v = this->vehicle_list[num]; const Vehicle *v = this->vehicle_list[num];
this->DrawVehicleInDepot(v, cell); this->DrawVehicleInDepot(v, cell);
@ -723,6 +730,14 @@ struct DepotWindow : Window {
BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list); BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
this->generate_list = false; this->generate_list = false;
DepotSortList(&this->vehicle_list); DepotSortList(&this->vehicle_list);
if (this->type == VEH_TRAIN) {
this->problematic_vehicles.clear();
TrainPlacement tp;
for (uint num = 0; num < this->vehicle_list.size(); ++num) {
const Vehicle *v = this->vehicle_list[num];
this->problematic_vehicles.push_back(!tp.CanFindAppropriatePlatform(Train::From(v), false));
}
}
uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list); uint new_unitnumber_digits = GetUnitNumberDigits(this->vehicle_list);
/* Only increase the size; do not decrease to prevent constant changes */ /* Only increase the size; do not decrease to prevent constant changes */