Merge remote-tracking branch 'upstream/master' into 13.0
This commit is contained in:
+27
-17
@@ -143,6 +143,7 @@ struct ChildScreenSpriteToDraw {
|
||||
const SubSprite *sub; ///< only draw a rectangular part of the sprite
|
||||
int32 x;
|
||||
int32 y;
|
||||
bool relative;
|
||||
int next; ///< next child to draw (-1 at the end)
|
||||
};
|
||||
|
||||
@@ -578,7 +579,7 @@ void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubSprite *
|
||||
int *old_child = _vd.last_child;
|
||||
_vd.last_child = _vd.last_foundation_child[foundation_part];
|
||||
|
||||
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false);
|
||||
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub, false, false);
|
||||
|
||||
/* Switch back to last ChildSprite list */
|
||||
_vd.last_child = old_child;
|
||||
@@ -863,8 +864,10 @@ bool IsInsideSelectedRectangle(int x, int y)
|
||||
* @param y sprite y-offset (screen coordinates) relative to parent sprite.
|
||||
* @param transparent if true, switch the palette between the provided palette and the transparent palette,
|
||||
* @param sub Only draw a part of the sprite.
|
||||
* @param scale if true, scale offsets to base zoom level.
|
||||
* @param relative if true, draw sprite relative to parent sprite offsets.
|
||||
*/
|
||||
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale)
|
||||
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale, bool relative)
|
||||
{
|
||||
assert((image & SPRITE_MASK) < MAX_SPRITES);
|
||||
|
||||
@@ -885,6 +888,7 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran
|
||||
cs.sub = sub;
|
||||
cs.x = scale ? x * ZOOM_LVL_BASE : x;
|
||||
cs.y = scale ? y * ZOOM_LVL_BASE : y;
|
||||
cs.relative = relative;
|
||||
cs.next = -1;
|
||||
|
||||
/* Append the sprite to the active ChildSprite list.
|
||||
@@ -919,16 +923,18 @@ static void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint
|
||||
* @param ti TileInfo Tile that is being drawn
|
||||
* @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting.
|
||||
* @param foundation_part Foundation part the sprite belongs to.
|
||||
* @param extra_offs_x Pixel X offset for the sprite position.
|
||||
* @param extrDrawa_offs_y Pixel Y offset for the sprite position.
|
||||
*/
|
||||
void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part)
|
||||
void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part, int extra_offs_x = 0, int extra_offs_y = 0)
|
||||
{
|
||||
/* FIXME: This is not totally valid for some autorail highlights that extend over the edges of the tile. */
|
||||
if (_vd.foundation[foundation_part] == -1) {
|
||||
/* draw on real ground */
|
||||
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset);
|
||||
AddTileSpriteToDraw(image, pal, ti->x, ti->y, ti->z + z_offset, nullptr, extra_offs_x, extra_offs_y);
|
||||
} else {
|
||||
/* draw on top of foundation */
|
||||
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, 0, -z_offset * ZOOM_LVL_BASE);
|
||||
AddChildSpriteToFoundation(image, pal, nullptr, foundation_part, extra_offs_x, extra_offs_y - z_offset * ZOOM_LVL_BASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1347,7 +1353,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
|
||||
int right = left + dpi->width;
|
||||
int bottom = top + dpi->height;
|
||||
|
||||
int sign_height = ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM, dpi->zoom);
|
||||
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom);
|
||||
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom);
|
||||
|
||||
if (bottom < sign->top ||
|
||||
@@ -1363,7 +1369,7 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
|
||||
int shadow_offset = 0;
|
||||
if (string_small_shadow != STR_NULL) {
|
||||
shadow_offset = 4;
|
||||
AddStringToDraw(sign->center - sign_half_width + shadow_offset, sign->top, string_small_shadow, params_1, params_2, INVALID_COLOUR, sign->width_small);
|
||||
AddStringToDraw(sign->center - sign_half_width + shadow_offset, sign->top, string_small_shadow, params_1, params_2, INVALID_COLOUR, sign->width_small | 0x8000);
|
||||
}
|
||||
AddStringToDraw(sign->center - sign_half_width, sign->top - shadow_offset, string_small, params_1, params_2,
|
||||
colour, sign->width_small | 0x8000);
|
||||
@@ -1375,8 +1381,8 @@ Rect ExpandRectWithViewportSignMargins(Rect r, ZoomLevel zoom)
|
||||
/* Pessimistically always use normal font, but also assume small font is never larger in either dimension */
|
||||
const int fh = FONT_HEIGHT_NORMAL;
|
||||
const int max_tw = _viewport_sign_maxwidth / 2 + 1;
|
||||
const int expand_y = ScaleByZoom(VPSM_TOP + fh + VPSM_BOTTOM, zoom);
|
||||
const int expand_x = ScaleByZoom(VPSM_LEFT + max_tw + VPSM_RIGHT, zoom);
|
||||
const int expand_y = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + fh + WidgetDimensions::scaled.fullbevel.bottom, zoom);
|
||||
const int expand_x = ScaleByZoom(WidgetDimensions::scaled.fullbevel.left + max_tw + WidgetDimensions::scaled.fullbevel.right, zoom);
|
||||
|
||||
r.left -= expand_x;
|
||||
r.right += expand_x;
|
||||
@@ -1497,14 +1503,14 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID st
|
||||
char buffer[DRAW_STRING_BUFFER];
|
||||
|
||||
GetString(buffer, str, lastof(buffer));
|
||||
this->width_normal = VPSM_LEFT + Align(GetStringBoundingBox(buffer).width, 2) + VPSM_RIGHT;
|
||||
this->width_normal = WidgetDimensions::scaled.fullbevel.left + Align(GetStringBoundingBox(buffer).width, 2) + WidgetDimensions::scaled.fullbevel.right;
|
||||
this->center = center;
|
||||
|
||||
/* zoomed out version */
|
||||
if (str_small != STR_NULL) {
|
||||
GetString(buffer, str_small, lastof(buffer));
|
||||
}
|
||||
this->width_small = VPSM_LEFT + Align(GetStringBoundingBox(buffer, FS_SMALL).width, 2) + VPSM_RIGHT;
|
||||
this->width_small = WidgetDimensions::scaled.fullbevel.left + Align(GetStringBoundingBox(buffer, FS_SMALL).width, 2) + WidgetDimensions::scaled.fullbevel.right;
|
||||
|
||||
this->MarkDirty();
|
||||
}
|
||||
@@ -1524,7 +1530,7 @@ void ViewportSign::MarkDirty(ZoomLevel maxzoom) const
|
||||
zoomlevels[zoom].left = this->center - ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
||||
zoomlevels[zoom].top = this->top - ScaleByZoom(1, zoom);
|
||||
zoomlevels[zoom].right = this->center + ScaleByZoom(this->width_normal / 2 + 1, zoom);
|
||||
zoomlevels[zoom].bottom = this->top + ScaleByZoom(VPSM_TOP + FONT_HEIGHT_NORMAL + VPSM_BOTTOM + 1, zoom);
|
||||
zoomlevels[zoom].bottom = this->top + ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.fullbevel.bottom + 1, zoom);
|
||||
}
|
||||
|
||||
for (const Window *w : Window::Iterate()) {
|
||||
@@ -1680,7 +1686,11 @@ static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const
|
||||
while (child_idx >= 0) {
|
||||
const ChildScreenSpriteToDraw *cs = csstdv->data() + child_idx;
|
||||
child_idx = cs->next;
|
||||
DrawSpriteViewport(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub);
|
||||
if (cs->relative) {
|
||||
DrawSpriteViewport(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub);
|
||||
} else {
|
||||
DrawSpriteViewport(cs->image, cs->pal, ps->x + cs->x, ps->y + cs->y, cs->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1734,7 +1744,7 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
||||
int w = GB(ss.width, 0, 15);
|
||||
int x = UnScaleByZoom(ss.x, zoom);
|
||||
int y = UnScaleByZoom(ss.y, zoom);
|
||||
int h = VPSM_TOP + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + VPSM_BOTTOM;
|
||||
int h = WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom;
|
||||
|
||||
SetDParam(0, ss.params[0]);
|
||||
SetDParam(1, ss.params[1]);
|
||||
@@ -1752,13 +1762,13 @@ static void ViewportDrawStrings(ZoomLevel zoom, const StringSpriteToDrawVector *
|
||||
/* Draw the rectangle if 'transparent station signs' is off,
|
||||
* or if we are drawing a general text sign (STR_WHITE_SIGN). */
|
||||
DrawFrameRect(
|
||||
x, y, x + w, y + h, ss.colour,
|
||||
x, y, x + w - 1, y + h - 1, ss.colour,
|
||||
IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DrawString(x + VPSM_LEFT, x + w - 1 - VPSM_RIGHT, y + VPSM_TOP, ss.string, colour, SA_HOR_CENTER);
|
||||
DrawString(x + WidgetDimensions::scaled.fullbevel.left, x + w - 1 - WidgetDimensions::scaled.fullbevel.right, y + WidgetDimensions::scaled.fullbevel.top, ss.string, colour, SA_HOR_CENTER, false, small ? FS_SMALL : FS_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2179,7 +2189,7 @@ bool CheckClickOnViewportSign(const Viewport *vp, int x, int y, const ViewportSi
|
||||
{
|
||||
bool small = (vp->zoom >= ZOOM_LVL_OUT_16X);
|
||||
int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp->zoom);
|
||||
int sign_height = ScaleByZoom(VPSM_TOP + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + VPSM_BOTTOM, vp->zoom);
|
||||
int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + (small ? FONT_HEIGHT_SMALL : FONT_HEIGHT_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, vp->zoom);
|
||||
|
||||
return y >= sign->top && y < sign->top + sign_height &&
|
||||
x >= sign->center - sign_half_width && x < sign->center + sign_half_width;
|
||||
|
||||
Reference in New Issue
Block a user