diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 43d6c1bef..202e199d9 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -12,6 +12,7 @@ using Server.Misc; using Server.Multis; using Server.Network; using Server.Prompts; +using Server.Saves; using Server.Text; namespace Server.Gumps @@ -295,6 +296,9 @@ namespace Server.Gumps AddButtonLabeled(20, 230, GetButtonID(3, 203), "Shutdown & Restart (With Save)"); AddButtonLabeled(20, 250, GetButtonID(3, 204), "Shutdown & Restart (Without Save)"); + + AddButtonLabeled(20, 270, GetButtonID(3, 205), "Shutdown (With 15m Delay & Save)"); + /*} else { @@ -2147,6 +2151,12 @@ namespace Server.Gumps Shutdown(true, false); break; } + case 205: // shutdown with delay and save + { + var t = new ShutdownTimer(this); + t.Start(); + break; + } case 210: case 211: { @@ -4251,5 +4261,30 @@ namespace Server.Gumps public AdminNoticeGump(string content, Action callback) : base(callback) => Content = content; } + + public class ShutdownTimer : Timer + { + private readonly AdminGump _adminGump; + + public ShutdownTimer(AdminGump gump) : base(TimeSpan.Zero, TimeSpan.Zero, 8) => + _adminGump = gump; + + protected override void OnTick() + { + if (Index >= 7) + { + AutoSave.SavesEnabled = false; + _adminGump.Shutdown(false, true); + return; + } + + ReadOnlySpan times = [15, 10, 5, 4, 3, 2, 1, 0]; + var time = times[Index]; + _adminGump.m_From.SendMessage( + $"The shard will shutdown in {time} minute{(time == 1 ? "s" : "")} for maintenance." + ); + Interval = TimeSpan.FromMinutes(time - times[Index + 1]); + } + } } }