Changeset - r26032:c542cabb8e9c
[Not reviewed]
master
0 1 0
Loïc Guilloux - 3 years ago 2021-10-20 20:08:08
glx22@users.noreply.github.com
Fix #9630: intro game could zoom in/out more than allowed by settings (#9633)

Also fixes #9622
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -140,53 +140,53 @@ void ZoomInOrOutToCursorWindow(bool in, 
 
	assert(w != nullptr);
 

	
 
	if (_game_mode != GM_MENU) {
 
		Viewport *vp = w->viewport;
 
		if ((in && vp->zoom <= _settings_client.gui.zoom_min) || (!in && vp->zoom >= _settings_client.gui.zoom_max)) return;
 

	
 
		Point pt = GetTileZoomCenterWindow(in, w);
 
		if (pt.x != -1) {
 
			ScrollWindowTo(pt.x, pt.y, -1, w, true);
 

	
 
			DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w);
 
		}
 
	}
 
}
 

	
 
void FixTitleGameZoom(int zoom_adjust)
 
{
 
	if (_game_mode != GM_MENU) return;
 

	
 
	Viewport *vp = FindWindowByClass(WC_MAIN_WINDOW)->viewport;
 

	
 
	/* Adjust the zoom in/out.
 
	 * Can't simply add, since operator+ is not defined on the ZoomLevel type. */
 
	vp->zoom = _gui_zoom;
 
	while (zoom_adjust < 0 && vp->zoom != ZOOM_LVL_MIN) {
 
	while (zoom_adjust < 0 && vp->zoom != _settings_client.gui.zoom_min) {
 
		vp->zoom--;
 
		zoom_adjust++;
 
	}
 
	while (zoom_adjust > 0 && vp->zoom != ZOOM_LVL_MAX) {
 
	while (zoom_adjust > 0 && vp->zoom != _settings_client.gui.zoom_max) {
 
		vp->zoom++;
 
		zoom_adjust--;
 
	}
 

	
 
	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
 
	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
 
}
 

	
 
static const struct NWidgetPart _nested_main_window_widgets[] = {
 
	NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1),
 
};
 

	
 
enum {
 
	GHK_QUIT,
 
	GHK_ABANDON,
 
	GHK_CONSOLE,
 
	GHK_BOUNDING_BOXES,
 
	GHK_DIRTY_BLOCKS,
 
	GHK_CENTER,
 
	GHK_CENTER_ZOOM,
 
	GHK_RESET_OBJECT_TO_PLACE,
 
	GHK_DELETE_WINDOWS,
 
	GHK_DELETE_NONVITAL_WINDOWS,
 
	GHK_DELETE_ALL_MESSAGES,
0 comments (0 inline, 0 general)