Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Standardizes South/East selection gumps #1839

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Projects/UOContent/Gumps/SelectAddonDirectionGump.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Server.Items;
using Server.Network;

namespace Server.Gumps;

public abstract class SelectAddonDirectionGump<T> : StaticGump<T> where T : SelectAddonDirectionGump<T>
{
private readonly IDirectionAddonDeed _deed;

public SelectAddonDirectionGump(IDirectionAddonDeed deed) : base(60, 63) => _deed = deed;

public abstract int SelectionNumber { get; }

protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddPage();

builder.AddBackground(0, 0, 273, 324, 0x13BE);
builder.AddImageTiled(10, 10, 253, 20, 0xA40);
builder.AddImageTiled(10, 40, 253, 244, 0xA40);
builder.AddImageTiled(10, 294, 253, 20, 0xA40);
builder.AddAlphaRegion(10, 10, 253, 304);

builder.AddButton(10, 294, 0xFB1, 0xFB2, 0);

builder.AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL
builder.AddHtmlLocalized(14, 12, 273, 20, SelectionNumber, 0x7FFF);

builder.AddPage(1);

builder.AddButton(19, 49, 0x845, 0x846, 1);
builder.AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South
builder.AddButton(19, 73, 0x845, 0x846, 2);
builder.AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East
}

public override void OnResponse(NetState sender, in RelayInfo info)
{
if (_deed?.Deleted != false || info.ButtonID == 0)
{
return;
}

_deed.East = info.ButtonID != 1;
_deed.SendTarget(sender.Mobile);
}
}
8 changes: 8 additions & 0 deletions Projects/UOContent/Items/Deeds/IDirectionAddonDeed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Server.Items;

public interface IDirectionAddonDeed : IEntity
{
public bool East { get; set; }

public void SendTarget(Mobile m);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public BrokenBedAddon(bool east)
}

[SerializationGenerator(0)]
public partial class BrokenBedDeed : BaseAddonDeed
public partial class BrokenBedDeed : BaseAddonDeed, IDirectionAddonDeed
{
private bool _east;
public bool East { get; set; }

[Constructible]
public BrokenBedDeed() => LootType = LootType.Blessed;

public override BaseAddon Addon => new BrokenBedAddon(_east);
public override BaseAddon Addon => new BrokenBedAddon(East);

public override int LabelNumber => 1076263; // Broken Bed

Expand All @@ -54,47 +54,17 @@ public override void OnDoubleClick(Mobile from)
}
}

private void SendTarget(Mobile m)
public void SendTarget(Mobile m)
{
base.OnDoubleClick(m);
}

private class InternalGump : Gump
private class InternalGump : SelectAddonDirectionGump<InternalGump>
{
private readonly BrokenBedDeed _deed;

public InternalGump(BrokenBedDeed deed) : base(60, 36)
public InternalGump(IDirectionAddonDeed deed) : base(deed)
{
_deed = deed;

AddPage(0);

AddBackground(0, 0, 273, 324, 0x13BE);
AddImageTiled(10, 10, 253, 20, 0xA40);
AddImageTiled(10, 40, 253, 244, 0xA40);
AddImageTiled(10, 294, 253, 20, 0xA40);
AddAlphaRegion(10, 10, 253, 304);
AddButton(10, 294, 0xFB1, 0xFB2, 0);
AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL
AddHtmlLocalized(14, 12, 273, 20, 1076749, 0x7FFF); // Please select your broken bed position

AddPage(1);

AddButton(19, 49, 0x845, 0x846, 1);
AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South
AddButton(19, 73, 0x845, 0x846, 2);
AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East
}

public override void OnResponse(NetState sender, in RelayInfo info)
{
if (_deed?.Deleted != false || info.ButtonID == 0)
{
return;
}

_deed._east = info.ButtonID != 1;
_deed.SendTarget(sender.Mobile);
}
public override int SelectionNumber => 1076749; // Please select your broken bed position
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;

namespace Server.Items;

Expand All @@ -26,14 +25,15 @@ public BrokenVanityAddon(bool east)
}

[SerializationGenerator(0)]
public partial class BrokenVanityDeed : BaseAddonDeed
public partial class BrokenVanityDeed : BaseAddonDeed, IDirectionAddonDeed
{
private bool _east;
public bool East { get; set; }

[Constructible]
public BrokenVanityDeed() => LootType = LootType.Blessed;

public override BaseAddon Addon => new BrokenVanityAddon(_east);
public override BaseAddon Addon => new BrokenVanityAddon(East);

public override int LabelNumber => 1076260; // Broken Vanity

public override void OnDoubleClick(Mobile from)
Expand All @@ -49,47 +49,17 @@ public override void OnDoubleClick(Mobile from)
}
}

private void SendTarget(Mobile m)
public void SendTarget(Mobile m)
{
base.OnDoubleClick(m);
}

private class InternalGump : Gump
private class InternalGump : SelectAddonDirectionGump<InternalGump>
{
private readonly BrokenVanityDeed _deed;

public InternalGump(BrokenVanityDeed deed) : base(60, 63)
public InternalGump(IDirectionAddonDeed deed) : base(deed)
{
_deed = deed;

AddPage(0);

AddBackground(0, 0, 273, 324, 0x13BE);
AddImageTiled(10, 10, 253, 20, 0xA40);
AddImageTiled(10, 40, 253, 244, 0xA40);
AddImageTiled(10, 294, 253, 20, 0xA40);
AddAlphaRegion(10, 10, 253, 304);
AddButton(10, 294, 0xFB1, 0xFB2, 0);
AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL
AddHtmlLocalized(14, 12, 273, 20, 1076747, 0x7FFF); // Please select your broken vanity position

AddPage(1);

AddButton(19, 49, 0x845, 0x846, 1);
AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South
AddButton(19, 73, 0x845, 0x846, 2);
AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East
}

public override void OnResponse(NetState sender, in RelayInfo info)
{
if (_deed?.Deleted != false || info.ButtonID == 0)
{
return;
}

_deed._east = info.ButtonID != 1;
_deed.SendTarget(sender.Mobile);
}
public override int SelectionNumber => 1076747; // Please select your broken vanity position
}
}
44 changes: 7 additions & 37 deletions Projects/UOContent/Items/Special/Heritage Items/Curtains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ public CurtainsAddon(bool east)
}

[SerializationGenerator(0)]
public partial class CurtainsDeed : BaseAddonDeed
public partial class CurtainsDeed : BaseAddonDeed, IDirectionAddonDeed
{
private bool _east;
public bool East { get; set; }

[Constructible]
public CurtainsDeed() => LootType = LootType.Blessed;

public override BaseAddon Addon => new CurtainsAddon(_east);
public override BaseAddon Addon => new CurtainsAddon(East);
public override int LabelNumber => 1076280; // Curtains

public override void OnDoubleClick(Mobile from)
Expand All @@ -101,47 +101,17 @@ public override void OnDoubleClick(Mobile from)
}
}

private void SendTarget(Mobile m)
public void SendTarget(Mobile m)
{
base.OnDoubleClick(m);
}

private class InternalGump : Gump
private class InternalGump : SelectAddonDirectionGump<InternalGump>
{
private readonly CurtainsDeed _deed;

public InternalGump(CurtainsDeed deed) : base(60, 36)
public InternalGump(IDirectionAddonDeed deed) : base(deed)
{
_deed = deed;

AddPage(0);

AddBackground(0, 0, 273, 324, 0x13BE);
AddImageTiled(10, 10, 253, 20, 0xA40);
AddImageTiled(10, 40, 253, 244, 0xA40);
AddImageTiled(10, 294, 253, 20, 0xA40);
AddAlphaRegion(10, 10, 253, 304);
AddButton(10, 294, 0xFB1, 0xFB2, 0);
AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL
AddHtmlLocalized(14, 12, 273, 20, 1076581, 0x7FFF); // Please select your curtain position

AddPage(1);

AddButton(19, 49, 0x845, 0x846, 1);
AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South
AddButton(19, 73, 0x845, 0x846, 2);
AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East
}

public override void OnResponse(NetState sender, in RelayInfo info)
{
if (_deed?.Deleted != false || info.ButtonID == 0)
{
return;
}

_deed._east = info.ButtonID != 1;
_deed.SendTarget(sender.Mobile);
}
public override int SelectionNumber => 1076581; // Please select your curtain position
}
}
44 changes: 7 additions & 37 deletions Projects/UOContent/Items/Special/Heritage Items/HangingAxes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public HangingAxesAddon(bool east)
}

[SerializationGenerator(0)]
public partial class HangingAxesDeed : BaseAddonDeed
public partial class HangingAxesDeed : BaseAddonDeed, IDirectionAddonDeed
{
private bool m_East;
public bool East { get; set; }

[Constructible]
public HangingAxesDeed() => LootType = LootType.Blessed;

public override BaseAddon Addon => new HangingAxesAddon(m_East);
public override BaseAddon Addon => new HangingAxesAddon(East);
public override int LabelNumber => 1076271; // Hanging Axes

public override void OnDoubleClick(Mobile from)
Expand All @@ -49,47 +49,17 @@ public override void OnDoubleClick(Mobile from)
}
}

private void SendTarget(Mobile m)
public void SendTarget(Mobile m)
{
base.OnDoubleClick(m);
}

private class InternalGump : Gump
private class InternalGump : SelectAddonDirectionGump<InternalGump>
{
private readonly HangingAxesDeed m_Deed;

public InternalGump(HangingAxesDeed deed) : base(60, 36)
public InternalGump(IDirectionAddonDeed deed) : base(deed)
{
m_Deed = deed;

AddPage(0);

AddBackground(0, 0, 273, 324, 0x13BE);
AddImageTiled(10, 10, 253, 20, 0xA40);
AddImageTiled(10, 40, 253, 244, 0xA40);
AddImageTiled(10, 294, 253, 20, 0xA40);
AddAlphaRegion(10, 10, 253, 304);
AddButton(10, 294, 0xFB1, 0xFB2, 0);
AddHtmlLocalized(45, 296, 450, 20, 1060051, 0x7FFF); // CANCEL
AddHtmlLocalized(14, 12, 273, 20, 1076745, 0x7FFF); // Please select your hanging axe position

AddPage(1);

AddButton(19, 49, 0x845, 0x846, 1);
AddHtmlLocalized(44, 47, 213, 20, 1075386, 0x7FFF); // South
AddButton(19, 73, 0x845, 0x846, 2);
AddHtmlLocalized(44, 71, 213, 20, 1075387, 0x7FFF); // East
}

public override void OnResponse(NetState sender, in RelayInfo info)
{
if (m_Deed?.Deleted != false || info.ButtonID == 0)
{
return;
}

m_Deed.m_East = info.ButtonID != 1;
m_Deed.SendTarget(sender.Mobile);
}
public override int SelectionNumber => 1076745; // Please select your hanging axe position
}
}
Loading
Loading