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

Method UpdateButtonStatus

src/vehicle_gui.cpp:3354–3377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3352 }
3353
3354 void UpdateButtonStatus()
3355 {
3356 const Vehicle *v = Vehicle::Get(this->window_number);
3357 bool veh_stopped = v->IsStoppedInDepot();
3358
3359 /* Widget WID_VV_GOTO_DEPOT must be hidden if the vehicle is already stopped in depot.
3360 * Widget WID_VV_CLONE_VEH should then be shown, since cloning is allowed only while in depot and stopped.
3361 */
3362 PlaneSelections plane = veh_stopped ? SEL_DC_CLONE : SEL_DC_GOTO_DEPOT;
3363 NWidgetStacked *nwi = this->GetWidget<NWidgetStacked>(WID_VV_SELECT_DEPOT_CLONE); // Selection widget 'send to depot' / 'clone'.
3364 if (nwi->shown_plane + SEL_DC_BASEPLANE != plane) {
3365 this->SelectPlane(plane);
3366 this->SetWidgetDirty(WID_VV_SELECT_DEPOT_CLONE);
3367 }
3368 /* The same system applies to widget WID_VV_REFIT_VEH and VVW_WIDGET_TURN_AROUND.*/
3369 if (v->IsGroundVehicle()) {
3370 plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
3371 nwi = this->GetWidget<NWidgetStacked>(WID_VV_SELECT_REFIT_TURN);
3372 if (nwi->shown_plane + SEL_RT_BASEPLANE != plane) {
3373 this->SelectPlane(plane);
3374 this->SetWidgetDirty(WID_VV_SELECT_REFIT_TURN);
3375 }
3376 }
3377 }
3378
3379 /**
3380 * Some data on this window has become invalid.

Callers 2

VehicleViewWindowMethod · 0.95
OnInvalidateDataMethod · 0.95

Calls 4

SelectPlaneMethod · 0.95
SetWidgetDirtyMethod · 0.80
IsStoppedInDepotMethod · 0.45
IsGroundVehicleMethod · 0.45

Tested by

no test coverage detected