Skip to content

Commit

Permalink
fix: Converts ConfirmRelease, Tithing, Young gumps to static (#1854)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Jul 4, 2024
1 parent 8b1014f commit ed0ce4a
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 206 deletions.
65 changes: 36 additions & 29 deletions Projects/UOContent/Gumps/ConfirmReleaseGump.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,52 @@
using Server.Mobiles;
using Server.Network;

namespace Server.Gumps
namespace Server.Gumps;

public class ConfirmReleaseGump : StaticGump<ConfirmReleaseGump>
{
public class ConfirmReleaseGump : Gump
{
private readonly Mobile m_From;
private readonly BaseCreature m_Pet;
private readonly Mobile _from;
private readonly BaseCreature _pet;

public ConfirmReleaseGump(Mobile from, BaseCreature pet) : base(50, 50)
{
m_From = from;
m_Pet = pet;
public ConfirmReleaseGump(Mobile from, BaseCreature pet) : base(50, 50)
{
_from = from;
_pet = pet;
}

m_From.CloseGump<ConfirmReleaseGump>();
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddPage();

AddPage(0);
builder.AddBackground(0, 0, 270, 120, 5054);
builder.AddBackground(10, 10, 250, 100, 3000);

AddBackground(0, 0, 270, 120, 5054);
AddBackground(10, 10, 250, 100, 3000);
// Are you sure you want to release your pet?
builder.AddHtmlLocalized(20, 15, 230, 60, 1046257, true, true);

AddHtmlLocalized(20, 15, 230, 60, 1046257, true, true); // Are you sure you want to release your pet?
builder.AddButton(20, 80, 4005, 4007, 2);
builder.AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE

AddButton(20, 80, 4005, 4007, 2);
AddHtmlLocalized(55, 80, 75, 20, 1011011); // CONTINUE
builder.AddButton(135, 80, 4005, 4007, 1);
builder.AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL
}

AddButton(135, 80, 4005, 4007, 1);
AddHtmlLocalized(170, 80, 75, 20, 1011012); // CANCEL
}
public override void SendTo(NetState ns)
{
_from.CloseGump<ConfirmReleaseGump>();
base.SendTo(ns);
}

public override void OnResponse(NetState sender, in RelayInfo info)
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (info.ButtonID != 2 || _pet.Deleted ||
!(_pet.Controlled && _from == _pet.ControlMaster &&
_from.CheckAlive() && _pet.Map == _from.Map && _pet.InRange(_from, 14)))
{
if (info.ButtonID != 2 || m_Pet.Deleted ||
!(m_Pet.Controlled && m_From == m_Pet.ControlMaster &&
m_From.CheckAlive() && m_Pet.Map == m_From.Map && m_Pet.InRange(m_From, 14)))
{
return;
}

m_Pet.ControlTarget = null;
m_Pet.ControlOrder = OrderType.Release;
return;
}

_pet.ControlTarget = null;
_pet.ControlOrder = OrderType.Release;
}
}
194 changes: 99 additions & 95 deletions Projects/UOContent/Gumps/TithingGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,129 @@
using Server.Items;
using Server.Network;

namespace Server.Gumps
namespace Server.Gumps;

public class TithingGump : StaticGump<TithingGump>
{
public class TithingGump : Gump
{
private readonly Mobile m_From;
private int m_Offer;
// TODO: What's the maximum?
private const int MaxTitheAmount = 100000;
private readonly Mobile _from;
private int _offer;

public TithingGump(Mobile from, int offer) : base(160, 40)
{
var totalGold = from.TotalGold;
public TithingGump(Mobile from) : base(160, 40) => _from = from;

offer = Math.Clamp(offer, 0, totalGold);
protected override void BuildLayout(ref StaticGumpBuilder builder)
{
builder.AddPage();

m_From = from;
m_Offer = offer;
builder.AddImage(30, 30, 102);

AddPage(0);
// May your wealth bring blessings to those in need, if tithed upon this most sacred site.
builder.AddHtmlLocalized(95, 100, 120, 100, 1060198, 0);

AddImage(30, 30, 102);
builder.AddHtmlLocalized(57, 274, 50, 20, 3000311); // Gold:
// AddLabel(57, 274, 0, "Gold:");
builder.AddLabelPlaceholder(87, 274, 53, "goldOffer");

AddHtmlLocalized(
95,
100,
120,
100,
1060198,
0
); // May your wealth bring blessings to those in need, if tithed upon this most sacred site.
builder.AddHtmlLocalized(57, 274, 50, 20, 1079251); // Tithe:
// AddLabel(137, 274, 0, "Tithe:");
builder.AddLabelPlaceholder(172, 274, 53, "titheOffer");

AddLabel(57, 274, 0, "Gold:");
AddLabel(87, 274, 53, (totalGold - offer).ToString());
builder.AddButton(105, 230, 5220, 5220, 2);
builder.AddButton(113, 230, 5222, 5222, 2);
builder.AddLabel(108, 228, 0, "<");
builder.AddLabel(112, 228, 0, "<");

AddLabel(137, 274, 0, "Tithe:");
AddLabel(172, 274, 53, offer.ToString());
builder.AddButton(127, 230, 5223, 5223, 1);
builder.AddLabel(131, 228, 0, "<");

AddButton(105, 230, 5220, 5220, 2);
AddButton(113, 230, 5222, 5222, 2);
AddLabel(108, 228, 0, "<");
AddLabel(112, 228, 0, "<");
builder.AddButton(147, 230, 5224, 5224, 3);
builder.AddLabel(153, 228, 0, ">");

AddButton(127, 230, 5223, 5223, 1);
AddLabel(131, 228, 0, "<");
builder.AddButton(168, 230, 5220, 5220, 4);
builder.AddButton(176, 230, 5222, 5222, 4);
builder.AddLabel(172, 228, 0, ">");
builder.AddLabel(176, 228, 0, ">");

AddButton(147, 230, 5224, 5224, 3);
AddLabel(153, 228, 0, ">");
builder.AddButton(217, 272, 4023, 4024, 5);
}

AddButton(168, 230, 5220, 5220, 4);
AddButton(176, 230, 5222, 5222, 4);
AddLabel(172, 228, 0, ">");
AddLabel(176, 228, 0, ">");
protected override void BuildStrings(ref GumpStringsBuilder builder)
{
var totalGold = _from.TotalGold;

AddButton(217, 272, 4023, 4024, 5);
}
// Just in case
_offer = Math.Clamp(_offer, 0, totalGold);

builder.SetStringSlot("goldOffer", (totalGold - _offer).ToString("N0"));
builder.SetStringSlot("titheOffer", _offer.ToString("N0"));
}

public override void OnResponse(NetState sender, in RelayInfo info)
public override void OnResponse(NetState sender, in RelayInfo info)
{
switch (info.ButtonID)
{
switch (info.ButtonID)
{
case 0:
case 0:
{
// You have decided to tithe no gold to the shrine.
_from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193);
break;
}
case 1:
case 2:
case 3:
case 4:
{
_offer = info.ButtonID switch
{
// You have decided to tithe no gold to the shrine.
m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193);
break;
1 => _offer - 100,
2 => 0,
3 => _offer + 100,
4 => _from.TotalGold,
_ => 0
};

_from.SendGump(this);
break;
}
case 5:
{
var totalGold = _from.TotalGold;

_offer = Math.Clamp(_offer, 0, totalGold);

if (_from.TithingPoints + _offer > MaxTitheAmount)
{
_offer = MaxTitheAmount - _from.TithingPoints;
}
case 1:
case 2:
case 3:
case 4:

if (_offer <= 0)
{
var offer = info.ButtonID switch
{
1 => m_Offer - 100,
2 => 0,
3 => m_Offer + 100,
4 => m_From.TotalGold,
_ => 0
};

m_From.SendGump(new TithingGump(m_From, offer));
// You have decided to tithe no gold to the shrine.
_from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193);
break;
}
case 5:

var pack = _from.Backpack;

// TODO: At some point this was changed on OSI to only work from bank/account funds
if (pack?.ConsumeTotal(typeof(Gold), _offer) == true)
{
var totalGold = m_From.TotalGold;

m_Offer = Math.Clamp(m_Offer, 0, totalGold);

if (m_From.TithingPoints + m_Offer > 100000) // TODO: What's the maximum?
{
m_Offer = 100000 - m_From.TithingPoints;
}

if (m_Offer <= 0)
{
// You have decided to tithe no gold to the shrine.
m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193);
break;
}

var pack = m_From.Backpack;

if (pack?.ConsumeTotal(typeof(Gold), m_Offer) == true)
{
// You tithe gold to the shrine as a sign of devotion.
m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195);
m_From.TithingPoints += m_Offer;

m_From.PlaySound(0x243);
m_From.PlaySound(0x2E6);
}
else
{
// You do not have enough gold to tithe that amount!
m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194);
}
// You tithe gold to the shrine as a sign of devotion.
_from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195);
_from.TithingPoints += _offer;

break;
_from.PlaySound(0x243);
_from.PlaySound(0x2E6);
}
}
else
{
// You do not have enough gold to tithe that amount!
_from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194);
}

break;
}
}
}
}
Loading

0 comments on commit ed0ce4a

Please sign in to comment.