TBTR: Show warning on templates which include unavailable vehicles

This commit is contained in:
Jonathan G Rennison
2019-04-27 22:47:31 +01:00
parent 9d861fb8a0
commit 6d3e9093c4
5 changed files with 27 additions and 5 deletions

View File

@@ -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_notinyfont :{BLACK}Buying Cost: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :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_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_TMPL_GROUP_USES_TEMPLATE :{BLACK}Template in use: {NUM}
STR_TMP_TEMPLATE_IN_USE :Template is in use STR_TMP_TEMPLATE_IN_USE :Template is in use
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM} STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

View File

@@ -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_notinyfont :{BLACK}Anschaffungskosten: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :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_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_TMPL_GROUP_USES_TEMPLATE :{BLACK}Vorlage in Benutzung: {NUM}
STR_TMP_TEMPLATE_IN_USE :Vorlage ist in Benutzung STR_TMP_TEMPLATE_IN_USE :Vorlage ist in Benutzung
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM} STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

View File

@@ -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_notinyfont :{BLACK}구입 가격: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :구입 가격: {GOLD}{CURRENCY_LONG} STR_TMPL_TEMPLATE_OVR_VALUE_notinyfontandblack :구입 가격: {GOLD}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}Free Chain: 운행할 수 없습니다! STR_TMPL_WARNING_FREE_WAGON :{RED}Free Chain: 운행할 수 없습니다!
STR_TMPL_TEST :{ORANGE}시험 문자열: {STRING} {STRING}
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}사용 중인 템플릿: {NUM} STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}사용 중인 템플릿: {NUM}
STR_TMP_TEMPLATE_IN_USE :템플릿이 사용 중입니다. STR_TMP_TEMPLATE_IN_USE :템플릿이 사용 중입니다.
STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM} STR_TMPL_GROUP_NUM_TRAINS :{BLACK}{NUM}

View File

@@ -307,19 +307,28 @@ public:
old_dpi = _cur_dpi; old_dpi = _cur_dpi;
_cur_dpi = &tmp_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 */ /* Draw vehicle performance info */
const GroundVehicleCache *gcache = this->virtual_train->GetGroundVehicleCache(); const GroundVehicleCache *gcache = this->virtual_train->GetGroundVehicleCache();
SetDParam(2, this->virtual_train->GetDisplayMaxSpeed()); SetDParam(2, this->virtual_train->GetDisplayMaxSpeed());
SetDParam(1, gcache->cached_power); SetDParam(1, gcache->cached_power);
SetDParam(0, gcache->cached_weight); SetDParam(0, gcache->cached_weight);
SetDParam(3, gcache->cached_max_te / 1000); 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 */ /* Draw cargo summary */
CargoArray cargo_caps; CargoArray cargo_caps;
for (const Train *tmp = this->virtual_train; tmp != nullptr; tmp = tmp->Next()) { for (const Train *tmp = this->virtual_train; tmp != nullptr; tmp = tmp->Next()) {
cargo_caps[tmp->cargo_type] += tmp->cargo_cap; cargo_caps[tmp->cargo_type] += tmp->cargo_cap;
} }
int y = 30 - this->vscroll->GetPosition(); y += 26;
for (CargoID i = 0; i < NUM_CARGO; ++i) { for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) { if (cargo_caps[i] > 0) {
SetDParam(0, i); SetDParam(0, i);
@@ -444,10 +453,13 @@ public:
CargoArray cargo_caps; CargoArray cargo_caps;
if (virtual_train != nullptr) { if (virtual_train != nullptr) {
bool buildable = true;
for (Train *train = virtual_train; train != nullptr; train = train->Next()) { for (Train *train = virtual_train; train != nullptr; train = train->Next()) {
width += train->GetDisplayImageWidth(); width += train->GetDisplayImageWidth();
cargo_caps[train->cargo_type] += train->cargo_cap; 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) { for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (cargo_caps[i] > 0) { if (cargo_caps[i] > 0) {

View File

@@ -660,6 +660,18 @@ public:
DrawString(left, right - ScaleGUITrad(24), y + ScaleGUITrad(2), STR_TMPL_WARNING_FREE_WAGON, TC_RED, SA_RIGHT); 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 */ /* Draw the template's length in tile-units */
SetDParam(0, v->GetRealLength()); SetDParam(0, v->GetRealLength());
SetDParam(1, 1); SetDParam(1, 1);