viewport.c
changeset 4349 2fc39ff2626e
parent 4346 3f00094f2670
child 4439 08183ae93367
equal deleted inserted replaced
4348:95ba9ff1612e 4349:2fc39ff2626e
   881 	}
   881 	}
   882 }
   882 }
   883 
   883 
   884 static void ViewportAddSigns(DrawPixelInfo *dpi)
   884 static void ViewportAddSigns(DrawPixelInfo *dpi)
   885 {
   885 {
   886 	SignStruct *ss;
   886 	Sign *si;
   887 	int left, top, right, bottom;
   887 	int left, top, right, bottom;
   888 	StringSpriteToDraw *sstd;
   888 	StringSpriteToDraw *sstd;
   889 
   889 
   890 	if (!(_display_opt & DO_SHOW_SIGNS))
   890 	if (!(_display_opt & DO_SHOW_SIGNS))
   891 		return;
   891 		return;
   894 	top = dpi->top;
   894 	top = dpi->top;
   895 	right = left + dpi->width;
   895 	right = left + dpi->width;
   896 	bottom = top + dpi->height;
   896 	bottom = top + dpi->height;
   897 
   897 
   898 	if (dpi->zoom < 1) {
   898 	if (dpi->zoom < 1) {
   899 		FOR_ALL_SIGNS(ss) {
   899 		FOR_ALL_SIGNS(si) {
   900 			if (bottom > ss->sign.top &&
   900 			if (bottom > si->sign.top &&
   901 					top < ss->sign.top + 12 &&
   901 					top < si->sign.top + 12 &&
   902 					right > ss->sign.left &&
   902 					right > si->sign.left &&
   903 					left < ss->sign.left + ss->sign.width_1) {
   903 					left < si->sign.left + si->sign.width_1) {
   904 
   904 
   905 				sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0);
   905 				sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2806, si->str, 0, 0);
   906 				if (sstd != NULL) {
   906 				if (sstd != NULL) {
   907 					sstd->width = ss->sign.width_1;
   907 					sstd->width = si->sign.width_1;
   908 					sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner];
   908 					sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
   909 				}
   909 				}
   910 			}
   910 			}
   911 		}
   911 		}
   912 	} else if (dpi->zoom == 1) {
   912 	} else if (dpi->zoom == 1) {
   913 		right += 2;
   913 		right += 2;
   914 		bottom += 2;
   914 		bottom += 2;
   915 		FOR_ALL_SIGNS(ss) {
   915 		FOR_ALL_SIGNS(si) {
   916 			if (bottom > ss->sign.top &&
   916 			if (bottom > si->sign.top &&
   917 					top < ss->sign.top + 24 &&
   917 					top < si->sign.top + 24 &&
   918 					right > ss->sign.left &&
   918 					right > si->sign.left &&
   919 					left < ss->sign.left + ss->sign.width_1*2) {
   919 					left < si->sign.left + si->sign.width_1 * 2) {
   920 
   920 
   921 				sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0);
   921 				sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2806, si->str, 0, 0);
   922 				if (sstd != NULL) {
   922 				if (sstd != NULL) {
   923 					sstd->width = ss->sign.width_1;
   923 					sstd->width = si->sign.width_1;
   924 					sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner];
   924 					sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
   925 				}
   925 				}
   926 			}
   926 			}
   927 		}
   927 		}
   928 	} else {
   928 	} else {
   929 		right += 4;
   929 		right += 4;
   930 		bottom += 5;
   930 		bottom += 5;
   931 
   931 
   932 		FOR_ALL_SIGNS(ss) {
   932 		FOR_ALL_SIGNS(si) {
   933 			if (bottom > ss->sign.top &&
   933 			if (bottom > si->sign.top &&
   934 					top < ss->sign.top + 24 &&
   934 					top < si->sign.top + 24 &&
   935 					right > ss->sign.left &&
   935 					right > si->sign.left &&
   936 					left < ss->sign.left + ss->sign.width_2*4) {
   936 					left < si->sign.left + si->sign.width_2 * 4) {
   937 
   937 
   938 				sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2002, ss->str, 0, 0);
   938 				sstd=AddStringToDraw(si->sign.left + 1, si->sign.top + 1, STR_2002, si->str, 0, 0);
   939 				if (sstd != NULL) {
   939 				if (sstd != NULL) {
   940 					sstd->width = ss->sign.width_2 | 0x8000;
   940 					sstd->width = si->sign.width_2 | 0x8000;
   941 					sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner];
   941 					sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner];
   942 				}
   942 				}
   943 			}
   943 			}
   944 		}
   944 		}
   945 	}
   945 	}
   946 }
   946 }
  1561 	return false;
  1561 	return false;
  1562 }
  1562 }
  1563 
  1563 
  1564 static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
  1564 static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
  1565 {
  1565 {
  1566 	const SignStruct *ss;
  1566 	const Sign *si;
  1567 
  1567 
  1568 	if (!(_display_opt & DO_SHOW_SIGNS)) return false;
  1568 	if (!(_display_opt & DO_SHOW_SIGNS)) return false;
  1569 
  1569 
  1570 	if (vp->zoom < 1) {
  1570 	if (vp->zoom < 1) {
  1571 		x = x - vp->left + vp->virtual_left;
  1571 		x = x - vp->left + vp->virtual_left;
  1572 		y = y - vp->top + vp->virtual_top;
  1572 		y = y - vp->top + vp->virtual_top;
  1573 
  1573 
  1574 		FOR_ALL_SIGNS(ss) {
  1574 		FOR_ALL_SIGNS(si) {
  1575 			if (y >= ss->sign.top &&
  1575 			if (y >= si->sign.top &&
  1576 					y < ss->sign.top + 12 &&
  1576 					y < si->sign.top + 12 &&
  1577 					x >= ss->sign.left &&
  1577 					x >= si->sign.left &&
  1578 					x < ss->sign.left + ss->sign.width_1) {
  1578 					x < si->sign.left + si->sign.width_1) {
  1579 				ShowRenameSignWindow(ss);
  1579 				ShowRenameSignWindow(si);
  1580 				return true;
  1580 				return true;
  1581 			}
  1581 			}
  1582 		}
  1582 		}
  1583 	} else if (vp->zoom == 1) {
  1583 	} else if (vp->zoom == 1) {
  1584 		x = (x - vp->left + 1) * 2 + vp->virtual_left;
  1584 		x = (x - vp->left + 1) * 2 + vp->virtual_left;
  1585 		y = (y - vp->top + 1) * 2 + vp->virtual_top;
  1585 		y = (y - vp->top + 1) * 2 + vp->virtual_top;
  1586 		FOR_ALL_SIGNS(ss) {
  1586 		FOR_ALL_SIGNS(si) {
  1587 			if (y >= ss->sign.top &&
  1587 			if (y >= si->sign.top &&
  1588 					y < ss->sign.top + 24 &&
  1588 					y < si->sign.top + 24 &&
  1589 					x >= ss->sign.left &&
  1589 					x >= si->sign.left &&
  1590 					x < ss->sign.left + ss->sign.width_1 * 2) {
  1590 					x < si->sign.left + si->sign.width_1 * 2) {
  1591 				ShowRenameSignWindow(ss);
  1591 				ShowRenameSignWindow(si);
  1592 				return true;
  1592 				return true;
  1593 			}
  1593 			}
  1594 		}
  1594 		}
  1595 	} else {
  1595 	} else {
  1596 		x = (x - vp->left + 3) * 4 + vp->virtual_left;
  1596 		x = (x - vp->left + 3) * 4 + vp->virtual_left;
  1597 		y = (y - vp->top + 3) * 4 + vp->virtual_top;
  1597 		y = (y - vp->top + 3) * 4 + vp->virtual_top;
  1598 		FOR_ALL_SIGNS(ss) {
  1598 		FOR_ALL_SIGNS(si) {
  1599 			if (y >= ss->sign.top &&
  1599 			if (y >= si->sign.top &&
  1600 					y < ss->sign.top + 24 &&
  1600 					y < si->sign.top + 24 &&
  1601 					x >= ss->sign.left &&
  1601 					x >= si->sign.left &&
  1602 					x < ss->sign.left + ss->sign.width_2 * 4) {
  1602 					x < si->sign.left + si->sign.width_2 * 4) {
  1603 				ShowRenameSignWindow(ss);
  1603 				ShowRenameSignWindow(si);
  1604 				return true;
  1604 				return true;
  1605 			}
  1605 			}
  1606 		}
  1606 		}
  1607 	}
  1607 	}
  1608 
  1608