175 |
175 |
176 static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction) |
176 static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction) |
177 { |
177 { |
178 tile += TileOffsByDiagDir(direction); |
178 tile += TileOffsByDiagDir(direction); |
179 // if there is a roadpiece just outside of the station entrance, build a connecting route |
179 // if there is a roadpiece just outside of the station entrance, build a connecting route |
180 if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
180 if (IsNormalRoadTile(tile)) { |
181 if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { |
181 if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { |
182 DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD); |
182 DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD); |
183 } |
183 } |
184 } |
184 } |
185 } |
185 } |
253 RTW_REMOVE, |
253 RTW_REMOVE, |
254 }; |
254 }; |
255 |
255 |
256 typedef void OnButtonClick(Window *w); |
256 typedef void OnButtonClick(Window *w); |
257 |
257 |
|
258 |
|
259 /** Toogles state of the Remove button of Build road toolbar |
|
260 * @param w window the button belongs to |
|
261 */ |
|
262 static void ToggleRoadButton_Remove(Window *w) |
|
263 { |
|
264 w->ToggleWidgetLoweredState(RTW_REMOVE); |
|
265 w->InvalidateWidget(RTW_REMOVE); |
|
266 _remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE); |
|
267 SetSelectionRed(_remove_button_clicked); |
|
268 } |
|
269 |
|
270 /** Updates the Remove button because of Ctrl state change |
|
271 * @param w window the button belongs to |
|
272 * @return true iff the remove buton was changed |
|
273 */ |
|
274 static bool RoadToolbar_CtrlChanged(Window *w) |
|
275 { |
|
276 if (w->IsWidgetDisabled(RTW_REMOVE)) return false; |
|
277 |
|
278 /* allow ctrl to switch remove mode only for these widgets */ |
|
279 for (uint i = RTW_ROAD_X; i <= RTW_AUTOROAD; i++) { |
|
280 if (w->IsWidgetLowered(i)) { |
|
281 ToggleRoadButton_Remove(w); |
|
282 return true; |
|
283 } |
|
284 } |
|
285 |
|
286 return false; |
|
287 } |
|
288 |
|
289 |
258 /** |
290 /** |
259 * Function that handles the click on the |
291 * Function that handles the click on the |
260 * X road placement button. |
292 * X road placement button. |
261 * |
293 * |
262 * @param w The current window |
294 * @param w The current window |
336 } |
368 } |
337 |
369 |
338 static void BuildRoadClick_Remove(Window *w) |
370 static void BuildRoadClick_Remove(Window *w) |
339 { |
371 { |
340 if (w->IsWidgetDisabled(RTW_REMOVE)) return; |
372 if (w->IsWidgetDisabled(RTW_REMOVE)) return; |
341 SetWindowDirty(w); |
373 ToggleRoadButton_Remove(w); |
342 SndPlayFx(SND_15_BEEP); |
374 SndPlayFx(SND_15_BEEP); |
343 w->ToggleWidgetLoweredState(RTW_REMOVE); |
|
344 SetSelectionRed(w->IsWidgetLowered(RTW_REMOVE)); |
|
345 } |
375 } |
346 |
376 |
347 /** Array with the handlers of the button-clicks for the road-toolbar */ |
377 /** Array with the handlers of the button-clicks for the road-toolbar */ |
348 static OnButtonClick* const _build_road_button_proc[] = { |
378 static OnButtonClick* const _build_road_button_proc[] = { |
349 BuildRoadClick_X_Dir, |
379 BuildRoadClick_X_Dir, |
444 _remove_button_clicked = false; |
474 _remove_button_clicked = false; |
445 _one_way_button_clicked = false; |
475 _one_way_button_clicked = false; |
446 _build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w); |
476 _build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w); |
447 } |
477 } |
448 UpdateOptionWidgetStatus(w, e->we.click.widget); |
478 UpdateOptionWidgetStatus(w, e->we.click.widget); |
|
479 if (_ctrl_pressed) RoadToolbar_CtrlChanged(w); |
449 break; |
480 break; |
450 |
481 |
451 case WE_KEYPRESS: |
482 case WE_KEYPRESS: |
452 for (uint8 i = 0; i != lengthof(_road_keycodes); i++) { |
483 for (uint8 i = 0; i != lengthof(_road_keycodes); i++) { |
453 if (e->we.keypress.keycode == _road_keycodes[i]) { |
484 if (e->we.keypress.keycode == _road_keycodes[i]) { |
454 e->we.keypress.cont = false; |
485 e->we.keypress.cont = false; |
455 _remove_button_clicked = false; |
486 _remove_button_clicked = false; |
456 _one_way_button_clicked = false; |
487 _one_way_button_clicked = false; |
457 _build_road_button_proc[i](w); |
488 _build_road_button_proc[i](w); |
458 UpdateOptionWidgetStatus(w, i + RTW_ROAD_X); |
489 UpdateOptionWidgetStatus(w, i + RTW_ROAD_X); |
|
490 if (_ctrl_pressed) RoadToolbar_CtrlChanged(w); |
459 break; |
491 break; |
460 } |
492 } |
461 } |
493 } |
462 MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
494 MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection |
463 break; |
495 break; |
530 TileIndex end_tile = e->we.place.tile; |
562 TileIndex end_tile = e->we.place.tile; |
531 |
563 |
532 switch (e->we.place.select_proc) { |
564 switch (e->we.place.select_proc) { |
533 case DDSP_BUILD_BRIDGE: |
565 case DDSP_BUILD_BRIDGE: |
534 ResetObjectToPlace(); |
566 ResetObjectToPlace(); |
535 ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype)); |
567 ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype)); |
536 break; |
568 break; |
537 |
569 |
538 case DDSP_DEMOLISH_AREA: |
570 case DDSP_DEMOLISH_AREA: |
539 DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
571 DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); |
540 break; |
572 break; |
810 |
846 |
811 _thd.FSMportLayout = NULL; // ensure irregular airport support disabled |
847 _thd.FSMportLayout = NULL; // ensure irregular airport support disabled |
812 _thd.FSMportMask = NULL; |
848 _thd.FSMportMask = NULL; |
813 |
849 |
814 if (_station_show_coverage) { |
850 if (_station_show_coverage) { |
815 int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4; |
851 int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED; |
816 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
852 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); |
817 } else { |
853 } else { |
818 SetTileSelectSize(1, 1); |
854 SetTileSelectSize(1, 1); |
819 } |
855 } |
820 |
856 |