summaryrefslogtreecommitdiff
path: root/src/settings_gui.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/settings_gui.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r--src/settings_gui.cpp104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 34514c86f..51b5340e3 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -73,7 +73,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.
@@ -198,7 +198,7 @@ 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
{
@@ -436,19 +436,19 @@ struct GameOptionsWindow : Window {
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;
@@ -508,7 +508,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();
}
@@ -584,9 +584,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;
@@ -879,14 +879,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;
}
/**
@@ -961,7 +961,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;
}
@@ -973,7 +973,7 @@ void SettingEntry::Init(byte level)
{
BaseSettingEntry::Init(level);
this->setting = GetSettingFromName(this->name, &this->index);
- assert(this->setting != NULL);
+ assert(this->setting != nullptr);
}
/**
@@ -1253,14 +1253,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;
}
}
@@ -1416,14 +1416,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);
}
@@ -1479,9 +1479,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();
@@ -1801,10 +1801,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.
@@ -1828,10 +1828,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;
@@ -1885,9 +1885,9 @@ struct GameSettingsWindow : Window {
{
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. */
@@ -1977,7 +1977,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;
@@ -2006,7 +2006,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)
{
@@ -2055,14 +2055,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;
@@ -2072,7 +2072,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 */
@@ -2094,9 +2094,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);
@@ -2161,7 +2161,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;
@@ -2199,9 +2199,9 @@ struct GameSettingsWindow : Window {
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();
}
}
@@ -2209,9 +2209,9 @@ struct GameSettingsWindow : Window {
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;
@@ -2260,7 +2260,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);
@@ -2289,7 +2289,7 @@ 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();
}
@@ -2314,8 +2314,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;
@@ -2344,7 +2344,7 @@ struct GameSettingsWindow : Window {
}
};
-GameSettings *GameSettingsWindow::settings_ptr = NULL;
+GameSettings *GameSettingsWindow::settings_ptr = nullptr;
static const NWidgetPart _nested_settings_selection_widgets[] = {
NWidget(NWID_HORIZONTAL),
@@ -2603,7 +2603,7 @@ struct CustomCurrencyWindow : Window {
void OnQueryTextFinished(char *str) override
{
- if (str == NULL) return;
+ if (str == nullptr) return;
switch (this->query_widget) {
case WID_CC_RATE:
@@ -2680,7 +2680,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)