mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-11 16:54:42 +00:00
(svn r25074) -Cleanup: Simplify currency selection code slightly
This commit is contained in:
parent
e808104b88
commit
bd301e8475
@ -190,23 +190,17 @@ struct GameOptionsWindow : Window {
|
|||||||
*selected_index = this->opt->locale.currency;
|
*selected_index = this->opt->locale.currency;
|
||||||
StringID *items = BuildCurrencyDropdown();
|
StringID *items = BuildCurrencyDropdown();
|
||||||
uint disabled = _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies();
|
uint disabled = _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies();
|
||||||
int custom_index = -1;
|
|
||||||
|
|
||||||
/* Add non-custom currencies; sorted naturally */
|
/* Add non-custom currencies; sorted naturally */
|
||||||
for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
for (uint i = 0; i < CURRENCY_END; items++, i++) {
|
||||||
if (*items == STR_GAME_OPTIONS_CURRENCY_CUSTOM) {
|
if (i == CURRENCY_CUSTOM) continue;
|
||||||
custom_index = i;
|
list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
|
||||||
} else {
|
|
||||||
list->push_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
list->sort(DropDownListStringItem::NatSortFunc);
|
list->sort(DropDownListStringItem::NatSortFunc);
|
||||||
|
|
||||||
/* Append custom currency at the end */
|
/* Append custom currency at the end */
|
||||||
if (custom_index >= 0) {
|
list->push_back(new DropDownListItem(-1, false)); // separator line
|
||||||
list->push_back(new DropDownListItem(-1, false)); // separator line
|
list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
|
||||||
list->push_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, custom_index, HasBit(disabled, custom_index)));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user