Codechange: Make use of Rect Width/Height helpers.

This commit is contained in:
Peter Nelson
2022-09-29 00:10:41 +01:00
committed by PeterN
parent 632464a623
commit f5f035a22b
19 changed files with 40 additions and 40 deletions

View File

@@ -428,7 +428,7 @@ struct NewGRFInspectWindow : Window {
if (u == v) sel_end = total_width;
}
int width = r.right + 1 - r.left - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
int width = r.Width() - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
int skip = 0;
if (total_width > width) {
int sel_center = (sel_start + sel_end) / 2;
@@ -878,8 +878,8 @@ struct SpriteAlignerWindow : Window {
case WID_SA_SPRITE: {
/* Center the sprite ourselves */
const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
int width = r.right - r.left + 1 - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
int height = r.bottom - r.top + 1 - WD_BEVEL_TOP - WD_BEVEL_BOTTOM;
int width = r.Width() - WD_BEVEL_LEFT - WD_BEVEL_RIGHT;
int height = r.Height() - WD_BEVEL_TOP - WD_BEVEL_BOTTOM;
int x = -UnScaleGUI(spr->x_offs) + (width - UnScaleGUI(spr->width) ) / 2;
int y = -UnScaleGUI(spr->y_offs) + (height - UnScaleGUI(spr->height)) / 2;