diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-08 22:25:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-08 23:44:33 +0300 |
commit | 6328313a6d8a76b4d38a82f6f4dcef350c695704 (patch) | |
tree | fd2aba6ed0af90547f0805b335a461bda555a170 | |
parent | dcd0d2e4d8a827d06a10344855d8d044bd26630d (diff) | |
download | plus-6328313a6d8a76b4d38a82f6f4dcef350c695704.tar.gz plus-6328313a6d8a76b4d38a82f6f4dcef350c695704.tar.bz2 plus-6328313a6d8a76b4d38a82f6f4dcef350c695704.tar.xz plus-6328313a6d8a76b4d38a82f6f4dcef350c695704.zip |
Impliment notify manager.
Move buy/sell notifications to NotifyManager.
-rw-r--r-- | src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/net/ea/buysellhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/eathena/buysellhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 10 | ||||
-rw-r--r-- | src/notifications.h | 56 | ||||
-rw-r--r-- | src/notifymanager.cpp | 36 | ||||
-rw-r--r-- | src/notifymanager.h | 30 |
8 files changed, 142 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d86d4d3de..13b47965c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -612,6 +612,9 @@ SET(SRCS mouseinput.h normalopenglgraphics.cpp normalopenglgraphics.h + notifications.h + notifymanager.cpp + notifymanager.h particle.cpp particle.h particlecontainer.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b6cca8f67..453d53160 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -615,6 +615,9 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ mouseinput.h \ normalopenglgraphics.cpp \ normalopenglgraphics.h \ + notifications.h \ + notifymanager.cpp \ + notifymanager.h \ particle.cpp \ particle.h \ particlecontainer.cpp \ diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 1b24c6b42..2838f8351 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -25,9 +25,9 @@ #include "actorspritemanager.h" #include "client.h" #include "configuration.h" -#include "depricatedevent.h" #include "inventory.h" #include "localplayer.h" +#include "notifymanager.h" #include "playerinfo.h" #include "gui/buydialog.h" @@ -160,7 +160,7 @@ void BuySellHandler::processNpcSell(Net::MessageIn &msg, int offset) } else { - SERVER_NOTICE(_("Nothing to sell.")) + NotifyManager::notify(NotifyManager::SELL_LIST_EMPTY); } } @@ -168,7 +168,7 @@ void BuySellHandler::processNpcBuyResponse(Net::MessageIn &msg) { if (msg.readInt8() == 0) { - SERVER_NOTICE(_("Thanks for buying.")) + NotifyManager::notify(NotifyManager::BUY_DONE); } else { @@ -176,7 +176,7 @@ void BuySellHandler::processNpcBuyResponse(Net::MessageIn &msg) // would go fine if (mBuyDialog) mBuyDialog->setMoney(PlayerInfo::getAttribute(PlayerInfo::MONEY)); - SERVER_NOTICE(_("Unable to buy.")) + NotifyManager::notify(NotifyManager::BUY_FAILED); } } diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp index 4214a76f0..3e81304b0 100644 --- a/src/net/eathena/buysellhandler.cpp +++ b/src/net/eathena/buysellhandler.cpp @@ -24,9 +24,9 @@ #include "actorspritemanager.h" #include "configuration.h" -#include "depricatedevent.h" #include "inventory.h" #include "localplayer.h" +#include "notifymanager.h" #include "playerinfo.h" #include "gui/buydialog.h" @@ -124,17 +124,17 @@ void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) switch (msg.readInt8()) { case 0: - SERVER_NOTICE(_("Thanks for selling.")) + NotifyManager::notify(NotifyManager::SOLD); break; case 1: default: - SERVER_NOTICE(_("Unable to sell.")) + NotifyManager::notify(NotifyManager::SELL_FAILED); break; case 2: - SERVER_NOTICE(_("Unable to sell while trading.")) + NotifyManager::notify(NotifyManager::SELL_TRADE_FAILED); break; case 3: - SERVER_NOTICE(_("Unable to sell unsellable item.")) + NotifyManager::notify(NotifyManager::SELL_UNSELLABLE_FAILED); break; } } diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 00cb16231..997a6220c 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -24,9 +24,9 @@ #include "actorspritemanager.h" #include "configuration.h" -#include "depricatedevent.h" #include "inventory.h" #include "localplayer.h" +#include "notifymanager.h" #include "playerinfo.h" #include "gui/buydialog.h" @@ -130,17 +130,17 @@ void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) switch (msg.readInt8()) { case 0: - SERVER_NOTICE(_("Thanks for selling.")) + NotifyManager::notify(NotifyManager::SOLD); break; case 1: default: - SERVER_NOTICE(_("Unable to sell.")) + NotifyManager::notify(NotifyManager::SELL_FAILED); break; case 2: - SERVER_NOTICE(_("Unable to sell while trading.")) + NotifyManager::notify(NotifyManager::SELL_TRADE_FAILED); break; case 3: - SERVER_NOTICE(_("Unable to sell unsellable item.")) + NotifyManager::notify(NotifyManager::SELL_UNSELLABLE_FAILED); break; } } diff --git a/src/notifications.h b/src/notifications.h new file mode 100644 index 000000000..9c8e1533a --- /dev/null +++ b/src/notifications.h @@ -0,0 +1,56 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013 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 NOTIFYCATIONS_H +#define NOTIFYCATIONS_H + +#include "utils/gettext.h" + +namespace NotifyManager +{ + struct NotificationInfo + { + const char *text; + }; + + enum NotifyTypes + { + BUY_DONE, + BUY_FAILED, + SELL_LIST_EMPTY, + SOLD, + SELL_FAILED, + SELL_TRADE_FAILED, + SELL_UNSELLABLE_FAILED, + TYPE_END + }; + + static const NotificationInfo notifications[] = + { + {N_("Thanks for buying.")}, + {N_("Unable to buy.")}, + {N_("Nothing to sell.")}, + {N_("Thanks for selling.")}, + {N_("Unable to sell.")}, + {N_("Unable to sell while trading.")}, + {N_("Unable to sell unsellable item.")} + }; +} +#endif diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp new file mode 100644 index 000000000..616082b04 --- /dev/null +++ b/src/notifymanager.cpp @@ -0,0 +1,36 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013 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/>. + */ + +#include "notifymanager.h" + +#include "gui/widgets/chattab.h" + +#include "utils/gettext.h" + +namespace NotifyManager +{ + void notify(const unsigned int message) + { + if (message >= TYPE_END || !localChatTab) + return; + localChatTab->chatLog(gettext(notifications[message].text), + BY_SERVER); + } +} diff --git a/src/notifymanager.h b/src/notifymanager.h new file mode 100644 index 000000000..db0b51f85 --- /dev/null +++ b/src/notifymanager.h @@ -0,0 +1,30 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013 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 NOTIFYMANAGER_H +#define NOTIFYMANAGER_H + +#include "notifications.h" + +namespace NotifyManager +{ + void notify(const unsigned int message); +} +#endif |