Changeset - r1998:57add07880e8
[Not reviewed]
master
0 6 0
tron - 19 years ago 2005-07-01 14:05:44
tron@openttd.org
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
6 files changed with 64 insertions and 68 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -10,7 +10,6 @@
 
#include "command.h"
 
#include "station.h"
 
#include "news.h"
 
#include "gfx.h"
 
#include "sound.h"
 
#include "player.h"
 
#include "airport.h"
 
@@ -118,18 +117,6 @@ void DrawAircraftEngine(int x, int y, in
 
	}
 
}
 

	
 
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
 
	SetDParam(0, ((_price.aircraft_base >> 3) * avi->base_cost) >> 5);
 
	SetDParam(1, avi->max_speed << 3);
 
	SetDParam(2, avi->passenger_capacity);
 
	SetDParam(3, avi->mail_capacity);
 
	SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
 

	
 
	DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
 
}
 

	
 
/* Allocate many vehicles */
 
static bool AllocateVehicles(Vehicle **vl, int num)
 
{
engine.h
Show inline comments
 
@@ -194,11 +194,6 @@ void DrawRoadVehEngine(int x, int y, int
 
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod);
 
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod);
 

	
 
void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
 
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
 
void DrawShipEngineInfo(int engine, int x, int y, int maxw);
 
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
 

	
 
void AcceptEnginePreview(Engine *e, PlayerID player);
 

	
 
void LoadCustomEngineNames(void);
engine_gui.c
Show inline comments
 
@@ -49,6 +49,11 @@ typedef struct DrawEngineInfo {
 
	DrawEngineInfoProc *info_proc;
 
} DrawEngineInfo;
 

	
 
static void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
 
static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
 
static void DrawShipEngineInfo(int engine, int x, int y, int maxw);
 
static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
 

	
 
static const DrawEngineInfo _draw_engine_list[4] = {
 
	{DrawTrainEngine,DrawTrainEngineInfo},
 
	{DrawRoadVehEngine,DrawRoadVehEngineInfo},
 
@@ -113,6 +118,28 @@ void ShowEnginePreviewWindow(int engine)
 
	w->window_number = engine;
 
}
 

	
 
static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 
	int cap;
 
	uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
 

	
 
	SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5);
 
	SetDParam(2, rvi->max_speed * 10 >> 4);
 
	SetDParam(3, rvi->power << multihead);
 
	SetDParam(1, rvi->weight << multihead);
 

	
 
	SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8 << multihead);
 

	
 
	cap = rvi->capacity;
 
	SetDParam(5, STR_8838_N_A);
 
	if (cap != 0) {
 
		SetDParam(6, cap << multihead);
 
		SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
 
	}
 
	DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
 
}
 

	
 
void DrawNewsNewTrainAvail(Window *w)
 
{
 
	int engine;
 
@@ -142,6 +169,18 @@ StringID GetNewsStringNewTrainAvail(News
 
	return STR_02B6;
 
}
 

	
 
static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
 
	SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5);
 
	SetDParam(1, avi->max_speed << 3);
 
	SetDParam(2, avi->passenger_capacity);
 
	SetDParam(3, avi->mail_capacity);
 
	SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
 

	
 
	DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
 
}
 

	
 
void DrawNewsNewAircraftAvail(Window *w)
 
{
 
	int engine;
 
@@ -169,6 +208,20 @@ StringID GetNewsStringNewAircraftAvail(N
 
	return STR_02B6;
 
}
 

	
 
static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const RoadVehicleInfo *rvi = RoadVehInfo(engine);
 

	
 
	SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5);
 
	SetDParam(1, rvi->max_speed * 10 >> 5);
 
	SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
 

	
 
	SetDParam(4, rvi->capacity);
 
	SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]);
 

	
 
	DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
 
}
 

	
 
void DrawNewsNewRoadVehAvail(Window *w)
 
{
 
	int engine;
 
@@ -195,6 +248,17 @@ StringID GetNewsStringNewRoadVehAvail(Ne
 
	return STR_02B6;
 
}
 

	
 
static void DrawShipEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const ShipVehicleInfo *svi = ShipVehInfo(engine);
 
	SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
 
	SetDParam(1, svi->max_speed * 10 >> 5);
 
	SetDParam(2, _cargoc.names_long_p[svi->cargo_type]);
 
	SetDParam(3, svi->capacity);
 
	SetDParam(4, svi->running_cost * _price.ship_running >> 8);
 
	DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
 
}
 

	
 
void DrawNewsNewShipAvail(Window *w)
 
{
 
	int engine;
roadveh_cmd.c
Show inline comments
 
@@ -9,7 +9,6 @@
 
#include "command.h"
 
#include "station.h"
 
#include "news.h"
 
#include "gfx.h"
 
#include "pathfind.h"
 
#include "npf.h"
 
#include "player.h"
 
@@ -91,20 +90,6 @@ void DrawRoadVehEngine(int x, int y, int
 
	DrawSprite((6 + _roadveh_images[spritenum]) | image_ormod, x, y);
 
}
 

	
 
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const RoadVehicleInfo *rvi = RoadVehInfo(engine);
 

	
 
	SetDParam(0, ((_price.roadveh_base >> 3) * rvi->base_cost) >> 5);
 
	SetDParam(1, rvi->max_speed * 10 >> 5);
 
	SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
 

	
 
	SetDParam(4, rvi->capacity);
 
	SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]);
 

	
 
	DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
 
}
 

	
 
int32 EstimateRoadVehCost(EngineID engine_type)
 
{
 
	return ((_price.roadveh_base >> 3) * RoadVehInfo(engine_type)->base_cost) >> 5;
ship_cmd.c
Show inline comments
 
@@ -7,7 +7,6 @@
 
#include "command.h"
 
#include "pathfind.h"
 
#include "station.h"
 
#include "gfx.h"
 
#include "news.h"
 
#include "engine.h"
 
#include "gui.h"
 
@@ -41,17 +40,6 @@ void DrawShipEngine(int x, int y, int en
 
	DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y);
 
}
 

	
 
void DrawShipEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const ShipVehicleInfo *svi = ShipVehInfo(engine);
 
	SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
 
	SetDParam(1, svi->max_speed * 10 >> 5);
 
	SetDParam(2, _cargoc.names_long_p[svi->cargo_type]);
 
	SetDParam(3, svi->capacity);
 
	SetDParam(4, svi->running_cost * _price.ship_running >> 8);
 
	DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
 
}
 

	
 
int GetShipImage(const Vehicle *v, byte direction)
 
{
 
	int spritenum = v->spritenum;
train_cmd.c
Show inline comments
 
@@ -10,7 +10,6 @@
 
#include "npf.h"
 
#include "station.h"
 
#include "table/train_cmd.h"
 
#include "gfx.h"
 
#include "news.h"
 
#include "engine.h"
 
#include "player.h"
 
@@ -392,28 +391,6 @@ void DrawTrainEngine(int x, int y, int e
 
	DrawSprite(image | image_ormod, x, y);
 
}
 

	
 
void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
 
{
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 
	int cap;
 
	uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
 

	
 
	SetDParam(0, ((_price.build_railvehicle >> 3) * rvi->base_cost) >> 5);
 
	SetDParam(2, rvi->max_speed * 10 >> 4);
 
	SetDParam(3, rvi->power << multihead);
 
	SetDParam(1, rvi->weight << multihead);
 

	
 
	SetDParam(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead);
 

	
 
	cap = rvi->capacity;
 
	SetDParam(5, STR_8838_N_A);
 
	if (cap != 0) {
 
		SetDParam(6, cap << multihead);
 
		SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
 
	}
 
	DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
 
}
 

	
 

	
 
static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
 
{
0 comments (0 inline, 0 general)