コード例 #1
0
ファイル: CreateEMEntryGump.cs プロジェクト: zmazza/ServUO
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                string headline = info.GetTextEntry(1).Text;
                string body1    = info.GetTextEntry(2).Text;
                string body2    = info.GetTextEntry(3).Text;
                string body3    = info.GetTextEntry(4).Text;
                string exp      = info.GetTextEntry(5).Text;

                int expires = Utility.ToInt32(exp);

                if (Entry == null)
                {
                    Entry = new TownCryerModeratorEntry(User, expires, headline, body1, body2, body3);
                }
                else
                {
                    Entry.Title = headline;
                    Entry.Body1 = body1;
                    Entry.Body2 = body2;
                    Entry.Body3 = body3;

                    if (expires >= 1 && expires <= 30)
                    {
                        Entry.Expires = DateTime.Now + TimeSpan.FromDays(expires);
                    }
                }

                if (expires < 1 || expires > 30)
                {
                    User.SendLocalizedMessage(1158033); // The expiry can be between 1 and 30 days. Please check your entry and try again.
                }
                else if (string.IsNullOrEmpty(headline) || string.IsNullOrEmpty(body1) || headline.Length < 5 || body1.Length < 5)
                {
                    User.SendLocalizedMessage(1158032); // You have made an illegal entry.  Check your entries and try again.
                }
                else
                {
                    if (!Edit)
                    {
                        TownCryerSystem.AddEntry(Entry);
                    }

                    User.SendLocalizedMessage(1158039); // Your entry has been submitted.

                    SendGump(new TownCryerGump(User, Cryer, 0, TownCryerGump.GumpCategory.EventModerator));
                    return;
                }

                Refresh();
            }
        }
コード例 #2
0
ファイル: CreateCityEntryGump.cs プロジェクト: ygtkms/ServUO
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                string headline = info.GetTextEntry(1).Text;
                string body     = info.GetTextEntry(2).Text;
                string exp      = info.GetTextEntry(3).Text;

                int expires = Utility.ToInt32(exp);

                if (Entry == null)
                {
                    Entry = new TownCryerCityEntry(User, City, expires, headline, body);
                }
                else
                {
                    Entry.Title = headline;
                    Entry.Body  = body;

                    if (expires >= 1 && expires <= 14)
                    {
                        Entry.Expires = DateTime.Now + TimeSpan.FromDays(expires);
                    }
                }

                if (expires < 1 || expires > 14)
                {
                    User.SendLocalizedMessage(1158042); // The expiry can be between 1 and 14 days. Please check your entry and try again.
                }
                else if (string.IsNullOrEmpty(headline) || string.IsNullOrEmpty(body) || headline.Length < 3 || body.Length < 5)
                {
                    User.SendLocalizedMessage(1158032); // The expiry can be between 1 and 30 days. Please check your entry and try again.
                }
                else
                {
                    if (!Edit)
                    {
                        TownCryerSystem.AddEntry(Entry);
                    }

                    User.SendLocalizedMessage(1158039); // Your entry has been submitted.

                    BaseGump.SendGump(new TownCryerGump(User, Cryer, 0, TownCryerGump.GumpCategory.City));
                    return;
                }

                Refresh();
            }
        }
コード例 #3
0
        private static void LoadPreloadedMessages()
        {
            if (!Enabled || !UsePreloadedMessages)
            {
                return;
            }

            if (File.Exists(PreLoadedPath))
            {
                XmlDocument doc = new XmlDocument();
                Utility.WriteConsoleColor(ConsoleColor.Cyan, "*** Loading Pre-Loaded Town Crier Messages...");

                try
                {
                    doc.Load(PreLoadedPath);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Utility.WriteConsoleColor(ConsoleColor.Cyan, "...FAILED! ***");
                    return;
                }

                XmlElement root    = doc["preloadedTC"];
                int        good    = 0;
                int        expired = 0;
                int        errors  = 0;

                if (root != null)
                {
                    int index = 0;

                    foreach (XmlElement reg in root.GetElementsByTagName("message"))
                    {
                        string   title    = Utility.GetText(reg["title"], null);
                        string   body     = Utility.GetText(reg["body"], null);
                        DateTime created  = GetDateTime(Utility.GetText(reg["created"], null));
                        DateTime expires  = GetDateTime(Utility.GetText(reg["expires"], null));
                        string   link     = Utility.GetText(reg["link"], null);
                        string   linktext = Utility.GetText(reg["linktext"], null);

                        if (title == null)
                        {
                            ErrorToConsole("Invalid title", index);
                            errors++;
                        }
                        else if (body == null)
                        {
                            ErrorToConsole("Invalid body", index);
                            errors++;
                        }
                        else if (created == DateTime.MinValue)
                        {
                            ErrorToConsole("Invalid creation time", index);
                            errors++;
                        }
                        else if (expires > DateTime.Now || expires == DateTime.MinValue)
                        {
                            TownCryerGreetingEntry entry = new TownCryerGreetingEntry(title, body, -1, link, linktext);

                            entry.PreLoaded = true;
                            entry.Created   = created;

                            if (expires > created)
                            {
                                entry.Expires = expires;
                            }

                            TownCryerSystem.AddEntry(entry);
                            good++;
                        }
                        else
                        {
                            ErrorToConsole("Expired message", index);
                            expired++;
                        }

                        index++;
                    }
                }

                if (expired > 0 || errors > 0)
                {
                    Utility.WriteConsoleColor(ConsoleColor.Cyan, "...Complete! Loaded {0} Pre-Loaded Messages. {1} expired messages and {2} erroneous messages not loaded! ***", good, expired, errors);
                }
                else
                {
                    Utility.WriteConsoleColor(ConsoleColor.Cyan, "...Complete! Loaded {0} Pre-Loaded Messages. ***", good);
                }
            }
        }
コード例 #4
0
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                HandleText(info);

                var headline = _Headline;
                var body     = _Body;
                var body2    = _Body2;
                var body3    = _Body3;
                var exp      = _Expires;
                var link     = _Link;
                var linkText = _LinkText;

                int expires = -1;

                if (!String.IsNullOrEmpty(exp))
                {
                    expires = Utility.ToInt32(exp);
                }

                if (Entry == null)
                {
                    Entry = new TownCryerGreetingEntry(headline, body, body2, body3, expires, link, linkText, true);
                }
                else
                {
                    Entry.Title    = headline;
                    Entry.Body1    = body;
                    Entry.Body2    = body2;
                    Entry.Body3    = body3;
                    Entry.Link     = link;
                    Entry.LinkText = linkText;

                    if (expires >= 1 && expires <= 30)
                    {
                        Entry.Expires = DateTime.Now + TimeSpan.FromDays(expires);
                    }
                }

                if (!Edit && (expires < 1 || expires > 30))
                {
                    User.SendLocalizedMessage(1158033); // The expiry can be between 1 and 30 days. Please check your entry and try again.
                }
                else if (string.IsNullOrEmpty(headline) || string.IsNullOrEmpty(body) || headline.Length < 5 || body.Length < 5)
                {
                    User.SendLocalizedMessage(1158032); // You have made an illegal entry.  Check your entries and try again.
                }
                else
                {
                    if (!Edit)
                    {
                        TownCryerSystem.AddEntry(Entry);
                        User.SendLocalizedMessage(1158039); // Your entry has been submitted.
                    }
                    else
                    {
                        User.SendMessage("Your edited entry has been submitted.");
                    }

                    return;
                }

                Refresh();
            }
        }
コード例 #5
0
        public override void OnResponse(RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                string headline = info.GetTextEntry(1).Text;
                string m        = info.GetTextEntry(2).Text;
                string d        = info.GetTextEntry(3).Text;
                string t        = info.GetTextEntry(4).Text;
                string desc     = info.GetTextEntry(5).Text;
                string meet     = info.GetTextEntry(6).Text;

                DateTime dt          = DateTime.Now;
                bool     illegalDate = false;

                int year = dt.Year;

                if (Utility.ToInt32(m) < DateTime.Now.Month)
                {
                    year++;
                }

                if (Entry == null)
                {
                    if (!DateTime.TryParse(string.Format("{0}/{1}/{2} {3}:00:00", m, d, year.ToString(), t), out dt)) // bad format
                    {
                        illegalDate = true;
                        dt          = DateTime.MinValue;
                    }

                    Entry = new TownCryerGuildEntry(User, dt, meet, headline, desc);
                }
                else
                {
                    Entry.Title         = headline;
                    Entry.Body          = desc;
                    Entry.EventLocation = meet;

                    if (DateTime.TryParse(string.Format("{0}/{1}/{2} {3}:00:00", m, d, year.ToString(), t), out dt))
                    {
                        Entry.EventTime = dt;
                    }
                }

                if (string.IsNullOrEmpty(headline) || string.IsNullOrEmpty(desc) || string.IsNullOrEmpty(meet))
                {
                    User.SendLocalizedMessage(1158062); // All fields must be populated.  Please check your entries and try again.
                }
                else if (illegalDate)
                {
                    User.SendLocalizedMessage(1158032); // You have made an illegal entry.  Check your entries and try again.
                }
                else
                {
                    if (!Edit)
                    {
                        TownCryerSystem.AddEntry(Entry);
                    }

                    User.SendLocalizedMessage(1158039); // Your entry has been submitted.

                    BaseGump.SendGump(new TownCryerGump(User, Cryer, 0, TownCryerGump.GumpCategory.Guild));
                    return;
                }

                Refresh();
            }
        }