summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-09 00:32:28 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-09 00:32:28 +0300
commit0aca242db52695fa0804ac180fc7961b281b422a (patch)
tree8592405060b32827d0412c25f9c5bd742eb6bd57
parenta36ef7797d382c62f02be97976d564418029d24c (diff)
downloadplus-0aca242db52695fa0804ac180fc7961b281b422a.tar.gz
plus-0aca242db52695fa0804ac180fc7961b281b422a.tar.bz2
plus-0aca242db52695fa0804ac180fc7961b281b422a.tar.xz
plus-0aca242db52695fa0804ac180fc7961b281b422a.zip
Add new notifications to gamehandler.
-rw-r--r--src/net/ea/gamehandler.cpp3
-rw-r--r--src/notifications.h33
-rw-r--r--src/notifymanager.cpp20
-rw-r--r--src/notifymanager.h1
4 files changed, 42 insertions, 15 deletions
diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp
index eaed1ec5d..4f1a6d5d6 100644
--- a/src/net/ea/gamehandler.cpp
+++ b/src/net/ea/gamehandler.cpp
@@ -25,6 +25,7 @@
#include "client.h"
#include "game.h"
#include "localplayer.h"
+#include "notifymanager.h"
#include "gui/okdialog.h"
@@ -84,7 +85,7 @@ void GameHandler::processMapLogin(Net::MessageIn &msg)
void GameHandler::processWhoAnswer(Net::MessageIn &msg)
{
- SERVER_NOTICE(strprintf(_("Online users: %d"), msg.readInt32()))
+ NotifyManager::notify(NotifyManager::ONLINE_USERS, msg.readInt32());
}
void GameHandler::processCharSwitchResponse(Net::MessageIn &msg)
diff --git a/src/notifications.h b/src/notifications.h
index 9c8e1533a..b5c622c76 100644
--- a/src/notifications.h
+++ b/src/notifications.h
@@ -25,11 +25,6 @@
namespace NotifyManager
{
- struct NotificationInfo
- {
- const char *text;
- };
-
enum NotifyTypes
{
BUY_DONE,
@@ -39,18 +34,32 @@ namespace NotifyManager
SELL_FAILED,
SELL_TRADE_FAILED,
SELL_UNSELLABLE_FAILED,
+ ONLINE_USERS,
TYPE_END
};
+ enum NotifyFlags
+ {
+ EMPTY,
+ INT
+ };
+
+ struct NotificationInfo
+ {
+ const char *text;
+ const NotifyFlags flags;
+ };
+
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.")}
+ {N_("Thanks for buying."), EMPTY},
+ {N_("Unable to buy."), EMPTY},
+ {N_("Nothing to sell."), EMPTY},
+ {N_("Thanks for selling."), EMPTY},
+ {N_("Unable to sell."), EMPTY},
+ {N_("Unable to sell while trading."), EMPTY},
+ {N_("Unable to sell unsellable item."), EMPTY},
+ {N_("Online users: %d"), INT}
};
}
#endif
diff --git a/src/notifymanager.cpp b/src/notifymanager.cpp
index 616082b04..2dae7d280 100644
--- a/src/notifymanager.cpp
+++ b/src/notifymanager.cpp
@@ -30,7 +30,23 @@ namespace NotifyManager
{
if (message >= TYPE_END || !localChatTab)
return;
- localChatTab->chatLog(gettext(notifications[message].text),
- BY_SERVER);
+ const NotificationInfo &info = notifications[message];
+ if (info.flags == EMPTY)
+ {
+ localChatTab->chatLog(gettext(info.text),
+ BY_SERVER);
+ }
+ }
+
+ void notify(const unsigned int message, const int num)
+ {
+ if (message >= TYPE_END || !localChatTab)
+ return;
+ const NotificationInfo &info = notifications[message];
+ if (info.flags == INT)
+ {
+ localChatTab->chatLog(strprintf(gettext(info.text),
+ num), BY_SERVER);
+ }
}
}
diff --git a/src/notifymanager.h b/src/notifymanager.h
index db0b51f85..9c24f5890 100644
--- a/src/notifymanager.h
+++ b/src/notifymanager.h
@@ -26,5 +26,6 @@
namespace NotifyManager
{
void notify(const unsigned int message);
+ void notify(const unsigned int message, const int num);
}
#endif