TrinityCore
ScriptedGossip.cpp
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#include "ScriptedGossip.h"
19#include "Creature.h"
20#include "Player.h"
21
23{
24 return player->PlayerTalkClass->GetGossipOptionSender(menuId);
25}
26
27uint32 GetGossipActionFor(Player* player, uint32 gossipListId)
28{
29 return player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
30}
31
32void InitGossipMenuFor(Player* player, uint32 menuId)
33{
34 player->PlayerTalkClass->GetGossipMenu().SetMenuId(menuId);
35}
36
38{
39 player->PlayerTalkClass->ClearMenus();
40}
41
42// Using provided text, not from DB
43void AddGossipItemFor(Player* player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
44{
45 player->PlayerTalkClass->GetGossipMenu().AddMenuItem(0, -1, optionNpc, std::move(text), 0, GossipOptionFlags::None, {}, 0, 0, false, 0, "", {}, {}, sender, action);
46}
47
48// Using provided texts, not from DB
49void AddGossipItemFor(Player* player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action, std::string popupText, uint32 popupMoney, bool coded)
50{
51 player->PlayerTalkClass->GetGossipMenu().AddMenuItem(0, -1, optionNpc, std::move(text), 0, GossipOptionFlags::None, {}, 0, 0, coded, popupMoney, std::move(popupText), {}, {}, sender, action);
52}
53
54// Uses gossip item info from DB
55void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action)
56{
57 player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action);
58}
59
60void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const& guid)
61{
62 player->PlayerTalkClass->SendGossipMenu(npcTextID, guid);
63}
64
65void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature)
66{
67 if (creature)
68 SendGossipMenuFor(player, npcTextID, creature->GetGUID());
69}
70
72{
73 player->PlayerTalkClass->SendCloseGossip();
74}
uint32_t uint32
Definition: Define.h:142
GossipOptionNpc
Definition: GossipDef.h:35
uint32 GetGossipActionFor(Player *player, uint32 gossipListId)
uint32 GetGossipSenderFor(Player *player, uint32 menuId)
void AddGossipItemFor(Player *player, GossipOptionNpc optionNpc, std::string text, uint32 sender, uint32 action)
void SendGossipMenuFor(Player *player, uint32 npcTextID, ObjectGuid const &guid)
void ClearGossipMenuFor(Player *player)
void InitGossipMenuFor(Player *player, uint32 menuId)
void CloseGossipMenuFor(Player *player)
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:159
std::unique_ptr< PlayerMenu > PlayerTalkClass
Definition: Player.h:2380