MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateOptionWidgetStatus

Method UpdateOptionWidgetStatus

src/road_gui.cpp:460–508  ·  view source on GitHub ↗

* Update the remove button lowered state of the road toolbar * * @param clicked_widget The widget which the client clicked just now */

Source from the content-addressed store, hash-verified

458 * @param clicked_widget The widget which the client clicked just now
459 */
460 void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
461 {
462 /* The remove and the one way button state is driven
463 * by the other buttons so they don't act on themselves.
464 * Both are only valid if they are able to apply as options. */
465 switch (clicked_widget) {
466 case WID_ROT_REMOVE:
467 if (RoadTypeIsRoad(this->roadtype)) {
468 this->RaiseWidget(WID_ROT_ONE_WAY);
469 this->SetWidgetDirty(WID_ROT_ONE_WAY);
470 }
471
472 break;
473
474 case WID_ROT_ONE_WAY:
475 this->RaiseWidget(WID_ROT_REMOVE);
476 this->SetWidgetDirty(WID_ROT_REMOVE);
477 break;
478
479 case WID_ROT_BUS_STATION:
480 case WID_ROT_TRUCK_STATION:
481 case WID_ROT_BUILD_WAYPOINT:
482 if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
483 this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
484 break;
485
486 case WID_ROT_ROAD_X:
487 case WID_ROT_ROAD_Y:
488 case WID_ROT_AUTOROAD:
489 this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
490 if (RoadTypeIsRoad(this->roadtype)) {
491 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
492 }
493 break;
494
495 default:
496 /* When any other buttons than road/station, raise and
497 * disable the removal button */
498 this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
499 this->SetWidgetLoweredState(WID_ROT_REMOVE, false);
500
501 if (RoadTypeIsRoad(this->roadtype)) {
502 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
503 this->SetWidgetLoweredState(WID_ROT_ONE_WAY, false);
504 }
505
506 break;
507 }
508 }
509
510 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
511 {

Callers 1

OnClickMethod · 0.95

Calls 7

RoadTypeIsRoadFunction · 0.85
RaiseWidgetMethod · 0.80
SetWidgetDirtyMethod · 0.80
DisableWidgetMethod · 0.80
IsWidgetLoweredMethod · 0.80
SetWidgetLoweredStateMethod · 0.80

Tested by

no test coverage detected