src/viewport.cpp
branchcpp_gui
changeset 6268 4b5241e5dd10
parent 6263 19dab6a68886
child 6298 c30fe89622df
equal deleted inserted replaced
6267:7c8ec33959b1 6268:4b5241e5dd10
     1 /* $Id$ */
     1 /* $Id$ */
       
     2 
       
     3 /** @file viewport.cpp */
     2 
     4 
     3 #include "stdafx.h"
     5 #include "stdafx.h"
     4 #include "openttd.h"
     6 #include "openttd.h"
     5 #include "debug.h"
     7 #include "debug.h"
     6 #include "functions.h"
     8 #include "functions.h"
    21 #include "variables.h"
    23 #include "variables.h"
    22 #include "train.h"
    24 #include "train.h"
    23 
    25 
    24 #define VIEWPORT_DRAW_MEM (65536 * 2)
    26 #define VIEWPORT_DRAW_MEM (65536 * 2)
    25 
    27 
    26 /* viewport.c */
       
    27 // XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
    28 // XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
    28 static ViewPort _viewports[25 - 2];
    29 static ViewPort _viewports[25 - 2];
    29 static uint32 _active_viewports;    ///< bitmasked variable where each bit signifies if a viewport is in use or not
    30 static uint32 _active_viewports;    ///< bitmasked variable where each bit signifies if a viewport is in use or not
    30 assert_compile(lengthof(_viewports) < sizeof(_active_viewports) * 8);
    31 assert_compile(lengthof(_viewports) < sizeof(_active_viewports) * 8);
    31 
    32 
  1595 
  1596 
  1596 static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
  1597 static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
  1597 {
  1598 {
  1598 	const Sign *si;
  1599 	const Sign *si;
  1599 
  1600 
  1600 	if (!(_display_opt & DO_SHOW_SIGNS)) return false;
  1601 	if (!(_display_opt & DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
  1601 
  1602 
  1602 	switch (vp->zoom) {
  1603 	switch (vp->zoom) {
  1603 		case 0:
  1604 		case 0:
  1604 			x = x - vp->left + vp->virtual_left;
  1605 			x = x - vp->left + vp->virtual_left;
  1605 			y = y - vp->top  + vp->virtual_top;
  1606 			y = y - vp->top  + vp->virtual_top;
  1881 			int x2 = _thd.selstart.x;
  1882 			int x2 = _thd.selstart.x;
  1882 			int y2 = _thd.selstart.y;
  1883 			int y2 = _thd.selstart.y;
  1883 			x1 &= ~0xF;
  1884 			x1 &= ~0xF;
  1884 			y1 &= ~0xF;
  1885 			y1 &= ~0xF;
  1885 
  1886 
  1886 			if (x1 >= x2) intswap(x1,x2);
  1887 			if (x1 >= x2) Swap(x1, x2);
  1887 			if (y1 >= y2) intswap(y1,y2);
  1888 			if (y1 >= y2) Swap(y1, y2);
  1888 			_thd.new_pos.x = x1;
  1889 			_thd.new_pos.x = x1;
  1889 			_thd.new_pos.y = y1;
  1890 			_thd.new_pos.y = y1;
  1890 			_thd.new_size.x = x2 - x1 + TILE_SIZE;
  1891 			_thd.new_size.x = x2 - x1 + TILE_SIZE;
  1891 			_thd.new_size.y = y2 - y1 + TILE_SIZE;
  1892 			_thd.new_size.y = y2 - y1 + TILE_SIZE;
  1892 			_thd.new_drawstyle = _thd.next_drawstyle;
  1893 			_thd.new_drawstyle = _thd.next_drawstyle;