fix: Adds static warning/notice gumps. (#1741)

### Summary
* Adds `StaticNoticeGump<T>` and `StaticWarningGump<T>`
* Converts NoticeGump/WarningGump to use `DynamicGump`
* Changes various uses of notice gump and warning gump to their static counterpart.
This commit is contained in:
Kamron Batman 2024-04-26 17:19:16 -07:00 • committed by GitHub
parent 65532ea887
commit bb7bc57e42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 713 additions and 430 deletions

View file

@ -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, // <CENTER>NOTICE</CENTER>
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,
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
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
)
{
}
}