360 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
360 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
361 { |
361 { |
362 ViewPort *vp = w->viewport; |
362 ViewPort *vp = w->viewport; |
363 |
363 |
364 if (vp != NULL && |
364 if (vp != NULL && |
365 IsInsideMM(x, vp->left, vp->left + vp->width) && |
365 IsInsideMM(x, vp->left, vp->left + vp->width) && |
366 IsInsideMM(y, vp->top, vp->top + vp->height)) |
366 IsInsideMM(y, vp->top, vp->top + vp->height)) |
367 return vp; |
367 return vp; |
368 |
368 |
369 return NULL; |
369 return NULL; |
370 } |
370 } |
688 left = ps->left = (pt.x += spr->x_offs); |
688 left = ps->left = (pt.x += spr->x_offs); |
689 right = (pt.x + spr->width ); |
689 right = (pt.x + spr->width ); |
690 top = ps->top = (pt.y += spr->y_offs); |
690 top = ps->top = (pt.y += spr->y_offs); |
691 bottom = (pt.y + spr->height); |
691 bottom = (pt.y + spr->height); |
692 } |
692 } |
|
693 |
693 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
694 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
694 /* Compute maximal extents of sprite and it's bounding box */ |
695 /* Compute maximal extents of sprite and it's bounding box */ |
695 left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
696 left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
696 right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
697 right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
697 top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
698 top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
698 bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
699 bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
699 } |
700 } |
|
701 |
700 /* Do not add the sprite to the viewport, if it is outside */ |
702 /* Do not add the sprite to the viewport, if it is outside */ |
701 if (left >= vd->dpi.left + vd->dpi.width || |
703 if (left >= vd->dpi.left + vd->dpi.width || |
702 right <= vd->dpi.left || |
704 right <= vd->dpi.left || |
703 top >= vd->dpi.top + vd->dpi.height || |
705 top >= vd->dpi.top + vd->dpi.height || |
704 bottom <= vd->dpi.top) { |
706 bottom <= vd->dpi.top) { |
705 return; |
707 return; |
706 } |
708 } |
707 |
709 |
1615 /* null terminate parent sprite list */ |
1617 /* null terminate parent sprite list */ |
1616 *vd.parent_list = NULL; |
1618 *vd.parent_list = NULL; |
1617 |
1619 |
1618 ViewportSortParentSprites(parent_list); |
1620 ViewportSortParentSprites(parent_list); |
1619 ViewportDrawParentSprites(parent_list); |
1621 ViewportDrawParentSprites(parent_list); |
|
1622 |
1620 if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(parent_list); |
1623 if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(parent_list); |
1621 |
1624 |
1622 if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string); |
1625 if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string); |
1623 |
1626 |
1624 _cur_dpi = old_dpi; |
1627 _cur_dpi = old_dpi; |
1729 WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y; |
1732 WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y; |
1730 } |
1733 } |
1731 } |
1734 } |
1732 |
1735 |
1733 ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1736 ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
|
1737 |
1734 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1738 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1735 } |
1739 } |
1736 } |
1740 } |
1737 |
1741 |
1738 /** |
1742 /** |
2866 |
2870 |
2867 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
2871 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
2868 { |
2872 { |
2869 Window *w; |
2873 Window *w; |
2870 |
2874 |
2871 /* undo clicking on button */ |
2875 /* undo clicking on button and drag & drop */ |
2872 if (_thd.place_mode != VHM_NONE) { |
2876 if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) { |
2873 _thd.place_mode = VHM_NONE; |
|
2874 w = FindWindowById(_thd.window_class, _thd.window_number); |
2877 w = FindWindowById(_thd.window_class, _thd.window_number); |
2875 if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); |
2878 if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); |
2876 } |
2879 } |
2877 |
2880 |
2878 SetTileSelectSize(1, 1); |
2881 SetTileSelectSize(1, 1); |