TrinityCore
Loading...
Searching...
No Matches
CreatureTextMgr.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
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 TRINITY_CREATURE_TEXT_MGR_H
19#define TRINITY_CREATURE_TEXT_MGR_H
20
21#include "Common.h"
22#include "SharedDefines.h"
23#include <map>
24#include <unordered_map>
25#include <vector>
26
27class Creature;
28class Player;
29class Unit;
30class WorldObject;
31class WorldPacket;
32
41
57
59{
60 std::vector<std::string> Text;
61};
62
64{
66
67 friend std::strong_ordering operator<=>(CreatureTextId const& left, CreatureTextId const& right) = default;
68
72};
73
74typedef std::vector<CreatureTextEntry> CreatureTextGroup; // texts in a group
75typedef std::unordered_map<uint8, CreatureTextGroup> CreatureTextHolder; // groups for a creature by groupid
76typedef std::unordered_map<uint32, CreatureTextHolder> CreatureTextMap; // all creatures by entry
77
78typedef std::map<CreatureTextId, CreatureTextLocale> LocaleCreatureTextMap;
79
81{
82 private:
85
86 public:
87 static CreatureTextMgr* instance();
88
89 void LoadCreatureTexts();
90 void LoadCreatureTextLocales();
91 CreatureTextMap const& GetTextMap() const { return mTextMap; }
92
93 void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly);
94 void SendEmote(Unit* source, Emote emote);
95
96 //if sent, returns the 'duration' of the text else 0 if error
97 uint32 SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget = nullptr, ChatMsg msgType = CHAT_MSG_ADDON, Language language = LANG_ADDON, CreatureTextRange range = TEXT_RANGE_NORMAL, uint32 sound = 0, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = nullptr);
98 bool TextExist(uint32 sourceEntry, uint8 textGroup);
99 std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const;
100
101 template<class Builder>
102 void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const;
103
104 private:
105 void SendNonChatPacket(WorldObject* source, WorldPacket const* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const;
106 float GetRangeForChatType(ChatMsg msgType) const;
107
110};
111
112#define sCreatureTextMgr CreatureTextMgr::instance()
113
114#endif
LocaleConstant
Definition Common.h:48
std::vector< CreatureTextEntry > CreatureTextGroup
std::unordered_map< uint8, CreatureTextGroup > CreatureTextHolder
std::map< CreatureTextId, CreatureTextLocale > LocaleCreatureTextMap
std::unordered_map< uint32, CreatureTextHolder > CreatureTextMap
CreatureTextRange
@ TEXT_RANGE_ZONE
@ TEXT_RANGE_AREA
@ TEXT_RANGE_WORLD
@ TEXT_RANGE_NORMAL
@ TEXT_RANGE_MAP
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
Language
@ LANG_ADDON
@ TEAM_OTHER
ChatMsg
@ CHAT_MSG_ADDON
LocaleCreatureTextMap mLocaleTextMap
CreatureTextMap const & GetTextMap() const
CreatureTextMap mTextMap
Definition Unit.h:769
CreatureTextRange TextRange
friend std::strong_ordering operator<=>(CreatureTextId const &left, CreatureTextId const &right)=default
CreatureTextId(uint32 e, uint32 g, uint32 i)
std::vector< std::string > Text