Changeset - r14749:107a1d25efe3
[Not reviewed]
master
0 5 0
terkhen - 14 years ago 2010-03-06 12:59:28
terkhen@openttd.org
(svn r19347) -Add: Vehicle GUI now shows power, weight and tractive effort for road vehicles.
5 files changed with 82 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -508,11 +508,37 @@ static int DrawRoadVehPurchaseInfo(int l
 
{
 
	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());
src/engine.cpp
Show inline comments
 
@@ -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();
 
	}
src/engine_gui.cpp
Show inline comments
 
@@ -188,17 +188,36 @@ static StringID GetAircraftEngineInfoStr
 

	
 
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)
src/settings.cpp
Show inline comments
 
@@ -791,6 +791,11 @@ static bool RoadVehAccelerationModelChan
 
		}
 
	}
 

	
 
	/* 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;
 
}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -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());
0 comments (0 inline, 0 general)