public CreateGreetingEntryGump(PlayerMobile pm, TownCrier cryer, TownCryerGreetingEntry entry = null) : base(pm, cryer) { Entry = entry; if (Entry != null) { Edit = true; } }
public CreateGreetingEntryGump(PlayerMobile pm, TownCrier cryer, TownCryerGreetingEntry entry = null) : base(pm, cryer) { Entry = entry; if (Entry != null) { Edit = true; _Headline = Entry.Title.String; _Body = Entry.Body1 != null ? Entry.Body1.String : String.Empty; _Body2 = Entry.Body2 != null ? Entry.Body2 : String.Empty; _Body3 = Entry.Body3 != null ? Entry.Body3 : String.Empty; _Link = Entry.Link; _LinkText = Entry.LinkText; } }
public override void AddGumpLayout() { base.AddGumpLayout(); var list = TownCryerSystem.GreetingsEntries; Entry = TownCryerSystem.GreetingsEntries[0]; if (Page >= 0 && Page < list.Count) { Entry = list[Page]; } int y = 150; if (Entry.Title != null) { if (Entry.Title.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Title.Number, false, false); } else { AddHtml(78, y, 700, 400, Entry.Title.ToString(), false, false); } y += 40; } if (Entry.Body.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Body.Number, false, false); } else { AddHtml(78, y, 700, 400, Entry.Body.ToString(), false, false); } if (Entry.Expires != DateTime.MinValue) { AddHtmlLocalized(50, 550, 200, 20, 1060658, String.Format("{0}\t{1}", "Created", Entry.Created.ToShortDateString()), 0, false, false); AddHtmlLocalized(50, 570, 200, 20, 1060659, String.Format("{0}\t{1}", "Expires", Entry.Expires.ToShortDateString()), 0, false, false); } AddButton(350, 570, 0x605, 0x606, 1, GumpButtonType.Reply, 0); AddButton(380, 570, 0x609, 0x60A, 2, GumpButtonType.Reply, 0); AddButton(430, 570, 0x607, 0x608, 3, GumpButtonType.Reply, 0); AddButton(455, 570, 0x603, 0x604, 4, GumpButtonType.Reply, 0); AddHtml(395, 570, 35, 20, Center(String.Format("{0}/{1}", (Page + 1).ToString(), Pages.ToString())), false, false); AddButton(525, 625, 0x5FF, 0x600, 5, GumpButtonType.Reply, 0); AddHtmlLocalized(550, 625, 300, 20, 1158386, false, false); // Close and do not show this version again if (Entry.Link != null) { if (!string.IsNullOrEmpty(Entry.LinkText)) { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.LinkText), false, false); } else { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.Link), false, false); } } /*if (TownCryerSystem.HasCustomEntries()) * { * AddButton(40, 615, 0x603, 0x604, 6, GumpButtonType.Reply, 0); * AddHtmlLocalized(68, 615, 300, 20, 1060660, String.Format("{0}\t{1}", "Sort By", Sort.ToString()), 0, false, false); * }*/ if (User.AccessLevel >= AccessLevel.Administrator) { AddButton(40, 640, 0x603, 0x604, 7, GumpButtonType.Reply, 0); AddHtml(68, 640, 300, 20, "Entry Props", false, false); } }
public static void Load(GenericReader reader) { int version = reader.ReadInt(); int greetingsCount = 0; switch (version) { case 1: greetingsCount = reader.ReadInt(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { PlayerMobile pm = reader.ReadMobile() as PlayerMobile; if (pm != null) { AddExempt(pm); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { TownCryerGreetingEntry entry = new TownCryerGreetingEntry(reader); if (!entry.Expired) { GreetingsEntries.Add(entry); } } goto case 0; case 0: count = reader.ReadInt(); for (int i = 0; i < count; i++) { TownCryerModeratorEntry entry = new TownCryerModeratorEntry(reader); if (!entry.Expired) { ModeratorEntries.Add(entry); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { TownCryerCityEntry entry = new TownCryerCityEntry(reader); if (!entry.Expired) { CityEntries.Add(entry); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { TownCryerGuildEntry entry = new TownCryerGuildEntry(reader); if (!entry.Expired) { GuildEntries.Add(entry); } } count = reader.ReadInt(); for (int i = 0; i < count; i++) { Mobile m = reader.ReadMobile(); DateTime dt = reader.ReadDateTime(); if (m != null) { if (MysteriousPotionEffects == null) { MysteriousPotionEffects = new Dictionary <Mobile, DateTime>(); } MysteriousPotionEffects[m] = dt; } } break; } if (greetingsCount < GreetingsEntries.Count) { NewGreeting = true; } CheckTimer(); }
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 static void AddEntry(TownCryerGreetingEntry entry) { GreetingsEntries.Add(entry); CheckTimer(); }
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 AddGumpLayout() { base.AddGumpLayout(); List <TownCryerGreetingEntry> list = new List <TownCryerGreetingEntry>(TownCryerSystem.GreetingsEntries); list.Sort(); Entry = list[0]; if (Page >= 0 && Page < list.Count) { Entry = list[Page]; } int y = 150; if (Entry.Title != null) { if (Entry.Title.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Title.Number, false, false); } else { AddHtml(78, y, 700, 400, Entry.Title.ToString(), false, false); } y += 40; } // For now, we're only supporting a cliloc (hard coded greetings per EA) or string (Custom) entries. Not both. // Html tags will needed to be added when creating the entry, this will not auto format it for you. if (Entry.Body1.Number > 0) { AddHtmlLocalized(78, y, 700, 400, Entry.Body1.Number, false, false); } else if (!String.IsNullOrEmpty(Entry.Body1.String)) { string str = Entry.Body1.String; if (!String.IsNullOrEmpty(Entry.Body2)) { if (!str.EndsWith("<br>")) { str += " "; } str += Entry.Body2; } if (!String.IsNullOrEmpty(Entry.Body3)) { if (!str.EndsWith("<br>")) { str += " "; } str += Entry.Body3; } AddHtml(78, y, 700, 400, str, false, false); } if (Entry.Expires != DateTime.MinValue) { AddHtmlLocalized(50, 550, 200, 20, 1060658, String.Format("{0}\t{1}", "Created", Entry.Created.ToShortDateString()), 0, false, false); AddHtmlLocalized(50, 570, 200, 20, 1060659, String.Format("{0}\t{1}", "Expires", Entry.Expires.ToShortDateString()), 0, false, false); } AddButton(350, 570, 0x605, 0x606, 1, GumpButtonType.Reply, 0); AddButton(380, 570, 0x609, 0x60A, 2, GumpButtonType.Reply, 0); AddButton(430, 570, 0x607, 0x608, 3, GumpButtonType.Reply, 0); AddButton(455, 570, 0x603, 0x604, 4, GumpButtonType.Reply, 0); AddHtml(395, 570, 35, 20, Center(String.Format("{0}/{1}", (Page + 1).ToString(), Pages.ToString())), false, false); AddButton(525, 625, 0x5FF, 0x600, 5, GumpButtonType.Reply, 0); AddHtmlLocalized(550, 625, 300, 20, 1158386, false, false); // Close and do not show this version again if (Entry.Link != null) { if (!string.IsNullOrEmpty(Entry.LinkText)) { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.LinkText), false, false); } else { AddHtml(50, 490, 745, 40, String.Format("<a href=\"{0}\">{1}</a>", Entry.Link, Entry.Link), false, false); } } /*if (TownCryerSystem.HasCustomEntries()) * { * AddButton(40, 615, 0x603, 0x604, 6, GumpButtonType.Reply, 0); * AddHtmlLocalized(68, 615, 300, 20, 1060660, String.Format("{0}\t{1}", "Sort By", Sort.ToString()), 0, false, false); * }*/ if (User.AccessLevel >= AccessLevel.Administrator) { if (Entry.CanEdit) { AddButton(40, 601, 0x603, 0x604, 7, GumpButtonType.Reply, 0); AddHtml(68, 601, 300, 20, "Edit Greeting", false, false); } AddButton(40, 623, 0x603, 0x604, 8, GumpButtonType.Reply, 0); AddHtml(68, 623, 300, 20, "New Greeting", false, false); AddButton(40, 645, 0x603, 0x604, 9, GumpButtonType.Reply, 0); AddHtml(68, 645, 300, 20, "Entry Props", false, false); } ColUtility.Free(list); }
public static void Save(GenericWriter writer) { writer.Write(1); writer.Write(GreetingsEntries.Count); writer.Write(TownCryerExempt.Count); for (var index = 0; index < TownCryerExempt.Count; index++) { PlayerMobile pm = TownCryerExempt[index]; writer.Write(pm); } int count = 0; for (var index = 0; index < GreetingsEntries.Count; index++) { var x = GreetingsEntries[index]; if (x.Saves) { count++; } } writer.Write(count); for (var index = 0; index < GreetingsEntries.Count; index++) { TownCryerGreetingEntry e = GreetingsEntries[index]; if (e.Saves) { e.Serialize(writer); } } writer.Write(ModeratorEntries.Count); for (var index = 0; index < ModeratorEntries.Count; index++) { TownCryerModeratorEntry e = ModeratorEntries[index]; e.Serialize(writer); } writer.Write(CityEntries.Count); for (var index = 0; index < CityEntries.Count; index++) { TownCryerCityEntry e = CityEntries[index]; e.Serialize(writer); } writer.Write(GuildEntries.Count); for (var index = 0; index < GuildEntries.Count; index++) { TownCryerGuildEntry e = GuildEntries[index]; e.Serialize(writer); } writer.Write(MysteriousPotionEffects != null ? MysteriousPotionEffects.Count : 0); if (MysteriousPotionEffects != null) { foreach (KeyValuePair <Mobile, DateTime> kvp in MysteriousPotionEffects) { writer.Write(kvp.Key); writer.Write(kvp.Value); } } }