feat: Adds missing door types to [adddoor (#2017)
This commit is contained in:
parent
c75514cc04
commit
54cf52f8ec
1 changed files with 149 additions and 89 deletions
|
|
@ -2,101 +2,10 @@ using System;
|
|||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
namespace Server.Gumps;
|
||||
|
||||
public class AddDoorGump : DynamicGump
|
||||
{
|
||||
public class AddDoorGump : Gump
|
||||
{
|
||||
public static DoorInfo[] m_Types =
|
||||
{
|
||||
new(typeof(MetalDoor), 0x675),
|
||||
new(typeof(RattanDoor), 0x695),
|
||||
new(typeof(DarkWoodDoor), 0x6A5),
|
||||
new(typeof(LightWoodDoor), 0x6D5),
|
||||
new(typeof(StrongWoodDoor), 0x6E5)
|
||||
};
|
||||
|
||||
private readonly int m_Type;
|
||||
|
||||
public AddDoorGump(int type = -1) : base(50, 40)
|
||||
{
|
||||
m_Type = type;
|
||||
|
||||
AddPage(0);
|
||||
|
||||
if (m_Type >= 0 && m_Type < m_Types.Length)
|
||||
{
|
||||
AddBlueBack(155, 174);
|
||||
|
||||
var baseID = m_Types[m_Type].m_BaseID;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBlueBack(int width, int height)
|
||||
{
|
||||
AddBackground(0, 0, width - 00, height - 00, 0xE10);
|
||||
AddBackground(8, 5, width - 16, height - 11, 0x053);
|
||||
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)
|
||||
{
|
||||
from.SendGump(new AddDoorGump(button));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (button >= 0 && button < 8)
|
||||
{
|
||||
from.SendGump(new AddDoorGump(m_Type));
|
||||
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
|
||||
{
|
||||
from.SendGump(new AddDoorGump());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
CommandSystem.Register("AddDoor", AccessLevel.GameMaster, AddDoor_OnCommand);
|
||||
|
|
@ -107,17 +16,168 @@ namespace Server.Gumps
|
|||
{
|
||||
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 class DoorInfo
|
||||
{
|
||||
public int m_BaseID;
|
||||
public Type m_Type;
|
||||
public override bool Singleton => true;
|
||||
|
||||
public DoorInfo(Type type, int baseID)
|
||||
protected override void BuildLayout(ref DynamicGumpBuilder builder)
|
||||
{
|
||||
m_Type = type;
|
||||
m_BaseID = baseID;
|
||||
builder.AddPage();
|
||||
|
||||
if (_type != null)
|
||||
{
|
||||
AddBlueBack(ref builder, 155, 174);
|
||||
|
||||
builder.AddItem(25, 24, _baseId);
|
||||
builder.AddButton(26, 37, 0x5782, 0x5782, 1);
|
||||
|
||||
builder.AddItem(47, 45, _baseId + 2);
|
||||
builder.AddButton(43, 57, 0x5783, 0x5783, 2);
|
||||
|
||||
builder.AddItem(87, 22, _baseId + 10);
|
||||
builder.AddButton(116, 35, 0x5785, 0x5785, 6);
|
||||
|
||||
builder.AddItem(65, 45, _baseId + 8);
|
||||
builder.AddButton(96, 55, 0x5784, 0x5784, 5);
|
||||
|
||||
builder.AddButton(73, 36, 0x2716, 0x2716, 9);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pages = _types.Length;
|
||||
if (_maxCount == 0)
|
||||
{
|
||||
for (var i = 0; i < pages; i++)
|
||||
{
|
||||
_maxCount = Math.Max(_maxCount, _types[i].Length);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var page = i + 1;
|
||||
|
||||
builder.AddPage(page);
|
||||
|
||||
if (page < pages)
|
||||
{
|
||||
builder.AddButton(30, 60, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddBlueBack(ref DynamicGumpBuilder builder, int width, int height)
|
||||
{
|
||||
builder.AddBackground(0, 0, width - 00, height - 00, 0xE10);
|
||||
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 override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
var from = sender.Mobile;
|
||||
var button = info.ButtonID - 1;
|
||||
|
||||
if (_type == null)
|
||||
{
|
||||
if (button < 0 || button >= _types.Length)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue