fix: Converts PageResponse/Prompt gumps (#1838)

This commit is contained in:
Kamron Batman 2024-06-16 21:16:15 -07:00 • committed by GitHub
parent c302ff23bc
commit 9c0b57213a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 118 additions and 124 deletions

View file

@ -1,60 +1,65 @@
using Server.Gumps;
using Server.Network;
namespace Server.Engines.Help
namespace Server.Engines.Help;
public sealed class PagePromptGump : StaticGump<PagePromptGump>
{
public class PagePromptGump : Gump
private readonly Mobile _from;
private readonly PageType _type;
public PagePromptGump(Mobile from, PageType type) : base(0, 0)
{
private readonly Mobile m_From;
private readonly PageType m_Type;
_from = from;
_type = type;
}
public PagePromptGump(Mobile from, PageType type) : base(0, 0)
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddBackground(50, 50, 540, 350, 2600);
builder.AddPage();
builder.AddHtmlLocalized(264, 80, 200, 24, 1062524); // Enter Description
// Please enter a brief description (up to 200 characters) of your problem:
builder.AddHtmlLocalized(120, 108, 420, 48, 1062638);
builder.AddBackground(100, 148, 440, 200, 3500);
builder.AddTextEntry(120, 168, 400, 200, 1153, 0, "");
builder.AddButton(175, 355, 2074, 2075, 1); // Okay
builder. AddButton(405, 355, 2073, 2072, 0); // Cancel
}
public override void SendTo(NetState ns)
{
_from.CloseGump<PagePromptGump>();
base.SendTo(ns);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (info.ButtonID == 0)
{
m_From = from;
m_Type = type;
from.CloseGump<PagePromptGump>();
AddBackground(50, 50, 540, 350, 2600);
AddPage(0);
AddHtmlLocalized(264, 80, 200, 24, 1062524); // Enter Description
// Please enter a brief description (up to 200 characters) of your problem:
AddHtmlLocalized(120, 108, 420, 48, 1062638);
AddBackground(100, 148, 440, 200, 3500);
AddTextEntry(120, 168, 400, 200, 1153, 0, "");
AddButton(175, 355, 2074, 2075, 1); // Okay
AddButton(405, 355, 2073, 2072, 0); // Cancel
_from.SendLocalizedMessage(501235, "", 0x35); // Help request aborted.
return;
}
public override void OnResponse(NetState sender, in RelayInfo info)
var text = info.GetTextEntry(0)?.Trim() ?? "";
if (text.Length == 0)
{
if (info.ButtonID == 0)
{
m_From.SendLocalizedMessage(501235, "", 0x35); // Help request aborted.
}
else
{
var text = info.GetTextEntry(0)?.Trim() ?? "";
_from.SendMessage(0x35, "You must enter a description.");
_from.SendGump(new PagePromptGump(_from, _type));
}
else
{
/* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
_from.SendLocalizedMessage(501234, "", 0x35);
if (text.Length == 0)
{
m_From.SendMessage(0x35, "You must enter a description.");
m_From.SendGump(new PagePromptGump(m_From, m_Type));
}
else
{
/* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
m_From.SendLocalizedMessage(501234, "", 0x35);
PageQueue.Enqueue(new PageEntry(m_From, text, m_Type));
}
}
PageQueue.Enqueue(new PageEntry(_from, text, _type));
}
}
}