diff options
Diffstat (limited to 'src/gui/windows')
-rw-r--r-- | src/gui/windows/socialwindow.cpp | 277 |
1 files changed, 1 insertions, 276 deletions
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index e878e0368..987e0639b 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -57,6 +57,7 @@ #include "gui/widgets/tabs/chattab.h" #include "gui/widgets/tabs/socialguildtab.h" #include "gui/widgets/tabs/socialguildtab2.h" +#include "gui/widgets/tabs/socialnavigationtab.h" #include "gui/widgets/tabs/socialpartytab.h" #include "gui/widgets/tabs/socialplayerstab.h" @@ -98,282 +99,6 @@ namespace } friendSorter; } // namespace -class SocialNavigationTab final : public SocialTab -{ -public: - SocialNavigationTab(const Widget2 *const widget, - 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); - - // TRANSLATORS: Navigation tab name in social window. Should be small - setCaption(_("Nav")); - } - - A_DELETE_COPY(SocialNavigationTab) - - ~SocialNavigationTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - if (!socialWindow || !player_node) - return; - - const Map *const map = socialWindow->getMap(); - if (!map || map->empty()) - return; - - if (socialWindow->getProcessedPortals()) - return; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - std::vector<MapItem*> portals = map->getPortals(); - - std::vector<MapItem*>::const_iterator i = portals.begin(); - const SpecialLayer *const specialLayer = map->getSpecialLayer(); - - std::vector<Avatar*>::iterator ia = avatars->begin(); - - while (ia != avatars->end()) - { - delete *ia; - ++ ia; - } - - avatars->clear(); - - int online = 0; - int total = 0; - - int idx = 0; - while (i != portals.end()) - { - MapItem *portal = *i; - if (!portal) - continue; - - const int x = portal->getX(); - const int y = portal->getY(); - - const std::string name = strprintf("%s [%d %d]", - portal->getComment().c_str(), x, y); - - Avatar *const ava = new Avatar(name); - if (player_node) - ava->setOnline(player_node->isReachable(x, y, true)); - else - ava->setOnline(false); - ava->setLevel(-1); - ava->setType(portal->getType()); - ava->setX(x); - ava->setY(y); - avatars->push_back(ava); - - if (ava->getOnline()) - online ++; - total ++; - - if (config.getBoolValue("drawHotKeys") && idx < 80 && outfitWindow) - { - Being *const being = actorManager - ->findPortalByTile(x, y); - if (being) - { - being->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); - } - - if (specialLayer) - { - portal = specialLayer->getTile(ava->getX(), ava->getY()); - if (portal) - { - portal->setName(keyboard.getKeyShortString( - outfitWindow->keyName(idx))); - } - } - } - - ++i; - idx ++; - } - if (socialWindow) - socialWindow->setProcessedPortals(true); - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Portals: %u/%u"), - static_cast<uint32_t>(online), - static_cast<uint32_t>(total)); - updateCounter(); - } - - - void selectIndex(const unsigned num) override final - { - if (!player_node) - return; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars || avatars->size() <= static_cast<size_t>(num)) - return; - - const Avatar *const ava = avatars->at(num); - if (ava && player_node) - player_node->navigateTo(ava->getX(), ava->getY()); - } - - void updateNames() - { - if (!socialWindow) - return; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return; - - const Map *const map = socialWindow->getMap(); - if (!map) - return; - - std::vector<Avatar*>::const_iterator i = avatars->begin(); - const std::vector<Avatar*>::const_iterator i_end = avatars->end(); - while (i != i_end) - { - Avatar *const ava = *i; - if (!ava) - break; - - const MapItem *const item = map->findPortalXY( - ava->getX(), ava->getY()); - if (item) - { - const std::string name = strprintf("%s [%d %d]", - item->getComment().c_str(), item->getX(), item->getY()); - ava->setName(name); - ava->setOriginalName(name); - } - - ++i; - } - } - - int getPortalIndex(const int x, const int y) - { - if (!socialWindow) - return -1; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return -1; - - const Map *const map = socialWindow->getMap(); - if (!map) - return -1; - - std::vector<Avatar*>::const_iterator i = avatars->begin(); - const std::vector<Avatar*>::const_iterator i_end = avatars->end(); - unsigned num = 0; - while (i != i_end) - { - const Avatar *const ava = *i; - if (!ava) - break; - - if (ava->getX() == x && ava->getY() == y) - return num; - - ++i; - num ++; - } - return -1; - } - - void addPortal(const int x, const int y) - { - if (!socialWindow || !player_node) - return; - - const Map *const map = socialWindow->getMap(); - if (!map) - return; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - - if (!avatars) - return; - - const MapItem *const portal = map->findPortalXY(x, y); - if (!portal) - return; - - const std::string name = strprintf("%s [%d %d]", - portal->getComment().c_str(), x, y); - - Avatar *const ava = new Avatar(name); - if (player_node) - ava->setOnline(player_node->isReachable(x, y, true)); - else - ava->setOnline(false); - ava->setLevel(-1); - ava->setType(portal->getType()); - ava->setX(x); - ava->setY(y); - avatars->push_back(ava); - } - - void removePortal(const int x, const int y) - { - if (!socialWindow || !player_node) - return; - - const Map *const map = socialWindow->getMap(); - if (!map) - return; - - std::vector<Avatar*> *const avatars = mBeings->getMembers(); - - if (!avatars) - return; - - std::vector<Avatar*>::iterator i = avatars->begin(); - const std::vector<Avatar*>::iterator i_end = avatars->end(); - - while (i != i_end) - { - Avatar *ava = (*i); - - if (!ava) - break; - - if (ava->getX() == x && ava->getY() == y) - { - delete ava; - avatars->erase(i); - return; - } - - ++ i; - } - } - -private: - BeingsListModel *mBeings; -}; - - #define addAvatars(mob, str, type) \ {\ ava = new Avatar(str);\ |