feat: Adds missing door types to [adddoor (#2017)

This commit is contained in:
Kamron Batman 2024-12-12 23:34:41 -08:00 committed by GitHub
parent c75514cc04
commit 54cf52f8ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,122 +2,182 @@ using System;
using Server.Items; using Server.Items;
using Server.Network; using Server.Network;
namespace Server.Gumps namespace Server.Gumps;
public class AddDoorGump : DynamicGump
{ {
public class AddDoorGump : Gump public static void Configure()
{ {
public static DoorInfo[] m_Types = CommandSystem.Register("AddDoor", AccessLevel.GameMaster, AddDoor_OnCommand);
}
[Usage("AddDoor"), Description("Displays a menu from which you can interactively add doors.")]
public static void AddDoor_OnCommand(CommandEventArgs e)
{
e.Mobile.SendGump(new AddDoorGump());
}
private static readonly (Type Type, int BaseID)[][] _types =
[
// Standard
[
(typeof(MetalDoor), 0x675),
(typeof(RattanDoor), 0x695),
(typeof(DarkWoodDoor), 0x6A5),
(typeof(LightWoodDoor), 0x6D5),
(typeof(StrongWoodDoor), 0x6E5),
(typeof(BarredMetalDoor2), 0x1FED),
],
// Tall
[
(typeof(BarredMetalDoor), 0x685),
(typeof(MediumWoodDoor), 0x6B5),
(typeof(MetalDoor2), 0x6C5),
],
// Short
[
(typeof(IronGate), 0x824),
(typeof(IronGateShort), 0x84C),
(typeof(LightWoodGate), 0x839),
(typeof(DarkWoodGate), 0x866),
],
// Secret
[
(typeof(SecretStoneDoor1), 0xE8),
(typeof(SecretDungeonDoor), 0x314),
(typeof(SecretStoneDoor2), 0x324),
(typeof(SecretWoodenDoor), 0x334),
(typeof(SecretLightWoodDoor), 0x344),
(typeof(SecretStoneDoor3), 0x354)
]
];
private static int _maxCount;
private Type _type;
private int _baseId;
public AddDoorGump() : base(50, 40)
{
}
public override bool Singleton => true;
protected override void BuildLayout(ref DynamicGumpBuilder builder)
{
builder.AddPage();
if (_type != null)
{ {
new(typeof(MetalDoor), 0x675), AddBlueBack(ref builder, 155, 174);
new(typeof(RattanDoor), 0x695),
new(typeof(DarkWoodDoor), 0x6A5),
new(typeof(LightWoodDoor), 0x6D5),
new(typeof(StrongWoodDoor), 0x6E5)
};
private readonly int m_Type; builder.AddItem(25, 24, _baseId);
builder.AddButton(26, 37, 0x5782, 0x5782, 1);
public AddDoorGump(int type = -1) : base(50, 40) builder.AddItem(47, 45, _baseId + 2);
{ builder.AddButton(43, 57, 0x5783, 0x5783, 2);
m_Type = type;
AddPage(0); builder.AddItem(87, 22, _baseId + 10);
builder.AddButton(116, 35, 0x5785, 0x5785, 6);
if (m_Type >= 0 && m_Type < m_Types.Length) builder.AddItem(65, 45, _baseId + 8);
{ builder.AddButton(96, 55, 0x5784, 0x5784, 5);
AddBlueBack(155, 174);
var baseID = m_Types[m_Type].m_BaseID; builder.AddButton(73, 36, 0x2716, 0x2716, 9);
AddItem(25, 24, baseID);
AddButton(26, 37, 0x5782, 0x5782, 1);
AddItem(47, 45, baseID + 2);
AddButton(43, 57, 0x5783, 0x5783, 2);
AddItem(87, 22, baseID + 10);
AddButton(116, 35, 0x5785, 0x5785, 6);
AddItem(65, 45, baseID + 8);
AddButton(96, 55, 0x5784, 0x5784, 5);
AddButton(73, 36, 0x2716, 0x2716, 9);
}
else
{
AddBlueBack(265, 145);
for (var i = 0; i < m_Types.Length; ++i)
{
AddButton(30 + i * 49, 13, 0x2624, 0x2625, i + 1);
AddItem(22 + i * 49, 20, m_Types[i].m_BaseID);
}
}
} }
else
public void AddBlueBack(int width, int height)
{ {
AddBackground(0, 0, width - 00, height - 00, 0xE10); var pages = _types.Length;
AddBackground(8, 5, width - 16, height - 11, 0x053); if (_maxCount == 0)
AddImageTiled(15, 14, width - 29, height - 29, 0xE14);
AddAlphaRegion(15, 14, width - 29, height - 29);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
var from = sender.Mobile;
var button = info.ButtonID - 1;
if (m_Type == -1)
{ {
if (button >= 0 && button < m_Types.Length) for (var i = 0; i < pages; i++)
{ {
from.SendGump(new AddDoorGump(button)); _maxCount = Math.Max(_maxCount, _types[i].Length);
} }
} }
else
AddBlueBack(ref builder, 20 + (_maxCount + 1) * 50, 165);
builder.AddHtmlLocalized(30, 45, 60, 20, 1043353, 0x7FFF); // Next
builder.AddHtmlLocalized(30, 85, 60, 20, 1011393, 0x7FFF); // Back
for (var i = 0; i < pages; ++i)
{ {
if (button >= 0 && button < 8) var page = i + 1;
builder.AddPage(page);
if (page < pages)
{ {
from.SendGump(new AddDoorGump(m_Type)); builder.AddButton(30, 60, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page + 1);
CommandSystem.Handle(
from,
$"{CommandSystem.Prefix}Add {m_Types[m_Type].m_Type.Name} {(DoorFacing)button}"
);
}
else if (button == 8)
{
from.SendGump(new AddDoorGump(m_Type));
CommandSystem.Handle(from, $"{CommandSystem.Prefix}Link");
} }
else else
{ {
from.SendGump(new AddDoorGump()); builder.AddButton(30, 60, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 1);
}
if (page > 1)
{
builder.AddButton(30, 100, 0xFAE, 0xFB0, 0, GumpButtonType.Page, page - 1);
}
else
{
builder.AddButton(30, 100, 0xFAE, 0xFB0, 0, GumpButtonType.Page, pages);
}
for (var j = 0; j < _types[i].Length; j++)
{
var x = (j + 1) * 50;
builder.AddButton(30 + x, 20, 0x2624, 0x2625, i * _maxCount + j + 1);
builder.AddItem(15 + x, 30, _types[i][j].BaseID);
} }
} }
} }
public static void Configure()
{
CommandSystem.Register("AddDoor", AccessLevel.GameMaster, AddDoor_OnCommand);
}
[Usage("AddDoor"), Description("Displays a menu from which you can interactively add doors.")]
public static void AddDoor_OnCommand(CommandEventArgs e)
{
e.Mobile.SendGump(new AddDoorGump());
}
} }
public class DoorInfo private static void AddBlueBack(ref DynamicGumpBuilder builder, int width, int height)
{ {
public int m_BaseID; builder.AddBackground(0, 0, width - 00, height - 00, 0xE10);
public Type m_Type; builder.AddBackground(8, 5, width - 16, height - 11, 0x053);
builder.AddImageTiled(15, 14, width - 29, height - 29, 0xE14);
builder.AddAlphaRegion(15, 14, width - 29, height - 29);
}
public DoorInfo(Type type, int baseID) public override void OnResponse(NetState sender, in RelayInfo info)
{
var from = sender.Mobile;
var button = info.ButtonID - 1;
if (_type == null)
{ {
m_Type = type; if (button < 0 || button >= _types.Length)
m_BaseID = baseID; {
return;
}
var page = Math.DivRem(button, _maxCount, out var pos);
var door = _types[page][pos];
_type = door.Type;
_baseId = door.BaseID;
} }
else if (button is >= 0 and < 8)
{
CommandSystem.Handle(
from,
$"{CommandSystem.Prefix}Add {_type.Name} {(DoorFacing)button}"
);
}
else if (button == 8)
{
CommandSystem.Handle(from, $"{CommandSystem.Prefix}Link");
}
else
{
_type = null;
_baseId = 0;
}
from.SendGump(this);
} }
} }