mirror of https://github.com/OpenTTD/OpenTTD
Change: position error window closer to cursor on large screens (#11923)
parent
2b1f78d2ca
commit
a05b7acec8
|
@ -223,26 +223,20 @@ public:
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom.
|
constexpr int distance_to_cursor = 200;
|
||||||
* Add a fixed distance 20 to make it less cluttered.
|
|
||||||
*/
|
|
||||||
int scr_top = GetMainViewTop() + 20;
|
|
||||||
int scr_bot = GetMainViewBottom() - 20;
|
|
||||||
|
|
||||||
Point pt = RemapCoords(this->position.x, this->position.y, GetSlopePixelZOutsideMap(this->position.x, this->position.y));
|
/* Position the error window just above the cursor. This makes the
|
||||||
const Viewport *vp = GetMainWindow()->viewport;
|
* error window clearly visible, without being in the way of what
|
||||||
if (this->face == INVALID_COMPANY) {
|
* the user is doing. */
|
||||||
/* move x pos to opposite corner */
|
Point pt;
|
||||||
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
|
pt.x = _cursor.pos.x - sm_width / 2;
|
||||||
pt.x = (pt.x < (_screen.width >> 1)) ? _screen.width - sm_width - 20 : 20; // Stay 20 pixels away from the edge of the screen.
|
pt.y = _cursor.pos.y - (distance_to_cursor + sm_height);
|
||||||
|
|
||||||
/* move y pos to opposite corner */
|
if (pt.y < GetMainViewTop()) {
|
||||||
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
|
/* Window didn't fit above cursor, so place it below. */
|
||||||
pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top;
|
pt.y = _cursor.pos.y + distance_to_cursor;
|
||||||
} else {
|
|
||||||
pt.x = std::min(std::max(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0), _screen.width - sm_width);
|
|
||||||
pt.y = std::min(std::max(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top), scr_bot - sm_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue