summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/socialwindow.cpp166
1 files changed, 1 insertions, 165 deletions
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index b2cc5610f..e878e0368 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -58,6 +58,7 @@
#include "gui/widgets/tabs/socialguildtab.h"
#include "gui/widgets/tabs/socialguildtab2.h"
#include "gui/widgets/tabs/socialpartytab.h"
+#include "gui/widgets/tabs/socialplayerstab.h"
#include "net/net.h"
#include "net/guildhandler.h"
@@ -97,171 +98,6 @@ namespace
} friendSorter;
} // namespace
-class SocialPlayersTab final : public SocialTab
-{
-public:
- SocialPlayersTab(const Widget2 *const widget,
- std::string name,
- const bool showBackground) :
- SocialTab(widget),
- mBeings(new BeingsListModel)
- {
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
-
- getPlayersAvatars();
- setCaption(name);
- }
-
- A_DELETE_COPY(SocialPlayersTab)
-
- ~SocialPlayersTab()
- {
- delete2(mList)
- delete2(mScroll)
- delete2(mBeings)
- }
-
- void updateList() override final
- {
- getPlayersAvatars();
- }
-
- void updateAvatar(const std::string &name) override final
- {
- if (!actorManager)
- return;
-
- Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
- return;
- if (Party::getParty(1))
- {
- const PartyMember *const pm = Party::getParty(1)->getMember(name);
- if (pm && pm->getMaxHp() > 0)
- {
- avatar->setMaxHp(pm->getMaxHp());
- avatar->setHp(pm->getHp());
- }
- }
- const Being *const being = actorManager->findBeingByName(
- name, ActorType::PLAYER);
- if (being)
- {
- avatar->setDamageHp(being->getDamageTaken());
- avatar->setLevel(being->getLevel());
- avatar->setGender(being->getGender());
- avatar->setIp(being->getIp());
- avatar->setPoison(being->getPoison());
- }
- }
-
- void resetDamage(const std::string &name) override final
- {
- if (!actorManager)
- return;
-
- Avatar *const avatar = findAvatarbyName(name);
- if (!avatar)
- return;
- avatar->setDamageHp(0);
- Being *const being = actorManager->findBeingByName(
- name, ActorType::PLAYER);
-
- if (being)
- being->setDamageTaken(0);
- }
-
- Avatar* findAvatarbyName(const std::string &name)
- {
- std::vector<Avatar*> *const avatars = mBeings->getMembers();
- if (!avatars)
- return nullptr;
-
- Avatar *ava = nullptr;
- std::vector<Avatar*>::const_iterator i = avatars->begin();
- const std::vector<Avatar*>::const_iterator i_end = avatars->end();
- while (i != i_end)
- {
- ava = (*i);
- if (ava && ava->getName() == name)
- return ava;
- ++i;
- }
- ava = new Avatar(name);
- ava->setOnline(true);
- avatars->push_back(ava);
- return ava;
- }
-
- void getPlayersAvatars()
- {
- std::vector<Avatar*> *const avatars = mBeings->getMembers();
- if (!avatars)
- return;
-
- if (actorManager)
- {
- StringVect names;
- actorManager->getPlayerNames(names, false);
-
- std::vector<Avatar*>::iterator ai = avatars->begin();
- while (ai != avatars->end())
- {
- bool finded = false;
- const Avatar *const ava = (*ai);
- if (!ava)
- break;
-
- StringVectCIter i = names.begin();
- const StringVectCIter i_end = names.end();
- while (i != i_end)
- {
- if (ava->getName() == (*i) && (*i) != "")
- {
- finded = true;
- break;
- }
- ++i;
- }
-
- if (!finded)
- {
- delete *ai;
- ai = avatars->erase(ai);
- }
- else
- {
- ++ai;
- }
- }
-
- StringVectCIter i = names.begin();
- const StringVectCIter i_end = names.end();
-
- while (i != i_end)
- {
- if ((*i) != "")
- updateAvatar(*i);
- ++i;
- }
- }
- // TRANSLATORS: social window label
- mCounterString = strprintf(_("Visible players: %d"),
- static_cast<int>(avatars->size()));
- updateCounter();
- }
-
-private:
- BeingsListModel *mBeings;
-};
-
-
class SocialNavigationTab final : public SocialTab
{
public: