359 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
359 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
360 { |
360 { |
361 ViewPort *vp = w->viewport; |
361 ViewPort *vp = w->viewport; |
362 |
362 |
363 if (vp != NULL && |
363 if (vp != NULL && |
364 IsInsideMM(x, vp->left, vp->left + vp->width) && |
364 IsInsideMM(x, vp->left, vp->left + vp->width) && |
365 IsInsideMM(y, vp->top, vp->top + vp->height)) |
365 IsInsideMM(y, vp->top, vp->top + vp->height)) |
366 return vp; |
366 return vp; |
367 |
367 |
368 return NULL; |
368 return NULL; |
369 } |
369 } |
687 left = ps->left = (pt.x += spr->x_offs); |
687 left = ps->left = (pt.x += spr->x_offs); |
688 right = (pt.x + spr->width ); |
688 right = (pt.x + spr->width ); |
689 top = ps->top = (pt.y += spr->y_offs); |
689 top = ps->top = (pt.y += spr->y_offs); |
690 bottom = (pt.y + spr->height); |
690 bottom = (pt.y + spr->height); |
691 } |
691 } |
|
692 |
692 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
693 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
693 /* Compute maximal extents of sprite and it's bounding box */ |
694 /* Compute maximal extents of sprite and it's bounding box */ |
694 left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
695 left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
695 right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
696 right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
696 top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
697 top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
697 bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
698 bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
698 } |
699 } |
|
700 |
699 /* Do not add the sprite to the viewport, if it is outside */ |
701 /* Do not add the sprite to the viewport, if it is outside */ |
700 if (left >= vd->dpi.left + vd->dpi.width || |
702 if (left >= vd->dpi.left + vd->dpi.width || |
701 right <= vd->dpi.left || |
703 right <= vd->dpi.left || |
702 top >= vd->dpi.top + vd->dpi.height || |
704 top >= vd->dpi.top + vd->dpi.height || |
703 bottom <= vd->dpi.top) { |
705 bottom <= vd->dpi.top) { |
704 return; |
706 return; |
705 } |
707 } |
706 |
708 |
1590 /* null terminate parent sprite list */ |
1592 /* null terminate parent sprite list */ |
1591 *vd.parent_list = NULL; |
1593 *vd.parent_list = NULL; |
1592 |
1594 |
1593 ViewportSortParentSprites(parent_list); |
1595 ViewportSortParentSprites(parent_list); |
1594 ViewportDrawParentSprites(parent_list); |
1596 ViewportDrawParentSprites(parent_list); |
|
1597 |
1595 if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(parent_list); |
1598 if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(parent_list); |
1596 |
1599 |
1597 if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string); |
1600 if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string); |
1598 |
1601 |
1599 _cur_dpi = old_dpi; |
1602 _cur_dpi = old_dpi; |
1704 WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y; |
1707 WP(w, vp_d).scrollpos_y = WP(w, vp_d).dest_scrollpos_y; |
1705 } |
1708 } |
1706 } |
1709 } |
1707 |
1710 |
1708 ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1711 ClampViewportToMap(vp, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
|
1712 |
1709 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1713 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1710 } |
1714 } |
1711 } |
1715 } |
1712 |
1716 |
1713 /** |
1717 /** |
2841 |
2845 |
2842 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
2846 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
2843 { |
2847 { |
2844 Window *w; |
2848 Window *w; |
2845 |
2849 |
2846 /* undo clicking on button */ |
2850 /* undo clicking on button and drag & drop */ |
2847 if (_thd.place_mode != VHM_NONE) { |
2851 if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) { |
2848 _thd.place_mode = VHM_NONE; |
|
2849 w = FindWindowById(_thd.window_class, _thd.window_number); |
2852 w = FindWindowById(_thd.window_class, _thd.window_number); |
2850 if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); |
2853 if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); |
2851 } |
2854 } |
2852 |
2855 |
2853 SetTileSelectSize(1, 1); |
2856 SetTileSelectSize(1, 1); |