summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-03-06 12:59:28 +0000
committerterkhen <terkhen@openttd.org>2010-03-06 12:59:28 +0000
commitbe3b839ded1372ad6a3802118bb70fead2ccd4ce (patch)
treea3cd77841a20bf21b1dbcd7768b66467647a8046
parentb443a3ee0a39f28be1fde279e67c82ee51814f4d (diff)
downloadopenttd-be3b839ded1372ad6a3802118bb70fead2ccd4ce.tar.xz
(svn r19347) -Add: Vehicle GUI now shows power, weight and tractive effort for road vehicles.
-rw-r--r--src/build_vehicle_gui.cpp36
-rw-r--r--src/engine.cpp12
-rw-r--r--src/engine_gui.cpp37
-rw-r--r--src/settings.cpp5
-rw-r--r--src/vehicle_gui.cpp9
5 files changed, 82 insertions, 17 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index b521935f7..1ac9936e9 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -508,11 +508,37 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
{
const Engine *e = Engine::Get(engine_number);
- /* 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;
+ 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());
diff --git a/src/engine.cpp b/src/engine.cpp
index 8e6c41ba0..0cccfcaac 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -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();
}
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index d8dc95695..7247450d6 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -188,17 +188,36 @@ static StringID GetAircraftEngineInfoString(const Engine *e)
static StringID GetRoadVehEngineInfoString(const Engine *e)
{
- SetDParam(0, e->GetCost());
- SetDParam(1, e->GetDisplayMaxSpeed());
- uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
- if (capacity != 0) {
- SetDParam(2, e->GetDefaultCargoType());
- SetDParam(3, capacity);
+ if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, e->GetDisplayMaxSpeed());
+ uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
+ if (capacity != 0) {
+ SetDParam(2, e->GetDefaultCargoType());
+ SetDParam(3, capacity);
+ } else {
+ SetDParam(2, CT_INVALID);
+ }
+ SetDParam(4, e->GetRunningCost());
+ return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
} else {
- SetDParam(2, CT_INVALID);
+ 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;
}
- SetDParam(4, e->GetRunningCost());
- return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
}
static StringID GetShipEngineInfoString(const Engine *e)
diff --git a/src/settings.cpp b/src/settings.cpp
index e4379f2b2..2aa30d750 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -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;
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index b20ad3507..5b6f91379 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -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());