| 1238 | } |
| 1239 | |
| 1240 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 1241 | { |
| 1242 | switch (widget) { |
| 1243 | case WID_TF_NEW_TOWN: |
| 1244 | HandlePlacePushButton(this, WID_TF_NEW_TOWN, SPR_CURSOR_TOWN, HT_RECT); |
| 1245 | break; |
| 1246 | |
| 1247 | case WID_TF_RANDOM_TOWN: |
| 1248 | this->ExecuteFoundTownCommand(TileIndex{}, true, STR_ERROR_CAN_T_GENERATE_TOWN, CcFoundRandomTown); |
| 1249 | break; |
| 1250 | |
| 1251 | case WID_TF_TOWN_NAME_RANDOM: |
| 1252 | this->RandomTownName(); |
| 1253 | this->SetFocusedWidget(WID_TF_TOWN_NAME_EDITBOX); |
| 1254 | break; |
| 1255 | |
| 1256 | case WID_TF_MANY_RANDOM_TOWNS: { |
| 1257 | std::string default_town_number = fmt::format("{}", GetDefaultTownsForMapSize()); |
| 1258 | ShowQueryString(default_town_number, STR_MAPGEN_NUMBER_OF_TOWNS, 5, this, CS_NUMERAL, {QueryStringFlag::AcceptUnchanged}); |
| 1259 | break; |
| 1260 | } |
| 1261 | case WID_TF_LOAD_FROM_FILE: |
| 1262 | ShowSaveLoadDialog(FT_TOWN_DATA, SLO_LOAD); |
| 1263 | break; |
| 1264 | |
| 1265 | case WID_TF_EXPAND_ALL_TOWNS: |
| 1266 | for (Town *t : Town::Iterate()) { |
| 1267 | Command<CMD_EXPAND_TOWN>::Do(DoCommandFlag::Execute, t->index, 0, FoundTownWindow::expand_modes); |
| 1268 | } |
| 1269 | break; |
| 1270 | |
| 1271 | case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM: |
| 1272 | this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL); |
| 1273 | this->UpdateButtons(false); |
| 1274 | break; |
| 1275 | |
| 1276 | case WID_TF_CITY: |
| 1277 | this->city ^= true; |
| 1278 | this->SetWidgetLoweredState(WID_TF_CITY, this->city); |
| 1279 | this->SetDirty(); |
| 1280 | break; |
| 1281 | |
| 1282 | case WID_TF_EXPAND_BUILDINGS: |
| 1283 | FoundTownWindow::expand_modes.Flip(TownExpandMode::Buildings); |
| 1284 | this->UpdateButtons(false); |
| 1285 | break; |
| 1286 | |
| 1287 | case WID_TF_EXPAND_ROADS: |
| 1288 | FoundTownWindow::expand_modes.Flip(TownExpandMode::Roads); |
| 1289 | this->UpdateButtons(false); |
| 1290 | break; |
| 1291 | |
| 1292 | case WID_TF_LAYOUT_ORIGINAL: case WID_TF_LAYOUT_BETTER: case WID_TF_LAYOUT_GRID2: |
| 1293 | case WID_TF_LAYOUT_GRID3: case WID_TF_LAYOUT_RANDOM: |
| 1294 | this->town_layout = (TownLayout)(widget - WID_TF_LAYOUT_ORIGINAL); |
| 1295 | |
| 1296 | /* If we are in the editor, sync the settings of the current game to the chosen layout, |
| 1297 | * so that importing towns from file uses the selected layout. */ |
nothing calls this directly
no test coverage detected