Merge branch 'origin/master' commit 'a499e9acdd385b57dd43caf88af3a6f7f53716ba'
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
@@ -38,6 +36,7 @@
|
||||
#include "querystring_gui.h"
|
||||
#include "fontcache.h"
|
||||
#include "settings_func.h"
|
||||
#include "zoom_func.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -79,7 +78,7 @@ static const StringID _font_zoom_dropdown[] = {
|
||||
};
|
||||
|
||||
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of original town names.
|
||||
static StringID *_grf_names = NULL; ///< Pointer to town names defined by NewGRFs.
|
||||
static StringID *_grf_names = nullptr; ///< Pointer to town names defined by NewGRFs.
|
||||
static int _nb_grf_names = 0; ///< Number of town names defined by NewGRFs.
|
||||
|
||||
static Dimension _circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
|
||||
@@ -110,17 +109,14 @@ static inline StringID TownName(int town_name)
|
||||
|
||||
/**
|
||||
* Get index of the current screen resolution.
|
||||
* @return Index of the current screen resolution if it is a known resolution, #_num_resolutions otherwise.
|
||||
* @return Index of the current screen resolution if it is a known resolution, _resolutions.size() otherwise.
|
||||
*/
|
||||
static int GetCurRes()
|
||||
static uint GetCurRes()
|
||||
{
|
||||
int i;
|
||||
uint i;
|
||||
|
||||
for (i = 0; i != _num_resolutions; i++) {
|
||||
if ((int)_resolutions[i].width == _screen.width &&
|
||||
(int)_resolutions[i].height == _screen.height) {
|
||||
break;
|
||||
}
|
||||
for (i = 0; i != _resolutions.size(); i++) {
|
||||
if (_resolutions[i] == Dimension(_screen.width, _screen.height)) break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
@@ -130,20 +126,20 @@ static void ShowCustCurrency();
|
||||
static void ReconstructUserInterface();
|
||||
|
||||
template <class T>
|
||||
static DropDownList *BuildSetDropDownList(int *selected_index, bool allow_selection)
|
||||
static DropDownList BuildSetDropDownList(int *selected_index, bool allow_selection)
|
||||
{
|
||||
int n = T::GetNumSets();
|
||||
*selected_index = T::GetIndexOfUsedSet();
|
||||
|
||||
DropDownList *list = new DropDownList();
|
||||
DropDownList list;
|
||||
for (int i = 0; i < n; i++) {
|
||||
*list->Append() = new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i));
|
||||
list.emplace_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
DropDownList *BuildMusicSetDropDownList(int *selected_index)
|
||||
DropDownList BuildMusicSetDropDownList(int *selected_index)
|
||||
{
|
||||
return BuildSetDropDownList<BaseMusic>(selected_index, true);
|
||||
}
|
||||
@@ -160,7 +156,7 @@ struct BaseSetTextfileWindow : public TextfileWindow {
|
||||
this->LoadTextfile(textfile, BASESET_DIR);
|
||||
}
|
||||
|
||||
/* virtual */ void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
if (widget == WID_TF_CAPTION) {
|
||||
SetDParam(0, content_type);
|
||||
@@ -207,14 +203,13 @@ struct GameOptionsWindow : Window {
|
||||
* 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 NULL if the widget has no dropdown menu.
|
||||
* @return the built dropdown list, or nullptr if the widget has no dropdown menu.
|
||||
*/
|
||||
DropDownList *BuildDropDownList(int widget, int *selected_index) const
|
||||
DropDownList BuildDropDownList(int widget, int *selected_index) const
|
||||
{
|
||||
DropDownList *list = NULL;
|
||||
DropDownList list;
|
||||
switch (widget) {
|
||||
case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
|
||||
list = new DropDownList();
|
||||
*selected_index = this->opt->locale.currency;
|
||||
StringID *items = BuildCurrencyDropdown();
|
||||
uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
|
||||
@@ -222,18 +217,17 @@ struct GameOptionsWindow : Window {
|
||||
/* Add non-custom currencies; sorted naturally */
|
||||
for (uint i = 0; i < CURRENCY_END; items++, i++) {
|
||||
if (i == CURRENCY_CUSTOM) continue;
|
||||
*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
|
||||
}
|
||||
QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
|
||||
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
|
||||
|
||||
/* Append custom currency at the end */
|
||||
*list->Append() = new DropDownListItem(-1, false); // separator line
|
||||
*list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM));
|
||||
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_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
|
||||
list = new DropDownList();
|
||||
*selected_index = this->opt->vehicle.road_side;
|
||||
const StringID *items = _driveside_dropdown;
|
||||
uint disabled = 0;
|
||||
@@ -246,13 +240,12 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
|
||||
for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||
*list->Append() = new DropDownListStringItem(*items, i, HasBit(disabled, i));
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_TOWNNAME_DROPDOWN: { // Setup townname dropdown
|
||||
list = new DropDownList();
|
||||
*selected_index = this->opt->game_creation.town_name;
|
||||
|
||||
int enabled_item = (_game_mode == GM_MENU || Town::GetNumItems() == 0) ? -1 : *selected_index;
|
||||
@@ -260,52 +253,49 @@ struct GameOptionsWindow : Window {
|
||||
/* Add and sort newgrf townnames generators */
|
||||
for (int i = 0; i < _nb_grf_names; i++) {
|
||||
int result = _nb_orig_names + i;
|
||||
*list->Append() = new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0);
|
||||
list.emplace_back(new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0));
|
||||
}
|
||||
QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
|
||||
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
|
||||
|
||||
int newgrf_size = list->Length();
|
||||
size_t newgrf_size = list.size();
|
||||
/* Insert newgrf_names at the top of the list */
|
||||
if (newgrf_size > 0) {
|
||||
*list->Append() = new DropDownListItem(-1, false); // separator line
|
||||
list.emplace_back(new DropDownListItem(-1, false)); // separator line
|
||||
newgrf_size++;
|
||||
}
|
||||
|
||||
/* Add and sort original townnames generators */
|
||||
for (int i = 0; i < _nb_orig_names; i++) {
|
||||
*list->Append() = new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0);
|
||||
list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0));
|
||||
}
|
||||
QSortT(list->Begin() + newgrf_size, list->Length() - newgrf_size, DropDownListStringItem::NatSortFunc);
|
||||
std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
|
||||
list = new DropDownList();
|
||||
*selected_index = _settings_client.gui.autosave;
|
||||
const StringID *items = _autosave_dropdown;
|
||||
for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||
*list->Append() = new DropDownListStringItem(*items, i, false);
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
|
||||
list = new DropDownList();
|
||||
for (uint i = 0; i < _languages.Length(); i++) {
|
||||
for (uint i = 0; i < _languages.size(); i++) {
|
||||
if (&_languages[i] == _current_language) *selected_index = i;
|
||||
*list->Append() = new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false);
|
||||
list.emplace_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false));
|
||||
}
|
||||
QSortT(list->Begin(), list->Length(), DropDownListStringItem::NatSortFunc);
|
||||
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
|
||||
if (_num_resolutions == 0) break;
|
||||
if (_resolutions.empty()) break;
|
||||
|
||||
list = new DropDownList();
|
||||
*selected_index = GetCurRes();
|
||||
for (int i = 0; i < _num_resolutions; i++) {
|
||||
*list->Append() = new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false);
|
||||
for (uint i = 0; i < _resolutions.size(); i++) {
|
||||
list.emplace_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -323,21 +313,19 @@ struct GameOptionsWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_GO_GUI_ZOOM_DROPDOWN: {
|
||||
list = new DropDownList();
|
||||
*selected_index = ZOOM_LVL_OUT_4X - _gui_zoom;
|
||||
const StringID *items = _gui_zoom_dropdown;
|
||||
for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||
*list->Append() = new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i);
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_FONT_ZOOM_DROPDOWN: {
|
||||
list = new DropDownList();
|
||||
*selected_index = ZOOM_LVL_OUT_4X - _font_zoom;
|
||||
const StringID *items = _font_zoom_dropdown;
|
||||
for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||
*list->Append() = new DropDownListStringItem(*items, i, false);
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -353,15 +341,12 @@ struct GameOptionsWindow : Window {
|
||||
case WID_GO_BASE_MUSIC_DROPDOWN:
|
||||
list = BuildMusicSetDropDownList(selected_index);
|
||||
break;
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
|
||||
@@ -369,7 +354,7 @@ struct GameOptionsWindow : Window {
|
||||
case WID_GO_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
|
||||
case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
|
||||
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
|
||||
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
||||
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _resolutions.size() ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
|
||||
case WID_GO_BUTTON_SIZE_DROPDOWN:SetDParam(0, _settings_client.gui.min_button); break;
|
||||
case WID_GO_TEXT_SIZE_DROPDOWN: SetDParam(0, _freetype.medium.size); break;
|
||||
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
|
||||
@@ -382,7 +367,7 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GO_BASE_GRF_DESCRIPTION:
|
||||
@@ -402,7 +387,7 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GO_BASE_GRF_DESCRIPTION:
|
||||
@@ -453,38 +438,37 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
default: {
|
||||
int selected;
|
||||
DropDownList *list = this->BuildDropDownList(widget, &selected);
|
||||
if (list != NULL) {
|
||||
DropDownList list = this->BuildDropDownList(widget, &selected);
|
||||
if (!list.empty()) {
|
||||
/* Find the biggest item for the default size. */
|
||||
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); it++) {
|
||||
for (const auto &ddli : list) {
|
||||
Dimension string_dim;
|
||||
int width = (*it)->Width();
|
||||
int width = ddli->Width();
|
||||
string_dim.width = width + padding.width;
|
||||
string_dim.height = (*it)->Height(width) + padding.height;
|
||||
string_dim.height = ddli->Height(width) + padding.height;
|
||||
*size = maxdim(*size, string_dim);
|
||||
}
|
||||
delete list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
|
||||
if (BaseGraphics::GetUsedSet() == NULL) return;
|
||||
if (BaseGraphics::GetUsedSet() == nullptr) return;
|
||||
|
||||
ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
|
||||
return;
|
||||
}
|
||||
if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
|
||||
if (BaseSounds::GetUsedSet() == NULL) return;
|
||||
if (BaseSounds::GetUsedSet() == nullptr) return;
|
||||
|
||||
ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
|
||||
return;
|
||||
}
|
||||
if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
|
||||
if (BaseMusic::GetUsedSet() == NULL) return;
|
||||
if (BaseMusic::GetUsedSet() == nullptr) return;
|
||||
|
||||
ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
|
||||
return;
|
||||
@@ -549,9 +533,9 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
default: {
|
||||
int selected;
|
||||
DropDownList *list = this->BuildDropDownList(widget, &selected);
|
||||
if (list != NULL) {
|
||||
ShowDropDownList(this, list, selected, widget);
|
||||
DropDownList list = this->BuildDropDownList(widget, &selected);
|
||||
if (!list.empty()) {
|
||||
ShowDropDownList(this, std::move(list), selected, widget);
|
||||
} else {
|
||||
if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
|
||||
}
|
||||
@@ -580,7 +564,7 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GO_CURRENCY_DROPDOWN: // Currency
|
||||
@@ -592,7 +576,7 @@ struct GameOptionsWindow : Window {
|
||||
case WID_GO_ROADSIDE_DROPDOWN: // Road side
|
||||
if (this->opt->vehicle.road_side != index) { // only change if setting changed
|
||||
uint i;
|
||||
if (GetSettingFromName("vehicle.road_side", &i) == NULL) NOT_REACHED();
|
||||
if (GetSettingFromName("vehicle.road_side", &i) == nullptr) NOT_REACHED();
|
||||
SetSettingValue(i, index);
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
@@ -614,14 +598,15 @@ struct GameOptionsWindow : Window {
|
||||
ReadLanguagePack(&_languages[index]);
|
||||
DeleteWindowByClass(WC_QUERY_STRING);
|
||||
CheckForMissingGlyphs();
|
||||
ClearAllCachedNames();
|
||||
UpdateAllVirtCoords();
|
||||
ReInitAllWindows();
|
||||
break;
|
||||
|
||||
case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
|
||||
if (index < _num_resolutions && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
|
||||
ReconstructUserInterface();
|
||||
if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
|
||||
this->SetDirty();
|
||||
ReconstructUserInterface();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -644,6 +629,7 @@ struct GameOptionsWindow : Window {
|
||||
_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
|
||||
UpdateCursorSize();
|
||||
UpdateAllVirtCoords();
|
||||
FixTitleGameZoom();
|
||||
ReInitAllWindows();
|
||||
break;
|
||||
|
||||
@@ -675,7 +661,7 @@ struct GameOptionsWindow : Window {
|
||||
* @param data Information about the changed data. @see GameOptionsInvalidationData
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
this->SetWidgetLoweredState(WID_GO_WINDOWS_TITLEBARS, _settings_client.gui.windows_titlebars);
|
||||
@@ -691,9 +677,9 @@ struct GameOptionsWindow : Window {
|
||||
this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
|
||||
|
||||
for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_GRF_TEXTFILE + tft, BaseGraphics::GetUsedSet() == NULL || BaseGraphics::GetUsedSet()->GetTextfile(tft) == NULL);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == NULL || BaseSounds::GetUsedSet()->GetTextfile(tft) == NULL);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_TEXTFILE + tft, BaseMusic::GetUsedSet() == NULL || BaseMusic::GetUsedSet()->GetTextfile(tft) == NULL);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_GRF_TEXTFILE + tft, BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->GetTextfile(tft) == nullptr);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == nullptr || BaseSounds::GetUsedSet()->GetTextfile(tft) == nullptr);
|
||||
this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_TEXTFILE + tft, BaseMusic::GetUsedSet() == nullptr || BaseMusic::GetUsedSet()->GetTextfile(tft) == nullptr);
|
||||
}
|
||||
|
||||
missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
|
||||
@@ -1001,14 +987,14 @@ bool BaseSettingEntry::IsVisible(const BaseSettingEntry *item) const
|
||||
* Find setting entry at row \a row_num
|
||||
* @param row_num Index of entry to return
|
||||
* @param cur_row Current row number
|
||||
* @return The requested setting entry or \c NULL if it not found (folded or filtered)
|
||||
* @return The requested setting entry or \c nullptr if it not found (folded or filtered)
|
||||
*/
|
||||
BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
|
||||
{
|
||||
if (this->IsFiltered()) return NULL;
|
||||
if (this->IsFiltered()) return nullptr;
|
||||
if (row_num == *cur_row) return this;
|
||||
(*cur_row)++;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1083,7 +1069,7 @@ uint BaseSettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int
|
||||
SettingEntry::SettingEntry(const char *name)
|
||||
{
|
||||
this->name = name;
|
||||
this->setting = NULL;
|
||||
this->setting = nullptr;
|
||||
this->index = 0;
|
||||
}
|
||||
|
||||
@@ -1095,7 +1081,7 @@ void SettingEntry::Init(byte level)
|
||||
{
|
||||
BaseSettingEntry::Init(level);
|
||||
this->setting = GetSettingFromName(this->name, &this->index);
|
||||
assert(this->setting != NULL);
|
||||
assert(this->setting != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1374,14 +1360,14 @@ uint SettingsContainer::Length() const
|
||||
* Find the setting entry at row number \a row_num
|
||||
* @param row_num Index of entry to return
|
||||
* @param cur_row Variable used for keeping track of the current row number. Should point to memory initialized to \c 0 when first called.
|
||||
* @return The requested setting entry or \c NULL if it does not exist
|
||||
* @return The requested setting entry or \c nullptr if it does not exist
|
||||
*/
|
||||
BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
|
||||
{
|
||||
BaseSettingEntry *pe = NULL;
|
||||
BaseSettingEntry *pe = nullptr;
|
||||
for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
|
||||
pe = (*it)->FindEntry(row_num, cur_row);
|
||||
if (pe != NULL) {
|
||||
if (pe != nullptr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1537,14 +1523,14 @@ uint SettingsPage::Length() const
|
||||
* Find setting entry at row \a row_num
|
||||
* @param row_num Index of entry to return
|
||||
* @param cur_row Current row number
|
||||
* @return The requested setting entry or \c NULL if it not found (folded or filtered)
|
||||
* @return The requested setting entry or \c nullptr if it not found (folded or filtered)
|
||||
*/
|
||||
BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
|
||||
{
|
||||
if (this->IsFiltered()) return NULL;
|
||||
if (this->IsFiltered()) return nullptr;
|
||||
if (row_num == *cur_row) return this;
|
||||
(*cur_row)++;
|
||||
if (this->folded) return NULL;
|
||||
if (this->folded) return nullptr;
|
||||
|
||||
return SettingsContainer::FindEntry(row_num, cur_row);
|
||||
}
|
||||
@@ -1600,9 +1586,9 @@ void SettingsPage::DrawSetting(GameSettings *settings_ptr, int left, int right,
|
||||
/** Construct settings tree */
|
||||
static SettingsContainer &GetSettingsTree()
|
||||
{
|
||||
static SettingsContainer *main = NULL;
|
||||
static SettingsContainer *main = nullptr;
|
||||
|
||||
if (main == NULL)
|
||||
if (main == nullptr)
|
||||
{
|
||||
/* Build up the dynamic settings-array only once per OpenTTD session */
|
||||
main = new SettingsContainer();
|
||||
@@ -1695,6 +1681,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
interface->Add(new SettingEntry("gui.timetable_in_ticks"));
|
||||
interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
|
||||
interface->Add(new SettingEntry("gui.expenses_layout"));
|
||||
interface->Add(new SettingEntry("gui.show_newgrf_name"));
|
||||
}
|
||||
|
||||
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
|
||||
@@ -1827,6 +1814,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
genworld->Add(new SettingEntry("economy.town_layout"));
|
||||
genworld->Add(new SettingEntry("difficulty.industry_density"));
|
||||
genworld->Add(new SettingEntry("gui.pause_on_newgame"));
|
||||
genworld->Add(new SettingEntry("game_creation.ending_year"));
|
||||
}
|
||||
|
||||
SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
|
||||
@@ -1847,6 +1835,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
towns->Add(new SettingEntry("economy.allow_town_roads"));
|
||||
towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
|
||||
towns->Add(new SettingEntry("economy.found_town"));
|
||||
towns->Add(new SettingEntry("economy.town_cargogen_mode"));
|
||||
}
|
||||
|
||||
SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
|
||||
@@ -1856,6 +1845,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
|
||||
industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
|
||||
industries->Add(new SettingEntry("economy.smooth_economy"));
|
||||
industries->Add(new SettingEntry("station.serve_neutral_industries"));
|
||||
}
|
||||
|
||||
SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
|
||||
@@ -1882,6 +1872,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
{
|
||||
npc->Add(new SettingEntry("script.settings_profile"));
|
||||
npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
|
||||
npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
|
||||
npc->Add(new SettingEntry("difficulty.competitor_speed"));
|
||||
npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
|
||||
npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
|
||||
@@ -1892,6 +1883,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
|
||||
ai->Add(new SettingEntry("economy.give_money"));
|
||||
ai->Add(new SettingEntry("economy.allow_shares"));
|
||||
ai->Add(new SettingEntry("economy.min_years_for_shares"));
|
||||
}
|
||||
|
||||
main->Init();
|
||||
@@ -1925,10 +1917,10 @@ struct GameSettingsWindow : Window {
|
||||
|
||||
static GameSettings *settings_ptr; ///< Pointer to the game settings being displayed and modified.
|
||||
|
||||
SettingEntry *valuewindow_entry; ///< If non-NULL, pointer to setting for which a value-entering window has been opened.
|
||||
SettingEntry *clicked_entry; ///< If non-NULL, pointer to a clicked numeric setting (with a depressed left or right button).
|
||||
SettingEntry *last_clicked; ///< If non-NULL, pointer to the last clicked setting.
|
||||
SettingEntry *valuedropdown_entry; ///< If non-NULL, pointer to the value for which a dropdown window is currently opened.
|
||||
SettingEntry *valuewindow_entry; ///< If non-nullptr, pointer to setting for which a value-entering window has been opened.
|
||||
SettingEntry *clicked_entry; ///< If non-nullptr, pointer to a clicked numeric setting (with a depressed left or right button).
|
||||
SettingEntry *last_clicked; ///< If non-nullptr, pointer to the last clicked setting.
|
||||
SettingEntry *valuedropdown_entry; ///< If non-nullptr, pointer to the value for which a dropdown window is currently opened.
|
||||
bool closing_dropdown; ///< True, if the dropdown list is currently closing.
|
||||
|
||||
SettingFilter filter; ///< Filter for the list.
|
||||
@@ -1952,10 +1944,10 @@ struct GameSettingsWindow : Window {
|
||||
_circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
|
||||
GetSettingsTree().FoldAll(); // Close all sub-pages
|
||||
|
||||
this->valuewindow_entry = NULL; // No setting entry for which a entry window is opened
|
||||
this->clicked_entry = NULL; // No numeric setting buttons are depressed
|
||||
this->last_clicked = NULL;
|
||||
this->valuedropdown_entry = NULL;
|
||||
this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
|
||||
this->clicked_entry = nullptr; // No numeric setting buttons are depressed
|
||||
this->last_clicked = nullptr;
|
||||
this->valuedropdown_entry = nullptr;
|
||||
this->closing_dropdown = false;
|
||||
this->manually_changed_folding = false;
|
||||
|
||||
@@ -1975,7 +1967,7 @@ struct GameSettingsWindow : Window {
|
||||
SaveToConfig(); // save all settins immediately on Android, because users tend to kill the app instead of pressing 'Quit' button
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GS_OPTIONSPANEL:
|
||||
@@ -2010,13 +2002,13 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
if (this->closing_dropdown) {
|
||||
this->closing_dropdown = false;
|
||||
assert(this->valuedropdown_entry != NULL);
|
||||
assert(this->valuedropdown_entry != nullptr);
|
||||
this->valuedropdown_entry->SetButtons(0);
|
||||
this->valuedropdown_entry = NULL;
|
||||
this->valuedropdown_entry = nullptr;
|
||||
}
|
||||
|
||||
/* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
|
||||
@@ -2051,7 +2043,7 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GS_RESTRICT_DROPDOWN:
|
||||
@@ -2069,34 +2061,31 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
DropDownList *BuildDropDownList(int widget) const
|
||||
DropDownList BuildDropDownList(int widget) const
|
||||
{
|
||||
DropDownList *list = NULL;
|
||||
DropDownList list;
|
||||
switch (widget) {
|
||||
case WID_GS_RESTRICT_DROPDOWN:
|
||||
list = new DropDownList();
|
||||
|
||||
for (int mode = 0; mode != RM_END; mode++) {
|
||||
/* If we are in adv. settings screen for the new game's settings,
|
||||
* we don't want to allow comparing with new game's settings. */
|
||||
bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
|
||||
|
||||
*list->Append() = new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled);
|
||||
list.emplace_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_GS_TYPE_DROPDOWN:
|
||||
list = new DropDownList();
|
||||
*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false);
|
||||
*list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false);
|
||||
*list->Append() = new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false);
|
||||
*list->Append() = new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false);
|
||||
list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
|
||||
list.emplace_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false));
|
||||
list.emplace_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false));
|
||||
list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
|
||||
break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GS_OPTIONSPANEL: {
|
||||
@@ -2109,7 +2098,7 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
|
||||
case WID_GS_HELP_TEXT:
|
||||
if (this->last_clicked != NULL) {
|
||||
if (this->last_clicked != nullptr) {
|
||||
const SettingDesc *sd = this->last_clicked->setting;
|
||||
|
||||
int y = r.top;
|
||||
@@ -2138,7 +2127,7 @@ struct GameSettingsWindow : Window {
|
||||
|
||||
/**
|
||||
* Set the entry that should have its help text displayed, and mark the window dirty so it gets repainted.
|
||||
* @param pe Setting to display help text of, use \c NULL to stop displaying help of the currently displayed setting.
|
||||
* @param pe Setting to display help text of, use \c nullptr to stop displaying help of the currently displayed setting.
|
||||
*/
|
||||
void SetDisplayedHelpText(SettingEntry *pe)
|
||||
{
|
||||
@@ -2146,7 +2135,7 @@ struct GameSettingsWindow : Window {
|
||||
this->last_clicked = pe;
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GS_EXPAND_ALL:
|
||||
@@ -2162,17 +2151,17 @@ struct GameSettingsWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_GS_RESTRICT_DROPDOWN: {
|
||||
DropDownList *list = this->BuildDropDownList(widget);
|
||||
if (list != NULL) {
|
||||
ShowDropDownList(this, list, this->filter.mode, widget);
|
||||
DropDownList list = this->BuildDropDownList(widget);
|
||||
if (!list.empty()) {
|
||||
ShowDropDownList(this, std::move(list), this->filter.mode, widget);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GS_TYPE_DROPDOWN: {
|
||||
DropDownList *list = this->BuildDropDownList(widget);
|
||||
if (list != NULL) {
|
||||
ShowDropDownList(this, list, this->filter.type, widget);
|
||||
DropDownList list = this->BuildDropDownList(widget);
|
||||
if (!list.empty()) {
|
||||
ShowDropDownList(this, std::move(list), this->filter.type, widget);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2187,14 +2176,14 @@ struct GameSettingsWindow : Window {
|
||||
uint cur_row = 0;
|
||||
BaseSettingEntry *clicked_entry = GetSettingsTree().FindEntry(btn, &cur_row);
|
||||
|
||||
if (clicked_entry == NULL) return; // Clicked below the last setting of the page
|
||||
if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
|
||||
|
||||
int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (clicked_entry->level + 1) * LEVEL_WIDTH; // Shift x coordinate
|
||||
if (x < 0) return; // Clicked left of the entry
|
||||
|
||||
SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
|
||||
if (clicked_page != NULL) {
|
||||
this->SetDisplayedHelpText(NULL);
|
||||
if (clicked_page != nullptr) {
|
||||
this->SetDisplayedHelpText(nullptr);
|
||||
clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
|
||||
|
||||
this->manually_changed_folding = true;
|
||||
@@ -2204,7 +2193,7 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
|
||||
SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
|
||||
assert(pe != NULL);
|
||||
assert(pe != nullptr);
|
||||
const SettingDesc *sd = pe->setting;
|
||||
|
||||
/* return if action is only active in network, or only settable by server */
|
||||
@@ -2226,9 +2215,9 @@ struct GameSettingsWindow : Window {
|
||||
HideDropDownMenu(this);
|
||||
this->closing_dropdown = false;
|
||||
this->valuedropdown_entry->SetButtons(0);
|
||||
this->valuedropdown_entry = NULL;
|
||||
this->valuedropdown_entry = nullptr;
|
||||
} else {
|
||||
if (this->valuedropdown_entry != NULL) this->valuedropdown_entry->SetButtons(0);
|
||||
if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
|
||||
this->closing_dropdown = false;
|
||||
|
||||
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
|
||||
@@ -2245,12 +2234,12 @@ struct GameSettingsWindow : Window {
|
||||
this->valuedropdown_entry = pe;
|
||||
this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
|
||||
|
||||
DropDownList *list = new DropDownList();
|
||||
DropDownList list;
|
||||
for (int i = sdb->min; i <= (int)sdb->max; i++) {
|
||||
*list->Append() = new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false);
|
||||
list.emplace_back(new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false));
|
||||
}
|
||||
|
||||
ShowDropDownListAt(this, list, value, -1, wi_rect, COLOUR_ORANGE, true);
|
||||
ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true);
|
||||
}
|
||||
}
|
||||
this->SetDirty();
|
||||
@@ -2293,7 +2282,7 @@ struct GameSettingsWindow : Window {
|
||||
|
||||
/* Set up scroller timeout for numeric values */
|
||||
if (value != oldvalue) {
|
||||
if (this->clicked_entry != NULL) { // Release previous buttons if any
|
||||
if (this->clicked_entry != nullptr) { // Release previous buttons if any
|
||||
this->clicked_entry->SetButtons(0);
|
||||
}
|
||||
this->clicked_entry = pe;
|
||||
@@ -2329,21 +2318,21 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnTimeout()
|
||||
void OnTimeout() override
|
||||
{
|
||||
if (this->clicked_entry != NULL) { // On timeout, release any depressed buttons
|
||||
if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
|
||||
this->clicked_entry->SetButtons(0);
|
||||
this->clicked_entry = NULL;
|
||||
this->clicked_entry = nullptr;
|
||||
this->SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
/* The user pressed cancel */
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
assert(this->valuewindow_entry != NULL);
|
||||
assert(this->valuewindow_entry != nullptr);
|
||||
const SettingDesc *sd = this->valuewindow_entry->setting;
|
||||
|
||||
int32 value;
|
||||
@@ -2364,7 +2353,7 @@ struct GameSettingsWindow : Window {
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_GS_RESTRICT_DROPDOWN:
|
||||
@@ -2392,7 +2381,7 @@ struct GameSettingsWindow : Window {
|
||||
default:
|
||||
if (widget < 0) {
|
||||
/* Deal with drop down boxes on the panel. */
|
||||
assert(this->valuedropdown_entry != NULL);
|
||||
assert(this->valuedropdown_entry != nullptr);
|
||||
const SettingDesc *sd = this->valuedropdown_entry->setting;
|
||||
assert(sd->desc.flags & SGF_MULTISTRING);
|
||||
|
||||
@@ -2408,7 +2397,7 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
|
||||
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
|
||||
{
|
||||
if (widget >= 0) {
|
||||
/* Normally the default implementation of OnDropdownClose() takes care of
|
||||
@@ -2421,13 +2410,13 @@ struct GameSettingsWindow : Window {
|
||||
* the same dropdown button was clicked again, and then not open the dropdown again.
|
||||
* So, we only remember that it was closed, and process it on the next OnPaint, which is
|
||||
* after OnClick. */
|
||||
assert(this->valuedropdown_entry != NULL);
|
||||
assert(this->valuedropdown_entry != nullptr);
|
||||
this->closing_dropdown = true;
|
||||
this->SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
|
||||
@@ -2446,8 +2435,8 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
|
||||
|
||||
if (this->last_clicked != NULL && !GetSettingsTree().IsVisible(this->last_clicked)) {
|
||||
this->SetDisplayedHelpText(NULL);
|
||||
if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
|
||||
this->SetDisplayedHelpText(nullptr);
|
||||
}
|
||||
|
||||
bool all_folded = true;
|
||||
@@ -2457,7 +2446,7 @@ struct GameSettingsWindow : Window {
|
||||
this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
|
||||
}
|
||||
|
||||
virtual void OnEditboxChanged(int wid)
|
||||
void OnEditboxChanged(int wid) override
|
||||
{
|
||||
if (wid == WID_GS_FILTER) {
|
||||
this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
|
||||
@@ -2470,13 +2459,13 @@ struct GameSettingsWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET);
|
||||
}
|
||||
};
|
||||
|
||||
GameSettings *GameSettingsWindow::settings_ptr = NULL;
|
||||
GameSettings *GameSettingsWindow::settings_ptr = nullptr;
|
||||
|
||||
static const NWidgetPart _nested_settings_selection_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
@@ -2614,7 +2603,7 @@ struct CustomCurrencyWindow : Window {
|
||||
this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
|
||||
@@ -2632,7 +2621,7 @@ struct CustomCurrencyWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
/* Set the appropriate width for the edit 'buttons' */
|
||||
@@ -2651,7 +2640,7 @@ struct CustomCurrencyWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
int line = 0;
|
||||
int len = 0;
|
||||
@@ -2733,9 +2722,9 @@ struct CustomCurrencyWindow : Window {
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
switch (this->query_widget) {
|
||||
case WID_CC_RATE:
|
||||
@@ -2765,7 +2754,7 @@ struct CustomCurrencyWindow : Window {
|
||||
SetButtonState();
|
||||
}
|
||||
|
||||
virtual void OnTimeout()
|
||||
void OnTimeout() override
|
||||
{
|
||||
this->SetDirty();
|
||||
}
|
||||
@@ -2812,7 +2801,7 @@ static const NWidgetPart _nested_cust_currency_widgets[] = {
|
||||
};
|
||||
|
||||
static WindowDesc _cust_currency_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_CUSTOM_CURRENCY, WC_NONE,
|
||||
0,
|
||||
_nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
|
||||
|
||||
Reference in New Issue
Block a user