src/viewport.cpp
changeset 7954 57b51c69c072
parent 7951 9df5b61377c7
child 7970 7d6b9ab57081
equal deleted inserted replaced
7953:db4cd9ef0efc 7954:57b51c69c072
   342 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
   342 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y)
   343 {
   343 {
   344 	ViewPort *vp = w->viewport;
   344 	ViewPort *vp = w->viewport;
   345 
   345 
   346 	if (vp != NULL &&
   346 	if (vp != NULL &&
   347 	    IS_INT_INSIDE(x, vp->left, vp->left + vp->width) &&
   347 	    IsInsideMM(x, vp->left, vp->left + vp->width) &&
   348 			IS_INT_INSIDE(y, vp->top, vp->top + vp->height))
   348 			IsInsideMM(y, vp->top, vp->top + vp->height))
   349 		return vp;
   349 		return vp;
   350 
   350 
   351 	return NULL;
   351 	return NULL;
   352 }
   352 }
   353 
   353 
   499  * @param extra_offs_y Pixel Y offset for the sprite position.
   499  * @param extra_offs_y Pixel Y offset for the sprite position.
   500  */
   500  */
   501 static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y)
   501 static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y)
   502 {
   502 {
   503 	ViewportDrawer *vd = _cur_vd;
   503 	ViewportDrawer *vd = _cur_vd;
   504 	assert(IS_INT_INSIDE(foundation_part, 0, FOUNDATION_PART_END));
   504 	assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
   505 	assert(vd->foundation[foundation_part] != NULL);
   505 	assert(vd->foundation[foundation_part] != NULL);
   506 	Point offs = vd->foundation_offset[foundation_part];
   506 	Point offs = vd->foundation_offset[foundation_part];
   507 
   507 
   508 	/* Change the active ChildSprite list to the one of the foundation */
   508 	/* Change the active ChildSprite list to the one of the foundation */
   509 	ChildScreenSpriteToDraw **old_child = vd->last_child;
   509 	ChildScreenSpriteToDraw **old_child = vd->last_child;
   930 
   930 
   931 	/* no selection active? */
   931 	/* no selection active? */
   932 	if (_thd.drawstyle == 0) return;
   932 	if (_thd.drawstyle == 0) return;
   933 
   933 
   934 	/* Inside the inner area? */
   934 	/* Inside the inner area? */
   935 	if (IS_INSIDE_1D(ti->x, _thd.pos.x, _thd.size.x) &&
   935 	if (IsInsideBS(ti->x, _thd.pos.x, _thd.size.x) &&
   936 			IS_INSIDE_1D(ti->y, _thd.pos.y, _thd.size.y)) {
   936 			IsInsideBS(ti->y, _thd.pos.y, _thd.size.y)) {
   937 		if (_thd.drawstyle & HT_RECT) {
   937 		if (_thd.drawstyle & HT_RECT) {
   938 			DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE);
   938 			DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE);
   939 		} else if (_thd.drawstyle & HT_POINT) {
   939 		} else if (_thd.drawstyle & HT_POINT) {
   940 			/* Figure out the Z coordinate for the single dot. */
   940 			/* Figure out the Z coordinate for the single dot. */
   941 			byte z = 0;
   941 			byte z = 0;
   976 	}
   976 	}
   977 
   977 
   978 	/* Check if it's inside the outer area? */
   978 	/* Check if it's inside the outer area? */
   979 	if (_thd.outersize.x &&
   979 	if (_thd.outersize.x &&
   980 			_thd.size.x < _thd.size.x + _thd.outersize.x &&
   980 			_thd.size.x < _thd.size.x + _thd.outersize.x &&
   981 			IS_INSIDE_1D(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
   981 			IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
   982 			IS_INSIDE_1D(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
   982 			IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
   983 		/* Draw a blue rect. */
   983 		/* Draw a blue rect. */
   984 		DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE);
   984 		DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE);
   985 		return;
   985 		return;
   986 	}
   986 	}
   987 }
   987 }
  1752 void MarkTileDirty(int x, int y)
  1752 void MarkTileDirty(int x, int y)
  1753 {
  1753 {
  1754 	uint z = 0;
  1754 	uint z = 0;
  1755 	Point pt;
  1755 	Point pt;
  1756 
  1756 
  1757 	if (IS_INT_INSIDE(x, 0, MapSizeX() * TILE_SIZE) &&
  1757 	if (IsInsideMM(x, 0, MapSizeX() * TILE_SIZE) &&
  1758 			IS_INT_INSIDE(y, 0, MapSizeY() * TILE_SIZE))
  1758 			IsInsideMM(y, 0, MapSizeY() * TILE_SIZE))
  1759 		z = GetTileZ(TileVirtXY(x, y));
  1759 		z = GetTileZ(TileVirtXY(x, y));
  1760 	pt = RemapCoords(x, y, z);
  1760 	pt = RemapCoords(x, y, z);
  1761 
  1761 
  1762 	MarkAllViewportsDirty(
  1762 	MarkAllViewportsDirty(
  1763 		pt.x - 31,
  1763 		pt.x - 31,