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

Function BuildTownNameDropDown

src/genworld_gui.cpp:355–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355static DropDownList BuildTownNameDropDown()
356{
357 DropDownList list;
358
359 /* Add and sort newgrf townnames generators */
360 const auto &grf_names = GetGRFTownNameList();
361 for (uint i = 0; i < grf_names.size(); i++) {
362 list.push_back(MakeDropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i));
363 }
364 std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
365
366 size_t newgrf_size = list.size();
367 /* Insert newgrf_names at the top of the list */
368 if (newgrf_size > 0) {
369 list.push_back(MakeDropDownListDividerItem()); // separator line
370 newgrf_size++;
371 }
372
373 /* Add and sort original townnames generators */
374 for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
375 list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
376 }
377 std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
378
379 return list;
380}
381
382
383static const StringID _elevations[] = {STR_TERRAIN_TYPE_VERY_FLAT, STR_TERRAIN_TYPE_FLAT, STR_TERRAIN_TYPE_HILLY, STR_TERRAIN_TYPE_MOUNTAINOUS, STR_TERRAIN_TYPE_ALPINIST, STR_TERRAIN_TYPE_CUSTOM};

Callers 1

OnClickMethod · 0.85

Calls 6

push_backMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected