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

Function HandlePlacePushButton

src/main_gui.cpp:63–78  ·  view source on GitHub ↗

* This code is shared for the majority of the pushbuttons. * Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters * * @param w Window which called the function * @param widget ID of the widget (=button) that called this function * @param cursor How should the cursor image change? E.g. cursor with depot image in it * @param mode Tile high

Source from the content-addressed store, hash-verified

61 * @return true if the button is clicked, false if it's unclicked
62 */
63bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
64{
65 if (w->IsWidgetDisabled(widget)) return false;
66
67 SndClickBeep();
68 w->SetDirty();
69
70 if (w->IsWidgetLowered(widget)) {
71 ResetObjectToPlace();
72 return false;
73 }
74
75 SetObjectToPlace(cursor, PAL_NONE, mode, w->window_class, w->window_number);
76 w->LowerWidget(widget);
77 return true;
78}
79
80
81void CcPlaySound_EXPLOSION(Commands, const CommandCost &result, TileIndex tile)

Callers 10

OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85

Calls 7

SndClickBeepFunction · 0.85
ResetObjectToPlaceFunction · 0.85
SetObjectToPlaceFunction · 0.85
IsWidgetDisabledMethod · 0.80
IsWidgetLoweredMethod · 0.80
LowerWidgetMethod · 0.80
SetDirtyMethod · 0.45

Tested by

no test coverage detected