mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r19347) -Add: Vehicle GUI now shows power, weight and tractive effort for road vehicles.
This commit is contained in:
parent
b443a3ee0a
commit
be3b839ded
@ -508,11 +508,37 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
|
||||
{
|
||||
const Engine *e = Engine::Get(engine_number);
|
||||
|
||||
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
|
||||
/* Purchase Cost */
|
||||
SetDParam(0, e->GetCost());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
/* Road vehicle weight - (including cargo) */
|
||||
int16 weight = e->GetDisplayWeight();
|
||||
SetDParam(0, weight);
|
||||
uint cargo_weight = CargoSpec::Get(e->GetDefaultCargoType())->weight * GetTotalCapacityOfArticulatedParts(engine_number) / 16;
|
||||
SetDParam(1, cargo_weight + weight);
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
/* Max speed - Engine power */
|
||||
SetDParam(0, e->GetDisplayMaxSpeed());
|
||||
SetDParam(1, e->GetPower());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
/* Max tractive effort */
|
||||
SetDParam(0, e->GetDisplayMaxTractiveEffort());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
} else {
|
||||
/* Purchase cost - Max speed */
|
||||
SetDParam(0, e->GetCost());
|
||||
SetDParam(1, e->GetDisplayMaxSpeed());
|
||||
DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
/* Running cost */
|
||||
SetDParam(0, e->GetRunningCost());
|
||||
|
@ -297,10 +297,12 @@ uint Engine::GetDisplayMaxSpeed() const
|
||||
|
||||
uint Engine::GetPower() const
|
||||
{
|
||||
/* Currently only trains have 'power' */
|
||||
/* Only trains and road vehicles have 'power'. */
|
||||
switch (this->type) {
|
||||
case VEH_TRAIN:
|
||||
return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power);
|
||||
case VEH_ROAD:
|
||||
return this->u.road.power * 10;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
@ -313,10 +315,12 @@ uint Engine::GetPower() const
|
||||
*/
|
||||
uint Engine::GetDisplayWeight() const
|
||||
{
|
||||
/* Currently only trains have 'weight' */
|
||||
/* Only trains and road vehicles have 'weight'. */
|
||||
switch (this->type) {
|
||||
case VEH_TRAIN:
|
||||
return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, this->u.rail.weight) << (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
|
||||
case VEH_ROAD:
|
||||
return this->u.road.weight / 4;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
@ -329,10 +333,12 @@ uint Engine::GetDisplayWeight() const
|
||||
*/
|
||||
uint Engine::GetDisplayMaxTractiveEffort() const
|
||||
{
|
||||
/* Currently only trains have 'tractive effort' */
|
||||
/* Only trains and road vehicles have 'tractive effort'. */
|
||||
switch (this->type) {
|
||||
case VEH_TRAIN:
|
||||
return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256;
|
||||
case VEH_ROAD:
|
||||
return (10 * this->GetDisplayWeight() * this->u.road.tractive_effort) / 256;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
@ -188,6 +188,7 @@ static StringID GetAircraftEngineInfoString(const Engine *e)
|
||||
|
||||
static StringID GetRoadVehEngineInfoString(const Engine *e)
|
||||
{
|
||||
if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) {
|
||||
SetDParam(0, e->GetCost());
|
||||
SetDParam(1, e->GetDisplayMaxSpeed());
|
||||
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
|
||||
@ -199,6 +200,24 @@ static StringID GetRoadVehEngineInfoString(const Engine *e)
|
||||
}
|
||||
SetDParam(4, e->GetRunningCost());
|
||||
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
|
||||
} else {
|
||||
SetDParam(0, e->GetCost());
|
||||
SetDParam(2, e->GetDisplayMaxSpeed());
|
||||
SetDParam(3, e->GetPower());
|
||||
SetDParam(1, e->GetDisplayWeight());
|
||||
SetDParam(7, e->GetDisplayMaxTractiveEffort());
|
||||
|
||||
SetDParam(4, e->GetRunningCost());
|
||||
|
||||
uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
|
||||
if (capacity != 0) {
|
||||
SetDParam(5, e->GetDefaultCargoType());
|
||||
SetDParam(6, capacity);
|
||||
} else {
|
||||
SetDParam(5, CT_INVALID);
|
||||
}
|
||||
return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
|
||||
}
|
||||
}
|
||||
|
||||
static StringID GetShipEngineInfoString(const Engine *e)
|
||||
|
@ -791,6 +791,11 @@ static bool RoadVehAccelerationModelChanged(int32 p1)
|
||||
}
|
||||
}
|
||||
|
||||
/* These windows show acceleration values only when realistic acceleration is on. They must be redrawn after a setting change. */
|
||||
SetWindowClassesDirty(WC_ENGINE_PREVIEW);
|
||||
SetWindowClassesDirty(WC_BUILD_VEHICLE);
|
||||
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1533,6 +1533,15 @@ struct VehicleDetailsWindow : Window {
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
|
||||
SetDParam(2, v->GetDisplayMaxSpeed());
|
||||
SetDParam(1, RoadVehicle::From(v)->acc_cache.cached_power);
|
||||
SetDParam(0, RoadVehicle::From(v)->acc_cache.cached_weight);
|
||||
SetDParam(3, RoadVehicle::From(v)->acc_cache.cached_max_te / 1000);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE);
|
||||
break;
|
||||
}
|
||||
/* Fallthrough */
|
||||
case VEH_SHIP:
|
||||
case VEH_AIRCRAFT:
|
||||
SetDParam(0, v->GetDisplayMaxSpeed());
|
||||
|
Loading…
Reference in New Issue
Block a user