mirror of https://github.com/OpenTTD/OpenTTD
(svn r20962) -Fix [FS#4166](r20956): Determine tile under cursor before opening the new viewport. It might appear just below the cursor.
parent
bcd006e4fc
commit
12a7e2fde0
|
@ -66,6 +66,7 @@ enum WarningLevel {
|
|||
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0);
|
||||
|
||||
void ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
|
||||
void ShowExtraViewPortWindowForTileUnderCursor();
|
||||
|
||||
/* bridge_gui.cpp */
|
||||
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type);
|
||||
|
|
|
@ -1343,7 +1343,7 @@ struct MainToolbarWindow : Window {
|
|||
case MTHK_GIANT_SCREENSHOT: MenuClickWorldScreenshot(); break;
|
||||
case MTHK_CHEATS: if (!_networking) ShowCheatWindow(); break;
|
||||
case MTHK_TERRAFORM: ShowTerraformToolbar(); break;
|
||||
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindow(); break;
|
||||
case MTHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
||||
#ifdef ENABLE_NETWORK
|
||||
case MTHK_CLIENT_LIST: if (_networking) ShowClientList(); break;
|
||||
#endif
|
||||
|
@ -1645,7 +1645,7 @@ public:
|
|||
case MTEHK_ZOOM_OUT: ToolbarZoomOutClick(this); break;
|
||||
case MTEHK_TERRAFORM: ShowEditorTerraformToolbar(); break;
|
||||
case MTEHK_SMALLMAP: ShowSmallMap(); break;
|
||||
case MTEHK_EXTRA_VIEWPORT: ShowExtraViewPortWindow(); break;
|
||||
case MTEHK_EXTRA_VIEWPORT: ShowExtraViewPortWindowForTileUnderCursor(); break;
|
||||
default: return ES_NOT_HANDLED;
|
||||
}
|
||||
return ES_HANDLED;
|
||||
|
|
|
@ -71,12 +71,7 @@ public:
|
|||
|
||||
Point pt;
|
||||
if (tile == INVALID_TILE) {
|
||||
/* Use tile under mouse as center for new viewport */
|
||||
Point pt = GetTileBelowCursor();
|
||||
if (pt.x != -1) tile = TileVirtXY(pt.x, pt.y);
|
||||
}
|
||||
if (tile == INVALID_TILE) {
|
||||
/* Still no tile? Use center of main viewport. */
|
||||
/* No tile? Use center of main viewport. */
|
||||
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||
|
||||
/* center on same place as main window (zoom is maximum, no adjustment needed) */
|
||||
|
@ -175,6 +170,10 @@ static const WindowDesc _extra_view_port_desc(
|
|||
_nested_extra_view_port_widgets, lengthof(_nested_extra_view_port_widgets)
|
||||
);
|
||||
|
||||
/**
|
||||
* Show a new Extra Viewport window.
|
||||
* @param tile Tile to center the view on. INVALID_TILE means to use the center of main viewport.
|
||||
*/
|
||||
void ShowExtraViewPortWindow(TileIndex tile)
|
||||
{
|
||||
int i = 0;
|
||||
|
@ -184,3 +183,16 @@ void ShowExtraViewPortWindow(TileIndex tile)
|
|||
|
||||
new ExtraViewportWindow(&_extra_view_port_desc, i, tile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a new Extra Viewport window.
|
||||
* Center it on the tile under the cursor, if the cursor is inside a viewport.
|
||||
* If that fails, center it on main viewport center.
|
||||
*/
|
||||
void ShowExtraViewPortWindowForTileUnderCursor()
|
||||
{
|
||||
/* Use tile under mouse as center for new viewport.
|
||||
* Do this before creating the window, it might appear just below the mouse. */
|
||||
Point pt = GetTileBelowCursor();
|
||||
ShowExtraViewPortWindow(pt.x != -1 ? TileVirtXY(pt.x, pt.y) : INVALID_TILE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue