mirror of https://github.com/OpenTTD/OpenTTD
(svn r7068) if () cascades -> switch ()
parent
f9fa8437eb
commit
a763e7e52e
265
viewport.c
265
viewport.c
|
@ -768,48 +768,51 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
|
||||||
right = left + dpi->width;
|
right = left + dpi->width;
|
||||||
bottom = top + dpi->height;
|
bottom = top + dpi->height;
|
||||||
|
|
||||||
if (dpi->zoom < 1) {
|
switch (dpi->zoom) {
|
||||||
FOR_ALL_TOWNS(t) {
|
case 0:
|
||||||
if (bottom > t->sign.top &&
|
FOR_ALL_TOWNS(t) {
|
||||||
top < t->sign.top + 12 &&
|
if (bottom > t->sign.top &&
|
||||||
right > t->sign.left &&
|
top < t->sign.top + 12 &&
|
||||||
left < t->sign.left + t->sign.width_1) {
|
right > t->sign.left &&
|
||||||
|
left < t->sign.left + t->sign.width_1) {
|
||||||
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
|
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
|
||||||
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
|
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
|
||||||
t->index, t->population);
|
t->index, t->population);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (dpi->zoom == 1) {
|
|
||||||
right += 2;
|
|
||||||
bottom += 2;
|
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
case 1:
|
||||||
if (bottom > t->sign.top &&
|
right += 2;
|
||||||
top < t->sign.top + 24 &&
|
bottom += 2;
|
||||||
right > t->sign.left &&
|
|
||||||
left < t->sign.left + t->sign.width_1*2) {
|
|
||||||
|
|
||||||
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
|
FOR_ALL_TOWNS(t) {
|
||||||
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
|
if (bottom > t->sign.top &&
|
||||||
t->index, t->population);
|
top < t->sign.top + 24 &&
|
||||||
|
right > t->sign.left &&
|
||||||
|
left < t->sign.left + t->sign.width_1*2) {
|
||||||
|
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
|
||||||
|
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
|
||||||
|
t->index, t->population);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
|
||||||
right += 4;
|
|
||||||
bottom += 5;
|
|
||||||
|
|
||||||
assert(dpi->zoom == 2);
|
default: NOT_REACHED();
|
||||||
FOR_ALL_TOWNS(t) {
|
case 2:
|
||||||
if (bottom > t->sign.top &&
|
right += 4;
|
||||||
top < t->sign.top + 24 &&
|
bottom += 5;
|
||||||
right > t->sign.left &&
|
|
||||||
left < t->sign.left + t->sign.width_2*4) {
|
|
||||||
|
|
||||||
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0);
|
FOR_ALL_TOWNS(t) {
|
||||||
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0);
|
if (bottom > t->sign.top &&
|
||||||
|
top < t->sign.top + 24 &&
|
||||||
|
right > t->sign.left &&
|
||||||
|
left < t->sign.left + t->sign.width_2*4) {
|
||||||
|
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0);
|
||||||
|
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,42 +842,44 @@ static void ViewportAddStationNames(DrawPixelInfo *dpi)
|
||||||
right = left + dpi->width;
|
right = left + dpi->width;
|
||||||
bottom = top + dpi->height;
|
bottom = top + dpi->height;
|
||||||
|
|
||||||
if (dpi->zoom < 1) {
|
switch (dpi->zoom) {
|
||||||
FOR_ALL_STATIONS(st) {
|
case 0:
|
||||||
if (bottom > st->sign.top &&
|
FOR_ALL_STATIONS(st) {
|
||||||
top < st->sign.top + 12 &&
|
if (bottom > st->sign.top &&
|
||||||
right > st->sign.left &&
|
top < st->sign.top + 12 &&
|
||||||
left < st->sign.left + st->sign.width_1) {
|
right > st->sign.left &&
|
||||||
AddStation(st, STR_305C_0, st->sign.width_1);
|
left < st->sign.left + st->sign.width_1) {
|
||||||
|
AddStation(st, STR_305C_0, st->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (dpi->zoom == 1) {
|
|
||||||
right += 2;
|
|
||||||
bottom += 2;
|
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
case 1:
|
||||||
if (bottom > st->sign.top &&
|
right += 2;
|
||||||
top < st->sign.top + 24 &&
|
bottom += 2;
|
||||||
right > st->sign.left &&
|
FOR_ALL_STATIONS(st) {
|
||||||
left < st->sign.left + st->sign.width_1*2) {
|
if (bottom > st->sign.top &&
|
||||||
AddStation(st, STR_305C_0, st->sign.width_1);
|
top < st->sign.top + 24 &&
|
||||||
|
right > st->sign.left &&
|
||||||
|
left < st->sign.left + st->sign.width_1*2) {
|
||||||
|
AddStation(st, STR_305C_0, st->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
} else {
|
default: NOT_REACHED();
|
||||||
assert(dpi->zoom == 2);
|
case 2:
|
||||||
|
right += 4;
|
||||||
right += 4;
|
bottom += 5;
|
||||||
bottom += 5;
|
FOR_ALL_STATIONS(st) {
|
||||||
|
if (bottom > st->sign.top &&
|
||||||
FOR_ALL_STATIONS(st) {
|
top < st->sign.top + 24 &&
|
||||||
if (bottom > st->sign.top &&
|
right > st->sign.left &&
|
||||||
top < st->sign.top + 24 &&
|
left < st->sign.left + st->sign.width_2*4) {
|
||||||
right > st->sign.left &&
|
AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000);
|
||||||
left < st->sign.left + st->sign.width_2*4) {
|
}
|
||||||
AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000);
|
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,38 +909,44 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
|
||||||
right = left + dpi->width;
|
right = left + dpi->width;
|
||||||
bottom = top + dpi->height;
|
bottom = top + dpi->height;
|
||||||
|
|
||||||
if (dpi->zoom < 1) {
|
switch (dpi->zoom) {
|
||||||
FOR_ALL_SIGNS(si) {
|
case 0:
|
||||||
if (bottom > si->sign.top &&
|
FOR_ALL_SIGNS(si) {
|
||||||
top < si->sign.top + 12 &&
|
if (bottom > si->sign.top &&
|
||||||
right > si->sign.left &&
|
top < si->sign.top + 12 &&
|
||||||
left < si->sign.left + si->sign.width_1) {
|
right > si->sign.left &&
|
||||||
AddSign(si, STR_2806, si->sign.width_1);
|
left < si->sign.left + si->sign.width_1) {
|
||||||
|
AddSign(si, STR_2806, si->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (dpi->zoom == 1) {
|
|
||||||
right += 2;
|
|
||||||
bottom += 2;
|
|
||||||
FOR_ALL_SIGNS(si) {
|
|
||||||
if (bottom > si->sign.top &&
|
|
||||||
top < si->sign.top + 24 &&
|
|
||||||
right > si->sign.left &&
|
|
||||||
left < si->sign.left + si->sign.width_1 * 2) {
|
|
||||||
AddSign(si, STR_2806, si->sign.width_1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
right += 4;
|
|
||||||
bottom += 5;
|
|
||||||
|
|
||||||
FOR_ALL_SIGNS(si) {
|
case 1:
|
||||||
if (bottom > si->sign.top &&
|
right += 2;
|
||||||
top < si->sign.top + 24 &&
|
bottom += 2;
|
||||||
right > si->sign.left &&
|
FOR_ALL_SIGNS(si) {
|
||||||
left < si->sign.left + si->sign.width_2 * 4) {
|
if (bottom > si->sign.top &&
|
||||||
AddSign(si, STR_2002, si->sign.width_2 | 0x8000);
|
top < si->sign.top + 24 &&
|
||||||
|
right > si->sign.left &&
|
||||||
|
left < si->sign.left + si->sign.width_1 * 2) {
|
||||||
|
AddSign(si, STR_2806, si->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
default: NOT_REACHED();
|
||||||
|
case 2:
|
||||||
|
right += 4;
|
||||||
|
bottom += 5;
|
||||||
|
FOR_ALL_SIGNS(si) {
|
||||||
|
if (bottom > si->sign.top &&
|
||||||
|
top < si->sign.top + 24 &&
|
||||||
|
right > si->sign.left &&
|
||||||
|
left < si->sign.left + si->sign.width_2 * 4) {
|
||||||
|
AddSign(si, STR_2002, si->sign.width_2 | 0x8000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,38 +976,44 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi)
|
||||||
right = left + dpi->width;
|
right = left + dpi->width;
|
||||||
bottom = top + dpi->height;
|
bottom = top + dpi->height;
|
||||||
|
|
||||||
if (dpi->zoom < 1) {
|
switch (dpi->zoom) {
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
case 0:
|
||||||
if (bottom > wp->sign.top &&
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
top < wp->sign.top + 12 &&
|
if (bottom > wp->sign.top &&
|
||||||
right > wp->sign.left &&
|
top < wp->sign.top + 12 &&
|
||||||
left < wp->sign.left + wp->sign.width_1) {
|
right > wp->sign.left &&
|
||||||
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
|
left < wp->sign.left + wp->sign.width_1) {
|
||||||
|
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (dpi->zoom == 1) {
|
|
||||||
right += 2;
|
|
||||||
bottom += 2;
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
|
||||||
if (bottom > wp->sign.top &&
|
|
||||||
top < wp->sign.top + 24 &&
|
|
||||||
right > wp->sign.left &&
|
|
||||||
left < wp->sign.left + wp->sign.width_1*2) {
|
|
||||||
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
right += 4;
|
|
||||||
bottom += 5;
|
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
case 1:
|
||||||
if (bottom > wp->sign.top &&
|
right += 2;
|
||||||
top < wp->sign.top + 24 &&
|
bottom += 2;
|
||||||
right > wp->sign.left &&
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
left < wp->sign.left + wp->sign.width_2*4) {
|
if (bottom > wp->sign.top &&
|
||||||
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000);
|
top < wp->sign.top + 24 &&
|
||||||
|
right > wp->sign.left &&
|
||||||
|
left < wp->sign.left + wp->sign.width_1*2) {
|
||||||
|
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
default: NOT_REACHED();
|
||||||
|
case 2:
|
||||||
|
right += 4;
|
||||||
|
bottom += 5;
|
||||||
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
|
if (bottom > wp->sign.top &&
|
||||||
|
top < wp->sign.top + 24 &&
|
||||||
|
right > wp->sign.left &&
|
||||||
|
left < wp->sign.left + wp->sign.width_2*4) {
|
||||||
|
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue