mirror of https://github.com/OpenTTD/OpenTTD
Fix #7950: Incorrect setup of normal screenshot viewport
parent
bf4672864d
commit
2158e26b9e
|
@ -712,8 +712,25 @@ static bool MakeSmallScreenshot(bool crashlog)
|
||||||
*/
|
*/
|
||||||
void SetupScreenshotViewport(ScreenshotType t, ViewPort *vp)
|
void SetupScreenshotViewport(ScreenshotType t, ViewPort *vp)
|
||||||
{
|
{
|
||||||
|
switch(t) {
|
||||||
|
case SC_VIEWPORT:
|
||||||
|
case SC_CRASHLOG: {
|
||||||
|
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||||
|
vp->virtual_left = w->viewport->virtual_left;
|
||||||
|
vp->virtual_top = w->viewport->virtual_top;
|
||||||
|
vp->virtual_width = w->viewport->virtual_width;
|
||||||
|
vp->virtual_height = w->viewport->virtual_height;
|
||||||
|
|
||||||
|
/* Compute pixel coordinates */
|
||||||
|
vp->left = 0;
|
||||||
|
vp->top = 0;
|
||||||
|
vp->width = _screen.width;
|
||||||
|
vp->height = _screen.height;
|
||||||
|
vp->overlay = w->viewport->overlay;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SC_WORLD: {
|
||||||
/* Determine world coordinates of screenshot */
|
/* Determine world coordinates of screenshot */
|
||||||
if (t == SC_WORLD) {
|
|
||||||
vp->zoom = ZOOM_LVL_WORLD_SCREENSHOT;
|
vp->zoom = ZOOM_LVL_WORLD_SCREENSHOT;
|
||||||
|
|
||||||
TileIndex north_tile = _settings_game.construction.freeform_edges ? TileXY(1, 1) : TileXY(0, 0);
|
TileIndex north_tile = _settings_game.construction.freeform_edges ? TileXY(1, 1) : TileXY(0, 0);
|
||||||
|
@ -728,15 +745,6 @@ void SetupScreenshotViewport(ScreenshotType t, ViewPort *vp)
|
||||||
vp->virtual_top = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, extra_height_top).y;
|
vp->virtual_top = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(north_tile) * TILE_SIZE, extra_height_top).y;
|
||||||
vp->virtual_width = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, 0).x - vp->virtual_left + 1;
|
vp->virtual_width = RemapCoords(TileX(north_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, 0).x - vp->virtual_left + 1;
|
||||||
vp->virtual_height = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, reclaim_height_bottom).y - vp->virtual_top + 1;
|
vp->virtual_height = RemapCoords(TileX(south_tile) * TILE_SIZE, TileY(south_tile) * TILE_SIZE, reclaim_height_bottom).y - vp->virtual_top + 1;
|
||||||
} else {
|
|
||||||
vp->zoom = (t == SC_ZOOMEDIN) ? _settings_client.gui.zoom_min : ZOOM_LVL_VIEWPORT;
|
|
||||||
|
|
||||||
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
|
||||||
vp->virtual_left = w->viewport->virtual_left;
|
|
||||||
vp->virtual_top = w->viewport->virtual_top;
|
|
||||||
vp->virtual_width = w->viewport->virtual_width;
|
|
||||||
vp->virtual_height = w->viewport->virtual_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compute pixel coordinates */
|
/* Compute pixel coordinates */
|
||||||
vp->left = 0;
|
vp->left = 0;
|
||||||
|
@ -744,6 +752,26 @@ void SetupScreenshotViewport(ScreenshotType t, ViewPort *vp)
|
||||||
vp->width = UnScaleByZoom(vp->virtual_width, vp->zoom);
|
vp->width = UnScaleByZoom(vp->virtual_width, vp->zoom);
|
||||||
vp->height = UnScaleByZoom(vp->virtual_height, vp->zoom);
|
vp->height = UnScaleByZoom(vp->virtual_height, vp->zoom);
|
||||||
vp->overlay = nullptr;
|
vp->overlay = nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
vp->zoom = (t == SC_ZOOMEDIN) ? _settings_client.gui.zoom_min : ZOOM_LVL_VIEWPORT;
|
||||||
|
|
||||||
|
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||||
|
vp->virtual_left = w->viewport->virtual_left;
|
||||||
|
vp->virtual_top = w->viewport->virtual_top;
|
||||||
|
vp->virtual_width = w->viewport->virtual_width;
|
||||||
|
vp->virtual_height = w->viewport->virtual_height;
|
||||||
|
|
||||||
|
/* Compute pixel coordinates */
|
||||||
|
vp->left = 0;
|
||||||
|
vp->top = 0;
|
||||||
|
vp->width = UnScaleByZoom(vp->virtual_width, vp->zoom);
|
||||||
|
vp->height = UnScaleByZoom(vp->virtual_height, vp->zoom);
|
||||||
|
vp->overlay = nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue