Modernization Fixes & Updates to Default Values (#3)

This commit is contained in:
Kamron Batman 2018-10-28 00:33:16 -07:00 • committed by GitHub
parent 445eddff68
commit dcf64091b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
768 changed files with 10507 additions and 14196 deletions

View file

@ -20,7 +20,7 @@ namespace Server.Gumps
m_SearchResults = searchResults;
m_Page = page;
from.CloseGump(typeof(AddGump));
from.CloseGump<AddGump>();
AddPage(0);

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Network;
@ -7,13 +7,13 @@ namespace Server.Gumps
{
public class BanDurationGump : Gump
{
private ArrayList m_List;
private List<Account> m_List;
public BanDurationGump(Account a) : this(MakeList(a))
public BanDurationGump(Account a) : this(new List<Account>{ a })
{
}
public BanDurationGump(ArrayList list) : base((640 - 500) / 2, (480 - 305) / 2)
public BanDurationGump(List<Account> list) : base((640 - 500) / 2, (480 - 305) / 2)
{
m_List = list;
@ -55,13 +55,6 @@ namespace Server.Gumps
AddTextEntry(x + 2, y + 2, width - 4, height - 4, 0, index, "");
}
public static ArrayList MakeList(object obj)
{
ArrayList list = new ArrayList(1);
list.Add(obj);
return list;
}
public void AddInput(int bid, int idx, string name)
{
int x = 15;
@ -88,15 +81,13 @@ namespace Server.Gumps
TimeSpan duration;
bool shouldSet;
string fromString = from.ToString();
switch (info.ButtonID)
{
case 0:
{
for (int i = 0; i < m_List.Count; ++i)
{
Account a = (Account)m_List[i];
Account a = m_List[i];
a.SetUnspecifiedBan(from);
}
@ -123,6 +114,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
duration = TimeSpan.Zero;
@ -142,6 +134,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
duration = TimeSpan.Zero;
@ -161,6 +154,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
duration = TimeSpan.Zero;
@ -180,6 +174,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
duration = TimeSpan.Zero;
@ -199,6 +194,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
duration = TimeSpan.Zero;
@ -223,7 +219,7 @@ namespace Server.Gumps
for (int i = 0; i < m_List.Count; ++i)
{
Account a = (Account)m_List[i];
Account a = m_List[i];
a.SetBanTags(from, DateTime.UtcNow, duration);

View file

@ -8,7 +8,7 @@ namespace Server.Gumps
{
Closable = false;
Disposable = true;
Dragable = true;
Draggable = true;
Resizable = false;
AddPage(0);

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using Server.Network;
namespace Server.Gumps
@ -50,13 +50,12 @@ namespace Server.Gumps
public class BaseImageTileButtonsGump : Gump
{
public BaseImageTileButtonsGump(TextDefinition header, ArrayList buttons) : this(header,
(ImageTileButtonInfo[])buttons.ToArray(typeof(ImageTileButtonInfo)))
public BaseImageTileButtonsGump(TextDefinition header, List<ImageTileButtonInfo> buttons) :
this(header, buttons.ToArray())
{
}
public BaseImageTileButtonsGump(TextDefinition header, ImageTileButtonInfo[] buttons) :
base(10, 10) //Coords are 0, o on OSI, intentional difference
public BaseImageTileButtonsGump(TextDefinition header, ImageTileButtonInfo[] buttons) : base(10, 10) //Coords are 0, o on OSI, intentional difference
{
Buttons = buttons;
AddPage(0);

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Server.Commands;
@ -82,7 +82,7 @@ namespace Server.Gumps
}
else
{
ArrayList nodes = new ArrayList();
List<CAGNode> nodes = new List<CAGNode>();
while (xml.Read() && xml.NodeType != XmlNodeType.EndElement)
if (xml.NodeType == XmlNodeType.Element && xml.Name == "object")
@ -99,7 +99,7 @@ namespace Server.Gumps
xml.Skip();
}
Nodes = (CAGNode[])nodes.ToArray(typeof(CAGNode));
Nodes = nodes.ToArray();
}
}
@ -131,9 +131,8 @@ namespace Server.Gumps
{
if (File.Exists(path))
{
XmlTextReader xml = new XmlTextReader(path);
XmlTextReader xml = new XmlTextReader(path) { WhitespaceHandling = WhitespaceHandling.None };
xml.WhitespaceHandling = WhitespaceHandling.None;
while (xml.Read())
if (xml.Name == "category" && xml.NodeType == XmlNodeType.Element)
@ -222,7 +221,7 @@ namespace Server.Gumps
public CategorizedAddGump(Mobile owner, CAGCategory category, int page) : base(GumpOffsetX, GumpOffsetY)
{
owner.CloseGump(typeof(WhoGump));
owner.CloseGump<WhoGump>();
m_Owner = owner;
m_Category = category;

View file

@ -185,7 +185,7 @@ namespace Server.Gumps
if (!BaseCommand.IsAccessible(from, focus))
{
from.SendMessage("That is not accessible.");
from.SendLocalizedMessage(500447); // That is not accessible.
}
else
{

View file

@ -99,7 +99,7 @@ namespace Server.Gumps
public override void OnCancel(Mobile from)
{
from.CloseGump(typeof(CommentsGump));
from.CloseGump<CommentsGump>();
from.SendGump(new CommentsGump(m_Acct));
base.OnCancel(from);
}
@ -110,7 +110,7 @@ namespace Server.Gumps
from.SendMessage("Comment added.");
//m_Acct.AddComment( from.Name, text );
m_Acct.Comments.Add(new AccountComment(from.Name, text));
from.CloseGump(typeof(CommentsGump));
from.CloseGump<CommentsGump>();
from.SendGump(new CommentsGump(m_Acct));
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Gumps
m_Mobile = mobile;
m_House = house;
mobile.CloseGump(typeof(ConfirmHouseResize));
mobile.CloseGump<ConfirmHouseResize>();
Closable = false;
@ -150,7 +150,7 @@ namespace Server.Gumps
}
else if (info.ButtonID == 0)
{
m_Mobile.CloseGump(typeof(ConfirmHouseResize));
m_Mobile.CloseGump<ConfirmHouseResize>();
m_Mobile.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, m_Mobile, m_House));
}
}

View file

@ -13,7 +13,7 @@ namespace Server.Gumps
m_From = from;
m_Pet = pet;
m_From.CloseGump(typeof(ConfirmReleaseGump));
m_From.CloseGump<ConfirmReleaseGump>();
AddPage(0);

View file

@ -2,7 +2,7 @@ using System.Xml;
namespace Server.Gumps
{
public class ChildNode
public class ChildNode : IGoNode
{
public ChildNode(XmlTextReader xml, ParentNode parent)
{
@ -19,10 +19,7 @@ namespace Server.Gumps
private void Parse(XmlTextReader xml)
{
if (xml.MoveToAttribute("name"))
Name = xml.Value;
else
Name = "empty";
Name = xml.MoveToAttribute("name") ? xml.Value : "empty";
int x = 0, y = 0, z = 0;

View file

@ -67,7 +67,7 @@ namespace Server.Gumps
private GoGump(int page, Mobile from, LocationTree tree, ParentNode node) : base(50, 50)
{
from.CloseGump(typeof(GoGump));
from.CloseGump<GoGump>();
tree.LastBranch[from] = node;
@ -151,13 +151,8 @@ namespace Server.Gumps
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
object child = node.Children[index];
string name = "";
if (child is ParentNode parentNode)
name = parentNode.Name;
else if (child is ChildNode childNode)
name = childNode.Name;
IGoNode child = node.Children[index];
string name = child.Name;
AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, name);
@ -228,7 +223,7 @@ namespace Server.Gumps
if (index >= 0 && index < m_Node.Children.Length)
{
object o = m_Node.Children[index];
IGoNode o = m_Node.Children[index];
if (o is ParentNode node)
from.SendGump(new GoGump(0, from, m_Tree, node));

View file

@ -1,37 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using System.Xml;
namespace Server.Gumps
{
public class ParentNode
public interface IGoNode
{
ParentNode Parent{ get; }
string Name{ get; }
}
public class ParentNode : IGoNode
{
public ParentNode(XmlTextReader xml, ParentNode parent)
{
Parent = parent;
Parse(xml);
}
public ParentNode Parent{ get; }
public object[] Children{ get; private set; }
public IGoNode[] Children{ get; private set; }
public string Name{ get; private set; }
private void Parse(XmlTextReader xml)
{
if (xml.MoveToAttribute("name"))
Name = xml.Value;
else
Name = "empty";
Name = xml.MoveToAttribute("name") ? xml.Value : "empty";
if (xml.IsEmptyElement)
{
Children = new object[0];
}
Children = new IGoNode[0];
else
{
ArrayList children = new ArrayList();
List<IGoNode> children = new List<IGoNode>();
while (xml.Read() && (xml.NodeType == XmlNodeType.Element || xml.NodeType == XmlNodeType.Comment))
{
@ -39,15 +40,9 @@ namespace Server.Gumps
continue;
if (xml.Name == "child")
{
ChildNode n = new ChildNode(xml, this);
children.Add(n);
}
children.Add(new ChildNode(xml, this));
else
{
children.Add(new ParentNode(xml, this));
}
}
Children = children.ToArray();

View file

@ -16,7 +16,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 400, 5054);

View file

@ -14,7 +14,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 400, 5054);

View file

@ -33,7 +33,7 @@ namespace Server.Gumps
if (text.Length >= 3)
{
List<Guild> guilds = Utility.CastConvertList<BaseGuild, Guild>(BaseGuild.Search(text));
List<Guild> guilds = Utility.CastListCovariant<BaseGuild, Guild>(BaseGuild.Search(text));
GuildGump.EnsureClosed(m_Mobile);

View file

@ -13,7 +13,7 @@ namespace Server.Gumps
m_Mobile = beholder;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 400, 5054);
@ -110,17 +110,17 @@ namespace Server.Gumps
public static void EnsureClosed(Mobile m)
{
m.CloseGump(typeof(DeclareFealtyGump));
m.CloseGump(typeof(GrantGuildTitleGump));
m.CloseGump(typeof(GuildAdminCandidatesGump));
m.CloseGump(typeof(GuildCandidatesGump));
m.CloseGump(typeof(GuildChangeTypeGump));
m.CloseGump(typeof(GuildCharterGump));
m.CloseGump(typeof(GuildDismissGump));
m.CloseGump(typeof(GuildGump));
m.CloseGump(typeof(GuildmasterGump));
m.CloseGump(typeof(GuildRosterGump));
m.CloseGump(typeof(GuildWarGump));
m.CloseGump<DeclareFealtyGump>();
m.CloseGump<GrantGuildTitleGump>();
m.CloseGump<GuildAdminCandidatesGump>();
m.CloseGump<GuildCandidatesGump>();
m.CloseGump<GuildChangeTypeGump>();
m.CloseGump<GuildCharterGump>();
m.CloseGump<GuildDismissGump>();
m.CloseGump<GuildGump>();
m.CloseGump<GuildmasterGump>();
m.CloseGump<GuildRosterGump>();
m.CloseGump<GuildWarGump>();
}
public static bool BadLeader(Mobile m, Guild g)

View file

@ -14,7 +14,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 440, 5054);

View file

@ -15,7 +15,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 440, 5054);

View file

@ -13,7 +13,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 440, 5054);

View file

@ -14,7 +14,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 440, 5054);

View file

@ -14,7 +14,7 @@ namespace Server.Gumps
m_Mobile = from;
m_Guild = guild;
Dragable = false;
Draggable = false;
AddPage(0);
AddBackground(0, 0, 550, 400, 5054);

View file

@ -16,7 +16,7 @@ namespace Server.Guilds
guild = g;
player = pm;
pm.CloseGump(typeof(BaseGuildGump));
pm.CloseGump<BaseGuildGump>();
}
protected Guild guild{ get; }

View file

@ -8,8 +8,8 @@ namespace Server.Guilds
{
public CreateGuildGump(PlayerMobile pm, string guildName = "Guild Name", string guildAbbrev = "") : base(10, 10)
{
pm.CloseGump(typeof(CreateGuildGump));
pm.CloseGump(typeof(BaseGuildGump));
pm.CloseGump<CreateGuildGump>();
pm.CloseGump<BaseGuildGump>();
AddPage(0);

View file

@ -19,7 +19,7 @@ namespace Server.Guilds
public GuildDiplomacyGump(PlayerMobile pm, Guild g)
: this(pm, g, NameComparer.Instance, true, "", 0, GuildDisplayType.All,
Utility.CastConvertList<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
1063136 + (int)GuildDisplayType.All)
{
}
@ -27,7 +27,7 @@ namespace Server.Guilds
public GuildDiplomacyGump(PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter,
int startNumber, GuildDisplayType display)
: this(pm, g, currentComparer, ascending, filter, startNumber, display,
Utility.CastConvertList<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
1063136 + (int)display)
{
}

View file

@ -148,7 +148,7 @@ namespace Server.Guilds
// Guild Faction
if (Guild.OrderChaos && IsLeader(pm, guild))
{
pm.CloseGump(typeof(GuildChangeTypeGump));
pm.CloseGump<GuildChangeTypeGump>();
pm.SendGump(new GuildChangeTypeGump(pm, guild));
}

View file

@ -95,7 +95,7 @@ namespace Server.Guilds
if (pm.GuildRank.GetFlag(RankFlags.CanInvitePlayer))
{
pm.SendLocalizedMessage(1063048); // Whom do you wish to invite into your guild?
pm.BeginTarget(-1, false, TargetFlags.None, new TargetStateCallback(InvitePlayer_Callback), guild);
pm.BeginTarget(-1, false, TargetFlags.None, InvitePlayer_Callback, guild);
}
else
{
@ -104,13 +104,11 @@ namespace Server.Guilds
}
}
public void InvitePlayer_Callback(Mobile from, object targeted, object state)
public void InvitePlayer_Callback(Mobile from, object targeted, Guild g)
{
PlayerMobile pm = from as PlayerMobile;
PlayerMobile targ = targeted as PlayerMobile;
Guild g = state as Guild;
PlayerState guildState = PlayerState.Find(g.Leader);
PlayerState targetState = PlayerState.Find(targ);
@ -137,7 +135,7 @@ namespace Server.Guilds
{
pm.SendLocalizedMessage(1063051, targ.Name); // ~1_val~ is already a member of a guild.
}
else if (targ.HasGump(typeof(BaseGuildGump)) || targ.HasGump(typeof(CreateGuildGump))
else if (targ.HasGump<BaseGuildGump>() || targ.HasGump<CreateGuildGump>()
) //TODO: Check message if CreateGuildGump Open
{
pm.SendLocalizedMessage(1063052, targ.Name); // ~1_val~ is currently considering another guild invitation.

View file

@ -564,7 +564,7 @@ namespace Server.Gumps
if (types.Count > 0 && cliloc > 0)
{
sender.Mobile.CloseGump(typeof(ConfirmHeritageGump));
sender.Mobile.CloseGump<ConfirmHeritageGump>();
sender.Mobile.SendGump(new ConfirmHeritageGump(m_Token, types.ToArray(), cliloc));
}
else

View file

@ -16,7 +16,7 @@ namespace Server.Gumps
m_Mobile = mobile;
m_House = house;
mobile.CloseGump(typeof(HouseDemolishGump));
mobile.CloseGump<HouseDemolishGump>();
Closable = false;

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using Server.Guilds;
using Server.Multis;
using Server.Network;
@ -10,7 +10,7 @@ namespace Server.Gumps
{
private BaseHouse m_House;
public HouseListGump(int number, ArrayList list, BaseHouse house, bool accountOf) : base(20, 30)
public HouseListGump(int number, List<Mobile> list, BaseHouse house, bool accountOf) : base(20, 30)
{
if (house.Deleted)
return;
@ -27,29 +27,31 @@ namespace Server.Gumps
AddHtmlLocalized(20, 20, 350, 20, number, false, false);
if (list != null)
for (int i = 0; i < list.Count; ++i)
if (list == null)
return;
for (int i = 0; i < list.Count; ++i)
{
if (i % 16 == 0)
{
if (i % 16 == 0)
{
if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 16 + 1);
if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 16 + 1);
AddPage(i / 16 + 1);
AddPage(i / 16 + 1);
if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 16);
}
Mobile m = (Mobile)list[i];
string name;
if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0)
continue;
AddLabel(55, 55 + i % 16 * 20, 0, accountOf && m.Player && m.Account != null
? $"Account of {name}"
: name);
if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 16);
}
Mobile m = list[i];
string name;
if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0)
continue;
AddLabel(55, 55 + i % 16 * 20, 0, accountOf && m.Player && m.Account != null
? $"Account of {name}"
: name);
}
}
public override void OnResponse(NetState state, RelayInfo info)
@ -67,10 +69,10 @@ namespace Server.Gumps
{
private bool m_AccountOf;
private BaseHouse m_House;
private ArrayList m_List, m_Copy;
private List<Mobile> m_List, m_Copy;
private int m_Number;
public HouseRemoveGump(int number, ArrayList list, BaseHouse house, bool accountOf) : base(20, 30)
public HouseRemoveGump(int number, List<Mobile> list, BaseHouse house, bool accountOf) : base(20, 30)
{
if (house.Deleted)
return;
@ -93,33 +95,33 @@ namespace Server.Gumps
AddHtmlLocalized(20, 20, 350, 20, number, false, false);
if (list != null)
if (list == null)
return;
m_Copy = new List<Mobile>(list);
for (int i = 0; i < list.Count; ++i)
{
m_Copy = new ArrayList(list);
for (int i = 0; i < list.Count; ++i)
if (i % 15 == 0)
{
if (i % 15 == 0)
{
if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 15 + 1);
if (i != 0) AddButton(370, 20, 4005, 4007, 0, GumpButtonType.Page, i / 15 + 1);
AddPage(i / 15 + 1);
AddPage(i / 15 + 1);
if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15);
}
Mobile m = (Mobile)list[i];
string name;
if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0)
continue;
AddCheck(34, 52 + i % 15 * 20, 0xD2, 0xD3, false, i);
AddLabel(55, 52 + i % 15 * 20, 0, accountOf && m.Player && m.Account != null
? $"Account of {name}"
: name);
if (i != 0) AddButton(340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15);
}
Mobile m = list[i];
string name;
if (m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0)
continue;
AddCheck(34, 52 + i % 15 * 20, 0xD2, 0xD3, false, i);
AddLabel(55, 52 + i % 15 * 20, 0, accountOf && m.Player && m.Account != null
? $"Account of {name}"
: name);
}
}
@ -146,9 +148,9 @@ namespace Server.Gumps
if (m_List.Count > 0)
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseRemoveGump(m_Number, m_List, m_House, m_AccountOf));
return;
}
@ -170,9 +172,9 @@ namespace Server.Gumps
m_House = house;
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
bool isCombatRestricted = house.IsCombatRestricted(from);
@ -195,15 +197,14 @@ namespace Server.Gumps
if (m_House.Sign != null)
{
ArrayList lines = Wrap(m_House.Sign.GetName());
List<string> lines = Wrap(m_House.Sign.GetName());
if (lines != null)
for (int i = 0, y = (101 - lines.Count * 14) / 2; i < lines.Count; ++i, y += 14)
{
string s = (string)lines[i];
for (int i = 0, y = (101 - lines.Count * 14) / 2; i < lines.Count; ++i, y += 14)
{
string s = lines[i];
AddLabel(130 + (143 - s.Length * 8) / 2, y, 0, s);
}
AddLabel(130 + (143 - s.Length * 8) / 2, y, 0, s);
}
}
if (!isFriend)
@ -349,13 +350,13 @@ namespace Server.Gumps
}
}
private ArrayList Wrap(string value)
private List<string> Wrap(string value)
{
if (value == null || (value = value.Trim()).Length <= 0)
return null;
string[] values = value.Split(' ');
ArrayList list = new ArrayList();
List<string> list = new List<string>();
string current = "";
for (int i = 0; i < values.Length; ++i)
@ -458,9 +459,9 @@ namespace Server.Gumps
}
case 2: // List of co-owners
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseListGump(1011275, m_House.CoOwners, m_House, false));
break;
@ -484,9 +485,9 @@ namespace Server.Gumps
{
if (isOwner)
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseRemoveGump(1011274, m_House.CoOwners, m_House, false));
}
else
@ -513,9 +514,9 @@ namespace Server.Gumps
}
case 6: // List friends
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseListGump(1011273, m_House.Friends, m_House, false));
break;
@ -538,9 +539,9 @@ namespace Server.Gumps
{
if (isCoOwner)
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseRemoveGump(1011272, m_House.Friends, m_House, false));
}
else
@ -581,18 +582,18 @@ namespace Server.Gumps
}
case 12: // List bans
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseListGump(1011271, m_House.Bans, m_House, true));
break;
}
case 13: // Remove ban
{
from.CloseGump(typeof(HouseGump));
from.CloseGump(typeof(HouseListGump));
from.CloseGump(typeof(HouseRemoveGump));
from.CloseGump<HouseGump>();
from.CloseGump<HouseListGump>();
from.CloseGump<HouseRemoveGump>();
from.SendGump(new HouseRemoveGump(1011269, m_House.Bans, m_House, true));
break;
@ -621,7 +622,7 @@ namespace Server.Gumps
}
else
{
from.CloseGump(typeof(HouseDemolishGump));
from.CloseGump<HouseDemolishGump>();
from.SendGump(new HouseDemolishGump(from, m_House));
}
}

View file

@ -1,6 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Guilds;
using Server.Items;
using Server.Mobiles;
@ -71,7 +71,7 @@ namespace Server.Gumps
private static List<int> _HouseSigns = new List<int>();
private BaseHouse m_House;
private ArrayList m_List;
private List<Mobile> m_List;
private HouseGumpPageAOS m_Page;
public HouseGumpAOS(HouseGumpPageAOS page, Mobile from, BaseHouse house) : base(50, 40)
@ -79,7 +79,7 @@ namespace Server.Gumps
m_House = house;
m_Page = page;
from.CloseGump(typeof(HouseGumpAOS));
from.CloseGump<HouseGumpAOS>();
//from.CloseGump( typeof( HouseListGump ) );
//from.CloseGump( typeof( HouseRemoveGump ) );
@ -114,15 +114,14 @@ namespace Server.Gumps
if (m_House.Sign != null)
{
ArrayList lines = Wrap(m_House.Sign.GetName());
List<string> lines = Wrap(m_House.Sign.GetName());
if (lines != null)
for (int i = 0, y = (114 - lines.Count * 14) / 2; i < lines.Count; ++i, y += 14)
{
string s = (string)lines[i];
for (int i = 0, y = (114 - lines.Count * 14) / 2; i < lines.Count; ++i, y += 14)
{
string s = (string)lines[i];
AddLabel(10 + (160 - s.Length * 8) / 2, y, 0, s);
}
AddLabel(10 + (160 - s.Length * 8) / 2, y, 0, s);
}
}
if (page == HouseGumpPageAOS.Vendors)
@ -506,10 +505,7 @@ namespace Server.Gumps
private string GetDateTime(DateTime val)
{
if (val == DateTime.MinValue)
return "";
return val.ToString("yyyy'-'MM'-'dd HH':'mm':'ss");
return val == DateTime.MinValue ? "" : val.ToString("yyyy'-'MM'-'dd HH':'mm':'ss");
}
public void AddPageButton(int x, int y, int buttonID, int number, HouseGumpPageAOS page)
@ -533,12 +529,12 @@ namespace Server.Gumps
AddHtmlLocalized(x + 35, y, 240, 20, number, enabled ? LabelColor : DisabledColor, false, false);
}
public void AddList(ArrayList list, int button, bool accountOf, bool leadingStar, Mobile from)
public void AddList(List<Mobile> list, int button, bool accountOf, bool leadingStar, Mobile from)
{
if (list == null)
return;
m_List = new ArrayList(list);
m_List = new List<Mobile>(list);
int lastPage = 0;
int index = 0;
@ -563,7 +559,7 @@ namespace Server.Gumps
}
Mobile m = (Mobile)list[i];
Mobile m = list[i];
string name;
int labelHue = LabelHue;
@ -606,26 +602,20 @@ namespace Server.Gumps
return 1 + index * 15 + type;
}
public static void PublicPrivateNotice_Callback(Mobile from, object state)
public static void PublicPrivateNotice_Callback(Mobile from, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (!house.Deleted)
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
}
public static void CustomizeNotice_Callback(Mobile from, object state)
public static void CustomizeNotice_Callback(Mobile from, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (!house.Deleted)
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, house));
}
public static void ClearCoOwners_Callback(Mobile from, bool okay, object state)
public static void ClearCoOwners_Callback(Mobile from, bool okay, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (house.Deleted)
return;
@ -639,10 +629,8 @@ namespace Server.Gumps
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
}
public static void ClearFriends_Callback(Mobile from, bool okay, object state)
public static void ClearFriends_Callback(Mobile from, bool okay, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (house.Deleted)
return;
@ -656,10 +644,8 @@ namespace Server.Gumps
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
}
public static void ClearBans_Callback(Mobile from, bool okay, object state)
public static void ClearBans_Callback(Mobile from, bool okay, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (house.Deleted)
return;
@ -673,22 +659,20 @@ namespace Server.Gumps
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
}
public static void ClearAccess_Callback(Mobile from, bool okay, object state)
public static void ClearAccess_Callback(Mobile from, bool okay, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (house.Deleted)
return;
if (okay && house.IsFriend(from))
{
ArrayList list = new ArrayList(house.Access);
List<Mobile> list = house.Access.ToList();
house.Access?.Clear();
for (int i = 0; i < list.Count; ++i)
{
Mobile m = (Mobile)list[i];
Mobile m = list[i];
if (!house.HasAccess(m) && house.IsInside(m))
{
@ -703,10 +687,8 @@ namespace Server.Gumps
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
}
public static void ConvertHouse_Callback(Mobile from, bool okay, object state)
public static void ConvertHouse_Callback(Mobile from, bool okay, BaseHouse house)
{
BaseHouse house = (BaseHouse)state;
if (house.Deleted)
return;
@ -714,8 +696,9 @@ namespace Server.Gumps
{
HousePlacementEntry e = house.ConvertEntry;
if (e != null)
{
if (e == null)
return;
int cost = e.Cost - house.Price;
if (cost > 0)
@ -749,10 +732,10 @@ namespace Server.Gumps
house.MoveAllToCrate();
newHouse.Friends = new ArrayList(house.Friends);
newHouse.CoOwners = new ArrayList(house.CoOwners);
newHouse.Bans = new ArrayList(house.Bans);
newHouse.Access = new ArrayList(house.Access);
newHouse.Friends = new List<Mobile>(house.Friends);
newHouse.CoOwners = new List<Mobile>(house.CoOwners);
newHouse.Bans = new List<Mobile>(house.Bans);
newHouse.Access = new List<Mobile>(house.Access);
newHouse.BuiltOn = house.BuiltOn;
newHouse.LastTraded = house.LastTraded;
newHouse.Public = house.Public;
@ -799,10 +782,9 @@ namespace Server.Gumps
* These containers can be used to re-create the vendor in a new location.
* Any barkeepers have been converted into deeds.
*/
from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280, null, null));
from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280));
return;
}
}
}
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house));
@ -971,7 +953,7 @@ namespace Server.Gumps
{
if (isOwner)
from.SendGump(new WarningGump(1060635, 30720, 1060736, 32512, 420, 280,
ClearCoOwners_Callback, m_House));
okay => ClearCoOwners_Callback(from, okay, m_House)));
break;
}
@ -1003,7 +985,7 @@ namespace Server.Gumps
{
if (isCoOwner)
from.SendGump(new WarningGump(1060635, 30720, 1018039, 32512, 420, 280,
ClearFriends_Callback, m_House));
okay => ClearFriends_Callback(from, okay, m_House)));
break;
}
@ -1015,8 +997,8 @@ namespace Server.Gumps
}
case 9: // Clear Ban List
{
from.SendGump(new WarningGump(1060635, 30720, 1060753, 32512, 420, 280, ClearBans_Callback,
m_House));
from.SendGump(new WarningGump(1060635, 30720, 1060753, 32512, 420, 280,
okay => ClearBans_Callback(from, okay, m_House)));
break;
}
@ -1028,8 +1010,8 @@ namespace Server.Gumps
}
case 11: // Clear Access List
{
from.SendGump(new WarningGump(1060635, 30720, 1061842, 32512, 420, 280, ClearAccess_Callback,
m_House));
from.SendGump(new WarningGump(1060635, 30720, 1061842, 32512, 420, 280,
okay => ClearAccess_Callback(from, okay, m_House)));
break;
}
@ -1041,7 +1023,7 @@ namespace Server.Gumps
{
// You have vendors working out of this building. It cannot be declared private until there are no vendors in place.
from.SendGump(new NoticeGump(1060637, 30720, 501887, 32512, 320, 180,
PublicPrivateNotice_Callback, m_House));
() => PublicPrivateNotice_Callback(from, m_House)));
break;
}
@ -1049,7 +1031,7 @@ namespace Server.Gumps
{
// You cannot currently take this action because you have vendor contracts locked down in your home. You must remove them first.
from.SendGump(new NoticeGump(1060637, 30720, 1062351, 32512, 320, 180,
PublicPrivateNotice_Callback, m_House));
() => PublicPrivateNotice_Callback(from, m_House)));
break;
}
@ -1059,7 +1041,7 @@ namespace Server.Gumps
// This house is now private.
from.SendGump(new NoticeGump(1060637, 30720, 501888, 32512, 320, 180,
PublicPrivateNotice_Callback, m_House));
() => PublicPrivateNotice_Callback(from, m_House)));
Region r = m_House.Region;
List<Mobile> list = r.GetMobiles();
@ -1086,11 +1068,11 @@ namespace Server.Gumps
if (BaseHouse.NewVendorSystem)
from.SendGump(new NoticeGump(1060637, 30720, 501886, 32512, 320, 180,
PublicPrivateNotice_Callback, m_House));
() => PublicPrivateNotice_Callback(from, m_House)));
else
from.SendGump(new NoticeGump(1060637, 30720,
"This house is now public. Friends of the house may now have vendors working out of this building.",
0xF8C000, 320, 180, PublicPrivateNotice_Callback, m_House));
0xF8C000, 320, 180, () => PublicPrivateNotice_Callback(from, m_House)));
Region r = m_House.Region;
List<Mobile> list = r.GetMobiles();
@ -1122,7 +1104,7 @@ namespace Server.Gumps
{
// You cannot perform this action while you still have vendors rented out in this house.
from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180,
CustomizeNotice_Callback, m_House));
() => CustomizeNotice_Callback(from, m_House)));
}
else
{
@ -1130,7 +1112,7 @@ namespace Server.Gumps
if (e != null)
from.SendGump(new WarningGump(1060635, 30720, 1060013, 32512, 420, 280,
ConvertHouse_Callback, m_House));
okay => ConvertHouse_Callback(from, okay, m_House)));
}
}
@ -1142,13 +1124,13 @@ namespace Server.Gumps
{
if (m_House.HasRentedVendors)
from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180,
CustomizeNotice_Callback, m_House));
() => CustomizeNotice_Callback(from, m_House)));
#region Mondain's Legacy
else if (m_House.HasAddonContainers)
from.SendGump(new NoticeGump(1060637, 30720, 1074863, 32512, 320, 180,
CustomizeNotice_Callback, m_House));
() => CustomizeNotice_Callback(from, m_House)));
#endregion
@ -1239,7 +1221,7 @@ namespace Server.Gumps
}
else
{
from.CloseGump(typeof(HouseDemolishGump));
from.CloseGump<HouseDemolishGump>();
from.SendGump(new HouseDemolishGump(from, m_House));
}
}
@ -1436,13 +1418,13 @@ namespace Server.Gumps
}
}
private ArrayList Wrap(string value)
private List<string> Wrap(string value)
{
if (value == null || (value = value.Trim()).Length <= 0)
return null;
string[] values = value.Split(' ');
ArrayList list = new ArrayList();
List<string> list = new List<string>();
string current = "";
for (int i = 0; i < values.Length; ++i)

View file

@ -2,18 +2,16 @@ using Server.Network;
namespace Server.Gumps
{
public delegate void NoticeGumpCallback(Mobile from, object state);
public delegate void NoticeGumpCallback();
public class NoticeGump : Gump
{
private NoticeGumpCallback m_Callback;
private object m_State;
public NoticeGump(int header, int headerColor, object content, int contentColor, int width, int height,
NoticeGumpCallback callback, object state) : base((640 - width) / 2, (480 - height) / 2)
NoticeGumpCallback callback = null) : base((640 - width) / 2, (480 - height) / 2)
{
m_Callback = callback;
m_State = state;
Closable = false;
@ -43,7 +41,7 @@ namespace Server.Gumps
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 1)
m_Callback?.Invoke(sender.Mobile, m_State);
m_Callback?.Invoke();
}
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Gumps
public PetResurrectGump(Mobile from, BaseCreature pet, double hitsScalar) : base(50, 50)
{
from.CloseGump(typeof(PetResurrectGump));
from.CloseGump<PetResurrectGump>();
m_Pet = pet;
m_HitsScalar = hitsScalar;
@ -54,8 +54,7 @@ namespace Server.Gumps
return;
}
if (m_Pet.Region != null && m_Pet.Region.IsPartOf("Khaldun")
) //TODO: Confirm for pets, as per Bandage's script.
if (m_Pet.Region?.IsPartOf("Khaldun") == true) //TODO: Confirm for pets, as per Bandage's script.
{
from.SendLocalizedMessage(
1010395); // The veil of death in this area is too strong and resists thy efforts to restore life.

View file

@ -426,7 +426,7 @@ namespace Server.Gumps
m_Vendor = v;
int x, y;
from.CloseGump(typeof(PlayerVendorCustomizeGump));
from.CloseGump<PlayerVendorCustomizeGump>();
AddPage(0);
AddBackground(0, 0, 585, 393, 5054);

View file

@ -1,6 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Server.Commands.Generic;
using Server.Network;
@ -125,7 +125,7 @@ namespace Server.Gumps
private static Type typeofCPA = typeof(CPA);
private static Type typeofObject = typeof(object);
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -162,7 +162,7 @@ namespace Server.Gumps
Initialize(0);
}
public PropertiesGump(Mobile mobile, object o, Stack<StackEntry> stack, ArrayList list, int page) : base(GumpOffsetX,
public PropertiesGump(Mobile mobile, object o, Stack<StackEntry> stack, List<object> list, int page) : base(GumpOffsetX,
GumpOffsetY)
{
m_Mobile = mobile;
@ -385,7 +385,7 @@ namespace Server.Gumps
else if (IsType(type, typeofMap))
{
from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List,
Map.GetMapNames(), Map.GetMapValues()));
Map.GetMapNames(), Map.GetMapValues().ToArray<object>()));
}
else if (IsType(type, typeofSkills) && m_Object is Mobile mobile)
{
@ -513,30 +513,29 @@ namespace Server.Gumps
return o.ToString();
}
private ArrayList BuildList()
private List<object> BuildList()
{
ArrayList list = new ArrayList();
List<object> list = new List<object>();
if (m_Type == null)
return list;
PropertyInfo[] props = m_Type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
ArrayList groups = GetGroups(m_Type, props);
List<KeyValuePair<Type, List<PropertyInfo>>> groups = GetGroups(m_Type, props);
for (int i = 0; i < groups.Count; ++i)
{
DictionaryEntry de = (DictionaryEntry)groups[i];
ArrayList groupList = (ArrayList)de.Value;
KeyValuePair<Type, List<PropertyInfo>> kvp = groups[i];
if (!HasAttribute((Type)de.Key, typeofNoSort, false))
groupList.Sort(PropertySorter.Instance);
if (!HasAttribute(kvp.Key, typeofNoSort, false))
kvp.Value.Sort(PropertySorter.Instance);
if (i != 0)
list.Add(null);
list.Add(de.Key);
list.AddRange(groupList);
list.Add(kvp.Key);
list.AddRange(kvp.Value);
}
return list;
@ -551,9 +550,9 @@ namespace Server.Gumps
return null;
}
private ArrayList GetGroups(Type objectType, PropertyInfo[] props)
private List<KeyValuePair<Type, List<PropertyInfo>>> GetGroups(Type objectType, PropertyInfo[] props)
{
Hashtable groups = new Hashtable();
Dictionary<Type, List<PropertyInfo>> groups = new Dictionary<Type, List<PropertyInfo>>();
for (int i = 0; i < props.Length; ++i)
{
@ -569,32 +568,24 @@ namespace Server.Gumps
while (true)
{
Type baseType = type.BaseType;
Type baseType = type?.BaseType;
if (baseType == null || baseType == typeofObject)
break;
if (baseType.GetProperty(prop.Name, prop.PropertyType) != null)
type = baseType;
else
if (baseType == typeofObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null)
break;
type = baseType;
}
ArrayList list = (ArrayList)groups[type];
if (list == null)
groups[type] = list = new ArrayList();
list.Add(prop);
if (type != null && !groups.ContainsKey(type))
groups[type] = new List<PropertyInfo>{ prop };
}
}
}
ArrayList sorted = new ArrayList(groups);
List<KeyValuePair<Type, List<PropertyInfo>>> list = groups.ToList();
list.Sort(new GroupComparer(objectType));
sorted.Sort(new GroupComparer(objectType));
return sorted;
return list;
}
public static object GetObjectFromString(Type t, string s)
@ -652,7 +643,7 @@ namespace Server.Gumps
return o.ToString();
}
private class PropertySorter : IComparer
private class PropertySorter : IComparer<PropertyInfo>
{
public static readonly PropertySorter Instance = new PropertySorter();
@ -660,28 +651,19 @@ namespace Server.Gumps
{
}
public int Compare(object x, object y)
public int Compare(PropertyInfo x, PropertyInfo y)
{
if (x == null && y == null)
return 0;
if (x == null)
return -1;
if (y == null)
return 1;
PropertyInfo a = x as PropertyInfo;
PropertyInfo b = y as PropertyInfo;
if (a == null || b == null)
throw new ArgumentException();
return a.Name.CompareTo(b.Name);
return y == null ? 1 : x.Name.CompareTo(x.Name);
}
}
private class GroupComparer : IComparer
{
private static Type typeofObject = typeof(object);
private class GroupComparer : IComparer<KeyValuePair<Type, List<PropertyInfo>>>
{
private Type m_Start;
public GroupComparer(Type start)
@ -689,22 +671,9 @@ namespace Server.Gumps
m_Start = start;
}
public int Compare(object x, object y)
public int Compare(KeyValuePair<Type, List<PropertyInfo>> x, KeyValuePair<Type, List<PropertyInfo>> y)
{
if (x == null && y == null)
return 0;
if (x == null)
return -1;
if (y == null)
return 1;
if (!(x is DictionaryEntry) || !(y is DictionaryEntry))
throw new ArgumentException();
DictionaryEntry de1 = (DictionaryEntry)x;
DictionaryEntry de2 = (DictionaryEntry)y;
return GetDistance((Type)de1.Key).CompareTo(GetDistance((Type)de2.Key));
return GetDistance(x.Key).CompareTo(GetDistance(y.Key));
}
private int GetDistance(Type type)

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -13,24 +12,19 @@ namespace Server.Gumps
private const int SelectedColor32 = 0x8080FF;
private const int TextColor32 = 0xFFFFFF;
private static ArrayList m_Monster, m_Animal, m_Sea, m_Human;
private ArrayList m_List;
private static List<InternalEntry> m_Monster, m_Animal, m_Sea, m_Human;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private ArrayList m_OurList;
private List<InternalEntry> m_OurList;
private int m_OurPage;
private ModelBodyType m_OurType;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
: this(prop, mobile, o, stack, page, list, 0, null, ModelBodyType.Invalid)
{
}
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list,
int ourPage, ArrayList ourList, ModelBodyType ourType)
public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list,
int ourPage = 0, List<InternalEntry> ourList = null, ModelBodyType ourType = ModelBodyType.Invalid)
: base(20, 30)
{
m_Property = prop;
@ -73,7 +67,7 @@ namespace Server.Gumps
{
for (int i = 0, index = ourPage * 12; i < 12 && index >= 0 && index < ourList.Count; ++i, ++index)
{
InternalEntry entry = (InternalEntry)ourList[index];
InternalEntry entry = ourList[index];
int itemID = entry.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF];
@ -134,7 +128,7 @@ namespace Server.Gumps
LoadLists();
ModelBodyType type;
ArrayList list;
List<InternalEntry> list;
switch (index)
{
@ -181,7 +175,7 @@ namespace Server.Gumps
{
try
{
InternalEntry entry = (InternalEntry)m_OurList[index];
InternalEntry entry = m_OurList[index];
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, entry.Body.ToString());
m_Property.SetValue(m_Object, entry.Body, null);
@ -201,10 +195,10 @@ namespace Server.Gumps
private static void LoadLists()
{
m_Monster = new ArrayList();
m_Animal = new ArrayList();
m_Sea = new ArrayList();
m_Human = new ArrayList();
m_Monster = new List<InternalEntry>();
m_Animal = new List<InternalEntry>();
m_Sea = new List<InternalEntry>();
m_Human = new List<InternalEntry>();
List<BodyEntry> entries = Docs.LoadBodies();
@ -216,10 +210,11 @@ namespace Server.Gumps
if (((Body)bodyID).IsEmpty)
continue;
ArrayList list = null;
List<InternalEntry> list;
switch (oldEntry.BodyType)
{
default: continue;
case ModelBodyType.Monsters:
list = m_Monster;
break;
@ -234,9 +229,6 @@ namespace Server.Gumps
break;
}
if (list == null)
continue;
int itemID = ShrinkTable.Lookup(bodyID, -1);
if (itemID != -1)
@ -249,7 +241,7 @@ namespace Server.Gumps
m_Human.Sort();
}
private class InternalEntry : IComparable
public class InternalEntry : IComparable<InternalEntry>
{
private static string[] m_GroupNames =
{
@ -296,10 +288,8 @@ namespace Server.Gumps
public string DisplayName{ get; }
public int CompareTo(object obj)
public int CompareTo(InternalEntry comp)
{
InternalEntry comp = (InternalEntry)obj;
int v = Name.CompareTo(comp.Name);
if (v == 0)

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -12,7 +11,7 @@ namespace Server.Gumps
private string[] m_Names;
public SetCustomEnumGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
ArrayList list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null)
List<object> list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null)
{
m_Names = names;
}
@ -26,7 +25,7 @@ namespace Server.Gumps
{
MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) });
string result = "";
string result;
if (info != null)
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
@ -34,6 +33,8 @@ namespace Server.Gumps
else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
Enum.Parse(m_Property.PropertyType, m_Names[index], false), true);
else
result = "";
m_Mobile.SendMessage(result);

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -50,14 +49,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list) : base(
public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list) : base(
GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -246,7 +245,7 @@ namespace Server.Gumps
private class InternalPicker : HuePicker
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -254,7 +253,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalPicker(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(((IHued)o).HuedItemID)
List<object> list) : base(((IHued)o).HuedItemID)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -56,17 +55,17 @@ namespace Server.Gumps
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
protected ArrayList m_List;
protected List<object> m_List;
protected Mobile m_Mobile;
protected object m_Object;
protected int m_Page;
protected PropertyInfo m_Property;
protected Stack<StackEntry> m_Stack;
protected object[] m_Values;
private object[] m_Values;
public SetListOptionGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int propspage,
ArrayList list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY)
List<object> list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -52,7 +51,7 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -61,7 +60,7 @@ namespace Server.Gumps
private Type m_Type;
public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list) : base(GumpOffsetX, GumpOffsetY)
List<object> list) : base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
m_Mobile = mobile;
@ -204,7 +203,7 @@ namespace Server.Gumps
private class InternalPrompt : Prompt
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -213,7 +212,7 @@ namespace Server.Gumps
private Type m_Type;
public InternalPrompt(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list)
List<object> list)
{
m_Property = prop;
m_Mobile = mobile;
@ -233,7 +232,7 @@ namespace Server.Gumps
{
try
{
int serial = Utility.ToInt32(text);
uint serial = Utility.ToUInt32(text);
IEntity toSet = World.FindEntity(serial);

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -10,7 +9,7 @@ namespace Server.Gumps
{
public class SetObjectTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -19,7 +18,7 @@ namespace Server.Gumps
private Type m_Type;
public SetObjectTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, Type type, int page,
ArrayList list) : base(-1, false, TargetFlags.None)
List<object> list) : base(-1, false, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;
@ -37,8 +36,8 @@ namespace Server.Gumps
if (m_Type == typeof(Type))
targeted = targeted.GetType();
else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) &&
targeted is AddonComponent)
targeted = ((AddonComponent)targeted).Addon;
targeted is AddonComponent addonComponent)
targeted = addonComponent.Addon;
if (m_Type.IsInstanceOfType(targeted))
{

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -51,14 +50,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -190,7 +189,7 @@ namespace Server.Gumps
private class InternalTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -198,7 +197,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(-1, true, TargetFlags.None)
List<object> list) : base(-1, true, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,4 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -51,14 +50,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -197,7 +196,7 @@ namespace Server.Gumps
private class InternalTarget : Target
{
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
@ -205,7 +204,7 @@ namespace Server.Gumps
private Stack<StackEntry> m_Stack;
public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page,
ArrayList list) : base(-1, true, TargetFlags.None)
List<object> list) : base(-1, true, TargetFlags.None)
{
m_Property = prop;
m_Mobile = mobile;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server.Commands;
@ -50,14 +49,14 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ArrayList m_List;
private List<object> m_List;
private Mobile m_Mobile;
private object m_Object;
private int m_Page;
private PropertyInfo m_Property;
private Stack<StackEntry> m_Stack;
public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, ArrayList list)
public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack<StackEntry> stack, int page, List<object> list)
: base(GumpOffsetX, GumpOffsetY)
{
m_Property = prop;
@ -127,7 +126,7 @@ namespace Server.Gumps
{
bool successfulParse = false;
if (h != null && m != null && s != null)
successfulParse = TimeSpan.TryParse(h.Text + ":" + m.Text + ":" + s.Text, out toSet);
successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet);
else
toSet = TimeSpan.Zero;
@ -148,6 +147,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;
@ -169,6 +169,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;
@ -190,6 +191,7 @@ namespace Server.Gumps
}
catch
{
// ignored
}
toSet = TimeSpan.Zero;

View file

@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Multis;
using Server.Network;
@ -7,12 +8,12 @@ namespace Server.Gumps
public class ReclaimVendorGump : Gump
{
private BaseHouse m_House;
private ArrayList m_Vendors;
private List<Mobile> m_Vendors;
public ReclaimVendorGump(BaseHouse house) : base(50, 50)
{
m_House = house;
m_Vendors = new ArrayList(house.InternalizedVendors);
m_Vendors = house.InternalizedVendors.ToList();
AddBackground(0, 0, 170, 50 + m_Vendors.Count * 20, 0x13BE);
@ -23,7 +24,7 @@ namespace Server.Gumps
for (int i = 0; i < m_Vendors.Count; i++)
{
Mobile m = (Mobile)m_Vendors[i];
Mobile m = m_Vendors[i];
int y = 40 + i * 20;
@ -45,7 +46,7 @@ namespace Server.Gumps
if (index < 0 || index >= m_Vendors.Count)
return;
Mobile mob = (Mobile)m_Vendors[index];
Mobile mob = m_Vendors[index];
if (!m_House.InternalizedVendors.Contains(mob))
return;
@ -56,8 +57,7 @@ namespace Server.Gumps
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor(from.Location, from.Map, out vendor, out contract);
BaseHouse.IsThereVendor(from.Location, from.Map, out bool vendor, out bool contract);
if (vendor)
{

View file

@ -131,22 +131,15 @@ namespace Server.Gumps
AddHtmlLocalized( 400, 300, 300, 50, 1046363, false, false ); // No
}
public static void ReportedListExpiry_Callback( object state )
public static void ReportedListExpiry_Callback( PlayerMobile from, Mobile killer )
{
object[] states = (object[])state;
PlayerMobile from = (PlayerMobile)states[0];
Mobile killer = (Mobile)states[1];
if (from.RecentlyReported.Contains(killer))
{
from.RecentlyReported.Remove(killer);
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
PlayerMobile from = (PlayerMobile)state.Mobile;
switch ( info.ButtonID )
{
@ -160,8 +153,8 @@ namespace Server.Gumps
if (Core.SE)
{
((PlayerMobile)from).RecentlyReported.Add(killer);
Timer.DelayCall(TimeSpan.FromMinutes(10), new TimerStateCallback(ReportedListExpiry_Callback), new object[] { from, killer });
from.RecentlyReported.Add(killer);
Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer));
}
if (killer is PlayerMobile pk)

View file

@ -140,7 +140,7 @@ namespace Server.Gumps
{
Mobile from = state.Mobile;
from.CloseGump( typeof( ResurrectGump ) );
from.CloseGump<ResurrectGump>();
if ( info.ButtonID == 1 || info.ButtonID == 2 )
{

View file

@ -251,7 +251,7 @@ namespace Server.Gumps
{
if (Book.CurCharges <= 0)
{
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
from.SendGump(new RunebookGump(from, Book));
from.SendLocalizedMessage(502412); // There are no charges left on that item.
@ -284,7 +284,7 @@ namespace Server.Gumps
{
Book.DropRune(from, e, index);
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
if (!Core.ML)
from.SendGump(new RunebookGump(from, Book));
}
@ -304,7 +304,7 @@ namespace Server.Gumps
{
Book.Default = e;
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
from.SendGump(new RunebookGump(from, Book));
from.SendLocalizedMessage(502417); // New default location set.
@ -329,7 +329,7 @@ namespace Server.Gumps
}
Book.OnTravel();
new RecallSpell(from, null, e, null).Cast();
new RecallSpell(from, null, e).Cast();
}
else
{
@ -387,7 +387,7 @@ namespace Server.Gumps
}
Book.OnTravel();
new SacredJourneySpell(from, null, e, null).Cast();
new SacredJourneySpell(from, null, e).Cast();
}
else
{
@ -426,7 +426,7 @@ namespace Server.Gumps
{
m_Book.Description = Utility.FixHtml(text.Trim());
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
from.SendGump(new RunebookGump(from, m_Book));
from.SendMessage("The book's title has been changed.");
@ -445,7 +445,7 @@ namespace Server.Gumps
if (!m_Book.Deleted && from.InRange(m_Book.GetWorldLocation(), Core.ML ? 3 : 1))
{
from.CloseGump(typeof(RunebookGump));
from.CloseGump<RunebookGump>();
from.SendGump(new RunebookGump(from, m_Book));
}
}

View file

@ -36,7 +36,7 @@ namespace Server.Gumps
{
Closable = true;
Disposable = true;
Dragable = true;
Draggable = true;
Resizable = false;
m_ToTEras = Enum.GetValues(typeof(TreasuresOfTokunoEra)).Length - 1;
@ -128,7 +128,7 @@ namespace Server.Gumps
ToTAdminGump tg;
tg = new ToTAdminGump();
e.Mobile.CloseGump(typeof(ToTAdminGump));
e.Mobile.CloseGump<ToTAdminGump>();
e.Mobile.SendGump(tg);
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Mobiles;
using Server.Multis;
using Server.Network;
@ -9,12 +10,12 @@ namespace Server.Gumps
public class VendorInventoryGump : Gump
{
private BaseHouse m_House;
private ArrayList m_Inventories;
private List<VendorInventory> m_Inventories;
public VendorInventoryGump(BaseHouse house, Mobile from) : base(50, 50)
{
m_House = house;
m_Inventories = new ArrayList(house.VendorInventories);
m_Inventories = house.VendorInventories.ToList();
AddBackground(0, 0, 420, 50 + 20 * m_Inventories.Count, 0x13BE);
@ -26,7 +27,7 @@ namespace Server.Gumps
for (int i = 0; i < m_Inventories.Count; i++)
{
VendorInventory inventory = (VendorInventory)m_Inventories[i];
VendorInventory inventory = m_Inventories[i];
int y = 40 + 20 * i;
@ -64,7 +65,7 @@ namespace Server.Gumps
if (index < 0 || index >= m_Inventories.Count)
return;
VendorInventory inventory = (VendorInventory)m_Inventories[index];
VendorInventory inventory = m_Inventories[index];
if (inventory.Owner != from || !m_House.VendorInventories.Contains(inventory))
return;

View file

@ -23,7 +23,7 @@ namespace Server.Gumps
m_List = list;
m_Selection = sel;
from.CloseGump(typeof(ViewHousesGump));
from.CloseGump<ViewHousesGump>();
AddPage(0);

View file

@ -1,25 +1,14 @@
using System;
namespace Server.Gumps
{
public delegate void WarningGumpCallback( Mobile from, bool okay, object state );
public delegate void WarningGumpCallback( bool okay );
public class WarningGump : Gump
{
private WarningGumpCallback m_Callback;
private object m_State;
private bool m_CancelButton;
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state )
: this( header, headerColor, content, contentColor, width, height, callback, state, true )
{
}
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state, bool cancelButton ) : base( (640 - width) / 2, (480 - height) / 2 )
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback = null, bool cancelButton = true) : base( (640 - width) / 2, (480 - height) / 2 )
{
m_Callback = callback;
m_State = state;
m_CancelButton = cancelButton;
Closable = false;
@ -45,7 +34,7 @@ namespace Server.Gumps
AddButton( 10, height - 30, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, height - 30, 170, 20, 1011036, 32767, false, false ); // OKAY
if ( m_CancelButton )
if ( cancelButton )
{
AddButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 32767, false, false ); // CANCEL
@ -58,9 +47,9 @@ namespace Server.Gumps
return;
if ( info.ButtonID == 1)
m_Callback( sender.Mobile, true, m_State );
m_Callback( true );
else
m_Callback.Invoke( sender.Mobile, false, m_State );
m_Callback.Invoke( false );
}
}
}

View file

@ -104,7 +104,7 @@ namespace Server.Gumps
public WhoGump( Mobile owner, List<Mobile> list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( WhoGump ) );
owner.CloseGump<WhoGump>();
m_Owner = owner;
m_Mobiles = list;