MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckClickOnViewportSign

Function CheckClickOnViewportSign

src/viewport.cpp:2270–2278  ·  view source on GitHub ↗

* Test whether a sign is below the mouse * @param vp the clicked viewport * @param x X position of click * @param y Y position of click * @param sign the sign to check * @return true if the sign was hit */

Source from the content-addressed store, hash-verified

2268 * @return true if the sign was hit
2269 */
2270static bool CheckClickOnViewportSign(const Viewport &vp, int x, int y, const ViewportSign *sign)
2271{
2272 bool small = (vp.zoom >= ZoomLevel::Out4x);
2273 int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, vp.zoom);
2274 int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(small ? FS_SMALL : FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, vp.zoom);
2275
2276 return y >= sign->top && y < sign->top + sign_height &&
2277 x >= sign->center - sign_half_width && x < sign->center + sign_half_width;
2278}
2279
2280
2281/**

Callers 1

HandleViewportClickedFunction · 0.85

Calls 13

ScaleByZoomFunction · 0.85
GetCharacterHeightFunction · 0.85
HasBitFunction · 0.85
IsInvisibilitySetFunction · 0.85
NOT_REACHEDFunction · 0.85
ShowStationViewWindowFunction · 0.85
ShowWaypointWindowFunction · 0.85
ShowTownViewWindowFunction · 0.85
HandleClickOnSignFunction · 0.85
FindContainedMethod · 0.80
NoneMethod · 0.80

Tested by

no test coverage detected