Mercurial > hg > openttd
comparison src/viewport.cpp @ 5587:c44c070c5032 draft
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 10 Jan 2007 18:56:51 +0000 |
parents | 4b26bd55bd24 |
children | ca6b459bf488 |
comparison
equal
deleted
inserted
replaced
5586:9a8c53342d29 | 5587:c44c070c5032 |
---|---|
678 | 678 |
679 if (dir < 2) { | 679 if (dir < 2) { |
680 side = 0; | 680 side = 0; |
681 } else { | 681 } else { |
682 TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); | 682 TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); |
683 int diffx = myabs(TileX(start) - TileX(ti->tile)); | 683 side = delta(delta(TileX(start), TileX(ti->tile)), delta(TileY(start), TileY(ti->tile))); |
684 int diffy = myabs(TileY(start) - TileY(ti->tile)); | |
685 side = myabs(diffx - diffy); | |
686 } | 684 } |
687 | 685 |
688 image = SPR_AUTORAIL_BASE + _AutorailTilehSprite[ti->tileh][_AutorailType[dir][side]]; | 686 image = SPR_AUTORAIL_BASE + _AutorailTilehSprite[ti->tileh][_AutorailType[dir][side]]; |
689 | 687 |
690 if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED; | 688 if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED; |
836 | 834 |
837 static void AddStation(const Station *st, StringID str, uint16 width) | 835 static void AddStation(const Station *st, StringID str, uint16 width) |
838 { | 836 { |
839 StringSpriteToDraw *sstd; | 837 StringSpriteToDraw *sstd; |
840 | 838 |
841 sstd = AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities); | 839 sstd = (StringSpriteToDraw*)AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities); |
842 if (sstd != NULL) { | 840 if (sstd != NULL) { |
843 sstd->color = (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _player_colors[st->owner]; | 841 sstd->color = (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _player_colors[st->owner]; |
844 sstd->width = width; | 842 sstd->width = width; |
845 } | 843 } |
846 } | 844 } |
903 | 901 |
904 static void AddSign(const Sign *si, StringID str, uint16 width) | 902 static void AddSign(const Sign *si, StringID str, uint16 width) |
905 { | 903 { |
906 StringSpriteToDraw *sstd; | 904 StringSpriteToDraw *sstd; |
907 | 905 |
908 sstd = AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->str, 0); | 906 sstd = (StringSpriteToDraw*)AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->str, 0); |
909 if (sstd != NULL) { | 907 if (sstd != NULL) { |
910 sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner]; | 908 sstd->color = (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner]; |
911 sstd->width = width; | 909 sstd->width = width; |
912 } | 910 } |
913 } | 911 } |
970 | 968 |
971 static void AddWaypoint(const Waypoint *wp, StringID str, uint16 width) | 969 static void AddWaypoint(const Waypoint *wp, StringID str, uint16 width) |
972 { | 970 { |
973 StringSpriteToDraw *sstd; | 971 StringSpriteToDraw *sstd; |
974 | 972 |
975 sstd = AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0); | 973 sstd = (StringSpriteToDraw*)AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0); |
976 if (sstd != NULL) { | 974 if (sstd != NULL) { |
977 sstd->color = (wp->deleted ? 0xE : 11); | 975 sstd->color = (wp->deleted ? 0xE : 11); |
978 sstd->width = width; | 976 sstd->width = width; |
979 } | 977 } |
980 } | 978 } |
1173 /* Draw the rectangle if 'tranparent station signs' is off, | 1171 /* Draw the rectangle if 'tranparent station signs' is off, |
1174 * or if we are drawing a general text sign (STR_2806) */ | 1172 * or if we are drawing a general text sign (STR_2806) */ |
1175 if (!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806) | 1173 if (!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806) |
1176 DrawFrameRect( | 1174 DrawFrameRect( |
1177 x, y, x + w, bottom, ss->color, | 1175 x, y, x + w, bottom, ss->color, |
1178 (_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT : 0 | 1176 (_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT : FR_NONE |
1179 ); | 1177 ); |
1180 } | 1178 } |
1181 | 1179 |
1182 SetDParam(0, ss->params[0]); | 1180 SetDParam(0, ss->params[0]); |
1183 SetDParam(1, ss->params[1]); | 1181 SetDParam(1, ss->params[1]); |
2316 | 2314 |
2317 case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */ | 2315 case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */ |
2318 int limit = (_thd.sizelimit - 1) * TILE_SIZE; | 2316 int limit = (_thd.sizelimit - 1) * TILE_SIZE; |
2319 x = sx + clamp(x - sx, -limit, limit); | 2317 x = sx + clamp(x - sx, -limit, limit); |
2320 y = sy + clamp(y - sy, -limit, limit); | 2318 y = sy + clamp(y - sy, -limit, limit); |
2321 /* Fallthrough */ | 2319 } /* Fallthrough */ |
2322 case VPM_X_AND_Y: /* drag an X by Y area */ | 2320 case VPM_X_AND_Y: { /* drag an X by Y area */ |
2323 if (_patches.measure_tooltip) { | 2321 if (_patches.measure_tooltip) { |
2324 static const StringID measure_strings_area[] = { | 2322 static const StringID measure_strings_area[] = { |
2325 STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF | 2323 STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF |
2326 }; | 2324 }; |
2327 | 2325 |
2328 TileIndex t0 = TileVirtXY(sx, sy); | 2326 TileIndex t0 = TileVirtXY(sx, sy); |
2329 TileIndex t1 = TileVirtXY(x, y); | 2327 TileIndex t1 = TileVirtXY(x, y); |
2330 uint dx = abs(TileX(t0) - TileX(t1)) + 1; | 2328 uint dx = delta(TileX(t0), TileX(t1)) + 1; |
2331 uint dy = abs(TileY(t0) - TileY(t1)) + 1; | 2329 uint dy = delta(TileY(t0), TileY(t1)) + 1; |
2332 byte index = 0; | 2330 byte index = 0; |
2333 uint params[3]; | 2331 uint params[3]; |
2334 | 2332 |
2335 /* If dragging an area (eg dynamite tool) and it is actually a single | 2333 /* If dragging an area (eg dynamite tool) and it is actually a single |
2336 * row/column, change the type to 'line' to get proper calculation for height */ | 2334 * row/column, change the type to 'line' to get proper calculation for height */ |