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

Method OnClick

src/genworld_gui.cpp:1152–1213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1150 }
1151
1152 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1153 {
1154 switch (widget) {
1155 case WID_CS_TEMPERATE:
1156 case WID_CS_ARCTIC:
1157 case WID_CS_TROPICAL:
1158 case WID_CS_TOYLAND:
1159 this->RaiseWidget(to_underlying(_settings_newgame.game_creation.landscape) + WID_CS_TEMPERATE);
1160 SetNewLandscapeType(LandscapeType(widget - WID_CS_TEMPERATE));
1161 break;
1162
1163 case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
1164 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_CS_MAPSIZE_X_PULLDOWN);
1165 break;
1166
1167 case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
1168 ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_CS_MAPSIZE_Y_PULLDOWN);
1169 break;
1170
1171 case WID_CS_EMPTY_WORLD: // Empty world / flat world
1172 StartGeneratingLandscape(GLWM_SCENARIO);
1173 break;
1174
1175 case WID_CS_RANDOM_WORLD: // Generate
1176 ShowGenerateLandscape();
1177 break;
1178
1179 case WID_CS_START_DATE_DOWN:
1180 case WID_CS_START_DATE_UP: // Year buttons
1181 /* Don't allow too fast scrolling */
1182 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1183 this->HandleButtonClick(widget);
1184 this->SetDirty();
1185
1186 _settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + widget - WID_CS_START_DATE_TEXT, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
1187 }
1188 _left_button_clicked = false;
1189 break;
1190
1191 case WID_CS_START_DATE_TEXT: // Year text
1192 this->widget_id = WID_CS_START_DATE_TEXT;
1193 ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.starting_year), STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, {});
1194 break;
1195
1196 case WID_CS_FLAT_LAND_HEIGHT_DOWN:
1197 case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons
1198 /* Don't allow too fast scrolling */
1199 if (!this->flags.Test(WindowFlag::Timeout) || this->timeout_timer <= 1) {
1200 this->HandleButtonClick(widget);
1201 this->SetDirty();
1202
1203 _settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - WID_CS_FLAT_LAND_HEIGHT_TEXT, 0, GetMapHeightLimit());
1204 }
1205 _left_button_clicked = false;
1206 break;
1207
1208 case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text
1209 this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT;

Callers

nothing calls this directly

Calls 15

to_underlyingFunction · 0.85
SetNewLandscapeTypeFunction · 0.85
ShowDropDownListFunction · 0.85
BuildMapsizeDropDownFunction · 0.85
StartGeneratingLandscapeFunction · 0.85
ShowGenerateLandscapeFunction · 0.85
ClampFunction · 0.85
ShowQueryStringFunction · 0.85
GetMapHeightLimitFunction · 0.85
RaiseWidgetMethod · 0.80
TestMethod · 0.80
HandleButtonClickMethod · 0.80

Tested by

no test coverage detected