diff options
Diffstat (limited to 'src/gui/widgets/tabs')
-rw-r--r-- | src/gui/widgets/tabs/chattab.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_relations.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialattacktab.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialfriendsfunctor.h | 52 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialfriendstab.h | 37 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialguildtab.h | 13 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialguildtab2.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialnavigationtab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialpartytab.h | 18 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialpickuptab.h | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialplayerstab.h | 3 |
11 files changed, 95 insertions, 52 deletions
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 47787d25d..4f81d2aa7 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -212,10 +212,13 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own, // if configured, move magic messages log to debug chat tab if (localChatTab && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") && own == ChatMsgType::BY_PLAYER - && tmp.text.length() > 1 && tmp.text.at(0) == '#' + && ((config.getBoolValue("showMagicInDebug") + && own == ChatMsgType::BY_PLAYER + && tmp.text.length() > 1 + && tmp.text.at(0) == '#' && tmp.text.at(1) != '#') - || (config.getBoolValue("serverMsgInDebug") && (own == ChatMsgType::BY_SERVER + || (config.getBoolValue("serverMsgInDebug") + && (own == ChatMsgType::BY_SERVER || tmp.nick.empty())))) { if (debugChatTab) diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 723131edc..b14208c3b 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -39,7 +39,6 @@ #include "gui/widgets/guitable.h" #include "utils/delete2.h" -#include "utils/gettext.h" #include "debug.h" diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h index 01921b016..17ee78eb0 100644 --- a/src/gui/widgets/tabs/socialattacktab.h +++ b/src/gui/widgets/tabs/socialattacktab.h @@ -31,8 +31,6 @@ #include "gui/widgets/tabs/socialtabbase.h" -#include "resources/map/mapitem.h" - #include "utils/delete2.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h new file mode 100644 index 000000000..1ad209adb --- /dev/null +++ b/src/gui/widgets/tabs/socialfriendsfunctor.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H +#define GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H + +#include "avatar.h" + +#include "localconsts.h" + +class SortFriendsFunctor final +{ + public: + bool operator() (const Avatar *const m1, + const Avatar *const m2) const + { + if (!m1 || !m2) + return false; + + if (m1->getOnline() != m2->getOnline()) + return m1->getOnline() > m2->getOnline(); + + if (m1->getName() != m2->getName()) + { + std::string s1 = m1->getName(); + std::string s2 = m2->getName(); + toLower(s1); + toLower(s2); + return s1 < s2; + } + return false; + } +}; + +#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index 3d65e2678..0a43c6e2f 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -24,15 +24,15 @@ #include "gui/widgets/tabs/socialtab.h" #include "actormanager.h" -#include "avatar.h" -#include "being/actortype.h" #include "being/playerrelations.h" #include "gui/models/beingslistmodel.h" #include "gui/windows/whoisonline.h" +#include "gui/widgets/tabs/socialfriendsfunctor.h" + #include "utils/delete2.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -41,33 +41,6 @@ #include "localconsts.h" -namespace -{ - static class SortFriendsFunctor final - { - public: - bool operator() (const Avatar *const m1, - const Avatar *const m2) const - { - if (!m1 || !m2) - return false; - - if (m1->getOnline() != m2->getOnline()) - return m1->getOnline() > m2->getOnline(); - - if (m1->getName() != m2->getName()) - { - std::string s1 = m1->getName(); - std::string s2 = m2->getName(); - toLower(s1); - toLower(s2); - return s1 < s2; - } - return false; - } - } friendSorter; -} // namespace - class SocialFriendsTab final : public SocialTab { public: @@ -75,7 +48,8 @@ class SocialFriendsTab final : public SocialTab std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModel) + mBeings(new BeingsListModel), + mFriendSorter() { createControls(mBeings, showBackground); @@ -139,7 +113,7 @@ class SocialFriendsTab final : public SocialTab total ++; avatars->push_back(ava); } - std::sort(avatars->begin(), avatars->end(), friendSorter); + std::sort(avatars->begin(), avatars->end(), mFriendSorter); delete players; // TRANSLATORS: social window label @@ -151,6 +125,7 @@ class SocialFriendsTab final : public SocialTab private: BeingsListModel *mBeings; + SortFriendsFunctor mFriendSorter; }; #endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h index ee40e146f..0347087b7 100644 --- a/src/gui/widgets/tabs/socialguildtab.h +++ b/src/gui/widgets/tabs/socialguildtab.h @@ -54,7 +54,8 @@ class SocialGuildTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -81,7 +82,9 @@ class SocialGuildTab final : public SocialTab, localChatTab->chatLog(strprintf( // TRANSLATORS: chat message _("Invited user %s to guild %s."), - name.c_str(), mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + name.c_str(), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialGuildTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Guild %s quit requested."), - mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Guild %s quit requested."), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h index c5702b17d..ba40d7c4f 100644 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ b/src/gui/widgets/tabs/socialguildtab2.h @@ -52,7 +52,8 @@ class SocialGuildTab2 final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -70,7 +71,8 @@ class SocialGuildTab2 final : public SocialTab, { } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index e8925cbb2..4344e1251 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -204,7 +204,8 @@ class SocialNavigationTab final : public SocialTab if (item) { const std::string name = strprintf("%s [%d %d]", - item->getComment().c_str(), item->getX(), item->getY()); + item->getComment().c_str(), + item->getX(), item->getY()); ava->setName(name); ava->setOriginalName(name); } diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h index 247414851..847a43d42 100644 --- a/src/gui/widgets/tabs/socialpartytab.h +++ b/src/gui/widgets/tabs/socialpartytab.h @@ -55,7 +55,8 @@ class SocialPartyTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::PARTY_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(party, showBackground); @@ -80,8 +81,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Invited user %s to party."), - name.c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Invited user %s to party."), + name.c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: tab in social window - localChatTab->chatLog(strprintf(_("Party %s quit requested."), - mParty->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Party %s quit requested."), + mParty->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } @@ -129,7 +134,8 @@ class SocialPartyTab final : public SocialTab, mConfirmDialog->addActionListener(this); } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h index 15d7c3aeb..3dd4d5959 100644 --- a/src/gui/widgets/tabs/socialpickuptab.h +++ b/src/gui/widgets/tabs/socialpickuptab.h @@ -46,7 +46,8 @@ class SocialPickupTab final : public SocialTab { createControls(mBeings, showBackground); - // TRANSLATORS: Pickup filter tab name in social window. Should be small + // TRANSLATORS: Pickup filter tab name in social window. + // TRANSLATORS: Should be small setCaption(_("Pik")); } diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index bb2e2250a..78c03feb4 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -78,7 +78,8 @@ class SocialPlayersTab final : public SocialTab return; if (Party::getParty(1)) { - const PartyMember *const pm = Party::getParty(1)->getMember(name); + const PartyMember *const + pm = Party::getParty(1)->getMember(name); if (pm && pm->getMaxHp() > 0) { avatar->setMaxHp(pm->getMaxHp()); |