equal
deleted
inserted
replaced
142 |
142 |
143 TileHighlightData _thd; |
143 TileHighlightData _thd; |
144 static TileInfo *_cur_ti; |
144 static TileInfo *_cur_ti; |
145 bool _draw_bounding_boxes = false; |
145 bool _draw_bounding_boxes = false; |
146 |
146 |
147 extern void SmallMapCenterOnCurrentPos(Window *w); |
|
148 |
|
149 static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z) |
147 static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z) |
150 { |
148 { |
151 Point p = RemapCoords(x, y, z); |
149 Point p = RemapCoords(x, y, z); |
152 p.x -= vp->virtual_width / 2; |
150 p.x -= vp->virtual_width / 2; |
153 p.y -= vp->virtual_height / 2; |
151 p.y -= vp->virtual_height / 2; |
2076 |
2074 |
2077 w->viewport->dest_scrollpos_x = pt.x; |
2075 w->viewport->dest_scrollpos_x = pt.x; |
2078 w->viewport->dest_scrollpos_y = pt.y; |
2076 w->viewport->dest_scrollpos_y = pt.y; |
2079 return true; |
2077 return true; |
2080 } |
2078 } |
2081 |
|
2082 |
|
2083 bool ScrollMainWindowTo(int x, int y, bool instant) |
|
2084 { |
|
2085 Window *w; |
|
2086 bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant); |
|
2087 |
|
2088 /* If a user scrolls to a tile (via what way what so ever) and already is on |
|
2089 * that tile (e.g.: pressed twice), move the smallmap to that location, |
|
2090 * so you directly see where you are on the smallmap. */ |
|
2091 |
|
2092 if (res) return res; |
|
2093 |
|
2094 w = FindWindowById(WC_SMALLMAP, 0); |
|
2095 if (w == NULL) return res; |
|
2096 |
|
2097 SmallMapCenterOnCurrentPos(w); |
|
2098 |
|
2099 return res; |
|
2100 } |
|
2101 |
|
2102 |
2079 |
2103 bool ScrollMainWindowToTile(TileIndex tile, bool instant) |
2080 bool ScrollMainWindowToTile(TileIndex tile, bool instant) |
2104 { |
2081 { |
2105 return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant); |
2082 return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant); |
2106 } |
2083 } |