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:
parent
65532ea887
commit
bb7bc57e42
19 changed files with 713 additions and 430 deletions
|
|
@ -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<bool> _callback;
|
||||
|
||||
public class WarningGump : Gump
|
||||
public WarningGump(
|
||||
TextDefinition content, int width, int height,
|
||||
Action<bool> callback = null, bool cancelButton = true
|
||||
) : this(
|
||||
1060635, // <CENTER>WARNING</CENTER>
|
||||
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<bool> 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,
|
||||
$"<BASEFONT COLOR=#{contentColor:X6}>{content.String}</BASEFONT>",
|
||||
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,
|
||||
$"<BASEFONT COLOR=#{_contentColor:X6}>{_content.String}</BASEFONT>",
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue