ManaPlus
Functions | Variables
NotifyManager Namespace Reference

Functions

static ChatTabgetGuildTab ()
 
static void chatLog (ChatTab *const tab, const std::string &str)
 
void notify (const unsigned int message)
 
void notify (const unsigned int message, const int num)
 
void notify (const unsigned int message, const std::string &str)
 
int getIndexBySound (const std::string &sound)
 

Variables

static const NotificationInfo notifications [NotifyTypes::TYPE_END]
 

Function Documentation

◆ chatLog()

static void NotifyManager::chatLog ( ChatTab *const  tab,
const std::string &  str 
)
static

Definition at line 61 of file notifymanager.cpp.

62  {
63  if (str.empty())
64  return;
65  if (tab != nullptr)
66  {
67  tab->chatLog(str,
71  }
72  else if (debugChatTab != nullptr)
73  {
74  debugChatTab->chatLog(str,
78  }
79  }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), debugChatTab, IgnoreRecord_false, and TryRemoveColors_true.

Referenced by notify().

◆ getGuildTab()

static ChatTab* NotifyManager::getGuildTab ( )
static

Definition at line 44 of file notifymanager.cpp.

45  {
46  const Guild *const guild = localPlayer->getGuild();
47  if (guild != nullptr)
48  {
49 #ifdef TMWA_SUPPORT
50  if (guild->getServerGuild())
51  return guildHandler->getTab();
52  else if (guildManager != nullptr)
53  return guildManager->getTab();
54 #else // TMWA_SUPPORT
55  return guildHandler->getTab();
56 #endif // TMWA_SUPPORT
57  }
58  return nullptr;
59  }

References Being::getGuild(), GuildManager::getTab(), Net::GuildHandler::getTab(), guild, guildHandler, guildManager, and localPlayer.

Referenced by notify().

◆ getIndexBySound()

int NotifyManager::getIndexBySound ( const std::string &  sound)

Definition at line 204 of file notifymanager.cpp.

205  {
206  for (int f = 0; f < NotifyTypes::TYPE_END; f ++)
207  {
208  if (notifications[f].sound == sound)
209  return f;
210  }
211  return 0;
212  }

References notifications, and NotifyTypes::TYPE_END.

Referenced by SoundDB::loadXmlFile().

◆ notify() [1/3]

void NotifyManager::notify ( const unsigned int  message)

Definition at line 81 of file notifymanager.cpp.

82  {
83  if (message >= NotifyTypes::TYPE_END ||
84  localChatTab == nullptr)
85  {
86  return;
87  }
88  const NotificationInfo &info = notifications[message];
89  if (*info.text == 0)
90  {
91  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
92  return;
93  }
94 
95  switch (info.flags)
96  {
97  case NotifyFlags::EMPTY:
98  localChatTab->chatLog(gettext(info.text),
102  break;
103 
104  case NotifyFlags::GUILD:
105  {
106  if (localPlayer == nullptr)
107  return;
108  ChatTab *const tab = getGuildTab();
109  chatLog(tab, gettext(info.text));
110  break;
111  }
112 
113  case NotifyFlags::PARTY:
114  {
115  ChatTab *const tab = partyHandler->getTab();
116  chatLog(tab, gettext(info.text));
117  break;
118  }
119 
120  case NotifyFlags::SPEECH:
121  {
122  if (localPlayer != nullptr)
123  localPlayer->setSpeech(gettext(info.text));
124  break;
125  }
126 
127  case NotifyFlags::INT:
128  case NotifyFlags::STRING:
131  default:
132  break;
133  }
134  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
135  }

References ChatMsgType::BY_SERVER, chatLog(), ChatTab::chatLog(), NotifyFlags::EMPTY, getGuildTab(), SoundDB::getSound(), Net::PartyHandler::getTab(), NotifyFlags::GUILD, NotifyFlags::GUILD_STRING, IgnoreRecord_false, Actions::info(), NotifyFlags::INT, localChatTab, localPlayer, notifications, NotifyFlags::PARTY, NotifyFlags::PARTY_STRING, partyHandler, SoundManager::playSfx(), Being::setSpeech(), soundManager, NotifyFlags::SPEECH, NotifyFlags::STRING, TryRemoveColors_true, and NotifyTypes::TYPE_END.

Referenced by GuildManager::afterRemove(), EAthena::MercenaryRecv::handleMercenaryMessage(), EAthena::PartyHandler::kick(), TmwAthena::PartyHandler::kick(), EAthena::Mail2Recv::processAddItemResult(), EAthena::FamilyRecv::processAskForChildReply(), EAthena::BankRecv::processBankDeposit(), EAthena::BankRecv::processBankStatus(), EAthena::BankRecv::processBankWithdraw(), Ea::BeingRecv::processBeingRemove(), EAthena::InventoryRecv::processBindItem(), EAthena::VendingRecv::processBuyAck(), EAthena::BuyingStoreRecv::processBuyingStoreCreateFailed(), EAthena::BuyingStoreRecv::processBuyingStoreSellerSellFailed(), EAthena::BuyingStoreRecv::processBuyingStoreSellFailed(), EAthena::FamilyRecv::processCallPartner(), EAthena::InventoryRecv::processCartAddError(), EAthena::CashShopRecv::processCashShopBuyAck(), EAthena::ChatRecv::processChatRoomAddMember(), EAthena::ChatRecv::processChatRoomCreateAck(), EAthena::ChatRecv::processChatRoomJoinFailed(), EAthena::ChatRecv::processChatRoomLeave(), EAthena::ChatRecv::processChatRoomRoleChange(), EAthena::ChatRecv::processChatSilence(), EAthena::Mail2Recv::processCheckNameResult(), EAthena::MailRecv::processDeleteAck(), EAthena::FamilyRecv::processDivorced(), EAthena::ChatRecv::processFormatMessageNumber(), EAthena::MailRecv::processGetAttachment(), EAthena::GuildRecv::processGuildCreateResponse(), EAthena::GuildRecv::processGuildExpulsionContinue(), EAthena::GuildRecv::processGuildInviteAck(), EAthena::GuildRecv::processGuildLeave(), EAthena::GuildRecv::processGuildLeave2(), EAthena::HomunculusRecv::processHomunculusFood(), Ea::ChatRecv::processIgnoreAllResponse(), EAthena::ChatRecv::processIgnoreNickAck(), EAthena::InventoryRecv::processItemMoveFailed(), Ea::InventoryRecv::processItemUseResponse(), Ea::AdminRecv::processKickAck(), EAthena::MailRecv::processMailReturn(), EAthena::ChatRecv::processMannerMessage(), EAthena::BeingRecv::processMapType(), EAthena::MarketRecv::processMarketBuyAck(), Ea::ChatRecv::processMVPEffect(), EAthena::MailRecv::processNewMail(), EAthena::BuySellRecv::processNpcBuyResponse(), TmwAthena::BuySellRecv::processNpcBuyResponse(), Ea::BuySellRecv::processNpcSell(), EAthena::BuySellRecv::processNpcSellResponse(), TmwAthena::BuySellRecv::processNpcSellResponse(), EAthena::PartyRecv::processPartyAutoItemSettingsContinue(), Ea::PartyRecv::processPartyCreate(), Ea::PartyRecv::processPartyExpSettingsContinue(), TmwAthena::PartyRecv::processPartyInfo(), EAthena::PartyRecv::processPartyInfo(), TmwAthena::PartyRecv::processPartyInviteResponse(), EAthena::PartyRecv::processPartyInviteResponse(), Ea::PartyRecv::processPartyItemSettingsContinue(), Ea::PartyRecv::processPartyLeave(), TmwAthena::PartyRecv::processPartyMessage(), EAthena::PartyRecv::processPartyMessage(), EAthena::PetRecv::processPetCatchProcess(), EAthena::PetRecv::processPetFood(), EAthena::PetRecv::processPetRoulette(), Ea::PlayerRecv::processPlayerArrowMessage(), TmwAthena::InventoryRecv::processPlayerEquip(), EAthena::InventoryRecv::processPlayerEquip(), EAthena::InventoryRecv::processPlayerInsertCard(), EAthena::InventoryRecv::processPlayerInventoryRemove(), EAthena::InventoryRecv::processPlayerInventoryRemove2(), EAthena::InventoryRecv::processPlayerInventoryUse(), EAthena::InventoryRecv::processPlayerItemRentalExpired(), EAthena::InventoryRecv::processPlayerItemRentalTime(), EAthena::InventoryRecv::processPlayerRefine(), EAthena::PlayerRecv::processPlayerSkillMessage(), Ea::PlayerRecv::processPlayerStatUpdate4(), EAthena::InventoryRecv::processPlayerUnEquip(), EAthena::Mail2Recv::processRemoveItemResult(), EAthena::VendingRecv::processReport(), EAthena::Mail2Recv::processRequestItems(), EAthena::Mail2Recv::processRequestMoney(), EAthena::SearchStoreRecv::processSearchFailed(), EAthena::MailRecv::processSendMailAck(), EAthena::Mail2Recv::processSendResult(), EAthena::MailRecv::processSetAttachmentAck(), TmwAthena::SkillRecv::processSkillFailed(), EAthena::SkillRecv::processSkillFailed(), EAthena::SkillRecv::processSkillMemoMessage(), Ea::TradeRecv::processTradeCancel(), Ea::TradeRecv::processTradeComplete(), TmwAthena::TradeRecv::processTradeItemAddResponse(), EAthena::TradeRecv::processTradeItemAddResponse(), Ea::TradeRecv::processTradeResponseContinue(), Ea::GameRecv::processWhoAnswer(), PlayerInfo::setAttribute(), Map::setPvpMode(), EAthena::PlayerHandler::setStat(), TmwAthena::PlayerHandler::setStat(), PlayerInfo::setStatBase(), and PlayerInfo::setStatMod().

◆ notify() [2/3]

void NotifyManager::notify ( const unsigned int  message,
const int  num 
)

Definition at line 137 of file notifymanager.cpp.

138  {
139  if (message >= NotifyTypes::TYPE_END ||
140  localChatTab == nullptr)
141  {
142  return;
143  }
144  const NotificationInfo &info = notifications[message];
145  if (info.flags == NotifyFlags::INT &&
146  *info.text != 0)
147  {
149  strprintf(gettext(info.text), num),
153  }
154  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
155  }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), SoundDB::getSound(), IgnoreRecord_false, Actions::info(), NotifyFlags::INT, localChatTab, notifications, SoundManager::playSfx(), soundManager, strprintf(), TryRemoveColors_true, and NotifyTypes::TYPE_END.

◆ notify() [3/3]

void NotifyManager::notify ( const unsigned int  message,
const std::string &  str 
)

Definition at line 157 of file notifymanager.cpp.

158  {
159  if (message >= NotifyTypes::TYPE_END ||
160  localChatTab == nullptr)
161  {
162  return;
163  }
164  const NotificationInfo &info = notifications[message];
165  if (*info.text == 0)
166  {
167  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
168  return;
169  }
170  switch (info.flags)
171  {
172  case NotifyFlags::STRING:
173  {
175  strprintf(gettext(info.text), str.c_str()),
179  break;
180  }
182  {
183  ChatTab *const tab = getGuildTab();
184  chatLog(tab, strprintf(gettext(info.text), str.c_str()));
185  break;
186  }
188  {
189  ChatTab *const tab = partyHandler->getTab();
190  chatLog(tab, strprintf(gettext(info.text), str.c_str()));
191  break;
192  }
193  case NotifyFlags::EMPTY:
194  case NotifyFlags::INT:
195  case NotifyFlags::GUILD:
196  case NotifyFlags::PARTY:
197  case NotifyFlags::SPEECH:
198  default:
199  break;
200  }
201  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
202  }

References ChatMsgType::BY_SERVER, chatLog(), ChatTab::chatLog(), NotifyFlags::EMPTY, getGuildTab(), SoundDB::getSound(), Net::PartyHandler::getTab(), NotifyFlags::GUILD, NotifyFlags::GUILD_STRING, IgnoreRecord_false, Actions::info(), NotifyFlags::INT, localChatTab, notifications, NotifyFlags::PARTY, NotifyFlags::PARTY_STRING, partyHandler, SoundManager::playSfx(), soundManager, NotifyFlags::SPEECH, NotifyFlags::STRING, strprintf(), TryRemoveColors_true, and NotifyTypes::TYPE_END.

Variable Documentation

◆ notifications

const NotificationInfo NotifyManager::notifications[NotifyTypes::TYPE_END]
static

Definition at line 34 of file notifications.h.

Referenced by getIndexBySound(), and notify().

ChatTab
Definition: chattab.h:61
guildHandler
Net::GuildHandler * guildHandler
Definition: net.cpp:91
NotifyFlags::STRING
@ STRING
Definition: notifyflags.h:30
SoundDB::getSound
std::string & getSound(const int id)
Definition: sounddb.cpp:94
ChatTab::chatLog
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:110
NotifyManager::notifications
static const NotificationInfo notifications[NotifyTypes::TYPE_END]
Definition: notifications.h:34
Being::getGuild
const Guild * getGuild(const std::string &guildName) const
Definition: being.cpp:1257
NotificationInfo
Definition: notificationinfo.h:28
partyHandler
Net::PartyHandler * partyHandler
Definition: net.cpp:93
IgnoreRecord_false
const bool IgnoreRecord_false
Definition: ignorerecord.h:29
NotifyFlags::INT
@ INT
Definition: notifyflags.h:29
Net::GuildHandler::getTab
virtual ChatTab * getTab() const =0
Being::setSpeech
void setSpeech(const std::string &text)
Definition: being.cpp:571
TryRemoveColors_true
const bool TryRemoveColors_true
Definition: tryremovecolors.h:29
Net::PartyHandler::getTab
virtual ChatTab * getTab() const =0
NotifyFlags::EMPTY
@ EMPTY
Definition: notifyflags.h:28
NotifyFlags::PARTY_STRING
@ PARTY_STRING
Definition: notifyflags.h:34
Actions::info
bool info(InputEvent &event)
Definition: commands.cpp:56
ChatMsgType::BY_SERVER
@ BY_SERVER
Definition: chatmsgtype.h:34
localPlayer
LocalPlayer * localPlayer
Definition: localplayer.cpp:108
strprintf
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
GuildManager::getTab
ChatTab * getTab()
Definition: guildmanager.cpp:544
NotifyFlags::PARTY
@ PARTY
Definition: notifyflags.h:33
NotifyFlags::SPEECH
@ SPEECH
Definition: notifyflags.h:35
NotifyManager::getGuildTab
static ChatTab * getGuildTab()
Definition: notifymanager.cpp:44
Guild
Definition: guild.h:68
NotifyManager::chatLog
static void chatLog(ChatTab *const tab, const std::string &str)
Definition: notifymanager.cpp:61
debugChatTab
ChatTab * debugChatTab
Definition: chattab.cpp:62
guild
uint32_t guild
Definition: maptypeproperty2.h:5
guildManager
GuildManager * guildManager
Definition: guildmanager.cpp:47
NotifyTypes::TYPE_END
@ TYPE_END
Definition: notifytypes.h:253
SoundManager::playSfx
void playSfx(const std::string &path, const int x, const int y) const
Definition: soundmanager.cpp:462
soundManager
SoundManager soundManager
Definition: soundmanager.cpp:54
localChatTab
ChatTab * localChatTab
Definition: chattab.cpp:61
NotifyFlags::GUILD
@ GUILD
Definition: notifyflags.h:31
NotifyFlags::GUILD_STRING
@ GUILD_STRING
Definition: notifyflags.h:32