mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r6256) if () cascades -> switch ()
This commit is contained in:
parent
22d2ca7cc6
commit
45e34d555c
295
viewport.c
295
viewport.c
@ -1471,187 +1471,210 @@ static bool CheckClickOnTown(const ViewPort *vp, int x, int y)
|
|||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false;
|
if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
x = x - vp->left + vp->virtual_left;
|
case 0:
|
||||||
y = y - vp->top + vp->virtual_top;
|
x = x - vp->left + vp->virtual_left;
|
||||||
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
FOR_ALL_TOWNS(t) {
|
||||||
|
if (y >= t->sign.top &&
|
||||||
|
y < t->sign.top + 12 &&
|
||||||
|
x >= t->sign.left &&
|
||||||
|
x < t->sign.left + t->sign.width_1) {
|
||||||
|
ShowTownViewWindow(t->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
FOR_ALL_TOWNS(t) {
|
case 1:
|
||||||
if (y >= t->sign.top &&
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y < t->sign.top + 12 &&
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
x >= t->sign.left &&
|
FOR_ALL_TOWNS(t) {
|
||||||
x < t->sign.left + t->sign.width_1) {
|
if (y >= t->sign.top &&
|
||||||
ShowTownViewWindow(t->index);
|
y < t->sign.top + 24 &&
|
||||||
return true;
|
x >= t->sign.left &&
|
||||||
|
x < t->sign.left + t->sign.width_1 * 2) {
|
||||||
|
ShowTownViewWindow(t->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (vp->zoom == 1) {
|
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
default:
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
FOR_ALL_TOWNS(t) {
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
if (y >= t->sign.top &&
|
FOR_ALL_TOWNS(t) {
|
||||||
y < t->sign.top + 24 &&
|
if (y >= t->sign.top &&
|
||||||
x >= t->sign.left &&
|
y < t->sign.top + 24 &&
|
||||||
x < t->sign.left + t->sign.width_1 * 2) {
|
x >= t->sign.left &&
|
||||||
ShowTownViewWindow(t->index);
|
x < t->sign.left + t->sign.width_2 * 4) {
|
||||||
return true;
|
ShowTownViewWindow(t->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
|
||||||
FOR_ALL_TOWNS(t) {
|
|
||||||
if (y >= t->sign.top &&
|
|
||||||
y < t->sign.top + 24 &&
|
|
||||||
x >= t->sign.left &&
|
|
||||||
x < t->sign.left + t->sign.width_2 * 4) {
|
|
||||||
ShowTownViewWindow(t->index);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnStation(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Station *st;
|
const Station *st;
|
||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false;
|
if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
x = x - vp->left + vp->virtual_left;
|
case 0:
|
||||||
y = y - vp->top + vp->virtual_top;
|
x = x - vp->left + vp->virtual_left;
|
||||||
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
FOR_ALL_STATIONS(st) {
|
||||||
|
if (y >= st->sign.top &&
|
||||||
|
y < st->sign.top + 12 &&
|
||||||
|
x >= st->sign.left &&
|
||||||
|
x < st->sign.left + st->sign.width_1) {
|
||||||
|
ShowStationViewWindow(st->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
case 1:
|
||||||
if (y >= st->sign.top &&
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y < st->sign.top + 12 &&
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
x >= st->sign.left &&
|
FOR_ALL_STATIONS(st) {
|
||||||
x < st->sign.left + st->sign.width_1) {
|
if (y >= st->sign.top &&
|
||||||
ShowStationViewWindow(st->index);
|
y < st->sign.top + 24 &&
|
||||||
return true;
|
x >= st->sign.left &&
|
||||||
|
x < st->sign.left + st->sign.width_1 * 2) {
|
||||||
|
ShowStationViewWindow(st->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (vp->zoom == 1) {
|
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
default:
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
FOR_ALL_STATIONS(st) {
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
if (y >= st->sign.top &&
|
FOR_ALL_STATIONS(st) {
|
||||||
y < st->sign.top + 24 &&
|
if (y >= st->sign.top &&
|
||||||
x >= st->sign.left &&
|
y < st->sign.top + 24 &&
|
||||||
x < st->sign.left + st->sign.width_1 * 2) {
|
x >= st->sign.left &&
|
||||||
ShowStationViewWindow(st->index);
|
x < st->sign.left + st->sign.width_2 * 4) {
|
||||||
return true;
|
ShowStationViewWindow(st->index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
|
||||||
FOR_ALL_STATIONS(st) {
|
|
||||||
if (y >= st->sign.top &&
|
|
||||||
y < st->sign.top + 24 &&
|
|
||||||
x >= st->sign.left &&
|
|
||||||
x < st->sign.left + st->sign.width_2 * 4) {
|
|
||||||
ShowStationViewWindow(st->index);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnSign(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Sign *si;
|
const Sign *si;
|
||||||
|
|
||||||
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
|
if (!(_display_opt & DO_SHOW_SIGNS)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
x = x - vp->left + vp->virtual_left;
|
case 0:
|
||||||
y = y - vp->top + vp->virtual_top;
|
x = x - vp->left + vp->virtual_left;
|
||||||
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
FOR_ALL_SIGNS(si) {
|
||||||
|
if (y >= si->sign.top &&
|
||||||
|
y < si->sign.top + 12 &&
|
||||||
|
x >= si->sign.left &&
|
||||||
|
x < si->sign.left + si->sign.width_1) {
|
||||||
|
ShowRenameSignWindow(si);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
FOR_ALL_SIGNS(si) {
|
case 1:
|
||||||
if (y >= si->sign.top &&
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y < si->sign.top + 12 &&
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
x >= si->sign.left &&
|
FOR_ALL_SIGNS(si) {
|
||||||
x < si->sign.left + si->sign.width_1) {
|
if (y >= si->sign.top &&
|
||||||
ShowRenameSignWindow(si);
|
y < si->sign.top + 24 &&
|
||||||
return true;
|
x >= si->sign.left &&
|
||||||
|
x < si->sign.left + si->sign.width_1 * 2) {
|
||||||
|
ShowRenameSignWindow(si);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (vp->zoom == 1) {
|
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
default:
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
FOR_ALL_SIGNS(si) {
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
if (y >= si->sign.top &&
|
FOR_ALL_SIGNS(si) {
|
||||||
y < si->sign.top + 24 &&
|
if (y >= si->sign.top &&
|
||||||
x >= si->sign.left &&
|
y < si->sign.top + 24 &&
|
||||||
x < si->sign.left + si->sign.width_1 * 2) {
|
x >= si->sign.left &&
|
||||||
ShowRenameSignWindow(si);
|
x < si->sign.left + si->sign.width_2 * 4) {
|
||||||
return true;
|
ShowRenameSignWindow(si);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
|
||||||
FOR_ALL_SIGNS(si) {
|
|
||||||
if (y >= si->sign.top &&
|
|
||||||
y < si->sign.top + 24 &&
|
|
||||||
x >= si->sign.left &&
|
|
||||||
x < si->sign.left + si->sign.width_2 * 4) {
|
|
||||||
ShowRenameSignWindow(si);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
|
||||||
{
|
{
|
||||||
const Waypoint *wp;
|
const Waypoint *wp;
|
||||||
|
|
||||||
if (!(_display_opt & DO_WAYPOINTS)) return false;
|
if (!(_display_opt & DO_WAYPOINTS)) return false;
|
||||||
|
|
||||||
if (vp->zoom < 1) {
|
switch (vp->zoom) {
|
||||||
x = x - vp->left + vp->virtual_left;
|
case 0:
|
||||||
y = y - vp->top + vp->virtual_top;
|
x = x - vp->left + vp->virtual_left;
|
||||||
|
y = y - vp->top + vp->virtual_top;
|
||||||
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
|
if (y >= wp->sign.top &&
|
||||||
|
y < wp->sign.top + 12 &&
|
||||||
|
x >= wp->sign.left &&
|
||||||
|
x < wp->sign.left + wp->sign.width_1) {
|
||||||
|
ShowRenameWaypointWindow(wp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
case 1:
|
||||||
if (y >= wp->sign.top &&
|
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
||||||
y < wp->sign.top + 12 &&
|
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
||||||
x >= wp->sign.left &&
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
x < wp->sign.left + wp->sign.width_1) {
|
if (y >= wp->sign.top &&
|
||||||
ShowRenameWaypointWindow(wp);
|
y < wp->sign.top + 24 &&
|
||||||
return true;
|
x >= wp->sign.left &&
|
||||||
|
x < wp->sign.left + wp->sign.width_1 * 2) {
|
||||||
|
ShowRenameWaypointWindow(wp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if (vp->zoom == 1) {
|
|
||||||
x = (x - vp->left + 1) * 2 + vp->virtual_left;
|
default:
|
||||||
y = (y - vp->top + 1) * 2 + vp->virtual_top;
|
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
||||||
if (y >= wp->sign.top &&
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
y < wp->sign.top + 24 &&
|
if (y >= wp->sign.top &&
|
||||||
x >= wp->sign.left &&
|
y < wp->sign.top + 24 &&
|
||||||
x < wp->sign.left + wp->sign.width_1 * 2) {
|
x >= wp->sign.left &&
|
||||||
ShowRenameWaypointWindow(wp);
|
x < wp->sign.left + wp->sign.width_2 * 4) {
|
||||||
return true;
|
ShowRenameWaypointWindow(wp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
|
||||||
x = (x - vp->left + 3) * 4 + vp->virtual_left;
|
|
||||||
y = (y - vp->top + 3) * 4 + vp->virtual_top;
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
|
||||||
if (y >= wp->sign.top &&
|
|
||||||
y < wp->sign.top + 24 &&
|
|
||||||
x >= wp->sign.left &&
|
|
||||||
x < wp->sign.left + wp->sign.width_2 * 4) {
|
|
||||||
ShowRenameWaypointWindow(wp);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user