Changeset - r26579:321856031c47
[Not reviewed]
master
0 19 0
Peter Nelson - 2 years ago 2022-09-05 20:05:18
peter1138@openttd.org
Change: Use power-of-2 scaling for some dimensions in GUI.

These are related to drawing sprites that are normally drawn on the
landscape, and should therefore still follow power-of-2 scaling to fit
correctly.
19 files changed with 89 insertions and 79 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -231,7 +231,7 @@ void DrawAircraftEngine(int left, int ri
 
		VehicleSpriteSeq rotor_seq;
 
		GetCustomRotorIcon(engine, image_type, &rotor_seq);
 
		if (!rotor_seq.IsValid()) rotor_seq.Set(SPR_ROTOR_STOPPED);
 
		rotor_seq.Draw(preferred_x, y - ScaleGUITrad(5), PAL_NONE, false);
 
		rotor_seq.Draw(preferred_x, y - ScaleSpriteTrad(5), PAL_NONE, false);
 
	}
 
}
 

	
src/aircraft_gui.cpp
Show inline comments
 
@@ -93,7 +93,7 @@ void DrawAircraftImage(const Vehicle *v,
 
	int x = rtl ? right - width - x_offs : left - x_offs;
 
	bool helicopter = v->subtype == AIR_HELICOPTER;
 

	
 
	int y_offs = ScaleGUITrad(10);
 
	int y_offs = ScaleSpriteTrad(10);
 
	int heli_offs = 0;
 

	
 
	PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
@@ -103,7 +103,7 @@ void DrawAircraftImage(const Vehicle *v,
 
		VehicleSpriteSeq rotor_seq;
 
		GetCustomRotorSprite(a, image_type, &rotor_seq);
 
		if (!rotor_seq.IsValid()) rotor_seq.Set(SPR_ROTOR_STOPPED);
 
		heli_offs = ScaleGUITrad(5);
 
		heli_offs = ScaleSpriteTrad(5);
 
		rotor_seq.Draw(x, y + y_offs - heli_offs, PAL_NONE, false);
 
	}
 
	if (v->index == selection) {
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -977,7 +977,7 @@ void DrawEngineList(VehicleType type, co
 

	
 
	Rect ir      = r.WithHeight(step_size).Shrink(WidgetDimensions::scaled.matrix);
 
	int sprite_x = ir.WithWidth(sprite_width, rtl).left + sprite_left;
 
	int sprite_y_offset = ScaleGUITrad(sprite_y_offsets[type]) + ir.Height() / 2;
 
	int sprite_y_offset = ScaleSpriteTrad(sprite_y_offsets[type]) + ir.Height() / 2;
 

	
 
	Dimension replace_icon = {0, 0};
 
	int count_width = 0;
src/depot_gui.cpp
Show inline comments
 
@@ -190,17 +190,17 @@ static void InitBlocksizeForVehicles(Veh
 
		if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
 
	}
 

	
 
	int min_extend = ScaleGUITrad(16);
 
	int max_extend = ScaleGUITrad(98);
 
	int min_extend = ScaleSpriteTrad(16);
 
	int max_extend = ScaleSpriteTrad(98);
 

	
 
	switch (image_type) {
 
		case EIT_IN_DEPOT:
 
			_base_block_sizes_depot[type].height       = std::max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
 
			_base_block_sizes_depot[type].height       = std::max<uint>(ScaleSpriteTrad(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       = std::max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
 
			_base_block_sizes_purchase[type].height       = std::max<uint>(ScaleSpriteTrad(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;
 
@@ -310,7 +310,7 @@ struct DepotWindow : Window {
 
	void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
 
	{
 
		bool free_wagon = false;
 
		int sprite_y = y + (this->resize.step_height - ScaleGUITrad(GetVehicleHeight(v->type))) / 2;
 
		int sprite_y = y + (this->resize.step_height - ScaleSpriteTrad(GetVehicleHeight(v->type))) / 2;
 

	
 
		bool rtl = _current_text_dir == TD_RTL;
 
		int image_left  = rtl ? left  + this->count_width  : left  + this->header_width;
 
@@ -322,7 +322,7 @@ struct DepotWindow : Window {
 
				free_wagon = u->IsFreeWagon();
 

	
 
				uint x_space = free_wagon ?
 
						ScaleGUITrad(_consistent_train_width != 0 ? _consistent_train_width : TRAININFO_DEFAULT_VEHICLE_WIDTH) :
 
						ScaleSpriteTrad(_consistent_train_width != 0 ? _consistent_train_width : TRAININFO_DEFAULT_VEHICLE_WIDTH) :
 
						0;
 

	
 
				DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y,
 
@@ -381,7 +381,7 @@ struct DepotWindow : Window {
 
		 *  - All vehicles are 8/8. This cannot be checked for NewGRF, so instead we check for "all vehicles are original vehicles".
 
		 */
 
		if (this->type == VEH_TRAIN && _consistent_train_width != 0) {
 
			int w = ScaleGUITrad(2 * _consistent_train_width);
 
			int w = ScaleSpriteTrad(2 * _consistent_train_width);
 
			int col = _colour_gradient[wid->colour][4];
 
			int image_left  = rtl ? ir.left  + this->count_width  : ir.left  + this->header_width;
 
			int image_right = rtl ? ir.right - this->header_width : ir.right - this->count_width;
 
@@ -486,7 +486,7 @@ struct DepotWindow : Window {
 
			pos -= (uint)this->vehicle_list.size();
 
			*veh = this->wagon_list[pos];
 
			/* free wagons don't have an initial loco. */
 
			x -= ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			x -= ScaleSpriteTrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			wagon = true;
 
		}
 

	
 
@@ -682,7 +682,7 @@ struct DepotWindow : Window {
 
				resize->height = std::max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
 
				if (this->type == VEH_TRAIN) {
 
					resize->width = 1;
 
					size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts
 
					size->width = base_width + 2 * ScaleSpriteTrad(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;
 
@@ -725,7 +725,7 @@ struct DepotWindow : Window {
 

	
 
		/* determine amount of items for scroller */
 
		if (this->type == VEH_TRAIN) {
 
			uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			uint max_width = ScaleSpriteTrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			for (uint num = 0; num < this->vehicle_list.size(); num++) {
 
				uint width = 0;
 
				for (const Train *v = Train::From(this->vehicle_list[num]); v != nullptr; v = v->Next()) {
 
@@ -736,7 +736,7 @@ struct DepotWindow : Window {
 
			/* Always have 1 empty row, so people can change the setting of the train */
 
			this->vscroll->SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
 
			/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
 
			this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
 
			this->hscroll->SetCount(max_width + ScaleSpriteTrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
 
		} else {
 
			this->vscroll->SetCount(CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
 
		}
src/dock_gui.cpp
Show inline comments
 
@@ -549,12 +549,12 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = (r.Width()  - ScaleGUITrad(96)) / 2;
 
					int y = (r.Height() - ScaleGUITrad(64)) / 2;
 
					int x1 = ScaleGUITrad(63);
 
					int x2 = ScaleGUITrad(31);
 
					DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleGUITrad(17), axis, DEPOT_PART_NORTH);
 
					DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleGUITrad(33), axis, DEPOT_PART_SOUTH);
 
					int x = (r.Width()  - ScaleSpriteTrad(96)) / 2;
 
					int y = (r.Height() - ScaleSpriteTrad(64)) / 2;
 
					int x1 = ScaleSpriteTrad(63);
 
					int x2 = ScaleSpriteTrad(31);
 
					DrawShipDepotSprite(x + (axis == AXIS_X ? x1 : x2), y + ScaleSpriteTrad(17), axis, DEPOT_PART_NORTH);
 
					DrawShipDepotSprite(x + (axis == AXIS_X ? x2 : x1), y + ScaleSpriteTrad(33), axis, DEPOT_PART_SOUTH);
 
					_cur_dpi = old_dpi;
 
				}
 
				break;
src/highscore_gui.cpp
Show inline comments
 
@@ -133,7 +133,7 @@ struct EndGameWindow : EndGameHighScoreB
 
	void OnPaint() override
 
	{
 
		this->SetupHighScoreEndWindow();
 
		Point pt = this->GetTopLeft(ScaleGUITrad(640), ScaleGUITrad(480));
 
		Point pt = this->GetTopLeft(ScaleSpriteTrad(640), ScaleSpriteTrad(480));
 

	
 
		const Company *c = Company::GetIfValid(_local_company);
 
		if (c == nullptr) return;
 
@@ -144,11 +144,11 @@ struct EndGameWindow : EndGameHighScoreB
 
			SetDParam(0, c->index);
 
			SetDParam(1, c->index);
 
			SetDParam(2, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
 
			DrawStringMultiLine(pt.x + ScaleGUITrad(15), pt.x + ScaleGUITrad(640) - ScaleGUITrad(25), pt.y + ScaleGUITrad(90), pt.y + ScaleGUITrad(160), STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(pt.x + ScaleSpriteTrad(15), pt.x + ScaleSpriteTrad(640) - ScaleSpriteTrad(25), pt.y + ScaleSpriteTrad(90), pt.y + ScaleSpriteTrad(160), STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS, TC_FROMSTRING, SA_CENTER);
 
		} else {
 
			SetDParam(0, c->index);
 
			SetDParam(1, EndGameGetPerformanceTitleFromValue(c->old_economy[0].performance_history));
 
			DrawStringMultiLine(pt.x + ScaleGUITrad(36), pt.x + ScaleGUITrad(640), pt.y + ScaleGUITrad(140), pt.y + ScaleGUITrad(206), STR_HIGHSCORE_COMPANY_ACHIEVES_STATUS, TC_FROMSTRING, SA_CENTER);
 
			DrawStringMultiLine(pt.x + ScaleSpriteTrad(36), pt.x + ScaleSpriteTrad(640), pt.y + ScaleSpriteTrad(140), pt.y + ScaleSpriteTrad(206), STR_HIGHSCORE_COMPANY_ACHIEVES_STATUS, TC_FROMSTRING, SA_CENTER);
 
		}
 
	}
 
};
 
@@ -185,24 +185,24 @@ struct HighScoreWindow : EndGameHighScor
 
		const HighScore *hs = _highscore_table[this->window_number];
 

	
 
		this->SetupHighScoreEndWindow();
 
		Point pt = this->GetTopLeft(ScaleGUITrad(640), ScaleGUITrad(480));
 
		Point pt = this->GetTopLeft(ScaleSpriteTrad(640), ScaleSpriteTrad(480));
 

	
 
		SetDParam(0, _settings_game.game_creation.ending_year);
 
		DrawStringMultiLine(pt.x + ScaleGUITrad(70), pt.x + ScaleGUITrad(570), pt.y, pt.y + ScaleGUITrad(140), !_networking ? STR_HIGHSCORE_TOP_COMPANIES_WHO_REACHED : STR_HIGHSCORE_TOP_COMPANIES_NETWORK_GAME, TC_FROMSTRING, SA_CENTER);
 
		DrawStringMultiLine(pt.x + ScaleSpriteTrad(70), pt.x + ScaleSpriteTrad(570), pt.y, pt.y + ScaleSpriteTrad(140), !_networking ? STR_HIGHSCORE_TOP_COMPANIES_WHO_REACHED : STR_HIGHSCORE_TOP_COMPANIES_NETWORK_GAME, TC_FROMSTRING, SA_CENTER);
 

	
 
		/* Draw Highscore peepz */
 
		for (uint8 i = 0; i < lengthof(_highscore_table[0]); i++) {
 
			SetDParam(0, i + 1);
 
			DrawString(pt.x + ScaleGUITrad(40), pt.x + ScaleGUITrad(600), pt.y + ScaleGUITrad(140 + i * 55), STR_HIGHSCORE_POSITION);
 
			DrawString(pt.x + ScaleSpriteTrad(40), pt.x + ScaleSpriteTrad(600), pt.y + ScaleSpriteTrad(140 + i * 55), STR_HIGHSCORE_POSITION);
 

	
 
			if (hs[i].company[0] != '\0') {
 
				TextColour colour = (this->rank == i) ? TC_RED : TC_BLACK; // draw new highscore in red
 

	
 
				SetDParamStr(0, hs[i].company);
 
				DrawString(pt.x + ScaleGUITrad(71), pt.x + ScaleGUITrad(569), pt.y + ScaleGUITrad(140 + i * 55), STR_JUST_BIG_RAW_STRING, colour);
 
				DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140 + i * 55), STR_JUST_BIG_RAW_STRING, colour);
 
				SetDParam(0, hs[i].title);
 
				SetDParam(1, hs[i].score);
 
				DrawString(pt.x + ScaleGUITrad(71), pt.x + ScaleGUITrad(569), pt.y + ScaleGUITrad(140) + FONT_HEIGHT_LARGE + ScaleGUITrad(i * 55), STR_HIGHSCORE_STATS, colour);
 
				DrawString(pt.x + ScaleSpriteTrad(71), pt.x + ScaleSpriteTrad(569), pt.y + ScaleSpriteTrad(140) + FONT_HEIGHT_LARGE + ScaleSpriteTrad(i * 55), STR_HIGHSCORE_STATS, colour);
 
			}
 
		}
 
	}
src/object_gui.cpp
Show inline comments
 
@@ -360,9 +360,9 @@ public:
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec, GB(widget, 16, 16));
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
 
					}
 
					_cur_dpi = old_dpi;
 
				}
 
@@ -387,9 +387,9 @@ public:
 
					if (spec->grf_prop.grffile == nullptr) {
 
						extern const DrawTileSprites _objects[];
 
						const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), dts, PAL_NONE);
 
						DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
 
					} else {
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleGUITrad(TILE_PIXELS), spec,
 
						DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), spec,
 
								std::min<int>(_selected_object_view, spec->views - 1));
 
					}
 
					_cur_dpi = old_dpi;
src/rail_gui.cpp
Show inline comments
 
@@ -1257,8 +1257,8 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
					int y = (r.Height() + ScaleGUITrad(58)) / 2 - ScaleGUITrad(31);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(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);
 
					}
 
@@ -1271,8 +1271,8 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
					int y = (r.Height() + ScaleGUITrad(58)) / 2 - ScaleGUITrad(31);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(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);
 
					}
 
@@ -1308,8 +1308,8 @@ public:
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
					int y = (r.Height() + ScaleGUITrad(58)) / 2 - ScaleGUITrad(31);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(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);
 
					}
 
@@ -1942,8 +1942,8 @@ struct BuildRailDepotWindow : public Pic
 
		if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
			DrawPixelInfo *old_dpi = _cur_dpi;
 
			_cur_dpi = &tmp_dpi;
 
			int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
			int y = (r.Height() + ScaleGUITrad(48)) / 2 - ScaleGUITrad(31);
 
			int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
			DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
 
			_cur_dpi = old_dpi;
 
		}
 
@@ -2054,8 +2054,8 @@ struct BuildRailWaypointWindow : PickerW
 
				if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
					DrawPixelInfo *old_dpi = _cur_dpi;
 
					_cur_dpi = &tmp_dpi;
 
					int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
					int y = (r.Height() + ScaleGUITrad(58)) / 2 - ScaleGUITrad(31);
 
					int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
					int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
 
					DrawWaypointSprite(x, y, type, _cur_railtype);
 
					_cur_dpi = old_dpi;
 
				}
src/road_gui.cpp
Show inline comments
 
@@ -986,8 +986,8 @@ struct BuildRoadDepotWindow : public Pic
 
		if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
			DrawPixelInfo *old_dpi = _cur_dpi;
 
			_cur_dpi = &tmp_dpi;
 
			int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
			int y = (r.Height() + ScaleGUITrad(48)) / 2 - ScaleGUITrad(31);
 
			int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
			DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
 
			_cur_dpi = old_dpi;
 
		}
 
@@ -1121,8 +1121,8 @@ struct BuildRoadStationWindow : public P
 
		if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
 
			DrawPixelInfo *old_dpi = _cur_dpi;
 
			_cur_dpi = &tmp_dpi;
 
			int x = (r.Width()  - ScaleGUITrad(64)) / 2 + ScaleGUITrad(31);
 
			int y = (r.Height() + ScaleGUITrad(48)) / 2 - ScaleGUITrad(31);
 
			int x = (r.Width()  - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
 
			int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
 
			StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
 
			_cur_dpi = old_dpi;
 
		}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -94,10 +94,10 @@ int RoadVehicle::GetDisplayImageWidth(Po
 
	int reference_width = ROADVEHINFO_DEFAULT_VEHICLE_WIDTH;
 

	
 
	if (offset != nullptr) {
 
		offset->x = ScaleGUITrad(reference_width) / 2;
 
		offset->x = ScaleSpriteTrad(reference_width) / 2;
 
		offset->y = 0;
 
	}
 
	return ScaleGUITrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
	return ScaleSpriteTrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
}
 

	
 
static void GetRoadVehIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result)
src/roadveh_gui.cpp
Show inline comments
 
@@ -27,7 +27,7 @@
 
 */
 
void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
 
{
 
	int y = r.top + (v->HasArticulatedPart() ? ScaleGUITrad(15) : 0); // Draw the first line below the sprite of an articulated RV instead of after it.
 
	int y = r.top + (v->HasArticulatedPart() ? ScaleSpriteTrad(15) : 0); // Draw the first line below the sprite of an articulated RV instead of after it.
 
	StringID str;
 
	Money feeder_share = 0;
 

	
 
@@ -135,7 +135,7 @@ void DrawRoadVehImage(const Vehicle *v, 
 
	DrawPixelInfo tmp_dpi, *old_dpi;
 
	int max_width = right - left + 1;
 

	
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, ScaleGUITrad(14))) return;
 
	if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, ScaleSpriteTrad(14))) return;
 

	
 
	old_dpi = _cur_dpi;
 
	_cur_dpi = &tmp_dpi;
 
@@ -149,14 +149,14 @@ void DrawRoadVehImage(const Vehicle *v, 
 
			PaletteID pal = (u->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(u);
 
			VehicleSpriteSeq seq;
 
			u->GetImage(dir, image_type, &seq);
 
			seq.Draw(px + (rtl ? -offset.x : offset.x), ScaleGUITrad(6) + offset.y, pal, (u->vehstatus & VS_CRASHED) != 0);
 
			seq.Draw(px + (rtl ? -offset.x : offset.x), ScaleSpriteTrad(6) + offset.y, pal, (u->vehstatus & VS_CRASHED) != 0);
 
		}
 

	
 
		px += rtl ? -width : width;
 
	}
 

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

	
 
	_cur_dpi = old_dpi;
src/ship_gui.cpp
Show inline comments
 
@@ -43,7 +43,7 @@ void DrawShipImage(const Vehicle *v, int
 
	int x_offs = UnScaleGUI(rect.left);
 
	int x = rtl ? right - width - x_offs : left - x_offs;
 

	
 
	y += ScaleGUITrad(10);
 
	y += ScaleSpriteTrad(10);
 
	seq.Draw(x, y, GetVehiclePalette(v), false);
 

	
 
	if (v->index == selection) {
src/sprite.cpp
Show inline comments
 
@@ -125,7 +125,7 @@ void DrawCommonTileSeqInGUI(int x, int y
 
		} 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 + ScaleGUITrad(offs_x), y + child_offset.y + ScaleGUITrad(offs_y));
 
			DrawSprite(image, pal, x + child_offset.x + ScaleSpriteTrad(offs_x), y + child_offset.y + ScaleSpriteTrad(offs_y));
 
		}
 
	}
 
}
src/station_gui.cpp
Show inline comments
 
@@ -811,7 +811,7 @@ static const NWidgetPart _nested_station
 
 */
 
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int y)
 
{
 
	int width = ScaleGUITrad(10);
 
	int width = ScaleSpriteTrad(10);
 
	uint num = std::min<uint>((waiting + (width / 2)) / width, (right - left) / width); // maximum is width / 10 icons so it won't overflow
 
	if (num == 0) return;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -451,10 +451,10 @@ int Train::GetDisplayImageWidth(Point *o
 
	}
 

	
 
	if (offset != nullptr) {
 
		offset->x = ScaleGUITrad(reference_width) / 2;
 
		offset->y = ScaleGUITrad(vehicle_pitch);
 
		offset->x = ScaleSpriteTrad(reference_width) / 2;
 
		offset->y = ScaleSpriteTrad(vehicle_pitch);
 
	}
 
	return ScaleGUITrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
	return ScaleSpriteTrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH);
 
}
 

	
 
static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction)
 
@@ -500,7 +500,7 @@ static void GetRailIcon(EngineID engine,
 
		GetCustomVehicleIcon(engine, dir, image_type, result);
 
		if (result->IsValid()) {
 
			if (e->GetGRF() != nullptr) {
 
				y += ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
 
				y += ScaleSpriteTrad(e->GetGRF()->traininfo_vehicle_pitch);
 
			}
 
			return;
 
		}
 
@@ -528,11 +528,11 @@ void DrawTrainEngine(int left, int right
 
		seqr.GetBounds(&rectr);
 

	
 
		preferred_x = Clamp(preferred_x,
 
				left - UnScaleGUI(rectf.left) + ScaleGUITrad(14),
 
				right - UnScaleGUI(rectr.right) - ScaleGUITrad(15));
 

	
 
		seqf.Draw(preferred_x - ScaleGUITrad(14), yf, pal, pal == PALETTE_CRASH);
 
		seqr.Draw(preferred_x + ScaleGUITrad(15), yr, pal, pal == PALETTE_CRASH);
 
				left - UnScaleGUI(rectf.left) + ScaleSpriteTrad(14),
 
				right - UnScaleGUI(rectr.right) - ScaleSpriteTrad(15));
 

	
 
		seqf.Draw(preferred_x - ScaleSpriteTrad(14), yf, pal, pal == PALETTE_CRASH);
 
		seqr.Draw(preferred_x + ScaleSpriteTrad(15), yr, pal, pal == PALETTE_CRASH);
 
	} else {
 
		VehicleSpriteSeq seq;
 
		GetRailIcon(engine, false, y, image_type, &seq);
 
@@ -576,9 +576,9 @@ void GetTrainSpriteSize(EngineID engine,
 
		seq.GetBounds(&rect);
 

	
 
		/* Calculate values relative to an imaginary center between the two sprites. */
 
		width = ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) + UnScaleGUI(rect.right) - xoffs;
 
		width = ScaleSpriteTrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) + UnScaleGUI(rect.right) - xoffs;
 
		height = std::max<uint>(height, UnScaleGUI(rect.Height()));
 
		xoffs  = xoffs - ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) / 2;
 
		xoffs  = xoffs - ScaleSpriteTrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) / 2;
 
		yoffs  = std::min(yoffs, UnScaleGUI(rect.top));
 
	}
 
}
src/train_gui.cpp
Show inline comments
 
@@ -73,7 +73,7 @@ static int HighlightDragPosition(int px,
 

	
 
	if (drag_hlight_width > 0) {
 
		GfxFillRect(drag_hlight_left + WidgetDimensions::scaled.framerect.left, WidgetDimensions::scaled.framerect.top + 1,
 
				drag_hlight_right - WidgetDimensions::scaled.framerect.right, ScaleGUITrad(13) - WidgetDimensions::scaled.framerect.bottom, _colour_gradient[COLOUR_GREY][7]);
 
				drag_hlight_right - WidgetDimensions::scaled.framerect.right, ScaleSpriteTrad(13) - WidgetDimensions::scaled.framerect.bottom, _colour_gradient[COLOUR_GREY][7]);
 
	}
 

	
 
	return drag_hlight_width;
 
@@ -99,7 +99,7 @@ void DrawTrainImage(const Train *v, int 
 
	int highlight_l = 0;
 
	int highlight_r = 0;
 
	int max_width = right - left + 1;
 
	int height = ScaleGUITrad(14);
 
	int height = ScaleSpriteTrad(14);
 

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

	
 
@@ -341,7 +341,7 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
			num += std::max(1u, (unsigned)_cargo_summary.size());
 

	
 
			uint length = GetLengthOfArticulatedVehicle(v);
 
			if (length > TRAIN_DETAILS_MAX_INDENT) num++;
 
			if (length > (uint)ScaleSpriteTrad(TRAIN_DETAILS_MAX_INDENT)) num++;
 
		}
 
	}
 

	
 
@@ -382,7 +382,7 @@ void DrawTrainDetails(const Train *v, co
 
					int pitch = 0;
 
					const Engine *e = Engine::Get(v->engine_type);
 
					if (e->GetGRF() != nullptr) {
 
						pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch);
 
						pitch = ScaleSpriteTrad(e->GetGRF()->traininfo_vehicle_pitch);
 
					}
 
					PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
					VehicleSpriteSeq seq;
 
@@ -394,13 +394,13 @@ void DrawTrainDetails(const Train *v, co
 
				u = u->Next();
 
			} while (u != nullptr && u->IsArticulatedPart());
 

	
 
			bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT));
 
			bool separate_sprite_row = (dx > (uint)ScaleSpriteTrad(TRAIN_DETAILS_MAX_INDENT));
 
			if (separate_sprite_row) {
 
				vscroll_pos--;
 
				dx = 0;
 
			}
 

	
 
			int sprite_width = std::max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + WidgetDimensions::scaled.hsep_normal;
 
			int sprite_width = std::max<int>(dx, ScaleSpriteTrad(TRAIN_DETAILS_MIN_INDENT)) + WidgetDimensions::scaled.hsep_normal;
 
			Rect dr = r.Indent(sprite_width, rtl);
 
			uint num_lines = std::max(1u, (unsigned)_cargo_summary.size());
 
			for (uint i = 0; i < num_lines; i++) {
src/vehicle_gui.cpp
Show inline comments
 
@@ -972,7 +972,7 @@ struct RefitWindow : public Window {
 
								}
 

	
 
								if (left != right) {
 
									DrawFrameRect(left, r.top + WidgetDimensions::scaled.framerect.top, right, r.top + WidgetDimensions::scaled.framerect.top + ScaleGUITrad(14) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
									DrawFrameRect(left, r.top + WidgetDimensions::scaled.framerect.top, right, r.top + WidgetDimensions::scaled.framerect.top + ScaleSpriteTrad(14) - 1, COLOUR_WHITE, FR_BORDERONLY);
 
								}
 

	
 
								left = INT32_MIN;
 
@@ -1647,7 +1647,7 @@ void BaseVehicleListWindow::DrawVehicleL
 

	
 
	int image_left  = (rtl && show_orderlist) ? olr.right : tr.left;
 
	int image_right = (!rtl && show_orderlist) ? olr.left : tr.right;
 
	int image_height = ScaleGUITrad(GetVehicleHeight(this->vli.vtype));
 
	int image_height = ScaleSpriteTrad(GetVehicleHeight(this->vli.vtype));
 

	
 
	int vehicle_button_x = rtl ? ir.right - profit.width : ir.left;
 

	
 
@@ -3344,7 +3344,7 @@ void SetMouseCursorVehicle(const Vehicle
 
	bool is_ground_vehicle = v->IsGroundVehicle();
 

	
 
	while (v != nullptr) {
 
		if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break;
 
		if (total_width >= ScaleSpriteTrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break;
 

	
 
		PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
 
		VehicleSpriteSeq seq;
 
@@ -3352,7 +3352,7 @@ void SetMouseCursorVehicle(const Vehicle
 
		if (rotor_seq) {
 
			GetCustomRotorSprite(Aircraft::From(v), image_type, &seq);
 
			if (!seq.IsValid()) seq.Set(SPR_ROTOR_STOPPED);
 
			y_offset = - ScaleGUITrad(5);
 
			y_offset = -ScaleSpriteTrad(5);
 
		} else {
 
			v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq);
 
		}
 
@@ -3379,7 +3379,7 @@ void SetMouseCursorVehicle(const Vehicle
 

	
 
	if (is_ground_vehicle) {
 
		/* Center trains and road vehicles on the front vehicle */
 
		int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
 
		int offs = (ScaleSpriteTrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
 
		if (rtl) offs = -offs;
 
		for (uint i = 0; i < _cursor.sprite_count; ++i) {
 
			_cursor.sprite_pos[i].x += offs;
src/widget.cpp
Show inline comments
 
@@ -786,7 +786,7 @@ static inline void DrawCloseBox(const Re
 
	Dimension d = GetSpriteSize(SPR_CLOSEBOX, &offset);
 
	d.width  -= offset.x;
 
	d.height -= offset.y;
 
	int s = ScaleGUITrad(1); /* Offset to account for shadow of SPR_CLOSEBOX */
 
	int s = ScaleSpriteTrad(1); /* Offset to account for shadow of SPR_CLOSEBOX */
 
	DrawSprite(SPR_CLOSEBOX, (colour != COLOUR_WHITE ? TC_BLACK : TC_SILVER) | (1U << PALETTE_TEXT_RECOLOUR), CenterBounds(r.left, r.right, d.width - s) - offset.x, CenterBounds(r.top, r.bottom, d.height - s) - offset.y);
 
}
 

	
src/zoom_func.h
Show inline comments
 
@@ -100,6 +100,16 @@ static inline ZoomLevel UnScaleZoomGUI(Z
 
}
 

	
 
/**
 
 * Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
 
 * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size).
 
 * @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
 
 */
 
static inline int ScaleSpriteTrad(int value)
 
{
 
	return UnScaleGUI(value * ZOOM_LVL_BASE);
 
}
 

	
 
/**
 
 * Scale traditional pixel dimensions to GUI zoom level.
 
 * @param value Pixel amount at #ZOOM_LVL_BASE (traditional "normal" interface size).
 
 * @return Pixel amount at #ZOOM_LVL_GUI (current interface size).
0 comments (0 inline, 0 general)