summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2024-04-07 21:20:55 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-04-09 17:48:28 +0200
commit6101c30189e979a97d07a9bdd7274e8a4ca403a8 (patch)
tree5e41033f1b0a84bafe5f7ba4cea68f988f886768
parent6f102137fc36447b7ce29fd065581a1f6f996fc6 (diff)
downloadmana-6101c30189e979a97d07a9bdd7274e8a4ca403a8.tar.gz
mana-6101c30189e979a97d07a9bdd7274e8a4ca403a8.tar.bz2
mana-6101c30189e979a97d07a9bdd7274e8a4ca403a8.tar.xz
mana-6101c30189e979a97d07a9bdd7274e8a4ca403a8.zip
Add player list tab
-rw-r--r--src/gui/socialwindow.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 9ba64e9f..f15140ff 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -47,6 +47,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
+#include "widgets/avatarlistbox.h"
#include <memory>
@@ -231,6 +232,54 @@ private:
Party *mParty;
};
+class PlayerList : public AvatarListModel
+{
+public:
+
+ /**
+ * Get size of members list.
+ * @return Returns the number of members in the party.
+ */
+ int getNumberOfElements() override {
+ return mPlayers.size();
+ }
+
+ Avatar *getAvatarAt(int index) override {
+ return mPlayers[index];
+ }
+
+private:
+ std::vector<Avatar*> mPlayers;
+};
+
+class PlayerListTab : public SocialTab
+{
+public:
+ PlayerListTab()
+ {
+ setCaption("Online Players");
+
+ mPlayerList = new PlayerList;
+
+ mList = std::make_unique<AvatarListBox>(mPlayerList);
+ mScroll = std::make_unique<ScrollArea>(mList.get());
+
+ mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ }
+ ~PlayerListTab()
+ {
+ delete mPlayerList;
+ }
+
+protected:
+ void invite() override {}
+ void leave() override {}
+
+private:
+ PlayerList *mPlayerList;
+};
+
/*class BuddyTab : public SocialTab
{
// TODO?
@@ -316,6 +365,9 @@ SocialWindow::SocialWindow() :
mCreatePopup = new CreatePopup();
+ auto *tab = new PlayerListTab();
+ mTabs->addTab(tab, tab->mScroll.get());
+
if (local_player->getParty())
{
addTab(local_player->getParty());