summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/attrs/attrdisplay.cpp2
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h2
-rw-r--r--src/gui/widgets/avatarlistbox.cpp56
-rw-r--r--src/gui/widgets/basiccontainer.cpp12
-rw-r--r--src/gui/widgets/basiccontainer2.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp38
-rw-r--r--src/gui/widgets/button.cpp68
-rw-r--r--src/gui/widgets/characterdisplay.cpp14
-rw-r--r--src/gui/widgets/characterviewnormal.cpp4
-rw-r--r--src/gui/widgets/characterviewsmall.cpp4
-rw-r--r--src/gui/widgets/chatinput.h6
-rw-r--r--src/gui/widgets/checkbox.cpp28
-rw-r--r--src/gui/widgets/colorpage.cpp6
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/containerplacer.cpp7
-rw-r--r--src/gui/widgets/desktop.cpp20
-rw-r--r--src/gui/widgets/dropdown.cpp44
-rw-r--r--src/gui/widgets/emotepage.cpp10
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp40
-rw-r--r--src/gui/widgets/extendedlistbox.cpp20
-rw-r--r--src/gui/widgets/flowcontainer.cpp8
-rw-r--r--src/gui/widgets/guitable.cpp41
-rw-r--r--src/gui/widgets/horizontcontainer.cpp2
-rw-r--r--src/gui/widgets/icon.cpp14
-rw-r--r--src/gui/widgets/itemcontainer.cpp134
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp14
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp100
-rw-r--r--src/gui/widgets/label.cpp16
-rw-r--r--src/gui/widgets/layoutarray.cpp14
-rw-r--r--src/gui/widgets/layoutcell.cpp4
-rw-r--r--src/gui/widgets/layouthelper.cpp10
-rw-r--r--src/gui/widgets/linepart.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp30
-rw-r--r--src/gui/widgets/passwordfield.cpp4
-rw-r--r--src/gui/widgets/playerbox.cpp10
-rw-r--r--src/gui/widgets/popup.cpp22
-rw-r--r--src/gui/widgets/popuplist.cpp18
-rw-r--r--src/gui/widgets/progressbar.cpp18
-rw-r--r--src/gui/widgets/progressindicator.cpp10
-rw-r--r--src/gui/widgets/radiobutton.cpp26
-rw-r--r--src/gui/widgets/scrollarea.cpp86
-rw-r--r--src/gui/widgets/selldialog.cpp39
-rw-r--r--src/gui/widgets/serverslistbox.h2
-rw-r--r--src/gui/widgets/setupitem.cpp52
-rw-r--r--src/gui/widgets/setuptouchitem.cpp6
-rw-r--r--src/gui/widgets/shoplistbox.cpp22
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp10
-rw-r--r--src/gui/widgets/skilllistbox.h29
-rw-r--r--src/gui/widgets/skillrectanglelistbox.h34
-rw-r--r--src/gui/widgets/slider.cpp44
-rw-r--r--src/gui/widgets/sliderlist.cpp14
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp48
-rw-r--r--src/gui/widgets/statspage.cpp4
-rw-r--r--src/gui/widgets/statspagebasic.cpp12
-rw-r--r--src/gui/widgets/tabbedarea.cpp60
-rw-r--r--src/gui/widgets/tabs/chat/channeltab.cpp6
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp36
-rw-r--r--src/gui/widgets/tabs/chat/emulateguildtab.cpp14
-rw-r--r--src/gui/widgets/tabs/chat/guildtab.cpp12
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp4
-rw-r--r--src/gui/widgets/tabs/chat/whispertab.cpp10
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.cpp12
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_chat.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp18
-rw-r--r--src/gui/widgets/tabs/setup_input.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp14
-rw-r--r--src/gui/widgets/tabs/setup_mods.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_players.cpp4
-rw-r--r--src/gui/widgets/tabs/setup_relations.cpp22
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp8
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp6
-rw-r--r--src/gui/widgets/tabs/setuptabscroll.cpp12
-rw-r--r--src/gui/widgets/tabs/skilltab.h6
-rw-r--r--src/gui/widgets/tabs/socialfriendsfunctor.h7
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h8
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h10
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h4
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h50
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h8
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h22
-rw-r--r--src/gui/widgets/tabs/socialtab.h8
-rw-r--r--src/gui/widgets/tabs/tab.cpp44
-rw-r--r--src/gui/widgets/tabstrip.cpp6
-rw-r--r--src/gui/widgets/textbox.cpp10
-rw-r--r--src/gui/widgets/textfield.cpp33
-rw-r--r--src/gui/widgets/textpreview.cpp12
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/gui/widgets/virtshortcutcontainer.cpp46
-rw-r--r--src/gui/widgets/widget.cpp42
-rw-r--r--src/gui/widgets/widget.h2
-rw-r--r--src/gui/widgets/widget2.h8
-rw-r--r--src/gui/widgets/widgetgroup.cpp4
-rw-r--r--src/gui/widgets/window.cpp152
-rw-r--r--src/gui/widgets/windowcontainer.cpp2
96 files changed, 1040 insertions, 988 deletions
diff --git a/src/gui/widgets/attrs/attrdisplay.cpp b/src/gui/widgets/attrs/attrdisplay.cpp
index 503444e7f..3b91fef9d 100644
--- a/src/gui/widgets/attrs/attrdisplay.cpp
+++ b/src/gui/widgets/attrs/attrdisplay.cpp
@@ -60,7 +60,7 @@ std::string AttrDisplay::update()
const int base = PlayerInfo::getStatBase(mId);
const int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base + bonus);
- if (bonus)
+ if (bonus != 0)
value.append(strprintf("=%d%+d", base, bonus));
mValue->setCaption(value);
return mName;
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
index c4f23339f..1641bac9f 100644
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ b/src/gui/widgets/attrs/attrdisplay.h
@@ -54,7 +54,7 @@ class AttrDisplay notfinal : public Container
std::string getValue() const
{
- if (!mValue)
+ if (mValue == nullptr)
return "-";
else
return mValue->getCaption();
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c81798e29..383efb397 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -56,7 +56,7 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(const Widget2 *const widget,
AvatarListModel *const model) :
ListBox(widget, model, "avatarlistbox.xml"),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
mShowGender(config.getBoolValue("showgender")),
mShowLevel(config.getBoolValue("showlevel"))
{
@@ -86,12 +86,12 @@ AvatarListBox::~AvatarListBox()
if (instances == 0)
{
- if (onlineIcon)
+ if (onlineIcon != nullptr)
{
onlineIcon->decRef();
onlineIcon = nullptr;
}
- if (offlineIcon)
+ if (offlineIcon != nullptr)
{
offlineIcon->decRef();
offlineIcon = nullptr;
@@ -102,14 +102,14 @@ AvatarListBox::~AvatarListBox()
void AvatarListBox::draw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -129,7 +129,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -139,7 +139,7 @@ void AvatarListBox::draw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
{
graphics->calcTileCollection(&vertexes, icon,
mImagePadding, y + mPadding);
@@ -155,7 +155,7 @@ void AvatarListBox::draw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -175,7 +175,7 @@ void AvatarListBox::draw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -347,14 +347,14 @@ void AvatarListBox::draw(Graphics *const graphics)
void AvatarListBox::safeDraw(Graphics *const graphics)
{
BLOCK_START("AvatarListBox::draw")
- if (!mListModel || !localPlayer)
+ if ((mListModel == nullptr) || (localPlayer == nullptr))
{
BLOCK_END("AvatarListBox::draw")
return;
}
const Widget *const parent = mParent;
- if (!parent)
+ if (parent == nullptr)
return;
AvatarListModel *const model = static_cast<AvatarListModel *>(
@@ -373,7 +373,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -383,7 +383,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
// Draw online status
const Image *const icon = a->getOnline()
? onlineIcon : offlineIcon;
- if (icon)
+ if (icon != nullptr)
graphics->drawImage(icon, mImagePadding, y + mPadding);
}
}
@@ -393,7 +393,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
++i, y += fontHeight)
{
const Avatar *const a = model->getAvatarAt(i);
- if (!a)
+ if (a == nullptr)
continue;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -413,7 +413,7 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
a->getHp(), a->getMaxHp());
}
const bool isPoison = a->getPoison();
- if (a->getMaxHp())
+ if (a->getMaxHp() != 0)
{
const ProgressColorIdT themeColor = (isPoison
? ProgressColorId::PROG_HP_POISON
@@ -584,15 +584,19 @@ void AvatarListBox::safeDraw(Graphics *const graphics)
void AvatarListBox::mousePressed(MouseEvent &event)
{
- if (!actorManager || !localPlayer || !popupManager)
+ if (actorManager == nullptr ||
+ localPlayer == nullptr ||
+ popupManager == nullptr)
+ {
return;
+ }
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
const int y = (event.getY() - mPadding) / height;
- if (!mListModel || y > mListModel->getNumberOfElements())
+ if ((mListModel == nullptr) || y > mListModel->getNumberOfElements())
return;
setSelected(y);
@@ -600,10 +604,10 @@ void AvatarListBox::mousePressed(MouseEvent &event)
const int selected = getSelected();
AvatarListModel *const model = static_cast<AvatarListModel *>(
mListModel);
- if (!model)
+ if (model == nullptr)
return;
const Avatar *ava = model->getAvatarAt(selected);
- if (!ava)
+ if (ava == nullptr)
return;
const MapItemType::Type type = static_cast<MapItemType::Type>(
@@ -618,7 +622,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Being *const being = actorManager->findBeingByName(
ava->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
actorManager->heal(being);
}
else
@@ -634,11 +638,11 @@ void AvatarListBox::mousePressed(MouseEvent &event)
case MapItemType::EMPTY:
{
const Avatar *const avatar = model->getAvatarAt(selected);
- if (avatar)
+ if (avatar != nullptr)
{
const Being *const being = actorManager->findBeingByName(
avatar->getName(), ActorType::Player);
- if (being)
+ if (being != nullptr)
{
popupMenu->showPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -698,7 +702,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
{
const Map *const map = viewport->getMap();
ava = model->getAvatarAt(selected);
- if (map && ava)
+ if ((map != nullptr) && (ava != nullptr))
{
MapItem *const mapItem = map->findPortalXY(
ava->getX(), ava->getY());
@@ -712,12 +716,12 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (type == MapItemType::EMPTY && chatWindow)
+ if (type == MapItemType::EMPTY && (chatWindow != nullptr))
{
const std::string &name = model->getAvatarAt(selected)->getName();
const WhisperTab *const tab = chatWindow->addWhisperTab(
name, name, true);
- if (tab)
+ if (tab != nullptr)
chatWindow->saveState();
}
}
diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp
index 68f440fcf..771ba83f4 100644
--- a/src/gui/widgets/basiccontainer.cpp
+++ b/src/gui/widgets/basiccontainer.cpp
@@ -234,7 +234,7 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
{
Widget::setFocusHandler(focusHandler);
- if (mInternalFocusHandler)
+ if (mInternalFocusHandler != nullptr)
return;
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
@@ -243,13 +243,13 @@ void BasicContainer::setFocusHandler(FocusHandler *restrict2 const
void BasicContainer::add(Widget *const widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
mWidgets.push_back(widget);
if (widget->isAllowLogic())
mLogicWidgets.push_back(widget);
- if (!mInternalFocusHandler)
+ if (mInternalFocusHandler == nullptr)
widget->setFocusHandler(getFocusHandler());
else
widget->setFocusHandler(mInternalFocusHandler);
@@ -260,7 +260,7 @@ void BasicContainer::add(Widget *const widget) restrict2
void BasicContainer::remove(Widget *const restrict widget) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
FOR_EACH (WidgetListIterator, iter, mWidgets)
{
@@ -391,7 +391,7 @@ void BasicContainer::logicChildren() restrict2
void BasicContainer::showWidgetPart(Widget *restrict const widget,
const Rect &restrict area) restrict2
{
- if (!widget)
+ if (widget == nullptr)
return;
const Rect widgetArea = getChildrenArea();
@@ -417,7 +417,7 @@ void BasicContainer::setInternalFocusHandler(FocusHandler *const restrict
{
Widget::setInternalFocusHandler(focusHandler);
- FocusHandler *const restrict handler = mInternalFocusHandler ?
+ FocusHandler *const restrict handler = mInternalFocusHandler != nullptr ?
mInternalFocusHandler : getFocusHandler();
FOR_EACH (WidgetListConstIterator, iter, mWidgets)
{
diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp
index c89cf1962..ad143010d 100644
--- a/src/gui/widgets/basiccontainer2.cpp
+++ b/src/gui/widgets/basiccontainer2.cpp
@@ -121,7 +121,7 @@ void BasicContainer2::addXY(Widget *const widget,
const int x,
const int y)
{
- if (!widget)
+ if (widget == nullptr)
return;
widget->setPosition(x, y);
BasicContainer::add(widget);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 0c35b63d4..22a6cec9d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -123,7 +123,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "browserbox.xml");
if (mInstances == 0)
{
@@ -132,15 +132,15 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mNewLinePadding = CAST_U32(
mSkin->getOption("newLinePadding", 15));
mItemPadding = mSkin->getOption("itemPadding");
- if (mSkin->getOption("highlightBackground"))
+ if (mSkin->getOption("highlightBackground") != 0)
mHighlightMode |= LinkHighlightMode::BACKGROUND;
- if (mSkin->getOption("highlightUnderline"))
+ if (mSkin->getOption("highlightUnderline") != 0)
mHighlightMode |= LinkHighlightMode::UNDERLINE;
}
@@ -161,10 +161,10 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
BrowserBox::~BrowserBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
mSkin = nullptr;
@@ -173,7 +173,7 @@ BrowserBox::~BrowserBox()
mInstances --;
if (mInstances == 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -231,7 +231,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
{
bLink.caption = BrowserBoxTools::replaceLinkCommands(
bLink.link);
- if (translator)
+ if (translator != nullptr)
bLink.caption = translator->getStr(bLink.caption);
}
@@ -295,7 +295,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
int cnt = mTextRowLinksCount.front();
mTextRowLinksCount.pop_front();
- while (cnt && !mLinks.empty())
+ while ((cnt != 0) && !mLinks.empty())
{
mLinks.erase(mLinks.begin());
cnt --;
@@ -413,7 +413,7 @@ void BrowserBox::clearRows()
void BrowserBox::mousePressed(MouseEvent &event)
{
- if (!mLinkHandler)
+ if (mLinkHandler == nullptr)
return;
const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(),
@@ -462,7 +462,7 @@ void BrowserBox::draw(Graphics *const graphics)
if (mSelectedLink >= 0 &&
mSelectedLink < CAST_S32(mLinks.size()))
{
- if ((mHighlightMode & LinkHighlightMode::BACKGROUND))
+ if ((mHighlightMode & LinkHighlightMode::BACKGROUND) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHighlightColor);
@@ -473,7 +473,7 @@ void BrowserBox::draw(Graphics *const graphics)
link.y2 - link.y1));
}
- if ((mHighlightMode & LinkHighlightMode::UNDERLINE))
+ if ((mHighlightMode & LinkHighlightMode::UNDERLINE) != 0u)
{
BrowserLink &link = mLinks[CAST_SIZE(mSelectedLink)];
graphics->setColor(mHyperLinkColor);
@@ -494,7 +494,7 @@ void BrowserBox::draw(Graphics *const graphics)
continue;
if (part.mY > yEnd)
break;
- if (!part.mType)
+ if (part.mType == 0u)
{
if (part.mBold)
{
@@ -513,7 +513,7 @@ void BrowserBox::draw(Graphics *const graphics)
part.mX, part.mY);
}
}
- else if (part.mImage)
+ else if (part.mImage != nullptr)
{
graphics->drawImage(part.mImage, part.mX, part.mY);
}
@@ -580,7 +580,7 @@ int BrowserBox::calcHeight()
if (sz > 2 && str.substr(sz - 1) == "~")
str = str.substr(0, sz - 1);
Image *const img = Loader::getImage(str);
- if (img)
+ if (img != nullptr)
{
img->incRef();
mLineParts.push_back(LinePart(CAST_S32(x),
@@ -757,14 +757,14 @@ int BrowserBox::calcHeight()
const int cid = row.at(start + 2) - '0';
if (cid >= 0)
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
const size_t sz = mEmotes->size();
if (CAST_SIZE(cid) < sz)
{
Image *const img = mEmotes->get(
CAST_SIZE(cid));
- if (img)
+ if (img != nullptr)
{
mLineParts.push_back(LinePart(
CAST_S32(x),
@@ -890,7 +890,7 @@ int BrowserBox::calcHeight()
void BrowserBox::updateHeight()
{
if (mAlwaysUpdate || mUpdateTime != cur_time
- || mTextRows.size() < 3 || !mUpdateTime)
+ || mTextRows.size() < 3 || (mUpdateTime == 0))
{
mWidth = mDimension.width;
mHeight = calcHeight();
@@ -958,7 +958,7 @@ void BrowserBox::moveSelectionDown()
void BrowserBox::selectSelection()
{
- if (!mLinkHandler ||
+ if ((mLinkHandler == nullptr) ||
mSelectedLink < 0 ||
mSelectedLink >= static_cast<signed int>(mLinks.size()))
{
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index f24d5c9a0..3509b927c 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -183,7 +183,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -234,7 +234,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -284,7 +284,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -334,7 +334,7 @@ Button::Button(const Widget2 *const widget,
adjustSize();
setActionEventId(actionEventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
@@ -351,12 +351,12 @@ void Button::init()
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
{
Skin *const skin = theme->load(data[mode], "button.xml");
- if (skin)
+ if (skin != nullptr)
{
button[mode] = skin;
mSpacing[mode] = skin->getOption("spacing");
@@ -372,26 +372,26 @@ void Button::init()
Button::~Button()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < BUTTON_COUNT; mode ++)
theme->unload(button[mode]);
}
delete2(mVertexes2);
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
- if (mImages)
+ if (mImages != nullptr)
{
for (int f = 0; f < BUTTON_COUNT; f ++)
mImages[f] = nullptr;
@@ -403,7 +403,7 @@ Button::~Button()
void Button::loadImage(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
@@ -416,21 +416,21 @@ void Button::loadImage(const std::string &imageName)
void Button::loadImageSet(const std::string &imageName)
{
- if (mImageSet)
+ if (mImageSet != nullptr)
{
mImageSet->decRef();
mImageSet = nullptr;
}
mImageSet = Theme::getImageSetFromTheme(imageName,
mImageWidth, mImageHeight);
- if (!mImageSet)
+ if (mImageSet == nullptr)
return;
mImages = new Image*[BUTTON_COUNT];
mImages[0] = nullptr;
for (size_t f = 0; f < BUTTON_COUNT; f ++)
{
Image *const img = mImageSet->get(f);
- if (img)
+ if (img != nullptr)
mImages[f] = img;
else
mImages[f] = mImages[0];
@@ -450,11 +450,11 @@ void Button::updateAlpha()
for (int a = 0; a < 9; a ++)
{
Skin *const skin = button[mode];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -477,7 +477,7 @@ void Button::draw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::draw")
return;
@@ -526,7 +526,7 @@ void Button::draw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -536,7 +536,7 @@ void Button::draw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -550,7 +550,7 @@ void Button::draw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -581,7 +581,7 @@ void Button::draw(Graphics *const graphics)
width, height,
skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
{
@@ -635,7 +635,7 @@ void Button::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::draw")
@@ -656,7 +656,7 @@ void Button::safeDraw(Graphics *const graphics)
mode = BUTTON_STANDARD;
const Skin *const skin = button[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Button::safeDraw")
return;
@@ -681,7 +681,7 @@ void Button::safeDraw(Graphics *const graphics)
const int height = rect.height;
Font *const font = getFont();
int textY = height / 2 - font->getHeight() / 2;
- if (mImages)
+ if (mImages != nullptr)
imageY = height / 2 - mImageHeight / 2;
// need move calculation from draw!!!
@@ -691,7 +691,7 @@ void Button::safeDraw(Graphics *const graphics)
default:
case Graphics::LEFT:
{
- if (mImages)
+ if (mImages != nullptr)
{
imageX = padding;
textX = padding + mImageWidth + spacing;
@@ -705,7 +705,7 @@ void Button::safeDraw(Graphics *const graphics)
case Graphics::CENTER:
{
const int width1 = font->getWidth(mCaption);
- if (mImages)
+ if (mImages != nullptr)
{
const int w = width1 + mImageWidth + spacing;
imageX = (width - w) / 2;
@@ -728,7 +728,7 @@ void Button::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0, width, height, skin->getBorder());
- if (mImages)
+ if (mImages != nullptr)
{
if (isPressed())
graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
@@ -771,7 +771,7 @@ void Button::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Button::safeDraw")
@@ -822,15 +822,15 @@ void Button::adjustSize()
{
const Font *const font = getFont();
const Skin *const skin = button[BUTTON_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
- if (mImages)
+ if (mImages != nullptr)
{
const int spacing = mSpacing[BUTTON_STANDARD];
const int width = font->getWidth(mCaption);
- if (width)
+ if (width != 0)
setWidth(width + mImageWidth + spacing + 2 * padding);
else
setWidth(mImageWidth + 2 * padding);
@@ -916,14 +916,14 @@ void Button::mouseDragged(MouseEvent& event)
void Button::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Button::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 696b8c2bf..c3b5ea064 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -85,7 +85,7 @@ void CharacterDisplay::setCharacter(Net::Character *const character)
return;
mCharacter = character;
- mPlayerBox->setPlayer(character ? character->dummy : nullptr);
+ mPlayerBox->setPlayer(character != nullptr ? character->dummy : nullptr);
update();
}
@@ -99,7 +99,7 @@ void CharacterDisplay::setActive(const bool active A_UNUSED)
void CharacterDisplay::update()
{
- if (mCharacter)
+ if (mCharacter != nullptr)
mName->setCaption(mCharacter->dummy->getName());
else
mName->setCaption("");
@@ -111,20 +111,24 @@ void CharacterDisplay::update()
void CharacterDisplay::widgetHidden(const Event &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED)
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (!gui || !textPopup || !mCharacter)
+ if (gui == nullptr ||
+ textPopup == nullptr ||
+ mCharacter == nullptr)
+ {
return;
+ }
int mouseX = 0;
int mouseY = 0;
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp
index c4bf0d5ef..c92ad7477 100644
--- a/src/gui/widgets/characterviewnormal.cpp
+++ b/src/gui/widgets/characterviewnormal.cpp
@@ -34,7 +34,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -47,7 +47,7 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget,
if (mSelected >= 0 && mSelected < CAST_S32(sz))
{
CharacterDisplay *const display = (*mCharacterEntries)[mSelected];
- if (display)
+ if (display != nullptr)
display->setSelect(false);
}
if (sz > 0)
diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp
index dbb04064f..a861e5033 100644
--- a/src/gui/widgets/characterviewsmall.cpp
+++ b/src/gui/widgets/characterviewsmall.cpp
@@ -40,7 +40,7 @@ CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget,
mCharacterEntries(entries)
{
addKeyListener(widget);
- if (entries)
+ if (entries != nullptr)
{
FOR_EACHP (std::vector<CharacterDisplay*>::iterator,
it, entries)
@@ -81,7 +81,7 @@ void CharacterViewSmall::show(const int i)
const int sz = CAST_S32(mCharacterEntries->size());
if (sz <= 0)
return;
- if (mSelectedEntry)
+ if (mSelectedEntry != nullptr)
mSelectedEntry->setVisible(Visible_false);
if (i >= sz)
mSelected = 0;
diff --git a/src/gui/widgets/chatinput.h b/src/gui/widgets/chatinput.h
index 2a6a23a80..92c7dc341 100644
--- a/src/gui/widgets/chatinput.h
+++ b/src/gui/widgets/chatinput.h
@@ -60,7 +60,7 @@ class ChatInput final : public TextField
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
{
processVisible(Visible_false);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->updateVisibility();
mFocusGaining = false;
return;
@@ -72,7 +72,7 @@ class ChatInput final : public TextField
void processVisible(const Visible n)
{
- if (!mWindow || isVisible() == (n == Visible_true))
+ if (mWindow == nullptr || isVisible() == (n == Visible_true))
return;
if (n == Visible_false)
@@ -83,7 +83,7 @@ class ChatInput final : public TextField
{
mWindow->adjustTabSize();
}
- if (emoteWindow)
+ if (emoteWindow != nullptr)
{
emoteWindow->hide();
}
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 03da61a7b..ab1227b08 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -115,7 +115,7 @@ CheckBox::CheckBox(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::CHECKBOX_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("checkbox.xml", "");
updateAlpha();
@@ -127,17 +127,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mForegroundColor = getThemeColor(ThemeColorId::CHECKBOX);
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
mImageSize = mSkin->getOption("imageSize");
mSpacing = mSkin->getOption("spacing");
- mDrawBox = mSkin->getOption("drawBox", 1);
+ mDrawBox = (mSkin->getOption("drawBox", 1) != 0);
mTextX = mPadding + mImageSize + mSpacing;
}
adjustSize();
@@ -145,17 +145,17 @@ CheckBox::CheckBox(const Widget2 *const widget,
CheckBox::~CheckBox()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -179,7 +179,7 @@ void CheckBox::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("CheckBox::draw")
@@ -198,13 +198,13 @@ void CheckBox::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 6; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -213,7 +213,7 @@ void CheckBox::updateAlpha()
void CheckBox::drawBox(Graphics *const graphics)
{
- if (!mSkin || !mDrawBox)
+ if ((mSkin == nullptr) || !mDrawBox)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -247,7 +247,7 @@ void CheckBox::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -313,7 +313,7 @@ void CheckBox::setCaption(const std::string& caption)
void CheckBox::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -326,7 +326,7 @@ void CheckBox::widgetHidden(const Event &event A_UNUSED)
void CheckBox::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp
index f29540c0f..fa3099c2c 100644
--- a/src/gui/widgets/colorpage.cpp
+++ b/src/gui/widgets/colorpage.cpp
@@ -35,11 +35,11 @@ ColorPage::ColorPage(const Widget2 *const widget,
const std::string &skin) :
ListBox(widget, listModel, skin)
{
- mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1;
+ mItemPadding = mSkin != nullptr ? mSkin->getOption("itemPadding") : 1;
const Font *const font = getFont();
mRowHeight = CAST_U32(font->getHeight() +
2 * mItemPadding);
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements()
@@ -114,7 +114,7 @@ void ColorPage::resetAction()
void ColorPage::adjustSize()
{
BLOCK_START("ColorPage::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() +
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index e6f8ad4f4..2da444728 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -34,7 +34,7 @@ Container::Container(const Widget2 *const widget) :
Container::~Container()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
removeControls();
}
diff --git a/src/gui/widgets/containerplacer.cpp b/src/gui/widgets/containerplacer.cpp
index 8db3a0e25..634a87fcd 100644
--- a/src/gui/widgets/containerplacer.cpp
+++ b/src/gui/widgets/containerplacer.cpp
@@ -29,15 +29,16 @@
ContainerPlacer ContainerPlacer::at(const int x, const int y)
{
- return ContainerPlacer(mContainer, mCell ? &mCell->at(x, y) : nullptr);
+ return ContainerPlacer(mContainer,
+ mCell != nullptr ? &mCell->at(x, y) : nullptr);
}
LayoutCell &ContainerPlacer::operator()
(const int x, const int y, Widget *const wg, const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
- if (mCell)
+ if (mCell != nullptr)
return mCell->place(wg, x, y, w, h);
return LayoutCell::emptyCell;
}
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 83d5bd58e..43248ebe8 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -64,11 +64,11 @@ Desktop::Desktop(const Widget2 *const widget) :
Wallpaper::loadWallpapers();
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("desktop.xml", "");
- if (mSkin)
- mShowBackground = mSkin->getOption("showBackground");
+ if (mSkin != nullptr)
+ mShowBackground = (mSkin->getOption("showBackground") != 0);
const std::string appName = branding.getValue("appName", std::string());
if (appName.empty())
@@ -87,18 +87,18 @@ Desktop::Desktop(const Widget2 *const widget) :
Desktop::~Desktop()
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
mWallpaper->decRef();
mWallpaper = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
void Desktop::postInit()
{
- if (mSkin)
+ if (mSkin != nullptr)
{
addXY(mVersionLabel,
mSkin->getOption("versionX", 25),
@@ -130,7 +130,7 @@ void Desktop::draw(Graphics *const graphics)
const Rect &rect = mDimension;
const int width = rect.width;
const int height = rect.height;
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
const int wallpWidth = mWallpaper->getWidth();
const int wallpHeight = mWallpaper->getHeight();
@@ -178,9 +178,9 @@ void Desktop::setBestFittingWallpaper()
Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName);
- if (nWallPaper)
+ if (nWallPaper != nullptr)
{
- if (mWallpaper)
+ if (mWallpaper != nullptr)
{
ResourceManager::decRefDelete(mWallpaper);
mWallpaper = nullptr;
@@ -198,7 +198,7 @@ void Desktop::setBestFittingWallpaper()
Image *const newRsclWlPpr = Loader::getRescaled(
nWallPaper, width, height);
- if (newRsclWlPpr)
+ if (newRsclWlPpr != nullptr)
{
ResourceManager::decRefDelete(nWallPaper);
// We replace the resource in the resource manager
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index eb848f4d6..cb9eef73d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -84,20 +84,20 @@ DropDown::DropDown(const Widget2 *const widget,
mPopup->setHeight(100);
// Initialize graphics
- if (instances == 0 && theme)
+ if (instances == 0 && (theme != nullptr))
{
// Load the background skin
for (int i = 0; i < 2; i ++)
{
Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml");
- if (skin)
+ if (skin != nullptr)
{
- if (!i)
+ if (i == 0)
mSkin = skin;
const ImageRect &rect = skin->getBorder();
for (int f = 0; f < 2; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
{
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
@@ -108,7 +108,7 @@ DropDown::DropDown(const Widget2 *const widget,
buttons[f][i] = nullptr;
}
}
- if (i)
+ if (i != 0)
theme->unload(skin);
}
else
@@ -144,12 +144,12 @@ DropDown::DropDown(const Widget2 *const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
mPopup->adjustSize();
- if (mSkin)
+ if (mSkin != nullptr)
{
mSpacing = mSkin->getOption("spacing");
mFrameSize = CAST_U32(mSkin->getOption("frameSize"));
@@ -161,7 +161,7 @@ DropDown::DropDown(const Widget2 *const widget,
DropDown::~DropDown()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
@@ -171,11 +171,11 @@ DropDown::~DropDown()
{
for (int i = 0; i < 2; i ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skinRect);
@@ -192,18 +192,18 @@ void DropDown::updateAlpha()
{
mAlpha = alpha;
- if (buttons[0][0])
+ if (buttons[0][0] != nullptr)
buttons[0][0]->setAlpha(mAlpha);
- if (buttons[0][1])
+ if (buttons[0][1] != nullptr)
buttons[0][1]->setAlpha(mAlpha);
- if (buttons[1][0])
+ if (buttons[1][0] != nullptr)
buttons[1][0]->setAlpha(mAlpha);
- if (buttons[1][1])
+ if (buttons[1][1] != nullptr)
buttons[1][1]->setAlpha(mAlpha);
for (int a = 0; a < 9; a++)
{
- if (skinRect.grid[a])
+ if (skinRect.grid[a] != nullptr)
skinRect.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void DropDown::draw(Graphics *const graphics)
mShadowColor.a = alpha;
ListModel *const model = mPopup->getListModel();
- if (model && mPopup->getSelected() >= 0)
+ if ((model != nullptr) && mPopup->getSelected() >= 0)
{
Font *const font = getFont();
if (mExtended)
@@ -236,7 +236,7 @@ void DropDown::draw(Graphics *const graphics)
ExtendedListModel *const model2
= static_cast<ExtendedListModel *>(model);
const Image *const image = model2->getImageAt(sel);
- if (!image)
+ if (image == nullptr)
{
font->drawString(graphics,
mForegroundColor,
@@ -320,7 +320,7 @@ void DropDown::drawButton(Graphics *const graphics)
const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height;
Image *image = buttons[mDroppedDown][mPushed];
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mDimension.width - image->getWidth() - mImagePadding,
@@ -356,7 +356,7 @@ void DropDown::keyPressed(KeyEvent& event)
break;
case InputAction::GUI_END:
- if (mPopup->getListModel())
+ if (mPopup->getListModel() != nullptr)
{
setSelected(mPopup->getListModel()->
getNumberOfElements() - 1);
@@ -441,7 +441,7 @@ void DropDown::mouseWheelMovedDown(MouseEvent& event)
void DropDown::setSelectedString(const std::string &str)
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return;
for (int f = 0; f < listModel->getNumberOfElements(); f ++)
@@ -457,7 +457,7 @@ void DropDown::setSelectedString(const std::string &str)
std::string DropDown::getSelectedString() const
{
ListModel *const listModel = mPopup->getListModel();
- if (!listModel)
+ if (listModel == nullptr)
return "";
return listModel->getElementAt(getSelected());
@@ -472,7 +472,7 @@ void DropDown::dropDown()
{
if (!mDroppedDown)
{
- if (!mParent)
+ if (mParent == nullptr)
return;
mDroppedDown = true;
mFoldedUpHeight = getHeight();
diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp
index 771813d1b..459e386a4 100644
--- a/src/gui/widgets/emotepage.cpp
+++ b/src/gui/widgets/emotepage.cpp
@@ -54,7 +54,7 @@ EmotePage::EmotePage(const Widget2 *const widget) :
EmotePage::~EmotePage()
{
- if (mEmotes)
+ if (mEmotes != nullptr)
{
mEmotes->decRef();
mEmotes = nullptr;
@@ -68,7 +68,7 @@ void EmotePage::draw(Graphics *const graphics)
if (mRedraw)
{
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -82,7 +82,7 @@ void EmotePage::draw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->calcTileCollection(mVertexes, image, x, y);
x += emoteWidth;
@@ -104,7 +104,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
{
BLOCK_START("EmotePage::safeDraw")
- if (!mEmotes)
+ if (mEmotes == nullptr)
return;
const std::vector<Image*> &images = mEmotes->getImages();
@@ -116,7 +116,7 @@ void EmotePage::safeDraw(Graphics *const graphics)
FOR_EACH (std::vector<Image*>::const_iterator, it, images)
{
const Image *const image = *it;
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image, x, y);
x += emoteWidth;
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 0d75051eb..37acf7263 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -57,14 +57,14 @@ EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *restrict const
mEmoteClicked(false),
mEmoteMoved(0)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(settings.guiAlpha);
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
const EmoteSprite *const sprite = EmoteDB::getSprite(i, true);
- if (sprite && sprite->sprite)
+ if ((sprite != nullptr) && (sprite->sprite != nullptr))
mEmoteImg.push_back(sprite);
}
@@ -85,13 +85,13 @@ void EmoteShortcutContainer::setWidget2(const Widget2 *restrict const widget)
void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,10 +105,10 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -137,13 +137,13 @@ void EmoteShortcutContainer::draw(Graphics *restrict graphics) restrict2
void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
BLOCK_START("EmoteShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -157,10 +157,10 @@ void EmoteShortcutContainer::safeDraw(Graphics *restrict graphics) restrict2
for (unsigned i = 0; i < sz; i++)
{
const EmoteSprite *restrict const emoteImg = mEmoteImg[i];
- if (emoteImg)
+ if (emoteImg != nullptr)
{
const AnimatedSprite *restrict const sprite = emoteImg->sprite;
- if (sprite)
+ if (sprite != nullptr)
{
sprite->draw(graphics,
(i % mGridWidth) * mBoxWidth + 2,
@@ -199,7 +199,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
if (event.getButton() == MouseButton::LEFT)
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -214,14 +214,14 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
emoteShortcut->setEmote(index);
emoteShortcut->setEmoteSelected(0);
}
- else if (emoteShortcut->getEmote(index))
+ else if (emoteShortcut->getEmote(index) != 0u)
{
mEmoteClicked = true;
}
}
else if (event.getButton() == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showEmoteType();
@@ -232,7 +232,7 @@ void EmoteShortcutContainer::mousePressed(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
restrict2
{
- if (!emoteShortcut)
+ if (emoteShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -248,12 +248,12 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
return;
}
- if (mEmoteMoved)
+ if (mEmoteMoved != 0u)
{
emoteShortcut->setEmotes(index, mEmoteMoved);
mEmoteMoved = 0;
}
- else if (emoteShortcut->getEmote(index) && mEmoteClicked)
+ else if ((emoteShortcut->getEmote(index) != 0u) && mEmoteClicked)
{
emoteShortcut->useEmote(index + 1);
}
@@ -264,7 +264,7 @@ void EmoteShortcutContainer::mouseReleased(MouseEvent &restrict event)
void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
{
- if (!emoteShortcut || !textPopup)
+ if ((emoteShortcut == nullptr) || (textPopup == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -274,7 +274,7 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
textPopup->setVisible(Visible_false);
- if (CAST_SIZE(index) < mEmoteImg.size() && mEmoteImg[index])
+ if (CAST_SIZE(index) < mEmoteImg.size() && (mEmoteImg[index] != nullptr))
{
const EmoteSprite *restrict const sprite = mEmoteImg[index];
textPopup->show(viewport->mMouseX, viewport->mMouseY,
@@ -285,13 +285,13 @@ void EmoteShortcutContainer::mouseMoved(MouseEvent &restrict event) restrict2
void EmoteShortcutContainer::mouseExited(MouseEvent &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
void EmoteShortcutContainer::widgetHidden(const Event &restrict event A_UNUSED)
restrict2
{
- if (textPopup)
+ if (textPopup != nullptr)
textPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp
index 921dfee7f..ebbb07bf3 100644
--- a/src/gui/widgets/extendedlistbox.cpp
+++ b/src/gui/widgets/extendedlistbox.cpp
@@ -35,13 +35,13 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget,
const std::string &skin,
const unsigned int rowHeight) :
ListBox(widget, listModel, skin),
- mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0),
- mSpacing(mSkin ? mSkin->getOption("spacing") : 0),
+ mImagePadding(mSkin != nullptr ? mSkin->getOption("imagePadding") : 0),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing") : 0),
mHeight(0),
mListItems(),
mSelectedItems()
{
- if (rowHeight)
+ if (rowHeight != 0u)
mRowHeight = rowHeight;
}
@@ -51,7 +51,7 @@ ExtendedListBox::~ExtendedListBox()
void ExtendedListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ExtendedListBox::draw")
@@ -81,7 +81,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
int strWidth = font->getWidth(str) + 8;
const Image *const image = model->getImageAt(row);
- if (image)
+ if (image != nullptr)
strWidth += image->getWidth() + mImagePadding;
std::vector<ExtendedListBoxItem> &list =
@@ -145,7 +145,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -160,7 +160,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundColor, mForegroundColor2,
@@ -182,7 +182,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
const int row1 = item.row;
const int y1 = item.y;
const Image *const image = model->getImageAt(row1);
- if (!image || !item.image)
+ if ((image == nullptr) || !item.image)
{
font->drawString(graphics,
mForegroundSelectedColor, mForegroundSelectedColor2,
@@ -205,7 +205,7 @@ void ExtendedListBox::draw(Graphics *const graphics)
if (item.image)
{
const Image *const image = model->getImageAt(row1);
- if (image)
+ if (image != nullptr)
{
graphics->drawImage(image,
mImagePadding,
@@ -224,7 +224,7 @@ void ExtendedListBox::safeDraw(Graphics *const graphics)
void ExtendedListBox::adjustSize()
{
- if (mHeight)
+ if (mHeight != 0)
setHeight(mHeight + 2 * mPadding);
else
ListBox::adjustSize();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 7f33208c2..ee3181636 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -34,9 +34,9 @@ FlowContainer::FlowContainer(const Widget2 *const widget,
mGridHeight(1)
{
addWidgetListener(this);
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mBoxWidth = 1;
- if (!mBoxHeight)
+ if (mBoxHeight == 0)
mBoxHeight = 1;
}
@@ -50,7 +50,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
const int itemCount = CAST_S32(mWidgets.size());
- if (!mBoxWidth)
+ if (mBoxWidth == 0)
mGridWidth = getWidth();
else
mGridWidth = getWidth() / mBoxWidth;
@@ -88,7 +88,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED)
void FlowContainer::add(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 3c22dd4b1..392755a20 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -69,7 +69,7 @@ GuiTable::GuiTable(const Widget2 *const widget,
GuiTable::~GuiTable()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
uninstallActionListeners();
@@ -83,7 +83,7 @@ const TableModel *GuiTable::getModel() const
void GuiTable::setModel(TableModel *const new_model)
{
- if (mModel)
+ if (mModel != nullptr)
{
uninstallActionListeners();
mModel->removeListener(this);
@@ -98,7 +98,7 @@ void GuiTable::setModel(TableModel *const new_model)
void GuiTable::recomputeDimensions()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
const int rows_nr = mModel->getRows();
@@ -211,7 +211,7 @@ void GuiTable::installActionListeners()
for (int column = 0; column < columns; ++column)
{
Widget *const widget = mModel->getElementAt(row, column);
- if (widget)
+ if (widget != nullptr)
{
mActionListeners2.push_back(new GuiTableActionListener(
this, widget, row, column));
@@ -225,7 +225,7 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -246,7 +246,7 @@ void GuiTable::draw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -288,7 +288,7 @@ void GuiTable::draw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -331,7 +331,7 @@ void GuiTable::draw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -343,7 +343,7 @@ void GuiTable::draw(Graphics *const graphics)
void GuiTable::safeDraw(Graphics *const graphics)
{
- if (!getRowHeight())
+ if (getRowHeight() == 0)
return;
BLOCK_START("GuiTable::draw")
@@ -364,7 +364,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
// First, determine how many rows we need to draw,
// and where we should start.
int rHeight = getRowHeight();
- if (!rHeight)
+ if (rHeight == 0)
rHeight = 1;
int first_row = -(y / rHeight);
@@ -406,7 +406,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
CAST_S32(c));
const int cWidth = CAST_S32(getColumnWidth(
CAST_S32(c)));
- if (widget)
+ if (widget != nullptr)
{
Rect bounds(x_offset, y_offset, cWidth, rHeight);
@@ -449,7 +449,7 @@ void GuiTable::safeDraw(Graphics *const graphics)
y_offset += rHeight;
}
- if (mTopWidget)
+ if (mTopWidget != nullptr)
{
const Rect &bounds = mTopWidget->getDimension();
graphics->pushClipArea(bounds);
@@ -513,7 +513,7 @@ void GuiTable::keyPressed(KeyEvent& event)
setSelectedColumn(0);
event.consume();
}
- else if (action == InputAction::GUI_END && mModel)
+ else if (action == InputAction::GUI_END && (mModel != nullptr))
{
setSelectedRow(mModel->getRows() - 1);
setSelectedColumn(mModel->getColumns() - 1);
@@ -596,13 +596,16 @@ Widget *GuiTable::getWidgetAt(int x, int y)
const int row = getRowForY(y);
const int column = getColumnForX(x);
- if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y))
+ if (mTopWidget != nullptr &&
+ mTopWidget->getDimension().isPointInRect(x, y))
+ {
return mTopWidget;
+ }
- if (mModel && row > -1 && column > -1)
+ if ((mModel != nullptr) && row > -1 && column > -1)
{
Widget *const w = mModel->getElementAt(row, column);
- if (w && w->isFocusable())
+ if ((w != nullptr) && w->isFocusable())
return w;
else
return nullptr; // Grab the event locally
@@ -648,7 +651,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
{
// add check for focusHandler. may be need remove it?
- if (!focusHandler)
+ if (focusHandler == nullptr)
return;
Widget::setFocusHandler(focusHandler);
@@ -660,7 +663,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
for (int c = 0; c < cols ; ++c)
{
Widget *const w = mModel->getElementAt(r, c);
- if (w)
+ if (w != nullptr)
w->setFocusHandler(focusHandler);
}
}
@@ -668,7 +671,7 @@ void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
void GuiTable::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
Widget::requestFocus();
}
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index 5b3b08d16..8a026329a 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -45,7 +45,7 @@ void HorizontContainer::add(Widget *const widget)
void HorizontContainer::add(Widget *const widget, const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 8cb43db6d..dbe46a21a 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -39,7 +39,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(Loader::getImage(file)),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -54,7 +54,7 @@ Icon::Icon(const Widget2 *const widget,
mImage(image),
mAutoRelease(autoRelease)
{
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -64,16 +64,16 @@ Icon::Icon(const Widget2 *const widget,
Icon::~Icon()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mImage && mAutoRelease == AutoRelease_true)
+ if ((mImage != nullptr) && mAutoRelease == AutoRelease_true)
mImage->decRef();
}
void Icon::setImage(Image *const image)
{
mImage = image;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &bounds = mImage->mBounds;
setSize(bounds.w, bounds.h);
@@ -83,7 +83,7 @@ void Icon::setImage(Image *const image)
void Icon::draw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
@@ -95,7 +95,7 @@ void Icon::draw(Graphics *const graphics)
void Icon::safeDraw(Graphics *const graphics)
{
BLOCK_START("Icon::draw")
- if (mImage)
+ if (mImage != nullptr)
{
graphics->drawImage(mImage,
(mDimension.width - mImage->mBounds.w) / 2,
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 857467f63..15e2df093 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -88,7 +88,7 @@ namespace
{
const Item *const item1 = pair1->mItem;
const Item *const item2 = pair2->mItem;
- if (!item1 || !item2)
+ if ((item1 == nullptr) || (item2 == nullptr))
return false;
const std::string name1 = item1->getInfo().getName(
@@ -112,7 +112,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int id1 = pair1->mItem->getId();
@@ -134,7 +134,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int w1 = pair1->mItem->getInfo().getWeight();
@@ -164,7 +164,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const int c1 = pair1->mItem->getQuantity();
@@ -194,7 +194,7 @@ namespace
bool operator() (const ItemIdPair *const pair1,
const ItemIdPair *const pair2) const
{
- if (!pair1->mItem || !pair2->mItem)
+ if ((pair1->mItem == nullptr) || (pair2->mItem == nullptr))
return false;
const ItemInfo &info1 = pair1->mItem->getInfo();
@@ -232,7 +232,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mCellBackgroundImg(Theme::getImageFromThemeXml("inventory_cell.xml", "")),
mName(),
mShowMatrix(nullptr),
- mSkin(theme ? theme->load("itemcontainer.xml", "") : nullptr),
+ mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "") : nullptr),
mVertexes(new ImageCollection),
mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED)),
mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE)),
@@ -246,12 +246,12 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
mTag(0),
mSortType(0),
mClicks(1),
- mBoxWidth(mSkin ? mSkin->getOption("boxWidth", 35) : 35),
- mBoxHeight(mSkin ? mSkin->getOption("boxHeight", 43) : 43),
- mEquippedTextPadding(mSkin ? mSkin->getOption(
+ mBoxWidth(mSkin != nullptr ? mSkin->getOption("boxWidth", 35) : 35),
+ mBoxHeight(mSkin != nullptr ? mSkin->getOption("boxHeight", 43) : 43),
+ mEquippedTextPadding(mSkin != nullptr ? mSkin->getOption(
"equippedTextPadding", 29) : 29),
- mPaddingItemX(mSkin ? mSkin->getOption("paddingItemX", 0) : 0),
- mPaddingItemY(mSkin ? mSkin->getOption("paddingItemY", 0) : 0),
+ mPaddingItemX(mSkin != nullptr ? mSkin->getOption("paddingItemX", 0) : 0),
+ mPaddingItemY(mSkin != nullptr ? mSkin->getOption("paddingItemY", 0) : 0),
mMaxColumns(maxColumns),
mSelectionStatus(SEL_NONE),
mForceQuantity(forceQuantity),
@@ -267,26 +267,26 @@ ItemContainer::ItemContainer(const Widget2 *const widget,
ItemContainer::~ItemContainer()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (mSelImg)
+ if (mSelImg != nullptr)
{
mSelImg->decRef();
mSelImg = nullptr;
}
- if (mProtectedImg)
+ if (mProtectedImg != nullptr)
{
mProtectedImg->decRef();
mProtectedImg = nullptr;
}
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
mCellBackgroundImg->decRef();
mCellBackgroundImg = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
delete []mShowMatrix;
@@ -298,7 +298,7 @@ void ItemContainer::logic()
BLOCK_START("ItemContainer::logic")
Widget::logic();
- if (!mInventory)
+ if (mInventory == nullptr)
{
BLOCK_END("ItemContainer::logic")
return;
@@ -316,13 +316,13 @@ void ItemContainer::logic()
void ItemContainer::draw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
if (mRedraw || graphics->getRedraw())
{
@@ -367,22 +367,22 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -408,7 +408,7 @@ void ItemContainer::draw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -447,13 +447,13 @@ void ItemContainer::draw(Graphics *const graphics)
void ItemContainer::safeDraw(Graphics *const graphics)
{
- if (!mInventory || !mShowMatrix)
+ if ((mInventory == nullptr) || (mShowMatrix == nullptr))
return;
BLOCK_START("ItemContainer::draw")
Font *const font = getFont();
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
{
const int invSize = mInventory->getSize();
const int maxRows = mShowEmptyRows == ShowEmptyRows_true ?
@@ -489,22 +489,22 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
if (mShowMatrix[itemIndex] == mSelectedIndex)
{
- if (mSelImg)
+ if (mSelImg != nullptr)
graphics->drawImage(mSelImg, itemX, itemY);
}
image->setAlpha(1.0F); // ensure the image if fully drawn...
graphics->drawImage(image,
itemX + mPaddingItemX,
itemY + mPaddingItemY);
- if (mProtectedImg && PlayerInfo::isItemProtected(
+ if ((mProtectedImg != nullptr) && PlayerInfo::isItemProtected(
item->getId()))
{
graphics->drawImage(mProtectedImg,
@@ -530,7 +530,7 @@ void ItemContainer::safeDraw(Graphics *const graphics)
const Item *const item = mInventory->getItem(
mShowMatrix[itemIndex]);
- if (!item || item->getId() == 0)
+ if ((item == nullptr) || item->getId() == 0)
continue;
// Draw item caption
@@ -592,7 +592,7 @@ void ItemContainer::setSelectedIndex(const int newIndex)
Item *ItemContainer::getSelectedItem() const
{
- if (mInventory)
+ if (mInventory != nullptr)
return mInventory->getItem(mSelectedIndex);
else
return nullptr;
@@ -602,7 +602,7 @@ void ItemContainer::distributeValueChangedEvent()
{
FOR_EACH (SelectionListenerIterator, i, mSelectionListeners)
{
- if (*i)
+ if (*i != nullptr)
{
SelectionEvent event(this);
(*i)->valueChanged(event);
@@ -620,7 +620,7 @@ void ItemContainer::keyReleased(KeyEvent &event A_UNUSED)
void ItemContainer::mousePressed(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const MouseButtonT button = event.getButton();
@@ -636,7 +636,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
Item *const item = mInventory->getItem(index);
// put item name into chat window
- if (item && mDescItems && chatWindow)
+ if ((item != nullptr) && mDescItems && (chatWindow != nullptr))
chatWindow->addItemText(item->getInfo().getName());
DragDropSourceT src = DragDropSource::Empty;
@@ -674,7 +674,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
dragDrop.select(item);
mSelectionStatus = SEL_DESELECTING;
}
- else if (item && item->getId())
+ else if ((item != nullptr) && (item->getId() != 0))
{
if (index >= 0)
{
@@ -683,16 +683,16 @@ void ItemContainer::mousePressed(MouseEvent &event)
setSelectedIndex(index);
mSelectionStatus = SEL_SELECTING;
- if (itemShortcutWindow)
+ if (itemShortcutWindow != nullptr)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
{
- if (itemShortcut[num])
+ if (itemShortcut[num] != nullptr)
itemShortcut[num]->setItemSelected(item);
}
}
- if (shopWindow)
+ if (shopWindow != nullptr)
shopWindow->setItemSelected(item->getId());
}
}
@@ -712,8 +712,12 @@ void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED)
void ItemContainer::mouseReleased(MouseEvent &event)
{
- if (mClicks == 2 || !inventoryHandler || !tradeHandler)
+ if (mClicks == 2 ||
+ inventoryHandler == nullptr ||
+ tradeHandler == nullptr)
+ {
return;
+ }
switch (mSelectionStatus)
{
@@ -742,7 +746,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
inventoryHandler->moveItem(mSelectedIndex, index);
selectNone();
}
- else if (mInventory)
+ else if (mInventory != nullptr)
{
const DragDropSourceT src = dragDrop.getSource();
DragDropSourceT dst = DragDropSource::Empty;
@@ -809,7 +813,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
return;
- if (inventoryWindow)
+ if (inventoryWindow != nullptr)
inventoryWindow->combineItems(index, mSelectedIndex);
return;
}
@@ -845,7 +849,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
|| dst == DragDropSource::Mail))
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
if (mInventory->addVirtualItem(
@@ -868,7 +872,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
return;
@@ -886,17 +890,17 @@ void ItemContainer::mouseReleased(MouseEvent &event)
Equipm_false,
Equipped_false);
Item *const item2 = mInventory->getItem(index);
- if (item2)
+ if (item2 != nullptr)
item2->setTag(item->getTag());
mInventory->removeItemAt(dragDrop.getTag());
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item, 1);
mInventory->removeItemAt(dragDrop.getTag());
@@ -909,10 +913,10 @@ void ItemContainer::mouseReleased(MouseEvent &event)
dst == DragDropSource::Craft)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
Item *const item = inventory->getItem(dragDrop.getTag());
- if (!item || item->isEquipped() == Equipped_true)
+ if ((item == nullptr) || item->isEquipped() == Equipped_true)
return;
const int slot = getSlotByXY(event.getX(), event.getY());
if (item->getQuantity() > 1
@@ -948,7 +952,7 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const int index = getSlotByXY(event.getX(), event.getY());
if (index == Inventory::NO_SLOT_INDEX)
{
- if (inventory)
+ if (inventory != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -960,11 +964,11 @@ void ItemContainer::mouseReleased(MouseEvent &event)
}
else
{
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(
dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
inventory->virtualRestore(item,
item->getQuantity());
@@ -977,19 +981,19 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (src == DragDropSource::Mail)
{
inventory = PlayerInfo::getInventory();
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
mInventory->removeItemAt(dragDrop.getTag());
}
return;
}
- if (inventory)
+ if (inventory != nullptr)
{
const Item *const item = inventory->getItem(dragDrop.getTag());
- if (item)
+ if (item != nullptr)
{
if (srcContainer != InventoryType::TypeEnd)
{ // inventory <--> storage, cart
@@ -1013,13 +1017,13 @@ void ItemContainer::mouseReleased(MouseEvent &event)
void ItemContainer::mouseMoved(MouseEvent &event)
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
const Item *const item = mInventory->getItem(
getSlotIndex(event.getX(), event.getY()));
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -1057,7 +1061,7 @@ void ItemContainer::widgetMoved(const Event &event A_UNUSED)
void ItemContainer::adjustHeight()
{
- if (!mGridColumns)
+ if (mGridColumns == 0)
return;
mGridRows = (mLastUsedSlot + 1) / mGridColumns;
@@ -1081,7 +1085,7 @@ void ItemContainer::adjustHeight()
void ItemContainer::updateMatrix()
{
- if (!mInventory)
+ if (mInventory == nullptr)
return;
mRedraw = true;
@@ -1100,7 +1104,9 @@ void ItemContainer::updateMatrix()
{
Item *const item = mInventory->getItem(idx);
- if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
+ if (item == nullptr ||
+ item->getId() == 0 ||
+ !item->isHaveTag(mTag))
{
if (mShowEmptyRows == ShowEmptyRows_true)
sortedItems.push_back(new ItemIdPair(idx, nullptr));
@@ -1174,7 +1180,7 @@ void ItemContainer::updateMatrix()
int ItemContainer::getSlotIndex(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1194,7 +1200,7 @@ int ItemContainer::getSlotIndex(int x, int y) const
int ItemContainer::getSlotByXY(int x, int y) const
{
- if (!mShowMatrix)
+ if (mShowMatrix == nullptr)
return Inventory::NO_SLOT_INDEX;
if (x < mDimension.width && y < mDimension.height && x >= 0 && y >= 0)
@@ -1223,7 +1229,7 @@ void ItemContainer::setSortType(const int sortType)
void ItemContainer::setCellBackgroundImage(const std::string &xmlName)
{
- if (mCellBackgroundImg)
+ if (mCellBackgroundImg != nullptr)
mCellBackgroundImg->decRef();
mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, "");
mRedraw = true;
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 2d732ad3c..ba640d374 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -126,7 +126,7 @@ class ItemContainer final : public Widget,
void updateMatrix();
bool getClickCount() const noexcept2 A_WARN_UNUSED
- { return mClicks; }
+ { return mClicks != 0; }
void unsetInventory() noexcept2
{ mInventory = nullptr; }
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index 90a26a4a0..295e41d16 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -95,7 +95,7 @@ void ItemLinkHandler::handleCommandLink(const std::string &link,
void ItemLinkHandler::handleHelpLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->loadHelp(link.substr(7));
helpWindow->requestMoveToTop();
@@ -105,7 +105,7 @@ void ItemLinkHandler::handleHelpLink(const std::string &link)
void ItemLinkHandler::handleHttpLink(const std::string &link,
const MouseEvent *const event)
{
- if (!event)
+ if (event == nullptr)
return;
std::string url = link;
replaceAll(url, " ", "");
@@ -124,14 +124,14 @@ void ItemLinkHandler::handleHttpLink(const std::string &link,
}
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showLinkPopup(url);
}
}
void ItemLinkHandler::handleItemLink(const std::string &link)
{
- if (!itemPopup || link.empty())
+ if ((itemPopup == nullptr) || link.empty())
return;
const char ch = link[0];
@@ -160,7 +160,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
{
itemPopup->setVisible(Visible_false);
}
- else if (viewport)
+ else if (viewport != nullptr)
{
itemPopup->position(viewport->mMouseX,
viewport->mMouseY);
@@ -170,7 +170,7 @@ void ItemLinkHandler::handleItemLink(const std::string &link)
void ItemLinkHandler::handleSearchLink(const std::string &link)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(link.substr(1));
helpWindow->requestMoveToTop();
@@ -205,7 +205,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
}
else if (link == "news")
{
- if (helpWindow)
+ if (helpWindow != nullptr)
helpWindow->loadHelpSimple("news");
}
else if (link == "copyright")
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 424986efe..400ae0d88 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -63,7 +63,7 @@ ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget,
mUnEquipedColor(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED)),
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE))
{
- if (itemShortcut[mNumber])
+ if (itemShortcut[mNumber] != nullptr)
mMaxItems = itemShortcut[mNumber]->getItemCount();
else
mMaxItems = 0;
@@ -88,7 +88,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -96,7 +96,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -105,7 +105,7 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -136,11 +136,11 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -171,17 +171,17 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -195,15 +195,15 @@ void ItemShortcutContainer::draw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -225,7 +225,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
{
BLOCK_START("ItemShortcutContainer::draw")
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -233,7 +233,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (settings.guiAlpha != mAlpha)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
mAlpha = settings.guiAlpha;
}
@@ -242,7 +242,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("ItemShortcutContainer::draw")
return;
@@ -273,11 +273,11 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
if (itemId < SPELL_MIN_ID)
{
const Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -308,17 +308,17 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
}
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{ // this is magic shortcut
const TextCommand *const spell = spellManager
->getSpellByItem(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -332,15 +332,15 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
itemX + 2, itemY + mBoxHeight / 2);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
const SkillInfo *const skill = skillDialog->getSkill(
itemId - SKILL_MIN_ID);
- if (skill)
+ if (skill != nullptr)
{
Image *const image = skill->data->icon;
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -361,7 +361,7 @@ void ItemShortcutContainer::safeDraw(Graphics *const graphics)
void ItemShortcutContainer::mouseDragged(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -383,13 +383,13 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
event.consume();
if (itemId < SPELL_MIN_ID)
{ // items
- if (!PlayerInfo::getInventory())
+ if (PlayerInfo::getInventory() == nullptr)
return;
const Item *const item = PlayerInfo::getInventory()->findItem(
itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragItem(item, DragDropSource::Shortcuts, index);
@@ -401,7 +401,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else if (itemId < SKILL_MIN_ID)
{ // spells/commands
- if (!spellManager)
+ if (spellManager == nullptr)
{
dragDrop.clear();
return;
@@ -409,7 +409,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
const TextCommand *const spell = spellManager->getSpellByItem(
itemId);
- if (spell)
+ if (spell != nullptr)
{
selShortcut->removeItem(index);
dragDrop.dragCommand(spell,
@@ -423,14 +423,14 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
}
else
{ // skills
- if (!skillDialog)
+ if (skillDialog == nullptr)
{
dragDrop.clear();
return;
}
const SkillInfo *const skill
= skillDialog->getSkillByItem(itemId);
- if (skill)
+ if (skill != nullptr)
{
const std::string itemData = selShortcut->getItemData(
index);
@@ -454,7 +454,7 @@ void ItemShortcutContainer::mouseDragged(MouseEvent &event)
void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -466,17 +466,17 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
{
event.consume();
// Stores the selected item if theirs one.
- if (selShortcut->isItemSelected() && inventoryWindow &&
+ if (selShortcut->isItemSelected() && (inventoryWindow != nullptr) &&
(inventoryWindow->isWindowVisible()
|| selShortcut->getSelectedItem() >= SPELL_MIN_ID))
{
selShortcut->setItem(index);
selShortcut->setItemSelected(-1);
- if (spellShortcut)
+ if (spellShortcut != nullptr)
spellShortcut->setItemSelected(-1);
inventoryWindow->unselectItem();
}
- else if (selShortcut->getItem(index))
+ else if (selShortcut->getItem(index) != 0)
{
mItemClicked = true;
}
@@ -484,7 +484,9 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
else if (event.getButton() == MouseButton::RIGHT)
{
event.consume();
- if (popupMenu && selShortcut && viewport)
+ if (popupMenu != nullptr &&
+ selShortcut != nullptr &&
+ viewport != nullptr)
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -497,7 +499,7 @@ void ItemShortcutContainer::mousePressed(MouseEvent &event)
void ItemShortcutContainer::mouseReleased(MouseEvent &event)
{
ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -511,7 +513,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
if (dragDrop.isEmpty())
{
- if (selShortcut->getItem(index) && mItemClicked)
+ if ((selShortcut->getItem(index) != 0) && mItemClicked)
selShortcut->useItem(index);
}
else
@@ -541,7 +543,7 @@ void ItemShortcutContainer::mouseReleased(MouseEvent &event)
void ItemShortcutContainer::mouseMoved(MouseEvent &event)
{
const ItemShortcut *const selShortcut = itemShortcut[mNumber];
- if (!selShortcut)
+ if (selShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -561,11 +563,11 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -575,12 +577,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
itemPopup->setVisible(Visible_false);
}
}
- else if (itemId < SKILL_MIN_ID && spellManager)
+ else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
{
skillPopup->setVisible(Visible_false);
itemPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpellByItem(itemId);
- if (spell && viewport)
+ if ((spell != nullptr) && (viewport != nullptr))
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX,
@@ -591,12 +593,12 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
spellPopup->setVisible(Visible_false);
}
}
- else if (skillDialog)
+ else if (skillDialog != nullptr)
{
itemPopup->setVisible(Visible_false);
spellPopup->setVisible(Visible_false);
const SkillInfo *const skill = skillDialog->getSkillByItem(itemId);
- if (!skill)
+ if (skill == nullptr)
return;
const std::string data = selShortcut->getItemData(index);
@@ -629,18 +631,18 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
// Hide ItemTooltip
void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
- if (skillPopup)
+ if (skillPopup != nullptr)
skillPopup->setVisible(Visible_false);
}
void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 52fdbd716..aeacddbdb 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -106,16 +106,16 @@ Label::Label(const Widget2 *const widget,
Label::~Label()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances --;
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
removeMouseListener(this);
@@ -130,12 +130,12 @@ void Label::init()
mForegroundColor2 = getThemeColor(ThemeColorId::LABEL_OUTLINE);
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("label.xml", "");
}
mInstances ++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getPadding();
else
mPadding = 0;
@@ -179,7 +179,7 @@ void Label::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, textX, textY);
BLOCK_END("Label::draw")
}
@@ -262,14 +262,14 @@ void Label::setCaption(const std::string& caption)
void Label::setParent(Widget *const widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void Label::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/layoutarray.cpp b/src/gui/widgets/layoutarray.cpp
index 7bd6ff34f..de9c8cd30 100644
--- a/src/gui/widgets/layoutarray.cpp
+++ b/src/gui/widgets/layoutarray.cpp
@@ -61,15 +61,15 @@ LayoutCell &LayoutArray::at(const int x, const int y,
{
resizeGrid(x + w, y + h);
LayoutCell *&cell = mCells[CAST_SIZE(y)][static_cast<size_t>(x)];
- if (!cell)
+ if (cell == nullptr)
cell = new LayoutCell;
return *cell;
}
void LayoutArray::resizeGrid(int w, const int h)
{
- const bool extW = w && w > CAST_S32(mSizes[0].size());
- const bool extH = h && h > CAST_S32(mSizes[1].size());
+ const bool extW = (w != 0) && w > CAST_S32(mSizes[0].size());
+ const bool extH = (h != 0) && h > CAST_S32(mSizes[1].size());
if (!extW && !extH)
return;
@@ -132,7 +132,7 @@ LayoutCell &LayoutArray::place(Widget *const widget, const int x,
assert(cell.mType == LayoutCell::NONE);
cell.mType = LayoutCell::WIDGET;
cell.mWidget = widget;
- if (widget)
+ if (widget != nullptr)
{
cell.mSize[0] = w == 1 ? widget->getWidth() : 0;
cell.mSize[1] = h == 1 ? widget->getHeight() : 0;
@@ -166,7 +166,7 @@ void LayoutArray::align(int &restrict pos, int &restrict size, const int dim,
return;
int size_max = sizes[0];
int cnt = cell.mExtent[dim];
- if (sizeCount && cell.mExtent[dim] > sizeCount)
+ if ((sizeCount != 0) && cell.mExtent[dim] > sizeCount)
cnt = sizeCount;
for (int i = 1; i < cnt; ++i)
@@ -208,7 +208,7 @@ std::vector<int> LayoutArray::getSizes(const int dim, int upp) const
{
const LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (!cell || cell->mType == LayoutCell::NONE)
+ if ((cell == nullptr) || cell->mType == LayoutCell::NONE)
continue;
if (cell->mExtent[dim] == 1)
@@ -297,7 +297,7 @@ void LayoutArray::reflow(const int nx, const int ny,
{
LayoutCell *const cell = mCells[CAST_SIZE(gridY)]
[CAST_SIZE(gridX)];
- if (cell && cell->mType != LayoutCell::NONE)
+ if ((cell != nullptr) && cell->mType != LayoutCell::NONE)
{
int dx = x, dy = y, dw = 0, dh = 0;
align(dx, dw, 0, *cell,
diff --git a/src/gui/widgets/layoutcell.cpp b/src/gui/widgets/layoutcell.cpp
index 21efd4818..b898b1dfc 100644
--- a/src/gui/widgets/layoutcell.cpp
+++ b/src/gui/widgets/layoutcell.cpp
@@ -44,7 +44,7 @@ LayoutArray &LayoutCell::getArray()
return tempArray;
if (mType == ARRAY)
{
- if (!mArray)
+ if (mArray == nullptr)
return tempArray;
return *mArray;
}
@@ -90,7 +90,7 @@ void LayoutCell::computeSizes()
while (j != i->end())
{
LayoutCell *const cell = *j;
- if (cell && cell->mType == ARRAY)
+ if ((cell != nullptr) && cell->mType == ARRAY)
cell->computeSizes();
++j;
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 2de26dbab..19114c1ae 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,13 +32,13 @@ LayoutHelper::LayoutHelper(BasicContainer2 *const container) :
mLayout(),
mContainer(container)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->addWidgetListener(this);
}
LayoutHelper::~LayoutHelper()
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->removeWidgetListener(this);
}
@@ -51,7 +51,7 @@ LayoutCell &LayoutHelper::place(const int x, const int y,
Widget *const wg,
const int w, const int h)
{
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->add(wg);
return mLayout.place(wg, x, y, w, h);
}
@@ -64,13 +64,13 @@ ContainerPlacer LayoutHelper::getPlacer(const int x, const int y)
void LayoutHelper::reflowLayout(int w, int h)
{
mLayout.reflow(w, h);
- if (mContainer)
+ if (mContainer != nullptr)
mContainer->setSize(w, h);
}
void LayoutHelper::widgetResized(const Event &event A_UNUSED)
{
- if (!mContainer)
+ if (mContainer == nullptr)
return;
const Rect area = mContainer->getChildrenArea();
int w = area.width;
diff --git a/src/gui/widgets/linepart.cpp b/src/gui/widgets/linepart.cpp
index 0f9403c85..2e1cab392 100644
--- a/src/gui/widgets/linepart.cpp
+++ b/src/gui/widgets/linepart.cpp
@@ -27,7 +27,7 @@
LinePart::~LinePart()
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = nullptr;
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 0095baf1f..9628c2764 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -114,10 +114,10 @@ ListBox::ListBox(const Widget2 *const widget,
mForegroundColor = getThemeColor(ThemeColorId::LISTBOX);
mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE);
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load(skin, "listbox.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mItemPadding = mSkin->getOption("itemPadding");
@@ -135,10 +135,10 @@ void ListBox::postInit()
ListBox::~ListBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
@@ -153,7 +153,7 @@ void ListBox::updateAlpha()
void ListBox::draw(Graphics *const graphics)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
BLOCK_START("ListBox::draw")
@@ -245,9 +245,15 @@ void ListBox::keyPressed(KeyEvent &event)
else if (action == InputAction::GUI_UP)
{
if (mSelected > 0)
+ {
setSelected(mSelected - 1);
- else if (mSelected == 0 && mWrappingEnabled && getListModel())
+ }
+ else if (mSelected == 0 &&
+ mWrappingEnabled &&
+ getListModel() != nullptr)
+ {
setSelected(getListModel()->getNumberOfElements() - 1);
+ }
event.consume();
}
else if (action == InputAction::GUI_DOWN)
@@ -264,7 +270,7 @@ void ListBox::keyPressed(KeyEvent &event)
setSelected(0);
event.consume();
}
- else if (action == InputAction::GUI_END && getListModel())
+ else if (action == InputAction::GUI_END && (getListModel() != nullptr))
{
setSelected(getListModel()->getNumberOfElements() - 1);
event.consume();
@@ -311,7 +317,7 @@ void ListBox::mouseReleased(MouseEvent &event)
mOldSelected = mSelected;
break;
case 2:
- if (gui)
+ if (gui != nullptr)
gui->resetClickCount();
if (mOldSelected == mSelected)
mouseReleased1(event);
@@ -343,13 +349,13 @@ void ListBox::mouseDragged(MouseEvent &event)
return;
// Make list selection update on drag, but guard against negative y
- if (getRowHeight())
+ if (getRowHeight() != 0u)
setSelected(std::max(0, getSelectionByMouse(event.getY())));
}
void ListBox::refocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -359,7 +365,7 @@ void ListBox::refocus()
void ListBox::adjustSize()
{
BLOCK_START("ListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(CAST_S32(getRowHeight()) *
mListModel->getNumberOfElements() + 2 * mPadding);
@@ -383,7 +389,7 @@ int ListBox::getSelectionByMouse(const int y) const
void ListBox::setSelected(const int selected)
{
- if (!mListModel)
+ if (mListModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp
index 7400ffd76..bc2ca4827 100644
--- a/src/gui/widgets/passwordfield.cpp
+++ b/src/gui/widgets/passwordfield.cpp
@@ -29,7 +29,7 @@
PasswordField::PasswordField(const Widget2 *const widget,
const std::string &text) :
TextField(widget, text),
- mPasswordChar(mSkin ? CAST_8(
+ mPasswordChar(mSkin != nullptr ? CAST_8(
mSkin->getOption("passwordChar", 42))
: CAST_8(42))
{
@@ -40,7 +40,7 @@ void PasswordField::draw(Graphics *const graphics)
BLOCK_START("PasswordField::draw")
// std::string uses cow, thus cheap copy
const std::string original = mText;
- if (mPasswordChar)
+ if (mPasswordChar != 0)
mText.assign(mText.length(), mPasswordChar);
else
mText.clear();
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 47221af1f..b6217383f 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -76,7 +76,7 @@ PlayerBox::PlayerBox(Widget2 *const widget,
PlayerBox::~PlayerBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
Theme::unloadRect(mBackground);
@@ -90,13 +90,13 @@ void PlayerBox::init(std::string name, std::string selectedName)
setFrameSize(2);
addMouseListener(this);
- if (theme)
+ if (theme != nullptr)
{
if (name.empty())
name = "playerbox.xml";
mSkin = theme->loadSkinRect(mBackground,
name, "playerbox_background.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
mDrawBackground = (mSkin->getOption("drawbackground") != 0);
mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2);
@@ -120,7 +120,7 @@ void PlayerBox::init(std::string name, std::string selectedName)
void PlayerBox::draw(Graphics *const graphics)
{
BLOCK_START("PlayerBox::draw")
- if (mBeing)
+ if (mBeing != nullptr)
{
const int bs = mFrameSize;
const int x = mDimension.width / 2 + bs + mOffsetX;
@@ -133,7 +133,7 @@ void PlayerBox::draw(Graphics *const graphics)
const float alpha = settings.guiAlpha;
for (int a = 0; a < 9; a++)
{
- if (mBackground.grid[a])
+ if (mBackground.grid[a] != nullptr)
mBackground.grid[a]->setAlpha(alpha);
}
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 978e5b9ca..bf2b2bb83 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -60,17 +60,17 @@ Popup::Popup(const std::string &name,
if (skin.empty())
skin = "popup.xml";
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "popup.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
setPalette(mSkin->getOption("palette"));
}
}
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
// Popups are invisible by default
@@ -83,9 +83,9 @@ Popup::~Popup()
delete2(mVertexes);
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -106,7 +106,7 @@ void Popup::draw(Graphics *const graphics)
{
BLOCK_START("Popup::draw")
- if (mSkin)
+ if (mSkin != nullptr)
{
if (mRedraw)
{
@@ -130,7 +130,7 @@ void Popup::safeDraw(Graphics *const graphics)
{
BLOCK_START("Popup::safeDraw")
- if (mSkin)
+ if (mSkin != nullptr)
{
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
@@ -169,7 +169,7 @@ void Popup::setContentSize(int width, int height)
void Popup::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -187,7 +187,7 @@ void Popup::setLocationRelativeTo(const Widget *const widget)
void Popup::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -200,7 +200,7 @@ void Popup::setMinWidth(const int width)
void Popup::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinHeight = height > mSkin->getMinHeight() ?
height : mSkin->getMinHeight();
@@ -248,7 +248,7 @@ void Popup::position(const int x, const int y)
void Popup::mouseMoved(MouseEvent &event A_UNUSED)
{
- if (popupManager)
+ if (popupManager != nullptr)
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index d623fd811..0260945ce 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -61,7 +61,7 @@ void PopupList::postInit()
Popup::postInit();
add(mScrollArea);
- if (gui)
+ if (gui != nullptr)
gui->addGlobalFocusListener(this);
addKeyListener(mDropDown);
@@ -71,9 +71,9 @@ void PopupList::postInit()
PopupList::~PopupList()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->removeFocusListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeGlobalFocusListener(this);
removeKeyListener(mDropDown);
}
@@ -105,7 +105,7 @@ void PopupList::widgetResized(const Event &event)
void PopupList::setSelected(const int selected)
{
- if (!mListBox)
+ if (mListBox == nullptr)
return;
mListBox->setSelected(selected);
@@ -113,7 +113,7 @@ void PopupList::setSelected(const int selected)
int PopupList::getSelected() const
{
- if (!mListBox)
+ if (mListBox == nullptr)
return -1;
return mListBox->getSelected();
@@ -121,7 +121,7 @@ int PopupList::getSelected() const
void PopupList::setListModel(ListModel *const model)
{
- if (mListBox)
+ if (mListBox != nullptr)
mListBox->setListModel(model);
mListModel = model;
}
@@ -155,7 +155,7 @@ void PopupList::mouseReleased(MouseEvent& event)
mPressedIndex = -2;
if (event.getSource() == mScrollArea)
return;
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -174,7 +174,7 @@ void PopupList::focusGained(const Event& event)
return;
}
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
setVisible(Visible_false);
if (mModal == Modal_true)
@@ -183,6 +183,6 @@ void PopupList::focusGained(const Event& event)
void PopupList::focusLost(const Event& event A_UNUSED)
{
- if (mDropDown)
+ if (mDropDown != nullptr)
mDropDown->updateSelection();
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index e84200973..7299140c6 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -80,10 +80,10 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
addWidgetListener(this);
setSize(width, height);
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "progressbar.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
mFillPadding = mSkin->getOption("fillPadding");
@@ -99,13 +99,13 @@ ProgressBar::ProgressBar(const Widget2 *const widget,
ProgressBar::~ProgressBar()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
@@ -157,7 +157,7 @@ void ProgressBar::updateAlpha()
void ProgressBar::draw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::draw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::draw")
return;
@@ -223,7 +223,7 @@ void ProgressBar::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
@@ -236,7 +236,7 @@ void ProgressBar::draw(Graphics *const graphics)
void ProgressBar::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressBar::safeDraw")
- if (!mSkin)
+ if (mSkin == nullptr)
{
BLOCK_END("ProgressBar::safeDraw")
return;
@@ -294,7 +294,7 @@ void ProgressBar::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
{
const int textX = (mDimension.width - font->getWidth(mText)) / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index 1b2b333e2..abeee678c 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -39,7 +39,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ImageSet *const images = Theme::getImageSetFromTheme(
"progress-indicator.png", 32, 32);
- if (images)
+ if (images != nullptr)
{
Animation *const anim = new Animation("progress indicator");
for (ImageSet::size_type i = 0, fsz = images->size();
@@ -57,7 +57,7 @@ ProgressIndicator::ProgressIndicator(const Widget2 *const widget) :
ProgressIndicator::~ProgressIndicator()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mIndicator);
@@ -66,7 +66,7 @@ ProgressIndicator::~ProgressIndicator()
void ProgressIndicator::logic()
{
BLOCK_START("ProgressIndicator::logic")
- if (mIndicator)
+ if (mIndicator != nullptr)
mIndicator->update(10);
BLOCK_END("ProgressIndicator::logic")
}
@@ -74,7 +74,7 @@ void ProgressIndicator::logic()
void ProgressIndicator::draw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
@@ -87,7 +87,7 @@ void ProgressIndicator::draw(Graphics *const graphics)
void ProgressIndicator::safeDraw(Graphics *const graphics)
{
BLOCK_START("ProgressIndicator::draw")
- if (mIndicator)
+ if (mIndicator != nullptr)
{
// Draw the indicator centered on the widget
const int x = (mDimension.width - 32) / 2;
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 3a781061c..71b7171ae 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -119,7 +119,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
mForegroundColor2 = getThemeColor(ThemeColorId::RADIOBUTTON_OUTLINE);
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("radio.xml", "");
updateAlpha();
@@ -128,7 +128,7 @@ RadioButton::RadioButton(const Widget2 *const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mImagePadding = mSkin->getOption("imagePadding");
@@ -142,19 +142,19 @@ RadioButton::RadioButton(const Widget2 *const widget,
RadioButton::~RadioButton()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
setGroup(std::string());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
@@ -167,13 +167,13 @@ void RadioButton::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- if (mSkin)
+ if (mSkin != nullptr)
{
const ImageRect &rect = mSkin->getBorder();
for (int a = 0; a < 4; a ++)
{
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -182,7 +182,7 @@ void RadioButton::updateAlpha()
void RadioButton::drawBox(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
const ImageRect &rect = mSkin->getBorder();
@@ -217,7 +217,7 @@ void RadioButton::drawBox(Graphics *const graphics)
updateAlpha();
- if (box)
+ if (box != nullptr)
{
graphics->drawImage(box,
mImagePadding,
@@ -244,7 +244,7 @@ void RadioButton::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mTextX, mPadding);
BLOCK_END("RadioButton::draw")
@@ -293,7 +293,7 @@ void RadioButton::setSelected(const bool selected)
iter != iterEnd;
++ iter)
{
- if (iter->second && iter->second->isSelected())
+ if ((iter->second != nullptr) && iter->second->isSelected())
iter->second->setSelected(false);
}
}
@@ -348,7 +348,7 @@ void RadioButton::setCaption(const std::string& caption)
void RadioButton::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
@@ -361,7 +361,7 @@ void RadioButton::widgetHidden(const Event &event A_UNUSED)
void RadioButton::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 4ac8f5dce..630f7e9bf 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -148,7 +148,7 @@ ScrollArea::ScrollArea(Widget2 *const widget2,
ScrollArea::~ScrollArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// Garbage collection
@@ -166,7 +166,7 @@ ScrollArea::~ScrollArea()
{
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (buttons[f][i])
+ if (buttons[f][i] != nullptr)
buttons[f][i]->decRef();
}
}
@@ -201,7 +201,7 @@ void ScrollArea::init(std::string skinName)
// +++ here probably need move background from static
if (skinName.empty())
skinName = "scroll_background.xml";
- if (theme)
+ if (theme != nullptr)
{
theme->loadRect(background, skinName, "scroll_background.xml");
theme->loadRect(vMarker, "scroll.xml", "");
@@ -213,14 +213,14 @@ void ScrollArea::init(std::string skinName)
for (int i = 0; i < 2; i ++)
{
Skin *skin = nullptr;
- if (theme)
+ if (theme != nullptr)
skin = theme->load(buttonFiles[i], "scrollbuttons.xml");
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
for (int f = UP; f < BUTTONS_DIR; f ++)
{
- if (rect.grid[f])
+ if (rect.grid[f] != nullptr)
rect.grid[f]->incRef();
buttons[f][i] = rect.grid[f];
}
@@ -236,7 +236,7 @@ void ScrollArea::init(std::string skinName)
for (int f = UP; f < BUTTONS_DIR; f ++)
buttons[f][i] = nullptr;
}
- if (theme)
+ if (theme != nullptr)
theme->unload(skin);
}
}
@@ -259,7 +259,7 @@ void ScrollArea::logic()
setHorizontalScrollAmount(getHorizontalScrollAmount());
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
unsigned int frameSize = content->getFrameSize();
content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize);
@@ -301,15 +301,15 @@ void ScrollArea::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (background.grid[a])
+ if (background.grid[a] != nullptr)
background.grid[a]->setAlpha(mAlpha);
- if (hBackground.grid[a])
+ if (hBackground.grid[a] != nullptr)
hBackground.grid[a]->setAlpha(mAlpha);
- if (vBackground.grid[a])
+ if (vBackground.grid[a] != nullptr)
vBackground.grid[a]->setAlpha(mAlpha);
- if (vMarker.grid[a])
+ if (vMarker.grid[a] != nullptr)
vMarker.grid[a]->setAlpha(mAlpha);
- if (vMarkerHi.grid[a])
+ if (vMarkerHi.grid[a] != nullptr)
vMarkerHi.grid[a]->setAlpha(mAlpha);
}
}
@@ -512,7 +512,7 @@ void ScrollArea::drawButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, dim.x, dim.y);
}
@@ -522,7 +522,7 @@ void ScrollArea::calcButton(Graphics *const graphics,
Rect dim;
const Image *const image = getImageByState(dim, dir);
- if (image)
+ if (image != nullptr)
{
static_cast<Graphics*>(graphics)->calcTileCollection(
mVertexes, image, dim.x, dim.y);
@@ -533,18 +533,18 @@ void ScrollArea::drawVBar(Graphics *const graphics) const
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->drawPattern(vBackground.grid[4],
dim.x, dim.y, dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->drawPattern(vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->drawPattern(vBackground.grid[7],
dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y,
@@ -556,21 +556,21 @@ void ScrollArea::calcVBar(const Graphics *const graphics)
{
const Rect &dim = getVerticalBarDimension();
- if (vBackground.grid[4])
+ if (vBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (vBackground.grid[1])
+ if (vBackground.grid[1] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[1],
dim.x, dim.y,
dim.width, vBackground.grid[1]->getHeight());
}
- if (vBackground.grid[7])
+ if (vBackground.grid[7] != nullptr)
{
graphics->calcPattern(mVertexes,
vBackground.grid[7],
@@ -583,21 +583,21 @@ void ScrollArea::drawHBar(Graphics *const graphics) const
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->drawPattern(hBackground.grid[4],
dim.x, dim.y,
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->drawPattern(hBackground.grid[3],
dim.x, dim.y,
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->drawPattern(hBackground.grid[5],
dim.x + dim.width - hBackground.grid[5]->getWidth(),
@@ -611,7 +611,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
{
const Rect &dim = getHorizontalBarDimension();
- if (hBackground.grid[4])
+ if (hBackground.grid[4] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[4],
@@ -619,7 +619,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
dim.width, dim.height);
}
- if (hBackground.grid[3])
+ if (hBackground.grid[3] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[3],
@@ -627,7 +627,7 @@ void ScrollArea::calcHBar(const Graphics *const graphics)
hBackground.grid[3]->getWidth(), dim.height);
}
- if (hBackground.grid[5])
+ if (hBackground.grid[5] != nullptr)
{
graphics->calcPattern(mVertexes,
hBackground.grid[5],
@@ -736,7 +736,7 @@ void ScrollArea::widgetResized(const Event &event A_UNUSED)
mRedraw = true;
const unsigned int frameSize = 2 * mFrameSize;
Widget *const content = getContent();
- if (content)
+ if (content != nullptr)
{
content->setSize(mDimension.width - frameSize,
mDimension.height - frameSize);
@@ -834,7 +834,9 @@ void ScrollArea::mousePressed(MouseEvent& event)
void ScrollArea::mouseReleased(MouseEvent& event)
{
- if (event.getButton() == MouseButton::LEFT && mClickX && mClickY)
+ if (event.getButton() == MouseButton::LEFT &&
+ mClickX != 0 &&
+ mClickY != 0)
{
if (!event.isConsumed())
{
@@ -869,7 +871,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
setHorizontalScrollAmount(s);
}
- else if (dy)
+ else if (dy != 0)
{
int s = mVScroll + dy;
if (s < 0)
@@ -887,7 +889,7 @@ void ScrollArea::mouseReleased(MouseEvent& event)
}
mClickX = 0;
mClickY = 0;
- if (mMouseConsume && (dx || dy))
+ if (mMouseConsume && ((dx != 0) || (dy != 0)))
event.consume();
}
}
@@ -1007,17 +1009,17 @@ Rect ScrollArea::getVerticalMarkerDimension()
height = mDimension.height - 2 * h2;
const int maxV = getVerticalMaxScroll();
- if (mMarkerSize && maxV)
+ if ((mMarkerSize != 0) && (maxV != 0))
{
pos = (mVScroll * height / maxV - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int h3 = content->getHeight();
- if (h3)
+ if (h3 != 0)
length = (height * getChildrenArea().height) / h3;
else
length = height;
@@ -1065,17 +1067,17 @@ Rect ScrollArea::getHorizontalMarkerDimension()
width = mDimension.width - w2 - mScrollbarWidth;
const int maxH = getHorizontalMaxScroll();
- if (mMarkerSize && maxH)
+ if ((mMarkerSize != 0) && (maxH != 0))
{
pos = (mHScroll * width / maxH - mMarkerSize / 2);
length = mMarkerSize;
}
else
{
- if (content)
+ if (content != nullptr)
{
const int w3 = content->getWidth();
- if (w3)
+ if (w3 != 0)
length = (width * getChildrenArea().width) / w3;
else
length = width;
@@ -1164,7 +1166,7 @@ Rect ScrollArea::getRightButtonDimension() const
void ScrollArea::setContent(Widget* widget)
{
- if (widget)
+ if (widget != nullptr)
{
clear();
add(widget);
@@ -1242,7 +1244,7 @@ int ScrollArea::getHorizontalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
const int value = content->getWidth() - getChildrenArea().width +
@@ -1259,7 +1261,7 @@ int ScrollArea::getVerticalMaxScroll()
checkPolicies();
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
return 0;
int value;
@@ -1282,7 +1284,7 @@ void ScrollArea::setScrollbarWidth(const int width)
void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area)
{
const Widget *const content = getContent();
- if (widget != content || !content)
+ if (widget != content || (content == nullptr))
return;
BasicContainer::showWidgetPart(widget, area);
@@ -1362,7 +1364,7 @@ void ScrollArea::checkPolicies()
mVBarVisible = false;
const Widget *const content = getContent();
- if (!content)
+ if (content == nullptr)
{
mHBarVisible = (mHPolicy == SHOW_ALWAYS);
mVBarVisible = (mVPolicy == SHOW_ALWAYS);
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index b455597a2..fc7bd9701 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -87,7 +87,7 @@ void SellDialog::postInit()
setMinHeight(220);
setDefaultSize(260, 230, ImagePosition::CENTER);
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->registerWindowForReset(this);
// Create a ShopItems instance, that is aware of duplicate entries.
@@ -205,7 +205,7 @@ SellDialog::~SellDialog()
void SellDialog::reset()
{
mShopItems->clear();
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setValue(0);
mShopItemList->setSelected(-1);
updateButtonsAndLabels();
@@ -213,7 +213,7 @@ void SellDialog::reset()
void SellDialog::addItem(const Item *const item, const int price)
{
- if (!item)
+ if (item == nullptr)
return;
mShopItems->addItem2(item->getInvIndex(),
@@ -263,25 +263,30 @@ void SellDialog::action(const ActionEvent &event)
if (eventId == "slider")
{
- if (mSlider)
+ if (mSlider != nullptr)
{
mAmountItems = CAST_S32(mSlider->getValue());
updateButtonsAndLabels();
}
}
- else if (eventId == "inc" && mSlider && mAmountItems < mMaxItems)
+ else if (eventId == "inc" &&
+ mSlider != nullptr &&
+ mAmountItems < mMaxItems)
{
mAmountItems++;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "dec" && mSlider && mAmountItems > 1)
+ else if (eventId == "dec" &&
+ mSlider != nullptr &&
+ mAmountItems > 1)
{
mAmountItems--;
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "max" && mSlider)
+ else if (eventId == "max" &&
+ mSlider != nullptr)
{
mAmountItems = mMaxItems;
mSlider->setValue(mAmountItems);
@@ -300,7 +305,7 @@ void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
- if (mSlider)
+ if (mSlider != nullptr)
{
mSlider->setValue(0);
mSlider->setScale(1, mMaxItems);
@@ -320,10 +325,10 @@ void SellDialog::updateButtonsAndLabels()
int income = 0;
ShopItem *item = nullptr;
- if (selectedItem > -1 && mShopItems->at(selectedItem))
+ if (selectedItem > -1 && (mShopItems->at(selectedItem) != nullptr))
{
item = mShopItems->at(selectedItem);
- if (item)
+ if (item != nullptr)
{
mMaxItems = item->getQuantity();
if (mAmountItems > mMaxItems)
@@ -344,27 +349,27 @@ void SellDialog::updateButtonsAndLabels()
// Update Buttons and slider
mSellButton->setEnabled(mAmountItems > 0);
- if (mDecreaseButton)
+ if (mDecreaseButton != nullptr)
mDecreaseButton->setEnabled(mAmountItems > 1);
- if (mIncreaseButton)
+ if (mIncreaseButton != nullptr)
mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
- if (mSlider)
+ if (mSlider != nullptr)
mSlider->setEnabled(mMaxItems > 1);
- if (mQuantityLabel)
+ if (mQuantityLabel != nullptr)
{
// Update the quantity and money labels
mQuantityLabel->setCaption(strprintf("%d / %d",
mAmountItems, mMaxItems));
}
- if (mMoneyLabel)
+ if (mMoneyLabel != nullptr)
{
// TRANSLATORS: sell dialog label
mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
UnitsDb::formatCurrency(income).c_str(),
UnitsDb::formatCurrency(mPlayerMoney + income).c_str()));
}
- if (item)
+ if (item != nullptr)
item->update();
}
@@ -374,7 +379,7 @@ void SellDialog::setVisible(Visible visible)
if (visible == Visible_true)
{
- if (mShopItemList)
+ if (mShopItemList != nullptr)
mShopItemList->requestFocus();
}
else
diff --git a/src/gui/widgets/serverslistbox.h b/src/gui/widgets/serverslistbox.h
index fb45dd01a..20d019f8d 100644
--- a/src/gui/widgets/serverslistbox.h
+++ b/src/gui/widgets/serverslistbox.h
@@ -47,7 +47,7 @@ class ServersListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
ServersListModel *const model
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 2ebd2ef19..8d6296d52 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -151,7 +151,7 @@ void SetupItem::save()
std::string SetupItem::getActionEventId() const
{
- if (!mWidget)
+ if (mWidget == nullptr)
return std::string();
return mWidget->getActionEventId();
@@ -159,7 +159,7 @@ std::string SetupItem::getActionEventId() const
void SetupItem::action(const ActionEvent &event)
{
- if (!mWidget)
+ if (mWidget == nullptr)
return;
if (event.getId() == mWidget->getActionEventId())
@@ -194,7 +194,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED)
void SetupItem::fixFirstItemSize(Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const int maxSize = mParent->getPreferredFirstItemSize();
if (widget->getWidth() < maxSize)
@@ -251,7 +251,7 @@ void SetupItemCheckBox::createControls()
void SetupItemCheckBox::fromWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
if (mCheckBox->isSelected())
@@ -262,7 +262,7 @@ void SetupItemCheckBox::fromWidget()
void SetupItemCheckBox::toWidget()
{
- if (!mCheckBox)
+ if (mCheckBox == nullptr)
return;
mCheckBox->setSelected(mValue != "0");
@@ -390,7 +390,7 @@ void SetupItemTextField::createControls()
void SetupItemTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -398,7 +398,7 @@ void SetupItemTextField::fromWidget()
void SetupItemTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -406,11 +406,11 @@ void SetupItemTextField::toWidget()
void SetupItemTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -528,7 +528,7 @@ void SetupItemIntTextField::createControls()
void SetupItemIntTextField::fromWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mValue = mTextField->getText();
@@ -536,7 +536,7 @@ void SetupItemIntTextField::fromWidget()
void SetupItemIntTextField::toWidget()
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
mTextField->setText(mValue);
@@ -544,11 +544,11 @@ void SetupItemIntTextField::toWidget()
void SetupItemIntTextField::action(const ActionEvent &event)
{
- if (!mTextField)
+ if (mTextField == nullptr)
return;
const std::string &eventId = event.getId();
- if (mWidget && eventId == mWidget->getActionEventId())
+ if ((mWidget != nullptr) && eventId == mWidget->getActionEventId())
{
fromWidget();
}
@@ -708,7 +708,7 @@ void SetupItemDropDown::createControls()
void SetupItemDropDown::fromWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mValue = toString(mDropDown->getSelected());
@@ -716,7 +716,7 @@ void SetupItemDropDown::fromWidget()
void SetupItemDropDown::toWidget()
{
- if (!mDropDown)
+ if (mDropDown == nullptr)
return;
mDropDown->setSelected(atoi(mValue.c_str()));
@@ -810,7 +810,7 @@ void SetupItemSlider::createControls()
void SetupItemSlider::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getValue());
@@ -818,7 +818,7 @@ void SetupItemSlider::fromWidget()
void SetupItemSlider::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setValue(atof(mValue.c_str()));
@@ -945,7 +945,7 @@ void SetupItemSlider2::createControls()
int SetupItemSlider2::getMaxWidth()
{
- if (!mValues || !gui)
+ if ((mValues == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
@@ -966,7 +966,7 @@ int SetupItemSlider2::getMaxWidth()
void SetupItemSlider2::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(mSlider->getValue());
@@ -977,7 +977,7 @@ void SetupItemSlider2::fromWidget()
void SetupItemSlider2::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
int val = roundDouble(atof(mValue.c_str()));
@@ -1107,7 +1107,7 @@ void SetupItemSliderList::createControls()
void SetupItemSliderList::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = mSlider->getSelectedString();
@@ -1115,7 +1115,7 @@ void SetupItemSliderList::fromWidget()
void SetupItemSliderList::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelectedString(mValue);
@@ -1157,7 +1157,7 @@ void SetupItemSound::addMoreControls()
{
mButton = new Button(this, BUTTON_PLAY, 16, 16,
mEventName + "_PLAY", this);
- if (mHorizont)
+ if (mHorizont != nullptr)
mHorizont->add(mButton);
}
@@ -1165,7 +1165,7 @@ void SetupItemSound::action(const ActionEvent &event)
{
if (event.getId() == mEventName + "_PLAY")
{
- if (mSlider && mSlider->getSelected())
+ if ((mSlider != nullptr) && (mSlider->getSelected() != 0))
{
soundManager.playGuiSfx(pathJoin(branding.getStringValue(
"systemsounds"),
@@ -1202,7 +1202,7 @@ void SetupItemSliderInt::addMoreControls()
void SetupItemSliderInt::fromWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mValue = toString(mSlider->getSelected() + mMin);
@@ -1210,7 +1210,7 @@ void SetupItemSliderInt::fromWidget()
void SetupItemSliderInt::toWidget()
{
- if (!mSlider)
+ if (mSlider == nullptr)
return;
mSlider->setSelected(atoi(mValue.c_str()) - mMin);
diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp
index 8dbaf550f..122853c7e 100644
--- a/src/gui/widgets/setuptouchitem.cpp
+++ b/src/gui/widgets/setuptouchitem.cpp
@@ -87,7 +87,7 @@ SetupActionDropDown::~SetupActionDropDown()
void SetupActionDropDown::createControls()
{
- if (!mModel)
+ if (mModel == nullptr)
return;
load();
@@ -115,7 +115,7 @@ void SetupActionDropDown::createControls()
void SetupActionDropDown::fromWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mValue = toString(CAST_S32(mModel->getActionFromSelection(
@@ -124,7 +124,7 @@ void SetupActionDropDown::fromWidget()
void SetupActionDropDown::toWidget()
{
- if (!mDropDown || !mModel)
+ if ((mDropDown == nullptr) || (mModel == nullptr))
return;
mDropDown->setSelected(mModel->getSelectionFromAction(
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index f1e5ed32f..3df46b854 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -91,7 +91,7 @@ void ShopListBox::setPlayersMoney(const int money)
void ShopListBox::draw(Graphics *const graphics)
{
BLOCK_START("ShopListBox::draw")
- if (!mListModel || !mShopItems)
+ if ((mListModel == nullptr) || (mShopItems == nullptr))
{
BLOCK_END("ShopListBox::draw")
return;
@@ -116,7 +116,7 @@ void ShopListBox::draw(Graphics *const graphics)
Color* backgroundColor = &mBackgroundColor;
ShopItem *const item = mShopItems->at(i);
- if (item &&
+ if ((item != nullptr) &&
(item->getDisabled() ||
(mPlayerMoney < item->getPrice() && mPriceCheck) ||
(mProtectItems && PlayerInfo::isItemProtected(item->getId()))))
@@ -155,10 +155,10 @@ void ShopListBox::draw(Graphics *const graphics)
width, mRowHeight));
}
- if (mShopItems && item)
+ if ((mShopItems != nullptr) && (item != nullptr))
{
Image *const icon = item->getImage();
- if (icon)
+ if (icon != nullptr)
{
icon->setAlpha(1.0F);
graphics->drawImage(icon, mPadding, y + mPadding);
@@ -194,7 +194,7 @@ void ShopListBox::safeDraw(Graphics *const graphics)
void ShopListBox::adjustSize()
{
BLOCK_START("ShopListBox::adjustSize")
- if (mListModel)
+ if (mListModel != nullptr)
{
setHeight(mRowHeight * mListModel->getNumberOfElements()
+ 2 * mPadding);
@@ -209,10 +209,10 @@ void ShopListBox::setPriceCheck(const bool check)
void ShopListBox::mouseMoved(MouseEvent &event)
{
- if (!itemPopup || !mRowHeight)
+ if ((itemPopup == nullptr) || (mRowHeight == 0u))
return;
- if (!mShopItems)
+ if (mShopItems == nullptr)
{
itemPopup->hide();
return;
@@ -227,7 +227,7 @@ void ShopListBox::mouseMoved(MouseEvent &event)
else
{
const Item *const item = mShopItems->at(index);
- if (item)
+ if (item != nullptr)
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -265,7 +265,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
inventory = PlayerInfo::getCartInventory();
else
return;
- if (!inventory)
+ if (inventory == nullptr)
return;
Item *const item = inventory->getItem(dragDrop.getTag());
if (mType == ShopListBoxType::BuyShop)
@@ -292,7 +292,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
return;
Item *const item = mShopItems->at(mSelected);
- if (popupMenu && viewport)
+ if ((popupMenu != nullptr) && (viewport != nullptr))
{
popupMenu->showItemPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -303,7 +303,7 @@ void ShopListBox::mouseReleased(MouseEvent& event)
void ShopListBox::mouseExited(MouseEvent& event A_UNUSED)
{
- if (!itemPopup)
+ if (itemPopup == nullptr)
return;
itemPopup->hide();
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index e9611b69f..a2b90514d 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -61,7 +61,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml", "background.xml");
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->setAlpha(settings.guiAlpha);
mBoxHeight = mBackgroundImg->getHeight();
@@ -76,13 +76,13 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) :
ShortcutContainer::~ShortcutContainer()
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
mBackgroundImg->decRef();
mBackgroundImg = nullptr;
}
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -123,7 +123,7 @@ int ShortcutContainer::getIndexFromGrid(const int pointX,
void ShortcutContainer::drawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
if (mRedraw)
{
@@ -143,7 +143,7 @@ void ShortcutContainer::drawBackground(Graphics *const g)
void ShortcutContainer::safeDrawBackground(Graphics *const g)
{
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
{
for (unsigned i = 0; i < mMaxItems; i ++)
{
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 2bada3a13..93c702381 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -58,8 +58,9 @@ class SkillListBox final : public ListBox
mTextColor(getThemeColor(ThemeColorId::TEXT)),
mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE)),
mCooldownColor(getThemeColor(ThemeColorId::SKILL_COOLDOWN)),
- mTextPadding(mSkin ? mSkin->getOption("textPadding", 34) : 34),
- mSpacing(mSkin ? mSkin->getOption("spacing", 0) : 0),
+ mTextPadding(mSkin != nullptr ?
+ mSkin->getOption("textPadding", 34) : 34),
+ mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 0) : 0),
mSkillClicked(false)
{
mRowHeight = getFont()->getHeight() * 2 + mSpacing + 2 * mPadding;
@@ -79,7 +80,7 @@ class SkillListBox final : public ListBox
SkillInfo *getSelectedInfo() const
{
const int selected = getSelected();
- if (!mListModel || selected < 0
+ if ((mListModel == nullptr) || selected < 0
|| selected > mListModel->getNumberOfElements())
{
return nullptr;
@@ -90,7 +91,7 @@ class SkillListBox final : public ListBox
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
SkillModel *const model = static_cast<SkillModel*>(mListModel);
@@ -121,9 +122,9 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
- if (e->cooldown)
+ if (e->cooldown != 0)
{
graphics->fillRectangle(Rect(mPadding, y,
usableWidth * 100 / e->cooldown, 10));
@@ -136,7 +137,7 @@ class SkillListBox final : public ListBox
++i, y += getRowHeight())
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
const SkillData *const data = e->data;
const std::string &description = data->description;
@@ -183,10 +184,10 @@ class SkillListBox final : public ListBox
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
const int y = (event.getY() + mPadding) / getRowHeight();
- if (!mModel || y >= mModel->getNumberOfElements())
+ if (mModel == nullptr || y >= mModel->getNumberOfElements())
return nullptr;
const SkillInfo *const skill = mModel->getSkillAt(y);
- if (!skill)
+ if (skill == nullptr)
return nullptr;
return skill;
}
@@ -194,11 +195,11 @@ class SkillListBox final : public ListBox
void mouseMoved(MouseEvent &event) override final
{
ListBox::mouseMoved(event);
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -219,7 +220,7 @@ class SkillListBox final : public ListBox
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -245,13 +246,13 @@ class SkillListBox final : public ListBox
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = static_cast<SkillModel*>(
mListModel);
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h
index dc5c664d8..88698de1c 100644
--- a/src/gui/widgets/skillrectanglelistbox.h
+++ b/src/gui/widgets/skillrectanglelistbox.h
@@ -73,13 +73,13 @@ class SkillRectangleListBox final : public Widget,
mTextYOffset(44),
mSkillClicked(false)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load("skillrectanglelistbox.xml",
"listbox.xml");
}
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mBoxWidth = mSkin->getOption("boxWidth", 80);
@@ -103,7 +103,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -127,7 +127,7 @@ class SkillRectangleListBox final : public Widget,
SkillInfo *getSelectedInfo() const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int selected = mSelected;
if (selected < 0 ||
@@ -141,7 +141,7 @@ class SkillRectangleListBox final : public Widget,
void draw(Graphics *const graphics) override final A_NONNULL(2)
{
- if (!mModel)
+ if (mModel == nullptr)
return;
SkillModel *const model = mModel;
@@ -155,7 +155,7 @@ class SkillRectangleListBox final : public Widget,
if (mSelected >= 0)
{
SkillInfo *const e = model->getSkillAt(mSelected);
- if (e)
+ if (e != nullptr)
{
const int x = e->x * mBoxWidth + mPadding;
const int y = e->y * mBoxHeight + mPadding;
@@ -180,7 +180,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = model->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (e->x > maxX)
maxX = e->x;
@@ -235,7 +235,7 @@ class SkillRectangleListBox final : public Widget,
const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return nullptr;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -244,7 +244,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return e;
@@ -255,7 +255,7 @@ class SkillRectangleListBox final : public Widget,
int getSelectionByEvent(const MouseEvent &event) const
{
- if (!mModel)
+ if (mModel == nullptr)
return -1;
const int posX = (event.getX() - mPadding) / mBoxWidth;
const int posY = (event.getY() - mPadding) / mBoxHeight;
@@ -264,7 +264,7 @@ class SkillRectangleListBox final : public Widget,
++i)
{
SkillInfo *const e = mModel->getSkillAt(i);
- if (e)
+ if (e != nullptr)
{
if (posX == e->x && posY == e->y)
return i;
@@ -275,11 +275,11 @@ class SkillRectangleListBox final : public Widget,
void mouseMoved(MouseEvent &event) override final
{
- if (!viewport || !dragDrop.isEmpty())
+ if ((viewport == nullptr) || !dragDrop.isEmpty())
return;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
skillPopup->show(skill,
skill->customSelectedLevel,
@@ -302,7 +302,7 @@ class SkillRectangleListBox final : public Widget,
{
mSkillClicked = false;
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
@@ -321,12 +321,12 @@ class SkillRectangleListBox final : public Widget,
button == MouseButton::RIGHT)
{
const SkillInfo *const skill = getSkillByEvent(event);
- if (!skill)
+ if (skill == nullptr)
return;
event.consume();
mSkillClicked = true;
SkillModel *const model = mModel;
- if (model &&
+ if ((model != nullptr) &&
mSelected >= 0 &&
model->getSkillAt(mSelected) == skill)
{
@@ -381,7 +381,7 @@ class SkillRectangleListBox final : public Widget,
void setSelected(const int selected)
{
- if (!mModel)
+ if (mModel == nullptr)
{
mSelected = -1;
}
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 2c5ac7c20..0d25ad2c5 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -132,7 +132,7 @@ Slider::Slider(Widget2 *const widget,
Slider::~Slider()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
delete2(mVertexes);
@@ -158,7 +158,7 @@ void Slider::init()
// Load resources
if (mInstances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < 2; mode ++)
theme->loadRect(buttons[mode], data[mode], "slider.xml", 0, 8);
@@ -168,7 +168,7 @@ void Slider::init()
mInstances++;
- if (buttons[0].grid[SliderGrid::HGRIP])
+ if (buttons[0].grid[SliderGrid::HGRIP] != nullptr)
setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth());
}
@@ -184,7 +184,7 @@ void Slider::updateAlpha()
{
for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++)
{
- if (buttons[f].grid[d])
+ if (buttons[f].grid[d] != nullptr)
buttons[f].grid[d]->setAlpha(mAlpha);
}
}
@@ -194,9 +194,9 @@ void Slider::updateAlpha()
void Slider::draw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -225,7 +225,7 @@ void Slider::draw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -240,7 +240,7 @@ void Slider::draw(Graphics *const graphics)
x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -256,11 +256,11 @@ void Slider::draw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->calcPattern(mVertexes,
@@ -270,14 +270,14 @@ void Slider::draw(Graphics *const graphics)
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
{
graphics->calcTileCollection(mVertexes,
buttons[1].grid[SliderGrid::HEND], x, y);
}
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->calcTileCollection(mVertexes,
img,
@@ -295,9 +295,9 @@ void Slider::draw(Graphics *const graphics)
void Slider::safeDraw(Graphics *const graphics)
{
BLOCK_START("Slider::draw")
- if (!buttons[0].grid[SliderGrid::HSTART] ||
- !buttons[1].grid[SliderGrid::HSTART] ||
- !buttons[0].grid[SliderGrid::HEND])
+ if ((buttons[0].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[1].grid[SliderGrid::HSTART] == nullptr) ||
+ (buttons[0].grid[SliderGrid::HEND] == nullptr))
{
BLOCK_END("Slider::draw")
return;
@@ -319,7 +319,7 @@ void Slider::safeDraw(Graphics *const graphics)
w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[0].grid[SliderGrid::HMID])
+ if (buttons[0].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[0].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
@@ -329,7 +329,7 @@ void Slider::safeDraw(Graphics *const graphics)
graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[0].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
@@ -341,22 +341,22 @@ void Slider::safeDraw(Graphics *const graphics)
const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth();
w -= width;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
w -= buttons[1].grid[SliderGrid::HEND]->getWidth();
x += width;
- if (buttons[1].grid[SliderGrid::HMID])
+ if (buttons[1].grid[SliderGrid::HMID] != nullptr)
{
const Image *const hMid = buttons[1].grid[SliderGrid::HMID];
graphics->drawPattern(hMid, x, y, w, hMid->getHeight());
}
x += w;
- if (buttons[1].grid[SliderGrid::HEND])
+ if (buttons[1].grid[SliderGrid::HEND] != nullptr)
graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y);
const Image *const img = buttons[1].grid[SliderGrid::HGRIP];
- if (img)
+ if (img != nullptr)
{
graphics->drawImage(img, getMarkerPosition(),
(mDimension.height - img->getHeight()) / 2);
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 3b42b43e5..edce0cf02 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -68,7 +68,7 @@ void SliderList::postInit2(ActionListener *const listener,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
updateLabel();
@@ -135,7 +135,7 @@ void SliderList::safeDraw(Graphics *const graphics)
void SliderList::updateLabel()
{
- if (!mListModel || mSelectedIndex < 0
+ if ((mListModel == nullptr) || mSelectedIndex < 0
|| mSelectedIndex >= mListModel->getNumberOfElements())
{
return;
@@ -157,7 +157,7 @@ void SliderList::updateLabel()
void SliderList::action(const ActionEvent &event)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
const std::string &eventId = event.getId();
@@ -179,7 +179,7 @@ void SliderList::action(const ActionEvent &event)
void SliderList::setSelectedString(const std::string &str)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
for (int f = 0; f < mListModel->getNumberOfElements(); f ++)
@@ -194,7 +194,7 @@ void SliderList::setSelectedString(const std::string &str)
std::string SliderList::getSelectedString() const
{
- if (!mListModel)
+ if (mListModel == nullptr)
return std::string();
return mListModel->getElementAt(mSelectedIndex);
@@ -202,7 +202,7 @@ std::string SliderList::getSelectedString() const
void SliderList::setSelected(const int idx)
{
- if (!mListModel)
+ if (mListModel == nullptr)
return;
mSelectedIndex = idx;
@@ -222,7 +222,7 @@ void SliderList::adjustSize()
int SliderList::getMaxLabelWidth() const
{
- if (!mListModel || !gui)
+ if ((mListModel == nullptr) || (gui == nullptr))
return 1;
int maxWidth = 0;
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 2b365c52d..6cc4def09 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -46,7 +46,7 @@ SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget,
mNumber(number),
mSpellClicked(false)
{
- if (spellShortcut)
+ if (spellShortcut != nullptr)
mMaxItems = spellShortcut->getSpellsCount();
else
mMaxItems = 0;
@@ -65,14 +65,14 @@ void SpellShortcutContainer::setWidget2(const Widget2 *const widget)
void SpellShortcutContainer::draw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -95,17 +95,17 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -125,14 +125,14 @@ void SpellShortcutContainer::draw(Graphics *const graphics)
void SpellShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!spellShortcut)
+ if (spellShortcut == nullptr)
return;
BLOCK_START("SpellShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
@@ -155,17 +155,17 @@ void SpellShortcutContainer::safeDraw(Graphics *const graphics)
mBoxWidth - 1, mBoxHeight - 1));
}
- if (!spellManager)
+ if (spellManager == nullptr)
continue;
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
if (!spell->isEmpty())
{
Image *const image = spell->getImage();
- if (image)
+ if (image != nullptr)
{
image->setAlpha(1.0F);
graphics->drawImage(image, itemX, itemY);
@@ -200,7 +200,7 @@ void SpellShortcutContainer::mouseDragged(MouseEvent &event)
return;
event.consume();
TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell)
+ if (spell != nullptr)
{
dragDrop.dragCommand(spell, DragDropSource::Spells, index);
dragDrop.setItem(spell->getId() + SPELL_MIN_ID);
@@ -234,7 +234,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
event.consume();
@@ -245,7 +245,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!spellShortcut || !spellManager)
+ if ((spellShortcut == nullptr) || (spellManager == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -287,11 +287,11 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const TextCommand *const
spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(
spell->getId() + SPELL_MIN_ID);
@@ -303,7 +303,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
{
const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < CAST_S32(SHORTCUT_TABS)
- && itemShortcut[num])
+ && (itemShortcut[num] != nullptr))
{
itemShortcut[num]->setItemSelected(-1);
}
@@ -317,7 +317,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
if (itemId >= 0)
spell = spellManager->getSpell(itemId);
- if (spell && popupMenu)
+ if ((spell != nullptr) && (popupMenu != nullptr))
{
popupMenu->showSpellPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -329,8 +329,12 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void SpellShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!spellPopup || !spellShortcut || !spellManager)
+ if (spellPopup == nullptr ||
+ spellShortcut == nullptr ||
+ spellManager == nullptr)
+ {
return;
+ }
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -340,7 +344,7 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
const int itemId = getItemByIndex(index);
spellPopup->setVisible(Visible_false);
const TextCommand *const spell = spellManager->getSpell(itemId);
- if (spell && !spell->isEmpty())
+ if ((spell != nullptr) && !spell->isEmpty())
{
spellPopup->setItem(spell);
spellPopup->view(viewport->mMouseX, viewport->mMouseY);
@@ -353,13 +357,13 @@ void SpellShortcutContainer::mouseMoved(MouseEvent &event)
void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (spellPopup)
+ if (spellPopup != nullptr)
spellPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/statspage.cpp b/src/gui/widgets/statspage.cpp
index db46931eb..eca98b1c4 100644
--- a/src/gui/widgets/statspage.cpp
+++ b/src/gui/widgets/statspage.cpp
@@ -72,7 +72,7 @@ void StatsPage::attributeChanged(const AttributesT id,
const int newVal A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -81,6 +81,6 @@ void StatsPage::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
diff --git a/src/gui/widgets/statspagebasic.cpp b/src/gui/widgets/statspagebasic.cpp
index 23fd22243..bdf90e14f 100644
--- a/src/gui/widgets/statspagebasic.cpp
+++ b/src/gui/widgets/statspagebasic.cpp
@@ -83,7 +83,7 @@ void StatsPageBasic::statChanged(const AttributesT id,
const int oldVal2 A_UNUSED)
{
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -105,7 +105,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -115,7 +115,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
- if (it->second)
+ if (it->second != nullptr)
it->second->update();
}
return;
@@ -125,7 +125,7 @@ void StatsPageBasic::attributeChanged(const AttributesT id,
}
PRAGMA45(GCC diagnostic pop)
const Attrs::const_iterator it = mAttrs.find(id);
- if (it != mAttrs.end() && it->second)
+ if (it != mAttrs.end() && (it->second != nullptr))
it->second->update();
}
@@ -137,7 +137,7 @@ void StatsPageBasic::setPointsNeeded(const AttributesT id,
if (it != mAttrs.end())
{
AttrDisplay *const disp = it->second;
- if (disp && disp->getType() == AttrDisplay::CHANGEABLE)
+ if ((disp != nullptr) && disp->getType() == AttrDisplay::CHANGEABLE)
static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed);
}
}
@@ -151,7 +151,7 @@ std::string StatsPageBasic::getStatsStr() const
{
const ChangeDisplay *const attr = dynamic_cast<ChangeDisplay*>(
(*it).second);
- if (attr)
+ if (attr != nullptr)
{
str.append(strprintf("%s:%s ", attr->getShortName().c_str(),
attr->getValue().c_str()));
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 6df39dfe6..95ea305d6 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -120,7 +120,7 @@ void TabbedArea::postInit()
TabbedArea::~TabbedArea()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
// +++ virtual method calls
@@ -141,16 +141,16 @@ void TabbedArea::enableScrollButtons(const bool enable)
{
if (mEnableScrollButtons && !enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
remove(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
remove(mArrowButton[1]);
}
else if (!mEnableScrollButtons && enable)
{
- if (mArrowButton[0])
+ if (mArrowButton[0] != nullptr)
add(mArrowButton[0]);
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
add(mArrowButton[1]);
}
mEnableScrollButtons = enable;
@@ -220,7 +220,7 @@ Widget *TabbedArea::getCurrentWidget() const
{
const Tab *const tab = getSelectedTab();
- if (tab)
+ if (tab != nullptr)
return getWidget(tab->getCaption());
else
return nullptr;
@@ -229,7 +229,7 @@ Widget *TabbedArea::getCurrentWidget() const
void TabbedArea::addTab(Tab *const tab,
Widget *const widget)
{
- if (!tab || !widget)
+ if ((tab == nullptr) || (widget == nullptr))
return;
tab->setTabbedArea(this);
@@ -238,7 +238,7 @@ void TabbedArea::addTab(Tab *const tab,
mTabContainer->add(tab);
mTabs.push_back(std::pair<Tab*, Widget*>(tab, widget));
- if (!mSelectedTab && tab->mVisible == Visible_true)
+ if ((mSelectedTab == nullptr) && tab->mVisible == Visible_true)
setSelectedTab(tab);
adjustTabPositions();
@@ -255,7 +255,7 @@ void TabbedArea::addTab(Tab *const tab,
void TabbedArea::adjustWidget(Widget *const widget) const
{
- if (!widget)
+ if (widget == nullptr)
return;
const int frameSize = 2 * mFrameSize;
widget->setSize(getWidth() - frameSize,
@@ -386,7 +386,7 @@ void TabbedArea::mousePressed(MouseEvent &event)
event.getX(), event.getY());
Tab *const tab = dynamic_cast<Tab *>(widget);
- if (tab)
+ if (tab != nullptr)
{
event.consume();
setSelectedTab(tab);
@@ -414,7 +414,7 @@ void TabbedArea::setSelectedTab(Tab *const tab)
Tab *const newTab = tab;
- if (newTab)
+ if (newTab != nullptr)
newTab->setCurrent();
widgetResized(Event(nullptr));
@@ -428,7 +428,7 @@ void TabbedArea::setSelectedTabDefault()
for (size_t i = 0; i < mTabs.size(); i++)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
setSelectedTab(tab);
return;
@@ -454,7 +454,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name)
{
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
- if ((*itr).first && (*itr).first->getCaption() == name)
+ if (((*itr).first != nullptr) && (*itr).first->getCaption() == name)
{
setSelectedTab((*itr).first);
return;
@@ -476,7 +476,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
Widget *const w = getCurrentWidget();
ScrollArea *const scr = dynamic_cast<ScrollArea *>(w);
- if (scr)
+ if (scr != nullptr)
{
if (mFollowDownScroll && height != 0)
{
@@ -492,14 +492,14 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
+ rect.height - height;
w->setSize(mWidgetContainer->getWidth() - frameSize,
mWidgetContainer->getHeight() - frameSize);
- if (newScroll)
+ if (newScroll != 0)
scr->setVerticalScrollAmount(newScroll);
}
}
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Check whether there is room to show more tabs now.
int innerWidth = w1 - 4 - mArrowButton[0]->getWidth()
@@ -508,10 +508,10 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
innerWidth = 0;
int newWidth = mVisibleTabsWidth;
- while (mTabScrollIndex && newWidth < innerWidth)
+ while ((mTabScrollIndex != 0u) && newWidth < innerWidth)
{
Tab *const tab = mTabs[mTabScrollIndex - 1].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
newWidth += tab->getWidth();
if (newWidth < innerWidth)
@@ -519,7 +519,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED)
}
}
- if (mArrowButton[1])
+ if (mArrowButton[1] != nullptr)
{
// Move the right arrow to fit the windows content.
newWidth = width - mArrowButton[1]->getWidth() - mRightMargin;
@@ -539,7 +539,7 @@ void TabbedArea::updateTabsWidth()
FOR_EACH (TabContainer::const_iterator, itr, mTabs)
{
Tab *const tab = (*itr).first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mTabsWidth += tab->getWidth();
}
updateVisibleTabsWidth();
@@ -551,7 +551,7 @@ void TabbedArea::updateVisibleTabsWidth()
for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
mVisibleTabsWidth += CAST_S32(tab->getWidth());
}
}
@@ -574,7 +574,7 @@ void TabbedArea::adjustSize()
mWidgetContainer->setPosition(0, maxTabHeight);
mWidgetContainer->setSize(width, height - maxTabHeight);
Widget *const w = getCurrentWidget();
- if (w)
+ if (w != nullptr)
{
const int wFrameSize = w->getFrameSize();
const int frame2 = 2 * wFrameSize;
@@ -600,7 +600,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = 0; i < sz; ++i)
{
const Tab *const tab = mTabs[i].first;
- if (tab &&
+ if ((tab != nullptr) &&
tab->mVisible == Visible_true &&
tab->getHeight() > maxTabHeight)
{
@@ -613,7 +613,7 @@ void TabbedArea::adjustTabPositions()
for (size_t i = mTabScrollIndex; i < sz; ++i)
{
Tab *const tab = mTabs[i].first;
- if (!tab || tab->mVisible == Visible_false)
+ if ((tab == nullptr) || tab->mVisible == Visible_false)
continue;
tab->setPosition(x, maxTabHeight - tab->getHeight());
x += tab->getWidth();
@@ -626,7 +626,7 @@ void TabbedArea::adjustTabPositions()
for (unsigned i = 0; i < mTabScrollIndex; ++i)
{
Tab *const tab = mTabs[i].first;
- if (tab && tab->mVisible == Visible_true)
+ if ((tab != nullptr) && tab->mVisible == Visible_true)
{
x -= tab->getWidth();
tab->setPosition(x, maxTabHeight - tab->getHeight());
@@ -640,7 +640,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
Widget *const source = actionEvent.getSource();
Tab *const tab = dynamic_cast<Tab *>(source);
- if (tab)
+ if (tab != nullptr)
{
setSelectedTab(tab);
}
@@ -649,7 +649,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
const std::string &eventId = actionEvent.getId();
if (eventId == "shift_left")
{
- if (mTabScrollIndex)
+ if (mTabScrollIndex != 0u)
--mTabScrollIndex;
}
else if (eventId == "shift_right")
@@ -665,7 +665,7 @@ void TabbedArea::action(const ActionEvent& actionEvent)
void TabbedArea::updateArrowEnableState()
{
updateTabsWidth();
- if (!mArrowButton[0] || !mArrowButton[1])
+ if ((mArrowButton[0] == nullptr) || (mArrowButton[1] == nullptr))
return;
const int width = mDimension.width;
@@ -684,7 +684,7 @@ void TabbedArea::updateArrowEnableState()
}
// Left arrow consistency check
- if (!mTabScrollIndex)
+ if (mTabScrollIndex == 0u)
mArrowButton[0]->setEnabled(false);
else
mArrowButton[0]->setEnabled(true);
@@ -801,7 +801,7 @@ void TabbedArea::death(const Event &event)
{
Tab *const tab = dynamic_cast<Tab*>(event.getSource());
- if (tab)
+ if (tab != nullptr)
removeTab(tab);
else
BasicContainer::death(event);
diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp
index d67de5287..37e6237a0 100644
--- a/src/gui/widgets/tabs/chat/channeltab.cpp
+++ b/src/gui/widgets/tabs/chat/channeltab.cpp
@@ -39,7 +39,7 @@ ChannelTab::ChannelTab(const Widget2 *const widget,
ChannelTab::~ChannelTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeChannel(mChannelName);
}
@@ -55,11 +55,11 @@ bool ChannelTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index e59d11eb4..fc2f09350 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -84,7 +84,7 @@ ChatTab::ChatTab(const Widget2 *const widget,
mTextOutput->setOpaque(Opaque_false);
mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
- if (chatWindow)
+ if (chatWindow != nullptr)
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
@@ -92,13 +92,13 @@ ChatTab::ChatTab(const Widget2 *const widget,
ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->addTab(this);
}
ChatTab::~ChatTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeTab(this);
delete2(mTextOutput);
@@ -225,7 +225,7 @@ void ChatTab::chatLog(std::string line,
// if configured, move magic messages log to debug chat tab
if (Net::getNetworkType() == ServerType::TMWATHENA
- && localChatTab && this == localChatTab
+ && (localChatTab != nullptr) && this == localChatTab
&& ((config.getBoolValue("showMagicInDebug")
&& own == ChatMsgType::BY_PLAYER
&& tmp.text.length() > 1
@@ -235,7 +235,7 @@ void ChatTab::chatLog(std::string line,
&& (own == ChatMsgType::BY_SERVER
|| tmp.nick.empty()))))
{
- if (debugChatTab)
+ if (debugChatTab != nullptr)
debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors);
return;
}
@@ -247,7 +247,7 @@ void ChatTab::chatLog(std::string line,
if (config.getBoolValue("useLocalTime"))
{
const tm *const timeInfo = localtime(&t);
- if (timeInfo)
+ if (timeInfo != nullptr)
{
line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(),
timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(),
@@ -292,7 +292,7 @@ void ChatTab::chatLog(std::string line,
addRow(line);
}
- if (chatWindow && this == localChatTab)
+ if ((chatWindow != nullptr) && this == localChatTab)
chatWindow->addToAwayLog(line);
mScrollArea->logic();
@@ -307,7 +307,7 @@ void ChatTab::chatLog(std::string line,
}
const TabbedArea *const tabArea = getTabbedArea();
- if (!tabArea)
+ if (tabArea == nullptr)
return;
const bool notFocused = WindowManager::getIsMinimized() ||
@@ -317,7 +317,8 @@ void ChatTab::chatLog(std::string line,
{
if (getFlash() == 0)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
{
setFlash(2);
soundManager.playGuiSound(SOUND_HIGHLIGHT);
@@ -329,8 +330,11 @@ void ChatTab::chatLog(std::string line,
}
else if (getFlash() == 2)
{
- if (chatWindow && chatWindow->findHighlight(tmp.text))
+ if (chatWindow != nullptr &&
+ chatWindow->findHighlight(tmp.text))
+ {
soundManager.playGuiSound(SOUND_HIGHLIGHT);
+ }
}
}
@@ -341,13 +345,13 @@ void ChatTab::chatLog(std::string line,
{
if (own == ChatMsgType::BY_GM)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
soundManager.playGuiSound(SOUND_GLOBAL);
}
else if (own != ChatMsgType::BY_SERVER)
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->unHideWindow();
playNewMessageSound();
}
@@ -358,7 +362,7 @@ void ChatTab::chatLog(std::string line,
void ChatTab::chatLog(const std::string &nick, std::string msg)
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const ChatMsgTypeT byWho = (nick == localPlayer->getName()
@@ -441,7 +445,7 @@ void ChatTab::handleCommandStr(const std::string &msg)
void ChatTab::handleHelp(const std::string &msg)
{
- if (helpWindow)
+ if (helpWindow != nullptr)
{
helpWindow->search(msg);
helpWindow->requestMoveToTop();
@@ -457,7 +461,7 @@ bool ChatTab::handleCommands(const std::string &type, const std::string &args)
void ChatTab::saveToLogFile(const std::string &msg) const
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
if (getType() == ChatTabType::INPUT)
{
@@ -498,7 +502,7 @@ void ChatTab::addRow(std::string &line)
void ChatTab::loadFromLogFile(const std::string &name)
{
- if (chatLogger)
+ if (chatLogger != nullptr)
{
std::list<std::string> list;
chatLogger->loadLast(name, list, 5);
diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
index 4c4401242..4374f6b2c 100644
--- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp
+++ b/src/gui/widgets/tabs/chat/emulateguildtab.cpp
@@ -56,13 +56,15 @@ EmulateGuildTab::~EmulateGuildTab()
bool EmulateGuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && guildManager)
+ if (guildManager == nullptr)
+ return false;
+ if (type == "invite")
guildManager->invite(args);
- else if (type == "leave" && guildManager)
+ else if (type == "leave")
guildManager->leave();
- else if (type == "kick" && guildManager)
+ else if (type == "kick")
guildManager->kick(args);
- else if (type == "notice" && guildManager)
+ else if (type == "notice")
guildManager->notice(args);
else
return false;
@@ -72,14 +74,14 @@ bool EmulateGuildTab::handleCommand(const std::string &restrict type,
void EmulateGuildTab::handleInput(const std::string &msg)
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->chat(ChatWindow::doReplace(msg));
}
void EmulateGuildTab::getAutoCompleteList(StringVect &names) const
{
- if (!guildManager)
+ if (guildManager == nullptr)
return;
guildManager->getNames(names);
diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp
index 982c27da5..51416b8ef 100644
--- a/src/gui/widgets/tabs/chat/guildtab.cpp
+++ b/src/gui/widgets/tabs/chat/guildtab.cpp
@@ -60,23 +60,23 @@ GuildTab::~GuildTab()
bool GuildTab::handleCommand(const std::string &restrict type,
const std::string &restrict args)
{
- if (type == "invite" && EAthena::taGuild)
+ if (type == "invite" && (EAthena::taGuild != nullptr))
{
guildHandler->invite(args);
}
- else if (type == "leave" && EAthena::taGuild)
+ else if (type == "leave" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::LEAVE_GUILD,
std::string(),
this);
}
- else if (type == "kick" && EAthena::taGuild)
+ else if (type == "kick" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::KICK_GUILD,
args,
this);
}
- else if (type == "notice" && EAthena::taGuild)
+ else if (type == "notice" && (EAthena::taGuild != nullptr))
{
inputManager.executeChatCommand(InputAction::GUILD_NOTICE,
args,
@@ -92,7 +92,7 @@ bool GuildTab::handleCommand(const std::string &restrict type,
void GuildTab::handleInput(const std::string &msg)
{
- if (!EAthena::taGuild)
+ if (EAthena::taGuild == nullptr)
return;
guildHandler->chat(ChatWindow::doReplace(msg));
@@ -100,7 +100,7 @@ void GuildTab::handleInput(const std::string &msg)
void GuildTab::getAutoCompleteList(StringVect &names) const
{
- if (EAthena::taGuild)
+ if (EAthena::taGuild != nullptr)
EAthena::taGuild->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
index 366a78241..befbb0393 100644
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ b/src/gui/widgets/tabs/chat/partytab.cpp
@@ -118,12 +118,12 @@ bool PartyTab::handleCommand(const std::string &restrict type,
void PartyTab::getAutoCompleteList(StringVect &names) const
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const p = localPlayer->getParty();
- if (p)
+ if (p != nullptr)
p->getNames(names);
}
diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp
index 1cbf471c7..d8672b22d 100644
--- a/src/gui/widgets/tabs/chat/whispertab.cpp
+++ b/src/gui/widgets/tabs/chat/whispertab.cpp
@@ -45,7 +45,7 @@ WhisperTab::WhisperTab(const Widget2 *const widget,
WhisperTab::~WhisperTab()
{
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->removeWhisper(mNick);
}
@@ -55,7 +55,7 @@ void WhisperTab::handleInput(const std::string &msg)
newMsg = ChatWindow::doReplace(msg);
chatHandler->privateMessage(mNick, newMsg);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), newMsg);
else
chatLog("?", newMsg);
@@ -78,7 +78,7 @@ void WhisperTab::handleCommandStr(const std::string &msg)
{
std::string str = textToMe(args);
chatHandler->privateMessage(mNick, str);
- if (localPlayer)
+ if (localPlayer != nullptr)
chatLog(localPlayer->getName(), str);
else
chatLog("?", str);
@@ -94,11 +94,11 @@ bool WhisperTab::handleCommand(const std::string &restrict type,
{
if (type == "close")
{
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->scheduleDelete(this);
else
delete this;
- if (chatWindow)
+ if (chatWindow != nullptr)
chatWindow->defaultTab();
}
else
diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp
index e75e1d42d..4a600d2fd 100644
--- a/src/gui/widgets/tabs/debugwindowtabs.cpp
+++ b/src/gui/widgets/tabs/debugwindowtabs.cpp
@@ -171,7 +171,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
void MapDebugTab::logic()
{
BLOCK_START("MapDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"),
@@ -184,7 +184,7 @@ void MapDebugTab::logic()
}
const Map *const map = Game::instance()->getCurrentMap();
- if (map && viewport)
+ if ((map != nullptr) && (viewport != nullptr))
{
// Get the current mouse position
const int mouseTileX = (viewport->mMouseX + viewport->getCameraX())
@@ -329,7 +329,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
void TargetDebugTab::logic()
{
BLOCK_START("TargetDebugTab::logic")
- if (localPlayer && localPlayer->getTarget())
+ if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr))
{
const Being *const target = localPlayer->getTarget();
@@ -344,7 +344,7 @@ void TargetDebugTab::logic()
mTargetTypeLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
_("Target type:"), toInt(target->getSubType(), int)));
- if (target->getLevel())
+ if (target->getLevel() != 0)
{
mTargetLevelLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -389,7 +389,7 @@ void TargetDebugTab::logic()
_("Effects:"), target->getStatusEffectsString().c_str()));
const int delay = target->getAttackDelay();
- if (delay)
+ if (delay != 0)
{
mAttackDelayLabel->setCaption(strprintf("%s %d",
// TRANSLATORS: debug window label
@@ -469,7 +469,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) :
void NetDebugTab::logic()
{
BLOCK_START("NetDebugTab::logic")
- if (localPlayer)
+ if (localPlayer != nullptr)
{
// TRANSLATORS: debug window label
mPingLabel->setCaption(strprintf(_("Ping: %s ms"),
diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp
index 0b958951a..7a37f2d89 100644
--- a/src/gui/widgets/tabs/setup_audio.cpp
+++ b/src/gui/widgets/tabs/setup_audio.cpp
@@ -181,10 +181,10 @@ void Setup_Audio::apply()
soundManager.init();
if (config.getBoolValue("playMusic"))
{
- if (viewport)
+ if (viewport != nullptr)
{ // in game
const Map *const map = viewport->getMap();
- if (map)
+ if (map != nullptr)
{
soundManager.playMusic(map->getMusicFile(),
SkipError_false);
diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp
index c9d0565b9..b27e1ec53 100644
--- a/src/gui/widgets/tabs/setup_chat.cpp
+++ b/src/gui/widgets/tabs/setup_chat.cpp
@@ -333,7 +333,7 @@ void Setup_Chat::apply()
{
SetupTabScroll::apply();
- if (chatWindow)
+ if (chatWindow != nullptr)
{
chatWindow->adjustTabSize();
chatWindow->parseHighlights();
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 9f7ad0154..f4efb2832 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -201,7 +201,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
Setup_Colors::~Setup_Colors()
{
- if (mPreviewBox && mPreviewBox->getContent() == mPreview)
+ if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview)
delete2(mTextPreview)
else
delete2(mPreview)
@@ -246,7 +246,7 @@ void Setup_Colors::action(const ActionEvent &event)
void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
mSelected = mColorBox->getSelected();
@@ -308,7 +308,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
break;
case UserColorId::ATTACK_RANGE_BORDER:
case UserColorId::HOME_PLACE_BORDER:
- if (gui)
+ if (gui != nullptr)
mTextPreview->setFont(gui->getFont());
mTextPreview->setTextColor(col);
mTextPreview->setOutline(false);
@@ -398,21 +398,21 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
void Setup_Colors::setEntry(Slider *const s, TextField *const t,
const int value)
{
- if (s)
+ if (s != nullptr)
s->setValue(value);
- if (t)
+ if (t != nullptr)
t->setText(toString(value));
}
void Setup_Colors::apply()
{
- if (userPalette)
+ if (userPalette != nullptr)
userPalette->commit();
}
void Setup_Colors::cancel()
{
- if (!userPalette)
+ if (userPalette == nullptr)
return;
userPalette->rollback();
@@ -430,7 +430,7 @@ void Setup_Colors::cancel()
void Setup_Colors::updateGradType()
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
mSelected = mColorBox->getSelected();
@@ -463,7 +463,7 @@ void Setup_Colors::updateGradType()
void Setup_Colors::updateColor() const
{
- if (mSelected == -1 || !userPalette)
+ if (mSelected == -1 || (userPalette == nullptr))
return;
const UserColorIdT type = static_cast<UserColorIdT>(
diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp
index 2b7c4bedd..dc1e531f8 100644
--- a/src/gui/widgets/tabs/setup_input.cpp
+++ b/src/gui/widgets/tabs/setup_input.cpp
@@ -91,7 +91,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mKeyListModel->setSize(mActionDataSize[0]);
refreshKeys();
- if (gui)
+ if (gui != nullptr)
mKeyList->setFont(gui->getHelpFont());
mKeyList->addActionListener(this);
@@ -106,7 +106,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) :
mTabs->addActionListener(this);
mTabs->setActionEventId("tabs_");
int k = 0;
- while (pages[k])
+ while (pages[k] != nullptr)
{
mTabs->addButton(gettext(pages[k]), pages[k], false);
k ++;
@@ -257,13 +257,13 @@ void Setup_Input::action(const ActionEvent &event)
{
int k = 0;
std::string str("tabs_");
- while (pages[k])
+ while (pages[k] != nullptr)
{
if (str + pages[k] == id)
break;
k ++;
}
- if (pages[k] && str + pages[k] == id)
+ if ((pages[k] != nullptr) && str + pages[k] == id)
{
mKeyListModel->setSelectedData(k);
mKeyListModel->setSize(mActionDataSize[k]);
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 784197eb9..12cf331a0 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -73,7 +73,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mNamesDropDown->setActionEventId("name");
mNamesDropDown->addActionListener(this);
- if (joystick)
+ if (joystick != nullptr)
{
mNamesDropDown->setSelected(joystick->getNumber());
}
@@ -113,12 +113,12 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else if (source == mNamesDropDown)
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setNumber(mNamesDropDown->getSelected());
}
else if (source == mDetectButton)
{
- if (joystick)
+ if (joystick != nullptr)
{
joystick->reload();
Joystick::getNames(mNamesModel->getNames());
@@ -127,7 +127,7 @@ void Setup_Joystick::action(const ActionEvent &event)
}
else
{
- if (!joystick)
+ if (joystick == nullptr)
return;
if (joystick->isCalibrating())
@@ -155,7 +155,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
mCalibrateButton->setEnabled(sel);
- if (joystick)
+ if (joystick != nullptr)
{
if (sel)
joystick->open();
@@ -166,7 +166,7 @@ void Setup_Joystick::setTempEnabled(const bool sel)
void Setup_Joystick::cancel()
{
- if (joystick)
+ if (joystick != nullptr)
joystick->setEnabled(mOriginalJoystickEnabled);
if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected())
@@ -177,7 +177,7 @@ void Setup_Joystick::cancel()
void Setup_Joystick::apply()
{
- if (!joystick)
+ if (joystick == nullptr)
return;
config.setValue("joystickEnabled", joystick->isEnabled());
diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp
index 994001763..7ee8f2f34 100644
--- a/src/gui/widgets/tabs/setup_mods.cpp
+++ b/src/gui/widgets/tabs/setup_mods.cpp
@@ -82,7 +82,7 @@ void Setup_Mods::loadMods()
FOR_EACH (ModInfoCIterator, it, mods)
{
const ModInfo *const info = (*it).second;
- if (!info)
+ if (info == nullptr)
continue;
std::string name = info->getName();
@@ -108,7 +108,7 @@ void Setup_Mods::saveMods() const
FOR_EACH (std::set<SetupItem*>::const_iterator, it, modsList)
{
const SetupItem *const item = *it;
- if (!item)
+ if (item == nullptr)
continue;
const std::string val = item->getValue();
if (val == "1")
diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp
index cca3acee9..4f9d8f856 100644
--- a/src/gui/widgets/tabs/setup_players.cpp
+++ b/src/gui/widgets/tabs/setup_players.cpp
@@ -186,6 +186,6 @@ void Setup_Players::externalUpdated()
void Setup_Players::apply()
{
SetupTabScroll::apply();
- settings.enableRemoteCommands = serverConfig.getValue(
- "enableRemoteCommands", 1);
+ settings.enableRemoteCommands = (serverConfig.getValue(
+ "enableRemoteCommands", 1) != 0);
}
diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp
index 0054da32b..d81bca9a9 100644
--- a/src/gui/widgets/tabs/setup_relations.cpp
+++ b/src/gui/widgets/tabs/setup_relations.cpp
@@ -70,10 +70,10 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
mPlayerScrollArea(new ScrollArea(this, mPlayerTable)),
// TRANSLATORS: relation dialog button
mDefaultTrading(new CheckBox(this, _("Allow trading"),
- player_relations.getDefault() & PlayerRelation::TRADE)),
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u)),
// TRANSLATORS: relation dialog button
mDefaultWhisper(new CheckBox(this, _("Allow whispers"),
- player_relations.getDefault() & PlayerRelation::WHISPER)),
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u)),
// TRANSLATORS: relation dialog button
mDeleteButton(new Button(this, _("Delete"), ACTION_DELETE, this)),
mIgnoreActionChoicesModel(new IgnoreChoicesListModel),
@@ -112,7 +112,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) :
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -177,10 +177,10 @@ void Setup_Relations::apply()
| (mDefaultTrading->isSelected() ? PlayerRelation::TRADE : 0)
| (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0));
- if (actorManager)
+ if (actorManager != nullptr)
actorManager->updatePlayerNames();
- if (localPlayer)
+ if (localPlayer != nullptr)
localPlayer->setCheckNameSetting(true);
}
@@ -231,10 +231,10 @@ void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
{
mPlayerTableModel->playerRelationsUpdated();
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
- if (localPlayer)
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
+ if (localPlayer != nullptr)
localPlayer->updateName();
}
@@ -246,7 +246,7 @@ void Setup_Relations::updateAll()
mPlayerTableModel = model;
int ignore_strategy_index = 0; // safe default
- if (player_relations.getPlayerIgnoreStrategy())
+ if (player_relations.getPlayerIgnoreStrategy() != nullptr)
{
ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
player_relations.getPlayerIgnoreStrategy()->mShortName);
@@ -260,7 +260,7 @@ void Setup_Relations::updateAll()
void Setup_Relations::externalUpdated()
{
mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
+ (player_relations.getDefault() & PlayerRelation::TRADE) != 0u);
mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
+ (player_relations.getDefault() & PlayerRelation::WHISPER) != 0u);
}
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index c97f192a0..47cbb2b92 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -237,7 +237,7 @@ void Setup_Theme::updateInfo()
{
delete mInfo;
mInfo = Theme::loadInfo(mTheme);
- if (mInfo)
+ if (mInfo != nullptr)
{
// TRANSLATORS: theme name
mThemeInfo = std::string(_("Name: ")).append(mInfo->name)
@@ -356,7 +356,7 @@ void Setup_Theme::apply()
}
config.setValue("selectedSkin", "");
- if (config.getStringValue("theme") != mTheme && mInfo)
+ if (config.getStringValue("theme") != mTheme && (mInfo != nullptr))
{
updateField(font, mFont);
updateField(boldFont, mBoldFont);
@@ -366,13 +366,13 @@ void Setup_Theme::apply()
updateField(npcFont, mNpcFont);
updateField(japanFont, mJapanFont);
updateField(chinaFont, mChinaFont);
- if (mInfo->fontSize)
+ if (mInfo->fontSize != 0)
{
const int size = mInfo->fontSize - 9;
if (size >= 0)
mFontSizeDropDown->setSelected(size);
}
- if (mInfo->npcfontSize)
+ if (mInfo->npcfontSize != 0)
{
const int size = mInfo->npcfontSize - 9;
if (size >= 0)
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 24fa8951f..b11b20f39 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -360,7 +360,7 @@ void Setup_Video::action(const ActionEvent &event)
if (mode == "custom")
{
- if (mDialog)
+ if (mDialog != nullptr)
{
mode = mDialog->getText();
mDialog = nullptr;
@@ -379,7 +379,7 @@ void Setup_Video::action(const ActionEvent &event)
}
const int width = atoi(mode.substr(0, mode.find('x')).c_str());
const int height = atoi(mode.substr(mode.find('x') + 1).c_str());
- if (!width || !height)
+ if ((width == 0) || (height == 0))
return;
if (width != mainGraphics->mActualWidth
@@ -491,7 +491,7 @@ void Setup_Video::action(const ActionEvent &event)
else if (id == "detect")
{
TestMain *test = graphicsManager.startDetection();
- if (test)
+ if (test != nullptr)
{
Configuration &conf = test->getConfig();
const int val = conf.getValueInt("opengl", -1);
diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp
index 898db7b3e..0cb623687 100644
--- a/src/gui/widgets/tabs/setuptabscroll.cpp
+++ b/src/gui/widgets/tabs/setuptabscroll.cpp
@@ -72,7 +72,7 @@ void SetupTabScroll::clear()
void SetupTabScroll::addControl(SetupItem *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
const std::string actionId = widget->getActionEventId();
if (!actionId.empty())
@@ -109,7 +109,7 @@ void SetupTabScroll::apply()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->apply((*iter).first);
}
}
@@ -120,7 +120,7 @@ void SetupTabScroll::cancel()
iter = mItems.begin(), iter_end = mItems.end();
iter != iter_end; ++ iter)
{
- if ((*iter).second)
+ if ((*iter).second != nullptr)
(*iter).second->cancel((*iter).first);
}
}
@@ -132,7 +132,7 @@ void SetupTabScroll::externalUpdated()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUpdated((*iter).first);
}
}
@@ -144,7 +144,7 @@ void SetupTabScroll::externalUnloaded()
iter != iter_end; ++ iter)
{
SetupItem *const widget = (*iter).second;
- if (widget && widget->isMainConfig() == MainConfig_false)
+ if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false)
widget->externalUnloaded((*iter).first);
}
}
@@ -158,6 +158,6 @@ void SetupTabScroll::widgetResized(const Event &event A_UNUSED)
void SetupTabScroll::reread(const std::string &name)
{
SetupItem *const item = mItems[name + "Event"];
- if (item)
+ if (item != nullptr)
item->rereadValue();
}
diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h
index 3845444d6..9086a4d0c 100644
--- a/src/gui/widgets/tabs/skilltab.h
+++ b/src/gui/widgets/tabs/skilltab.h
@@ -65,9 +65,9 @@ class SkillTab final : public Tab
SkillInfo *getSelectedInfo() const
{
- if (mListBox)
+ if (mListBox != nullptr)
return mListBox->getSelectedInfo();
- else if (mRectangleListBox)
+ else if (mRectangleListBox != nullptr)
return mRectangleListBox->getSelectedInfo();
else
return nullptr;
@@ -76,7 +76,7 @@ class SkillTab final : public Tab
protected:
void setCurrent() override
{
- if (skillDialog)
+ if (skillDialog != nullptr)
skillDialog->updateTabSelection();
}
diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h
index a15f566d6..e68647a77 100644
--- a/src/gui/widgets/tabs/socialfriendsfunctor.h
+++ b/src/gui/widgets/tabs/socialfriendsfunctor.h
@@ -35,11 +35,14 @@ class SortFriendsFunctor final
bool operator() (const Avatar *const m1,
const Avatar *const m2) const
{
- if (!m1 || !m2)
+ if ((m1 == nullptr) || (m2 == nullptr))
return false;
if (m1->getOnline() != m2->getOnline())
- return m1->getOnline() > m2->getOnline();
+ {
+ return static_cast<int>(m1->getOnline()) >
+ static_cast<int>(m2->getOnline());
+ }
if (m1->getName() != m2->getName())
{
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 616fba43d..dfae61090 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -71,7 +71,7 @@ class SocialFriendsTab final : public SocialTab
void getPlayersAvatars()
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -90,7 +90,7 @@ class SocialFriendsTab final : public SocialTab
const std::set<std::string> &players2
= whoIsOnline->getOnlineNicks();
- if (!players)
+ if (players == nullptr)
return;
int online = 0;
@@ -99,8 +99,8 @@ class SocialFriendsTab final : public SocialTab
FOR_EACHP (StringVectCIter, it, players)
{
Avatar *const ava = new Avatar(*it);
- if (actorManager->findBeingByName(*it, ActorType::Player)
- || players2.find(*it) != players2.end())
+ if (actorManager->findBeingByName(*it, ActorType::Player) !=
+ nullptr || players2.find(*it) != players2.end())
{
ava->setOnline(true);
online ++;
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index 53b7d46f4..775e22c6f 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -78,7 +78,7 @@ class SocialGuildTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
guildHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -96,7 +96,7 @@ class SocialGuildTab final : public SocialTab,
else if (eventId == "yes")
{
guildHandler->leave(mGuild->getId());
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -137,7 +137,7 @@ class SocialGuildTab final : public SocialTab,
void buildCounter(const int online0, const int total0) override final
{
- if (online0 || total0)
+ if ((online0 != 0) || (total0 != 0))
{
// TRANSLATORS: social window label
mCounterString = strprintf(_("Members: %u/%u"),
@@ -146,11 +146,11 @@ class SocialGuildTab final : public SocialTab,
}
else
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index a21594aab..f26e99421 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -77,11 +77,11 @@ class SocialGuildTab2 final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Guild *const guild = localPlayer->getGuild();
- if (!guild)
+ if (guild == nullptr)
return;
const Guild::MemberList *const members = guild->getMembers();
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index 0f72b60f9..80b5910f3 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -72,11 +72,11 @@ class SocialNavigationTab final : public SocialTab
void updateList() override final
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map || map->empty())
+ if ((map == nullptr) || map->empty())
return;
if (socialWindow->getProcessedPortals())
@@ -105,7 +105,7 @@ class SocialNavigationTab final : public SocialTab
while (i != portals.end())
{
MapItem *portal = *i;
- if (!portal)
+ if (portal == nullptr)
continue;
const int x = portal->getX();
@@ -115,7 +115,7 @@ class SocialNavigationTab final : public SocialTab
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -130,21 +130,21 @@ class SocialNavigationTab final : public SocialTab
total ++;
if (config.getBoolValue("drawHotKeys")
- && idx < 80 && outfitWindow)
+ && idx < 80 && (outfitWindow != nullptr))
{
Being *const being = actorManager
->findPortalByTile(x, y);
- if (being)
+ if (being != nullptr)
{
being->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
}
- if (specialLayer)
+ if (specialLayer != nullptr)
{
portal = specialLayer->getTile(
ava->getX(), ava->getY());
- if (portal)
+ if (portal != nullptr)
{
portal->setName(keyboard.getKeyShortString(
outfitWindow->keyName(idx)));
@@ -155,7 +155,7 @@ class SocialNavigationTab final : public SocialTab
++i;
idx ++;
}
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->setProcessedPortals(true);
// TRANSLATORS: social window label
@@ -167,7 +167,7 @@ class SocialNavigationTab final : public SocialTab
void selectIndex(const unsigned num) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -175,19 +175,19 @@ class SocialNavigationTab final : public SocialTab
return;
const Avatar *const ava = avatars->at(num);
- if (ava && localPlayer)
+ if ((ava != nullptr) && (localPlayer != nullptr))
localPlayer->navigateTo(ava->getX(), ava->getY());
}
void updateNames()
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -195,12 +195,12 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
const MapItem *const item = map->findPortalXY(
ava->getX(), ava->getY());
- if (item)
+ if (item != nullptr)
{
const std::string name = strprintf("%s [%d %d]",
item->getComment().c_str(),
@@ -215,12 +215,12 @@ class SocialNavigationTab final : public SocialTab
int getPortalIndex(const int x, const int y)
{
- if (!socialWindow)
+ if (socialWindow == nullptr)
return -1;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return -1;
std::vector<Avatar*>::const_iterator i = avatars->begin();
@@ -229,7 +229,7 @@ class SocialNavigationTab final : public SocialTab
while (i != i_end)
{
const Avatar *const ava = *i;
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
@@ -243,23 +243,23 @@ class SocialNavigationTab final : public SocialTab
void addPortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
const MapItem *const portal = map->findPortalXY(x, y);
- if (!portal)
+ if (portal == nullptr)
return;
const std::string name = strprintf("%s [%d %d]",
portal->getComment().c_str(), x, y);
Avatar *const ava = new Avatar(name);
- if (localPlayer)
+ if (localPlayer != nullptr)
ava->setOnline(localPlayer->isReachable(x, y, true));
else
ava->setOnline(false);
@@ -272,11 +272,11 @@ class SocialNavigationTab final : public SocialTab
void removePortal(const int x, const int y)
{
- if (!socialWindow || !localPlayer)
+ if ((socialWindow == nullptr) || (localPlayer == nullptr))
return;
const Map *const map = socialWindow->getMap();
- if (!map)
+ if (map == nullptr)
return;
std::vector<Avatar*> *const avatars = mBeings->getMembers();
@@ -287,7 +287,7 @@ class SocialNavigationTab final : public SocialTab
{
Avatar *ava = (*i);
- if (!ava)
+ if (ava == nullptr)
break;
if (ava->getX() == x && ava->getY() == y)
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index 93625f7eb..b24f8f411 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -80,7 +80,7 @@ class SocialPartyTab final : public SocialTab,
const std::string name = mInviteDialog->getText();
partyHandler->invite(name);
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: chat message
@@ -97,7 +97,7 @@ class SocialPartyTab final : public SocialTab,
else if (eventId == "yes")
{
partyHandler->leave();
- if (localChatTab)
+ if (localChatTab != nullptr)
{
localChatTab->chatLog(strprintf(
// TRANSLATORS: tab in social window
@@ -139,11 +139,11 @@ class SocialPartyTab final : public SocialTab,
void buildCounter(const int online0 A_UNUSED,
const int total0 A_UNUSED) override final
{
- if (!localPlayer)
+ if (localPlayer == nullptr)
return;
const Party *const party = localPlayer->getParty();
- if (!party)
+ if (party == nullptr)
return;
const Party::MemberList *const members = party->getMembers();
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 2a80b3005..447e0791e 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -71,18 +71,18 @@ class SocialPlayersTab final : public SocialTab
void updateAvatar(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
BLOCK_START("SocialPlayersTab::updateAvatar")
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
- if (Party::getParty(1))
+ if (Party::getParty(1) != nullptr)
{
const PartyMember *const
pm = Party::getParty(1)->getMember(name);
- if (pm && pm->getMaxHp() > 0)
+ if ((pm != nullptr) && pm->getMaxHp() > 0)
{
avatar->setMaxHp(pm->getMaxHp());
avatar->setHp(pm->getHp());
@@ -90,7 +90,7 @@ class SocialPlayersTab final : public SocialTab
}
const Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
{
avatar->setDamageHp(being->getDamageTaken());
avatar->setLevel(being->getLevel());
@@ -103,17 +103,17 @@ class SocialPlayersTab final : public SocialTab
void resetDamage(const std::string &name) override final
{
- if (!actorManager)
+ if (actorManager == nullptr)
return;
Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
+ if (avatar == nullptr)
return;
avatar->setDamageHp(0);
Being *const being = actorManager->findBeingByName(
name, ActorType::Player);
- if (being)
+ if (being != nullptr)
being->setDamageTaken(0);
}
@@ -126,7 +126,7 @@ class SocialPlayersTab final : public SocialTab
while (i != i_end)
{
ava = (*i);
- if (ava && ava->getName() == name)
+ if ((ava != nullptr) && ava->getName() == name)
return ava;
++i;
}
@@ -139,7 +139,7 @@ class SocialPlayersTab final : public SocialTab
void getPlayersAvatars()
{
std::vector<Avatar*> *const avatars = mBeings->getMembers();
- if (actorManager)
+ if (actorManager != nullptr)
{
StringVect names;
actorManager->getPlayerNames(names, NpcNames_false);
@@ -149,7 +149,7 @@ class SocialPlayersTab final : public SocialTab
{
bool finded = false;
const Avatar *const ava = (*ai);
- if (!ava)
+ if (ava == nullptr)
break;
StringVectCIter i = names.begin();
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
index 7458e62ee..34f864561 100644
--- a/src/gui/widgets/tabs/socialtab.h
+++ b/src/gui/widgets/tabs/socialtab.h
@@ -88,14 +88,14 @@ class SocialTab notfinal : public Tab
virtual ~SocialTab()
{
// Cleanup dialogs
- if (mInviteDialog)
+ if (mInviteDialog != nullptr)
{
mInviteDialog->close();
mInviteDialog->scheduleDelete();
mInviteDialog = nullptr;
}
- if (mConfirmDialog)
+ if (mConfirmDialog != nullptr)
{
mConfirmDialog->close();
mConfirmDialog->scheduleDelete();
@@ -122,13 +122,13 @@ class SocialTab notfinal : public Tab
void updateCounter() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateCounter(this, mCounterString);
}
void updateMenu() const
{
- if (socialWindow)
+ if (socialWindow != nullptr)
socialWindow->updateMenu(this, mMenuAction);
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 95588e98d..a4a2f583b 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -130,11 +130,11 @@ Tab::Tab(const Widget2 *const widget) :
Tab::~Tab()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
mInstances--;
- if (mInstances == 0 && theme)
+ if (mInstances == 0 && (theme != nullptr))
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
theme->unload(tabImg[mode]);
@@ -142,7 +142,7 @@ Tab::~Tab()
delete2(mLabel);
- if (mImage)
+ if (mImage != nullptr)
{
mImage->decRef();
mImage = nullptr;
@@ -162,7 +162,7 @@ void Tab::init()
if (mInstances == 0)
{
// Load the skin
- if (theme)
+ if (theme != nullptr)
{
for (int mode = 0; mode < TAB_COUNT; mode ++)
tabImg[mode] = theme->load(data[mode], "tab.xml");
@@ -174,7 +174,7 @@ void Tab::init()
add(mLabel);
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int padding = skin->getPadding();
@@ -194,11 +194,11 @@ void Tab::updateAlpha()
for (int t = 0; t < TAB_COUNT; t++)
{
Skin *const skin = tabImg[t];
- if (skin)
+ if (skin != nullptr)
{
const ImageRect &rect = skin->getBorder();
Image *const image = rect.grid[a];
- if (image)
+ if (image != nullptr)
image->setAlpha(mAlpha);
}
}
@@ -212,7 +212,7 @@ void Tab::draw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -223,7 +223,7 @@ void Tab::draw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -269,7 +269,7 @@ void Tab::draw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -288,10 +288,10 @@ void Tab::draw(Graphics *const graphics)
mDimension.width, mDimension.height,
rect);
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->calcTileCollection(mVertexes,
@@ -315,7 +315,7 @@ void Tab::safeDraw(Graphics *const graphics)
int mode = TAB_STANDARD;
// check which type of tab to draw
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
{
int labelMode = mFlash;
@@ -326,7 +326,7 @@ void Tab::safeDraw(Graphics *const graphics)
// if tab is selected, it doesnt need to highlight activity
mFlash = 0;
}
- else if (!labelMode)
+ else if (labelMode == 0)
{
if (mHasMouse)
{
@@ -370,7 +370,7 @@ void Tab::safeDraw(Graphics *const graphics)
}
const Skin *const skin = tabImg[mode];
- if (!skin)
+ if (skin == nullptr)
{
BLOCK_END("Tab::draw")
return;
@@ -381,10 +381,10 @@ void Tab::safeDraw(Graphics *const graphics)
graphics->drawImageRect(0, 0,
mDimension.width, mDimension.height,
skin->getBorder());
- if (mImage)
+ if (mImage != nullptr)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
+ if (skin1 != nullptr)
{
const int padding = skin1->getPadding();
graphics->drawImage(mImage, padding, padding);
@@ -407,7 +407,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED)
void Tab::setLabelFont(Font *const font)
{
- if (!mLabel)
+ if (mLabel == nullptr)
return;
mLabel->setFont(font);
@@ -420,11 +420,11 @@ void Tab::setLabelFont(Font *const font)
void Tab::adjustSize()
{
const Skin *const skin = tabImg[TAB_STANDARD];
- if (!skin)
+ if (skin == nullptr)
return;
const int pad2 = skin->getPadding() * 2;
- if (mImage)
+ if (mImage != nullptr)
{
const SDL_Rect &rect = mImage->mBounds;
setSize(rect.w + pad2, rect.h + pad2);
@@ -435,7 +435,7 @@ void Tab::adjustSize()
mLabel->getHeight() + pad2);
}
- if (mTabbedArea)
+ if (mTabbedArea != nullptr)
mTabbedArea->adjustTabPositions();
}
@@ -458,7 +458,7 @@ void Tab::setCaption(const std::string &caption)
void Tab::setImage(Image *const image)
{
- if (mImage)
+ if (mImage != nullptr)
mImage->decRef();
mImage = image;
adjustSize();
diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp
index 1f8db0d5e..2a8299ea1 100644
--- a/src/gui/widgets/tabstrip.cpp
+++ b/src/gui/widgets/tabstrip.cpp
@@ -50,7 +50,7 @@ Widget *TabStrip::createWidget(const std::string &text,
widget->setStick(true);
widget->setCaption(text);
widget->adjustSize();
- if ((!mCount && mPressFirst) || pressed)
+ if (((mCount == 0) && mPressFirst) || pressed)
widget->setPressed(true);
widget->setTag(CAST_S32(mWidgets.size()));
return widget;
@@ -59,11 +59,11 @@ Widget *TabStrip::createWidget(const std::string &text,
void TabStrip::action(const ActionEvent &event)
{
WidgetGroup::action(event);
- if (event.getSource())
+ if (event.getSource() != nullptr)
{
Widget *const widget = event.getSource();
Button *const button = static_cast<Button*>(widget);
- if (!button)
+ if (button == nullptr)
return;
if (button->isPressed2())
{
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 5b8acdb2e..31e000082 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -101,14 +101,14 @@ TextBox::TextBox(const Widget2 *const widget) :
TextBox::~TextBox()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
}
void TextBox::setTextWrapped(const std::string &text, const int minDimension)
{
// Make sure parent scroll area sets width of this widget
- if (getParent())
+ if (getParent() != nullptr)
getParent()->logic();
// Take the supplied minimum dimension as a starting
@@ -384,7 +384,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -400,7 +400,7 @@ void TextBox::keyPressed(KeyEvent& event)
{
Widget *const par = getParent();
- if (par)
+ if (par != nullptr)
{
const int rowsPerPage = par->getChildrenArea().height
/ getFont()->getHeight();
@@ -605,7 +605,7 @@ void TextBox::mousePressed(MouseEvent& event)
if (event.getButton() == MouseButton::LEFT)
{
const int height = getFont()->getHeight();
- if (!height)
+ if (height == 0)
return;
event.consume();
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index ce37879a4..e536b5b13 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -123,7 +123,7 @@ TextField::TextField(const Widget2 *restrict const widget,
mCaretColor(&getThemeColor(ThemeColorId::CARET)),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false),
+ mLastEventPaste(0),
mPadding(1),
mNumeric(false),
mLoseFocusOnTab(loseFocusOnTab),
@@ -144,7 +144,7 @@ TextField::TextField(const Widget2 *restrict const widget,
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->loadSkinRect(skin, "textfield.xml",
"textfield_background.xml");
@@ -153,7 +153,7 @@ TextField::TextField(const Widget2 *restrict const widget,
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
{
mPadding = mSkin->getPadding();
mFrameSize = mSkin->getOption("frameSize", 2);
@@ -163,22 +163,22 @@ TextField::TextField(const Widget2 *restrict const widget,
if (!eventId.empty())
setActionEventId(eventId);
- if (listener)
+ if (listener != nullptr)
addActionListener(listener);
}
TextField::~TextField()
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->removeWidgetListener(this);
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
{
theme->unload(mSkin);
Theme::unloadRect(skin);
@@ -197,7 +197,7 @@ void TextField::updateAlpha()
mAlpha = alpha;
for (int a = 0; a < 9; a++)
{
- if (skin.grid[a])
+ if (skin.grid[a] != nullptr)
skin.grid[a]->setAlpha(mAlpha);
}
}
@@ -227,7 +227,7 @@ void TextField::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, mPadding - mXScroll, mPadding);
BLOCK_END("TextField::draw")
@@ -269,7 +269,7 @@ void TextField::setNumeric(const bool numeric)
return;
const char *const text = mText.c_str();
- for (const char *textPtr = text; *textPtr; ++textPtr)
+ for (const char *textPtr = text; *textPtr != 0; ++textPtr)
{
if (*textPtr < '0' || *textPtr > '9')
{
@@ -318,7 +318,8 @@ void TextField::keyPressed(KeyEvent &event)
{
if (mNumeric)
{
- if ((val >= '0' && val <= '9') || (val == '-' && !mCaretPosition))
+ if ((val >= '0' && val <= '9') ||
+ (val == '-' && mCaretPosition == 0u))
{
char buf[2];
buf[0] = CAST_8(val);
@@ -333,7 +334,7 @@ void TextField::keyPressed(KeyEvent &event)
return;
}
}
- else if (!mMaximum ||
+ else if ((mMaximum == 0) ||
CAST_S32(mText.size()) < mMaximum)
{
int len;
@@ -566,7 +567,7 @@ void TextField::handleCtrlKeys(const InputActionT action, bool &consumed)
#else // USE_SDL2
// hack to prevent paste key sticking
- if (mLastEventPaste && mLastEventPaste > cur_time)
+ if ((mLastEventPaste != 0) && mLastEventPaste > cur_time)
break;
handlePaste();
mLastEventPaste = cur_time + 2;
@@ -771,7 +772,7 @@ void TextField::mousePressed(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
#ifndef DYECMD
- if (popupMenu)
+ if (popupMenu != nullptr)
popupMenu->showTextFieldPopup(this);
#endif // DYECMD
}
@@ -817,14 +818,14 @@ void TextField::widgetHidden(const Event &event A_UNUSED)
void TextField::setParent(Widget *widget)
{
- if (mWindow)
+ if (mWindow != nullptr)
mWindow->addWidgetListener(this);
Widget::setParent(widget);
}
void TextField::setWindow(Widget *const widget)
{
- if (!widget && mWindow)
+ if ((widget == nullptr) && (mWindow != nullptr))
{
mWindow->removeWidgetListener(this);
mWindow = nullptr;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 04d2b39aa..53f84badc 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -55,13 +55,13 @@ TextPreview::TextPreview(const Widget2 *const widget,
mAllowLogic = false;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
mSkin = theme->load("textpreview.xml", "");
}
instances++;
- if (mSkin)
+ if (mSkin != nullptr)
mPadding = mSkin->getOption("padding", 0);
adjustSize();
@@ -69,21 +69,21 @@ TextPreview::TextPreview(const Widget2 *const widget,
TextPreview::~TextPreview()
{
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
instances--;
if (instances == 0)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
}
}
void TextPreview::draw(Graphics *const graphics)
{
- if (!mFont)
+ if (mFont == nullptr)
return;
BLOCK_START("TextPreview::draw")
@@ -103,7 +103,7 @@ void TextPreview::draw(Graphics *const graphics)
mDimension.width, mDimension.height));
}
- if (mTextBGColor)
+ if (mTextBGColor != nullptr)
{
const int x = mFont->getWidth(mText) + 1
+ 2 * ((mOutline || mShadow) ? 1 :0);
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index 9aaad702d..e15dc2481 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -48,7 +48,7 @@ void VertContainer::add1(Widget *const widget, const int spacing)
void VertContainer::add2(Widget *const widget, const bool resizable,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp
index dda7217c4..6b7642a3d 100644
--- a/src/gui/widgets/virtshortcutcontainer.cpp
+++ b/src/gui/widgets/virtshortcutcontainer.cpp
@@ -52,7 +52,7 @@ VirtShortcutContainer::VirtShortcutContainer(Widget2 *const widget,
mUnEquipedColor2(getThemeColor(ThemeColorId::ITEM_NOT_EQUIPPED_OUTLINE)),
mShortcut(shortcut)
{
- if (mShortcut)
+ if (mShortcut != nullptr)
mMaxItems = mShortcut->getItemCount();
else
mMaxItems = 0;
@@ -73,21 +73,21 @@ void VirtShortcutContainer::setWidget2(const Widget2 *const widget)
void VirtShortcutContainer::draw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::draw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
drawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::draw")
return;
@@ -106,12 +106,12 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -147,21 +147,21 @@ void VirtShortcutContainer::draw(Graphics *const graphics)
void VirtShortcutContainer::safeDraw(Graphics *const graphics)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
BLOCK_START("VirtShortcutContainer::safeDraw")
if (settings.guiAlpha != mAlpha)
{
mAlpha = settings.guiAlpha;
- if (mBackgroundImg)
+ if (mBackgroundImg != nullptr)
mBackgroundImg->setAlpha(mAlpha);
}
safeDrawBackground(graphics);
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
{
BLOCK_END("VirtShortcutContainer::safeDraw")
return;
@@ -180,12 +180,12 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
const Item *const item = inv->findItem(mShortcut->getItem(i),
mShortcut->getItemColor(i));
- if (item)
+ if (item != nullptr)
{
// Draw item icon.
Image *const image = item->getImage();
- if (image)
+ if (image != nullptr)
{
std::string caption;
if (item->getQuantity() > 1)
@@ -221,7 +221,7 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics)
void VirtShortcutContainer::mouseDragged(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -240,12 +240,12 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(itemId, itemColor);
- if (item)
+ if (item != nullptr)
{
dragDrop.dragItem(item, DragDropSource::Drop);
mShortcut->removeItem(index);
@@ -260,7 +260,7 @@ void VirtShortcutContainer::mouseDragged(MouseEvent &event)
void VirtShortcutContainer::mousePressed(MouseEvent &event)
{
- if (!mShortcut || !inventoryWindow)
+ if ((mShortcut == nullptr) || (inventoryWindow == nullptr))
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -290,13 +290,13 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
else if (eventButton == MouseButton::RIGHT)
{
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
Item *const item = inv->findItem(mShortcut->getItem(index),
mShortcut->getItemColor(index));
- if (popupMenu)
+ if (popupMenu != nullptr)
{
popupMenu->showDropPopup(viewport->mMouseX,
viewport->mMouseY,
@@ -307,7 +307,7 @@ void VirtShortcutContainer::mousePressed(MouseEvent &event)
void VirtShortcutContainer::mouseReleased(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -339,7 +339,7 @@ void VirtShortcutContainer::mouseReleased(MouseEvent &event)
// Show ItemTooltip
void VirtShortcutContainer::mouseMoved(MouseEvent &event)
{
- if (!mShortcut)
+ if (mShortcut == nullptr)
return;
const int index = getIndexFromGrid(event.getX(), event.getY());
@@ -354,12 +354,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
return;
const Inventory *const inv = PlayerInfo::getInventory();
- if (!inv)
+ if (inv == nullptr)
return;
const Item *const item = inv->findItem(itemId, itemColor);
- if (item && viewport)
+ if ((item != nullptr) && (viewport != nullptr))
{
itemPopup->setItem(item, false);
itemPopup->position(viewport->mMouseX, viewport->mMouseY);
@@ -372,12 +372,12 @@ void VirtShortcutContainer::mouseMoved(MouseEvent &event)
void VirtShortcutContainer::mouseExited(MouseEvent &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
void VirtShortcutContainer::widgetHidden(const Event &event A_UNUSED)
{
- if (itemPopup)
+ if (itemPopup != nullptr)
itemPopup->setVisible(Visible_false);
}
diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp
index 9523cb4b5..260272936 100644
--- a/src/gui/widgets/widget.cpp
+++ b/src/gui/widgets/widget.cpp
@@ -179,7 +179,7 @@ void Widget::setDimension(const Rect& dimension)
bool Widget::isFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
return (mFocusHandler->isFocused(this));
@@ -187,7 +187,7 @@ bool Widget::isFocused() const
void Widget::setFocusable(const bool focusable)
{
- if (!focusable && isFocused() && mFocusHandler)
+ if (!focusable && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
mFocusable = focusable;
}
@@ -199,7 +199,7 @@ bool Widget::isFocusable() const
void Widget::requestFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
if (isFocusable())
@@ -208,19 +208,19 @@ void Widget::requestFocus()
void Widget::requestMoveToTop()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToTop(this);
}
void Widget::requestMoveToBottom()
{
- if (mParent)
+ if (mParent != nullptr)
mParent->moveToBottom(this);
}
void Widget::setVisible(Visible visible)
{
- if (visible == Visible_false && isFocused() && mFocusHandler)
+ if (visible == Visible_false && isFocused() && (mFocusHandler != nullptr))
mFocusHandler->focusNone();
if (visible == Visible_true)
@@ -233,13 +233,13 @@ void Widget::setVisible(Visible visible)
void Widget::setFocusHandler(FocusHandler *const focusHandler)
{
- if (mFocusHandler)
+ if (mFocusHandler != nullptr)
{
releaseModalFocus();
mFocusHandler->remove(this);
}
- if (focusHandler)
+ if (focusHandler != nullptr)
focusHandler->add(this);
mFocusHandler = focusHandler;
@@ -307,7 +307,7 @@ void Widget::removeWidgetListener(WidgetListener *const widgetListener)
void Widget::getAbsolutePosition(int& x, int& y) const
{
- if (!mParent)
+ if (mParent == nullptr)
{
x = mDimension.x;
y = mDimension.y;
@@ -326,7 +326,7 @@ void Widget::getAbsolutePosition(int& x, int& y) const
Font* Widget::getFont() const
{
- if (!mCurrentFont)
+ if (mCurrentFont == nullptr)
return mGlobalFont;
return mCurrentFont;
}
@@ -337,7 +337,7 @@ void Widget::setGlobalFont(Font *const font)
FOR_EACH (std::list<Widget*>::const_iterator, iter, mAllWidgets)
{
- if (!(*iter)->mCurrentFont)
+ if ((*iter)->mCurrentFont == nullptr)
(*iter)->fontChanged();
}
}
@@ -375,38 +375,38 @@ bool Widget::isEnabled() const
void Widget::requestModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalFocus(this);
}
void Widget::requestModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->requestModalMouseInputFocus(this);
}
void Widget::releaseModalFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalFocus(this);
}
void Widget::releaseModalMouseInputFocus()
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
mFocusHandler->releaseModalMouseInputFocus(this);
}
bool Widget::isModalFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalFocused() == this)
|| mParent->isModalFocused();
@@ -417,10 +417,10 @@ bool Widget::isModalFocused() const
bool Widget::isModalMouseInputFocused() const
{
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return false;
- if (mParent)
+ if (mParent != nullptr)
{
return (mFocusHandler->getModalMouseInputFocused() == this)
|| mParent->isModalMouseInputFocused();
@@ -506,7 +506,7 @@ void Widget::distributeShownEvent()
void Widget::showPart(const Rect &rectangle)
{
- if (mParent)
+ if (mParent != nullptr)
mParent->showWidgetPart(this, rectangle);
}
@@ -517,7 +517,7 @@ void Widget::windowResized()
Widget *Widget::callPostInit(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
widget->postInit();
return widget;
}
diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h
index 2a8cae343..bbb1bc103 100644
--- a/src/gui/widgets/widget.h
+++ b/src/gui/widgets/widget.h
@@ -377,7 +377,7 @@ class Widget notfinal : public Widget2
bool isVisible() const A_WARN_UNUSED
{
return mVisible == Visible_true &&
- (!mParent || mParent->isVisible());
+ ((mParent == nullptr) || mParent->isVisible());
}
/**
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index d76bd696e..ed9110ba4 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -52,7 +52,7 @@ class Widget2 notfinal
bool &valid)
const A_WARN_UNUSED A_INLINE
{
- if (!theme)
+ if (theme == nullptr)
return Palette::BLACK;
const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
if (valid)
@@ -63,7 +63,7 @@ class Widget2 notfinal
virtual void setWidget2(const Widget2 *const widget)
{
- mPaletteOffset = widget ? widget->mPaletteOffset : 0;
+ mPaletteOffset = widget != nullptr ? widget->mPaletteOffset : 0;
}
void setPalette(int palette)
@@ -101,8 +101,8 @@ class Widget2 notfinal
protected:
explicit Widget2(const Widget2 *const widget) :
- mPaletteOffset(widget ? widget->mPaletteOffset : 0),
- mWindow(widget ? widget->getWindow() : nullptr),
+ mPaletteOffset(widget != nullptr ? widget->mPaletteOffset : 0),
+ mWindow(widget != nullptr ? widget->getWindow() : nullptr),
mForegroundColor2()
{
checkPalette();
diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp
index 18bd81a4f..72524b07c 100644
--- a/src/gui/widgets/widgetgroup.cpp
+++ b/src/gui/widgets/widgetgroup.cpp
@@ -46,7 +46,7 @@ void WidgetGroup::addButton(const std::string &restrict text,
return;
Widget *const widget = createWidget(text, pressed);
- if (widget)
+ if (widget != nullptr)
{
widget->setActionEventId(mActionEventId + tag);
widget->addActionListener(this);
@@ -66,7 +66,7 @@ void WidgetGroup::action(const ActionEvent &event)
void WidgetGroup::addWidget(Widget *const widget,
const int spacing)
{
- if (!widget)
+ if (widget == nullptr)
return;
Container::add(widget);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 86c2188d1..4a3103b99 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -180,10 +180,10 @@ Window::Window(const std::string &caption,
int childPalette = 1;
// Loads the skin
- if (theme)
+ if (theme != nullptr)
{
mSkin = theme->load(skin, "window.xml");
- if (mSkin)
+ if (mSkin != nullptr)
{
setPadding(mSkin->getPadding());
if (getOptionBool("titlebarBold"))
@@ -191,10 +191,10 @@ Window::Window(const std::string &caption,
mTitlePadding = mSkin->getTitlePadding();
mGripPadding = getOption("resizePadding");
mCaptionOffsetX = getOption("captionoffsetx");
- if (!mCaptionOffsetX)
+ if (mCaptionOffsetX == 0)
mCaptionOffsetX = 7;
mCaptionOffsetY = getOption("captionoffsety");
- if (!mCaptionOffsetY)
+ if (mCaptionOffsetY == 0)
mCaptionOffsetY = 5;
mCaptionAlign = static_cast<Graphics::Alignment>(
getOption("captionalign"));
@@ -205,7 +205,7 @@ Window::Window(const std::string &caption,
}
setTitleBarHeight(CAST_U32(
getOption("titlebarHeight")));
- if (!mTitleBarHeight)
+ if (mTitleBarHeight == 0u)
mTitleBarHeight = mCaptionFont->getHeight() + mPadding;
mTitleBarHeight += getOption("titlebarHeightRelative");
@@ -219,7 +219,7 @@ Window::Window(const std::string &caption,
}
// Add this window to the window container
- if (windowContainer)
+ if (windowContainer != nullptr)
windowContainer->add(this);
if (mModal == Modal_true)
@@ -241,11 +241,11 @@ Window::~Window()
{
logger->log("Window::~Window(\"%s\")", getCaption().c_str());
- if (gui)
+ if (gui != nullptr)
gui->removeDragged(this);
#ifndef DYECMD
- if (setupWindow)
+ if (setupWindow != nullptr)
setupWindow->unregisterWindowForReset(this);
#endif // DYECMD
@@ -265,13 +265,13 @@ Window::~Window()
windowInstances--;
- if (mSkin)
+ if (mSkin != nullptr)
{
- if (theme)
+ if (theme != nullptr)
theme->unload(mSkin);
mSkin = nullptr;
}
- if (mGrip)
+ if (mGrip != nullptr)
{
mGrip->decRef();
mGrip = nullptr;
@@ -290,7 +290,7 @@ void Window::setWindowContainer(WindowContainer *const wc)
void Window::draw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::draw")
@@ -318,7 +318,7 @@ void Window::draw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -330,7 +330,7 @@ void Window::draw(Graphics *const graphics)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
graphics->calcTileCollection(mVertexes,
button,
@@ -339,7 +339,7 @@ void Window::draw(Graphics *const graphics)
}
}
- if (mGrip)
+ if (mGrip != nullptr)
{
graphics->calcTileCollection(mVertexes,
mGrip,
@@ -383,7 +383,7 @@ void Window::draw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -402,7 +402,7 @@ void Window::draw(Graphics *const graphics)
void Window::safeDraw(Graphics *const graphics)
{
- if (!mSkin)
+ if (mSkin == nullptr)
return;
BLOCK_START("Window::safeDraw")
@@ -417,18 +417,18 @@ void Window::safeDraw(Graphics *const graphics)
{
const Image *const button = mSkin->getCloseImage(
mResizeHandles == CLOSE);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
}
// Draw Sticky Button
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
}
- if (mGrip)
+ if (mGrip != nullptr)
graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
// Draw title
@@ -460,7 +460,7 @@ void Window::safeDraw(Graphics *const graphics)
}
const Image *const image = mTextChunk.img;
- if (image)
+ if (image != nullptr)
graphics->drawImage(image, x, mCaptionOffsetY);
}
@@ -488,7 +488,7 @@ void Window::setContentSize(int width, int height)
void Window::setLocationRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -505,7 +505,7 @@ void Window::setLocationRelativeTo(const Widget *const widget)
void Window::setLocationHorisontallyRelativeTo(const Widget *const widget)
{
- if (!widget)
+ if (widget == nullptr)
return;
int wx, wy;
@@ -566,7 +566,7 @@ void Window::setLocationRelativeTo(const ImagePosition::Type &position,
void Window::setMinWidth(const int width)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinWidth = width > mSkin->getMinWidth()
? width : mSkin->getMinWidth();
@@ -579,7 +579,7 @@ void Window::setMinWidth(const int width)
void Window::setMinHeight(const int height)
{
- if (mSkin)
+ if (mSkin != nullptr)
{
mMinWinHeight = height > mSkin->getMinHeight()
? height : mSkin->getMinHeight();
@@ -605,12 +605,12 @@ void Window::setResizable(const bool r)
if ((mGrip != nullptr) == r)
return;
- if (mGrip)
+ if (mGrip != nullptr)
mGrip->decRef();
if (r)
{
mGrip = Theme::getImageFromThemeXml("resize.xml", "");
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight()
@@ -632,26 +632,26 @@ void Window::widgetResized(const Event &event A_UNUSED)
{
const Rect area = getChildrenArea();
- if (mGrip)
+ if (mGrip != nullptr)
{
mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
}
- if (mLayout)
+ if (mLayout != nullptr)
{
int w = area.width;
int h = area.height;
mLayout->reflow(w, h);
}
- if (mSkin)
+ if (mSkin != nullptr)
{
const bool showClose = mCloseWindowButton
- && mSkin->getCloseImage(false);
+ && (mSkin->getCloseImage(false) != nullptr);
if (showClose)
{
const Image *const button = mSkin->getCloseImage(false);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
@@ -663,7 +663,7 @@ void Window::widgetResized(const Event &event A_UNUSED)
if (mStickyButton)
{
const Image *const button = mSkin->getStickyImage(mSticky);
- if (button)
+ if (button != nullptr)
{
const int buttonWidth = button->getWidth();
int x = mDimension.width - buttonWidth
@@ -709,10 +709,10 @@ void Window::widgetHidden(const Event &event A_UNUSED)
mTextChanged = true;
mRedraw = true;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
- if (!mFocusHandler)
+ if (mFocusHandler == nullptr)
return;
for (WidgetListConstIterator it = mWidgets.begin();
@@ -732,7 +732,7 @@ void Window::setCloseButton(const bool flag)
bool Window::isResizable() const
{
- return mGrip;
+ return mGrip != nullptr;
}
void Window::setStickyButton(const bool flag)
@@ -781,11 +781,11 @@ void Window::setVisible(const Visible visible, const bool forceSticky)
{
if (mPlayVisibleSound)
soundManager.playGuiSound(SOUND_SHOW_WINDOW);
- if (gui)
+ if (gui != nullptr)
{
MouseEvent *const event = reinterpret_cast<MouseEvent*>(
gui->createMouseEvent(this));
- if (event)
+ if (event != nullptr)
{
const int x = event->getX();
const int y = event->getY();
@@ -817,7 +817,7 @@ void Window::mousePressed(MouseEvent &event)
if (event.getSource() == this)
{
- if (getParent())
+ if (getParent() != nullptr)
getParent()->moveToTop(this);
mDragOffsetX = event.getX();
@@ -832,21 +832,25 @@ void Window::mousePressed(MouseEvent &event)
const int y = event.getY();
// Handle close button
- if (mCloseWindowButton && mSkin && mCloseRect.isPointInRect(x, y))
+ if (mCloseWindowButton &&
+ mSkin != nullptr &&
+ mCloseRect.isPointInRect(x, y))
{
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
close();
return;
}
// Handle sticky button
- if (mStickyButton && mSkin && mStickyRect.isPointInRect(x, y))
+ if (mStickyButton &&
+ mSkin != nullptr &&
+ mStickyRect.isPointInRect(x, y))
{
setSticky(!isSticky());
mouseResize = 0;
- mMoved = 0;
+ mMoved = false;
event.consume();
return;
}
@@ -856,14 +860,14 @@ void Window::mousePressed(MouseEvent &event)
if (mouseResize != 0)
event.consume();
if (canMove())
- mMoved = !mouseResize;
+ mMoved = (mouseResize == 0);
else
mMoved = false;
}
#ifndef DYECMD
else if (button == MouseButton::RIGHT)
{
- if (popupMenu)
+ if (popupMenu != nullptr)
{
event.consume();
popupMenu->showWindowPopup(this);
@@ -879,10 +883,10 @@ void Window::close()
void Window::mouseReleased(MouseEvent &event A_UNUSED)
{
- if (mGrip && mouseResize)
+ if ((mGrip != nullptr) && (mouseResize != 0))
{
mouseResize = 0;
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
}
@@ -896,13 +900,13 @@ void Window::mouseEntered(MouseEvent &event)
void Window::mouseExited(MouseEvent &event A_UNUSED)
{
- if (mGrip && !mouseResize && gui)
+ if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
gui->setCursorType(Cursor::CURSOR_POINTER);
}
void Window::updateResizeHandler(MouseEvent &event)
{
- if (!gui)
+ if (gui == nullptr)
return;
#ifndef DYECMD
@@ -940,7 +944,7 @@ void Window::updateResizeHandler(MouseEvent &event)
void Window::mouseMoved(MouseEvent &event)
{
updateResizeHandler(event);
- if (popupManager && !event.isConsumed())
+ if ((popupManager != nullptr) && !event.isConsumed())
{
popupManager->hideBeingPopup();
popupManager->hideTextPopup();
@@ -983,31 +987,31 @@ void Window::mouseDragged(MouseEvent &event)
std::max(0, mDimension.y)));
}
- if (mouseResize && !mMoved)
+ if ((mouseResize != 0) && !mMoved)
{
const int dx = event.getX() - mDragOffsetX;
const int dy = event.getY() - mDragOffsetY;
Rect newDim = getDimension();
- if (mouseResize & (TOP | BOTTOM))
+ if ((mouseResize & (TOP | BOTTOM)) != 0)
{
const int newHeight = newDim.height
- + ((mouseResize & TOP) ? -dy : dy);
+ + ((mouseResize & TOP) != 0 ? -dy : dy);
newDim.height = std::min(mMaxWinHeight,
std::max(mMinWinHeight, newHeight));
- if (mouseResize & TOP)
+ if ((mouseResize & TOP) != 0)
newDim.y -= newDim.height - getHeight();
}
- if (mouseResize & (LEFT | RIGHT))
+ if ((mouseResize & (LEFT | RIGHT)) != 0)
{
const int newWidth = newDim.width
- + ((mouseResize & LEFT) ? -dx : dx);
+ + ((mouseResize & LEFT) != 0 ? -dx : dx);
newDim.width = std::min(mMaxWinWidth,
std::max(mMinWinWidth, newWidth));
- if (mouseResize & LEFT)
+ if ((mouseResize & LEFT) != 0)
newDim.x -= newDim.width - mDimension.width;
}
@@ -1028,10 +1032,10 @@ void Window::mouseDragged(MouseEvent &event)
newDim.height = mainGraphics->mHeight - newDim.y;
// Update mouse offset when dragging bottom or right border
- if (mouseResize & BOTTOM)
+ if ((mouseResize & BOTTOM) != 0)
mDragOffsetY += newDim.height - mDimension.height;
- if (mouseResize & RIGHT)
+ if ((mouseResize & RIGHT) != 0)
mDragOffsetX += newDim.width - mDimension.width;
// Set the new window and content dimensions
@@ -1046,7 +1050,7 @@ void Window::setModal(const Modal modal)
mModal = modal;
if (mModal == Modal_true)
{
- if (gui)
+ if (gui != nullptr)
gui->setCursorType(Cursor::CURSOR_POINTER);
requestModalFocus();
}
@@ -1078,7 +1082,7 @@ void Window::loadWindowState()
+ "Sticky", isSticky()));
}
- if (mGrip)
+ if (mGrip != nullptr)
{
int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
@@ -1102,7 +1106,7 @@ void Window::loadWindowState()
// Check if the window is off screen...
ensureOnScreen();
- if (viewport)
+ if (viewport != nullptr)
{
int width = mDimension.width;
int height = mDimension.height;
@@ -1133,7 +1137,7 @@ void Window::saveWindowState()
if (mStickyButton)
config.setValue(mWindowName + "Sticky", isSticky());
- if (mGrip)
+ if (mGrip != nullptr)
{
if (getMinWidth() > mDimension.width)
setWidth(getMinWidth());
@@ -1257,7 +1261,7 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth,
void Window::adjustSizeToScreen()
{
- if (!mGrip)
+ if (mGrip == nullptr)
return;
const int screenWidth = mainGraphics->mWidth;
@@ -1289,7 +1293,7 @@ int Window::getResizeHandles(const MouseEvent &event)
if (!mStickyButtonLock || !mSticky)
{
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > mTitleBarHeight ||
(CAST_S32(y) < mPadding &&
CAST_S32(mTitleBarHeight) > mPadding)))
@@ -1319,7 +1323,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
{
const int y = event.getY();
- if (mGrip &&
+ if ((mGrip != nullptr) &&
(y > CAST_S32(mTitleBarHeight) ||
y < mPadding))
{
@@ -1337,7 +1341,7 @@ bool Window::isResizeAllowed(const MouseEvent &event) const
Layout &Window::getLayout()
{
- if (!mLayout)
+ if (mLayout == nullptr)
mLayout = new Layout;
return *mLayout;
}
@@ -1347,7 +1351,7 @@ void Window::clearLayout()
clear();
// Recreate layout instance when one is present
- if (mLayout)
+ if (mLayout != nullptr)
{
delete mLayout;
mLayout = new Layout;
@@ -1368,7 +1372,7 @@ ContainerPlacer Window::getPlacer(const int x, const int y)
void Window::reflowLayout(int w, int h)
{
- if (!mLayout)
+ if (mLayout == nullptr)
return;
mLayout->reflow(w, h);
@@ -1378,7 +1382,7 @@ void Window::reflowLayout(int w, int h)
void Window::redraw()
{
- if (mLayout)
+ if (mLayout != nullptr)
{
const Rect area = getChildrenArea();
int w = area.width;
@@ -1426,10 +1430,10 @@ Rect Window::getWindowArea() const
int Window::getOption(const std::string &name, const int def) const
{
- if (mSkin)
+ if (mSkin != nullptr)
{
const int val = mSkin->getOption(name);
- if (val)
+ if (val != 0)
return val;
return def;
}
@@ -1438,8 +1442,8 @@ int Window::getOption(const std::string &name, const int def) const
bool Window::getOptionBool(const std::string &name, const bool def) const
{
- if (mSkin)
- return mSkin->getOption(name, def) != 0;
+ if (mSkin != nullptr)
+ return mSkin->getOption(name, static_cast<int>(def)) != 0;
return def;
}
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index 9529945b0..38efd1a77 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -44,7 +44,7 @@ void WindowContainer::slowLogic()
void WindowContainer::scheduleDelete(Widget *const widget)
{
- if (widget)
+ if (widget != nullptr)
mDeathList.push_back(widget);
}