mirror of https://github.com/OpenTTD/OpenTTD.git
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.
This commit is contained in:
parent
062ea68422
commit
ed60c88b0a
|
@ -231,7 +231,7 @@ void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID en
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
|
|||
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, int left, int right, int y, VehicleID s
|
|||
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) {
|
||||
|
|
|
@ -977,7 +977,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList *eng_li
|
|||
|
||||
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;
|
||||
|
|
|
@ -190,17 +190,17 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -133,7 +133,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
|
|||
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 : EndGameHighScoreBaseWindow {
|
|||
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 : EndGameHighScoreBaseWindow {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 PickerWindowBase {
|
|||
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 : PickerWindowBase {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -986,8 +986,8 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
|
|||
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 PickerWindowBase {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -94,10 +94,10 @@ int RoadVehicle::GetDisplayImageWidth(Point *offset) const
|
|||
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)
|
||||
|
|
|
@ -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, int left, int right, int y, VehicleID se
|
|||
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, int left, int right, int y, VehicleID se
|
|||
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;
|
||||
|
|
|
@ -43,7 +43,7 @@ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selec
|
|||
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) {
|
||||
|
|
|
@ -125,7 +125,7 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig
|
|||
} 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -811,7 +811,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
|||
*/
|
||||
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;
|
||||
|
||||
|
|
|
@ -451,10 +451,10 @@ int Train::GetDisplayImageWidth(Point *offset) const
|
|||
}
|
||||
|
||||
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, bool rear_head, int &y, EngineImageType
|
|||
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, int preferred_x, int y, EngineID engin
|
|||
seqr.GetBounds(&rectr);
|
||||
|
||||
preferred_x = Clamp(preferred_x,
|
||||
left - UnScaleGUI(rectf.left) + ScaleGUITrad(14),
|
||||
right - UnScaleGUI(rectr.right) - ScaleGUITrad(15));
|
||||
left - UnScaleGUI(rectf.left) + ScaleSpriteTrad(14),
|
||||
right - UnScaleGUI(rectr.right) - ScaleSpriteTrad(15));
|
||||
|
||||
seqf.Draw(preferred_x - ScaleGUITrad(14), yf, pal, pal == PALETTE_CRASH);
|
||||
seqr.Draw(preferred_x + ScaleGUITrad(15), yr, pal, pal == PALETTE_CRASH);
|
||||
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, uint &width, uint &height, int &xoffs,
|
|||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection, boo
|
|||
|
||||
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 left, int right, int y, VehicleID select
|
|||
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 veh_id, TrainDetailsWindowTabs det_tab)
|
|||
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, const Rect &r, int vscroll_pos, uint16 vsc
|
|||
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, const Rect &r, int vscroll_pos, uint16 vsc
|
|||
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++) {
|
||||
|
|
|
@ -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::DrawVehicleListItems(VehicleID selected_vehicle, int
|
|||
|
||||
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 *v, EngineImageType image_type)
|
|||
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 *v, EngineImageType image_type)
|
|||
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 *v, EngineImageType image_type)
|
|||
|
||||
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;
|
||||
|
|
|
@ -786,7 +786,7 @@ static inline void DrawCloseBox(const Rect &r, Colours colour)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,16 @@ static inline ZoomLevel UnScaleZoomGUI(ZoomLevel value)
|
|||
return std::clamp(ZoomLevel(value - (ZOOM_LVL_GUI - ZOOM_LVL_OUT_4X)), ZOOM_LVL_MIN, ZOOM_LVL_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
|
|
Loading…
Reference in New Issue