Codechange: Use functions to create common drop down list items.
This commit is contained in:

committed by
Peter Nelson

parent
11aa3694fa
commit
56cac21086
@@ -338,7 +338,7 @@ static DropDownList BuildMapsizeDropDown()
|
||||
|
||||
for (uint i = MIN_MAP_SIZE_BITS; i <= MAX_MAP_SIZE_BITS; i++) {
|
||||
SetDParam(0, 1LL << i);
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_INT, i, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_JUST_INT, i));
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -351,20 +351,20 @@ static DropDownList BuildTownNameDropDown()
|
||||
/* Add and sort newgrf townnames generators */
|
||||
const auto &grf_names = GetGRFTownNameList();
|
||||
for (uint i = 0; i < grf_names.size(); i++) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i, false));
|
||||
list.push_back(MakeDropDownListStringItem(grf_names[i], BUILTIN_TOWNNAME_GENERATOR_COUNT + i));
|
||||
}
|
||||
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
|
||||
|
||||
size_t newgrf_size = list.size();
|
||||
/* Insert newgrf_names at the top of the list */
|
||||
if (newgrf_size > 0) {
|
||||
list.push_back(std::make_unique<DropDownListDividerItem>(-1, false)); // separator line
|
||||
list.push_back(MakeDropDownListDividerItem()); // separator line
|
||||
newgrf_size++;
|
||||
}
|
||||
|
||||
/* Add and sort original townnames generators */
|
||||
for (uint i = 0; i < BUILTIN_TOWNNAME_GENERATOR_COUNT; i++) {
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i, false));
|
||||
list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
|
||||
}
|
||||
std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
|
||||
|
||||
|
Reference in New Issue
Block a user