src/viewport.cpp
changeset 6247 7d81e3a5d803
parent 6117 6507b2a7e71d
child 6248 e4a2ed7e5613
equal deleted inserted replaced
6246:75451000349d 6247:7d81e3a5d803
   127 	p.x -= vp->virtual_width / 2;
   127 	p.x -= vp->virtual_width / 2;
   128 	p.y -= vp->virtual_height / 2;
   128 	p.y -= vp->virtual_height / 2;
   129 	return p;
   129 	return p;
   130 }
   130 }
   131 
   131 
   132 void InitViewports(void) {
   132 void InitViewports() {
   133 	memset(_viewports, 0, sizeof(_viewports));
   133 	memset(_viewports, 0, sizeof(_viewports));
   134 	_active_viewports = 0;
   134 	_active_viewports = 0;
   135 }
   135 }
   136 
   136 
   137 void DeleteWindowViewport(Window *w)
   137 void DeleteWindowViewport(Window *w)
   369 
   369 
   370 	pt.y = pt.x = -1;
   370 	pt.y = pt.x = -1;
   371 	return pt;
   371 	return pt;
   372 }
   372 }
   373 
   373 
   374 Point GetTileBelowCursor(void)
   374 Point GetTileBelowCursor()
   375 {
   375 {
   376 	return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, _cursor.pos.x, _cursor.pos.y);
   376 	return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, _cursor.pos.x, _cursor.pos.y);
   377 }
   377 }
   378 
   378 
   379 
   379 
   532 	*vd->parent_list++ = ps;
   532 	*vd->parent_list++ = ps;
   533 
   533 
   534 	if (vd->combine_sprites == 1) vd->combine_sprites = 2;
   534 	if (vd->combine_sprites == 1) vd->combine_sprites = 2;
   535 }
   535 }
   536 
   536 
   537 void StartSpriteCombine(void)
   537 void StartSpriteCombine()
   538 {
   538 {
   539 	_cur_vd->combine_sprites = 1;
   539 	_cur_vd->combine_sprites = 1;
   540 }
   540 }
   541 
   541 
   542 void EndSpriteCombine(void)
   542 void EndSpriteCombine()
   543 {
   543 {
   544 	_cur_vd->combine_sprites = 0;
   544 	_cur_vd->combine_sprites = 0;
   545 }
   545 }
   546 
   546 
   547 void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y)
   547 void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y)
   723 		DrawSelectionSprite(SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh], PALETTE_SEL_TILE_BLUE, ti);
   723 		DrawSelectionSprite(SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh], PALETTE_SEL_TILE_BLUE, ti);
   724 		return;
   724 		return;
   725 	}
   725 	}
   726 }
   726 }
   727 
   727 
   728 static void ViewportAddLandscape(void)
   728 static void ViewportAddLandscape()
   729 {
   729 {
   730 	ViewportDrawer *vd = _cur_vd;
   730 	ViewportDrawer *vd = _cur_vd;
   731 	int x, y, width, height;
   731 	int x, y, width, height;
   732 	TileInfo ti;
   732 	TileInfo ti;
   733 	bool direction;
   733 	bool direction;
  1443 		pt.x - 31 + 67,
  1443 		pt.x - 31 + 67,
  1444 		pt.y - 122 + 154
  1444 		pt.y - 122 + 154
  1445 	);
  1445 	);
  1446 }
  1446 }
  1447 
  1447 
  1448 static void SetSelectionTilesDirty(void)
  1448 static void SetSelectionTilesDirty()
  1449 {
  1449 {
  1450 	int y_size, x_size;
  1450 	int y_size, x_size;
  1451 	int x = _thd.pos.x;
  1451 	int x = _thd.pos.x;
  1452 	int y = _thd.pos.y;
  1452 	int y = _thd.pos.y;
  1453 
  1453 
  1741 		DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
  1741 		DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
  1742 		_on_vehicle_click_proc[v->type](v);
  1742 		_on_vehicle_click_proc[v->type](v);
  1743 	}
  1743 	}
  1744 }
  1744 }
  1745 
  1745 
  1746 Vehicle *CheckMouseOverVehicle(void)
  1746 Vehicle *CheckMouseOverVehicle()
  1747 {
  1747 {
  1748 	const Window *w;
  1748 	const Window *w;
  1749 	const ViewPort *vp;
  1749 	const ViewPort *vp;
  1750 
  1750 
  1751 	int x = _cursor.pos.x;
  1751 	int x = _cursor.pos.x;
  1758 	return (vp != NULL) ? CheckClickOnVehicle(vp, x, y) : NULL;
  1758 	return (vp != NULL) ? CheckClickOnVehicle(vp, x, y) : NULL;
  1759 }
  1759 }
  1760 
  1760 
  1761 
  1761 
  1762 
  1762 
  1763 void PlaceObject(void)
  1763 void PlaceObject()
  1764 {
  1764 {
  1765 	Point pt;
  1765 	Point pt;
  1766 	Window *w;
  1766 	Window *w;
  1767 
  1767 
  1768 	pt = GetTileBelowCursor();
  1768 	pt = GetTileBelowCursor();
  1864 {
  1864 {
  1865 	return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF];
  1865 	return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF];
  1866 }
  1866 }
  1867 
  1867 
  1868 // called regular to update tile highlighting in all cases
  1868 // called regular to update tile highlighting in all cases
  1869 void UpdateTileSelection(void)
  1869 void UpdateTileSelection()
  1870 {
  1870 {
  1871 	int x1;
  1871 	int x1;
  1872 	int y1;
  1872 	int y1;
  1873 
  1873 
  1874 	_thd.new_drawstyle = 0;
  1874 	_thd.new_drawstyle = 0;
  1974 
  1974 
  1975 	/* show measurement only if there is any length to speak of */
  1975 	/* show measurement only if there is any length to speak of */
  1976 	if (distance > 1) GuiShowTooltipsWithArgs(STR_MEASURE_LENGTH, 1, &distance);
  1976 	if (distance > 1) GuiShowTooltipsWithArgs(STR_MEASURE_LENGTH, 1, &distance);
  1977 }
  1977 }
  1978 
  1978 
  1979 static void VpStartPreSizing(void)
  1979 static void VpStartPreSizing()
  1980 {
  1980 {
  1981 	_thd.selend.x = -1;
  1981 	_thd.selend.x = -1;
  1982 	_special_mouse_mode = WSM_PRESIZE;
  1982 	_special_mouse_mode = WSM_PRESIZE;
  1983 }
  1983 }
  1984 
  1984 
  2383 	_thd.selend.x = x;
  2383 	_thd.selend.x = x;
  2384 	_thd.selend.y = y;
  2384 	_thd.selend.y = y;
  2385 }
  2385 }
  2386 
  2386 
  2387 // while dragging
  2387 // while dragging
  2388 bool VpHandlePlaceSizingDrag(void)
  2388 bool VpHandlePlaceSizingDrag()
  2389 {
  2389 {
  2390 	Window *w;
  2390 	Window *w;
  2391 	WindowEvent e;
  2391 	WindowEvent e;
  2392 
  2392 
  2393 	if (_special_mouse_mode != WSM_SIZING) return true;
  2393 	if (_special_mouse_mode != WSM_SIZING) return true;
  2475 		SetAnimatedMouseCursor(_animcursors[~icon]);
  2475 		SetAnimatedMouseCursor(_animcursors[~icon]);
  2476 	else
  2476 	else
  2477 		SetMouseCursor(icon, pal);
  2477 		SetMouseCursor(icon, pal);
  2478 }
  2478 }
  2479 
  2479 
  2480 void ResetObjectToPlace(void)
  2480 void ResetObjectToPlace()
  2481 {
  2481 {
  2482 	SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
  2482 	SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
  2483 }
  2483 }