diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-09 02:10:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-09 14:39:29 +0300 |
commit | 29c0c9e731694a40a6f2e41c6bdedb4b78e2b952 (patch) | |
tree | e944129f98e652f2bd9adbcf5cd273a8bbb9e528 /src/net | |
parent | 0aca242db52695fa0804ac180fc7961b281b422a (diff) | |
download | manaplus-29c0c9e731694a40a6f2e41c6bdedb4b78e2b952.tar.gz manaplus-29c0c9e731694a40a6f2e41c6bdedb4b78e2b952.tar.bz2 manaplus-29c0c9e731694a40a6f2e41c6bdedb4b78e2b952.tar.xz manaplus-29c0c9e731694a40a6f2e41c6bdedb4b78e2b952.zip |
Add new notifications to guildhandler, guildmanager, inventoryhandler and partyhandler.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/guildhandler.cpp | 43 | ||||
-rw-r--r-- | src/net/ea/guildhandler.h | 2 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/partyhandler.cpp | 93 | ||||
-rw-r--r-- | src/net/ea/partyhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/partyhandler.cpp | 7 | ||||
-rw-r--r-- | src/net/guildhandler.h | 4 | ||||
-rw-r--r-- | src/net/partyhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 7 |
9 files changed, 68 insertions, 99 deletions
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 129ba931d..b521e313a 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -24,6 +24,7 @@ #include "actorspritemanager.h" #include "configuration.h" #include "localplayer.h" +#include "notifymanager.h" #include "gui/socialwindow.h" @@ -78,27 +79,27 @@ void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) { case 0: // Success - SERVER_NOTICE(_("Guild created.")) + NotifyManager::notify(NotifyManager::GUILD_CREATED); break; case 1: // Already in a guild - SERVER_NOTICE(_("You are already in guild.")) + NotifyManager::notify(NotifyManager::GUILD_ALREADY); break; case 2: // Unable to make (likely name already in use) - SERVER_NOTICE(_("You are already in guild.")) + NotifyManager::notify(NotifyManager::GUILD_ALREADY); break; case 3: // Emperium check failed - SERVER_NOTICE(_("Emperium check failed.")) + NotifyManager::notify(NotifyManager::GUILD_EMPERIUM_CHECK_FAILED); break; default: // Unknown response - SERVER_NOTICE(_("Unknown server response.")) + NotifyManager::notify(NotifyManager::GUILD_ERROR); break; } } @@ -406,23 +407,23 @@ void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) switch (flag) { case 0: - guildTab->chatLog(_("Could not inivte user to guild."), BY_SERVER); + NotifyManager::notify(NotifyManager::GUILD_INVITE_FAILED); break; case 1: - guildTab->chatLog(_("User rejected guild invite."), BY_SERVER); + NotifyManager::notify(NotifyManager::GUILD_INVITE_REJECTED); break; case 2: - guildTab->chatLog(_("User is now part of your guild."), BY_SERVER); + NotifyManager::notify(NotifyManager::GUILD_INVITE_JOINED); break; case 3: - guildTab->chatLog(_("Your guild is full."), BY_SERVER); + NotifyManager::notify(NotifyManager::GUILD_INVITE_FULL); break; default: - guildTab->chatLog(_("Unknown guild invite response."), BY_SERVER); + NotifyManager::notify(NotifyManager::GUILD_INVITE_ERROR); break; } } @@ -445,7 +446,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) taGuild->removeFromMembers(); taGuild->clearMembers(); } - SERVER_NOTICE(_("You have left the guild.")) + NotifyManager::notify(NotifyManager::GUILD_LEFT); delete guildTab; guildTab = nullptr; @@ -456,11 +457,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) } else { - if (guildTab) - { - guildTab->chatLog(strprintf(_("%s has left your guild."), - nick.c_str()), BY_SERVER); - } + NotifyManager::notify(NotifyManager::GUILD_USER_LEFT, nick); if (actorSpriteManager) { Being *const b = actorSpriteManager->findBeingByName( @@ -493,7 +490,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) taGuild->removeFromMembers(); taGuild->clearMembers(); } - SERVER_NOTICE(_("You were kicked from guild.")); + NotifyManager::notify(NotifyManager::GUILD_KICKED); delete guildTab; guildTab = nullptr; @@ -504,12 +501,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) } else { - if (guildTab) - { - guildTab->chatLog(strprintf(_("%s has kicked from your guild."), - nick.c_str()), BY_SERVER); - } - + NotifyManager::notify(NotifyManager::GUILD_USER_KICKED, nick); if (actorSpriteManager) { Being *const b = actorSpriteManager->findBeingByName( @@ -605,4 +597,9 @@ void GuildHandler::clear() taGuild = nullptr; } +ChatTab *GuildHandler::getTab() +{ + return guildTab; +} + } // namespace Ea diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 128bf368d..65a6973ca 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -102,6 +102,8 @@ class GuildHandler : public Net::GuildHandler void clear(); + ChatTab *getTab(); + protected: bool showBasicInfo; }; diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index eceb194f9..9e751f27c 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -23,6 +23,7 @@ #include "net/ea/inventoryhandler.h" #include "localplayer.h" +#include "notifymanager.h" #include "gui/ministatuswindow.h" @@ -399,7 +400,7 @@ void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) if (msg.readInt8() == 0) { - SERVER_NOTICE(_("Failed to use item.")) + NotifyManager::notify(NotifyManager::USE_FAILED); } else { @@ -565,7 +566,7 @@ void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) const int flag = msg.readInt8(); if (!flag) - SERVER_NOTICE(_("Unable to equip.")) + NotifyManager::notify(NotifyManager::EQUIP_FAILED); else mEquips.setEquipment(getSlot(equipType), index); } diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 41d0bdf00..7ab8ae5e8 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -24,6 +24,7 @@ #include "actorspritemanager.h" #include "configuration.h" #include "localplayer.h" +#include "notifymanager.h" #include "gui/socialwindow.h" @@ -74,9 +75,9 @@ void PartyHandler::clear() void PartyHandler::processPartyCreate(Net::MessageIn &msg) { if (msg.readInt8()) - SERVER_NOTICE(_("Could not create party.")) + NotifyManager::notify(NotifyManager::PARTY_CREATE_FAILED); else - SERVER_NOTICE(_("Party successfully created.")) + NotifyManager::notify(NotifyManager::PARTY_CREATED); } void PartyHandler::processPartyInfo(Net::MessageIn &msg) @@ -128,11 +129,10 @@ void PartyHandler::processPartyInfo(Net::MessageIn &msg) if (oldParty) { //member = Ea::taParty->getMember(id); - if (Ea::partyTab && names.find(nick) == names.end()) + if (names.find(nick) == names.end()) { - Ea::partyTab->chatLog(strprintf( - _("%s has joined your party."), - nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_USER_JOINED, + nick); } } PartyMember *member = Ea::taParty->addMember(id, nick); @@ -166,29 +166,21 @@ void PartyHandler::processPartyInviteResponse(Net::MessageIn &msg) switch (msg.readInt8()) { case 0: - Ea::partyTab->chatLog(strprintf( - _("%s is already a member of a party."), - nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_INVITE_ALREADY_MEMBER, + nick); break; case 1: - Ea::partyTab->chatLog(strprintf( - _("%s refused your invitation."), - nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_INVITE_REFUSED, nick); break; case 2: - Ea::partyTab->chatLog(strprintf( - _("%s is now a member of your party."), - nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_INVITE_DONE, nick); break; case 3: - Ea::partyTab->chatLog(strprintf( - _("%s can't join your party because party is " - "full."), nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_INVITE_PARTY_FULL, + nick); break; default: - Ea::partyTab->chatLog(strprintf( - _("QQQ Unknown invite response for %s."), - nick.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_INVITE_ERROR, nick); break; } } @@ -238,32 +230,19 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) if (mShareExp == PARTY_SHARE) break; mShareExp = PARTY_SHARE; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Experience sharing enabled."), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_ON); break; case PARTY_SHARE_NO: if (mShareExp == PARTY_SHARE_NO) break; mShareExp = PARTY_SHARE_NO; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Experience sharing disabled."), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_OFF); break; case PARTY_SHARE_NOT_POSSIBLE: if (mShareExp == PARTY_SHARE_NOT_POSSIBLE) break; mShareExp = PARTY_SHARE_NOT_POSSIBLE; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Experience sharing not possible."), - BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_EXP_SHARE_ERROR); break; default: logger->log("QQQ Unknown party exp option: %d\n", exp); @@ -276,35 +255,22 @@ void PartyHandler::processPartySettings(Net::MessageIn &msg) if (mShareItems == PARTY_SHARE) break; mShareItems = PARTY_SHARE; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Item sharing enabled."), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_ON); break; case PARTY_SHARE_NO: if (mShareItems == PARTY_SHARE_NO) break; mShareItems = PARTY_SHARE_NO; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Item sharing disabled."), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_OFF); break; case PARTY_SHARE_NOT_POSSIBLE: if (mShareItems == PARTY_SHARE_NOT_POSSIBLE) break; mShareItems = PARTY_SHARE_NOT_POSSIBLE; - if (Ea::partyTab) - { - Ea::partyTab->chatLog( - _("Item sharing not possible."), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_ITEM_SHARE_ERROR); break; default: - logger->log("QQQ Unknown party item option: %d\n", - exp); + logger->log("QQQ Unknown party item option: %d\n", exp); break; } } @@ -352,7 +318,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) Ea::taParty->removeFromMembers(); Ea::taParty->clearMembers(); } - SERVER_NOTICE(_("You have left the party.")) + NotifyManager::notify(NotifyManager::PARTY_LEFT); delete Ea::partyTab; Ea::partyTab = nullptr; @@ -362,12 +328,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) } else { - if (Ea::partyTab) - { - Ea::partyTab->chatLog(strprintf( - _("%s has left your party."), - nick.c_str()), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_USER_LEFT, nick); if (actorSpriteManager) { Being *const b = actorSpriteManager->findBeing(id); @@ -441,11 +402,15 @@ void PartyHandler::processPartyMessage(Net::MessageIn &msg) } else { - Ea::partyTab->chatLog(strprintf( - _("An unknown member tried to say: %s"), - chatMsg.c_str()), BY_SERVER); + NotifyManager::notify(NotifyManager::PARTY_UNKNOWN_USER_MSG, + chatMsg); } } } +ChatTab *PartyHandler::getTab() +{ + return partyTab; +} + } // namespace Ea diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index f9dde62b0..c113a6a3b 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -56,6 +56,8 @@ class PartyHandler : public Net::PartyHandler void clear(); + ChatTab *getTab(); + virtual void processPartyCreate(Net::MessageIn &msg); virtual void processPartyInfo(Net::MessageIn &msg); diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index 72b0beaf2..264b2bd26 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -23,6 +23,7 @@ #include "actorspritemanager.h" #include "localplayer.h" +#include "notifymanager.h" #include "net/eathena/protocol.h" @@ -166,11 +167,7 @@ void PartyHandler::kick(const std::string &name) const PartyMember *const m = Ea::taParty->getMember(name); if (!m) { - if (Ea::partyTab) - { - Ea::partyTab->chatLog(strprintf(_("%s is not in your party!"), - name.c_str()), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_USER_NOT_IN_PARTY, name); return; } diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h index 86873b7fb..b1f6bd7bf 100644 --- a/src/net/guildhandler.h +++ b/src/net/guildhandler.h @@ -25,6 +25,8 @@ #include "guild.h" +#include "gui/widgets/chattab.h" + #include <iosfwd> class Being; @@ -72,6 +74,8 @@ class GuildHandler std::string msg2) = 0; virtual void clear() = 0; + + virtual ChatTab *getTab() = 0; }; } diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 7e4923586..cd75e51fe 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -25,6 +25,8 @@ #include "localconsts.h" +#include "gui/widgets/chattab.h" + #include <string> class Being; @@ -76,6 +78,8 @@ class PartyHandler virtual void setShareItems(PartyShare share) = 0; virtual void clear() = 0; + + virtual ChatTab *getTab() = 0; }; } // namespace Net diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 2b3ac78d6..44fca8a6f 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -23,6 +23,7 @@ #include "actorspritemanager.h" #include "localplayer.h" +#include "notifymanager.h" #include "net/tmwa/protocol.h" @@ -168,11 +169,7 @@ void PartyHandler::kick(const std::string &name) const PartyMember *const m = Ea::taParty->getMember(name); if (!m) { - if (Ea::partyTab) - { - Ea::partyTab->chatLog(strprintf(_("%s is not in your party!"), - name.c_str()), BY_SERVER); - } + NotifyManager::notify(NotifyManager::PARTY_USER_NOT_IN_PARTY, name); return; } |