feat: Moves gumps out of the core (#1916)

> [!Important]
> **Developer Note**
> This code change will **completely move gumps out of the core**


### Summary

- Adds `GetGumps()` convenience which exposes methods to Find/Close/Send multiple gumps. This helper is a performance improvement by eliminating the Dictionary<Player, List> lookup for gumps.
This commit is contained in:
Kamron Batman 2024-08-09 19:07:32 -07:00 committed by GitHub
parent 40d99f6d1c
commit 8282b00ca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
246 changed files with 1722 additions and 1383 deletions

View file

@ -1,5 +1,4 @@
using Server.Gumps;
using Server.Network;
using Xunit;
namespace Server.Tests.Network;
@ -45,8 +44,7 @@ public class GumpPacketTests : IClassFixture<ServerFixture>
var ns = PacketTestUtilities.CreateTestNetState();
var expected = gump.Compile(ns).Compile();
ns.SendDisplayGump(gump, out _, out _);
ns.SendGump(gump);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);
@ -65,8 +63,7 @@ public class GumpPacketTests : IClassFixture<ServerFixture>
var ns = PacketTestUtilities.CreateTestNetState();
var expected = gump.Compile(ns).Compile();
ns.SendDisplayGump(gump, out _, out _);
ns.SendGump(gump);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);

View file

@ -0,0 +1,13 @@
using Server.Items;
namespace Server.Gumps
{
public interface IVirtualCheckGump
{
public VirtualCheck Check { get; }
public void Send();
public void Refresh(bool recompile);
public void Close();
}
}

View file

@ -15,7 +15,7 @@
using ModernUO.Serialization;
using Server.Gumps;
using Server.Network;
using System;
namespace Server.Items;
@ -23,10 +23,16 @@ namespace Server.Items;
public sealed partial class VirtualCheck : Item
{
public static bool UseEditGump { get; private set; }
public static unsafe delegate*<Mobile, VirtualCheck, IVirtualCheckGump> GumpActivator { get; set; }
public static void Configure()
public static unsafe void Configure()
{
UseEditGump = ServerConfiguration.GetSetting("virtualChecks.useEditGump", Core.TOL);
if (UseEditGump && GumpActivator is null)
{
throw new NullReferenceException(nameof(GumpActivator));
}
}
private int _gold;
@ -42,15 +48,12 @@ public sealed partial class VirtualCheck : Item
}
public override bool IsVirtualItem => true;
public override bool DisplayWeight => false;
public override bool DisplayLootType => false;
public override double DefaultWeight => 0;
public override string DefaultName => "Offer Of Currency";
public EditGump Editor { get; private set; }
public IVirtualCheckGump Editor { get; private set; }
[CommandProperty(AccessLevel.Administrator)]
public int Plat
@ -86,13 +89,13 @@ public sealed partial class VirtualCheck : Item
return c.RootParent == check && IsChildOf(c);
}
public override void OnDoubleClickSecureTrade(Mobile from)
public override unsafe void OnDoubleClickSecureTrade(Mobile from)
{
if (UseEditGump && IsAccessibleTo(from))
{
if (Editor?.Check?.Deleted != false)
{
Editor = new EditGump(from, this);
Editor = GumpActivator(from, this);
Editor.Send();
}
else
@ -161,226 +164,4 @@ public sealed partial class VirtualCheck : Item
{
Delete();
}
public class EditGump : Gump
{
public enum Buttons
{
Close,
Clear,
Accept,
AllPlat,
AllGold
}
private int _plat, _gold;
public EditGump(Mobile user, VirtualCheck check) : base(50, 50)
{
User = user;
Check = check;
_plat = Check.Plat;
_gold = Check.Gold;
Closable = true;
Disposable = true;
Draggable = true;
Resizable = false;
User.CloseGump<EditGump>();
CompileLayout();
}
public Mobile User { get; }
public VirtualCheck Check { get; private set; }
public override void OnServerClose(NetState owner)
{
base.OnServerClose(owner);
if (Check?.Deleted == false)
{
Check.UpdateTrade(User);
}
}
public void Close()
{
User.CloseGump<EditGump>();
if (Check?.Deleted == false)
{
Check.UpdateTrade(User);
}
else
{
Check = null;
}
}
public void Send()
{
if (Check?.Deleted == false)
{
User.SendGump(this);
}
else
{
Close();
}
}
public void Refresh(bool recompile)
{
if (Check?.Deleted != false)
{
Close();
return;
}
if (recompile)
{
CompileLayout();
}
Close();
Send();
}
private void CompileLayout()
{
if (Check?.Deleted != false)
{
return;
}
Entries.ForEach(e => e.Parent = null);
Entries.Clear();
AddPage(0);
AddBackground(0, 0, 400, 160, 3500);
// Title
AddImageTiled(25, 35, 350, 3, 96);
AddImage(10, 8, 113);
AddImage(360, 8, 113);
AddHtml(40, 15, 320, 20, $"BANK OF {User.RawName.ToUpper()}".Center(0x2F4F4F));
// Platinum Row
AddBackground(15, 60, 175, 20, 9300);
AddBackground(20, 45, 165, 30, 9350);
AddItem(20, 45, 3826); // Plat
AddLabel(60, 50, 0, User.Account.TotalPlat.ToString("#,0"));
AddButton(195, 50, 95, 95, (int)Buttons.AllPlat); // ->
AddBackground(210, 60, 175, 20, 9300);
AddBackground(215, 45, 165, 30, 9350);
AddTextEntry(225, 50, 145, 20, 0, 0, _plat.ToString(), User.Account.TotalPlat.ToString().Length);
// Gold Row
AddBackground(15, 100, 175, 20, 9300);
AddBackground(20, 85, 165, 30, 9350);
AddItem(20, 85, 3823); // Gold
AddLabel(60, 90, 0, User.Account.TotalGold.ToString("#,0"));
AddButton(195, 90, 95, 95, (int)Buttons.AllGold); // ->
AddBackground(210, 100, 175, 20, 9300);
AddBackground(215, 85, 165, 30, 9350);
AddTextEntry(225, 90, 145, 20, 0, 1, _gold.ToString(), User.Account.TotalGold.ToString().Length);
// Buttons
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
AddButton(215, 128, 12003, 12004, (int)Buttons.Clear);
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (Check?.Deleted != false || sender.Mobile != User)
{
Close();
return;
}
var refresh = false;
var updated = false;
switch ((Buttons)info.ButtonID)
{
case Buttons.Clear:
{
_plat = _gold = 0;
refresh = true;
break;
}
case Buttons.Accept:
{
var platText = info.GetTextEntry(0);
var goldText = info.GetTextEntry(1);
if (!int.TryParse(platText, out _plat))
{
User.SendMessage("That is not a valid amount of platinum.");
refresh = true;
}
else if (!int.TryParse(goldText, out _gold))
{
User.SendMessage("That is not a valid amount of gold.");
refresh = true;
}
else
{
var totalPlat = User.Account.TotalPlat;
var totalGold = User.Account.TotalGold;
if (totalPlat < _plat || totalGold < _gold)
{
_plat = User.Account.TotalPlat;
_gold = User.Account.TotalGold;
User.SendMessage("You do not have that much currency.");
refresh = true;
}
else
{
Check.Plat = _plat;
Check.Gold = _gold;
updated = true;
}
}
break;
}
case Buttons.AllPlat:
{
_plat = User.Account.TotalPlat;
refresh = true;
break;
}
case Buttons.AllGold:
{
_gold = User.Account.TotalGold;
refresh = true;
break;
}
}
if (updated)
{
User.SendMessage("Your offer has been updated.");
}
if (refresh && Check?.Deleted == false)
{
Refresh(true);
return;
}
Close();
}
}
}

View file

@ -13,14 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Server.Accounting;
using Server.Collections;
using Server.ContextMenus;
using Server.Guilds;
using Server.Gumps;
using Server.HuePickers;
using Server.Items;
using Server.Logging;
@ -30,6 +26,9 @@ using Server.Network;
using Server.Prompts;
using Server.Targeting;
using Server.Text;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using CalcMoves = Server.Movement.Movement;
namespace Server;
@ -8121,65 +8120,6 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
return false;
}
public BaseGump FindGump<T>() where T : BaseGump => m_NetState?.Gumps.Find(g => g is T);
public bool CloseGump<T>() where T : BaseGump
{
if (m_NetState == null)
{
return false;
}
var gump = FindGump<T>();
if (gump != null)
{
m_NetState.SendCloseGump(gump.TypeID, 0);
m_NetState.RemoveGump(gump);
gump.OnServerClose(m_NetState);
return true;
}
return false;
}
public void CloseAllGumps()
{
var ns = m_NetState;
if (ns.CannotSendPackets())
{
return;
}
var gumps = new List<BaseGump>(ns.Gumps);
ns.ClearGumps();
foreach (var gump in gumps)
{
ns.SendCloseGump(gump.TypeID, 0);
gump.OnServerClose(ns);
}
return;
}
public bool HasGump<T>() where T : BaseGump => m_NetState?.Gumps.Exists(g => g is T) ?? false;
public bool SendGump(BaseGump g)
{
if (m_NetState == null)
{
return false;
}
g.SendTo(m_NetState);
return true;
}
public bool SendMenu(IMenu m)
{
if (m_NetState == null)

View file

@ -13,6 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Accounting;
using Server.Collections;
using Server.Diagnostics;
using Server.HuePickers;
using Server.Items;
using Server.Logging;
using Server.Menus;
using System;
using System.Buffers;
using System.Collections.Concurrent;
@ -23,14 +30,6 @@ using System.Net.Sockets;
using System.Network;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Server.Accounting;
using Server.Collections;
using Server.Diagnostics;
using Server.Gumps;
using Server.HuePickers;
using Server.Items;
using Server.Logging;
using Server.Menus;
namespace Server.Network;
@ -46,7 +45,6 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
private static readonly TimeSpan ConnectingSocketIdleLimit = TimeSpan.FromMilliseconds(5000); // 5 seconds
private const int RecvPipeSize = 1024 * 64;
private const int SendPipeSize = 1024 * 256;
private const int GumpCap = 512;
private const int HuePickerCap = 512;
private const int MenuCap = 512;
private const int PacketPerSecondThreshold = 3000;
@ -126,7 +124,6 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
{
Connection = connection;
Seeded = false;
Gumps = [];
HuePickers = [];
Menus = [];
Trades = [];
@ -226,8 +223,6 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
public int Sequence { get; set; }
public List<BaseGump> Gumps { get; private set; }
public List<HuePicker> HuePickers { get; private set; }
public List<IMenu> Menus { get; private set; }
@ -419,36 +414,6 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
HuePickers?.Clear();
}
public void AddGump(BaseGump gump)
{
Gumps ??= [];
if (Gumps.Count < GumpCap)
{
Gumps.Add(gump);
}
else
{
LogInfo("Exceeded gump cap, disconnecting...");
Disconnect("Exceeded gump cap.");
}
}
public void RemoveGump(BaseGump gump)
{
Gumps?.Remove(gump);
}
public void RemoveGump(int index)
{
Gumps?.RemoveAt(index);
}
public void ClearGumps()
{
Gumps?.Clear();
}
public void LaunchBrowser(string url)
{
this.SendMessageLocalized(Serial.MinusOne, -1, MessageType.Label, 0x35, 3, 501231);
@ -1217,7 +1182,6 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
var a = Account;
Gumps.Clear();
Menus.Clear();
HuePickers.Clear();
Account = null;

View file

@ -1,3 +1,18 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2024 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SecureTrade.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using Server.Accounting;
using Server.Items;
@ -411,7 +426,7 @@ public class SecureTrade
}
}
public class SecureTradeInfo : IDisposable
public sealed class SecureTradeInfo : IDisposable
{
public SecureTradeInfo(SecureTrade owner, Mobile m, SecureTradeContainer c)
{

View file

@ -2,7 +2,6 @@ using System;
using System.Buffers;
using System.IO;
using Server.Gumps;
using Server.Network;
using Server.Tests.Network;
using Xunit;
@ -20,7 +19,7 @@ public class TestLayoutGumps
var staticGump = new DynamicTestGump("Test");
var buffer = GC.AllocateUninitializedArray<byte>(512);
var writer = new SpanWriter(buffer);
staticGump.CreatePacket(ref writer);
staticGump.Compile(ref writer);
AssertThat.Equal(writer.Span, legacyPacketData);
}
@ -61,7 +60,7 @@ public class TestLayoutGumps
var gump = new CachedGump();
var buffer = GC.AllocateUninitializedArray<byte>(512);
var writer = new SpanWriter(buffer);
gump.CreatePacket(ref writer);
gump.Compile(ref writer);
var packet = writer.Span.ToArray();
@ -69,7 +68,7 @@ public class TestLayoutGumps
writer.Seek(0, SeekOrigin.Begin);
// Second call should not call BuildLayout
gump.CreatePacket(ref writer);
gump.Compile(ref writer);
AssertThat.Equal(writer.Span, packet);
}
@ -85,7 +84,7 @@ public class TestLayoutGumps
var buffer = GC.AllocateUninitializedArray<byte>(512);
var writer = new SpanWriter(buffer);
staticGump.CreatePacket(ref writer);
staticGump.Compile(ref writer);
// Assert layout is exactly what we are expecting
AssertThat.Equal(writer.Span.Slice(19, layoutLength), expectedBufferWriter.Span);

View file

@ -1,5 +1,5 @@
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.SkillHandlers;
using Server.Tests;
using Server.Tests.Network;
@ -20,7 +20,7 @@ public class TrackingGumpTests : IClassFixture<ServerFixture>
var ns = PacketTestUtilities.CreateTestNetState();
var expected = g.Compile(ns).Compile();
ns.SendDisplayGump(g, out var switches, out var entries);
ns.SendGump(g);
var result = ns.SendPipe.Reader.AvailableToRead();
AssertThat.Equal(result, expected);

View file

@ -307,9 +307,10 @@ public class AddonGenerator
private const int GreenHue = 0x40;
private readonly PickerState _state;
public override bool Singleton => true;
public InternalGump(Mobile m, PickerState state) : base(100, 50)
{
m.CloseGump<InternalGump>();
_state = state;
MakeGump();
}

View file

@ -524,11 +524,11 @@ namespace Server.Commands.Generic
if (match.Length < 3)
{
e.Mobile.SendMessage("Invalid search string.");
e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, Type.EmptyTypes, false));
e.Mobile.SendGump(new AddGump(match, 0, Type.EmptyTypes, false));
}
else
{
e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, AddGump.Match(match), true));
e.Mobile.SendGump(new AddGump(match, 0, AddGump.Match(match), true));
}
}
else

View file

@ -290,18 +290,20 @@ public static class HelpInfo
public override void OnResponse(NetState sender, in RelayInfo info)
{
var m = sender.Mobile;
var gumps = m.GetGumps();
switch (info.ButtonID)
{
case 0:
{
m.CloseGump<CommandInfoGump>();
gumps.Close<CommandInfoGump>();
break;
}
case 1:
{
if (_page > 0)
{
m.SendGump(new CommandListGump(_page - 1, m, _list));
gumps.Send(new CommandListGump(_page - 1, m, _list));
}
break;
@ -310,7 +312,7 @@ public static class HelpInfo
{
if ((_page + 1) * EntriesPerPage < SortedHelpInfo.Count)
{
m.SendGump(new CommandListGump(_page + 1, m, _list));
gumps.Send(new CommandListGump(_page + 1, m, _list));
}
break;
@ -325,13 +327,13 @@ public static class HelpInfo
if (m.AccessLevel >= c.AccessLevel)
{
m.SendGump(new CommandInfoGump(c));
m.SendGump(new CommandListGump(_page, m, _list));
gumps.Send(new CommandInfoGump(c));
gumps.Send(new CommandListGump(_page, m, _list));
}
else
{
m.SendMessage("You no longer have access to that command.");
m.SendGump(new CommandListGump(_page, m, null));
gumps.Send(new CommandListGump(_page, m, null));
}
}

View file

@ -14,14 +14,14 @@ public class AddGump : DynamicGump
private readonly string _searchString;
private readonly bool _explicitSearch;
public AddGump(Mobile from, string searchString, int page, Type[] searchResults, bool explicitSearch) : base(50, 50)
public override bool Singleton => true;
public AddGump(string searchString, int page, Type[] searchResults, bool explicitSearch) : base(50, 50)
{
_searchString = searchString;
_searchResults = searchResults;
_explicitSearch = explicitSearch;
_page = page;
from.CloseGump<AddGump>();
}
protected override void BuildLayout(ref DynamicGumpBuilder builder) {
@ -120,7 +120,7 @@ public class AddGump : DynamicGump
explicitSearch = true;
}
e.Mobile.SendGump(new AddGump(e.Mobile, val, 0, types, explicitSearch));
e.Mobile.SendGump(new AddGump(val, 0, types, explicitSearch));
}
private static void Match(string match, Type[] types, HashSet<Type> results)
@ -212,11 +212,11 @@ public class AddGump : DynamicGump
if (match.Length < 3)
{
from.SendMessage("Invalid search string.");
from.SendGump(new AddGump(from, match, _page, _searchResults, false));
from.SendGump(new AddGump(match, _page, _searchResults, false));
}
else
{
from.SendGump(new AddGump(from, match, 0, Match(match), true));
from.SendGump(new AddGump(match, 0, Match(match), true));
}
break;
@ -225,7 +225,7 @@ public class AddGump : DynamicGump
{
if (_page > 0)
{
from.SendGump(new AddGump(from, _searchString, _page - 1, _searchResults, true));
from.SendGump(new AddGump(_searchString, _page - 1, _searchResults, true));
}
break;
@ -234,7 +234,7 @@ public class AddGump : DynamicGump
{
if ((_page + 1) * 10 < _searchResults.Length)
{
from.SendGump(new AddGump(from, _searchString, _page + 1, _searchResults, true));
from.SendGump(new AddGump(_searchString, _page + 1, _searchResults, true));
}
break;
@ -307,7 +307,7 @@ public class AddGump : DynamicGump
{
if (cancelType == TargetCancelType.Canceled)
{
from.SendGump(new AddGump(from, m_SearchString, m_Page, m_SearchResults, true));
from.SendGump(new AddGump(m_SearchString, m_Page, m_SearchResults, true));
}
}
}

View file

@ -34,14 +34,14 @@ namespace Server.Gumps
private readonly Mobile m_Owner;
private int m_Page;
public override bool Singleton => true;
public CategorizedAddGump(Mobile owner) : this(owner, CAGCategory.Root)
{
}
public CategorizedAddGump(Mobile owner, CAGCategory category, int page = 0) : base(GumpOffsetX, GumpOffsetY)
{
owner.CloseGump<WhoGump>();
m_Owner = owner;
m_Category = category;

View file

@ -1,3 +1,5 @@
using Server.Gumps;
namespace Server.Engines.AdvancedSearch;
public static class AdvancedSearchCommand
@ -14,7 +16,6 @@ public static class AdvancedSearchCommand
{
var from = e.Mobile;
from.CloseGump<AdvancedSearchGump>();
from.SendGump(new AdvancedSearchGump(from));
from.SendGump(new AdvancedSearchGump(from), true);
}
}

View file

@ -4,11 +4,11 @@ using Server.Network;
namespace Server.Engines.BulkOrders
{
public class BOBFilterGump : Gump
public sealed class BOBFilterGump : DynamicGump
{
private const int LabelColor = 0x7FFF;
private static readonly int[,] m_MaterialFilters =
private static readonly int[,] _materialFilters =
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
@ -30,21 +30,21 @@ namespace Server.Engines.BulkOrders
{ 1062238, 16 } // Barbed
};
private static readonly int[,] m_TypeFilters =
private static readonly int[,] _typeFilters =
{
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 } // Large
};
private static readonly int[,] m_QualityFilters =
private static readonly int[,] _qualityFilters =
{
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional
};
private static readonly int[,] m_AmountFilters =
private static readonly int[,] _amountFilters =
{
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
@ -52,74 +52,77 @@ namespace Server.Engines.BulkOrders
{ 1062239, 3 } // 20
};
private static readonly int[][,] m_Filters =
private static readonly int[][,] _filters =
{
m_TypeFilters,
m_QualityFilters,
m_MaterialFilters,
m_AmountFilters
_typeFilters,
_qualityFilters,
_materialFilters,
_amountFilters
};
private static readonly int[] m_XOffsets_Type = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Quality = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static readonly int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static readonly int[] _xOffsets_Type = [0, 75, 170];
private static readonly int[] _xOffsets_Quality = [0, 75, 170];
private static readonly int[] _xOffsets_Amount = [0, 75, 180, 275];
private static readonly int[] _xOffsets_Material = [0, 105, 210, 305, 390, 485];
private static readonly int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static readonly int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private static readonly int[] _xWidths_Small = [50, 50, 70, 50];
private static readonly int[] _xWidths_Large = [80, 50, 50, 50, 50, 50];
private readonly BulkOrderBook _book;
private readonly PlayerMobile _from;
public override bool Singleton => true;
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{
from.CloseGump<BOBGump>();
from.CloseGump<BOBFilterGump>();
m_From = from;
m_Book = book;
var f = from.UseOwnFilter ? from.BOBFilter : book.Filter;
AddPage(0);
AddBackground(10, 10, 600, 439, 5054);
AddImageTiled(18, 20, 583, 420, 2624);
AddAlphaRegion(18, 20, 583, 420);
AddImage(5, 5, 10460);
AddImage(585, 5, 10460);
AddImage(5, 424, 10460);
AddImage(585, 424, 10460);
AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor); // Filter Preference
AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor); // Bulk Order Type
AddFilterList(25, 96, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0);
AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor); // Quality
AddFilterList(320, 96, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1);
AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor); // Material Type
AddFilterList(25, 192, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2);
AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor); // Amount
AddFilterList(25, 352, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3);
AddHtmlLocalized(75, 416, 120, 32, 1062477, from.UseOwnFilter ? LabelColor : 16927); // Set Book Filter
AddButton(40, 416, 4005, 4007, 1);
AddHtmlLocalized(235, 416, 120, 32, 1062478, from.UseOwnFilter ? 16927 : LabelColor); // Set Your Filter
AddButton(200, 416, 4005, 4007, 2);
AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor); // Clear Filter
AddButton(370, 416, 4005, 4007, 3);
AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor); // APPLY
AddButton(505, 416, 4017, 4018, 0);
_from = from;
_book = book;
}
private void AddFilterList(
protected override void BuildLayout(ref DynamicGumpBuilder builder)
{
var f = _from.UseOwnFilter ? _from.BOBFilter : _book.Filter;
builder.AddPage();
builder.AddBackground(10, 10, 600, 439, 5054);
builder.AddImageTiled(18, 20, 583, 420, 2624);
builder.AddAlphaRegion(18, 20, 583, 420);
builder.AddImage(5, 5, 10460);
builder.AddImage(585, 5, 10460);
builder.AddImage(5, 424, 10460);
builder.AddImage(585, 424, 10460);
builder.AddHtmlLocalized(270, 32, 200, 32, 1062223, LabelColor); // Filter Preference
builder.AddHtmlLocalized(26, 64, 120, 32, 1062228, LabelColor); // Bulk Order Type
AddFilterList(ref builder, 25, 96, _xOffsets_Type, 40, _typeFilters, _xWidths_Small, f.Type, 0);
builder.AddHtmlLocalized(320, 64, 50, 32, 1062215, LabelColor); // Quality
AddFilterList(ref builder, 320, 96, _xOffsets_Quality, 40, _qualityFilters, _xWidths_Small, f.Quality, 1);
builder.AddHtmlLocalized(26, 160, 120, 32, 1062232, LabelColor); // Material Type
AddFilterList(ref builder, 25, 192, _xOffsets_Material, 40, _materialFilters, _xWidths_Large, f.Material, 2);
builder.AddHtmlLocalized(26, 320, 120, 32, 1062217, LabelColor); // Amount
AddFilterList(ref builder, 25, 352, _xOffsets_Amount, 40, _amountFilters, _xWidths_Small, f.Quantity, 3);
builder.AddHtmlLocalized(75, 416, 120, 32, 1062477, _from.UseOwnFilter ? LabelColor : 16927); // Set Book Filter
builder.AddButton(40, 416, 4005, 4007, 1);
builder.AddHtmlLocalized(235, 416, 120, 32, 1062478, _from.UseOwnFilter ? 16927 : LabelColor); // Set Your Filter
builder.AddButton(200, 416, 4005, 4007, 2);
builder.AddHtmlLocalized(405, 416, 120, 32, 1062231, LabelColor); // Clear Filter
builder.AddButton(370, 416, 4005, 4007, 3);
builder.AddHtmlLocalized(540, 416, 50, 32, 1011046, LabelColor); // APPLY
builder.AddButton(505, 416, 4017, 4018, 0);
}
private void AddFilterList(ref DynamicGumpBuilder builder,
int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue,
int filterIndex
)
@ -136,7 +139,7 @@ namespace Server.Engines.BulkOrders
var isSelected = filters[i, 1] == filterValue ||
i % xOffsets.Length == 0 && filterValue == 0;
AddHtmlLocalized(
builder.AddHtmlLocalized(
x + 35 + xOffsets[i % xOffsets.Length],
y + i / xOffsets.Length * yOffset,
xWidths[i % xOffsets.Length],
@ -144,7 +147,8 @@ namespace Server.Engines.BulkOrders
number,
isSelected ? 16927 : LabelColor
);
AddButton(
builder.AddButton(
x + xOffsets[i % xOffsets.Length],
y + i / xOffsets.Length * yOffset,
4005,
@ -156,7 +160,7 @@ namespace Server.Engines.BulkOrders
public override void OnResponse(NetState sender, in RelayInfo info)
{
var f = m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter;
var f = _from.UseOwnFilter ? _from.BOBFilter : _book.Filter;
var index = info.ButtonID;
@ -164,28 +168,28 @@ namespace Server.Engines.BulkOrders
{
case 0: // Apply
{
m_From.SendGump(new BOBGump(m_From, m_Book));
_from.SendGump(new BOBGump(_from, _book));
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
_from.UseOwnFilter = false;
_from.SendGump(new BOBFilterGump(_from, _book));
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
_from.UseOwnFilter = true;
_from.SendGump(new BOBFilterGump(_from, _book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
_from.SendGump(new BOBFilterGump(_from, _book));
break;
}
@ -196,9 +200,9 @@ namespace Server.Engines.BulkOrders
var type = index % 4;
index /= 4;
if (type >= 0 && type < m_Filters.Length)
if (type >= 0 && type < _filters.Length)
{
var filters = m_Filters[type];
var filters = _filters[type];
if (index >= 0 && index < filters.GetLength(0))
{
@ -223,7 +227,7 @@ namespace Server.Engines.BulkOrders
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
_from.SendGump(new BOBFilterGump(_from, _book));
}
}

View file

@ -11,20 +11,19 @@ namespace Server.Engines.BulkOrders
public class BOBGump : Gump
{
private const int LabelColor = 0x7FFF;
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private readonly List<IBOBEntry> m_List;
private readonly BulkOrderBook _book;
private readonly PlayerMobile _from;
private readonly List<IBOBEntry> _list;
private int m_Page;
private int _page;
public override bool Singleton => true;
public BOBGump(PlayerMobile from, BulkOrderBook book, int page = 0, List<IBOBEntry> list = null) : base(12, 24)
{
from.CloseGump<BOBGump>();
from.CloseGump<BOBFilterGump>();
m_From = from;
m_Book = book;
m_Page = page;
_from = from;
_book = book;
_page = page;
if (list == null)
{
@ -41,7 +40,7 @@ namespace Server.Engines.BulkOrders
}
}
m_List = list;
_list = list;
var index = GetIndexForPage(page);
var count = GetCountForIndex(index);
@ -313,7 +312,7 @@ namespace Server.Engines.BulkOrders
Type itemType
)
{
var f = m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter;
var f = _from.UseOwnFilter ? _from.BOBFilter : _book.Filter;
if (f.IsDefault)
{
@ -394,7 +393,7 @@ namespace Server.Engines.BulkOrders
var slots = 0;
var count = 0;
var list = m_List;
var list = _list;
for (var i = index; i >= 0 && i < list.Count; ++i)
{
@ -429,7 +428,7 @@ namespace Server.Engines.BulkOrders
var page = 0;
int i;
var list = m_List;
var list = _list;
for (i = 0; i < index && i < list.Count; i++)
{
var entry = list[i];
@ -525,6 +524,13 @@ namespace Server.Engines.BulkOrders
return "Invalid";
}
public override void SendTo(NetState ns)
{
ns.CloseGump<BOBFilterGump>();
base.SendTo(ns);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
var index = info.ButtonID;
@ -537,34 +543,34 @@ namespace Server.Engines.BulkOrders
}
case 1: // Set Filter
{
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
_from.SendGump(new BOBFilterGump(_from, _book));
break;
}
case 2: // Previous page
{
if (m_Page > 0)
if (_page > 0)
{
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
_from.SendGump(new BOBGump(_from, _book, _page - 1, _list));
}
return;
}
case 3: // Next page
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
if (GetIndexForPage(_page + 1) < _list.Count)
{
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
_from.SendGump(new BOBGump(_from, _book, _page + 1, _list));
}
break;
}
case 4: // Price all
{
if (m_Book.IsChildOf(m_From.Backpack))
if (_book.IsChildOf(_from.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
m_From.SendMessage("Type in a price for all deeds in the book:");
_from.Prompt = new SetPricePrompt(_book, null, _page, _list);
_from.SendMessage("Type in a price for all deeds in the book:");
}
break;
@ -576,28 +582,28 @@ namespace Server.Engines.BulkOrders
var type = index % 2;
index /= 2;
if (index < 0 || index >= m_List.Count)
if (index < 0 || index >= _list.Count)
{
break;
}
var bobEntry = m_List[index];
var bobEntry = _list[index];
if (!m_Book.Entries.Contains(bobEntry))
if (!_book.Entries.Contains(bobEntry))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
_from.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
}
if (type == 0) // Drop
{
if (m_Book.IsChildOf(m_From.Backpack))
if (_book.IsChildOf(_from.Backpack))
{
var item = bobEntry.Reconstruct();
var pack = m_From.Backpack;
var pack = _from.Backpack;
if (pack?.CheckHold(
m_From,
_from,
item,
true,
true,
@ -605,37 +611,37 @@ namespace Server.Engines.BulkOrders
item.PileWeight + item.TotalWeight
) != true)
{
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
_from.SendLocalizedMessage(503204); // You do not have room in your backpack for this
_from.SendGump(new BOBGump(_from, _book, _page));
}
else
{
if (m_Book.IsChildOf(m_From.Backpack))
if (_book.IsChildOf(_from.Backpack))
{
var sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
_from.AddToBackpack(item);
// The bulk order deed has been placed in your backpack.
m_From.SendLocalizedMessage(1045152);
_from.SendLocalizedMessage(1045152);
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
_book.Entries.Remove(bobEntry);
_book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
if (_book.Entries.Count / 5 < _book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
_book.ItemCount--;
_book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
if (_book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
_page = GetPageForIndex(index, sizeOfDroppedBod);
_from.SendGump(new BOBGump(_from, _book, _page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
_from.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
@ -643,14 +649,14 @@ namespace Server.Engines.BulkOrders
}
else // Set Price | Buy
{
if (m_Book.IsChildOf(m_From.Backpack))
if (_book.IsChildOf(_from.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List);
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
_from.Prompt = new SetPricePrompt(_book, bobEntry, _page, _list);
_from.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
else if (_book.RootParent is PlayerVendor pv)
{
var vi = pv.GetVendorItem(m_Book);
var vi = pv.GetVendorItem(_book);
if (vi?.IsForSale != false)
{
@ -662,18 +668,18 @@ namespace Server.Engines.BulkOrders
if (price == 0)
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
_from.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
if (_book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
_page = GetPageForIndex(index, sizeOfDroppedBod);
_from.SendGump(new BODBuyGump(_from, _book, bobEntry, _page, price));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is emptz
_from.SendLocalizedMessage(1062381); // The book is emptz
}
}
}

View file

@ -1,4 +1,5 @@
using ModernUO.Serialization;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.BulkOrders

View file

@ -8,14 +8,13 @@ namespace Server.Engines.BulkOrders
private readonly LargeBOD m_Deed;
private readonly Mobile m_From;
public override bool Singleton => true;
public LargeBODAcceptGump(Mobile from, LargeBOD deed) : base(50, 50)
{
m_From = from;
m_Deed = deed;
m_From.CloseGump<LargeBODAcceptGump>();
m_From.CloseGump<SmallBODAcceptGump>();
var entries = deed.Entries;
AddPage(0);

View file

@ -8,14 +8,13 @@ namespace Server.Engines.BulkOrders
private readonly LargeBOD m_Deed;
private readonly Mobile m_From;
public override bool Singleton => true;
public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25)
{
m_From = from;
m_Deed = deed;
m_From.CloseGump<LargeBODGump>();
m_From.CloseGump<SmallBODGump>();
var entries = deed.Entries;
AddPage(0);

View file

@ -1,4 +1,5 @@
using System;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;

View file

@ -8,14 +8,13 @@ namespace Server.Engines.BulkOrders
private readonly SmallBOD m_Deed;
private readonly Mobile m_From;
public override bool Singleton => true;
public SmallBODAcceptGump(Mobile from, SmallBOD deed) : base(50, 50)
{
m_From = from;
m_Deed = deed;
m_From.CloseGump<LargeBODAcceptGump>();
m_From.CloseGump<SmallBODAcceptGump>();
AddPage(0);
AddBackground(25, 10, 430, 264, 5054);

View file

@ -8,14 +8,13 @@ namespace Server.Engines.BulkOrders
private readonly SmallBOD m_Deed;
private readonly Mobile m_From;
public override bool Singleton => true;
public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25)
{
m_From = from;
m_Deed = deed;
m_From.CloseGump<LargeBODGump>();
m_From.CloseGump<SmallBODGump>();
AddPage(0);
AddBackground(50, 10, 455, 260, 5054);

View file

@ -22,6 +22,8 @@ namespace Server.Engines.ConPVP
private bool m_Active = true;
public override bool Singleton => true;
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(
50,
50
@ -33,8 +35,6 @@ namespace Server.Engines.ConPVP
m_Participant = p;
m_Slot = slot;
challenged.CloseGump<AcceptDuelGump>();
Closable = false;
AddPage(0);
@ -244,23 +244,18 @@ namespace Server.Engines.ConPVP
m_Challenger.SendMessage($"{m_Challenged.Name} has accepted the request.");
m_Challenged.SendMessage($"You have accepted the request from {m_Challenger.Name}.");
var ns = m_Challenger.NetState;
if (ns != null)
foreach (var g in m_Challenger.GetAllGumps())
{
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == m_Participant)
{
if (g is ParticipantGump pg && pg.Participant == m_Participant)
{
m_Challenger.SendGump(new ParticipantGump(m_Challenger, m_Context, m_Participant));
break;
}
m_Challenger.SendGump(new ParticipantGump(m_Challenger, m_Context, m_Participant));
break;
}
if (g is DuelContextGump dcg && dcg.Context == m_Context)
{
m_Challenger.SendGump(new DuelContextGump(m_Challenger, m_Context));
break;
}
if (g is DuelContextGump dcg && dcg.Context == m_Context)
{
m_Challenger.SendGump(new DuelContextGump(m_Challenger, m_Context));
break;
}
}
}

View file

@ -135,9 +135,9 @@ namespace Server.Engines.ConPVP
string title = move switch
{
NinjaMove => "Bushido",
NinjaMove => "Bushido",
SamuraiMove => "Ninjitsu",
_ => null
_ => null
};
if (title == null || name == null || Ruleset.GetOption(title, name))
@ -199,15 +199,15 @@ namespace Server.Engines.ConPVP
case MagerySpell magerySpell:
title = magerySpell.Circle switch
{
SpellCircle.First => "1st Circle",
SpellCircle.Second => "2nd Circle",
SpellCircle.Third => "3rd Circle",
SpellCircle.Fourth => "4th Circle",
SpellCircle.Fifth => "5th Circle",
SpellCircle.Sixth => "6th Circle",
SpellCircle.First => "1st Circle",
SpellCircle.Second => "2nd Circle",
SpellCircle.Third => "3rd Circle",
SpellCircle.Fourth => "4th Circle",
SpellCircle.Fifth => "5th Circle",
SpellCircle.Sixth => "6th Circle",
SpellCircle.Seventh => "7th Circle",
SpellCircle.Eighth => "8th Circle",
_ => null
SpellCircle.Eighth => "8th Circle",
_ => null
};
option = magerySpell.Name;
@ -1431,7 +1431,6 @@ namespace Server.Engines.ConPVP
if (prefs != null)
{
e.Mobile.CloseGump<PreferencesGump>();
e.Mobile.SendGump(new PreferencesGump(e.Mobile, prefs));
}
}
@ -1542,23 +1541,18 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
break;
}
}
}
@ -1580,34 +1574,29 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
var send = true;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
var send = true;
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (send)
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
}
if (send)
{
init.SendGump(new DuelContextGump(init, dc));
}
}
}
else
@ -1629,34 +1618,29 @@ namespace Server.Engines.ConPVP
p.Nullify(pl);
pm.DuelPlayer = null;
var ns = init.NetState;
var send = true;
if (ns != null)
foreach (var g in init.GetAllGumps())
{
var send = true;
foreach (var g in ns.Gumps)
if (g is ParticipantGump pg && pg.Participant == p)
{
if (g is ParticipantGump pg && pg.Participant == p)
{
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
init.SendGump(new ParticipantGump(init, dc, p));
send = false;
break;
}
if (send)
if (g is DuelContextGump dcg && dcg.Context == dc)
{
init.SendGump(new DuelContextGump(init, dc));
send = false;
break;
}
}
if (send)
{
init.SendGump(new DuelContextGump(init, dc));
}
}
}
}
@ -1714,13 +1698,15 @@ namespace Server.Engines.ConPVP
public void CloseAllGumps(DuelPlayer pl)
{
pl.Mobile.CloseGump<BeginGump>();
pl.Mobile.CloseGump<DuelContextGump>();
pl.Mobile.CloseGump<ParticipantGump>();
pl.Mobile.CloseGump<PickRulesetGump>();
pl.Mobile.CloseGump<ReadyGump>();
pl.Mobile.CloseGump<ReadyUpGump>();
pl.Mobile.CloseGump<RulesetGump>();
var gumps = pl.Mobile.GetGumps();
gumps.Close<BeginGump>();
gumps.Close<DuelContextGump>();
gumps.Close<ParticipantGump>();
gumps.Close<PickRulesetGump>();
gumps.Close<ReadyGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<RulesetGump>();
}
public void CloseAllGumps()
@ -1799,9 +1785,11 @@ namespace Server.Engines.ConPVP
}
// Close all of them?
mob.CloseGump<DuelContextGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<ReadyGump>();
var gumps = mob.GetGumps();
gumps.Close<DuelContextGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<ReadyGump>();
}
}
@ -2194,10 +2182,12 @@ namespace Server.Engines.ConPVP
{
if (count == 10)
{
mob.CloseGump<ReadyGump>();
mob.CloseGump<ReadyUpGump>();
mob.CloseGump<BeginGump>();
mob.SendGump(new BeginGump(count));
var gumps = mob.GetGumps();
gumps.Close<ReadyGump>();
gumps.Close<ReadyUpGump>();
gumps.Close<BeginGump>();
gumps.Send(new BeginGump(count));
}
mob.Frozen = true;
@ -2256,8 +2246,7 @@ namespace Server.Engines.ConPVP
if (mob != null && m_Tournament == null)
{
mob.CloseGump<ReadyUpGump>();
mob.SendGump(new ReadyUpGump(mob, this));
mob.SendGump(new ReadyUpGump(mob, this), true);
}
}
}
@ -2512,8 +2501,7 @@ namespace Server.Engines.ConPVP
{
if (m_Tournament == null)
{
mob.CloseGump<ReadyGump>();
mob.SendGump(new ReadyGump(mob, this, count));
mob.SendGump(new ReadyGump(mob, this, count), true);
}
}
else

View file

@ -1057,7 +1057,6 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump<BRBoardGump>();
from.SendGump(new BRBoardGump(from, m_TeamInfo.Game));
}
}
@ -1082,7 +1081,7 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000;
// private BRGame m_Game;
public override bool Singleton => true;
public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60)
{
@ -1719,7 +1718,6 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump<BRBoardGump>();
mob.SendGump(new BRBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1918,7 +1916,6 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump<BRBoardGump>();
dp.Mobile.SendGump(new BRBoardGump(dp.Mobile, this));
}
}

View file

@ -29,7 +29,6 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump<CTFBoardGump>();
from.SendGump(new CTFBoardGump(from, m_TeamInfo.Game));
}
}
@ -56,6 +55,8 @@ namespace Server.Engines.ConPVP
private CTFGame m_Game;
public override bool Singleton => true;
public CTFBoardGump(Mobile mob, CTFGame game, CTFTeamInfo section = null)
: base(60, 60)
{
@ -1059,7 +1060,6 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump<CTFBoardGump>();
mob.SendGump(new CTFBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1258,7 +1258,6 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump<CTFBoardGump>();
dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this));
}
}

View file

@ -27,7 +27,6 @@ namespace Server.Engines.ConPVP
{
if (m_TeamInfo?.Game != null)
{
from.CloseGump<DDBoardGump>();
from.SendGump(new DDBoardGump(from, m_TeamInfo.Game));
}
}
@ -52,7 +51,7 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000000;
// private DDGame m_Game;
public override bool Singleton => true;
public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null)
: base(60, 60)
@ -605,7 +604,6 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump<DDBoardGump>();
mob.SendGump(new DDBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -820,7 +818,6 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump<DDBoardGump>();
dp.Mobile.SendGump(new DDBoardGump(dp.Mobile, this));
}
}

View file

@ -311,7 +311,6 @@ namespace Server.Engines.ConPVP
{
if (m_Game != null)
{
from.CloseGump<KHBoardGump>();
from.SendGump(new KHBoardGump(from, m_Game));
}
else
@ -353,6 +352,8 @@ namespace Server.Engines.ConPVP
private KHGame m_Game;
public override bool Singleton => true;
public KHBoardGump(Mobile mob, KHGame game)
: base(60, 60)
{
@ -989,7 +990,6 @@ namespace Server.Engines.ConPVP
}
}
mob.CloseGump<KHBoardGump>();
mob.SendGump(new KHBoardGump(mob, this));
m_Context.Requip(mob, corpse);
@ -1199,7 +1199,6 @@ namespace Server.Engines.ConPVP
if (dp?.Mobile != null)
{
dp.Mobile.CloseGump<KHBoardGump>();
dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this));
}
}

View file

@ -50,7 +50,6 @@ namespace Server.Engines.ConPVP
return false;
}
from.CloseGump<ArenaGump>();
from.SendGump(new ArenaGump(from, this));
if (!from.Hidden || from.AccessLevel == AccessLevel.Player)
@ -84,6 +83,8 @@ namespace Server.Engines.ConPVP
private int m_ColumnX = 12;
public override bool Singleton => true;
public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
{
m_From = from;

View file

@ -19,6 +19,8 @@ namespace Server.Engines.ConPVP
private readonly Mobile m_Registrar;
private readonly Tournament m_Tournament;
public override bool Singleton => true;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50)
{
m_From = from;
@ -26,10 +28,11 @@ namespace Server.Engines.ConPVP
m_Tournament = tourney;
m_Players = players;
m_From.CloseGump<AcceptTeamGump>();
m_From.CloseGump<AcceptDuelGump>();
m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>();
var gumps = m_From.GetGumps();
gumps.Close<AcceptTeamGump>();
gumps.Close<AcceptDuelGump>();
gumps.Close<DuelContextGump>();
var ruleset = tourney.Ruleset;
var basedef = ruleset.Base;

View file

@ -5,14 +5,17 @@ namespace Server.Engines.ConPVP
{
public class DuelContextGump : Gump
{
public override bool Singleton => true;
public DuelContextGump(Mobile from, DuelContext context) : base(50, 50)
{
From = from;
Context = context;
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
var gumps = from.GetGumps();
gumps.Close<RulesetGump>();
gumps.Close<ParticipantGump>();
var count = context.Participants.Count;

View file

@ -52,8 +52,7 @@ namespace Server.Engines.ConPVP
if (ladder != null)
{
from.CloseGump<LadderGump>();
from.SendGump(new LadderGump(ladder));
from.SendGump(new LadderGump(ladder), true);
}
}
else

View file

@ -7,15 +7,18 @@ namespace Server.Engines.ConPVP
{
public class ParticipantGump : Gump
{
public override bool Singleton => true;
public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50)
{
From = from;
Context = context;
Participant = p;
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
var gumps = from.GetGumps();
gumps.Close<RulesetGump>();
gumps.Close<DuelContextGump>();
var count = p.Players.Length;

View file

@ -12,6 +12,8 @@ namespace Server.Engines.ConPVP
private readonly bool m_ReadOnly;
private readonly Ruleset m_Ruleset;
public override bool Singleton => true;
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false)
: base(readOnly ? 310 : 50, 50)
{
@ -23,9 +25,10 @@ namespace Server.Engines.ConPVP
Draggable = !readOnly;
from.CloseGump<RulesetGump>();
from.CloseGump<DuelContextGump>();
from.CloseGump<ParticipantGump>();
var gumps = from.GetGumps();
gumps.Close<DuelContextGump>();
gumps.Close<ParticipantGump>();
var depthCounter = page;

View file

@ -179,6 +179,8 @@ namespace Server.Engines.ConPVP
private readonly PreferencesEntry m_Entry;
private int m_ColumnX = 12;
public override bool Singleton => true;
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
{
m_Entry = prefs.Find(from);

View file

@ -1,3 +1,5 @@
using Server.Gumps;
namespace Server.Engines.ConPVP
{
public class TournamentBracketItem : Item
@ -26,8 +28,7 @@ namespace Server.Engines.ConPVP
if (tourney != null)
{
from.CloseGump<TournamentBracketGump>();
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index));
from.SendGump(new TournamentBracketGump(from, tourney, TourneyBracketGumpType.Index), true);
}
}
}

View file

@ -66,9 +66,11 @@ namespace Server.Engines.ConPVP
{
if (from.AccessLevel >= AccessLevel.GameMaster && Tournament != null)
{
from.CloseGump<PickRulesetGump>();
from.CloseGump<RulesetGump>();
from.SendGump(new PickRulesetGump(from, null, Tournament.Ruleset));
var gumps = from.GetGumps();
gumps.Close<RulesetGump>();
gumps.Close<PickRulesetGump>();
gumps.Send(new PickRulesetGump(from, null, Tournament.Ruleset));
}
}

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Server.Factions;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.ConPVP
@ -146,7 +147,6 @@ namespace Server.Engines.ConPVP
}
else if (!tourney.HasParticipant(from))
{
from.CloseGump<ConfirmSignupGump>();
from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List<Mobile> { from }));
}
else

View file

@ -24,6 +24,8 @@ public class CraftGump : DynamicGump
private readonly BaseTool _tool;
private readonly TextDefinition _notice;
public override bool Singleton => true;
public CraftGump(
Mobile from, CraftSystem craftSystem, BaseTool tool, TextDefinition notice, CraftPage page = CraftPage.None
) : base(40, 40)
@ -419,7 +421,6 @@ public class CraftGump : DynamicGump
public override void SendTo(NetState ns)
{
_from.CloseGump<CraftGump>();
_from.CloseGump<CraftGumpItem>();
base.SendTo(ns);

View file

@ -27,6 +27,8 @@ namespace Server.Engines.Craft
private bool m_ShowExceptionalChance;
public override bool Singleton => true;
public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool) : base(40, 40)
{
m_From = from;
@ -34,9 +36,6 @@ namespace Server.Engines.Craft
m_CraftItem = craftItem;
m_Tool = tool;
from.CloseGump<CraftGump>();
from.CloseGump<CraftGumpItem>();
AddPage(0);
AddBackground(0, 0, 530, 417, 5054);
AddImageTiled(10, 10, 510, 22, 2624);

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Server.Commands;
using Server.Factions;
using Server.Gumps;
using Server.Items;
using Server.Logging;
using Server.Mobiles;

View file

@ -1,4 +1,5 @@
using System;
using Server.Gumps;
using Server.Items;
using Server.Targeting;

View file

@ -14,13 +14,13 @@ namespace Server.Engines.Craft
private readonly BaseTool m_Tool;
private readonly Type m_TypeRes;
public override bool Singleton => true;
public QueryMakersMarkGump(
int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes,
BaseTool tool
) : base(100, 200)
{
from.CloseGump<QueryMakersMarkGump>();
m_Quality = quality;
m_From = from;
m_CraftItem = craftItem;

View file

@ -1,4 +1,5 @@
using System;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;

View file

@ -1,4 +1,5 @@
using Server.Ethics;
using Server.Gumps;
using Server.Items;
using Server.Targeting;

View file

@ -1,5 +1,6 @@
using System;
using Server.Factions;
using Server.Gumps;
using Server.Items;
using Server.Targeting;

View file

@ -5,6 +5,7 @@ using Server.Commands.Generic;
using Server.Engines.ConPVP;
using Server.Ethics;
using Server.Guilds;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;
using Server.Prompts;

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Mobiles;
namespace Server.Factions;

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Mobiles;
namespace Server.Factions;

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Mobiles;
namespace Server.Factions;

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Mobiles;
namespace Server.Factions;

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;

View file

@ -58,6 +58,8 @@ public sealed class HelpGump : DynamicGump
{
private readonly Mobile _from;
public override bool Singleton => true;
public HelpGump(Mobile from) : base(0, 0) => _from = from;
protected override void BuildLayout(ref DynamicGumpBuilder builder)
@ -206,12 +208,6 @@ public sealed class HelpGump : DynamicGump
builder.AddHtmlLocalized(180, y + 150, 335, 40, 1001015); // NO - I meant to ask for help with another matter.
}
public override void SendTo(NetState ns)
{
_from.CloseGump<HelpGump>();
base.SendTo(ns);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void AddOption(
ref DynamicGumpBuilder builder, int y, int buttonId, int localizedName, GumpButtonType type = GumpButtonType.Reply,
@ -237,12 +233,9 @@ public sealed class HelpGump : DynamicGump
public static void HelpRequest(Mobile m)
{
foreach (var gump in m.NetState.Gumps)
if (m.HasGump<HelpGump>())
{
if (gump is HelpGump)
{
return;
}
return;
}
if (!PageQueue.CheckAllowedToPage(m))

View file

@ -8,6 +8,8 @@ public sealed class PagePromptGump : StaticGump<PagePromptGump>
private readonly Mobile _from;
private readonly PageType _type;
public override bool Singleton => true;
public PagePromptGump(Mobile from, PageType type) : base(0, 0)
{
_from = from;
@ -31,12 +33,6 @@ public sealed class PagePromptGump : StaticGump<PagePromptGump>
builder. AddButton(405, 355, 2073, 2072, 0); // Cancel
}
public override void SendTo(NetState ns)
{
_from.CloseGump<PagePromptGump>();
base.SendTo(ns);
}
public override void OnResponse(NetState sender, in RelayInfo info)
{
if (info.ButtonID == 0)

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Misc;
using Server.Mobiles;
using Server.Network;

View file

@ -118,9 +118,7 @@ namespace Server.Engines.Help
{
if (PageQueue.List.IndexOf(m_List[info.ButtonID - 1]) >= 0)
{
var g = new PageEntryGump(state.Mobile, m_List[info.ButtonID - 1]);
g.SendTo(state);
state.SendGump(new PageEntryGump(state.Mobile, m_List[info.ButtonID - 1]));
}
else
{
@ -224,13 +222,13 @@ namespace Server.Engines.Help
private readonly Mobile m_From;
private readonly PredefinedResponse m_Response;
public override bool Singleton => true;
public PredefGump(Mobile from, PredefinedResponse response) : base(30, 30)
{
m_From = from;
m_Response = response;
from.CloseGump<PredefGump>();
var canEdit = from.AccessLevel >= AccessLevel.GameMaster;
AddPage(0);
@ -593,9 +591,7 @@ namespace Server.Engines.Help
public void Resend(NetState state)
{
var g = new PageEntryGump(m_Mobile, m_Entry);
g.SendTo(state);
state.SendGump(new PageEntryGump(m_Mobile, m_Entry));
}
public override void OnResponse(NetState state, in RelayInfo info)
@ -613,9 +609,7 @@ namespace Server.Engines.Help
{
if (m_Entry.Handler != state.Mobile)
{
var g = new PageQueueGump();
g.SendTo(state);
state.SendGump(new PageQueueGump());
}
break;
@ -722,10 +716,7 @@ namespace Server.Engines.Help
PageQueue.Remove(m_Entry);
state.Mobile.SendMessage("You delete the page.");
var g = new PageQueueGump();
g.SendTo(state);
state.SendGump(new PageQueueGump());
}
else
{
@ -764,10 +755,7 @@ namespace Server.Engines.Help
m_Entry.Handler = null;
state.Mobile.SendMessage("You mark the page as handled, and remove it from the queue.");
var g = new PageQueueGump();
g.SendTo(state);
state.SendGump(new PageQueueGump());
}
else
{

View file

@ -290,9 +290,11 @@ namespace Server.Items
);
}
from.CloseGump<PuzzleGump>();
from.CloseGump<StatusGump>();
from.SendGump(new PuzzleGump(from, this, solution, 0));
var gumps = from.GetGumps();
gumps.Close<StatusGump>();
gumps.Close<PuzzleGump>();
gumps.Send(new PuzzleGump(from, this, solution, 0));
return true;
}

View file

@ -268,12 +268,13 @@ namespace Server.Engines.MLQuests.Gumps
*/
public static void CloseOtherGumps(PlayerMobile pm)
{
pm.CloseGump<InfoNPCGump>();
pm.CloseGump<QuestRewardGump>();
pm.CloseGump<QuestConversationGump>();
pm.CloseGump<QuestReportBackGump>();
// pm.CloseGump( typeof( UnknownGump807 ) );
pm.CloseGump<QuestCancelConfirmGump>();
var gumps = pm.GetGumps();
gumps.Close<InfoNPCGump>();
gumps.Close<QuestRewardGump>();
gumps.Close<QuestConversationGump>();
gumps.Close<QuestReportBackGump>();
gumps.Close<QuestCancelConfirmGump>();
}
private struct ButtonInfo

View file

@ -8,6 +8,8 @@ namespace Server.Engines.MLQuests.Gumps
private readonly bool m_CloseGumps;
private readonly MLQuestInstance m_Instance;
public override bool Singleton => true;
public QuestLogDetailedGump(MLQuestInstance instance, bool closeGumps = true)
: base(1046026) // Quest Log
{
@ -20,7 +22,6 @@ namespace Server.Engines.MLQuests.Gumps
if (closeGumps)
{
CloseOtherGumps(pm);
pm.CloseGump<QuestLogDetailedGump>();
}
SetTitle(quest.Title);

View file

@ -9,6 +9,8 @@ namespace Server.Engines.MLQuests.Gumps
private readonly bool m_CloseGumps;
private readonly PlayerMobile m_Owner;
public override bool Singleton => true;
public QuestLogGump(PlayerMobile pm, bool closeGumps = true)
: base(1046026) // Quest Log
{
@ -17,7 +19,6 @@ namespace Server.Engines.MLQuests.Gumps
if (closeGumps)
{
pm.CloseGump<QuestLogGump>();
pm.CloseGump<QuestLogDetailedGump>();
}

View file

@ -9,6 +9,8 @@ namespace Server.Engines.MLQuests.Gumps
private readonly MLQuest m_Quest;
private readonly IQuestGiver m_Quester;
public override bool Singleton => true;
public QuestOfferGump(MLQuest quest, IQuestGiver quester, PlayerMobile pm)
: base(1049010) // Quest Offer
{
@ -16,7 +18,6 @@ namespace Server.Engines.MLQuests.Gumps
m_Quester = quester;
CloseOtherGumps(pm);
pm.CloseGump<QuestOfferGump>();
SetTitle(quest.Title);
RegisterButton(ButtonPosition.Left, ButtonGraphic.Accept, 1);

View file

@ -27,11 +27,11 @@ namespace Server.Engines.MLQuests.Gumps
private readonly IRaceChanger m_Owner;
private readonly Race m_Race;
public override bool Singleton => true;
public RaceChangeConfirmGump(IRaceChanger owner, PlayerMobile from, Race targetRace)
: base(50, 50)
{
from.CloseGump<RaceChangeConfirmGump>();
m_Owner = owner;
m_From = from;
m_Race = targetRace;

View file

@ -5,6 +5,7 @@ using Server.Engines.MLQuests.Gumps;
using Server.Engines.MLQuests.Objectives;
using Server.Engines.MLQuests.Rewards;
using Server.Engines.Spawners;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.MLQuests

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Server.Engines.MLQuests.Gumps;
using Server.Engines.MLQuests.Objectives;
using Server.Gumps;
using Server.Mobiles;
namespace Server.Engines.MLQuests

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Engines.MLQuests.Definitions;
using Server.Engines.MLQuests.Gumps;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Targeting;
namespace Server.Engines.Plants
@ -21,12 +22,7 @@ namespace Server.Engines.Plants
if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant &&
from.InRange(m_Plant.GetWorldLocation(), 3) && m_Plant.IsUsableBy(from))
{
if (from.HasGump<MainPlantGump>())
{
from.CloseGump<MainPlantGump>();
}
from.SendGump(new MainPlantGump(m_Plant));
from.SendGump(new MainPlantGump(m_Plant), true);
}
}
}

View file

@ -1,3 +1,4 @@
using Server.Gumps;
using Server.Targeting;
namespace Server.Engines.Plants

View file

@ -55,7 +55,6 @@ public partial class Impresario : BaseQuester
if (obj.IsInRightTheater())
{
player.CloseGump<SheetMusicOfferGump>();
player.SendGump(new SheetMusicOfferGump());
}
else
@ -68,6 +67,8 @@ public partial class Impresario : BaseQuester
public class SheetMusicOfferGump : BaseQuestGump
{
public override bool Singleton => true;
public SheetMusicOfferGump() : base(75, 25)
{
Closable = false;

View file

@ -130,6 +130,8 @@ namespace Server.Engines.Quests
{
private readonly QuestSystem m_System;
public override bool Singleton => true;
public QuestLogUpdatedGump(QuestSystem system) : base(3, 30)
{
m_System = system;

View file

@ -264,7 +264,6 @@ namespace Server.Engines.Quests
public virtual void ShowQuestLogUpdated()
{
From.CloseGump<QuestLogUpdatedGump>();
From.SendGump(new QuestLogUpdatedGump(this));
}
@ -272,18 +271,19 @@ namespace Server.Engines.Quests
{
if (Objectives.Count > 0)
{
From.CloseGump<QuestItemInfoGump>();
From.CloseGump<QuestLogUpdatedGump>();
From.CloseGump<QuestObjectivesGump>();
From.CloseGump<QuestConversationsGump>();
var gumps = From.GetGumps();
gumps.Close<QuestItemInfoGump>();
gumps.Close<QuestLogUpdatedGump>();
gumps.Close<QuestConversationsGump>();
gumps.Close<QuestObjectivesGump>();
From.SendGump(new QuestObjectivesGump(Objectives));
gumps.Send(new QuestObjectivesGump(Objectives));
var last = Objectives[^1];
if (last.Info != null)
{
From.SendGump(new QuestItemInfoGump(last.Info));
gumps.Send(new QuestItemInfoGump(last.Info));
}
}
}
@ -292,11 +292,13 @@ namespace Server.Engines.Quests
{
if (Conversations.Count > 0)
{
From.CloseGump<QuestItemInfoGump>();
From.CloseGump<QuestObjectivesGump>();
From.CloseGump<QuestConversationsGump>();
var gumps = From.GetGumps();
From.SendGump(new QuestConversationsGump(Conversations));
gumps.Close<QuestItemInfoGump>();
gumps.Close<QuestObjectivesGump>();
gumps.Close<QuestConversationsGump>();
gumps.Send(new QuestConversationsGump(Conversations));
var last = Conversations[^1];
@ -389,10 +391,10 @@ namespace Server.Engines.Quests
Conversations.Add(conv);
}
From.CloseGump<QuestItemInfoGump>();
From.CloseGump<QuestObjectivesGump>();
From.CloseGump<QuestConversationsGump>();
From.SendGump(conv.Logged ? new QuestConversationsGump(Conversations) : new QuestConversationsGump(conv));
var gumps = From.GetGumps();
gumps.Close<QuestItemInfoGump>();
gumps.Close<QuestObjectivesGump>();
gumps.Send(conv.Logged ? new QuestConversationsGump(Conversations) : new QuestConversationsGump(conv));
if (conv.Info != null)
{

View file

@ -186,7 +186,6 @@ public partial class Mardoth : BaseQuester
m.PlaySound(0x214);
m.FixedEffect(0x376A, 10, 16);
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.Healer));
}
}

View file

@ -203,7 +203,6 @@ public partial class Emino : BaseQuester
m.PlaySound(0x214);
m.FixedEffect(0x376A, 10, 16);
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.Healer));
}
}

View file

@ -105,7 +105,6 @@ public partial class Zoel : BaseQuester
m.PlaySound(0x214);
m.FixedEffect(0x376A, 10, 16);
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.Healer));
}
}

View file

@ -1,4 +1,5 @@
using System;
using Server.Gumps;
using Server.Regions;
using Server.Mobiles;

View file

@ -220,7 +220,6 @@ public partial class Chyloth : BaseQuester
AngryAt = null;
}
member.CloseGump<ChylothPartyGump>();
member.SendGump(new ChylothPartyGump(from, member));
}
}

View file

@ -130,7 +130,6 @@ public partial class Schmendrick : BaseQuester
m.PlaySound(0x214);
m.FixedEffect(0x376A, 10, 16);
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.Healer));
}
}

View file

@ -391,7 +391,6 @@ public partial class Uzeraan : BaseQuester
m.PlaySound(0x214);
m.FixedEffect(0x376A, 10, 16);
m.CloseGump<ResurrectGump>();
m.SendGump(new ResurrectGump(m, ResurrectMessage.Healer));
}
}

View file

@ -4,6 +4,7 @@ using System.Reflection;
using System.Text.Json;
using ModernUO.Serialization;
using Server.Commands;
using Server.Gumps;
using Server.Items;
using Server.Json;
using Server.Mobiles;

View file

@ -291,6 +291,8 @@ namespace Server.Mobiles
{
if (m.Alive && m is PlayerMobile pm)
{
var gumps = pm.GetGumps();
if (pm.Alive && (Z - pm.Z).Abs() < 16 && InRange(m, 3) && !InRange(oldLocation, 3))
{
if (pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
@ -298,11 +300,11 @@ namespace Server.Mobiles
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
SayTo(pm, 1070980);
pm.CloseGump<ToTTurnInGump>(); // Sanity
gumps.Close<ToTTurnInGump>(); // Sanity
if (!pm.HasGump<ToTRedeemGump>())
{
pm.SendGump(new ToTRedeemGump(this, false));
gumps.Send(new ToTRedeemGump(this, false));
}
}
else
@ -325,7 +327,7 @@ namespace Server.Mobiles
if (buttons?.Count > 0 && !pm.HasGump<ToTTurnInGump>())
{
pm.SendGump(new ToTTurnInGump(this, buttons));
gumps.Send(new ToTTurnInGump(this, buttons));
}
}
}
@ -334,8 +336,8 @@ namespace Server.Mobiles
if (!InRange(m, leaveRange) && InRange(oldLocation, leaveRange))
{
pm.CloseGump<ToTRedeemGump>();
pm.CloseGump<ToTTurnInGump>();
gumps.Close<ToTRedeemGump>();
gumps.Close<ToTTurnInGump>();
}
}
}
@ -412,16 +414,18 @@ namespace Server.Gumps
item.Delete();
var gumps = pm.GetGumps();
if (++pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)
{
// Congratulations! You have turned in enough minor treasures to earn a greater reward.
m_Collector.SayTo(pm, 1070980);
pm.CloseGump<ToTTurnInGump>(); // Sanity
gumps.Close<ToTTurnInGump>(); // Sanity
if (!pm.HasGump<ToTRedeemGump>())
if (!gumps.Has<ToTRedeemGump>())
{
pm.SendGump(new ToTRedeemGump(m_Collector, false));
gumps.Send(new ToTRedeemGump(m_Collector, false));
}
}
else
@ -434,11 +438,11 @@ namespace Server.Gumps
var buttons = FindRedeemableItems(pm);
pm.CloseGump<ToTTurnInGump>(); // Sanity
gumps.Close<ToTTurnInGump>(); // Sanity
if (buttons?.Count > 0)
{
pm.SendGump(new ToTTurnInGump(m_Collector, buttons));
gumps.Send(new ToTTurnInGump(m_Collector, buttons));
}
}
}
@ -594,9 +598,7 @@ namespace Server.Gumps
if (t.Type == typeof(PigmentsOfTokuno)) // Special case of course.
{
pm.CloseGump<ToTTurnInGump>(); // Sanity
pm.CloseGump<ToTRedeemGump>();
pm.SendGump(new ToTRedeemGump(m_Collector, true));
pm.SendGump(new ToTRedeemGump(m_Collector, true), true);
return;
}

View file

@ -591,8 +591,7 @@ public class CharacterStatueTarget : Target
_maker.Delete();
statue.Sculpt(from);
from.CloseGump<CharacterStatueGump>();
from.SendGump(new CharacterStatueGump(_maker, statue, from));
from.SendGump(new CharacterStatueGump(_maker, statue, from), true);
return;
}

View file

@ -8,12 +8,12 @@ namespace Server.Engines.VeteranRewards
{
private readonly Mobile m_From;
public override bool Singleton => true;
public RewardChoiceGump(Mobile from) : base(0, 0)
{
m_From = from;
from.CloseGump<RewardChoiceGump>();
RenderBackground();
RenderCategories();
}

View file

@ -9,13 +9,13 @@ namespace Server.Engines.VeteranRewards
private readonly RewardEntry m_Entry;
private readonly Mobile m_From;
public override bool Singleton => true;
public RewardConfirmGump(Mobile from, RewardEntry entry) : base(0, 0)
{
m_From = from;
m_Entry = entry;
from.CloseGump<RewardConfirmGump>();
AddPage(0);
AddBackground(10, 10, 500, 300, 2600);

View file

@ -8,6 +8,8 @@ namespace Server.Gumps
{
private readonly IAddon m_Addon;
public override bool Singleton => true;
public RewardDemolitionGump(IAddon addon, int question) : base(150, 50)
{
m_Addon = addon;

View file

@ -7,12 +7,12 @@ namespace Server.Engines.VeteranRewards
{
private readonly Mobile m_From;
public override bool Singleton => true;
public RewardNoticeGump(Mobile from) : base(0, 0)
{
m_From = from;
from.CloseGump<RewardNoticeGump>();
AddPage(0);
AddBackground(10, 10, 500, 135, 2600);

View file

@ -14,6 +14,8 @@ namespace Server.Gumps
private readonly IRewardOption m_Option;
private readonly RewardOptionList m_Options = new();
public override bool Singleton => true;
public RewardOptionGump(IRewardOption option, int title = 0) : base(60, 36)
{
m_Option = option;

View file

@ -1,5 +1,6 @@
using System;
using Server.Accounting;
using Server.Gumps;
using Server.Items;
using Server.Mobiles;

View file

@ -74,7 +74,6 @@ public static class SacrificeVirtue
* We need to wait for them to accept the gump or they can just use
* Sacrifice and cancel to have items in their backpack for free.
*/
from.CloseGump<ResurrectGump>();
from.SendGump(new ResurrectGump(from, fromSacrifice: true));
}
else

View file

@ -36,8 +36,7 @@ public class VirtueGump : Gump
}
else if (beholder.Map == beheld.Map && beholder.InRange(beheld, 12))
{
beholder.CloseGump<VirtueGump>();
beholder.SendGump(new VirtueGump(beholder, beheld));
beholder.SendGump(new VirtueGump(beholder, beheld), true);
}
}

View file

@ -74,13 +74,13 @@ namespace Server.Gumps
private readonly AdminGumpPage m_PageType;
private readonly object m_State;
public override bool Singleton => true;
public AdminGump(
Mobile from, AdminGumpPage pageType, int listPage = 0, List<object> list = null, string notice = null,
object state = null
) : base(50, 40)
{
from.CloseGump<AdminGump>();
m_From = from;
m_PageType = pageType;
m_ListPage = listPage;

View file

@ -15,12 +15,14 @@
using Server.Network;
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
namespace Server.Gumps;
public abstract class BaseGump
{
private static readonly byte[] _packetBuffer = GC.AllocateUninitializedArray<byte>(0x10000);
private static Serial nextSerial = (Serial)1;
public int TypeID { get; protected set; }
@ -30,9 +32,13 @@ public abstract class BaseGump
public abstract int TextEntries { get; }
public int X { get; set; }
public int Y { get; set; }
/**
* If true, only one instance of this gump can be open at a time per player.
*/
public virtual bool Singleton => false;
public BaseGump(int x, int y) : this()
{
X = x;
@ -45,7 +51,17 @@ public abstract class BaseGump
TypeID = GetTypeId(GetType());
}
public abstract void SendTo(NetState ns);
public virtual void SendTo(NetState ns)
{
var writer = new SpanWriter(_packetBuffer);
Compile(ref writer);
ns.Send(writer.Span);
writer.Dispose();
}
public abstract void Compile(ref SpanWriter writer);
public virtual void OnResponse(NetState sender, in RelayInfo info)
{

View file

@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Buffers;
using System.IO;
using Server.Network;
@ -22,8 +21,6 @@ namespace Server.Gumps;
public abstract class DynamicGump : BaseGump
{
private static readonly byte[] _packetBuffer = GC.AllocateUninitializedArray<byte>(0x10000);
private int _switches;
private int _textEntries;
@ -36,7 +33,7 @@ public abstract class DynamicGump : BaseGump
protected abstract void BuildLayout(ref DynamicGumpBuilder builder);
public void CreatePacket(ref SpanWriter writer)
public override void Compile(ref SpanWriter writer)
{
writer.Write((byte)0xDD); // Packet ID
writer.Seek(2, SeekOrigin.Current);
@ -62,16 +59,4 @@ public abstract class DynamicGump : BaseGump
writer.WritePacketLength();
}
public override void SendTo(NetState ns)
{
ns.AddGump(this);
var writer = new SpanWriter(_packetBuffer);
CreatePacket(ref writer);
ns.Send(writer.Span);
writer.Dispose();
}
}

Some files were not shown because too many files have changed in this diff Show more