summaryrefslogtreecommitdiff
path: root/src/gui/socialwindow.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-12 13:24:16 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-12 21:23:10 +0100
commit306ad2effe4d0897453e61ad787e01dc47c33076 (patch)
tree75b8b291af55e80d01d9eb85afd7d465233a1a57 /src/gui/socialwindow.cpp
parent66599a9896e0cf69b58c0a73152aba4750d87af2 (diff)
downloadmana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.gz
mana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.bz2
mana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.xz
mana-306ad2effe4d0897453e61ad787e01dc47c33076.zip
General code cleanups
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
Diffstat (limited to 'src/gui/socialwindow.cpp')
-rw-r--r--src/gui/socialwindow.cpp45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 96a9c389..00211e02 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -48,6 +48,8 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include <memory>
+
class SocialTab : public Tab
{
protected:
@@ -79,8 +81,8 @@ protected:
TextDialog *mInviteDialog = nullptr;
ConfirmDialog *mConfirmDialog = nullptr;
- ScrollArea *mScroll;
- AvatarListBox *mList;
+ std::unique_ptr<ScrollArea> mScroll;
+ std::unique_ptr<AvatarListBox> mList;
};
class GuildTab : public SocialTab, public gcn::ActionListener
@@ -93,21 +95,13 @@ public:
setTabColor(&Theme::getThemeColor(Theme::GUILD));
- mList = new AvatarListBox(guild);
- mScroll = new ScrollArea(mList);
+ mList = std::make_unique<AvatarListBox>(guild);
+ mScroll = std::make_unique<ScrollArea>(mList.get());
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
}
- ~GuildTab() override
- {
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- }
-
void action(const gcn::ActionEvent &event) override
{
if (event.getId() == "do invite")
@@ -176,21 +170,13 @@ public:
setTabColor(&Theme::getThemeColor(Theme::PARTY_SOCIAL_TAB));
- mList = new AvatarListBox(party);
- mScroll = new ScrollArea(mList);
+ mList = std::make_unique<AvatarListBox>(party);
+ mScroll = std::make_unique<ScrollArea>(mList.get());
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
}
- ~PartyTab() override
- {
- delete mList;
- mList = nullptr;
- delete mScroll;
- mScroll = nullptr;
- }
-
void action(const gcn::ActionEvent &event) override
{
if (event.getId() == "do invite")
@@ -302,10 +288,7 @@ private:
};
SocialWindow::SocialWindow() :
- Window(_("Social")),
- mGuildInvited(0),
- mGuildAcceptDialog(nullptr),
- mPartyAcceptDialog(nullptr)
+ Window(_("Social"))
{
setWindowName("Social");
setVisible(false);
@@ -373,7 +356,7 @@ bool SocialWindow::addTab(Guild *guild)
auto *tab = new GuildTab(guild);
mGuilds[guild] = tab;
- mTabs->addTab(tab, tab->mScroll);
+ mTabs->addTab(tab, tab->mScroll.get());
updateButtons();
@@ -403,7 +386,7 @@ bool SocialWindow::addTab(Party *party)
auto *tab = new PartyTab(party);
mParties[party] = tab;
- mTabs->addTab(tab, tab->mScroll);
+ mTabs->addTab(tab, tab->mScroll.get());
updateButtons();
@@ -490,7 +473,8 @@ void SocialWindow::action(const gcn::ActionEvent &event)
"shorter name."));
return;
}
- else if (!name.empty())
+
+ if (!name.empty())
{
Net::getGuildHandler()->create(name);
SERVER_NOTICE(strprintf(_("Creating guild called %s."),
@@ -513,7 +497,8 @@ void SocialWindow::action(const gcn::ActionEvent &event)
"shorter name."));
return;
}
- else if (!name.empty())
+
+ if (!name.empty())
{
Net::getPartyHandler()->create(name);
SERVER_NOTICE(strprintf(_("Creating party called %s."),