Exemple #1
0
        public override void OnClick()
        {
            PlayerMobile pm = Owner.From as PlayerMobile;

            if (pm != null)
            {
                Guild g = pm.Guild as Guild;

                if (g != null && pm.GuildRank != null && pm.GuildRank.Rank >= 3 && (pm.AccessLevel > AccessLevel.Player || g.Members.Count >= TownCryerSystem.MinGuildMemberCount))
                {
                    if (TownCryerSystem.HasGuildEntry(g))
                    {
                        Owner.From.SendLocalizedMessage(1158038); // You have reached the maximum entry count.  Please remove some and try again.
                    }
                    else
                    {
                        BaseGump.SendGump(new CreateGuildEntryGump(pm, Cryer));
                    }
                }
                else
                {
                    pm.SendLocalizedMessage(1158025); // Only Guild Leaders and Warlords of guilds with at least 20 members may post in the Town Cryer.
                }
            }
        }
Exemple #2
0
        private void BuildCityPage()
        {
            AddButton(233, 150, City == City.Britain ? 0x5E5 : 0x5E4, City == City.Britain ? 0x5E5 : 0x5E4, 10, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Britain));

            AddButton(280, 150, City == City.Jhelom ? 0x5E7 : 0x5E6, City == City.Jhelom ? 0x5E7 : 0x5E6, 11, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Jhelom));

            AddButton(327, 150, City == City.Minoc ? 0x5E5 : 0x5E4, City == City.Minoc ? 0x5E5 : 0x5E4, 12, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Minoc));

            AddButton(374, 150, City == City.Moonglow ? 0x5E3 : 0x5E2, City == City.Moonglow ? 0x5E3 : 0x5E2, 13, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Moonglow));

            AddButton(418, 150, City == City.NewMagincia ? 0x5DD : 0x5DC, City == City.NewMagincia ? 0x5DD : 0x5DC, 14, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.NewMagincia));

            AddButton(463, 150, City == City.SkaraBrae ? 0x5DF : 0x5DE, City == City.SkaraBrae ? 0x5DF : 0x5DE, 15, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.SkaraBrae));

            AddButton(509, 150, City == City.Trinsic ? 0x5E1 : 0x5E0, City == City.Trinsic ? 0x5E1 : 0x5E0, 16, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Trinsic));

            AddButton(555, 150, City == City.Vesper ? 0x5ED : 0x5ED, City == City.Vesper ? 0x5ED : 0x5EC, 17, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Vesper));

            AddButton(601, 150, City == City.Yew ? 0x5E9 : 0x5E8, City == City.Yew ? 0x5E9 : 0x5E8, 18, GumpButtonType.Reply, 0);
            AddTooltip(CityLoyaltySystem.GetCityLocalization(City.Yew));

            AddHtmlLocalized(0, 260, 854, 20, CenterLoc, string.Format("#{0}", TownCryerSystem.GetCityLoc(City)), 0, false, false); // The Latest News from the City of ~1_CITY~

            int y = 300;

            for (int i = 0; i < TownCryerSystem.CityEntries.Count && i < TownCryerSystem.MaxPerCityGoverrnorEntries; i++)
            {
                var entry = TownCryerSystem.CityEntries[i];

                if (entry.City != City)
                {
                    continue;
                }

                AddButton(50, y, 0x5FB, 0x5FC, 300 + i, GumpButtonType.Reply, 0);
                AddLabelCropped(87, y, 700, 20, 0, entry.Title);

                var city = CityLoyaltySystem.GetCitizenship(User, false);

                if ((city != null && city.Governor == User) || User.AccessLevel >= AccessLevel.GameMaster) // Only Governors
                {
                    AddButton(735, y, 0x5FD, 0x5FE, 3000 + i, GumpButtonType.Reply, 0);
                    AddButton(760, y, 0x5FF, 0x600, 3500 + i, GumpButtonType.Reply, 0);
                }

                y += 23;
            }

            AddImage(230, 460, 0x5F0);
        }
        public override void OnResponse(RelayInfo info)
        {
            int button = info.ButtonID;

            switch (button)
            {
            case 0: break;

            case 1:     // <<
                Page = 0;
                Refresh();
                break;

            case 2:     // <
                Page = Math.Max(0, Page - 1);
                Refresh();
                break;

            case 3:     // >
                Page = Math.Min(Pages - 1, Page + 1);
                Refresh();
                break;

            case 4:     // >>
                Page = Pages - 1;
                Refresh();
                break;

            case 5:     // No Show
                TownCryerSystem.AddExempt(User);
                break;

            case 7:
                if (Entry != null)
                {
                    BaseGump.SendGump(new CreateGreetingEntryGump(User, Cryer, Entry));
                }
                else
                {
                    Refresh();
                }
                break;

            case 8:
                BaseGump.SendGump(new CreateGreetingEntryGump(User, Cryer));
                break;

            case 9:
                Refresh();

                if (Entry != null)
                {
                    User.SendGump(new PropertiesGump(User, Entry));
                }
                break;
            }
        }
Exemple #4
0
        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();
            }
        }
Exemple #5
0
        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();
            }
        }
        public override void OnClick()
        {
            if (Owner.From is PlayerMobile pm)
            {
                CityLoyaltySystem system = CityLoyaltySystem.GetCitizenship(pm, false);

                if (TownCryerSystem.IsGovernor(pm, system))
                {
                    if (TownCryerSystem.CityEntryCount(system.City) < TownCryerSystem.MaxPerCityGoverrnorEntries)
                    {
                        BaseGump.SendGump(new CreateCityEntryGump(pm, Cryer, system.City));
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1158038); // You have reached the maximum entry count.  Please remove some and try again.
                    }
                }
            }
        }
Exemple #7
0
 public UpdateGuildEntry(Mobile from, TownCrier cryer)
     : base(1158024, 3) // Update Guild Town Crier
 {
     Cryer   = cryer;
     Enabled = from.Guild != null && !TownCryerSystem.HasGuildEntry(from.Guild as Guild);
 }
Exemple #8
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);
                }
            }
        }
        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();
            }
        }
        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();
            }
        }