TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ChatTextBuilder.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __CHATTEXT_BUILDER_H
19 #define __CHATTEXT_BUILDER_H
20 
21 #include "Chat.h"
22 #include "ObjectMgr.h"
23 #include "Packets/ChatPackets.h"
24 
25 namespace Trinity
26 {
28  {
29  public:
30  BroadcastTextBuilder(Unit const* obj, ChatMsg msgType, uint32 textId, WorldObject const* target = nullptr, uint32 achievementId = 0)
31  : _source(obj), _msgType(msgType), _textId(textId), _target(target), _achievementId(achievementId) { }
32 
34  {
35  BroadcastTextEntry const* bct = sBroadcastTextStore.LookupEntry(_textId);
38  return chat;
39  }
40 
41  private:
42  Unit const* _source;
47  };
48 
50  {
51  public:
52  CustomChatTextBuilder(WorldObject const* obj, ChatMsg msgType, std::string const& text, Language language = LANG_UNIVERSAL, WorldObject const* target = nullptr)
53  : _source(obj), _msgType(msgType), _text(text), _language(language), _target(target) { }
54 
56  {
58  chat->Initialize(_msgType, _language, _source, _target, _text, 0, "", locale);
59  return chat;
60  }
61 
62  private:
65  std::string _text;
68  };
69 }
70 // namespace Trinity
71 
72 #endif // __CHATTEXT_BUILDER_H
BroadcastTextBuilder(Unit const *obj, ChatMsg msgType, uint32 textId, WorldObject const *target=nullptr, uint32 achievementId=0)
Definition: ChatTextBuilder.h:30
WorldPackets::Chat::Chat * operator()(LocaleConstant locale) const
Definition: ChatTextBuilder.h:55
Definition: SharedDefines.h:961
int32 Language
Definition: DB2Structure.h:115
DB2Storage< BroadcastTextEntry > sBroadcastTextStore("BroadcastText.db2", BroadcastTextFormat, HOTFIX_SEL_BROADCAST_TEXT)
uint32 _textId
Definition: ChatTextBuilder.h:44
Unit const * _source
Definition: ChatTextBuilder.h:42
ChatMsg _msgType
Definition: ChatTextBuilder.h:64
Definition: ChatTextBuilder.h:49
Definition: ChatPackets.h:150
ChatMsg
Definition: SharedDefines.h:4228
static char const * GetBroadcastTextValue(BroadcastTextEntry const *broadcastText, LocaleConstant locale=DEFAULT_LOCALE, uint8 gender=GENDER_MALE, bool forceGender=false)
Definition: DB2Stores.cpp:610
Definition: DB2Structure.h:112
Definition: Object.h:423
Language
Definition: SharedDefines.h:959
WorldPackets::Chat::Chat * operator()(LocaleConstant locale) const
Definition: ChatTextBuilder.h:33
Definition: ChatTextBuilder.h:27
LocaleConstant
Definition: Common.h:115
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
uint32_t uint32
Definition: Define.h:150
ChatMsg _msgType
Definition: ChatTextBuilder.h:43
CustomChatTextBuilder(WorldObject const *obj, ChatMsg msgType, std::string const &text, Language language=LANG_UNIVERSAL, WorldObject const *target=nullptr)
Definition: ChatTextBuilder.h:52
WorldObject const * _source
Definition: ChatTextBuilder.h:63
uint8 getGender() const
Definition: Unit.h:1415
Language _language
Definition: ChatTextBuilder.h:66
WorldObject const * _target
Definition: ChatTextBuilder.h:45
WorldObject const * _target
Definition: ChatTextBuilder.h:67
Definition: Common.h:172
std::string _text
Definition: ChatTextBuilder.h:65
uint32 _achievementId
Definition: ChatTextBuilder.h:46
Definition: Unit.h:1305