@@ -99,116 +99,116 @@ static DropDownList BuildSetDropDownList
return list;
}
DropDownList BuildMusicSetDropDownList(int *selected_index)
{
return BuildSetDropDownList<BaseMusic>(selected_index, true);
/** Window for displaying the textfile of a BaseSet. */
template <class TBaseSet>
struct BaseSetTextfileWindow : public TextfileWindow {
const TBaseSet* baseset; ///< View the textfile of this BaseSet.
StringID content_type; ///< STR_CONTENT_TYPE_xxx for title.
BaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type) : TextfileWindow(file_type), baseset(baseset), content_type(content_type)
const char *textfile = this->baseset->GetTextfile(file_type);
this->LoadTextfile(textfile, BASESET_DIR);
void SetStringParameters(int widget) const override
if (widget == WID_TF_CAPTION) {
SetDParam(0, content_type);
SetDParamStr(1, this->baseset->name.c_str());
};
/**
* Open the BaseSet version of the textfile window.
* @param file_type The type of textfile to display.
* @param baseset The BaseSet to use.
* @param content_type STR_CONTENT_TYPE_xxx for title.
*/
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
DeleteWindowById(WC_TEXTFILE, file_type);
new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
* Add the refresh rate from the config and the refresh rates from all the monitors to
* our list of refresh rates shown in the GUI.
static void AddRefreshRatesAndSelect()
static void AddCustomRefreshRates()
/* Add the refresh rate as selected in the config. */
_refresh_rates.insert(_settings_client.gui.refresh_rate);
/* Add all the refresh rates of all monitors connected to the machine. */
std::vector<int> monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
struct GameOptionsWindow : Window {
GameSettings *opt;
bool reload;
GameOptionsWindow(WindowDesc *desc) : Window(desc)
this->opt = &GetGameSettings();
this->reload = false;
AddRefreshRatesAndSelect();
AddCustomRefreshRates();
this->InitNested(WN_GAME_OPTIONS_GAME_OPTIONS);
this->OnInvalidateData(0);
~GameOptionsWindow()
DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
DeleteWindowByClass(WC_TEXTFILE);
if (this->reload) _switch_mode = SM_MENU;
* Build the dropdown list for a specific widget.
* @param widget Widget to build list for
* @param selected_index Currently selected item
* @return the built dropdown list, or nullptr if the widget has no dropdown menu.
DropDownList BuildDropDownList(int widget, int *selected_index) const
DropDownList list;
switch (widget) {
case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
*selected_index = this->opt->locale.currency;
StringID *items = BuildCurrencyDropdown();
uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
/* Add non-custom currencies; sorted naturally */
for (uint i = 0; i < CURRENCY_END; items++, i++) {
if (i == CURRENCY_CUSTOM) continue;
list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
/* Append custom currency at the end */
list.emplace_back(new DropDownListItem(-1, false)); // separator line
list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
break;
case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
*selected_index = _settings_client.gui.autosave;
const StringID *items = _autosave_dropdown;
for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
list.emplace_back(new DropDownListStringItem(*items, i, false));
Status change: