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
42
59
61{
62 std::vector<std::string> Text;
63};
64
66{
68
69 friend std::strong_ordering operator<=>(CreatureTextId const& left, CreatureTextId const& right) = default;
70
74};
75
76typedef std::vector<CreatureTextEntry> CreatureTextGroup; // texts in a group
77typedef std::unordered_map<uint8, CreatureTextGroup> CreatureTextHolder; // groups for a creature by groupid
78typedef std::unordered_map<uint32, CreatureTextHolder> CreatureTextMap; // all creatures by entry
79
80typedef std::map<CreatureTextId, CreatureTextLocale> LocaleCreatureTextMap;
81
83{
84 private:
87
88 public:
91
94
95 static CreatureTextMgr* instance();
96
97 void LoadCreatureTexts();
98 void LoadCreatureTextLocales();
99 CreatureTextMap const& GetTextMap() const { return mTextMap; }
100
101 //if sent, returns the 'duration' of the text else 0 if error
102 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, SoundKitPlayType playType = SoundKitPlayType::Normal, Team team = TEAM_OTHER, bool gmOnly = false, Player* srcPlr = nullptr);
103 bool TextExist(uint32 sourceEntry, uint8 textGroup) const;
104 std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const;
105
106 template <class Builder>
107 static 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);
108
109 static float GetRangeForChatType(ChatMsg msgType);
110
111 private:
114};
115
116#define sCreatureTextMgr CreatureTextMgr::instance()
117
118#endif
LocaleConstant
Definition Common.h:51
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_PERSONAL
@ TEXT_RANGE_NORMAL
@ TEXT_RANGE_MAP
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
Language
@ LANG_ADDON
@ TEAM_OTHER
SoundKitPlayType
ChatMsg
@ CHAT_MSG_ADDON
LocaleCreatureTextMap mLocaleTextMap
CreatureTextMgr & operator=(CreatureTextMgr const &)=delete
CreatureTextMgr & operator=(CreatureTextMgr &&)=delete
CreatureTextMap const & GetTextMap() const
CreatureTextMgr(CreatureTextMgr const &)=delete
CreatureTextMap mTextMap
CreatureTextMgr(CreatureTextMgr &&)=delete
Definition Unit.h:635
SoundKitPlayType SoundPlayType
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