Skip to content

Commit

Permalink
fix: Converts PageResponse/Prompt gumps (#1838)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Jun 17, 2024
1 parent c302ff2 commit 9c0b572
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 114 deletions.
89 changes: 47 additions & 42 deletions Projects/UOContent/Engines/Help/PagePromptGump.cs
Original file line number Diff line number Diff line change
@@ -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)
{
m_From = from;
m_Type = type;
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddBackground(50, 50, 540, 350, 2600);

from.CloseGump<PagePromptGump>();
builder.AddPage();

AddBackground(50, 50, 540, 350, 2600);
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);

AddPage(0);
builder.AddBackground(100, 148, 440, 200, 3500);
builder.AddTextEntry(120, 168, 400, 200, 1153, 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);
builder.AddButton(175, 355, 2074, 2075, 1); // Okay
builder. AddButton(405, 355, 2073, 2072, 0); // Cancel
}

AddBackground(100, 148, 440, 200, 3500);
AddTextEntry(120, 168, 400, 200, 1153, 0, "");
public override void SendTo(NetState ns)
{
_from.CloseGump<PagePromptGump>();
base.SendTo(ns);
}

AddButton(175, 355, 2074, 2075, 1); // Okay
AddButton(405, 355, 2073, 2072, 0); // Cancel
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (info.ButtonID == 0)
{
_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() ?? "";

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));
}
}
_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);

PageQueue.Enqueue(new PageEntry(_from, text, _type));
}
}
}
54 changes: 28 additions & 26 deletions Projects/UOContent/Engines/Help/PageResponseGump.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
using Server.Gumps;
using Server.Network;

namespace Server.Engines.Help
namespace Server.Engines.Help;

public sealed class PageResponseGump : StaticGump<PageResponseGump>
{
public class PageResponseGump : Gump
{
private readonly Mobile m_From;
private readonly string m_Name;
private readonly string m_Text;
private readonly Mobile _from;
private readonly string _name;
private readonly string _text;

public PageResponseGump(Mobile from, string name, string text) : base(0, 0)
{
m_From = from;
m_Name = name;
m_Text = text;
public PageResponseGump(Mobile from, string name, string text) : base(0, 0)
{
_from = from;
_name = name;
_text = text;
}

AddBackground(50, 25, 540, 430, 2600);
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddBackground(50, 25, 540, 430, 2600);

AddPage(0);
builder.AddPage();

// <CENTER><U>Ultima Online Help Response</U></CENTER>
AddHtmlLocalized(150, 40, 360, 40, 1062610);
// <CENTER><U>Ultima Online Help Response</U></CENTER>
builder.AddHtmlLocalized(150, 40, 360, 40, 1062610);

AddHtml(80, 90, 480, 290, $"{name} tells {from.Name}: {text}", true, true);
builder.AddHtml(80, 90, 480, 290, $"{_name} tells {_from.Name}: {_text}", true, true);

// Clicking the OKAY button will remove the reponse you have received.
AddHtmlLocalized(80, 390, 480, 40, 1062611);
AddButton(400, 417, 2074, 2075, 1); // OKAY
// Clicking the OKAY button will remove the response you have received.
builder.AddHtmlLocalized(80, 390, 480, 40, 1062611);
builder.AddButton(400, 417, 2074, 2075, 1); // OKAY

AddButton(475, 417, 2073, 2072, 0); // CANCEL
}
builder.AddButton(475, 417, 2073, 2072, 0); // CANCEL
}

public override void OnResponse(NetState sender, in RelayInfo info)
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (info.ButtonID != 1)
{
if (info.ButtonID != 1)
{
m_From.SendGump(new MessageSentGump(m_From, m_Name, m_Text));
}
_from.SendGump(new MessageSentGump(_from, _name, _text));
}
}
}
8 changes: 4 additions & 4 deletions Projects/UOContent/Engines/Help/SpeechLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ protected override void OnTarget(Mobile from, object targeted)
{
if (pm.Female)
{
from.SendMessage($"You don't have the required access level to view her speech log.");
from.SendMessage("You don't have the required access level to view her speech log.");
}
else
{
from.SendMessage($"You don't have the required access level to view his speech log.");
from.SendMessage("You don't have the required access level to view his speech log.");
}
}
else if (pm.SpeechLog == null)
{
if (pm.Female)
{
from.SendMessage($"She has no speech log.");
from.SendMessage("She has no speech log.");
}
else
{
from.SendMessage($"He has no speech log.");
from.SendMessage("He has no speech log.");
}
}
else
Expand Down
7 changes: 1 addition & 6 deletions Projects/UOContent/Engines/Help/SpeechLogGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ public SpeechLogGump(Mobile player, List<SpeechLogEntry> log, int page)
builder.Append("<br>");
}

builder.AppendFormat(
"<u>{0}</u> (<i>{1}</i>): {2}",
name,
account.FixHtml(),
speech.FixHtml()
);
builder.Append($"<u>{name}</u> (<i>{account.FixHtml()}</i>): {speech.FixHtml()}");
}

sLog = builder.ToString();
Expand Down
64 changes: 28 additions & 36 deletions Projects/UOContent/Engines/Help/StuckMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,114 +22,106 @@ public StuckMenuEntry(int name, Point3D[] locations)
public class StuckMenu : Gump
{
private static readonly StuckMenuEntry[] m_Entries =
{
[
// Britain
new(
new StuckMenuEntry(
1011028,
new[]
{
[
new Point3D(1522, 1757, 28),
new Point3D(1519, 1619, 10),
new Point3D(1457, 1538, 30),
new Point3D(1607, 1568, 20),
new Point3D(1643, 1680, 18)
}
]
),

// Trinsic
new(
new StuckMenuEntry(
1011029,
new[]
{
[
new Point3D(2005, 2754, 30),
new Point3D(1993, 2827, 0),
new Point3D(2044, 2883, 0),
new Point3D(1876, 2859, 20),
new Point3D(1865, 2687, 0)
}
]
),

// Vesper
new(
new StuckMenuEntry(
1011030,
new[]
{
[
new Point3D(2973, 891, 0),
new Point3D(3003, 776, 0),
new Point3D(2910, 727, 0),
new Point3D(2865, 804, 0),
new Point3D(2832, 927, 0)
}
]
),

// Minoc
new(
new StuckMenuEntry(
1011031,
new[]
{
[
new Point3D(2498, 392, 0),
new Point3D(2433, 541, 0),
new Point3D(2445, 501, 15),
new Point3D(2501, 469, 15),
new Point3D(2444, 420, 15)
}
]
),

// Yew
new(
new StuckMenuEntry(
1011032,
new[]
{
[
new Point3D(490, 1166, 0),
new Point3D(652, 1098, 0),
new Point3D(650, 1013, 0),
new Point3D(536, 979, 0),
new Point3D(464, 970, 0)
}
]
),

// Cove
new(
new StuckMenuEntry(
1011033,
new[]
{
[
new Point3D(2230, 1159, 0),
new Point3D(2218, 1203, 0),
new Point3D(2247, 1194, 0),
new Point3D(2236, 1224, 0),
new Point3D(2273, 1231, 0)
}
]
)
};
];

private static readonly StuckMenuEntry[] m_T2AEntries =
{
[
// Papua
new(
new StuckMenuEntry(
1011057,
new[]
{
[
new Point3D(5720, 3109, -1),
new Point3D(5677, 3176, -3),
new Point3D(5678, 3227, 0),
new Point3D(5769, 3206, -2),
new Point3D(5777, 3270, -1)
}
]
),

// Delucia
new(
new StuckMenuEntry(
1011058,
new[]
{
[
new Point3D(5216, 4033, 37),
new Point3D(5262, 4049, 37),
new Point3D(5284, 4006, 37),
new Point3D(5189, 3971, 39),
new Point3D(5243, 3960, 37)
}
]
)
};
];

private readonly bool m_MarkUse;

Expand Down

0 comments on commit 9c0b572

Please sign in to comment.