Ejemplo n.º 1
0
 public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
 {
     if (info.ButtonID == 1)
     {
         ChatMessageManager.DisplayMessages(sender.Mobile);
     }
 }
Ejemplo n.º 2
0
        private static void SaveLists()
        {
            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }

            BinaryFileWriter writer = new BinaryFileWriter(SaveFile, true);

            writer.Write((int)_userListTable.Count);

            if (_userListTable.Count > 0)
            {
                foreach (KeyValuePair <Mobile, ChatInfo> kvp in _userListTable)
                {
                    if (kvp.Key == null || kvp.Key.Deleted || kvp.Value == null)
                    {
                        writer.Write((int)-1);
                    }
                    else
                    {
                        writer.Write((int)kvp.Key.Serial);
                        kvp.Value.Serialize(writer);
                    }
                }
            }

            writer.Close();

            ChatMessageManager.SerializeMessages();
        }
Ejemplo n.º 3
0
        private static void LoadLists()
        {
            if (!File.Exists(SaveFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(SaveFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    int serial = reader.ReadInt();

                    if (serial > -1)
                    {
                        Mobile   m    = World.FindMobile((Serial)serial);
                        ChatInfo info = new ChatInfo(reader);

                        if (m != null && !m.Deleted)
                        {
                            if (info != null && !_userListTable.ContainsKey(m))
                            {
                                _userListTable.Add(m, info);
                            }
                        }
                    }
                }
            }

            ChatMessageManager.DeserializeMessages();
        }
Ejemplo n.º 4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int val = (info.ButtonID - 1);

            if (val < 0)
            {
                return;
            }

            int type  = (val % 10);
            int index = (val / 10);

            switch (type)
            {
            case 0:
            {
                switch (index)
                {
                case 0:
                {
                    _client.SendGump(new ChatMessageListGump(_client, (byte)(_currentPage - 1)));
                    break;
                }

                case 1:
                {
                    _client.SendGump(new ChatMessageListGump(_client, (byte)(_currentPage + 1)));
                    break;
                }
                }

                break;
            }

            case 1:                     //read message at index
            {
                ChatMessageManager.RemoveMessage(_client, _messages[index]);
                _client.SendGump(new ChatReadMessageGump(_messages[index].Client, _client, _messages[index]));
                break;
            }
            }
        }
Ejemplo n.º 5
0
        public ChatMessageListGump(Mobile client, byte page)
            : base(10, 10)
        {
            _client      = client;
            _currentPage = Math.Max(page, (byte)1);

            List <ChatMessage> fullMessageList = ChatMessageManager.GetMessages(client);
            int rangeIdx = ((_currentPage * 10) - 10);
            int count    = Math.Min((fullMessageList.Count - rangeIdx), 10);

            List <ChatMessage> messages = fullMessageList.GetRange(rangeIdx, count);

            _messages = messages;

            int backSize = ((messages.Count > 0 ? 55 : 50) + (21 * messages.Count));

            AddPage(1);
            AddBackground(0, 0, 400, backSize, 9250);

            AddAlphaRegion(15, 15, 370, 20);
            AddHtml(15, 15, 370, 20, String.Format("<basefont color='white'><center>Message List - Unread: {0}</center></basefont>", fullMessageList.Count), false, false);

            if (page > 1)
            {
                AddButton(347, 18, 9706, 9607, ChatManager.GetButtonId(0, 0), GumpButtonType.Reply, 0);
            }

            if (fullMessageList.Count > (rangeIdx + 10))
            {
                AddButton(365, 18, 9702, 9703, ChatManager.GetButtonId(0, 1), GumpButtonType.Reply, 0);
            }

            for (int i = 0, y = 40; i < messages.Count; i++, y += 22)
            {
                AddAlphaRegion(15, y, 370, 20);
                AddButton(15, y, 4011, 4013, ChatManager.GetButtonId(1, i), GumpButtonType.Reply, 0);
                AddLabelCropped(50, y, 155, 20, ChatManager.GetGumpNameColor(_client, messages[i].Client), messages[i].Client.RawName);
                AddLabelCropped(210, y, 184, 20, ChatManager.GumpLabelHue, ChatMessageManager.FormatTimestamp(messages[i]));
            }
        }