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

Method OnClick

src/transparency_gui.cpp:73–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71 }
72
73 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
74 {
75 if (widget >= WID_TT_BEGIN && widget < WID_TT_END) {
76 if (_ctrl_pressed) {
77 /* toggle the bit of the transparencies lock variable */
78 ToggleTransparencyLock((TransparencyOption)(widget - WID_TT_BEGIN));
79 this->SetDirty();
80 } else {
81 /* toggle the bit of the transparencies variable and play a sound */
82 ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN));
83 SndClickBeep();
84 MarkWholeScreenDirty();
85 }
86 } else if (widget == WID_TT_BUTTONS) {
87 uint i;
88 for (i = WID_TT_BEGIN; i < WID_TT_END; i++) {
89 const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
90 if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x)) {
91 break;
92 }
93 }
94 if (i == WID_TT_TEXT|| i == WID_TT_END) return;
95
96 ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN));
97 SndClickBeep();
98
99 /* Redraw whole screen only if transparency is set */
100 if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) {
101 MarkWholeScreenDirty();
102 } else {
103 this->SetWidgetDirty(WID_TT_BUTTONS);
104 }
105 }
106 }
107
108 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
109 {

Callers

nothing calls this directly

Calls 10

ToggleTransparencyLockFunction · 0.85
ToggleTransparencyFunction · 0.85
SndClickBeepFunction · 0.85
MarkWholeScreenDirtyFunction · 0.85
IsInsideBSFunction · 0.85
ToggleInvisibilityFunction · 0.85
IsTransparencySetFunction · 0.85
SetWidgetDirtyMethod · 0.80
SetDirtyMethod · 0.45

Tested by

no test coverage detected