Changeset - r26598:0b885de2c951
[Not reviewed]
master
0 1 0
Peter Nelson - 19 months ago 2022-11-14 23:48:34
peter1138@openttd.org
Fix #8770: Centre vehicle status bar icon.

The icon is now centred within its scaled bounding box, which intentionally
leaves a little space around the icon when not at 1/2/4x scale.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/vehicle_gui.cpp
Show inline comments
 
@@ -2878,7 +2878,7 @@ public:
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		switch (widget) {
 
			case WID_VV_START_STOP:
 
				size->height = std::max<uint>({size->height, (uint)FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_WARNING_SIGN).height, GetSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
 
				size->height = std::max<uint>({size->height, (uint)FONT_HEIGHT_NORMAL, GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
 
				break;
 

	
 
			case WID_VV_FORCE_PROCEED:
 
@@ -3025,11 +3025,11 @@ public:
 

	
 
		/* Draw the flag plus orders. */
 
		bool rtl = (_current_text_dir == TD_RTL);
 
		uint icon_width = std::max({GetSpriteSize(SPR_WARNING_SIGN).width, GetSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetSpriteSize(SPR_FLAG_VEH_RUNNING).width});
 
		uint icon_width = std::max({GetScaledSpriteSize(SPR_WARNING_SIGN).width, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).width, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).width});
 
		int lowered = this->IsWidgetLowered(widget) ? WidgetDimensions::scaled.pressed : 0;
 
		Rect tr = r.Shrink(WidgetDimensions::scaled.framerect).Translate(lowered, lowered);
 
		SpriteID image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : (HasBit(v->vehicle_flags, VF_PATHFINDER_LOST)) ? SPR_WARNING_SIGN : SPR_FLAG_VEH_RUNNING;
 
		DrawSprite(image, PAL_NONE, tr.WithWidth(icon_width, rtl).left, CenterBounds(tr.top, tr.bottom, GetSpriteSize(image).height));
 
		DrawSpriteIgnorePadding(image, PAL_NONE, tr.WithWidth(icon_width, rtl), false, SA_CENTER);
 
		tr = tr.Indent(icon_width + WidgetDimensions::scaled.imgbtn.Horizontal(), rtl);
 
		DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, FONT_HEIGHT_NORMAL), str, text_colour, SA_HOR_CENTER);
 
	}
0 comments (0 inline, 0 general)