TBTR: Show warning on templates which include unavailable vehicles

pull/88/head
Jonathan G Rennison 5 years ago
parent 9d861fb8a0
commit 6d3e9093c4

@ -6059,7 +6059,7 @@ STR_TMPL_TEMPLATE_OVR_VALUE_nogoldandcurrency :{TINY_FONT}{BLA
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfont :{BLACK}Buying Cost: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :Buying Cost: {GOLD}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}Free Chain: not runnable!
STR_TMPL_TEST :{ORANGE}Test String: {RAW_STRING} {RAW_STRING}
STR_TMPL_WARNING_VEH_UNAVAILABLE :{RED}Train not buildable: vehicle unavailable!
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}Template in use: {NUM}
STR_TMP_TEMPLATE_IN_USE :Template is in use
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

@ -5848,7 +5848,6 @@ STR_TMPL_TEMPLATE_OVR_VALUE_nogoldandcurrency :{TINY_FONT}{BLA
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfont :{BLACK}Anschaffungskosten: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :Anschaffungskosten: {GOLD}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}Unvollständiger Antriebsstrang: Zug kann nicht bewegt werden!
STR_TMPL_TEST :{ORANGE}Test String: {STRING} {STRING}
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}Vorlage in Benutzung: {NUM}
STR_TMP_TEMPLATE_IN_USE :Vorlage ist in Benutzung
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

@ -6038,7 +6038,6 @@ STR_TMPL_TEMPLATE_OVR_VALUE_nogoldandcurrency :{TINY_FONT}{BLA
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfont :{BLACK}구입 가격: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :구입 가격: {GOLD}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}Free Chain: 운행할 수 없습니다!
STR_TMPL_TEST :{ORANGE}시험 문자열: {STRING} {STRING}
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}사용 중인 템플릿: {NUM}
STR_TMP_TEMPLATE_IN_USE :템플릿이 사용 중입니다.
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

@ -307,19 +307,28 @@ public:
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
int y = 4 - this->vscroll->GetPosition();
bool buildable = true;
for (Train *train = this->virtual_train; train != nullptr; train = train->Next()) {
if (!IsEngineBuildable(train->engine_type, VEH_TRAIN, train->owner)) buildable = false;
}
if (!buildable) {
DrawString(8, r.right, y, STR_TMPL_WARNING_VEH_UNAVAILABLE);
y += FONT_HEIGHT_NORMAL;
}
/* Draw vehicle performance info */
const GroundVehicleCache *gcache = this->virtual_train->GetGroundVehicleCache();
SetDParam(2, this->virtual_train->GetDisplayMaxSpeed());
SetDParam(1, gcache->cached_power);
SetDParam(0, gcache->cached_weight);
SetDParam(3, gcache->cached_max_te / 1000);
DrawString(8, r.right, 4 - this->vscroll->GetPosition(), STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
DrawString(8, r.right, y, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
/* Draw cargo summary */
CargoArray cargo_caps;
for (const Train *tmp = this->virtual_train; tmp != nullptr; tmp = tmp->Next()) {
cargo_caps[tmp->cargo_type] += tmp->cargo_cap;
}
int y = 30 - this->vscroll->GetPosition();
y += 26;
for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) {
SetDParam(0, i);
@ -444,10 +453,13 @@ public:
CargoArray cargo_caps;
if (virtual_train != nullptr) {
bool buildable = true;
for (Train *train = virtual_train; train != nullptr; train = train->Next()) {
width += train->GetDisplayImageWidth();
cargo_caps[train->cargo_type] += train->cargo_cap;
if (!IsEngineBuildable(train->engine_type, VEH_TRAIN, train->owner)) buildable = false;
}
if (!buildable) height += FONT_HEIGHT_NORMAL;
for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) {

@ -660,6 +660,18 @@ public:
DrawString(left, right - ScaleGUITrad(24), y + ScaleGUITrad(2), STR_TMPL_WARNING_FREE_WAGON, TC_RED, SA_RIGHT);
}
bool buildable = true;
for (const TemplateVehicle *u = v; u != nullptr; u = u->Next()) {
if (!IsEngineBuildable(u->engine_type, VEH_TRAIN, u->owner)) {
buildable = false;
break;
}
}
/* Draw a notification string for chains that are not buildable */
if (!buildable) {
DrawString(left, right - ScaleGUITrad(24), y + ScaleGUITrad(2), STR_TMPL_WARNING_VEH_UNAVAILABLE, TC_RED, SA_CENTER);
}
/* Draw the template's length in tile-units */
SetDParam(0, v->GetRealLength());
SetDParam(1, 1);

Loading…
Cancel
Save