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 62 of file notifymanager.cpp.

63  {
64  if (str.empty())
65  return;
66  if (tab != nullptr)
67  {
68  tab->chatLog(str,
72  }
73  else if (debugChatTab != nullptr)
74  {
75  debugChatTab->chatLog(str,
79  }
80  }
ChatTab * debugChatTab
Definition: chattab.cpp:63
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
const bool TryRemoveColors_true

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

Referenced by notify().

◆ getGuildTab()

static ChatTab* NotifyManager::getGuildTab ( )
static

Definition at line 45 of file notifymanager.cpp.

46  {
47  const Guild *const guild = localPlayer->getGuild();
48  if (guild != nullptr)
49  {
50 #ifdef TMWA_SUPPORT
51  if (guild->getServerGuild())
52  return guildHandler->getTab();
53  else if (guildManager != nullptr)
54  return guildManager->getTab();
55 #else // TMWA_SUPPORT
56  return guildHandler->getTab();
57 #endif // TMWA_SUPPORT
58  }
59  return nullptr;
60  }
const Guild * getGuild(const std::string &guildName) const
Definition: being.cpp:1258
ChatTab * getTab()
Definition: guild.h:70
virtual ChatTab * getTab() const =0
Net::GuildHandler * guildHandler
Definition: net.cpp:92
GuildManager * guildManager
LocalPlayer * localPlayer
uint32_t guild

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 205 of file notifymanager.cpp.

206  {
207  for (int f = 0; f < NotifyTypes::TYPE_END; f ++)
208  {
209  if (notifications[f].sound == sound)
210  return f;
211  }
212  return 0;
213  }
static const NotificationInfo notifications[NotifyTypes::TYPE_END]
Definition: notifications.h:35

References notifications, and NotifyTypes::TYPE_END.

Referenced by SoundDB::loadXmlFile().

◆ notify() [1/3]

void NotifyManager::notify ( const unsigned int  message)

Definition at line 82 of file notifymanager.cpp.

83  {
84  if (message >= NotifyTypes::TYPE_END ||
85  localChatTab == nullptr)
86  {
87  return;
88  }
89  const NotificationInfo &info = notifications[message];
90  if (*info.text == 0)
91  {
92  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
93  return;
94  }
95 
96  switch (info.flags)
97  {
98  case NotifyFlags::EMPTY:
99  localChatTab->chatLog(gettext(info.text),
103  break;
104 
105  case NotifyFlags::GUILD:
106  {
107  if (localPlayer == nullptr)
108  return;
109  ChatTab *const tab = getGuildTab();
110  chatLog(tab, gettext(info.text));
111  break;
112  }
113 
114  case NotifyFlags::PARTY:
115  {
116  ChatTab *const tab = partyHandler->getTab();
117  chatLog(tab, gettext(info.text));
118  break;
119  }
120 
121  case NotifyFlags::SPEECH:
122  {
123  if (localPlayer != nullptr)
124  localPlayer->setSpeech(gettext(info.text));
125  break;
126  }
127 
128  case NotifyFlags::INT:
129  case NotifyFlags::STRING:
132  default:
133  break;
134  }
135  soundManager.playSfx(SoundDB::getSound(message), 0, 0);
136  }
ChatTab * localChatTab
Definition: chattab.cpp:62
void setSpeech(const std::string &text)
Definition: being.cpp:572
virtual ChatTab * getTab() const =0
void playSfx(const std::string &path, const int x, const int y) const
bool info(InputEvent &event)
Definition: commands.cpp:57
static ChatTab * getGuildTab()
static void chatLog(ChatTab *const tab, const std::string &str)
std::string & getSound(const int id)
Definition: sounddb.cpp:95
Net::PartyHandler * partyHandler
Definition: net.cpp:94
SoundManager soundManager

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(), EAthena::PartyRecv::processPartyInfo(), TmwAthena::PartyRecv::processPartyInfo(), EAthena::PartyRecv::processPartyInviteResponse(), TmwAthena::PartyRecv::processPartyInviteResponse(), Ea::PartyRecv::processPartyItemSettingsContinue(), Ea::PartyRecv::processPartyLeave(), EAthena::PartyRecv::processPartyMessage(), TmwAthena::PartyRecv::processPartyMessage(), EAthena::PetRecv::processPetCatchProcess(), EAthena::PetRecv::processPetFood(), EAthena::PetRecv::processPetRoulette(), Ea::PlayerRecv::processPlayerArrowMessage(), EAthena::InventoryRecv::processPlayerEquip(), TmwAthena::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(), EAthena::SkillRecv::processSkillFailed(), TmwAthena::SkillRecv::processSkillFailed(), EAthena::SkillRecv::processSkillMemoMessage(), Ea::TradeRecv::processTradeCancel(), Ea::TradeRecv::processTradeComplete(), EAthena::TradeRecv::processTradeItemAddResponse(), TmwAthena::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 138 of file notifymanager.cpp.

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

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 158 of file notifymanager.cpp.

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

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 35 of file notifications.h.

Referenced by getIndexBySound(), and notify().