summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/dialogsmanager.cpp21
-rw-r--r--src/gui/fonts/font.cpp3
-rw-r--r--src/gui/gui.cpp3
-rw-r--r--src/gui/models/playertablemodel.cpp6
-rw-r--r--src/gui/models/skillmodel.cpp3
-rw-r--r--src/gui/models/worldlistmodel.h5
-rw-r--r--src/gui/popups/popupmenu.cpp3
-rw-r--r--src/gui/skin.h6
-rw-r--r--src/gui/theme.cpp5
-rw-r--r--src/gui/viewport.cpp106
-rw-r--r--src/gui/widgets/attrs/attrdisplay.h3
-rw-r--r--src/gui/widgets/button.cpp3
-rw-r--r--src/gui/widgets/guitable.cpp13
-rw-r--r--src/gui/widgets/itemcontainer.cpp3
-rw-r--r--src/gui/widgets/setupitem.cpp3
-rw-r--r--src/gui/widgets/tabbedarea.cpp9
-rw-r--r--src/gui/widgets/textbox.cpp6
-rw-r--r--src/gui/widgets/widget2.h3
-rw-r--r--src/gui/windows/chatwindow.cpp11
-rw-r--r--src/gui/windows/emotewindow.cpp3
-rw-r--r--src/gui/windows/socialwindow.cpp5
-rw-r--r--src/gui/windows/tradewindow.cpp9
-rw-r--r--src/gui/windows/whoisonline.cpp7
23 files changed, 95 insertions, 144 deletions
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index 9b2335736..979db937d 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -122,18 +122,15 @@ Window *DialogsManager::openErrorDialog(const std::string &header,
260);
return dialog;
}
- else
- {
- ConfirmDialog *const dialog = CREATEWIDGETR(ConfirmDialog,
- header,
- strprintf("%s %s", message.c_str(),
- // TRANSLATORS: error message question
- _("Do you want to open support page?")),
- SOUND_ERROR,
- false,
- modal);
- return dialog;
- }
+ ConfirmDialog *const dialog = CREATEWIDGETR(ConfirmDialog,
+ header,
+ strprintf("%s %s", message.c_str(),
+ // TRANSLATORS: error message question
+ _("Do you want to open support page?")),
+ SOUND_ERROR,
+ false,
+ modal);
+ return dialog;
}
void DialogsManager::playerDeath()
diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp
index 78c243a70..a2919481c 100644
--- a/src/gui/fonts/font.cpp
+++ b/src/gui/fonts/font.cpp
@@ -347,8 +347,7 @@ int Font::getWidth(const std::string &text) const
const Image *const image = chunk->img;
if (image != nullptr)
return image->getWidth();
- else
- return 0;
+ return 0;
}
// if string was not drawed
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index c27aeec35..67735e2a6 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -388,8 +388,7 @@ bool Gui::handleInput()
{
if (mInput != nullptr)
return handleKeyInput();
- else
- return false;
+ return false;
}
bool Gui::handleKeyInput()
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
index 417fafcbc..271b6a5bb 100644
--- a/src/gui/models/playertablemodel.cpp
+++ b/src/gui/models/playertablemodel.cpp
@@ -68,8 +68,7 @@ int PlayerTableModel::getRows() const
{
if (mPlayers != nullptr)
return CAST_S32(mPlayers->size());
- else
- return 0;
+ return 0;
}
int PlayerTableModel::getColumns() const
@@ -86,8 +85,7 @@ int PlayerTableModel::getColumnWidth(const int index) const
{
if (index == NAME_COLUMN)
return NAME_COLUMN_WIDTH;
- else
- return RELATION_CHOICE_COLUMN_WIDTH;
+ return RELATION_CHOICE_COLUMN_WIDTH;
}
void PlayerTableModel::playerRelationsUpdated()
diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp
index 0dcf9cedd..4d22280d8 100644
--- a/src/gui/models/skillmodel.cpp
+++ b/src/gui/models/skillmodel.cpp
@@ -47,8 +47,7 @@ std::string SkillModel::getElementAt(int i)
const SkillInfo *const info = getSkillAt(i);
if (info != nullptr)
return info->data->name;
- else
- return std::string();
+ return std::string();
}
void SkillModel::updateVisibilities()
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
index 9ae5a5e22..3be179c61 100644
--- a/src/gui/models/worldlistmodel.h
+++ b/src/gui/models/worldlistmodel.h
@@ -59,10 +59,7 @@ class WorldListModel final : public ListModel
return std::string(si->name).append(" (").append(
toString(si->online_users)).append(")");
}
- else
- {
- return "???";
- }
+ return "???";
}
private:
Worlds mWorlds;
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 18d2fd236..2ba797bf9 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -195,8 +195,7 @@ bool PopupMenu::isAllowOtherCommand(const ServerCommandTypeT command)
mGroup->mCommands[CAST_SIZE(command)];
if (mName == localPlayer->getName())
return (enabled & ServerCommandEnable::Self) != 0;
- else
- return (enabled & ServerCommandEnable::Other) != 0;
+ return (enabled & ServerCommandEnable::Other) != 0;
}
void PopupMenu::showPopup(const int x, const int y, const Being *const being)
diff --git a/src/gui/skin.h b/src/gui/skin.h
index 55f2b79a7..acba303ac 100644
--- a/src/gui/skin.h
+++ b/src/gui/skin.h
@@ -106,8 +106,7 @@ class Skin final
{
if (mOptions->find(name) != mOptions->end())
return (*mOptions)[name];
- else
- return 0;
+ return 0;
}
int getOption(const std::string &name,
@@ -115,8 +114,7 @@ class Skin final
{
if (mOptions->find(name) != mOptions->end())
return (*mOptions)[name];
- else
- return def;
+ return def;
}
int instances;
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 1ce1b7e30..503c3c86a 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -71,10 +71,7 @@ static void initDefaultThemePath()
{
return;
}
- else
- {
- defaultThemePath = "themes/";
- }
+ defaultThemePath = "themes/";
}
Theme::Theme() :
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index c77232591..168ec317a 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -441,71 +441,69 @@ bool Viewport::leftMouseAction()
mHoverBeing->talkTo();
return true;
}
- else
+
+ const ActorTypeT type = mHoverBeing->getType();
+ switch (type)
{
- const ActorTypeT type = mHoverBeing->getType();
- switch (type)
- {
- case ActorType::Player:
- validateSpeed();
- if (actorManager != nullptr)
- {
+ case ActorType::Player:
+ validateSpeed();
+ if (actorManager != nullptr)
+ {
#ifdef TMWA_SUPPORT
- if (localPlayer != mHoverBeing || mSelfMouseHeal)
- actorManager->heal(mHoverBeing);
+ if (localPlayer != mHoverBeing || mSelfMouseHeal)
+ actorManager->heal(mHoverBeing);
#endif // TMWA_SUPPORT
- if (localPlayer == mHoverBeing &&
- mHoverItem != nullptr)
- {
- localPlayer->pickUp(mHoverItem);
- }
- return true;
+ if (localPlayer == mHoverBeing &&
+ mHoverItem != nullptr)
+ {
+ localPlayer->pickUp(mHoverItem);
}
- break;
- case ActorType::Monster:
- case ActorType::Npc:
- case ActorType::SkillUnit:
- if (!stopAttack)
+ return true;
+ }
+ break;
+ case ActorType::Monster:
+ case ActorType::Npc:
+ case ActorType::SkillUnit:
+ if (!stopAttack)
+ {
+ if ((localPlayer->withinAttackRange(mHoverBeing) ||
+ inputManager.isActionActive(InputAction::ATTACK)))
{
- if ((localPlayer->withinAttackRange(mHoverBeing) ||
- inputManager.isActionActive(InputAction::ATTACK)))
+ validateSpeed();
+ if (!mStatsReUpdated && localPlayer != mHoverBeing)
{
- validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
- {
- localPlayer->attack(mHoverBeing,
- !inputManager.isActionActive(
- InputAction::STOP_ATTACK));
- return true;
- }
+ localPlayer->attack(mHoverBeing,
+ !inputManager.isActionActive(
+ InputAction::STOP_ATTACK));
+ return true;
}
- else if (!inputManager.isActionActive(
- InputAction::ATTACK))
+ }
+ else if (!inputManager.isActionActive(
+ InputAction::ATTACK))
+ {
+ validateSpeed();
+ if (!mStatsReUpdated && localPlayer != mHoverBeing)
{
- validateSpeed();
- if (!mStatsReUpdated && localPlayer != mHoverBeing)
- {
- localPlayer->setGotoTarget(mHoverBeing);
- return true;
- }
+ localPlayer->setGotoTarget(mHoverBeing);
+ return true;
}
}
- break;
- case ActorType::FloorItem:
- case ActorType::Portal:
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::Elemental:
- break;
- case ActorType::Unknown:
- case ActorType::Avatar:
- default:
- reportAlways("Left click on unknown actor type: %d",
- CAST_S32(type));
- break;
- }
+ }
+ break;
+ case ActorType::FloorItem:
+ case ActorType::Portal:
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::Homunculus:
+ case ActorType::Elemental:
+ break;
+ case ActorType::Unknown:
+ case ActorType::Avatar:
+ default:
+ reportAlways("Left click on unknown actor type: %d",
+ CAST_S32(type));
+ break;
}
}
// Picks up a item if we clicked on one
diff --git a/src/gui/widgets/attrs/attrdisplay.h b/src/gui/widgets/attrs/attrdisplay.h
index 1641bac9f..f682e41f5 100644
--- a/src/gui/widgets/attrs/attrdisplay.h
+++ b/src/gui/widgets/attrs/attrdisplay.h
@@ -56,8 +56,7 @@ class AttrDisplay notfinal : public Container
{
if (mValue == nullptr)
return "-";
- else
- return mValue->getCaption();
+ return mValue->getCaption();
}
const std::string &getShortName() const
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 3509b927c..df46014a3 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -880,8 +880,7 @@ bool Button::isPressed() const
{
if (mMousePressed)
return mHasMouse;
- else
- return mKeyPressed;
+ return mKeyPressed;
}
void Button::focusLost(const Event& event A_UNUSED)
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 9ff2075b1..4a0f88246 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -608,13 +608,10 @@ Widget *GuiTable::getWidgetAt(int x, int y)
if (row > -1 && column > -1)
{
Widget *const w = mModel->getElementAt(row, column);
- if ((w != nullptr) && w->isFocusable())
+ if (w != nullptr && w->isFocusable())
return w;
- else
- return nullptr; // Grab the event locally
}
- else
- return nullptr;
+ return nullptr;
}
int GuiTable::getRowForY(const int y) const
@@ -627,8 +624,7 @@ int GuiTable::getRowForY(const int y) const
if (row < 0 || row >= mModel->getRows())
return -1;
- else
- return row;
+ return row;
}
int GuiTable::getColumnForX(const int x) const
@@ -646,8 +642,7 @@ int GuiTable::getColumnForX(const int x) const
if (column < 0 || column >= colnum)
return -1;
- else
- return column;
+ return column;
}
void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 4b70c86b7..3d5c3829f 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -596,8 +596,7 @@ Item *ItemContainer::getSelectedItem() const
{
if (mInventory != nullptr)
return mInventory->getItem(mSelectedIndex);
- else
- return nullptr;
+ return nullptr;
}
void ItemContainer::distributeValueChangedEvent()
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index e4b40f9be..ee19caed1 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -104,8 +104,7 @@ Configuration *SetupItem::getConfig() const
{
if (mMainConfig == MainConfig_true)
return &config;
- else
- return &serverConfig;
+ return &serverConfig;
}
void SetupItem::load()
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index ced56cea0..e89f60418 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -223,8 +223,7 @@ Widget *TabbedArea::getCurrentWidget() const
if (tab != nullptr)
return getWidget(tab->getCaption());
- else
- return nullptr;
+ return nullptr;
}
void TabbedArea::addTab(Tab *const tab,
@@ -779,9 +778,8 @@ void TabbedArea::keyPressed(KeyEvent& event)
if (index < 0)
return;
- else
- setSelectedTab(mTabs[index].first);
+ setSelectedTab(mTabs[index].first);
event.consume();
}
else if (actionId == InputAction::GUI_RIGHT)
@@ -791,9 +789,8 @@ void TabbedArea::keyPressed(KeyEvent& event)
if (index >= CAST_S32(mTabs.size()))
return;
- else
- setSelectedTab(mTabs[index].first);
+ setSelectedTab(mTabs[index].first);
event.consume();
}
}
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 31e000082..5d1696835 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -529,10 +529,8 @@ void TextBox::setCaretPosition(unsigned int position)
mCaretColumn = position;
return; // we are done
}
- else
- {
- position--;
- }
+
+ position--;
}
// position beyond end of text
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index ed9110ba4..12103e317 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -57,8 +57,7 @@ class Widget2 notfinal
const ThemeColorIdT colorId = theme->getIdByChar(c, valid);
if (valid)
return theme->getColor(colorId + mPaletteOffset, 255U);
- else
- return Palette::BLACK;
+ return Palette::BLACK;
}
virtual void setWidget2(const Widget2 *const widget)
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 7992c6262..a3032de54 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -878,10 +878,8 @@ void ChatWindow::keyPressed(KeyEvent &event)
mChatInput->setCaretPosition(0);
return;
}
- else
- {
- mChatHistoryIndex --;
- }
+
+ mChatHistoryIndex --;
unsigned int f = 0;
const std::list<std::string> &rows = tab->getRows();
@@ -1313,10 +1311,7 @@ ChatTab *ChatWindow::addChatTab(const std::string &name,
chatHandler->joinChannel(name);
return tab;
}
- else
- {
- return addWhisperTab(name, name, switchTo);
- }
+ return addWhisperTab(name, name, switchTo);
}
void ChatWindow::postConnection()
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index e82d9986f..f4f720535 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -233,8 +233,7 @@ std::string EmoteWindow::getSelectedFont() const
if (index == 0)
return "##b";
- else
- return "##B";
+ return "##B";
}
void EmoteWindow::clearFont()
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index b6b635c1c..aa240498d 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -542,10 +542,7 @@ int SocialWindow::getPortalIndex(const int x, const int y)
return static_cast<SocialNavigationTab*>(
mNavigation)->getPortalIndex(x, y);
}
- else
- {
- return -1;
- }
+ return -1;
}
void SocialWindow::addPortal(const int x, const int y)
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index b86d86aa3..143a625e7 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -174,12 +174,9 @@ void TradeWindow::setMoney(const int amount)
close();
return;
}
- else
- {
- mMoneyLabel->setForegroundColorAll(
- getThemeColor(ThemeColorId::WARNING),
- getThemeColor(ThemeColorId::WARNING_OUTLINE));
- }
+ mMoneyLabel->setForegroundColorAll(
+ getThemeColor(ThemeColorId::WARNING),
+ getThemeColor(ThemeColorId::WARNING_OUTLINE));
}
else
{
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 79fe66a4f..1401ec280 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -776,11 +776,8 @@ const std::string WhoIsOnline::prepareNick(const std::string &restrict nick,
return strprintf("@@%s|##%s%s (%d)@@", text.c_str(),
color.c_str(), text.c_str(), level);
}
- else
- {
- return strprintf("@@%s|##%s%s@@", text.c_str(),
- color.c_str(), text.c_str());
- }
+ return strprintf("@@%s|##%s%s@@", text.c_str(),
+ color.c_str(), text.c_str());
}
void WhoIsOnline::optionChanged(const std::string &name)