Changeset - r21979:8f441a1deb2a
[Not reviewed]
master
0 25 0
frosch - 10 years ago 2015-02-01 20:54:24
frosch@openttd.org
(svn r27134) -Codechange: Simplify GUI scaling by adding UnScaleGUI() and ScaleGUITrad().
25 files changed with 177 insertions and 142 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -198,19 +198,21 @@ static SpriteID GetAircraftIcon(EngineID
 
}
 

	
 
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetAircraftIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI), right - UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI) - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI));
 
	preferred_x = Clamp(preferred_x,
 
			left - UnScaleGUI(real_sprite->x_offs),
 
			right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
 
	DrawSprite(sprite, pal, preferred_x, y);
 

	
 
	if (!(AircraftVehInfo(engine)->subtype & AIR_CTOL)) {
 
		SpriteID rotor_sprite = GetCustomRotorIcon(engine, image_type);
 
		if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
 
		DrawSprite(rotor_sprite, PAL_NONE, preferred_x, y - UnScaleByZoom(4 * 5, ZOOM_LVL_GUI));
 
		DrawSprite(rotor_sprite, PAL_NONE, preferred_x, y - ScaleGUITrad(5));
 
	}
 
}
 

	
 
/**
 
 * Get the size of the sprite of an aircraft sprite heading west (used for lists).
 
 * @param engine The engine to get the sprite from.
 
@@ -221,16 +223,16 @@ void DrawAircraftEngine(int left, int ri
 
 * @param image_type Context the sprite is used in.
 
 */
 
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
 
{
 
	const Sprite *spr = GetSprite(GetAircraftIcon(engine, image_type), ST_NORMAL);
 

	
 
	width  = UnScaleByZoom(spr->width, ZOOM_LVL_GUI);
 
	height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
 
	xoffs  = UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI);
 
	yoffs  = UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI);
 
	width  = UnScaleGUI(spr->width);
 
	height = UnScaleGUI(spr->height);
 
	xoffs  = UnScaleGUI(spr->x_offs);
 
	yoffs  = UnScaleGUI(spr->y_offs);
 
}
 

	
 
/**
 
 * Build an aircraft.
 
 * @param tile     tile of the depot where aircraft is built.
 
 * @param flags    type of operation.
src/aircraft_gui.cpp
Show inline comments
 
@@ -83,29 +83,29 @@ void DrawAircraftImage(const Vehicle *v,
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
	int width = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI);
 
	int x_offs = UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI);
 
	int width = UnScaleGUI(real_sprite->width);
 
	int x_offs = UnScaleGUI(real_sprite->x_offs);
 
	int x = rtl ? right - width - x_offs : left - x_offs;
 
	bool helicopter = v->subtype == AIR_HELICOPTER;
 

	
 
	int y_offs = UnScaleByZoom(4 * 10, ZOOM_LVL_GUI);
 
	int y_offs = ScaleGUITrad(10);
 
	int heli_offs = 0;
 

	
 
	PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
	DrawSprite(sprite, pal, x, y + y_offs);
 
	if (helicopter) {
 
		const Aircraft *a = Aircraft::From(v);
 
		SpriteID rotor_sprite = GetCustomRotorSprite(a, true, image_type);
 
		if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
 
		heli_offs = UnScaleByZoom(4 * 5, ZOOM_LVL_GUI);
 
		heli_offs = ScaleGUITrad(5);
 
		DrawSprite(rotor_sprite, PAL_NONE, x, y + y_offs - heli_offs);
 
	}
 
	if (v->index == selection) {
 
		x += x_offs;
 
		y += UnScaleByZoom(real_sprite->y_offs, ZOOM_LVL_GUI) + y_offs - heli_offs;
 
		DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleByZoom(real_sprite->height, ZOOM_LVL_GUI) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
 
		y += UnScaleGUI(real_sprite->y_offs) + y_offs - heli_offs;
 
		DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + heli_offs + 1, COLOUR_WHITE, FR_BORDERONLY);
 
	}
 
}
src/company_gui.cpp
Show inline comments
 
@@ -526,13 +526,13 @@ public:
 
	{
 
		return _colour_dropdown[this->result];
 
	}
 

	
 
	uint Height(uint width) const
 
	{
 
		return max(FONT_HEIGHT_NORMAL, UnScaleByZoom(4 * 12, ZOOM_LVL_GUI) + 2);
 
		return max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + 2);
 
	}
 

	
 
	bool Selectable() const
 
	{
 
		return true;
 
	}
 
@@ -540,14 +540,18 @@ public:
 
	void Draw(int left, int right, int top, int bottom, bool sel, int bg_colour) const
 
	{
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int height = bottom - top;
 
		int icon_y_offset = height / 2;
 
		int text_y_offset = (height - FONT_HEIGHT_NORMAL) / 2 + 1;
 
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + this->result, rtl ? right - 2 - UnScaleByZoom(4 * 14, ZOOM_LVL_GUI) : left + UnScaleByZoom(4 * 14, ZOOM_LVL_GUI) + 2, top + icon_y_offset);
 
		DrawString(rtl ? left + 2 : left + UnScaleByZoom(4 * 28, ZOOM_LVL_GUI) + 4, rtl ? right - UnScaleByZoom(4 * 28, ZOOM_LVL_GUI) - 4 : right - 2, top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
 
		DrawSprite(SPR_VEH_BUS_SIDE_VIEW, PALETTE_RECOLOUR_START + this->result,
 
				rtl ? right - 2 - ScaleGUITrad(14) : left + ScaleGUITrad(14) + 2,
 
				top + icon_y_offset);
 
		DrawString(rtl ? left + 2 : left + ScaleGUITrad(28) + 4,
 
				rtl ? right - ScaleGUITrad(28) - 4 : right - 2,
 
				top + text_y_offset, this->String(), sel ? TC_WHITE : TC_BLACK);
 
	}
 
};
 

	
 
/** Company livery colour scheme window. */
 
struct SelectCompanyLiveryWindow : public Window {
 
private:
src/depot_gui.cpp
Show inline comments
 
@@ -187,23 +187,23 @@ static void InitBlocksizeForVehicles(Veh
 
		}
 
		if (y > max_height) max_height = y;
 
		if (-x_offs > max_extend_left) max_extend_left = -x_offs;
 
		if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
 
	}
 

	
 
	int min_extend = UnScaleByZoom(16 * 4, ZOOM_LVL_GUI);
 
	int max_extend = UnScaleByZoom(98 * 4, ZOOM_LVL_GUI);
 
	int min_extend = ScaleGUITrad(16);
 
	int max_extend = ScaleGUITrad(98);
 

	
 
	switch (image_type) {
 
		case EIT_IN_DEPOT:
 
			_base_block_sizes_depot[type].height       = max<uint>(UnScaleByZoom(4 * GetVehicleHeight(type), ZOOM_LVL_GUI), max_height);
 
			_base_block_sizes_depot[type].height       = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
 
			_base_block_sizes_depot[type].extend_left  = Clamp(max_extend_left, min_extend, max_extend);
 
			_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
 
			break;
 
		case EIT_PURCHASE:
 
			_base_block_sizes_purchase[type].height       = max<uint>(UnScaleByZoom(4 * GetVehicleHeight(type), ZOOM_LVL_GUI), max_height);
 
			_base_block_sizes_purchase[type].height       = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
 
			_base_block_sizes_purchase[type].extend_left  = Clamp(max_extend_left, min_extend, max_extend);
 
			_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
 
			break;
 

	
 
		default: NOT_REACHED();
 
	}
 
@@ -276,24 +276,24 @@ struct DepotWindow : Window {
 
	 * @param right Right side of the box to draw in.
 
	 * @param y     Top of the box to draw in.
 
	 */
 
	void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
 
	{
 
		bool free_wagon = false;
 
		int sprite_y = y + (this->resize.step_height - UnScaleByZoom(4 * GetVehicleHeight(v->type), ZOOM_LVL_GUI)) / 2;
 
		int sprite_y = y + (this->resize.step_height - ScaleGUITrad(GetVehicleHeight(v->type))) / 2;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int image_left  = rtl ? left  + this->count_width  : left  + this->header_width;
 
		int image_right = rtl ? right - this->header_width : right - this->count_width;
 

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

	
 
				uint x_space = free_wagon ? UnScaleByZoom(4 * TRAININFO_DEFAULT_VEHICLE_WIDTH, ZOOM_LVL_GUI) : 0;
 
				uint x_space = free_wagon ? ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) : 0;
 
				DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
 
						this->sel, EIT_IN_DEPOT, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
 

	
 
				/* Length of consist in tiles with 1 fractional digit (rounded up) */
 
				SetDParam(0, CeilDiv(u->gcache.cached_total_length * 10, TILE_SIZE));
 
				SetDParam(1, 1);
 
@@ -426,13 +426,13 @@ struct DepotWindow : Window {
 
			/* Skip vehicles that are scrolled off the list */
 
			if (this->type == VEH_TRAIN) x += this->hscroll->GetPosition();
 
		} else {
 
			pos -= this->vehicle_list.Length();
 
			*veh = this->wagon_list[pos];
 
			/* free wagons don't have an initial loco. */
 
			x -= UnScaleByZoom(VEHICLEINFO_FULL_VEHICLE_WIDTH * ZOOM_LVL_BASE, ZOOM_LVL_GUI);
 
			x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			wagon = true;
 
		}
 

	
 
		const Train *v = NULL;
 
		if (this->type == VEH_TRAIN) {
 
			v = Train::From(*veh);
 
@@ -609,28 +609,28 @@ struct DepotWindow : Window {
 
					this->count_width = 0;
 
				}
 

	
 
				SetDParamMaxDigits(0, this->unitnumber_digits);
 
				Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
 
				const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
 
				this->flag_width  = UnScaleByZoom(spr->width, ZOOM_LVL_GUI) + WD_FRAMERECT_RIGHT;
 
				this->flag_height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
 
				this->flag_width  = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
 
				this->flag_height = UnScaleGUI(spr->height);
 

	
 
				if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
 
					min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleByZoom(spr->height, ZOOM_LVL_GUI));
 
					min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
 
					this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
 
				} else {
 
					min_height = unumber.height + UnScaleByZoom(spr->height, ZOOM_LVL_GUI) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
 
					min_height = unumber.height + UnScaleGUI(spr->height) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
 
					this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
 
				}
 
				int base_width = this->count_width + this->header_width;
 

	
 
				resize->height = max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
 
				if (this->type == VEH_TRAIN) {
 
					resize->width = 1;
 
					size->width = base_width + 2 * UnScaleByZoom(29 * 4, ZOOM_LVL_GUI); // about 2 parts
 
					size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts
 
					size->height = resize->height * 6;
 
				} else {
 
					resize->width = base_width + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_left + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_right;
 
					size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3);
 
					size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3);
 
				}
 
@@ -666,13 +666,13 @@ struct DepotWindow : Window {
 
				this->ReInit();
 
			}
 
		}
 

	
 
		/* determine amount of items for scroller */
 
		if (this->type == VEH_TRAIN) {
 
			uint max_width = UnScaleByZoom(VEHICLEINFO_FULL_VEHICLE_WIDTH * ZOOM_LVL_BASE, ZOOM_LVL_GUI);
 
			uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			for (uint num = 0; num < this->vehicle_list.Length(); num++) {
 
				uint width = 0;
 
				for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
 
					width += v->GetDisplayImageWidth();
 
				}
 
				max_width = max(max_width, width);
src/dock_gui.cpp
Show inline comments
 
@@ -501,26 +501,26 @@ public:
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		switch (widget) {
 
			case WID_BDD_X:
 
			case WID_BDD_Y:
 
				size->width  = UnScaleByZoom(96 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				size->width  = ScaleGUITrad(96) + 2;
 
				size->height = ScaleGUITrad(64) + 2;
 
				break;
 
		}
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		this->DrawWidgets();
 

	
 
		int x1 = UnScaleByZoom(63 * 4, ZOOM_LVL_GUI) + 1;
 
		int x2 = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
		int y1 = UnScaleByZoom(17 * 4, ZOOM_LVL_GUI) + 1;
 
		int y2 = UnScaleByZoom(33 * 4, ZOOM_LVL_GUI) + 1;
 
		int x1 = ScaleGUITrad(63) + 1;
 
		int x2 = ScaleGUITrad(31) + 1;
 
		int y1 = ScaleGUITrad(17) + 1;
 
		int y2 = ScaleGUITrad(33) + 1;
 

	
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + x1, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + y1, AXIS_X, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_x + x2, this->GetWidget<NWidgetBase>(WID_BDD_X)->pos_y + y2, AXIS_X, DEPOT_PART_SOUTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + x2, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + y1, AXIS_Y, DEPOT_PART_NORTH);
 
		DrawShipDepotSprite(this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_x + x1, this->GetWidget<NWidgetBase>(WID_BDD_Y)->pos_y + y2, AXIS_Y, DEPOT_PART_SOUTH);
 
	}
src/fontcache.cpp
Show inline comments
 
@@ -180,18 +180,18 @@ const Sprite *SpriteFontCache::GetGlyph(
 
}
 

	
 
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
 
{
 
	SpriteID sprite = this->GetUnicodeGlyph(key);
 
	if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
 
	return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + UnScaleByZoom(4 * (this->fs != FS_NORMAL), ZOOM_LVL_GUI) : 0;
 
	return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleGUITrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
 
}
 

	
 
int SpriteFontCache::GetHeight() const
 
{
 
	return UnScaleByZoom(4 * this->height, ZOOM_LVL_GUI);
 
	return ScaleGUITrad(this->height);
 
}
 

	
 
bool SpriteFontCache::GetDrawGlyphShadow()
 
{
 
	return false;
 
}
src/gfx.cpp
Show inline comments
 
@@ -1529,16 +1529,16 @@ bool FillDrawPixelInfo(DrawPixelInfo *n,
 
 */
 
void UpdateCursorSize()
 
{
 
	CursorVars *cv = &_cursor;
 
	const Sprite *p = GetSprite(GB(cv->sprite, 0, SPRITE_WIDTH), ST_NORMAL);
 

	
 
	cv->size.y = UnScaleByZoom(p->height, ZOOM_LVL_GUI);
 
	cv->size.x = UnScaleByZoom(p->width, ZOOM_LVL_GUI);
 
	cv->offs.x = UnScaleByZoom(p->x_offs, ZOOM_LVL_GUI);
 
	cv->offs.y = UnScaleByZoom(p->y_offs, ZOOM_LVL_GUI);
 
	cv->size.y = UnScaleGUI(p->height);
 
	cv->size.x = UnScaleGUI(p->width);
 
	cv->offs.x = UnScaleGUI(p->x_offs);
 
	cv->offs.y = UnScaleGUI(p->y_offs);
 

	
 
	cv->dirty = true;
 
}
 

	
 
/**
 
 * Switch cursor to different sprite.
src/gfx_func.h
Show inline comments
 
@@ -68,14 +68,12 @@ extern bool _screen_disable_anim;   ///<
 

	
 
extern int _num_resolutions;
 
extern Dimension _resolutions[32];
 
extern Dimension _cur_resolution;
 
extern Palette _cur_palette; ///< Current palette
 

	
 
extern ZoomLevelByte _gui_zoom;
 

	
 
void HandleKeypress(uint keycode, WChar key);
 
void HandleTextInput(const char *str, bool marked = false, const char *caret = NULL, const char *insert_location = NULL, const char *replacement_end = NULL);
 
void HandleCtrlChanged();
 
void HandleMouseEvents();
 
void CSleep(int milliseconds);
 
void UpdateWindows();
src/misc_gui.cpp
Show inline comments
 
@@ -681,13 +681,13 @@ struct TooltipsWindow : public Window
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		/* There is only one widget. */
 
		for (uint i = 0; i != this->paramcount; i++) SetDParam(i, this->params[i]);
 

	
 
		size->width  = min(GetStringBoundingBox(this->string_id).width, UnScaleByZoom(4 * 194, ZOOM_LVL_GUI));
 
		size->width  = min(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194));
 
		size->height = GetStringHeight(this->string_id, size->width);
 

	
 
		/* Increase slightly to have some space around the box. */
 
		size->width  += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
		size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
 
	}
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -855,21 +855,21 @@ struct SpriteAlignerWindow : Window {
 
		switch (widget) {
 
			case WID_SA_SPRITE: {
 
				/* Center the sprite ourselves */
 
				const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
 
				int width  = r.right  - r.left + 1;
 
				int height = r.bottom - r.top  + 1;
 
				int x = r.left - UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI) + (width  - UnScaleByZoom(spr->width, ZOOM_LVL_GUI)) / 2;
 
				int y = r.top  - UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI) + (height - UnScaleByZoom(spr->height, ZOOM_LVL_GUI)) / 2;
 
				int x = r.left - UnScaleGUI(spr->x_offs) + (width  - UnScaleGUI(spr->width) ) / 2;
 
				int y = r.top  - UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;
 

	
 
				/* And draw only the part within the sprite area */
 
				SubSprite subspr = {
 
					spr->x_offs + (spr->width  - ScaleByZoom(width,  ZOOM_LVL_GUI)) / 2 + 1,
 
					spr->y_offs + (spr->height - ScaleByZoom(height, ZOOM_LVL_GUI)) / 2 + 1,
 
					spr->x_offs + (spr->width  + ScaleByZoom(width,  ZOOM_LVL_GUI)) / 2 - 1,
 
					spr->y_offs + (spr->height + ScaleByZoom(height, ZOOM_LVL_GUI)) / 2 - 1,
 
					spr->x_offs + (spr->width  - UnScaleGUI(width) ) / 2 + 1,
 
					spr->y_offs + (spr->height - UnScaleGUI(height)) / 2 + 1,
 
					spr->x_offs + (spr->width  + UnScaleGUI(width) ) / 2 - 1,
 
					spr->y_offs + (spr->height + UnScaleGUI(height)) / 2 - 1,
 
				};
 

	
 
				DrawSprite(this->current_sprite, PAL_NONE, x, y, &subspr, ZOOM_LVL_GUI);
 
				break;
 
			}
 

	
src/object_gui.cpp
Show inline comments
 
@@ -162,25 +162,25 @@ public:
 
					two_wide |= spec->views >= 2;
 
					height[spec->views / 4] = max<int>(ObjectSpec::Get(i)->height, height[spec->views / 4]);
 
				}
 

	
 
				/* Determine the pixel heights. */
 
				for (size_t i = 0; i < lengthof(height); i++) {
 
					height[i] *= UnScaleByZoom(4 * TILE_HEIGHT, ZOOM_LVL_GUI);
 
					height[i] += UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI) + 2 * OBJECT_MARGIN;
 
					height[i] *= ScaleGUITrad(TILE_HEIGHT);
 
					height[i] += ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN;
 
				}
 

	
 
				/* Now determine the size of the minimum widgets. When there are two columns, then
 
				 * we want these columns to be slightly less wide. When there are two rows, then
 
				 * determine the size of the widgets based on the maximum size for a single row
 
				 * of widgets, or just the twice the widget height of the two row ones. */
 
				size->height = max(height[0], height[1] * 2 + 2);
 
				if (two_wide) {
 
					size->width  = (3 * UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI) + 2 * OBJECT_MARGIN) * 2 + 2;
 
					size->width  = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN) * 2 + 2;
 
				} else {
 
					size->width  = 4 * UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI) + 2 * OBJECT_MARGIN;
 
					size->width  = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN;
 
				}
 

	
 
				/* Get the right size for the single widget based on the current spec. */
 
				const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
 
				if (spec != NULL) {
 
					if (spec->views >= 2) size->width  = size->width  / 2 - 1;
 
@@ -196,14 +196,14 @@ public:
 
			case WID_BO_SELECT_MATRIX:
 
				fill->height = 1;
 
				resize->height = 1;
 
				break;
 

	
 
			case WID_BO_SELECT_IMAGE:
 
				size->width  = UnScaleByZoom(4 * 64, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(4 * 58, ZOOM_LVL_GUI) + 2;
 
				size->width  = ScaleGUITrad(64) + 2;
 
				size->height = ScaleGUITrad(58) + 2;
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
@@ -240,15 +240,15 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (spec->grf_prop.grffile == NULL) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI), spec, GB(widget, 16, 16));
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec, GB(widget, 16, 16));
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
 
			}
 

	
 
@@ -267,15 +267,15 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left + 1, r.top, (r.right - 1) - (r.left + 1) + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					if (spec->grf_prop.grffile == NULL) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - UnScaleByZoom(4 * TILE_PIXELS, ZOOM_LVL_GUI), spec,
 
						DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec,
 
								min(_selected_object_view, spec->views - 1));
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
 
			}
src/rail_gui.cpp
Show inline comments
 
@@ -1072,14 +1072,14 @@ public:
 
				break;
 
			}
 

	
 
			case WID_BRAS_PLATFORM_DIR_X:
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
			case WID_BRAS_IMAGE:
 
				size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(58 * 4, ZOOM_LVL_GUI) + 2;
 
				size->width  = ScaleGUITrad(64) + 2;
 
				size->height = ScaleGUITrad(58) + 2;
 
				break;
 

	
 
			case WID_BRAS_COVERAGE_TEXTS:
 
				size->height = this->coverage_height;
 
				break;
 

	
 
@@ -1097,28 +1097,28 @@ public:
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRAS_PLATFORM_DIR_X:
 
				/* Set up a clipping area for the '/' station preview */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					int x = ScaleGUITrad(31) + 1;
 
					int y = r.bottom - r.top - ScaleGUITrad(31);
 
					if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
 

	
 
			case WID_BRAS_PLATFORM_DIR_Y:
 
				/* Set up a clipping area for the '\' station preview */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					int x = ScaleGUITrad(31) + 1;
 
					int y = r.bottom - r.top - ScaleGUITrad(31);
 
					if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
 
@@ -1149,14 +1149,14 @@ public:
 
				}
 

	
 
				/* Set up a clipping area for the station preview. */
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = UnScaleByZoom(31 * 4, ZOOM_LVL_GUI) + 1;
 
					int y = r.bottom - r.top - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI);
 
					int x = ScaleGUITrad(31) + 1;
 
					int y = r.bottom - r.top - ScaleGUITrad(31);
 
					if (!DrawStationTile(x, y, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
 
						StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
 
@@ -1690,21 +1690,21 @@ struct BuildRailDepotWindow : public Pic
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
		size->width  = ScaleGUITrad(64) + 2;
 
		size->height = ScaleGUITrad(48) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
 

	
 
		DrawTrainDepotSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
		DrawTrainDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case WID_BRAD_DEPOT_NE:
 
@@ -1788,25 +1788,25 @@ struct BuildRailWaypointWindow : PickerW
 

	
 
				/* Resizing in X direction only at blob size, but at pixel level in Y. */
 
				resize->height = 1;
 
				break;
 

	
 
			case WID_BRW_WAYPOINT:
 
				size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
				size->height = UnScaleByZoom(58 * 4, ZOOM_LVL_GUI) + 2;
 
				size->width  = ScaleGUITrad(64) + 2;
 
				size->height = ScaleGUITrad(58) + 2;
 
				break;
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (GB(widget, 0, 16)) {
 
			case WID_BRW_WAYPOINT: {
 
				byte type = GB(widget, 16, 16);
 
				const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
 
				DrawWaypointSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), type, _cur_railtype);
 
				DrawWaypointSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), type, _cur_railtype);
 

	
 
				if (!IsStationAvailable(statspec)) {
 
					GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
 
				}
 
			}
 
		}
src/road_gui.cpp
Show inline comments
 
@@ -864,21 +864,21 @@ struct BuildRoadDepotWindow : public Pic
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
		size->width  = ScaleGUITrad(64) + 2;
 
		size->height = ScaleGUITrad(48) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
 

	
 
		DrawRoadDepotSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
		DrawRoadDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case WID_BROD_DEPOT_NW:
 
@@ -1000,22 +1000,22 @@ struct BuildRoadStationWindow : public P
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
 

	
 
		size->width  = UnScaleByZoom(64 * 4, ZOOM_LVL_GUI) + 2;
 
		size->height = UnScaleByZoom(48 * 4, ZOOM_LVL_GUI) + 2;
 
		size->width  = ScaleGUITrad(64) + 2;
 
		size->height = ScaleGUITrad(48) + 2;
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
 

	
 
		StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
 
		StationPickerDrawSprite(r.left + 1 + UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), r.bottom - UnScaleByZoom(31 * 4, ZOOM_LVL_GUI), st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
 
		StationPickerDrawSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		switch (widget) {
 
			case WID_BROS_STATION_NE:
src/roadveh_cmd.cpp
Show inline comments
 
@@ -104,16 +104,16 @@ bool RoadVehicle::IsBus() const
 
 */
 
int RoadVehicle::GetDisplayImageWidth(Point *offset) const
 
{
 
	int reference_width = ROADVEHINFO_DEFAULT_VEHICLE_WIDTH;
 

	
 
	if (offset != NULL) {
 
		offset->x = UnScaleByZoom(2 * reference_width, ZOOM_LVL_GUI);
 
		offset->x = ScaleGUITrad(reference_width) / 2;
 
		offset->y = 0;
 
	}
 
	return UnScaleByZoom(4 * this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH, ZOOM_LVL_GUI);
 
	return ScaleGUITrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
}
 

	
 
static SpriteID GetRoadVehIcon(EngineID engine, EngineImageType image_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint8 spritenum = e->u.road.image_index;
 
@@ -159,13 +159,15 @@ SpriteID RoadVehicle::GetImage(Direction
 
 * @param pal Palette to use.
 
 */
 
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetRoadVehIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI), right - UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI) - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI));
 
	preferred_x = Clamp(preferred_x,
 
			left - UnScaleGUI(real_sprite->x_offs),
 
			right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
 
	DrawSprite(sprite, pal, preferred_x, y);
 
}
 

	
 
/**
 
 * Get the size of the sprite of a road vehicle sprite heading west (used for lists).
 
 * @param engine The engine to get the sprite from.
 
@@ -176,16 +178,16 @@ void DrawRoadVehEngine(int left, int rig
 
 * @param image_type Context the sprite is used in.
 
 */
 
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
 
{
 
	const Sprite *spr = GetSprite(GetRoadVehIcon(engine, image_type), ST_NORMAL);
 

	
 
	width  = UnScaleByZoom(spr->width, ZOOM_LVL_GUI);
 
	height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
 
	xoffs  = UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI);
 
	yoffs  = UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI);
 
	width  = UnScaleGUI(spr->width);
 
	height = UnScaleGUI(spr->height);
 
	xoffs  = UnScaleGUI(spr->x_offs);
 
	yoffs  = UnScaleGUI(spr->y_offs);
 
}
 

	
 
/**
 
 * Get length of a road vehicle.
 
 * @param v Road vehicle to query length.
 
 * @return Length of the given road vehicle.
src/roadveh_gui.cpp
Show inline comments
 
@@ -28,13 +28,13 @@
 
 * @param left  The left most coordinate to draw
 
 * @param right The right most coordinate to draw
 
 * @param y     The y coordinate
 
 */
 
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
 
{
 
	uint y_offset = v->HasArticulatedPart() ? UnScaleByZoom(4 * 15, ZOOM_LVL_GUI) : 0; // Draw the first line below the sprite of an articulated RV instead of after it.
 
	uint y_offset = v->HasArticulatedPart() ? ScaleGUITrad(15) : 0; // Draw the first line below the sprite of an articulated RV instead of after it.
 
	StringID str;
 
	Money feeder_share = 0;
 

	
 
	SetDParam(0, v->engine_type);
 
	SetDParam(1, v->build_year);
 
	SetDParam(2, v->value);
 
@@ -134,30 +134,30 @@ void DrawRoadVehImage(const Vehicle *v, 
 
	Direction dir = rtl ? DIR_E : DIR_W;
 
	const RoadVehicle *u = RoadVehicle::From(v);
 

	
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	int max_width = right - left + 1;
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, UnScaleByZoom(4 * 14, ZOOM_LVL_GUI))) return;
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, ScaleGUITrad(14))) return;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &tmp_dpi;
 

	
 
	int px = rtl ? max_width + skip : -skip;
 
	for (; u != NULL && (rtl ? px > 0 : px < max_width); u = u->Next()) {
 
		Point offset;
 
		int width = u->GetDisplayImageWidth(&offset);
 

	
 
		if (rtl ? px + width > 0 : px - width < max_width) {
 
			PaletteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u);
 
			DrawSprite(u->GetImage(dir, image_type), pal, px + (rtl ? -offset.x : offset.x), UnScaleByZoom(4 * 6, ZOOM_LVL_GUI) + offset.y);
 
			DrawSprite(u->GetImage(dir, image_type), pal, px + (rtl ? -offset.x : offset.x), ScaleGUITrad(6) + offset.y);
 
		}
 

	
 
		px += rtl ? -width : width;
 
	}
 

	
 
	if (v->index == selection) {
 
		DrawFrameRect((rtl ? px : 0), 0, (rtl ? max_width : px) - 1, UnScaleByZoom(4 * 13, ZOOM_LVL_GUI) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
		DrawFrameRect((rtl ? px : 0), 0, (rtl ? max_width : px) - 1, ScaleGUITrad(13) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
	}
 

	
 
	_cur_dpi = old_dpi;
 
}
src/ship_cmd.cpp
Show inline comments
 
@@ -87,13 +87,15 @@ static SpriteID GetShipIcon(EngineID eng
 
}
 

	
 
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
 
{
 
	SpriteID sprite = GetShipIcon(engine, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
	preferred_x = Clamp(preferred_x, left - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI), right - UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI) - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI));
 
	preferred_x = Clamp(preferred_x,
 
			left - UnScaleGUI(real_sprite->x_offs),
 
			right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
 
	DrawSprite(sprite, pal, preferred_x, y);
 
}
 

	
 
/**
 
 * Get the size of the sprite of a ship sprite heading west (used for lists).
 
 * @param engine The engine to get the sprite from.
 
@@ -104,16 +106,16 @@ void DrawShipEngine(int left, int right,
 
 * @param image_type Context the sprite is used in.
 
 */
 
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
 
{
 
	const Sprite *spr = GetSprite(GetShipIcon(engine, image_type), ST_NORMAL);
 

	
 
	width  = UnScaleByZoom(spr->width, ZOOM_LVL_GUI);
 
	height = UnScaleByZoom(spr->height, ZOOM_LVL_GUI);
 
	xoffs  = UnScaleByZoom(spr->x_offs, ZOOM_LVL_GUI);
 
	yoffs  = UnScaleByZoom(spr->y_offs, ZOOM_LVL_GUI);
 
	width  = UnScaleGUI(spr->width);
 
	height = UnScaleGUI(spr->height);
 
	xoffs  = UnScaleGUI(spr->x_offs);
 
	yoffs  = UnScaleGUI(spr->y_offs);
 
}
 

	
 
SpriteID Ship::GetImage(Direction direction, EngineImageType image_type) const
 
{
 
	uint8 spritenum = this->spritenum;
 

	
src/ship_gui.cpp
Show inline comments
 
@@ -35,23 +35,23 @@ void DrawShipImage(const Vehicle *v, int
 
{
 
	bool rtl = _current_text_dir == TD_RTL;
 

	
 
	SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
	int width = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI);
 
	int x_offs = UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI);
 
	int width = UnScaleGUI(real_sprite->width);
 
	int x_offs = UnScaleGUI(real_sprite->x_offs);
 
	int x = rtl ? right - width - x_offs : left - x_offs;
 

	
 
	y += UnScaleByZoom(4 * 10, ZOOM_LVL_GUI);
 
	y += ScaleGUITrad(10);
 
	DrawSprite(sprite, GetVehiclePalette(v), x, y);
 

	
 
	if (v->index == selection) {
 
		x += x_offs;
 
		y += UnScaleByZoom(real_sprite->y_offs, ZOOM_LVL_GUI);
 
		DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleByZoom(real_sprite->height, ZOOM_LVL_GUI) + 1, COLOUR_WHITE, FR_BORDERONLY);
 
		y += UnScaleGUI(real_sprite->y_offs);
 
		DrawFrameRect(x - 1, y - 1, x + width + 1, y + UnScaleGUI(real_sprite->height) + 1, COLOUR_WHITE, FR_BORDERONLY);
 
	}
 
}
 

	
 
/**
 
 * Draw the details for the given vehicle at the given position
 
 *
src/sprite.cpp
Show inline comments
 
@@ -116,18 +116,18 @@ void DrawCommonTileSeqInGUI(int x, int y
 
		if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset;
 

	
 
		pal = SpriteLayoutPaletteTransform(image, pal, default_palette);
 

	
 
		if (dtss->IsParentSprite()) {
 
			Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
 
			DrawSprite(image, pal, x + UnScaleByZoom(pt.x, ZOOM_LVL_GUI), y + UnScaleByZoom(pt.y, ZOOM_LVL_GUI));
 
			DrawSprite(image, pal, x + UnScaleGUI(pt.x), y + UnScaleGUI(pt.y));
 

	
 
			const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL);
 
			child_offset.x = UnScaleByZoom(pt.x + spr->x_offs, ZOOM_LVL_GUI);
 
			child_offset.y = UnScaleByZoom(pt.y + spr->y_offs, ZOOM_LVL_GUI);
 
			child_offset.x = UnScaleGUI(pt.x + spr->x_offs);
 
			child_offset.y = UnScaleGUI(pt.y + spr->y_offs);
 
		} else {
 
			int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x;
 
			int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y;
 
			DrawSprite(image, pal, x + child_offset.x + offs_x, y + child_offset.y + offs_y);
 
			DrawSprite(image, pal, x + child_offset.x + ScaleGUITrad(offs_x), y + child_offset.y + ScaleGUITrad(offs_y));
 
		}
 
	}
 
}
src/station_gui.cpp
Show inline comments
 
@@ -803,13 +803,13 @@ static const NWidgetPart _nested_station
 
 * @param right right most coordinate to draw on
 
 * @param y y coordinate
 
 * @param width the width of the view
 
 */
 
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int y)
 
{
 
	int width = UnScaleByZoom(4 * 10, ZOOM_LVL_GUI);
 
	int width = ScaleGUITrad(10);
 
	uint num = min((waiting + (width / 2)) / width, (right - left) / width); // maximum is width / 10 icons so it won't overflow
 
	if (num == 0) return;
 

	
 
	SpriteID sprite = CargoSpec::Get(i)->GetCargoIcon();
 

	
 
	int x = _current_text_dir == TD_RTL ? left : right - num * width;
src/terraform_gui.cpp
Show inline comments
 
@@ -556,14 +556,14 @@ struct ScenarioEditorLandscapeGeneration
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
	{
 
		if (widget != WID_ETT_DOTS) return;
 

	
 
		size->width  = max<uint>(size->width,  UnScaleByZoom(4 * 59, ZOOM_LVL_GUI));
 
		size->height = max<uint>(size->height, UnScaleByZoom(4 * 31, ZOOM_LVL_GUI));
 
		size->width  = max<uint>(size->width,  ScaleGUITrad(59));
 
		size->height = max<uint>(size->height, ScaleGUITrad(31));
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != WID_ETT_DOTS) return;
 

	
 
@@ -572,13 +572,13 @@ struct ScenarioEditorLandscapeGeneration
 

	
 
		int n = _terraform_size * _terraform_size;
 
		const int8 *coords = &_multi_terraform_coords[0][0];
 

	
 
		assert(n != 0);
 
		do {
 
			DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + UnScaleByZoom(4 * coords[0], ZOOM_LVL_GUI), center_y + UnScaleByZoom(4 * coords[1], ZOOM_LVL_GUI));
 
			DrawSprite(SPR_WHITE_POINT, PAL_NONE, center_x + ScaleGUITrad(coords[0]), center_y + ScaleGUITrad(coords[1]));
 
			coords += 2;
 
		} while (--n);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
src/train_cmd.cpp
Show inline comments
 
@@ -461,16 +461,16 @@ int Train::GetDisplayImageWidth(Point *o
 
	if (e->GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
 
		reference_width = e->GetGRF()->traininfo_vehicle_width;
 
		vehicle_pitch = e->GetGRF()->traininfo_vehicle_pitch;
 
	}
 

	
 
	if (offset != NULL) {
 
		offset->x = UnScaleByZoom(2 * reference_width, ZOOM_LVL_GUI);
 
		offset->y = UnScaleByZoom(4 * vehicle_pitch, ZOOM_LVL_GUI);
 
		offset->x = ScaleGUITrad(reference_width) / 2;
 
		offset->y = ScaleGUITrad(vehicle_pitch);
 
	}
 
	return UnScaleByZoom(4 * this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH, ZOOM_LVL_GUI);
 
	return ScaleGUITrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
}
 

	
 
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
 
{
 
	assert(IsValidImageIndex<VEH_TRAIN>(spritenum));
 
	return ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]) + _engine_sprite_base[spritenum];
 
@@ -511,13 +511,13 @@ static SpriteID GetRailIcon(EngineID eng
 
	uint8 spritenum = e->u.rail.image_index;
 

	
 
	if (is_custom_sprite(spritenum)) {
 
		SpriteID sprite = GetCustomVehicleIcon(engine, dir, image_type);
 
		if (sprite != 0) {
 
			if (e->GetGRF() != NULL) {
 
				y += UnScaleByZoom(4 * e->GetGRF()->traininfo_vehicle_pitch, ZOOM_LVL_GUI);
 
				y += ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
 
			}
 
			return sprite;
 
		}
 

	
 
		spritenum = Engine::Get(engine)->original_image_index;
 
	}
 
@@ -535,20 +535,24 @@ void DrawTrainEngine(int left, int right
 

	
 
		SpriteID spritef = GetRailIcon(engine, false, yf, image_type);
 
		SpriteID spriter = GetRailIcon(engine, true, yr, image_type);
 
		const Sprite *real_spritef = GetSprite(spritef, ST_NORMAL);
 
		const Sprite *real_spriter = GetSprite(spriter, ST_NORMAL);
 

	
 
		preferred_x = Clamp(preferred_x, left - UnScaleByZoom(real_spritef->x_offs, ZOOM_LVL_GUI) + UnScaleByZoom(14 * 4, ZOOM_LVL_GUI), right - UnScaleByZoom(real_spriter->width, ZOOM_LVL_GUI) - UnScaleByZoom(real_spriter->x_offs, ZOOM_LVL_GUI) - UnScaleByZoom(15 * 4, ZOOM_LVL_GUI));
 

	
 
		DrawSprite(spritef, pal, preferred_x - UnScaleByZoom(14 * 4, ZOOM_LVL_GUI), yf);
 
		DrawSprite(spriter, pal, preferred_x + UnScaleByZoom(15 * 4, ZOOM_LVL_GUI), yr);
 
		preferred_x = Clamp(preferred_x,
 
				left - UnScaleGUI(real_spritef->x_offs) + ScaleGUITrad(14),
 
				right - UnScaleGUI(real_spriter->width) - UnScaleGUI(real_spriter->x_offs) - ScaleGUITrad(15));
 

	
 
		DrawSprite(spritef, pal, preferred_x - ScaleGUITrad(14), yf);
 
		DrawSprite(spriter, pal, preferred_x + ScaleGUITrad(15), yr);
 
	} else {
 
		SpriteID sprite = GetRailIcon(engine, false, y, image_type);
 
		const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
		preferred_x = Clamp(preferred_x, left - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI), right - UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI) - UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI));
 
		preferred_x = Clamp(preferred_x,
 
				left - UnScaleGUI(real_sprite->x_offs),
 
				right - UnScaleGUI(real_sprite->width) - UnScaleGUI(real_sprite->x_offs));
 
		DrawSprite(sprite, pal, preferred_x, y);
 
	}
 
}
 

	
 
/**
 
 * Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
 
@@ -563,26 +567,26 @@ void GetTrainSpriteSize(EngineID engine,
 
{
 
	int y = 0;
 

	
 
	SpriteID sprite = GetRailIcon(engine, false, y, image_type);
 
	const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
	width  = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI);
 
	height = UnScaleByZoom(real_sprite->height, ZOOM_LVL_GUI);
 
	xoffs  = UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI);
 
	yoffs  = UnScaleByZoom(real_sprite->y_offs, ZOOM_LVL_GUI);
 
	width  = UnScaleGUI(real_sprite->width);
 
	height = UnScaleGUI(real_sprite->height);
 
	xoffs  = UnScaleGUI(real_sprite->x_offs);
 
	yoffs  = UnScaleGUI(real_sprite->y_offs);
 

	
 
	if (RailVehInfo(engine)->railveh_type == RAILVEH_MULTIHEAD) {
 
		sprite = GetRailIcon(engine, true, y, image_type);
 
		real_sprite = GetSprite(sprite, ST_NORMAL);
 

	
 
		/* Calculate values relative to an imaginary center between the two sprites. */
 
		width = UnScaleByZoom(TRAININFO_DEFAULT_VEHICLE_WIDTH * 4, ZOOM_LVL_GUI) + UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI) + UnScaleByZoom(real_sprite->x_offs, ZOOM_LVL_GUI) - xoffs;
 
		height = max<uint>(height, UnScaleByZoom(real_sprite->height, ZOOM_LVL_GUI));
 
		xoffs  = xoffs - UnScaleByZoom(TRAININFO_DEFAULT_VEHICLE_WIDTH * 4, ZOOM_LVL_GUI) / 2;
 
		yoffs  = min(yoffs, UnScaleByZoom(real_sprite->y_offs, ZOOM_LVL_GUI));
 
		width = ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) + UnScaleGUI(real_sprite->width) + UnScaleGUI(real_sprite->x_offs) - xoffs;
 
		height = max<uint>(height, UnScaleGUI(real_sprite->height));
 
		xoffs  = xoffs - ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) / 2;
 
		yoffs  = min(yoffs, UnScaleGUI(real_sprite->y_offs));
 
	}
 
}
 

	
 
/**
 
 * Build a railroad wagon.
 
 * @param tile     tile of the depot where rail-vehicle is built.
src/train_gui.cpp
Show inline comments
 
@@ -71,13 +71,13 @@ static int HighlightDragPosition(int px,
 
	int drag_hlight_left = rtl ? max(px -dragged_width, 0) : px;
 
	int drag_hlight_right = rtl ? px : min(px + dragged_width, max_width);
 
	int drag_hlight_width = max(drag_hlight_right - drag_hlight_left, 0);
 

	
 
	if (drag_hlight_width > 0) {
 
		GfxFillRect(drag_hlight_left + WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP + 1,
 
				drag_hlight_right - WD_FRAMERECT_RIGHT, UnScaleByZoom(4 * 13, ZOOM_LVL_GUI) - WD_FRAMERECT_BOTTOM, _colour_gradient[COLOUR_GREY][7]);
 
				drag_hlight_right - WD_FRAMERECT_RIGHT, ScaleGUITrad(13) - WD_FRAMERECT_BOTTOM, _colour_gradient[COLOUR_GREY][7]);
 
	}
 

	
 
	return drag_hlight_width;
 
}
 

	
 
/**
 
@@ -97,13 +97,13 @@ void DrawTrainImage(const Train *v, int 
 

	
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	/* Position of highlight box */
 
	int highlight_l = 0;
 
	int highlight_r = 0;
 
	int max_width = right - left + 1;
 
	int height = UnScaleByZoom(4 * 14, ZOOM_LVL_GUI);
 
	int height = ScaleGUITrad(14);
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &tmp_dpi;
 

	
 
@@ -352,13 +352,13 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
 */
 
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
 
{
 
	/* get rid of awkward offset */
 
	y -= WD_MATRIX_TOP;
 

	
 
	int sprite_height = UnScaleByZoom(4 * GetVehicleHeight(VEH_TRAIN), ZOOM_LVL_GUI);
 
	int sprite_height = ScaleGUITrad(GetVehicleHeight(VEH_TRAIN));
 
	int line_height = max(sprite_height, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
 
	int sprite_y_offset = line_height / 2;
 
	int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2;
 

	
 
	/* draw the first 3 details tabs */
 
	if (det_tab != TDW_TAB_TOTALS) {
 
@@ -376,31 +376,31 @@ void DrawTrainDetails(const Train *v, in
 
				Point offset;
 
				int width = u->GetDisplayImageWidth(&offset);
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					int pitch = 0;
 
					const Engine *e = Engine::Get(v->engine_type);
 
					if (e->GetGRF() != NULL) {
 
						pitch = UnScaleByZoom(4 * e->GetGRF()->traininfo_vehicle_pitch, ZOOM_LVL_GUI);
 
						pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
 
					}
 
					PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
					DrawSprite(u->GetImage(dir, EIT_IN_DETAILS), pal, px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + pitch);
 
				}
 
				px += rtl ? -width : width;
 
				dx += width;
 
				u = u->Next();
 
			} while (u != NULL && u->IsArticulatedPart());
 

	
 
			bool separate_sprite_row = (dx > (uint)UnScaleByZoom(4 * TRAIN_DETAILS_MAX_INDENT, ZOOM_LVL_GUI));
 
			bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
 
			if (separate_sprite_row) {
 
				vscroll_pos--;
 
				dx = 0;
 
			}
 

	
 
			uint num_lines = max(1u, _cargo_summary.Length());
 
			for (uint i = 0; i < num_lines; i++) {
 
				int sprite_width = max<int>(dx, UnScaleByZoom(4 * TRAIN_DETAILS_MIN_INDENT, ZOOM_LVL_GUI)) + 3;
 
				int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3;
 
				int data_left  = left + (rtl ? 0 : sprite_width);
 
				int data_right = right - (rtl ? sprite_width : 0);
 
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
 
					int py = y - line_height * vscroll_pos + text_y_offset;
 
					if (i > 0 || separate_sprite_row) {
 
						if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
src/vehicle_gui.cpp
Show inline comments
 
@@ -662,13 +662,13 @@ struct RefitWindow : public Window {
 
			case WID_VR_MATRIX:
 
				resize->height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
 
				size->height = resize->height * 8;
 
				break;
 

	
 
			case WID_VR_VEHICLE_PANEL_DISPLAY:
 
				size->height = UnScaleByZoom(4 * GetVehicleHeight(Vehicle::Get(this->window_number)->type), ZOOM_LVL_GUI);
 
				size->height = ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type));
 
				break;
 

	
 
			case WID_VR_INFO:
 
				size->width = WD_FRAMERECT_LEFT + this->information_width + WD_FRAMERECT_RIGHT;
 
				break;
 
		}
 
@@ -759,13 +759,13 @@ struct RefitWindow : public Window {
 
								if (_current_text_dir == TD_RTL) {
 
									right = this->GetWidget<NWidgetCore>(WID_VR_VEHICLE_PANEL_DISPLAY)->current_x - left;
 
									left = right - width;
 
								}
 

	
 
								if (left != right) {
 
									DrawFrameRect(left, r.top + WD_FRAMERECT_TOP, right, r.top + WD_FRAMERECT_TOP + UnScaleByZoom(4 * 14, ZOOM_LVL_GUI) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
									DrawFrameRect(left, r.top + WD_FRAMERECT_TOP, right, r.top + WD_FRAMERECT_TOP + ScaleGUITrad(14) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
								}
 

	
 
								left = INT32_MIN;
 
							}
 

	
 
							int current_width = u->GetDisplayImageWidth();
 
@@ -1286,14 +1286,14 @@ static const NWidgetPart _nested_vehicle
 
static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, VehicleOrderID start = 0)
 
{
 
	const Order *order = v->GetOrder(start);
 
	if (order == NULL) return;
 

	
 
	bool rtl = _current_text_dir == TD_RTL;
 
	int l_offset = rtl ? 0 : UnScaleByZoom(4 * 6, ZOOM_LVL_GUI);
 
	int r_offset = rtl ? UnScaleByZoom(4 * 6, ZOOM_LVL_GUI) : 0;
 
	int l_offset = rtl ? 0 : ScaleGUITrad(6);
 
	int r_offset = rtl ? ScaleGUITrad(6) : 0;
 
	int i = 0;
 
	VehicleOrderID oid = start;
 

	
 
	do {
 
		if (oid == v->cur_real_order_index) DrawString(left, right, y, STR_TINY_RIGHT_ARROW, TC_BLACK);
 

	
 
@@ -1340,13 +1340,13 @@ void DrawVehicleImage(const Vehicle *v, 
 
 * @param divisor the resulting height must be dividable by this
 
 * @return the height
 
 */
 
uint GetVehicleListHeight(VehicleType type, uint divisor)
 
{
 
	/* Name + vehicle + profit */
 
	uint base = UnScaleByZoom(4 * GetVehicleHeight(type), ZOOM_LVL_GUI) + 2 * FONT_HEIGHT_SMALL;
 
	uint base = ScaleGUITrad(GetVehicleHeight(type)) + 2 * FONT_HEIGHT_SMALL;
 
	/* Drawing of the 4 small orders + profit*/
 
	if (type >= VEH_SHIP) base = max(base, 5U * FONT_HEIGHT_SMALL);
 

	
 
	if (divisor == 1) return base;
 

	
 
	/* Make sure the height is dividable by divisor */
 
@@ -1369,14 +1369,14 @@ void BaseVehicleListWindow::DrawVehicleL
 

	
 
	int text_offset = max<int>(GetSpriteSize(SPR_PROFIT_LOT).width, GetDigitWidth() * this->unitnumber_digits) + WD_FRAMERECT_RIGHT;
 
	int text_left  = left  + (rtl ?           0 : text_offset);
 
	int text_right = right - (rtl ? text_offset :           0);
 

	
 
	bool show_orderlist = this->vli.vtype >= VEH_SHIP;
 
	int orderlist_left  = left  + (rtl ? 0 : max(UnScaleByZoom(4 * 100, ZOOM_LVL_GUI) + text_offset, width / 2));
 
	int orderlist_right = right - (rtl ? max(UnScaleByZoom(4 * 100, ZOOM_LVL_GUI) + text_offset, width / 2) : 0);
 
	int orderlist_left  = left  + (rtl ? 0 : max(ScaleGUITrad(100) + text_offset, width / 2));
 
	int orderlist_right = right - (rtl ? max(ScaleGUITrad(100) + text_offset, width / 2) : 0);
 

	
 
	int image_left  = (rtl && show_orderlist) ? orderlist_right : text_left;
 
	int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
 

	
 
	int vehicle_button_x = rtl ? right - GetSpriteSize(SPR_PROFIT_LOT).width : left;
 

	
 
@@ -1906,13 +1906,13 @@ struct VehicleDetailsWindow : Window {
 
	 */
 
	uint GetRoadVehDetailsHeight(const Vehicle *v)
 
	{
 
		uint desired_height;
 
		if (v->HasArticulatedPart()) {
 
			/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
 
			desired_height = WD_FRAMERECT_TOP + UnScaleByZoom(4 * 15, ZOOM_LVL_GUI) + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
 
			desired_height = WD_FRAMERECT_TOP + ScaleGUITrad(15) + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
 
			/* Add space for the cargo amount for each part. */
 
			for (const Vehicle *u = v; u != NULL; u = u->Next()) {
 
				if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL + 1;
 
			}
 
		} else {
 
			desired_height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + 3 + WD_FRAMERECT_BOTTOM;
 
@@ -1963,13 +1963,13 @@ struct VehicleDetailsWindow : Window {
 
						NOT_REACHED(); // Train uses WID_VD_MATRIX instead.
 
				}
 
				break;
 
			}
 

	
 
			case WID_VD_MATRIX:
 
				resize->height = max(UnScaleByZoom(4 * 14, ZOOM_LVL_GUI), WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
 
				resize->height = max(ScaleGUITrad(14), WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM);
 
				size->height = 4 * resize->height;
 
				break;
 

	
 
			case WID_VD_SERVICE_INTERVAL_DROPDOWN: {
 
				StringID *strs = _service_interval_dropdown;
 
				while (*strs != INVALID_STRING_ID) {
 
@@ -2090,13 +2090,15 @@ struct VehicleDetailsWindow : Window {
 
				DrawVehicleDetails(v, r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, r.top + WD_MATRIX_TOP, this->vscroll->GetPosition(), this->vscroll->GetCapacity(), this->tab);
 
				break;
 

	
 
			case WID_VD_MIDDLE_DETAILS: {
 
				/* For other vehicles, at the place of the matrix. */
 
				bool rtl = _current_text_dir == TD_RTL;
 
				uint sprite_width = max<uint>(UnScaleByZoom(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, ZOOM_LVL_GUI), 70U) + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
				uint sprite_width = UnScaleGUI(
 
						max<uint>(GetSprite(v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DETAILS), ST_NORMAL)->width, 70U)) +
 
						WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 

	
 
				uint text_left  = r.left  + (rtl ? 0 : sprite_width);
 
				uint text_right = r.right - (rtl ? sprite_width : 0);
 

	
 
				/* Articulated road vehicles use a complete line. */
 
				if (v->type == VEH_ROAD && v->HasArticulatedPart()) {
 
@@ -2842,13 +2844,13 @@ int GetVehicleWidth(Vehicle *v, EngineIm
 
			break;
 

	
 
		default:
 
			bool rtl = _current_text_dir == TD_RTL;
 
			SpriteID sprite = v->GetImage(rtl ? DIR_E : DIR_W, image_type);
 
			const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL);
 
			vehicle_width = UnScaleByZoom(real_sprite->width, ZOOM_LVL_GUI);
 
			vehicle_width = UnScaleGUI(real_sprite->width);
 

	
 
			break;
 
	}
 

	
 
	return vehicle_width;
 
}
src/zoom_func.h
Show inline comments
 
@@ -61,7 +61,27 @@ static inline int ScaleByZoomLower(int v
 
static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
 
{
 
	assert(zoom >= 0);
 
	return value >> zoom;
 
}
 

	
 
/**
 
 * Short-hand to apply GUI zoom level.
 
 * @param value Pixel amount at #ZOOM_LVL_BEGIN (full zoom in).
 
 * @return value Pixel amount at #ZOOM_LVL_GUI.
 
 */
 
static inline int UnScaleGUI(int value)
 
{
 
	return UnScaleByZoom(value, ZOOM_LVL_GUI);
 
}
 

	
 
/**
 
 * Scale traditional pixel dimensions to GUI zoom level.
 
 * @param value Pixel amount at 1x zoom level.
 
 * @return value Pixel amount at #ZOOM_LVL_GUI.
 
 */
 
static inline int ScaleGUITrad(int value)
 
{
 
	return UnScaleGUI(value * ZOOM_LVL_BASE);
 
}
 

	
 
#endif /* ZOOM_FUNC_H */
src/zoom_type.h
Show inline comments
 
@@ -49,9 +49,10 @@ enum ZoomLevel {
 
};
 
DECLARE_POSTFIX_INCREMENT(ZoomLevel)
 

	
 
/** Type for storing the zoom level in a byte. */
 
typedef SimpleTinyEnumT<ZoomLevel, byte> ZoomLevelByte;
 

	
 
extern ZoomLevelByte _gui_zoom;
 
#define ZOOM_LVL_GUI (_gui_zoom)
 

	
 
#endif /* ZOOM_TYPE_H */
0 comments (0 inline, 0 general)