예제 #1
0
        public uint AddMenuItem(int optionIndex, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false)
        {
            Cypher.Assert(_menuItems.Count <= SharedConst.MaxGossipMenuItems);

            // Find a free new id - script case
            if (optionIndex == -1)
            {
                optionIndex = 0;
                if (!_menuItems.Empty())
                {
                    foreach (var item in _menuItems)
                    {
                        if (item.Key > optionIndex)
                        {
                            break;
                        }

                        optionIndex = (int)item.Key + 1;
                    }
                }
            }

            GossipMenuItem menuItem = new GossipMenuItem();

            menuItem.MenuItemIcon = (byte)icon;
            menuItem.Message      = message;
            menuItem.IsCoded      = coded;
            menuItem.Sender       = sender;
            menuItem.OptionType   = action;
            menuItem.BoxMessage   = boxMessage;
            menuItem.BoxMoney     = boxMoney;

            _menuItems[(uint)optionIndex] = menuItem;
            return((uint)optionIndex);
        }
예제 #2
0
        public void AddMenuItem(int menuItemId, GossipOptionIcon icon, string message, uint sender, uint action, string boxMessage, uint boxMoney, bool coded = false)
        {
            Contract.Assert(_menuItems.Count <= SharedConst.MaxGossipMenuItems);

            // Find a free new id - script case
            if (menuItemId == -1)
            {
                menuItemId = 0;
                if (!_menuItems.Empty())
                {
                    foreach (var item in _menuItems)
                    {
                        if (item.Key > menuItemId)
                        {
                            break;
                        }

                        menuItemId = (int)item.Key + 1;
                    }
                }
            }

            GossipMenuItem menuItem = new GossipMenuItem();

            menuItem.MenuItemIcon = (byte)icon;
            menuItem.Message      = message;
            menuItem.IsCoded      = coded;
            menuItem.Sender       = sender;
            menuItem.OptionType   = action;
            menuItem.BoxMessage   = boxMessage;
            menuItem.BoxMoney     = boxMoney;

            _menuItems[(uint)menuItemId] = menuItem;
        }
예제 #3
0
        public void SendGossipMenu(uint titleTextId, ObjectGuid objectGUID)
        {
            _interactionData.Reset();
            _interactionData.SourceGuid = objectGUID;

            GossipMessagePkt packet = new GossipMessagePkt();

            packet.GossipGUID = objectGUID;
            packet.GossipID   = (int)_gossipMenu.GetMenuId();
            packet.TextID     = (int)titleTextId;

            foreach (var pair in _gossipMenu.GetMenuItems())
            {
                ClientGossipOptions opt  = new ClientGossipOptions();
                GossipMenuItem      item = pair.Value;
                opt.ClientOption = (int)pair.Key;
                opt.OptionNPC    = item.MenuItemIcon;
                opt.OptionFlags  = (byte)(item.IsCoded ? 1 : 0); // makes pop up box password
                opt.OptionCost   = (int)item.BoxMoney;           // money required to open menu, 2.0.3
                opt.Text         = item.Message;                 // text for gossip item
                opt.Confirm      = item.BoxMessage;              // accept text (related to money) pop up box, 2.0.3
                opt.Status       = GossipOptionStatus.Available;
                packet.GossipOptions.Add(opt);
            }

            for (byte i = 0; i < _questMenu.GetMenuItemCount(); ++i)
            {
                QuestMenuItem item    = _questMenu.GetItem(i);
                uint          questID = item.QuestId;
                Quest         quest   = Global.ObjectMgr.GetQuestTemplate(questID);
                if (quest != null)
                {
                    ClientGossipText text = new ClientGossipText();
                    text.QuestID         = questID;
                    text.ContentTuningID = quest.ContentTuningId;
                    text.QuestType       = item.QuestIcon;
                    text.QuestFlags      = (uint)quest.Flags;
                    text.QuestFlagsEx    = (uint)quest.FlagsEx;
                    text.Repeatable      = quest.IsRepeatable();

                    text.QuestTitle = quest.LogTitle;
                    Locale locale = _session.GetSessionDbLocaleIndex();
                    if (locale != Locale.enUS)
                    {
                        QuestTemplateLocale localeData = Global.ObjectMgr.GetQuestLocale(quest.Id);
                        if (localeData != null)
                        {
                            ObjectManager.GetLocaleString(localeData.LogTitle, locale, ref text.QuestTitle);
                        }
                    }

                    packet.GossipText.Add(text);
                }
            }

            _session.SendPacket(packet);
        }