Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+25
-33
@@ -8,6 +8,7 @@
|
||||
/** @file roadveh_gui.cpp GUI for road vehicles. */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/backup_type.hpp"
|
||||
#include "roadveh.h"
|
||||
#include "window_gui.h"
|
||||
#include "strings_func.h"
|
||||
@@ -36,14 +37,11 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
SetDParam(2, v->value);
|
||||
if (_settings_client.gui.newgrf_developer_tools) SetDParam(3, v->index); // CM
|
||||
DrawString(r.left, r.right, y, _settings_client.gui.newgrf_developer_tools ? CM_STR_VEHICLE_INFO_BUILT_VALUE_WITH_ID : STR_VEHICLE_INFO_BUILT_VALUE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
|
||||
if (v->HasArticulatedPart()) {
|
||||
CargoArray max_cargo;
|
||||
StringID subtype_text[NUM_CARGO];
|
||||
char capacity[512];
|
||||
|
||||
memset(subtype_text, 0, sizeof(subtype_text));
|
||||
CargoArray max_cargo{};
|
||||
std::array<StringID, NUM_CARGO> subtype_text{};
|
||||
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
max_cargo[u->cargo_type] += u->cargo_cap;
|
||||
@@ -53,23 +51,20 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
}
|
||||
}
|
||||
|
||||
GetString(capacity, STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY, lastof(capacity));
|
||||
std::string capacity = GetString(STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY);
|
||||
|
||||
bool first = true;
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (max_cargo[i] > 0) {
|
||||
char buffer[128];
|
||||
for (const CargoSpec *cs : _sorted_cargo_specs) {
|
||||
CargoID cid = cs->Index();
|
||||
if (max_cargo[cid] > 0) {
|
||||
if (!first) capacity += ", ";
|
||||
|
||||
SetDParam(0, i);
|
||||
SetDParam(1, max_cargo[i]);
|
||||
GetString(buffer, STR_JUST_CARGO, lastof(buffer));
|
||||
SetDParam(0, cid);
|
||||
SetDParam(1, max_cargo[cid]);
|
||||
capacity += GetString(STR_JUST_CARGO);
|
||||
|
||||
if (!first) strecat(capacity, ", ", lastof(capacity));
|
||||
strecat(capacity, buffer, lastof(capacity));
|
||||
|
||||
if (subtype_text[i] != 0) {
|
||||
GetString(buffer, subtype_text[i], lastof(buffer));
|
||||
strecat(capacity, buffer, lastof(capacity));
|
||||
if (subtype_text[cid] != STR_NULL) {
|
||||
capacity += GetString(subtype_text[cid]);
|
||||
}
|
||||
|
||||
first = false;
|
||||
@@ -77,7 +72,7 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
}
|
||||
|
||||
DrawString(r.left, r.right, y, capacity, TC_BLUE);
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
||||
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
|
||||
|
||||
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->cargo_cap == 0) continue;
|
||||
@@ -86,12 +81,12 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
if (u->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, u->cargo_type);
|
||||
SetDParam(1, u->cargo.StoredCount());
|
||||
SetDParam(2, u->cargo.Source());
|
||||
SetDParam(2, u->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += u->cargo.FeederShare();
|
||||
feeder_share += u->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
y += GetCharacterHeight(FS_NORMAL);
|
||||
}
|
||||
y += WidgetDimensions::scaled.vsep_normal;
|
||||
} else {
|
||||
@@ -99,18 +94,18 @@ void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
|
||||
SetDParam(1, v->cargo_cap);
|
||||
SetDParam(4, GetCargoSubtypeText(v));
|
||||
DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
||||
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
|
||||
|
||||
str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
|
||||
if (v->cargo.StoredCount() > 0) {
|
||||
SetDParam(0, v->cargo_type);
|
||||
SetDParam(1, v->cargo.StoredCount());
|
||||
SetDParam(2, v->cargo.Source());
|
||||
SetDParam(2, v->cargo.GetFirstStation());
|
||||
str = STR_VEHICLE_DETAILS_CARGO_FROM;
|
||||
feeder_share += v->cargo.FeederShare();
|
||||
feeder_share += v->cargo.GetFeederShare();
|
||||
}
|
||||
DrawString(r.left, r.right, y, str);
|
||||
y += FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal;
|
||||
y += GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
|
||||
}
|
||||
|
||||
/* Draw Transfer credits text */
|
||||
@@ -131,13 +126,12 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
|
||||
Direction dir = rtl ? DIR_E : DIR_W;
|
||||
const RoadVehicle *u = RoadVehicle::From(v);
|
||||
|
||||
DrawPixelInfo tmp_dpi, *old_dpi;
|
||||
DrawPixelInfo tmp_dpi;
|
||||
int max_width = r.Width();
|
||||
|
||||
if (!FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) return;
|
||||
if (!FillDrawPixelInfo(&tmp_dpi, r)) return;
|
||||
|
||||
old_dpi = _cur_dpi;
|
||||
_cur_dpi = &tmp_dpi;
|
||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||
|
||||
int px = rtl ? max_width + skip : -skip;
|
||||
int y = r.Height() / 2;
|
||||
@@ -156,8 +150,6 @@ void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, Engi
|
||||
px += rtl ? -width : width;
|
||||
}
|
||||
|
||||
_cur_dpi = old_dpi;
|
||||
|
||||
if (v->index == selection) {
|
||||
int height = ScaleSpriteTrad(12);
|
||||
Rect hr = {(rtl ? px : 0), 0, (rtl ? max_width : px) - 1, height - 1};
|
||||
|
||||
Reference in New Issue
Block a user