Changeset - r16245:5fda73d1d097
[Not reviewed]
master
0 1 0
frosch - 14 years ago 2010-10-16 23:13:05
frosch@openttd.org
(svn r20956) -Feature: Center new extra viewports on the tile below the mouse. Only center on center of main viewport if mouse is not in any viewport.
1 file changed with 7 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/viewport_gui.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "window_gui.h"
 
#include "viewport_func.h"
 
#include "gfx_func.h"
 
#include "strings_func.h"
 
#include "zoom_func.h"
 
#include "window_func.h"
 
#include "tilehighlight_func.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 

	
 
/** Widget numbers of the extra viewport window. */
 
enum ExtraViewportWindowWidgets {
 
@@ -67,13 +68,18 @@ public:
 
		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(EVW_VIEWPORT);
 
		nvp->InitializeViewport(this, 0, ZOOM_LVL_NORMAL);
 
		this->DisableWidget(EVW_ZOOMIN);
 

	
 
		Point pt;
 
		if (tile == INVALID_TILE) {
 
			/* the main window with the main view */
 
			/* 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. */
 
			const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 

	
 
			/* center on same place as main window (zoom is maximum, no adjustment needed) */
 
			pt.x = w->viewport->scrollpos_x + w->viewport->virtual_width / 2;
 
			pt.y = w->viewport->scrollpos_y + w->viewport->virtual_height / 2;
 
		} else {
0 comments (0 inline, 0 general)