From bb7bc57e42d004aef6aff4a6d7455e016e52e73b Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:19:16 -0700 Subject: [PATCH] fix: Adds static warning/notice gumps. (#1741) ### Summary * Adds `StaticNoticeGump` and `StaticWarningGump` * Converts NoticeGump/WarningGump to use `DynamicGump` * Changes various uses of notice gump and warning gump to their static counterpart. --- .../UOContent/Assistants/AssistantHandler.cs | 24 +- .../Commands/Generic/Commands/Commands.cs | 39 ++- .../Commands/Generic/Commands/DesignInsert.cs | 20 +- Projects/UOContent/Commands/Handlers.cs | 20 +- Projects/UOContent/Gumps/AdminGump.cs | 68 +--- Projects/UOContent/Gumps/HouseGumpAOS.cs | 326 ++++++++++++------ Projects/UOContent/Gumps/NoticeGump.cs | 90 ++--- Projects/UOContent/Gumps/StaticNoticeGump.cs | 13 + Projects/UOContent/Gumps/StaticWarningGump.cs | 95 +++++ Projects/UOContent/Gumps/WarningGump.cs | 133 ++++--- .../House Raffle/HouseRaffleManagementGump.cs | 4 +- .../Special/House Raffle/HouseRaffleStone.cs | 63 ++-- Projects/UOContent/Misc/ClientVerification.cs | 40 ++- .../Mobiles/Familiars/HordeMinion.cs | 18 +- Projects/UOContent/Mobiles/PlayerMobile.cs | 11 +- Projects/UOContent/Multis/Houses/BaseHouse.cs | 34 +- .../Multis/Houses/HousePlacementTool.cs | 99 +++--- Projects/UOContent/Multis/Houses/HouseSign.cs | 24 +- Projects/UOContent/Regions/HouseRegion.cs | 22 +- 19 files changed, 713 insertions(+), 430 deletions(-) create mode 100644 Projects/UOContent/Gumps/StaticNoticeGump.cs create mode 100644 Projects/UOContent/Gumps/StaticWarningGump.cs diff --git a/Projects/UOContent/Assistants/AssistantHandler.cs b/Projects/UOContent/Assistants/AssistantHandler.cs index cfc4beed1..a087faa10 100644 --- a/Projects/UOContent/Assistants/AssistantHandler.cs +++ b/Projects/UOContent/Assistants/AssistantHandler.cs @@ -36,18 +36,7 @@ public static class AssistantHandler if (AssistantConfiguration.Settings.WarnOnFailure) { - var warningGump = new WarningGump( - 1060635, - 30720, - AssistantConfiguration.Settings.WarningMessage, - 0xFFC000, - 420, - 250, - null, - false - ); - - m.SendGump(warningGump); + m.SendGump(new AssistantFailureWarningGump()); } if (isPlayer) @@ -154,4 +143,15 @@ public static class AssistantHandler ns.Send(writer.Span); } + + private class AssistantFailureWarningGump : StaticWarningGump + { + private static readonly TextDefinition _warningMessage = AssistantConfiguration.Settings.WarningMessage; + + public override int StaticLocalizedContent => _warningMessage?.Number ?? 0; + public override string Content => _warningMessage.String; + public override int Width => 420; + public override int Height => 250; + public override bool CancelButton => false; + } } diff --git a/Projects/UOContent/Commands/Generic/Commands/Commands.cs b/Projects/UOContent/Commands/Generic/Commands/Commands.cs index 12f5243db..904921d45 100644 --- a/Projects/UOContent/Commands/Generic/Commands/Commands.cs +++ b/Projects/UOContent/Commands/Generic/Commands/Commands.cs @@ -284,13 +284,8 @@ namespace Server.Commands.Generic } mob.SendGump( - new WarningGump( - 1060637, - 30720, - $"A game master is requesting to open your web browser to the following URL:
{url}", - 0xFFC000, - 320, - 240, + new OpenBrowserWarningGump( + url, okay => OpenBrowser_Callback(mob, okay, from, url, echo) ) ); @@ -307,6 +302,16 @@ namespace Server.Commands.Generic } } + private class OpenBrowserWarningGump : StaticWarningGump + { + public override string Content { get; } + public override int Width => 320; + public override int Height => 240; + + public OpenBrowserWarningGump(string url, Action callback) : base(callback) => + Content = $"A game master is requesting to open your web browser to the following URL:
{url}"; + } + public override void Execute(CommandEventArgs e, object obj) { Execute(e, obj, true); @@ -912,15 +917,7 @@ namespace Server.Commands.Generic { var from = e.Mobile; from.SendGump( - new WarningGump( - 1060637, - 30720, - $"You are about to delete {list.Count} objects. This cannot be undone without a full server revert.

Continue?", - 0xFFC000, - 420, - 280, - okay => OnConfirmCallback(from, okay, e, list) - ) + new DeleteObjectsNoticeGump(list.Count, okay => OnConfirmCallback(from, okay, e, list)) ); AddResponse("Awaiting confirmation..."); } @@ -930,6 +927,16 @@ namespace Server.Commands.Generic } } + private class DeleteObjectsNoticeGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + public override string Content { get; } + + public DeleteObjectsNoticeGump(int count, Action callback) : base(callback) => + Content = $"You are about to delete {count} objects. This cannot be undone without a full server revert.

Continue?"; + } + public override void Execute(CommandEventArgs e, object obj) { if (obj is Item item) diff --git a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs index e2e7c3cc8..345ff37c9 100644 --- a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs +++ b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Server.Gumps; using Server.Items; @@ -87,19 +88,24 @@ namespace Server.Commands.Generic { var from = e.Mobile; from.SendGump( - new WarningGump( - 1060637, - 30720, - $"You are about to insert {list.Count} objects. This cannot be undone without a full server revert.

Continue?", - 0xFFC000, - 420, - 280, + new InsertObjectsNoticeGump( + list.Count, okay => OnConfirmCallback(from, okay, list, e.Length < 1 || !e.GetBoolean(0)) ) ); AddResponse("Awaiting confirmation..."); } + private class InsertObjectsNoticeGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + public override string Content { get; } + + public InsertObjectsNoticeGump(int count, Action callback) : base(callback) => + Content = $"You are about to insert {count} objects. This cannot be undone without a full server revert.

Continue?"; + } + private void OnConfirmCallback(Mobile from, bool okay, List list, bool staticsOnly) { var flushToLog = false; diff --git a/Projects/UOContent/Commands/Handlers.cs b/Projects/UOContent/Commands/Handlers.cs index 0201423b5..9bd0a5023 100644 --- a/Projects/UOContent/Commands/Handlers.cs +++ b/Projects/UOContent/Commands/Handlers.cs @@ -251,13 +251,8 @@ namespace Server.Commands ); from.SendGump( - new WarningGump( - 1060635, - 30720, - $"You are about to delete {list.Count} object{(list.Count == 1 ? "" : "s")} from this facet. Do you really wish to continue?", - 0xFFC000, - 360, - 260, + new DeleteObjectsNoticeGump( + list.Count, okay => DeleteList_Callback(from, okay, list) ) ); @@ -268,6 +263,17 @@ namespace Server.Commands } } + private class DeleteObjectsNoticeGump : StaticWarningGump + { + public override int Header => 1060635; //
WARNING
+ public override int Width => 360; + public override int Height => 260; + public override string Content { get; } + + public DeleteObjectsNoticeGump(int count, Action callback) : base(callback) => + Content = $"You are about to delete {count} object{(count == 1 ? "" : "s")} from this facet. Do you really wish to continue?"; + } + [Usage("GetFollowers")] [Description("Teleports all pets of a targeted player to your location.")] public static void GetFollowers_OnCommand(CommandEventArgs e) diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 703622276..d85b6230c 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -1767,13 +1767,8 @@ namespace Server.Gumps } from.SendGump( - new NoticeGump( - 1060637, - 30720, + new AdminNoticeGump( $"You have {(ban ? "banned" : "deleted")} the account{(rads.Count == 1 ? "" : "s")}.", - 0xFFC000, - 420, - 280, () => ResendGump_Callback(from, list, rads, ban ? page : 0) ) ); @@ -1786,13 +1781,8 @@ namespace Server.Gumps else { from.SendGump( - new NoticeGump( - 1060637, - 30720, + new AdminNoticeGump( $"You have chosen not to {(ban ? "ban" : "delete")} the account{(rads.Count == 1 ? "" : "s")}.", - 0xFFC000, - 420, - 280, () => ResendGump_Callback(from, list, rads, page) ) ); @@ -3049,10 +3039,7 @@ namespace Server.Gumps from.SendGump( new WarningGump( - 1060635, - 30720, sb.ToString(), - 0xFFC000, 420, 400, okay => BanShared_Callback(from, okay, a) @@ -3099,10 +3086,7 @@ namespace Server.Gumps { from.SendGump( new WarningGump( - 1060635, - 30720, $"You are about to firewall {a.LoginIPs.Length} address{(a.LoginIPs.Length != 1 ? "s" : "")}. Do you wish to continue?", - 0xFFC000, 420, 400, okay => FirewallShared_Callback(from, okay, a) @@ -3237,10 +3221,7 @@ namespace Server.Gumps from.SendGump( new WarningGump( - 1060635, - 30720, $"
Account of {a.Username}

You are about to permanently delete the account. Likewise, all characters on the account will be deleted, including equipped, inventory, and banked items. Any houses tied to the account will be demolished.

Do you wish to continue?", - 0xFFC000, 420, 280, okay => AccountDelete_Callback(from, okay, a) @@ -3266,10 +3247,7 @@ namespace Server.Gumps { from.SendGump( new WarningGump( - 1060635, - 30720, $"You are about to ban {rads.Count} marked account{(rads.Count == 1 ? "" : "s")}. Be cautioned, the only way to reverse this is by hand--manually unbanning each account.

Do you wish to continue?", - 0xFFC000, 420, 280, okay => Marked_Callback(from, okay, true, list, rads, m_ListPage) @@ -3279,13 +3257,8 @@ namespace Server.Gumps else { from.SendGump( - new NoticeGump( - 1060637, - 30720, + new AdminNoticeGump( "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", - 0xFFC000, - 420, - 280, () => ResendGump_Callback(from, list, rads, m_ListPage) ) ); @@ -3306,14 +3279,7 @@ namespace Server.Gumps { from.SendGump( new WarningGump( - 1060635, - 30720, - string.Format( - "You are about to permanently delete {0} marked account{1}. Likewise, all characters on the account{1} will be deleted, including equipped, inventory, and banked items. Any houses tied to the account{1} will be demolished.

Do you wish to continue?", - rads.Count, - rads.Count == 1 ? "" : "s" - ), - 0xFFC000, + $"You are about to permanently delete {rads.Count} marked account{(rads.Count == 1 ? "" : "s")}. Likewise, all characters on the account{(rads.Count == 1 ? "" : "s")} will be deleted, including equipped, inventory, and banked items. Any houses tied to the account{(rads.Count == 1 ? "" : "s")} will be demolished.

Do you wish to continue?", 420, 280, okay => Marked_Callback(from, okay, false, list, rads, m_ListPage) @@ -3323,13 +3289,8 @@ namespace Server.Gumps else { from.SendGump( - new NoticeGump( - 1060637, - 30720, + new AdminNoticeGump( "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", - 0xFFC000, - 420, - 280, () => ResendGump_Callback(from, list, rads, m_ListPage) ) ); @@ -3554,10 +3515,7 @@ namespace Server.Gumps { from.SendGump( new WarningGump( - 1060635, - 30720, $"You are about to clear the address list for account {a} containing {ips.Length} {(ips.Length == 1 ? "entry" : "entries")}. Do you wish to continue?", - 0xFFC000, 420, 280, okay => RemoveLoginIPs_Callback(from, okay, a) @@ -3998,10 +3956,7 @@ namespace Server.Gumps { from.SendGump( new WarningGump( - 1060635, - 30720, $"You are about to firewall {m_List[index]}. All connection attempts from a matching IP will be refused. Are you sure?", - 0xFFC000, 420, 280, okay => Firewall_Callback(from, okay, a, m_List[index]) @@ -4100,10 +4055,7 @@ namespace Server.Gumps from.SendGump( new WarningGump( - 1060635, - 30720, $"You are about to remove address {ip} from account {a}. Do you wish to continue?", - 0xFFC000, 420, 280, okay => RemoveLoginIP_Callback(from, okay, a, ip) @@ -4395,5 +4347,15 @@ namespace Server.Gumps return aLevel < bLevel ? 1 : x.Username.InsensitiveCompare(y.Username); } } + + private class AdminNoticeGump : StaticNoticeGump + { + public override int Width => 420; + public override int Height => 280; + + public override string Content { get; } + + public AdminNoticeGump(string content, Action callback) : base(callback) => Content = content; + } } } diff --git a/Projects/UOContent/Gumps/HouseGumpAOS.cs b/Projects/UOContent/Gumps/HouseGumpAOS.cs index ddc22c886..44fd2706f 100644 --- a/Projects/UOContent/Gumps/HouseGumpAOS.cs +++ b/Projects/UOContent/Gumps/HouseGumpAOS.cs @@ -903,7 +903,7 @@ namespace Server.Gumps * These containers can be used to re-create the vendor in a new location. * Any barkeepers have been converted into deeds. */ - from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280)); + from.SendGump(new ReplaceHouseNoticeGump()); return; } } @@ -1107,13 +1107,7 @@ namespace Server.Gumps if (isOwner) { from.SendGump( - new WarningGump( - 1060635, - 30720, - 1060736, - 32512, - 420, - 280, + new RemoveAllCoOwnersWarningGump( okay => ClearCoOwners_Callback(from, okay, m_House) ) ); @@ -1153,13 +1147,7 @@ namespace Server.Gumps if (isCoOwner) { from.SendGump( - new WarningGump( - 1060635, - 30720, - 1018039, - 32512, - 420, - 280, + new RemoveAllFriendsWarningGump( okay => ClearFriends_Callback(from, okay, m_House) ) ); @@ -1176,15 +1164,7 @@ namespace Server.Gumps case 9: // Clear Ban List { from.SendGump( - new WarningGump( - 1060635, - 30720, - 1060753, - 32512, - 420, - 280, - okay => ClearBans_Callback(from, okay, m_House) - ) + new LifeAllBansWarningGump(okay => ClearBans_Callback(from, okay, m_House)) ); break; @@ -1198,15 +1178,7 @@ namespace Server.Gumps case 11: // Clear Access List { from.SendGump( - new WarningGump( - 1060635, - 30720, - 1061842, - 32512, - 420, - 280, - okay => ClearAccess_Callback(from, okay, m_House) - ) + new RevokeAccessWarning(okay => ClearAccess_Callback(from, okay, m_House)) ); break; @@ -1217,15 +1189,8 @@ namespace Server.Gumps { if (m_House.PlayerVendors.Count > 0) { - // You have vendors working out of this building. It cannot be declared private until there are no vendors in place. from.SendGump( - new NoticeGump( - 1060637, - 30720, - 501887, - 32512, - 320, - 180, + new CannotConvertPrivateNoticeGump( () => PublicPrivateNotice_Callback(from, m_House) ) ); @@ -1234,15 +1199,8 @@ namespace Server.Gumps if (m_House.VendorRentalContracts.Count > 0) { - // You cannot currently take this action because you have vendor contracts locked down in your home. You must remove them first. from.SendGump( - new NoticeGump( - 1060637, - 30720, - 1062351, - 32512, - 320, - 180, + new CannotPerformActionContractsNoticeGump( () => PublicPrivateNotice_Callback(from, m_House) ) ); @@ -1253,15 +1211,8 @@ namespace Server.Gumps m_House.ChangeLocks(from); - // This house is now private. from.SendGump( - new NoticeGump( - 1060637, - 30720, - 501888, - 32512, - 320, - 180, + new HouseConvertedPrivateNoticeGump( () => PublicPrivateNotice_Callback(from, m_House) ) ); @@ -1294,13 +1245,7 @@ namespace Server.Gumps if (BaseHouse.NewVendorSystem) { from.SendGump( - new NoticeGump( - 1060637, - 30720, - 501886, - 32512, - 320, - 180, + new HouseConvertedPublicNoticeGump( () => PublicPrivateNotice_Callback(from, m_House) ) ); @@ -1308,13 +1253,7 @@ namespace Server.Gumps else { from.SendGump( - new NoticeGump( - 1060637, - 30720, - "This house is now public. Friends of the house may now have vendors working out of this building.", - 0xF8C000, - 320, - 180, + new HouseConvertedPublicOldSystemNoticeGump( () => PublicPrivateNotice_Callback(from, m_House) ) ); @@ -1350,37 +1289,19 @@ namespace Server.Gumps { if (m_House.HasRentedVendors) { - // You cannot perform this action while you still have vendors rented out in this house. from.SendGump( - new NoticeGump( - 1060637, - 30720, - 1062395, - 32512, - 320, - 180, + new CannotPerformActionVendorsNoticeGump( () => CustomizeNotice_Callback(from, m_House) ) ); } - else + else if (m_House.ConvertEntry != null) { - var e = m_House.ConvertEntry; - - if (e != null) - { - from.SendGump( - new WarningGump( - 1060635, - 30720, - 1060013, - 32512, - 420, - 280, - okay => ConvertHouse_Callback(from, okay, m_House) - ) - ); - } + from.SendGump( + new ConvertToCustomHouseWarningGump( + okay => ConvertHouse_Callback(from, okay, m_House) + ) + ); } } @@ -1393,13 +1314,7 @@ namespace Server.Gumps if (m_House.HasRentedVendors) { from.SendGump( - new NoticeGump( - 1060637, - 30720, - 1062395, - 32512, - 320, - 180, + new CannotPerformActionVendorsNoticeGump( () => CustomizeNotice_Callback(from, m_House) ) ); @@ -1407,13 +1322,7 @@ namespace Server.Gumps else if (m_House.HasAddonContainers) { from.SendGump( - new NoticeGump( - 1060637, - 30720, - 1074863, - 32512, - 320, - 180, + new CannotCustomizeAddonsNoticeGump( () => CustomizeNotice_Callback(from, m_House) ) ); @@ -1739,5 +1648,202 @@ namespace Server.Gumps } } } + + private class RemoveAllCoOwnersWarningGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + + // You are about to remove ALL co-owners from your house. Are you certain you wish to clear the co-owner list? + public override int StaticLocalizedContent => 1060736; + + public RemoveAllCoOwnersWarningGump(Action callback) : base(callback) + { + } + } + + private class RemoveAllFriendsWarningGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + + /* + * If you go ahead with this option, all of the current friendships will be removed from the house, + * and any vendors associated with said friends will be made unwelcome. Are you sure you want to do this? + */ + public override int StaticLocalizedContent => 1018039; + + public RemoveAllFriendsWarningGump(Action callback) : base(callback) + { + } + } + + private class LifeAllBansWarningGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + + // You are about to lift all bans for this house. Are you sure you wish to do this? + public override int StaticLocalizedContent => 1060753; + + public LifeAllBansWarningGump(Action callback) : base(callback) + { + } + } + + private class RevokeAccessWarning : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + + /* + * This will revoke access from everyone on this list and immediately eject them from the house. + * Those players will no longer be able to enter the house. + * Are you sure you wish to clear the house access list? + */ + public override int StaticLocalizedContent => 1061842; + + public RevokeAccessWarning(Action callback) : base(callback) + { + } + } + + private class ConvertToCustomHouseWarningGump : StaticWarningGump + { + public override int Width => 420; + public override int Height => 280; + + /* + * You are about to turn your house into a customizable house. + * You will be refunded or charged the value of this house minus the cost of the equivalent customizable dirt lot. + * All of your possessions in the house will be transported to a Moving Crate. + * Deed-based house add-ons will be converted back into deeds. + * Vendors and barkeeps will also be stored in the Moving Crate. + * Your house will be leveled to its foundation, and you will be able to build new walls, windows, doors, and stairs. + * Are you sure you wish to continue? + */ + public override int StaticLocalizedContent => 1060013; + + public ConvertToCustomHouseWarningGump(Action callback) : base(callback) + { + } + } + + private class CannotPerformActionVendorsNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + // You cannot perform this action while you still have vendors rented out in this house. + public override int StaticLocalizedContent => 1062395; + + public CannotPerformActionVendorsNoticeGump(Action callback) : base(callback) + { + } + } + + private class CannotPerformActionContractsNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + /* + * You cannot currently take this action because you have vendor contracts locked down in your home. + * You must remove them first. + */ + public override int StaticLocalizedContent => 1062351; + + public CannotPerformActionContractsNoticeGump(Action callback) : base(callback) + { + } + } + + private class CannotCustomizeAddonsNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + /* + * The house cannot be customized when certain special house add-ons including aquariums, raised garden beds, + * and special temporary add-ons are present in the house. + * Please re-deed the special add-ons before customizing the house. + */ + public override int StaticLocalizedContent => 1074863; + + public CannotCustomizeAddonsNoticeGump(Action callback) : base(callback) + { + } + } + + private class ReplaceHouseNoticeGump : StaticNoticeGump + { + public override int Width => 420; + public override int Height => 280; + + /* + * You have successfully replaced your original house with a new house. + * The value of the replaced house has been deposited into your bank box. + * All of the items in your original house have been relocated to a Moving Crate in the new house. + * Any deed-based house add-ons have been converted back into deeds. + * Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well. + * Use the Get Vendor context-sensitive menu option on your character to retrieve them. + * These containers can be used to re-create the vendor in a new location. + * Any barkeepers have been converted into deeds. + */ + public override int StaticLocalizedContent => 1060012; + } + + private class HouseConvertedPublicNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + // This house is now public. The owner may now place vendors and vendor rental contracts. + public override int StaticLocalizedContent => 501886; + + public HouseConvertedPublicNoticeGump(Action callback) : base(callback) + { + } + } + + private class CannotConvertPrivateNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + /* + * You have vendors working out of this building. + * It cannot be declared private until there are no vendors in place. + */ + public override int StaticLocalizedContent => 501887; + + public CannotConvertPrivateNoticeGump(Action callback) : base(callback) + { + } + } + + private class HouseConvertedPrivateNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + public override int StaticLocalizedContent => 501888; // This house is now private. + + public HouseConvertedPrivateNoticeGump(Action callback) : base(callback) + { + } + } + + private class HouseConvertedPublicOldSystemNoticeGump : StaticNoticeGump + { + public override int Width => 320; + public override int Height => 180; + + public override string Content { get; } + + public HouseConvertedPublicOldSystemNoticeGump(Action callback) : base(callback) => + Content = + "This house is now public. Friends of the house may now have vendors working out of this building."; + } } } diff --git a/Projects/UOContent/Gumps/NoticeGump.cs b/Projects/UOContent/Gumps/NoticeGump.cs index a416dbdf3..7903b7be1 100644 --- a/Projects/UOContent/Gumps/NoticeGump.cs +++ b/Projects/UOContent/Gumps/NoticeGump.cs @@ -1,65 +1,37 @@ -using Server.Network; +using System; -namespace Server.Gumps +namespace Server.Gumps; + +public class NoticeGump : WarningGump { - public delegate void NoticeGumpCallback(); - - public class NoticeGump : Gump + public NoticeGump( + TextDefinition content, int width, int height, + Action callback = null + ) : this( + 1060637, //
NOTICE
+ 0x7800, + content, + 0xFFC000, + width, + height, + callback + ) { - private readonly NoticeGumpCallback m_Callback; + } - public NoticeGump( - int header, int headerColor, TextDefinition content, int contentColor, int width, int height, - NoticeGumpCallback callback = null - ) : base((640 - width) / 2, (480 - height) / 2) - { - m_Callback = callback; - - Closable = false; - - AddPage(0); - - AddBackground(0, 0, width, height, 5054); - - AddImageTiled(10, 10, width - 20, 20, 2624); - AddAlphaRegion(10, 10, width - 20, 20); - AddHtmlLocalized(10, 10, width - 20, 20, header, headerColor); - - AddImageTiled(10, 40, width - 20, height - 80, 2624); - AddAlphaRegion(10, 40, width - 20, height - 80); - - if (content != null) - { - if (content.Number > 0) - { - AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true); - } - else - { - AddHtml( - 10, - 40, - width - 20, - height - 80, - $"{content.String}", - false, - true - ); - } - } - - AddImageTiled(10, height - 30, width - 20, 20, 2624); - AddAlphaRegion(10, height - 30, width - 20, 20); - AddButton(10, height - 30, 4005, 4007, 1); - AddHtmlLocalized(40, height - 30, 120, 20, 1011036, 32767); // OKAY - } - - public override void OnResponse(NetState sender, in RelayInfo info) - { - if (info.ButtonID == 1) - { - m_Callback?.Invoke(); - } - } + public NoticeGump( + int header, int headerColor, TextDefinition content, int contentColor, int width, int height, + Action callback = null + ) : base( + header, + headerColor, + content, + contentColor, + width, + height, + callback != null ? _ => callback() : null, + false + ) + { } } diff --git a/Projects/UOContent/Gumps/StaticNoticeGump.cs b/Projects/UOContent/Gumps/StaticNoticeGump.cs new file mode 100644 index 000000000..2a1b956b8 --- /dev/null +++ b/Projects/UOContent/Gumps/StaticNoticeGump.cs @@ -0,0 +1,13 @@ +using System; + +namespace Server.Gumps; + +public abstract class StaticNoticeGump : StaticWarningGump where T : StaticNoticeGump +{ + public override int Header => 1060637; //
NOTICE
+ public sealed override bool CancelButton => false; + + public StaticNoticeGump(Action callback = null) : base(callback != null ? _ => callback() : null) + { + } +} diff --git a/Projects/UOContent/Gumps/StaticWarningGump.cs b/Projects/UOContent/Gumps/StaticWarningGump.cs new file mode 100644 index 000000000..2cf54a5e4 --- /dev/null +++ b/Projects/UOContent/Gumps/StaticWarningGump.cs @@ -0,0 +1,95 @@ +using System; +using Server.Network; + +namespace Server.Gumps; + +public abstract class StaticWarningGump : StaticGump where T : StaticWarningGump +{ + public virtual int Header => 1060635; //
WARNING
+ public virtual int HeaderColor => 0x7800; + public virtual int ContentColor => StaticLocalizedContent > 0 ? 0x7F00 : 0xFFC000; + public abstract int Width { get; } + public abstract int Height { get; } + public virtual bool CancelButton => true; + + // If this is overridden, then the content will be localized and cached. + public virtual int StaticLocalizedContent => 0; + + public virtual string Content => null; + + private readonly Action _callback; + + public StaticWarningGump(Action callback = null) : base(0, 0) + { + _callback = callback; + X = (640 - Width) / 2; + Y = (480 - Height) / 2; + } + + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + var width = Width; + var height = Height; + var header = Header; + var headerColor = HeaderColor; + var cancelButton = CancelButton; + + builder.SetNoClose(); + + builder.AddPage(); + + builder.AddBackground(0, 0, width, height, 5054); + + builder.AddImageTiled(10, 10, width - 20, 20, 2624); + builder.AddAlphaRegion(10, 10, width - 20, 20); + builder.AddHtmlLocalized(10, 10, width - 20, 20, header, (short)headerColor); + + builder.AddImageTiled(10, 40, width - 20, height - 80, 2624); + builder.AddAlphaRegion(10, 40, width - 20, height - 80); + + if (StaticLocalizedContent > 0) + { + builder.AddHtmlLocalized( + 10, + 40, + width - 20, + height - 80, + StaticLocalizedContent, + (short)ContentColor, + false, + true + ); + } + else + { + builder.AddHtmlPlaceholder( + 10, + 40, + width - 20, + height - 80, + "content", + false, + true + ); + } + + builder.AddImageTiled(10, height - 30, width - 20, 20, 2624); + builder.AddAlphaRegion(10, height - 30, width - 20, 20); + + builder.AddButton(10, height - 30, 4005, 4007, 1); + builder.AddHtmlLocalized(40, height - 30, 170, 20, 1011036, 32767); // OKAY + + if (cancelButton) + { + builder.AddButton(10 + (width - 20) / 2, height - 30, 4005, 4007, 0); + builder.AddHtmlLocalized(40 + (width - 20) / 2, height - 30, 170, 20, 1011012, 32767); // CANCEL + } + } + + protected sealed override void BuildStrings(ref GumpStringsBuilder builder) + { + builder.SetStringSlot("content", $"{Content}"); + } + + public override void OnResponse(NetState sender, in RelayInfo info) => _callback?.Invoke(info.ButtonID == 1); +} diff --git a/Projects/UOContent/Gumps/WarningGump.cs b/Projects/UOContent/Gumps/WarningGump.cs index d78f489b7..b635655a2 100644 --- a/Projects/UOContent/Gumps/WarningGump.cs +++ b/Projects/UOContent/Gumps/WarningGump.cs @@ -1,66 +1,97 @@ +using System; using Server.Network; -namespace Server.Gumps +namespace Server.Gumps; + +public class WarningGump : DynamicGump { - public delegate void WarningGumpCallback(bool okay); + private readonly int _header; + private readonly int _headerColor; + private readonly int _contentColor; + private readonly int _width; + private readonly int _height; + private readonly bool _cancelButton; + private readonly TextDefinition _content; + private readonly Action _callback; - public class WarningGump : Gump + public WarningGump( + TextDefinition content, int width, int height, + Action callback = null, bool cancelButton = true + ) : this( + 1060635, //
WARNING
+ 0x7800, + content, + 0xFFC000, + width, + height, + callback, + cancelButton + ) { - private readonly WarningGumpCallback m_Callback; + } - public WarningGump( - int header, int headerColor, TextDefinition content, int contentColor, int width, int height, - WarningGumpCallback callback = null, bool cancelButton = true - ) : base((640 - width) / 2, (480 - height) / 2) + public WarningGump( + int header, int headerColor, TextDefinition content, int contentColor, int width, int height, + Action callback = null, bool cancelButton = true + ) : base((640 - width) / 2, (480 - height) / 2) + { + _header = header; + _headerColor = headerColor; + _content = content; + _contentColor = contentColor; + _width = width; + _height = height; + _cancelButton = cancelButton; + _callback = callback; + } + + protected sealed override void BuildLayout(ref DynamicGumpBuilder builder) + { + builder.SetNoClose(); + + builder.AddPage(); + + builder.AddBackground(0, 0, _width, _height, 5054); + + builder.AddImageTiled(10, 10, _width - 20, 20, 2624); + builder.AddAlphaRegion(10, 10, _width - 20, 20); + builder.AddHtmlLocalized(10, 10, _width - 20, 20, _header, (short)_headerColor); + + builder.AddImageTiled(10, 40, _width - 20, _height - 80, 2624); + builder.AddAlphaRegion(10, 40, _width - 20, _height - 80); + + if (_content != null) { - m_Callback = callback; - - Closable = false; - - AddPage(0); - - AddBackground(0, 0, width, height, 5054); - - AddImageTiled(10, 10, width - 20, 20, 2624); - AddAlphaRegion(10, 10, width - 20, 20); - AddHtmlLocalized(10, 10, width - 20, 20, header, headerColor); - - AddImageTiled(10, 40, width - 20, height - 80, 2624); - AddAlphaRegion(10, 40, width - 20, height - 80); - - if (content != null) + if (_content.Number > 0) { - if (content.Number > 0) - { - AddHtmlLocalized(10, 40, width - 20, height - 80, content.Number, contentColor, false, true); - } - else - { - AddHtml( - 10, - 40, - width - 20, - height - 80, - $"{content.String}", - false, - true - ); - } + builder.AddHtmlLocalized(10, 40, _width - 20, _height - 80, _content.Number, (short)_contentColor, false, true); } - - AddImageTiled(10, height - 30, width - 20, 20, 2624); - AddAlphaRegion(10, height - 30, width - 20, 20); - - AddButton(10, height - 30, 4005, 4007, 1); - AddHtmlLocalized(40, height - 30, 170, 20, 1011036, 32767); // OKAY - - if (cancelButton) + else { - AddButton(10 + (width - 20) / 2, height - 30, 4005, 4007, 0); - AddHtmlLocalized(40 + (width - 20) / 2, height - 30, 170, 20, 1011012, 32767); // CANCEL + builder.AddHtml( + 10, + 40, + _width - 20, + _height - 80, + $"{_content.String}", + false, + true + ); } } - public override void OnResponse(NetState sender, in RelayInfo info) => m_Callback?.Invoke(info.ButtonID == 1); + builder.AddImageTiled(10, _height - 30, _width - 20, 20, 2624); + builder.AddAlphaRegion(10, _height - 30, _width - 20, 20); + + builder.AddButton(10, _height - 30, 4005, 4007, 1); + builder.AddHtmlLocalized(40, _height - 30, 170, 20, 1011036, 0x7FFF); // OKAY + + if (_cancelButton) + { + builder.AddButton(10 + (_width - 20) / 2, _height - 30, 4005, 4007, 0); + builder.AddHtmlLocalized(40 + (_width - 20) / 2, _height - 30, 170, 20, 1011012, 32767); // CANCEL + } } + + public override void OnResponse(NetState sender, in RelayInfo info) => _callback?.Invoke(info.ButtonID == 1); } diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs index 397e7bc44..711115b67 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -63,10 +63,10 @@ public class HouseRaffleManagementGump : Gump AddHtml(10, 10, 598, 20, Color(Center("Raffle Management"), LabelColor)); AddHtml(45, 35, 100, 20, Color("Location:", LabelColor)); - AddHtml(145, 35, 250, 20, Color(_stone.FormatLocation(), LabelColor)); + AddHtml(145, 35, 250, 20, Color(HouseRaffleStone.FormatLocation(stone.PlotBounds, stone.GetPlotCenter(), stone.PlotFacet), LabelColor)); AddHtml(45, 55, 100, 20, Color("Ticket Price:", LabelColor)); - AddHtml(145, 55, 250, 20, Color(_stone.FormatPrice(), LabelColor)); + AddHtml(145, 55, 250, 20, Color(HouseRaffleStone.FormatPrice(stone.TicketPrice), LabelColor)); AddHtml(45, 75, 100, 20, Color("Total Entries:", LabelColor)); AddHtml(145, 75, 250, 20, Color(_stone.Entries.Count.ToString(), LabelColor)); diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index 7812153c6..b42128a9e 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Runtime.CompilerServices; using ModernUO.Serialization; using Server.Accounting; using Server.ContextMenus; @@ -234,10 +235,11 @@ public partial class HouseRaffleStone : Item } } - public bool ValidLocation() => - _plotBounds.Start != Point2D.Zero && - _plotBounds.End != Point2D.Zero && - _plotFacet != null && _plotFacet != Map.Internal; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool ValidLocation(Rectangle2D bounds, Map map) => + bounds.Start != Point2D.Zero && + bounds.End != Point2D.Zero && + map != null && map != Map.Internal; private void InvalidateRegion() { @@ -247,7 +249,7 @@ public partial class HouseRaffleStone : Item _region = null; } - if (ValidLocation()) + if (ValidLocation(_plotBounds, _plotFacet)) { _region = new HouseRaffleRegion(this); _region.Register(); @@ -337,25 +339,27 @@ public partial class HouseRaffleStone : Item return new Point3D(x, y, z); } - public string FormatLocation() => - !ValidLocation() ? "no location set" : FormatLocation(GetPlotCenter(), _plotFacet, true); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string FormatLocation(Rectangle2D bounds, Point3D center, Map map) => + !ValidLocation(bounds, map) ? "no location set" : FormatLocation(center, map, true); - public string FormatPrice() => _ticketPrice == 0 ? "FREE" : $"{_ticketPrice} gold"; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static string FormatPrice(int price) => price == 0 ? "FREE" : $"{price} gold"; public override void GetProperties(IPropertyList list) { base.GetProperties(list); - if (ValidLocation()) + if (ValidLocation(_plotBounds, _plotFacet)) { - list.Add(FormatLocation()); + list.Add(FormatLocation(_plotBounds, GetPlotCenter(), _plotFacet)); } switch (_currentState) { case HouseRaffleState.Active: { - list.Add(1060658, $"{"ticket price"}\t{FormatPrice()}"); // ~1_val~: ~2_val~ + list.Add(1060658, $"{"ticket price"}\t{FormatPrice(_ticketPrice)}"); // ~1_val~: ~2_val~ list.Add(1060659, $"{"ends"}\t{_started + _duration}"); // ~1_val~: ~2_val~ break; } @@ -433,13 +437,11 @@ public partial class HouseRaffleStone : Item else { from.SendGump( - new WarningGump( - 1150470, // CONFIRM TICKET PURCHASE - 0x7F00, - $"You are about to purchase a raffle ticket for the house plot located at {FormatLocation()}. The ticket price is {FormatPrice()}. Tickets are non-refundable and you can only purchase one ticket per account. Do you wish to continue?", - 0xFFFFFF, - 420, - 280, + new ConfirmTicketPurchaseGump( + _plotBounds, + GetPlotCenter(), + _plotFacet, + _ticketPrice, okay => Purchase_Callback(from, okay) ) ); @@ -471,7 +473,7 @@ public partial class HouseRaffleStone : Item } else { - from.SendMessage(MessageHue, $"You do not have the {FormatPrice()} required to enter the raffle."); + from.SendMessage(MessageHue, $"You do not have the {FormatPrice(_ticketPrice)} required to enter the raffle."); } } else @@ -499,7 +501,7 @@ public partial class HouseRaffleStone : Item _winner.SendMessage( MessageHue, - $"Congratulations, {_winner.Name}! You have won the raffle for the plot located at {FormatLocation()}." + $"Congratulations, {_winner.Name}! You have won the raffle for the plot located at {FormatLocation(_plotBounds, GetPlotCenter(), _plotFacet)}." ); if (_winner.AddToBackpack(Deed)) @@ -628,7 +630,7 @@ public partial class HouseRaffleStone : Item { public ActivateEntry(Mobile from, HouseRaffleStone stone) : base(from, stone, 5113) // Start { - if (!stone.ValidLocation()) + if (!ValidLocation(stone._plotBounds, stone._plotFacet)) { Flags |= CMEFlags.Disabled; } @@ -636,7 +638,7 @@ public partial class HouseRaffleStone : Item public override void OnClick() { - if (_stone.Deleted || _from.AccessLevel < AccessLevel.Seer || !_stone.ValidLocation()) + if (_stone.Deleted || _from.AccessLevel < AccessLevel.Seer || !ValidLocation(_stone._plotBounds, _stone._plotFacet)) { return; } @@ -661,4 +663,21 @@ public partial class HouseRaffleStone : Item _from.SendGump(new HouseRaffleManagementGump(_stone)); } } + + private class ConfirmTicketPurchaseGump : StaticWarningGump + { + public override int Header => 1150470; // CONFIRM TICKET PURCHASE + public override int HeaderColor => 0x7F00; + public override int ContentColor => 0xFFFFFF; + public override int Width => 420; + public override int Height => 280; + + public override string Content { get; } + + public ConfirmTicketPurchaseGump(Rectangle2D bounds, Point3D center, Map map, int price, Action callback) : base(callback) + { + Content = + $"You are about to purchase a raffle ticket for the house plot located at {FormatLocation(bounds, center, map)}. The ticket price is {FormatPrice(price)}. Tickets are non-refundable and you can only purchase one ticket per account. Do you wish to continue?"; + } + } } diff --git a/Projects/UOContent/Misc/ClientVerification.cs b/Projects/UOContent/Misc/ClientVerification.cs index 615afd5dd..124425648 100644 --- a/Projects/UOContent/Misc/ClientVerification.cs +++ b/Projects/UOContent/Misc/ClientVerification.cs @@ -220,7 +220,7 @@ namespace Server.Misc } } - private static void KickMessage(Mobile from, bool okay) + private static void KickMessage(Mobile from) { from.SendMessage("You will be reminded of this again."); @@ -238,23 +238,7 @@ namespace Server.Misc { if (m.NetState != null) { - Gump g = new WarningGump( - 1060637, - 30720, - $"Your client is invalid.
This server recommends that your client version is {GetVersionExpression()}.

You are currently using version {m.NetState.Version}.", - 0xFFC000, - 480, - 360, - okay => KickMessage(m, okay), - false - ) - { - Draggable = false, - Closable = false, - Resizable = false, - }; - - m.SendGump(g); + m.SendGump(new AnnoyGump(m.NetState.Version, () => KickMessage(m))); } } @@ -266,5 +250,25 @@ namespace Server.Misc LenientKick, Kick } + + private class AnnoyGump : StaticNoticeGump + { + public override int Width => 480; + public override int Height => 360; + + public override string Content { get; } + + public AnnoyGump(ClientVersion version, Action callback) : base(callback) => + Content = $"Your client is invalid.
This server recommends that your client version is {GetVersionExpression()}.

You are currently using version {version}."; + + protected override void BuildLayout(ref StaticGumpBuilder builder) + { + builder.SetNoDispose(); + builder.SetNoResize(); + builder.SetNoMove(); + + base.BuildLayout(ref builder); + } + } } } diff --git a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs index e0fcf847b..00d4e3d73 100644 --- a/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs +++ b/Projects/UOContent/Mobiles/Familiars/HordeMinion.cs @@ -121,7 +121,7 @@ public partial class HordeMinionFamiliar : BaseFamiliar if (Backpack?.Items.Count > 0) { from.SendGump( - new WarningGump(1060635, 30720, 1061672, 32512, 420, 280, okay => ConfirmRelease_Callback(from, okay)) + new ReleaseFamiliarWarningGump(okay => ConfirmRelease_Callback(from, okay)) ); } else @@ -185,4 +185,20 @@ public partial class HordeMinionFamiliar : BaseFamiliar PackAnimal.GetContextMenuEntries(this, from, list); } + + private class ReleaseFamiliarWarningGump : StaticWarningGump + { + /* + * If you release your familiar, everything in its backpack will be destroyed! + * Are you sure you want to release your familiar? + */ + public override int StaticLocalizedContent => 1061672; + + public override int Width => 420; + public override int Height => 280; + + public ReleaseFamiliarWarningGump(Action callback) : base(callback) + { + } + } } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index d4a7c3165..c417e7aa1 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -1246,7 +1246,7 @@ namespace Server.Mobiles notice = "The server is currently under lockdown. You have sufficient access level to connect."; } - from.SendGump(new NoticeGump(1060637, 30720, notice, 0xFFC000, 300, 140)); + from.SendGump(new ServerLockdownNoticeGump(notice)); return; } @@ -1257,6 +1257,15 @@ namespace Server.Mobiles } } + private class ServerLockdownNoticeGump : StaticNoticeGump + { + public override int Width => 300; + public override int Height => 140; + public override string Content { get; } + + public ServerLockdownNoticeGump(string content) => Content = content; + } + public void ValidateEquipment() { if (m_NoDeltaRecursion || Map == null || Map == Map.Internal) diff --git a/Projects/UOContent/Multis/Houses/BaseHouse.cs b/Projects/UOContent/Multis/Houses/BaseHouse.cs index 71d273e80..c6402d7ca 100644 --- a/Projects/UOContent/Multis/Houses/BaseHouse.cs +++ b/Projects/UOContent/Multis/Houses/BaseHouse.cs @@ -2240,22 +2240,8 @@ namespace Server.Multis if (HasRentedVendors) { - /* You are about to be traded a home that has active vendor contracts. - * While there are active vendor contracts in this house, you - * cannot demolish OR customize the home. - * When you accept this house, you also accept landlordship for every - * contract vendor in the house. - */ to.SendGump( - new WarningGump( - 1060635, - 30720, - 1062487, - 32512, - 420, - 280, - okay => ConfirmTransfer_Callback(to, okay, from) - ) + new TradeHouseWarningGump(okay => ConfirmTransfer_Callback(to, okay, from)) ); } else @@ -2266,6 +2252,24 @@ namespace Server.Multis } } + private class TradeHouseWarningGump : StaticWarningGump + { + /* + * You are about to be traded a home that has active vendor contracts. + * While there are active vendor contracts in this house, you + * cannot demolish OR customize the home. + * When you accept this house, you also accept landlordship for every contract vendor in the house. + */ + public override int StaticLocalizedContent => 1062487; + + public override int Width => 420; + public override int Height => 280; + + public TradeHouseWarningGump(Action callback) : base(callback) + { + } + } + private void ConfirmTransfer_Callback(Mobile to, bool ok, Mobile from) { if (!ok || Deleted || !from.CheckAlive() || !IsOwner(from)) diff --git a/Projects/UOContent/Multis/Houses/HousePlacementTool.cs b/Projects/UOContent/Multis/Houses/HousePlacementTool.cs index 87265d6f4..8ff26147b 100644 --- a/Projects/UOContent/Multis/Houses/HousePlacementTool.cs +++ b/Projects/UOContent/Multis/Houses/HousePlacementTool.cs @@ -1996,11 +1996,7 @@ namespace Server.Items if (prevHouse.Deleted) { - /* Too much time has passed and the test house you created has been deleted. - * Please try again! - */ - from.SendGump(new NoticeGump(1060637, 30720, 1060647, 32512, 320, 180)); - + from.SendGump(new HousePlacementTimeoutNoticeGump()); return; } @@ -2040,18 +2036,15 @@ namespace Server.Items { if (Banker.Withdraw(from, Cost)) { - from.SendLocalizedMessage( - 1060398, - Cost.ToString() - ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + // ~1_AMOUNT~ gold has been withdrawn from your bank box. + from.SendLocalizedMessage(1060398, Cost.ToString()); } else { house.RemoveKeys(from); house.Delete(); - from.SendLocalizedMessage( - 1060646 - ); // You do not have the funds available in your bank box to purchase this house. Try placing a smaller house, or adding gold or checks to your bank box. + // You do not have the funds available in your bank box to purchase this house. Try placing a smaller house, or adding gold or checks to your bank box. + from.SendLocalizedMessage(1060646); return; } } @@ -2081,9 +2074,8 @@ namespace Server.Items case HousePlacementResult.BadRegionHidden: case HousePlacementResult.NoSurface: { - from.SendLocalizedMessage( - 1043287 - ); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + from.SendLocalizedMessage(1043287); break; } case HousePlacementResult.BadRegion: @@ -2093,16 +2085,14 @@ namespace Server.Items } case HousePlacementResult.BadRegionTemp: { - from.SendLocalizedMessage( - 501270 - ); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + from.SendLocalizedMessage(501270); break; } case HousePlacementResult.BadRegionRaffle: { - from.SendLocalizedMessage( - 1150493 - ); // You must have a deed for this plot of land in order to build here. + // You must have a deed for this plot of land in order to build here. + from.SendLocalizedMessage(1150493); break; } case HousePlacementResult.InvalidCastleKeep: @@ -2170,28 +2160,8 @@ namespace Server.Items prev.MoveToWorld(center, from.Map); - /* You are about to place a new house. - * Placing this house will condemn any and all of your other houses that you may have. - * All of your houses on all shards will be affected. - * - * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week. - * - * Once you accept these terms, these effects cannot be reversed. - * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed. - * - * If you are absolutely certain you wish to proceed, click the button next to OKAY below. - * If you do not wish to trade for this house, click CANCEL. - */ from.SendGump( - new WarningGump( - 1060635, - 30720, - 1049583, - 32512, - 420, - 280, - okay => PlacementWarning_Callback(from, okay, prev) - ) + new CondemnWarningGump(okay => PlacementWarning_Callback(from, okay, prev)) ); return true; @@ -2205,9 +2175,8 @@ namespace Server.Items case HousePlacementResult.BadRegionHidden: case HousePlacementResult.NoSurface: { - from.SendLocalizedMessage( - 1043287 - ); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + from.SendLocalizedMessage(1043287); break; } case HousePlacementResult.BadRegion: @@ -2217,16 +2186,14 @@ namespace Server.Items } case HousePlacementResult.BadRegionTemp: { - from.SendLocalizedMessage( - 501270 - ); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + from.SendLocalizedMessage(501270); break; } case HousePlacementResult.BadRegionRaffle: { - from.SendLocalizedMessage( - 1150493 - ); // You must have a deed for this plot of land in order to build here. + // You must have a deed for this plot of land in order to build here. + from.SendLocalizedMessage(1150493); break; } case HousePlacementResult.InvalidCastleKeep: @@ -2311,5 +2278,35 @@ namespace Server.Items } } } + + private class CondemnWarningGump : StaticWarningGump + { + /* + * You are about to place a new house. + * Placing this house will condemn any and all of your other houses that you may have. + * All of your houses on all shards will be affected.

In addition, you will not be able to place + * another house or have one transferred to you for one (1) real-life week.

+ * Once you accept these terms, these effects cannot be reversed. + * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one + * week timer be removed.

If you are absolutely certain you wish to proceed, click the button next to OKAY below. + * If you do not wish to trade for this house, click CANCEL. + */ + + public override int StaticLocalizedContent => 1049583; + public override int Width => 420; + public override int Height => 280; + + public CondemnWarningGump(Action callback) : base(callback) + { + } + } + + private class HousePlacementTimeoutNoticeGump : StaticWarningGump + { + // Too much time has passed and the test house you created has been deleted. Please try again! + public override int StaticLocalizedContent => 1060647; + public override int Width => 320; + public override int Height => 180; + } } } diff --git a/Projects/UOContent/Multis/Houses/HouseSign.cs b/Projects/UOContent/Multis/Houses/HouseSign.cs index 4a5fcd199..d5759bb60 100644 --- a/Projects/UOContent/Multis/Houses/HouseSign.cs +++ b/Projects/UOContent/Multis/Houses/HouseSign.cs @@ -168,7 +168,7 @@ namespace Server.Multis if (canClaim && !BaseHouse.HasAccountHouse(m)) { m.SendGump( - new WarningGump(501036, 32512, 1049719, 32512, 420, 280, okay => ClaimGump_Callback(m, okay)) + new ClaimHouseWarningGump(okay => ClaimGump_Callback(m, okay)) ); } } @@ -176,6 +176,28 @@ namespace Server.Multis ShowSign(m); } + private class ClaimHouseWarningGump : StaticWarningGump + { + public override int Header => 501036; // Claim house + public override int HeaderColor => 0x7F00; + + /* + * You do not currently own any house on any shard with this account, and this house currently does not have an owner. + * If you wish, you may choose to claim this house and become its rightful owner. + * If you do this, it will become your Primary house and automatically refresh. + * If you claim this house, you will be unable to place another house or have another house transferred to you for the next 7 days. + * Do you wish to claim this house? + */ + public override int StaticLocalizedContent => 1049719; + + public override int Width => 420; + public override int Height => 280; + + public ClaimHouseWarningGump(Action callback) : base(callback) + { + } + } + public override void GetContextMenuEntries(Mobile from, List list) { base.GetContextMenuEntries(from, list); diff --git a/Projects/UOContent/Regions/HouseRegion.cs b/Projects/UOContent/Regions/HouseRegion.cs index dbbf6f71d..6d9ff162d 100644 --- a/Projects/UOContent/Regions/HouseRegion.cs +++ b/Projects/UOContent/Regions/HouseRegion.cs @@ -125,9 +125,9 @@ public class HouseRegion : BaseRegion } if (House.InternalizedVendors.Count > 0 && House.IsInside(m) && !House.IsInside(oldLocation, 16) && - House.IsOwner(m) && m.Alive && !m.HasGump()) + House.IsOwner(m) && m.Alive && !m.HasGump()) { - m.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); + m.SendGump(new RecentlyCustomizedWarningGump()); } m_Recursion = false; @@ -193,9 +193,9 @@ public class HouseRegion : BaseRegion if (House.InternalizedVendors.Count > 0 && House.IsInside(from) && !House.IsInside(oldLocation, 16) && House.IsOwner(from) && from.Alive && - !from.HasGump()) + !from.HasGump()) { - from.SendGump(new NoticeGump(1060635, 30720, 1061826, 32512, 320, 180)); + from.SendGump(new RecentlyCustomizedWarningGump()); } return true; @@ -402,4 +402,18 @@ public class HouseRegion : BaseRegion return base.OnSingleClick(from, o); } + + // TODO: Should this be a notice gump instead? + private class RecentlyCustomizedWarningGump : StaticWarningGump + { + /* + * This house has been customized recently, and vendors that work out of this house have been temporarily relocated. + * You must now put your vendors back to work. + * To do this, walk to a location inside the house where you wish to station your vendor, then activate the context-sensitive menu on your avatar and select "Get Vendor". + */ + public override int StaticLocalizedContent => 1061826; + public override int Width => 320; + public override int Height => 180; + public override bool CancelButton => false; + } }