Skip to content

Commit

Permalink
feat: Standardizes South/East selection gumps (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Feb 14, 2025
1 parent 279b10d commit 2e08eda
Show file tree
Hide file tree
Showing 21 changed files with 265 additions and 522 deletions.
1 change: 0 additions & 1 deletion Projects/UOContent/Engines/BuffIcons/BuffInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using ModernUO.CodeGeneratedEvents;
using Server.Mobiles;

namespace Server.Engines.BuffIcons;
Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Gumps/PetResurrectGump.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using Server.Mobiles;
using Server.Network;

Expand Down
49 changes: 49 additions & 0 deletions Projects/UOContent/Gumps/SelectAddonDirectionGump.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 override bool Singleton => false;

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);
}
}
46 changes: 23 additions & 23 deletions Projects/UOContent/Holiday Stuff/Christmas/2004/Mistletoe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void Placement_OnTarget(Mobile from, object targeted)

if (northWall && westWall)
{
from.SendGump(new MistletoeDeedGump(from, loc, this));
from.SendGump(new MistletoeDeedGump(loc, this));
}
else
{
Expand Down Expand Up @@ -276,47 +276,47 @@ private void PlaceAddon(Mobile from, Point3D loc, bool northWall, bool westWall)
}
}

private class MistletoeDeedGump : Gump
private class MistletoeDeedGump : StaticGump<MistletoeDeedGump>
{
private readonly MistletoeDeed _deed;
private readonly Mobile _from;
private readonly Point3D _loc;

public MistletoeDeedGump(Mobile from, Point3D loc, MistletoeDeed deed) : base(150, 50)
public override bool Singleton => false;

public MistletoeDeedGump(Point3D loc, MistletoeDeed deed) : base(150, 50)
{
_from = from;
_loc = loc;
_deed = deed;
}

AddBackground(0, 0, 300, 150, 0xA28);
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddBackground(0, 0, 300, 150, 0xA28);

AddPage(0);
builder.AddPage();

AddItem(90, 30, 0x2375);
AddItem(180, 30, 0x2374);
AddButton(50, 35, 0x868, 0x869, 1);
AddButton(145, 35, 0x868, 0x869, 2);
builder.AddItem(90, 30, 0x2375);
builder.AddItem(180, 30, 0x2374);
builder.AddButton(50, 35, 0x868, 0x869, 1);
builder.AddButton(145, 35, 0x868, 0x869, 2);
}

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

switch (info.ButtonID)
var from = sender.Mobile;

if (info.ButtonID == 1)
{
_deed.PlaceAddon(from, _loc, false, true);
}
else
{
case 1:
{
_deed.PlaceAddon(_from, _loc, false, true);
break;
}
case 2:
{
_deed.PlaceAddon(_from, _loc, true, false);
break;
}
_deed.PlaceAddon(from, _loc, true, false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,27 @@ public override void OnDoubleClick(Mobile from)
return;
}

from.SendGump(new FacingGump(this, from));
from.SendGump(new FacingGump(this));
}

private class FacingGump : Gump
private class FacingGump : StaticGump<FacingGump>
{
private readonly FirefliesDeed _deed;
private readonly Mobile _placer;

public override bool Singleton => true;

public FacingGump(FirefliesDeed deed, Mobile player) : base(150, 50)
{
_deed = deed;
_placer = player;

Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
public FacingGump(FirefliesDeed deed) : base(150, 50) => _deed = deed;

AddPage(0);

AddBackground(0, 0, 300, 150, 0xA28);
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddBackground(0, 0, 300, 150, 0xA28);
builder.AddPage();

AddItem(90, 30, 0x2332);
AddItem(180, 30, 0x2336);
builder.AddItem(90, 30, 0x2332);
builder.AddItem(180, 30, 0x2336);

AddButton(50, 35, 0x868, 0x869, (int)Buttons.East);
AddButton(145, 35, 0x868, 0x869, (int)Buttons.South);
builder.AddButton(50, 35, 0x868, 0x869, (int)Buttons.East);
builder.AddButton(145, 35, 0x868, 0x869, (int)Buttons.South);
}

public override void OnResponse(NetState sender, in RelayInfo info)
Expand All @@ -130,7 +122,12 @@ public override void OnResponse(NetState sender, in RelayInfo info)
_ => 0
};

_placer.Target = new InternalTarget(_deed, itemId);
if (itemId == 0)
{
return;
}

sender.Mobile.Target = new InternalTarget(_deed, itemId);
}

private enum Buttons
Expand Down
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;

Check notice on line 1 in Projects/UOContent/Items/Deeds/IDirectionAddonDeed.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Namespace does not correspond to file location

Namespace does not correspond to file location, must be: 'Server.Items.Deeds'

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

public void SendTarget(Mobile m);
}
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 Down Expand Up @@ -30,14 +29,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 @@ -53,49 +52,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 override bool Singleton => true;

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;

Check notice on line 4 in Projects/UOContent/Items/Special/Broken Furniture Collection/BrokenVanity.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Namespace does not correspond to file location

Namespace does not correspond to file location, must be: 'Server.Items.Special.Broken_Furniture_Collection'

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 @@ -48,49 +48,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 override bool Singleton => true;

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
}
}
Loading

0 comments on commit 2e08eda

Please sign in to comment.