public static void SendMessageTo(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
            {
                return;
            }

            AddMessageToQueue(from, message);

            if (from is PlayerMobile && from.NetState != null)
            {
                if (from.HasGump(typeof(NewMaginciaMessageGump)))
                {
                    from.CloseGump(typeof(NewMaginciaMessageGump));
                }

                if (from.HasGump(typeof(NewMaginciaMessageListGump)))
                {
                    from.CloseGump(typeof(NewMaginciaMessageListGump));
                }

                if (from.HasGump(typeof(NewMaginciaMessageDetailGump)))
                {
                    from.CloseGump(typeof(NewMaginciaMessageDetailGump));
                }

                if (HasMessageInQueue(from))
                {
                    BaseGump.SendGump(new NewMaginciaMessageGump((PlayerMobile)from));
                }
            }
        }
        public static void AddMessageToQueue(Mobile from, NewMaginciaMessage message)
        {
            if (!MessageQueue.ContainsKey(from) || m_MessageQueue[from] == null)
            {
                m_MessageQueue[from] = new List <NewMaginciaMessage>();
            }

            m_MessageQueue[from].Add(message);
        }
        public NewMaginciaMessageGump(Mobile from, NewMaginciaMessage message) : base(75, 75)
        {
            m_From    = from;
            m_Message = message;

            int messages = 1;

            if (MaginciaLottoSystem.MessageQueue.ContainsKey(from) && MaginciaLottoSystem.MessageQueue[from] != null)
            {
                messages = MaginciaLottoSystem.MessageQueue[from].Count;
            }

            AddBackground(0, 0, 424, 351, 9500);
            AddImage(5, 10, 5411);

            AddHtmlLocalized(40, 10, 100, 16, 1150425, messages.ToString(), GreenColor, false, false);

            if (message.Title != null)
            {
                if (message.Title.Number != 0)
                {
                    AddHtmlLocalized(195, 13, 150, 16, message.Title, GreenColor, false, false);
                }
                else
                {
                    AddHtml(150, 13, 195, 16, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", GreenColor, message.Title), false, false);
                }
            }

            if (message.Body != null)
            {
                if (message.Body.Number != 0)
                {
                    if (message.Args == null)
                    {
                        AddHtmlLocalized(10, 40, 404, 180, message.Body, BlueColor, true, true);
                    }
                    else
                    {
                        AddHtmlLocalized(10, 40, 404, 180, message.Body, message.Args, BlueColor, true, true);
                    }
                }
                else
                {
                    AddHtml(10, 40, 404, 180, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", BlueColor, message.Body), true, true);
                }
            }

            DateTime expires = message.Created + NewMaginciaMessage.ExpirePeriod;
            TimeSpan ts      = expires - DateTime.UtcNow;

            AddHtmlLocalized(5, 230, 414, 16, 1150432, String.Format("{0}\t{1}\t{2}", ts.Days, ts.Hours, ts.Minutes), GreenColor, false, false); // This message will expire in ~1_DAYS~ days, ~2_HOURS~ hours, and ~3_MIN~ minutes.

            AddButton(5, 250, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 250, 150, 16, 1150433, EntryColor, false, false); // DELETE NOW
        }
Exemple #4
0
        public override void OnResponse(RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0: break;

            case 1:
                if (m_Message != null)
                {
                    List <NewMaginciaMessage> messages = MaginciaLottoSystem.MessageQueue[User];

                    if (messages == null)
                    {
                        MaginciaLottoSystem.MessageQueue.Remove(User);
                    }
                    else
                    {
                        MaginciaLottoSystem.RemoveMessageFromQueue(User, m_Message);

                        if (MaginciaLottoSystem.HasMessageInQueue(User))
                        {
                            m_Message = m_Messages[0];
                            Refresh();
                        }
                    }
                }
                break;

            case 2:
                if (m_Message != null)
                {
                    m_Message = null;
                    Refresh();
                }
                else if (MaginciaLottoSystem.HasMessageInQueue(User))
                {
                    if (m_Messages != null && m_Messages.Count > 0)
                    {
                        m_Message = m_Messages[0];
                    }

                    Refresh();
                }
                break;

            default:
                int id = info.ButtonID - 1000;
                if (id >= 0 && id < m_Messages.Count)
                {
                    m_Message = m_Messages[id];
                }

                Refresh();
                break;
            }
        }
Exemple #5
0
        public void SendMessage_Callback(object o)
        {
            object[] obj = o as object[];

            if (obj != null)
            {
                Mobile             winner  = obj[0] as Mobile;
                NewMaginciaMessage message = obj[1] as NewMaginciaMessage;

                MaginciaLottoSystem.SendMessageTo(winner, message);
            }
        }
        public static void RemoveMessageFromQueue(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
            {
                return;
            }

            if (m_MessageQueue.ContainsKey(from) && m_MessageQueue[from].Contains(message))
            {
                m_MessageQueue[from].Remove(message);

                if (m_MessageQueue[from].Count == 0)
                {
                    m_MessageQueue.Remove(from);
                }
            }
        }
        public NewMaginciaMessageGump(Mobile from, NewMaginciaMessage message) : base(75, 75)
        {
            m_From = from;
            m_Message = message;

            int messages = 1;

            if (MaginciaLottoSystem.MessageQueue.ContainsKey(from) && MaginciaLottoSystem.MessageQueue[from] != null)
                messages = MaginciaLottoSystem.MessageQueue[from].Count;

            AddBackground(0, 0, 424, 351, 9500);
            AddImage(5, 10, 5411);

            AddHtmlLocalized(40, 10, 100, 16, 1150425, messages.ToString(), GreenColor, false, false);

            if (message.Title != null)
            {
                if (message.Title.Number != 0)
                    AddHtmlLocalized(195, 13, 150, 16, message.Title, GreenColor, false, false);
                else
                    AddHtml(150, 13, 195, 16, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", GreenColor, message.Title), false, false);
            }

            if (message.Body != null)
            {
                if (message.Body.Number != 0)
                {
                    if(message.Args == null)
                        AddHtmlLocalized(10, 40, 404, 180, message.Body, BlueColor, true, true);
                    else
                        AddHtmlLocalized(10, 40, 404, 180, message.Body, message.Args, BlueColor, true, true);
                }
                else
                    AddHtml(10, 40, 404, 180, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", BlueColor, message.Body), true, true);
            }

            DateTime expires = message.Created + NewMaginciaMessage.ExpirePeriod;
            TimeSpan ts = expires - DateTime.UtcNow;

            AddHtmlLocalized(5, 230, 414, 16, 1150432, String.Format("{0}\t{1}\t{2}", ts.Days, ts.Hours, ts.Minutes), GreenColor, false, false); // This message will expire in ~1_DAYS~ days, ~2_HOURS~ hours, and ~3_MIN~ minutes.

            AddButton(5, 250, 4005, 4007, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 250, 150, 16, 1150433, EntryColor, false, false); // DELETE NOW
        }
        public static void RemoveMessageFromQueue(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
            {
                return;
            }

            if (m_MessageQueue.ContainsKey(from) && m_MessageQueue[from].Contains(message))
            {
                m_MessageQueue[from].Remove(message);

                if (m_MessageQueue[from].Count == 0)
                {
                    m_MessageQueue.Remove(from);
                }

                return;
            }

            var account = from.Account as Account;

            for (int i = 0; i < account.Length; i++)
            {
                var m = account[i];

                if (m == from)
                {
                    continue;
                }

                if (m_MessageQueue.ContainsKey(m) && m_MessageQueue[m].Contains(message))
                {
                    m_MessageQueue[m].Remove(message);

                    if (m_MessageQueue[m].Count == 0)
                    {
                        m_MessageQueue.Remove(m);
                    }

                    break;
                }
            }
        }
Exemple #9
0
        public static void SendMessageTo(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
            {
                return;
            }

            AddMessageToQueue(from, message);

            if (from.NetState != null)
            {
                if (from.HasGump(typeof(NewMaginciaMessageGump)))
                {
                    from.CloseGump(typeof(NewMaginciaMessageGump));
                }

                if (HasMessageInQueue(from))
                {
                    from.SendGump(new NewMaginciaMessageGump(from, m_MessageQueue[from][0]));
                }
            }
        }
        public override void AddGumpLayout()
        {
            if (Messages == null)
            {
                return;
            }

            AddPage(0);

            int width    = Widescreen ? 200 : 0;
            int buttonid = Widescreen ? 0x1519 : 0x151A;

            AddBackground(0, 0, 314 + width, 241 + width, 0x24B8);
            AddButton(7, 7, 0x1523, 0x1523, 0, GumpButtonType.Reply, 0);
            AddButton(290 + width, 7, buttonid, buttonid, 1, GumpButtonType.Reply, 0);
            AddHtmlLocalized(47, 7, Widescreen ? 460 : 194, 18, 1150425, string.Format("{0}", Messages.Count), GreenColor, false, false); // ~1_COUNT~ Messages

            int page = 1;
            int y    = 0;

            AddPage(page);

            for (int i = 0; i < Messages.Count; i++)
            {
                if (page > 1)
                {
                    AddButton(Widescreen ? 446 : 246, 7, 0x1458, 0x1458, 0, GumpButtonType.Page, page - 1);
                }

                NewMaginciaMessage message = Messages[i];

                if (message == null)
                {
                    continue;
                }

                if (message.Title != null)
                {
                    if (message.Title.Number > 0)
                    {
                        AddHtmlLocalized(47, 34 + y * 32, 260 + width, 16, message.Title.Number, LightBlueColor, false, false);
                    }
                    else
                    {
                        AddHtml(40, 34 + y * 32, 260 + width, 16, Color("#94BDEF", message.Title.String), false, false);
                    }
                }
                else if (message.Body.Number > 0)
                {
                    if (message.Args == null)
                    {
                        AddHtmlLocalized(47, 34 + y * 32, 260 + width, 16, message.Body, LightBlueColor, false, false);
                    }
                    else
                    {
                        AddHtmlLocalized(47, 34 + y * 32, 260 + width, 16, message.Body, message.Args, LightBlueColor, false, false);
                    }
                }
                else
                {
                    AddHtml(40, 34 + y * 32, 260 + width, 16, Color("#94BDEF", message.Body.String), false, false);
                }

                AddButton(7, 34 + y * 32, 4029, 4031, i + 1000, GumpButtonType.Reply, 0);

                y++;

                bool pages = Widescreen && (i + 1) % 12 == 0 || !Widescreen && (i + 1) % 6 == 0;

                if (pages && Messages.Count - 1 != i)
                {
                    AddButton(Widescreen ? 468 : 268, 7, 0x1459, 0x1459, 0, GumpButtonType.Page, page + 1);
                    page++;
                    y = 0;

                    AddPage(page);
                }
            }
        }
 public NewMaginciaMessageDetailGump(PlayerMobile from, List <NewMaginciaMessage> messages, int messageid)
     : base(from, 490, 30)
 {
     Messages = messages;
     Message  = messages[messageid];
 }
Exemple #12
0
 public NewMaginciaMessageGump(PlayerMobile from, NewMaginciaMessage message = null)
     : base(from, 75, 75)
 {
     m_Message  = message;
     m_Messages = MaginciaLottoSystem.GetMessages(from);
 }
        public static void RemoveMessageFromQueue(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
                return;

            if (m_MessageQueue.ContainsKey(from) && m_MessageQueue[from].Contains(message))
            {
                m_MessageQueue[from].Remove(message);

                if (m_MessageQueue[from].Count == 0)
                    m_MessageQueue.Remove(from);
            }
        }
        public static void AddMessageToQueue(Mobile from, NewMaginciaMessage message)
        {
            if (!MessageQueue.ContainsKey(from) || m_MessageQueue[from] == null)
                m_MessageQueue[from] = new List<NewMaginciaMessage>();

            m_MessageQueue[from].Add(message);
        }
        public static void SendMessageTo(Mobile from, NewMaginciaMessage message)
        {
            if (from == null || message == null)
                return;

            AddMessageToQueue(from, message);

            if (from.NetState != null)
            {
                if(from.HasGump(typeof(NewMaginciaMessageGump)))
                    from.CloseGump(typeof(NewMaginciaMessageGump));

                if (HasMessageInQueue(from))
                    from.SendGump(new NewMaginciaMessageGump(from, m_MessageQueue[from][0]));
            }
        }