Merge branch 'master' into jgrpp
Replace build and refit, and group collapse implementations Fix template creation build and refit # Conflicts: # Makefile.bundle.in # config.lib # src/animated_tile.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.hpp # src/blitter/null.hpp # src/build_vehicle_gui.cpp # src/command.cpp # src/command_func.h # src/console_gui.cpp # src/core/smallstack_type.hpp # src/date.cpp # src/debug.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.h # src/main_gui.cpp # src/misc_gui.cpp # src/network/core/game.h # src/network/core/packet.cpp # src/network/core/udp.cpp # src/network/core/udp.h # src/network/network_content.cpp # src/network/network_type.h # src/network/network_udp.cpp # src/newgrf_house.h # src/openttd.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/osk_gui.cpp # src/pathfinder/opf/opf_ship.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.h # src/station_base.h # src/station_cmd.cpp # src/table/gameopt_settings.ini # src/table/newgrf_debug_data.h # src/table/settings.ini # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_gui.h
This commit is contained in:
@@ -177,13 +177,19 @@ struct CargoSummaryItem {
|
||||
{
|
||||
return this->cargo != other.cargo || this->subtype != other.subtype;
|
||||
}
|
||||
|
||||
/** Used by std::find() and similar functions */
|
||||
inline bool operator == (const CargoSummaryItem &other) const
|
||||
{
|
||||
return !(this->cargo != other.cargo);
|
||||
}
|
||||
};
|
||||
|
||||
static const uint TRAIN_DETAILS_MIN_INDENT = 32; ///< Minimum indent level in the train details window
|
||||
static const uint TRAIN_DETAILS_MAX_INDENT = 72; ///< Maximum indent level in the train details window; wider than this and we start on a new line
|
||||
|
||||
/** Container for the cargo summary information. */
|
||||
typedef SmallVector<CargoSummaryItem, 2> CargoSummary;
|
||||
typedef std::vector<CargoSummaryItem> CargoSummary;
|
||||
/** Reused container of cargo details */
|
||||
static CargoSummary _cargo_summary;
|
||||
|
||||
@@ -319,7 +325,7 @@ static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int
|
||||
*/
|
||||
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
|
||||
{
|
||||
summary->Clear();
|
||||
summary->clear();
|
||||
do {
|
||||
if (!v->GetEngine()->CanCarryCargo()) continue;
|
||||
|
||||
@@ -328,9 +334,10 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su
|
||||
new_item.subtype = GetCargoSubtypeText(v);
|
||||
if (new_item.cargo == INVALID_CARGO && new_item.subtype == STR_EMPTY) continue;
|
||||
|
||||
CargoSummaryItem *item = summary->Find(new_item);
|
||||
if (item == summary->End()) {
|
||||
item = summary->Append();
|
||||
auto item = std::find(summary->begin(), summary->end(), new_item);
|
||||
if (item == summary->end()) {
|
||||
summary->emplace_back();
|
||||
item = summary->end() - 1;
|
||||
item->cargo = new_item.cargo;
|
||||
item->subtype = new_item.subtype;
|
||||
item->capacity = 0;
|
||||
@@ -388,7 +395,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
|
||||
} else {
|
||||
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
|
||||
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
|
||||
num += max(1u, _cargo_summary.Length());
|
||||
num += max(1u, (unsigned)_cargo_summary.size());
|
||||
|
||||
uint length = GetLengthOfArticulatedVehicle(v);
|
||||
if (length > TRAIN_DETAILS_MAX_INDENT) num++;
|
||||
@@ -458,7 +465,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
|
||||
dx = 0;
|
||||
}
|
||||
|
||||
uint num_lines = max(1u, _cargo_summary.Length());
|
||||
uint num_lines = max(1u, (unsigned)_cargo_summary.size());
|
||||
for (uint i = 0; i < num_lines;) {
|
||||
int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
|
||||
int data_left = left + (rtl ? 0 : sprite_width);
|
||||
@@ -470,7 +477,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
|
||||
}
|
||||
switch (det_tab) {
|
||||
case TDW_TAB_CARGO:
|
||||
if (i < _cargo_summary.Length()) {
|
||||
if (i < _cargo_summary.size()) {
|
||||
TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
|
||||
} else {
|
||||
DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
|
||||
@@ -482,7 +489,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
|
||||
break;
|
||||
|
||||
case TDW_TAB_CAPACITY:
|
||||
if (i < _cargo_summary.Length()) {
|
||||
if (i < _cargo_summary.size()) {
|
||||
TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
|
||||
} else {
|
||||
SetDParam(0, STR_EMPTY);
|
||||
@@ -495,7 +502,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
|
||||
}
|
||||
if (det_tab != 1 || line_number >= (Train::From(v)->IsWagon() ? 0 : 2)) {
|
||||
line_number = 0;
|
||||
i++;
|
||||
i++;
|
||||
} else {
|
||||
line_number++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user