summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft_cmd.cpp14
-rw-r--r--src/aircraft_gui.cpp12
-rw-r--r--src/company_gui.cpp10
-rw-r--r--src/depot_gui.cpp26
-rw-r--r--src/dock_gui.cpp12
-rw-r--r--src/fontcache.cpp4
-rw-r--r--src/gfx.cpp8
-rw-r--r--src/gfx_func.h2
-rw-r--r--src/misc_gui.cpp2
-rw-r--r--src/newgrf_debug_gui.cpp12
-rw-r--r--src/object_gui.cpp20
-rw-r--r--src/rail_gui.cpp28
-rw-r--r--src/road_gui.cpp12
-rw-r--r--src/roadveh_cmd.cpp16
-rw-r--r--src/roadveh_gui.cpp8
-rw-r--r--src/ship_cmd.cpp12
-rw-r--r--src/ship_gui.cpp10
-rw-r--r--src/sprite.cpp8
-rw-r--r--src/station_gui.cpp2
-rw-r--r--src/terraform_gui.cpp6
-rw-r--r--src/train_cmd.cpp36
-rw-r--r--src/train_gui.cpp12
-rw-r--r--src/vehicle_gui.cpp24
-rw-r--r--src/zoom_func.h20
-rw-r--r--src/zoom_type.h1
25 files changed, 176 insertions, 141 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index ac71254e1..18dcbea27 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -201,13 +201,15 @@ void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID en
{
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));
}
}
@@ -224,10 +226,10 @@ void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoff
{
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);
}
/**
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 77cfd1de7..c3379d395 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -86,12 +86,12 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
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);
@@ -100,12 +100,12 @@ void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID s
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);
}
}
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 31c5ed368..1343acb91 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -529,7 +529,7 @@ public:
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
@@ -543,8 +543,12 @@ public:
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);
}
};
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 946f35ad8..fe75708dd 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -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 = 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;
@@ -279,7 +279,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 - 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;
@@ -290,7 +290,7 @@ struct DepotWindow : Window {
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);
@@ -429,7 +429,7 @@ struct DepotWindow : Window {
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;
}
@@ -612,14 +612,14 @@ struct DepotWindow : Window {
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;
@@ -627,7 +627,7 @@ struct DepotWindow : Window {
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;
@@ -669,7 +669,7 @@ struct DepotWindow : Window {
/* 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()) {
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index cd994bc0b..95145945c 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -504,8 +504,8 @@ public:
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;
}
}
@@ -514,10 +514,10 @@ public:
{
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);
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index e6f1e3725..4928b5377 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -183,12 +183,12 @@ 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()
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 6db886dda..b10943553 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -1532,10 +1532,10 @@ 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;
}
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 7363443a6..6576dee4f 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -71,8 +71,6 @@ 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();
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 0f61d67de..62da50b96 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -684,7 +684,7 @@ struct TooltipsWindow : public Window
/* 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. */
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index 82c7a7d22..4831b691a 100644
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -858,15 +858,15 @@ struct SpriteAlignerWindow : Window {
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);
diff --git a/src/object_gui.cpp b/src/object_gui.cpp
index 0ad74b081..25856c172 100644
--- a/src/object_gui.cpp
+++ b/src/object_gui.cpp
@@ -165,8 +165,8 @@ public:
/* 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
@@ -175,9 +175,9 @@ public:
* 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. */
@@ -199,8 +199,8 @@ public:
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;
@@ -243,9 +243,9 @@ public:
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;
}
@@ -270,9 +270,9 @@ public:
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;
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index ff330b035..17c6cec9b 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1075,8 +1075,8 @@ public:
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:
@@ -1100,8 +1100,8 @@ 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;
- 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);
}
@@ -1114,8 +1114,8 @@ 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;
- 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);
}
@@ -1152,8 +1152,8 @@ 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;
- 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);
}
@@ -1693,15 +1693,15 @@ struct BuildRailDepotWindow : public PickerWindowBase {
{
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)
@@ -1791,8 +1791,8 @@ struct BuildRailWaypointWindow : PickerWindowBase {
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;
}
}
@@ -1803,7 +1803,7 @@ struct BuildRailWaypointWindow : PickerWindowBase {
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);
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 6b23ca631..09b76a533 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -867,15 +867,15 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
{
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)
@@ -1003,8 +1003,8 @@ struct BuildRoadStationWindow : public PickerWindowBase {
{
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
@@ -1012,7 +1012,7 @@ struct BuildRoadStationWindow : public PickerWindowBase {
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)
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 45d1c2747..39a406a17 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -107,10 +107,10 @@ 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)
@@ -162,7 +162,9 @@ void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID eng
{
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);
}
@@ -179,10 +181,10 @@ void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs
{
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);
}
/**
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index e00fb2873..46ff6cea7 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -31,7 +31,7 @@
*/
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;
@@ -137,7 +137,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, 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;
@@ -149,14 +149,14 @@ void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID se
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;
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index fddff0b4f..a24fb3510 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -90,7 +90,9 @@ void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine
{
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);
}
@@ -107,10 +109,10 @@ void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, i
{
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
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index 4db55215c..7ad2e8473 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -38,17 +38,17 @@ void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selec
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);
}
}
diff --git a/src/sprite.cpp b/src/sprite.cpp
index 6db6966d8..22210712a 100644
--- a/src/sprite.cpp
+++ b/src/sprite.cpp
@@ -119,15 +119,15 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig
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));
}
}
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index b5e705f73..666e66d8b 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -806,7 +806,7 @@ static const NWidgetPart _nested_station_view_widgets[] = {
*/
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;
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 0f41da75d..06b66cad4 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -559,8 +559,8 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
{
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
@@ -575,7 +575,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
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);
}
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index cb9238eb2..45817159b 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -464,10 +464,10 @@ int Train::GetDisplayImageWidth(Point *offset) const
}
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)
@@ -514,7 +514,7 @@ static SpriteID GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImage
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;
}
@@ -538,14 +538,18 @@ void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engin
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));
+ 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 - UnScaleByZoom(14 * 4, ZOOM_LVL_GUI), yf);
- DrawSprite(spriter, pal, preferred_x + UnScaleByZoom(15 * 4, ZOOM_LVL_GUI), yr);
+ 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);
}
}
@@ -566,20 +570,20 @@ void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs,
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));
}
}
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 6c2d9a9d6..d9da09701 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -74,7 +74,7 @@ static int HighlightDragPosition(int px, int max_width, VehicleID selection)
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;
@@ -100,7 +100,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 = UnScaleByZoom(4 * 14, ZOOM_LVL_GUI);
+ int height = ScaleGUITrad(14);
if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, height)) return;
@@ -355,7 +355,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
/* 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;
@@ -379,7 +379,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
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);
@@ -389,7 +389,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
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;
@@ -397,7 +397,7 @@ void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_po
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) {
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index d9cb116a1..4ace090dd 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -665,7 +665,7 @@ struct RefitWindow : public Window {
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:
@@ -762,7 +762,7 @@ struct RefitWindow : public Window {
}
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;
@@ -1289,8 +1289,8 @@ static void DrawSmallOrderList(const Vehicle *v, int left, int right, int y, Veh
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;
@@ -1343,7 +1343,7 @@ void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID se
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);
@@ -1372,8 +1372,8 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
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;
@@ -1909,7 +1909,7 @@ struct VehicleDetailsWindow : Window {
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;
@@ -1966,7 +1966,7 @@ struct VehicleDetailsWindow : Window {
}
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;
@@ -2093,7 +2093,9 @@ struct VehicleDetailsWindow : Window {
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);
@@ -2845,7 +2847,7 @@ int GetVehicleWidth(Vehicle *v, EngineImageType image_type)
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;
}
diff --git a/src/zoom_func.h b/src/zoom_func.h
index 5f1bf830d..1cb3d0c48 100644
--- a/src/zoom_func.h
+++ b/src/zoom_func.h
@@ -64,4 +64,24 @@ static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
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 */
diff --git a/src/zoom_type.h b/src/zoom_type.h
index ec80eaf3b..c29f136cf 100644
--- a/src/zoom_type.h
+++ b/src/zoom_type.h
@@ -52,6 +52,7 @@ 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 */