Show buy cost and running cost in template windows

See: #312
pull/306/head
Jonathan G Rennison 3 years ago
parent d67f63a04e
commit 5afa1b93eb

@ -6668,6 +6668,9 @@ STR_TMPL_TEMPLATE_INFO :{BLACK}Template
STR_TMPL_RPL_START :{BLACK}Start replacing
STR_TMPL_RPL_STOP :{BLACK}Stop replacing
STR_TMPL_TEMPLATE_OVR_VALUE :{BLACK}Buying Cost: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_LTBLUE :{BLACK}Buying Cost: {LTBLUE}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_RUNNING_COST :{BLACK}Estimated Running Cost: {LTBLUE}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_MULTIPLE :{BLACK}{STRING1}{BLACK} {STRING1}
STR_TMPL_WARNING_FREE_WAGON :{RED}Free Chain: not runnable!
STR_TMPL_WARNING_VEH_UNAVAILABLE :{RED}Train not buildable: vehicle unavailable!
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}Template in use: {NUM}

@ -6438,6 +6438,7 @@ STR_TMPL_TEMPLATE_INFO :{BLACK}Vorlagen
STR_TMPL_RPL_START :{BLACK}Fahrzeugersetzung an
STR_TMPL_RPL_STOP :{BLACK}Fahrzeugersetzung aus
STR_TMPL_TEMPLATE_OVR_VALUE :{BLACK}Anschaffungskosten: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_LTBLUE :{BLACK}Anschaffungskosten: {LTBLUE}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}Unvollständiger Antriebsstrang: Zug kann nicht bewegt werden!
STR_TMPL_WARNING_VEH_UNAVAILABLE :{RED}Zug nicht erstellbar: Fahrzeug nicht verfügbar!
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}Vorlage in Benutzung: {NUM}

@ -6665,6 +6665,7 @@ STR_TMPL_TEMPLATE_INFO :{BLACK}템플
STR_TMPL_RPL_START :{BLACK}교체 시작
STR_TMPL_RPL_STOP :{BLACK}교체 중지
STR_TMPL_TEMPLATE_OVR_VALUE :{BLACK}구입 가격: {GOLD}{CURRENCY_LONG}
STR_TMPL_TEMPLATE_OVR_VALUE_LTBLUE :{BLACK}구입 가격: {LTBLUE}{CURRENCY_LONG}
STR_TMPL_WARNING_FREE_WAGON :{RED}객차/화차만 있음: 운행할 수 없습니다!
STR_TMPL_WARNING_VEH_UNAVAILABLE :{RED}열차 구성 불가: 차량을 사용할 수 없습니다!
STR_TMPL_GROUP_USES_TEMPLATE :{BLACK}{NUM}번 템플릿 사용 중

@ -307,13 +307,23 @@ public:
int y = 4 - this->vscroll->GetPosition();
bool buildable = true;
Money buy_cost = 0;
for (Train *train = this->virtual_train; train != nullptr; train = train->GetNextUnit()) {
if (!IsEngineBuildable(train->engine_type, VEH_TRAIN, train->owner)) buildable = false;
buy_cost += Engine::Get(train->engine_type)->GetCost();
}
if (!buildable) {
DrawString(8, r.right, y, STR_TMPL_WARNING_VEH_UNAVAILABLE);
y += FONT_HEIGHT_NORMAL;
}
SetDParam(0, STR_TMPL_TEMPLATE_OVR_VALUE_LTBLUE);
SetDParam(1, buy_cost);
SetDParam(2, STR_TMPL_TEMPLATE_OVR_RUNNING_COST);
SetDParam(3, this->virtual_train->GetDisplayRunningCost());
DrawString(8, r.right, y, STR_TMPL_TEMPLATE_OVR_MULTIPLE);
y += FONT_HEIGHT_NORMAL;
/* Draw vehicle performance info */
const bool original_acceleration = (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
GetRailTypeInfo(this->virtual_train->railtype)->acceleration_type == 2);

@ -742,6 +742,10 @@ public:
short top = ScaleGUITrad(4) - this->vscroll[2]->GetPosition();
short left = ScaleGUITrad(8);
SetDParam(0, CalculateOverallTemplateDisplayRunningCost(tmp));
DrawString(left, r.right, top, STR_TMPL_TEMPLATE_OVR_RUNNING_COST);
top += FONT_HEIGHT_NORMAL;
/* Draw vehicle performance info */
const bool original_acceleration = (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL ||
GetRailTypeInfo(tmp->railtype)->acceleration_type == 2);

@ -110,6 +110,16 @@ Money CalculateOverallTemplateCost(const TemplateVehicle *tv)
return val;
}
Money CalculateOverallTemplateDisplayRunningCost(const TemplateVehicle *tv)
{
Money val = 0;
for (; tv; tv = tv->GetNextUnit()) {
val += (Engine::Get(tv->engine_type))->GetDisplayRunningCost();
}
return val;
}
void DrawTemplate(const TemplateVehicle *tv, int left, int right, int y)
{
if (!tv) return;

@ -20,6 +20,7 @@ Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err,
void BuildTemplateGuiList(GUITemplateList*, Scrollbar*, Owner, RailType);
Money CalculateOverallTemplateCost(const TemplateVehicle*);
Money CalculateOverallTemplateDisplayRunningCost(const TemplateVehicle*);
void DrawTemplate(const TemplateVehicle*, int, int, int);

Loading…
Cancel
Save