Changeset - r13594:f2f46474fc53
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-11-16 20:58:38
rubidium@openttd.org
(svn r18128) -Codechange: rename GetVehicleListHeight to GetVehicleHeight as it has nothing to do with the height of the vehicle lists.
3 files changed with 11 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -33,25 +33,25 @@
 
#include "cargotype.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
/**
 
 * Get the height of a single 'entry' in the engine lists.
 
 * @param type the vehicle type to get the height of
 
 * @return the height for the entry
 
 */
 
uint GetEngineListHeight(VehicleType type)
 
{
 
	return max<uint>(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleListHeight(type));
 
	return max<uint>(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleHeight(type));
 
}
 

	
 
enum BuildVehicleWidgets {
 
	BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
 
	BUILD_VEHICLE_WIDGET_CAPTION,
 
	BUILD_VEHICLE_WIDGET_LIST_CONTROL,
 
	BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING,
 
	BUILD_VEHICLE_WIDGET_SORT_DROPDOWN,
 
	BUILD_VEHICLE_WIDGET_CARGO_FILTER_DROPDOWN,
 
	BUILD_VEHICLE_WIDGET_LIST,
 
	BUILD_VEHICLE_WIDGET_SCROLLBAR,
 
	BUILD_VEHICLE_WIDGET_PANEL,
src/depot_gui.cpp
Show inline comments
 
@@ -187,36 +187,36 @@ static void InitBlocksizeForShipAircraft
 
		if (y > max_height) max_height = y;
 
	}
 

	
 
	switch (type) {
 
		default: NOT_REACHED();
 
		case VEH_SHIP:
 
			_block_sizes[VEH_SHIP].width = max(90U, max_width + 20); // we need 20 pixels from the right edge to the sprite
 
			break;
 
		case VEH_AIRCRAFT:
 
			_block_sizes[VEH_AIRCRAFT].width = max(74U, max_width);
 
			break;
 
	}
 
	_block_sizes[type].height = max(GetVehicleListHeight(type), max_height);
 
	_block_sizes[type].height = max(GetVehicleHeight(type), max_height);
 
}
 

	
 
/** Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle sprites in the current game.
 
 * @note Calling this function once for each game is enough. */
 
void InitDepotWindowBlockSizes()
 
{
 
	_block_sizes[VEH_TRAIN].width = 1;
 
	_block_sizes[VEH_TRAIN].height = GetVehicleListHeight(VEH_TRAIN);
 
	_block_sizes[VEH_TRAIN].height = GetVehicleHeight(VEH_TRAIN);
 

	
 
	_block_sizes[VEH_ROAD].width = 56;
 
	_block_sizes[VEH_ROAD].height = GetVehicleListHeight(VEH_ROAD);
 
	_block_sizes[VEH_ROAD].height = GetVehicleHeight(VEH_ROAD);
 

	
 
	InitBlocksizeForShipAircraft(VEH_SHIP);
 
	InitBlocksizeForShipAircraft(VEH_AIRCRAFT);
 
}
 

	
 
static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
 
const Sprite *GetAircraftSprite(EngineID engine);
 

	
 
struct DepotWindow : Window {
 
	VehicleID sel;
 
	VehicleType type;
 
	bool generate_list;
 
@@ -246,25 +246,25 @@ struct DepotWindow : Window {
 
	}
 

	
 
	/** Draw a vehicle in the depot window in the box with the top left corner at x,y.
 
	 * @param v     Vehicle to draw.
 
	 * @param x     Left side of the box to draw in.
 
	 * @param y     Top of the box to draw in.
 
	 * @param left  Left edge of the widget.
 
	 * @param right Right edge of the widget.
 
	 */
 
	void DrawVehicleInDepot(const Vehicle *v, int x, int y, int left, int right) const
 
	{
 
		bool free_wagon = false;
 
		int sprite_y = y + this->resize.step_height - GetVehicleListHeight(v->type);
 
		int sprite_y = y + this->resize.step_height - GetVehicleHeight(v->type);
 

	
 
		switch (v->type) {
 
			case VEH_TRAIN: {
 
				const Train *u = Train::From(v);
 
				free_wagon = u->IsFreeWagon();
 

	
 
				uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
 
				DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.GetCapacity() - x_space, this->hscroll.GetPosition());
 

	
 
				/* Number of wagons relative to a standard length wagon (rounded up) */
 
				SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
 
				DrawString(left, right - 1, y + 4, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter
src/vehicle_gui.h
Show inline comments
 
@@ -77,26 +77,30 @@ void DrawAircraftImage(const Vehicle *v,
 

	
 
void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
 

	
 
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
 
StringID GetCargoSubtypeText(const Vehicle *v);
 

	
 
void ShowVehicleListWindow(const Vehicle *v);
 
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, const Waypoint *wp);
 
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
 
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
 
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
 

	
 

	
 
static inline uint GetVehicleListHeight(VehicleType type)
 
/**
 
 * Get the height of a single vehicle in the GUIs.
 
 * @param type the vehicle type to look at
 
 * @return the height
 
 */
 
static inline uint GetVehicleHeight(VehicleType type)
 
{
 
	return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
 
}
 

	
 
/** Get WindowClass for vehicle list of given vehicle type
 
 * @param vt vehicle type to check
 
 * @return corresponding window class
 
 * @note works only for company buildable vehicle types
 
 */
 
static inline WindowClass GetWindowClassForVehicleType(VehicleType vt)
 
{
 
	switch (vt) {
0 comments (0 inline, 0 general)