Change: Use CenterBounds function in more places.
CenterBounds may have a 1 pixel difference so the result is not exactly the same.
This commit is contained in:
@@ -1673,15 +1673,13 @@ private:
|
||||
* @param widget_index index of this widget in the window
|
||||
* @param image the sprite to draw
|
||||
*/
|
||||
void DrawSignalSprite(byte widget_index, SpriteID image) const
|
||||
void DrawSignalSprite(const Rect &r, int widget_index, SpriteID image) const
|
||||
{
|
||||
Point offset;
|
||||
Dimension sprite_size = GetSpriteSize(image, &offset);
|
||||
const NWidgetBase *widget = this->GetWidget<NWidgetBase>(widget_index);
|
||||
int x = widget->pos_x - offset.x +
|
||||
(widget->current_x - sprite_size.width + offset.x) / 2; // centered
|
||||
int y = widget->pos_y - sig_sprite_bottom_offset + WD_IMGBTN_TOP +
|
||||
(widget->current_y - WD_IMGBTN_TOP - WD_IMGBTN_BOTTOM + sig_sprite_size.height) / 2; // aligned to bottom
|
||||
int x = CenterBounds(r.left, r.right, sprite_size.width - offset.x);
|
||||
int y = r.top - sig_sprite_bottom_offset + WD_IMGBTN_TOP +
|
||||
(r.bottom - r.top - WD_IMGBTN_TOP - WD_IMGBTN_BOTTOM + sig_sprite_size.height) / 2; // aligned to bottom
|
||||
|
||||
DrawSprite(image, PAL_NONE,
|
||||
x + this->IsWidgetLowered(widget_index),
|
||||
@@ -1768,7 +1766,7 @@ public:
|
||||
int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
|
||||
SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
|
||||
|
||||
this->DrawSignalSprite(widget, sprite);
|
||||
this->DrawSignalSprite(r, widget, sprite);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user