fix(cleanup): Consolidate the duplicate code in Properties, PropsGump, and PropsConfig (#540)
This commit is contained in:
parent
98ce65083a
commit
dd2933a9ef
21 changed files with 335 additions and 761 deletions
|
|
@ -1,13 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server.Commands.Generic
|
||||
{
|
||||
public sealed class ObjectConditional
|
||||
{
|
||||
private static readonly Type typeofItem = typeof(Item);
|
||||
private static readonly Type typeofMobile = typeof(Mobile);
|
||||
|
||||
public static readonly ObjectConditional Empty = new(null, null);
|
||||
|
||||
private readonly ICondition[][] m_Conditions;
|
||||
|
|
@ -22,9 +21,9 @@ namespace Server.Commands.Generic
|
|||
|
||||
public Type Type { get; }
|
||||
|
||||
public bool IsItem => Type == null || Type == typeofItem || Type.IsSubclassOf(typeofItem);
|
||||
public bool IsItem => Type == null || Type.IsAssignableTo(OfItem);
|
||||
|
||||
public bool IsMobile => Type == null || Type == typeofMobile || Type.IsSubclassOf(typeofMobile);
|
||||
public bool IsMobile => Type == null || Type.IsAssignableTo(OfMobile);
|
||||
|
||||
public bool HasCompiled => m_Conditionals != null;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,39 +6,15 @@ using System.Text;
|
|||
using Server.Items;
|
||||
using CPA = Server.CommandPropertyAttribute;
|
||||
|
||||
using static Server.Attributes;
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server.Commands
|
||||
{
|
||||
public static class Add
|
||||
{
|
||||
private static readonly Type m_EntityType = typeof(IEntity);
|
||||
|
||||
private static readonly Type m_ConstructibleType = typeof(ConstructibleAttribute);
|
||||
|
||||
private static readonly Type m_EnumType = typeof(Enum);
|
||||
|
||||
private static readonly Type m_TypeType = typeof(Type);
|
||||
|
||||
private static readonly Type m_ParsableType = typeof(ParsableAttribute);
|
||||
|
||||
private static readonly Type[] m_ParseTypes = { typeof(string) };
|
||||
private static readonly object[] m_ParseArgs = new object[1];
|
||||
|
||||
private static readonly Type[] m_SignedNumerics =
|
||||
{
|
||||
typeof(long),
|
||||
typeof(int),
|
||||
typeof(short),
|
||||
typeof(sbyte)
|
||||
};
|
||||
|
||||
private static readonly Type[] m_UnsignedNumerics =
|
||||
{
|
||||
typeof(ulong),
|
||||
typeof(uint),
|
||||
typeof(ushort),
|
||||
typeof(byte)
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Tile", AccessLevel.GameMaster, Tile_OnCommand);
|
||||
|
|
@ -193,7 +169,7 @@ namespace Server.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
var attr = Properties.GetCPA(thisProp);
|
||||
var attr = GetCPA(thisProp);
|
||||
|
||||
if (attr == null)
|
||||
{
|
||||
|
|
@ -759,56 +735,21 @@ namespace Server.Commands
|
|||
InternalAvg_OnCommand(e, true);
|
||||
}
|
||||
|
||||
public static bool IsEntity(Type t) => m_EntityType.IsAssignableFrom(t);
|
||||
public static bool IsEnum(Type type) => type.IsSubclassOf(OfEnum);
|
||||
|
||||
public static bool IsConstructible(ConstructorInfo ctor, AccessLevel accessLevel)
|
||||
{
|
||||
var attrs = ctor.GetCustomAttributes(m_ConstructibleType, false);
|
||||
public static bool IsType(Type type) => type == OfType || type.IsSubclassOf(OfType);
|
||||
|
||||
return attrs.Length != 0 && accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel;
|
||||
}
|
||||
|
||||
public static bool IsEnum(Type type) => type.IsSubclassOf(m_EnumType);
|
||||
|
||||
public static bool IsType(Type type) => type == m_TypeType || type.IsSubclassOf(m_TypeType);
|
||||
|
||||
public static bool IsParsable(Type type) => type.IsDefined(m_ParsableType, false);
|
||||
public static bool IsParsable(Type type) => type.IsDefined(OfParsable, false);
|
||||
|
||||
public static object ParseParsable(Type type, string value)
|
||||
{
|
||||
var method = type.GetMethod("Parse", m_ParseTypes);
|
||||
var method = type.GetMethod("Parse", ParseTypes);
|
||||
|
||||
m_ParseArgs[0] = value;
|
||||
|
||||
return method?.Invoke(null, m_ParseArgs);
|
||||
}
|
||||
|
||||
public static bool IsSignedNumeric(Type type)
|
||||
{
|
||||
for (var i = 0; i < m_SignedNumerics.Length; ++i)
|
||||
{
|
||||
if (type == m_SignedNumerics[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsUnsignedNumeric(Type type)
|
||||
{
|
||||
for (var i = 0; i < m_UnsignedNumerics.Length; ++i)
|
||||
{
|
||||
if (type == m_UnsignedNumerics[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private enum TileZType
|
||||
{
|
||||
Start,
|
||||
|
|
|
|||
|
|
@ -2,55 +2,19 @@ using System;
|
|||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class CategorizedAddGump : Gump
|
||||
{
|
||||
public static bool OldStyle = PropsConfig.OldStyle;
|
||||
private static readonly int EntryHeight = PropsConfig.EntryHeight + 4;
|
||||
|
||||
public static readonly int EntryHeight = 24; // PropsConfig.EntryHeight;
|
||||
private static readonly int SetOffsetY = PropsConfig.SetOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
private static readonly int PrevOffsetY = PropsConfig.PrevOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX,
|
||||
SetOffsetY = PropsConfig.SetOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX,
|
||||
PrevOffsetY = PropsConfig.PrevOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX,
|
||||
NextOffsetY = PropsConfig.NextOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
private static readonly bool PrevLabel = false;
|
||||
private static readonly bool NextLabel = false;
|
||||
private static readonly int NextOffsetY = PropsConfig.NextOffsetY + (EntryHeight - 20) / 2 / 2;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
|
@ -62,10 +26,9 @@ namespace Server.Gumps
|
|||
private static readonly int EntryCount = 15;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + (EntryHeight + OffsetSize) * (EntryCount + 1);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
|
||||
private readonly CAGCategory m_Category;
|
||||
|
||||
private readonly Mobile m_Owner;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ using Server.Gumps;
|
|||
using Server.Targeting;
|
||||
using CPA = Server.CommandPropertyAttribute;
|
||||
|
||||
using static Server.Attributes;
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server.Commands
|
||||
{
|
||||
[Flags]
|
||||
|
|
@ -18,32 +21,8 @@ namespace Server.Commands
|
|||
|
||||
public static class Properties
|
||||
{
|
||||
private static readonly Type typeofCPA = typeof(CPA);
|
||||
|
||||
private static readonly Type typeofSerial = typeof(Serial);
|
||||
|
||||
private static readonly Type typeofType = typeof(Type);
|
||||
|
||||
private static readonly Type typeofChar = typeof(char);
|
||||
|
||||
private static readonly Type typeofString = typeof(string);
|
||||
|
||||
private static readonly Type typeofText = typeof(TextDefinition);
|
||||
|
||||
private static readonly Type typeofTimeSpan = typeof(TimeSpan);
|
||||
private static readonly Type typeofParsable = typeof(ParsableAttribute);
|
||||
|
||||
private static readonly Type[] m_ParseTypes = { typeof(string) };
|
||||
private static readonly object[] m_ParseParams = new object[1];
|
||||
|
||||
private static readonly Type[] m_NumericTypes =
|
||||
{
|
||||
typeof(byte), typeof(sbyte),
|
||||
typeof(short), typeof(ushort),
|
||||
typeof(int), typeof(uint),
|
||||
typeof(long), typeof(ulong)
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Props", AccessLevel.Counselor, Props_OnCommand);
|
||||
|
|
@ -78,18 +57,6 @@ namespace Server.Commands
|
|||
|
||||
private static bool CIEqual(string l, string r) => l.InsensitiveEquals(r);
|
||||
|
||||
public static CPA GetCPA(PropertyInfo p)
|
||||
{
|
||||
var attrs = p.GetCustomAttributes(typeofCPA, false);
|
||||
|
||||
if (attrs.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return attrs[0] as CPA;
|
||||
}
|
||||
|
||||
public static PropertyInfo[] GetPropertyInfoChain(
|
||||
Mobile from, Type type, string propertyString,
|
||||
PropertyAccess endAccess, ref string failReason
|
||||
|
|
@ -401,31 +368,15 @@ namespace Server.Commands
|
|||
return p == null ? failReason : InternalSetValue(from, logObject, o, p, name, value, true);
|
||||
}
|
||||
|
||||
private static bool IsSerial(Type t) => t == typeofSerial;
|
||||
|
||||
private static bool IsType(Type t) => t == typeofType;
|
||||
|
||||
private static bool IsChar(Type t) => t == typeofChar;
|
||||
|
||||
private static bool IsString(Type t) => t == typeofString;
|
||||
|
||||
private static bool IsText(Type t) => t == typeofText;
|
||||
|
||||
private static bool IsEnum(Type t) => t.IsEnum;
|
||||
|
||||
private static bool IsParsable(Type t) => t == typeofTimeSpan || t.IsDefined(typeofParsable, false);
|
||||
|
||||
private static object Parse(object o, Type t, string value)
|
||||
{
|
||||
var method = t.GetMethod("Parse", m_ParseTypes);
|
||||
var method = t.GetMethod("Parse", ParseTypes);
|
||||
|
||||
m_ParseParams[0] = value;
|
||||
|
||||
return method?.Invoke(o, m_ParseParams);
|
||||
}
|
||||
|
||||
private static bool IsNumeric(Type t) => Array.IndexOf(m_NumericTypes, t) >= 0;
|
||||
|
||||
public static string ConstructFromString(Type type, object obj, string value, ref object constructed)
|
||||
{
|
||||
object toSet;
|
||||
|
|
@ -433,7 +384,7 @@ namespace Server.Commands
|
|||
|
||||
if (isSerial) // mutate into int32
|
||||
{
|
||||
type = m_NumericTypes[4];
|
||||
type = OfInt;
|
||||
}
|
||||
|
||||
if (value == "(-null-)" && !type.IsValueType)
|
||||
|
|
@ -621,111 +572,6 @@ namespace Server.Commands
|
|||
|
||||
namespace Server
|
||||
{
|
||||
public abstract class PropertyException : Exception
|
||||
{
|
||||
protected Property m_Property;
|
||||
|
||||
public PropertyException(Property property, string message)
|
||||
: base(message) =>
|
||||
m_Property = property;
|
||||
|
||||
public Property Property => m_Property;
|
||||
}
|
||||
|
||||
public abstract class BindingException : PropertyException
|
||||
{
|
||||
public BindingException(Property property, string message)
|
||||
: base(property, message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NotYetBoundException : BindingException
|
||||
{
|
||||
public NotYetBoundException(Property property)
|
||||
: base(property, "Property has not yet been bound.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AlreadyBoundException : BindingException
|
||||
{
|
||||
public AlreadyBoundException(Property property)
|
||||
: base(property, "Property has already been bound.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class UnknownPropertyException : BindingException
|
||||
{
|
||||
public UnknownPropertyException(Property property, string current)
|
||||
: base(property, $"Property '{current}' not found.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ReadOnlyException : BindingException
|
||||
{
|
||||
public ReadOnlyException(Property property)
|
||||
: base(property, "Property is read-only.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class WriteOnlyException : BindingException
|
||||
{
|
||||
public WriteOnlyException(Property property)
|
||||
: base(property, "Property is write-only.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AccessException : PropertyException
|
||||
{
|
||||
public AccessException(Property property, string message)
|
||||
: base(property, message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class InternalAccessException : AccessException
|
||||
{
|
||||
public InternalAccessException(Property property)
|
||||
: base(property, "Property is internal.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ClearanceException : AccessException
|
||||
{
|
||||
public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
|
||||
: base(
|
||||
property,
|
||||
$"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property."
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public AccessLevel PlayerAccess { get; set; }
|
||||
public AccessLevel NeededAccess { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ReadAccessException : ClearanceException
|
||||
{
|
||||
public ReadAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
|
||||
: base(property, playerAccess, neededAccess, "read")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class WriteAccessException : ClearanceException
|
||||
{
|
||||
public WriteAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
|
||||
: base(property, playerAccess, neededAccess, "write")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Property
|
||||
{
|
||||
private PropertyInfo[] m_Chain;
|
||||
|
|
@ -788,7 +634,7 @@ namespace Server
|
|||
access |= PropertyAccess.Read;
|
||||
}
|
||||
|
||||
var security = Properties.GetCPA(prop);
|
||||
var security = GetCPA(prop);
|
||||
|
||||
if (security == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ using Server.Mobiles;
|
|||
using Server.Utilities;
|
||||
using CPA = Server.CommandPropertyAttribute;
|
||||
|
||||
using static Server.Attributes;
|
||||
|
||||
namespace Server.Engines.Spawners
|
||||
{
|
||||
public abstract class BaseSpawner : Item, ISpawner
|
||||
|
|
@ -529,7 +531,7 @@ namespace Server.Engines.Spawners
|
|||
return null;
|
||||
}
|
||||
|
||||
var attr = Properties.GetCPA(thisProp);
|
||||
var attr = GetCPA(thisProp);
|
||||
|
||||
if (attr == null || attr.WriteLevel > AccessLevel.Developer || !thisProp.CanWrite || attr.ReadOnly)
|
||||
{
|
||||
|
|
@ -600,7 +602,7 @@ namespace Server.Engines.Spawners
|
|||
if (paramargs.Length == 0)
|
||||
{
|
||||
entity = type.CreateInstance<IEntity>(
|
||||
ci => Add.IsConstructible(ci, AccessLevel.Developer)
|
||||
ci => IsConstructible(ci, AccessLevel.Developer)
|
||||
);
|
||||
}
|
||||
else
|
||||
|
|
@ -611,7 +613,7 @@ namespace Server.Engines.Spawners
|
|||
{
|
||||
var ctor = ctors[i];
|
||||
|
||||
if (Add.IsConstructible(ctor, AccessLevel.Developer))
|
||||
if (IsConstructible(ctor, AccessLevel.Developer))
|
||||
{
|
||||
var paramList = ctor.GetParameters();
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,11 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server.Engines.Spawners
|
||||
{
|
||||
public class EditSpawnCommand : BaseCommand
|
||||
|
|
@ -59,7 +60,7 @@ namespace Server.Engines.Spawners
|
|||
|
||||
var type = AssemblyHandler.FindTypeByName(name);
|
||||
|
||||
if (!Add.IsEntity(type))
|
||||
if (!IsEntity(type))
|
||||
{
|
||||
LogFailure("No type with that name was found.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Gumps;
|
||||
using Server.Targeting;
|
||||
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server.Engines.Spawners
|
||||
{
|
||||
public class SpawnPropsCommand : BaseCommand
|
||||
|
|
@ -53,15 +54,14 @@ namespace Server.Engines.Spawners
|
|||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private List<object> _list;
|
||||
private readonly List<object> _list;
|
||||
|
||||
public InternalTarget(List<object> list) : base(-1, false, TargetFlags.None) =>
|
||||
_list = list;
|
||||
public InternalTarget(List<object> list) : base(-1, false, TargetFlags.None) => _list = list;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
var type = targeted.GetType();
|
||||
if (!Add.IsEntity(type))
|
||||
if (!IsEntity(type))
|
||||
{
|
||||
from.SendMessage("No type with that name was found.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class GoGump : Gump
|
||||
|
|
@ -12,43 +14,6 @@ namespace Server.Gumps
|
|||
private static LocationTree Tokuno;
|
||||
private static LocationTree TerMur;
|
||||
|
||||
public static bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly bool PrevLabel = false;
|
||||
private static readonly bool NextLabel = false;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
||||
|
|
@ -59,10 +24,9 @@ namespace Server.Gumps
|
|||
private static readonly int EntryCount = 15;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + (EntryHeight + OffsetSize) * (EntryCount + 1);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
|
||||
private readonly GoCategory m_Node;
|
||||
private readonly int m_Page;
|
||||
|
||||
|
|
|
|||
109
Projects/UOContent/Gumps/Props/Exceptions.cs
Normal file
109
Projects/UOContent/Gumps/Props/Exceptions.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public abstract class PropertyException : Exception
|
||||
{
|
||||
protected Property m_Property;
|
||||
|
||||
public PropertyException(Property property, string message)
|
||||
: base(message) =>
|
||||
m_Property = property;
|
||||
|
||||
public Property Property => m_Property;
|
||||
}
|
||||
|
||||
public abstract class BindingException : PropertyException
|
||||
{
|
||||
public BindingException(Property property, string message)
|
||||
: base(property, message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NotYetBoundException : BindingException
|
||||
{
|
||||
public NotYetBoundException(Property property)
|
||||
: base(property, "Property has not yet been bound.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AlreadyBoundException : BindingException
|
||||
{
|
||||
public AlreadyBoundException(Property property)
|
||||
: base(property, "Property has already been bound.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class UnknownPropertyException : BindingException
|
||||
{
|
||||
public UnknownPropertyException(Property property, string current)
|
||||
: base(property, $"Property '{current}' not found.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ReadOnlyException : BindingException
|
||||
{
|
||||
public ReadOnlyException(Property property)
|
||||
: base(property, "Property is read-only.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class WriteOnlyException : BindingException
|
||||
{
|
||||
public WriteOnlyException(Property property)
|
||||
: base(property, "Property is write-only.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class AccessException : PropertyException
|
||||
{
|
||||
public AccessException(Property property, string message)
|
||||
: base(property, message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class InternalAccessException : AccessException
|
||||
{
|
||||
public InternalAccessException(Property property)
|
||||
: base(property, "Property is internal.")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ClearanceException : AccessException
|
||||
{
|
||||
public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
|
||||
: base(
|
||||
property,
|
||||
$"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property."
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public AccessLevel PlayerAccess { get; set; }
|
||||
public AccessLevel NeededAccess { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ReadAccessException : ClearanceException
|
||||
{
|
||||
public ReadAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
|
||||
: base(property, playerAccess, neededAccess, "read")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class WriteAccessException : ClearanceException
|
||||
{
|
||||
public WriteAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
|
||||
: base(property, playerAccess, neededAccess, "write")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -39,5 +39,8 @@ namespace Server.Gumps
|
|||
public static readonly int EntryHeight = 20;
|
||||
public static readonly int BorderSize = 10;
|
||||
public static readonly int ApplySize = 30;
|
||||
|
||||
public static readonly bool PrevLabel = false;
|
||||
public static readonly bool NextLabel = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ using Server.Commands.Generic;
|
|||
using Server.Network;
|
||||
using CPA = Server.CommandPropertyAttribute;
|
||||
|
||||
using static Server.Types;
|
||||
using static Server.Attributes;
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class StackEntry
|
||||
|
|
@ -22,40 +26,6 @@ namespace Server.Gumps
|
|||
|
||||
public class PropertiesGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly bool PrevLabel = OldStyle;
|
||||
private static readonly bool NextLabel = OldStyle;
|
||||
private static readonly bool TypeLabel = !OldStyle;
|
||||
|
|
@ -76,56 +46,7 @@ namespace Server.Gumps
|
|||
private static readonly int TotalWidth =
|
||||
OffsetSize + NameWidth + OffsetSize + ValueWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
||||
private static readonly int MaxHeight = OffsetSize + (EntryHeight + OffsetSize) * (MaxEntriesPerPage + 1);
|
||||
|
||||
protected static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
protected static readonly int BackHeight = BorderSize + MaxHeight + BorderSize;
|
||||
|
||||
public static readonly string[] BoolNames = { "True", "False" };
|
||||
public static readonly object[] BoolValues = { true, false };
|
||||
|
||||
public static readonly string[] PoisonNames = { "None", "Lesser", "Regular", "Greater", "Deadly", "Lethal" };
|
||||
|
||||
public static readonly object[] PoisonValues =
|
||||
{ null, Poison.Lesser, Poison.Regular, Poison.Greater, Poison.Deadly, Poison.Lethal };
|
||||
|
||||
public static readonly Type TypeofMobile = typeof(Mobile);
|
||||
public static readonly Type TypeofItem = typeof(Item);
|
||||
public static readonly Type TypeofType = typeof(Type);
|
||||
public static readonly Type TypeofPoint3D = typeof(Point3D);
|
||||
public static readonly Type TypeofPoint2D = typeof(Point2D);
|
||||
public static readonly Type TypeofTimeSpan = typeof(TimeSpan);
|
||||
public static readonly Type TypeofCustomEnum = typeof(CustomEnumAttribute);
|
||||
public static readonly Type TypeofEnum = typeof(Enum);
|
||||
public static readonly Type TypeofBool = typeof(bool);
|
||||
public static readonly Type TypeofString = typeof(string);
|
||||
public static readonly Type TypeofText = typeof(TextDefinition);
|
||||
public static readonly Type TypeofPoison = typeof(Poison);
|
||||
public static readonly Type TypeofMap = typeof(Map);
|
||||
public static readonly Type TypeofSkills = typeof(Skills);
|
||||
public static readonly Type TypeofPropertyObject = typeof(PropertyObjectAttribute);
|
||||
public static readonly Type TypeofNoSort = typeof(NoSortAttribute);
|
||||
|
||||
public static readonly Type[] DecimalTypes =
|
||||
{
|
||||
typeof(float),
|
||||
typeof(double)
|
||||
};
|
||||
|
||||
public static readonly Type[] NumericTypes =
|
||||
{
|
||||
typeof(byte),
|
||||
typeof(short),
|
||||
typeof(int),
|
||||
typeof(long),
|
||||
typeof(sbyte),
|
||||
typeof(ushort),
|
||||
typeof(uint),
|
||||
typeof(ulong)
|
||||
};
|
||||
|
||||
private static readonly Type TypeofCPA = typeof(CPA);
|
||||
private static readonly Type TypeofObject = typeof(object);
|
||||
|
||||
protected readonly List<object> m_List;
|
||||
protected readonly Mobile m_Mobile;
|
||||
|
|
@ -383,23 +304,23 @@ namespace Server.Gumps
|
|||
|
||||
var type = prop.PropertyType;
|
||||
|
||||
if (IsType(type, TypeofMobile) || IsType(type, TypeofItem))
|
||||
if (IsType(type, OfMobile) || IsType(type, OfItem))
|
||||
{
|
||||
from.SendGump(new SetObjectGump(prop, from, m_Object, type, this));
|
||||
}
|
||||
else if (IsType(type, TypeofType))
|
||||
else if (IsType(type, OfType))
|
||||
{
|
||||
from.Target = new SetObjectTarget(prop, from, m_Object, type, this);
|
||||
}
|
||||
else if (IsType(type, TypeofPoint3D))
|
||||
else if (IsType(type, OfPoint3D))
|
||||
{
|
||||
from.SendGump(new SetPoint3DGump(prop, from, m_Object, this));
|
||||
}
|
||||
else if (IsType(type, TypeofPoint2D))
|
||||
else if (IsType(type, OfPoint2D))
|
||||
{
|
||||
from.SendGump(new SetPoint2DGump(prop, from, m_Object, this));
|
||||
}
|
||||
else if (IsType(type, TypeofTimeSpan))
|
||||
else if (IsType(type, OfTimeSpan))
|
||||
{
|
||||
from.SendGump(new SetTimeSpanGump(prop, from, m_Object, this));
|
||||
}
|
||||
|
|
@ -415,7 +336,7 @@ namespace Server.Gumps
|
|||
)
|
||||
);
|
||||
}
|
||||
else if (IsType(type, TypeofEnum))
|
||||
else if (IsType(type, OfEnum))
|
||||
{
|
||||
from.SendGump(
|
||||
new SetListOptionGump(
|
||||
|
|
@ -428,7 +349,7 @@ namespace Server.Gumps
|
|||
)
|
||||
);
|
||||
}
|
||||
else if (IsType(type, TypeofBool))
|
||||
else if (IsType(type, OfBool))
|
||||
{
|
||||
from.SendGump(
|
||||
new SetListOptionGump(
|
||||
|
|
@ -441,13 +362,13 @@ namespace Server.Gumps
|
|||
)
|
||||
);
|
||||
}
|
||||
else if (IsType(type, TypeofString) || IsType(type, DecimalTypes) ||
|
||||
else if (IsType(type, OfString) || IsType(type, DecimalTypes) ||
|
||||
IsType(type, NumericTypes) ||
|
||||
IsType(type, TypeofText))
|
||||
IsType(type, OfText))
|
||||
{
|
||||
from.SendGump(new SetGump(prop, from, m_Object, this));
|
||||
}
|
||||
else if (IsType(type, TypeofPoison))
|
||||
else if (IsType(type, OfPoison))
|
||||
{
|
||||
from.SendGump(
|
||||
new SetListOptionGump(
|
||||
|
|
@ -460,7 +381,7 @@ namespace Server.Gumps
|
|||
)
|
||||
);
|
||||
}
|
||||
else if (IsType(type, TypeofMap))
|
||||
else if (IsType(type, OfMap))
|
||||
{
|
||||
from.SendGump(
|
||||
new SetListOptionGump(
|
||||
|
|
@ -473,12 +394,12 @@ namespace Server.Gumps
|
|||
)
|
||||
);
|
||||
}
|
||||
else if (IsType(type, TypeofSkills) && m_Object is Mobile mobile)
|
||||
else if (IsType(type, OfSkills) && m_Object is Mobile mobile)
|
||||
{
|
||||
from.SendGump(new PropertiesGump(from, mobile, m_Stack, m_List, m_Page));
|
||||
from.SendGump(new SkillsGump(from, mobile));
|
||||
}
|
||||
else if (HasAttribute(type, TypeofPropertyObject, true))
|
||||
else if (HasAttribute(type, OfPropertyObject, true))
|
||||
{
|
||||
var obj = prop.GetValue(m_Object, null);
|
||||
|
||||
|
|
@ -512,7 +433,7 @@ namespace Server.Gumps
|
|||
return list;
|
||||
}
|
||||
|
||||
private static bool IsCustomEnum(Type type) => type.IsDefined(TypeofCustomEnum, false);
|
||||
private static bool IsCustomEnum(Type type) => type.IsDefined(OfCustomEnum, false);
|
||||
|
||||
public void OnValueChanged(object obj, PropertyInfo prop)
|
||||
{
|
||||
|
|
@ -536,7 +457,7 @@ namespace Server.Gumps
|
|||
|
||||
private static string[] GetCustomEnumNames(Type type)
|
||||
{
|
||||
var attrs = type.GetCustomAttributes(TypeofCustomEnum, false);
|
||||
var attrs = type.GetCustomAttributes(OfCustomEnum, false);
|
||||
|
||||
if (attrs.Length == 0)
|
||||
{
|
||||
|
|
@ -551,12 +472,12 @@ namespace Server.Gumps
|
|||
return ce.Names;
|
||||
}
|
||||
|
||||
public static bool HasAttribute(Type type, Type check, bool inherit) =>
|
||||
private static bool HasAttribute(Type type, Type check, bool inherit) =>
|
||||
type.GetCustomAttributes(check, inherit).Length > 0;
|
||||
|
||||
public static bool IsType(Type type, Type check) => type == check || type.IsSubclassOf(check);
|
||||
private static bool IsType(Type type, Type check) => type == check || type.IsSubclassOf(check);
|
||||
|
||||
public static bool IsType(Type type, Type[] check)
|
||||
private static bool IsType(Type type, Type[] check)
|
||||
{
|
||||
for (var i = 0; i < check.Length; ++i)
|
||||
{
|
||||
|
|
@ -569,7 +490,7 @@ namespace Server.Gumps
|
|||
return false;
|
||||
}
|
||||
|
||||
public string ValueToString(PropertyInfo prop) => ValueToString(m_Object, prop);
|
||||
private string ValueToString(PropertyInfo prop) => ValueToString(m_Object, prop);
|
||||
|
||||
public static string ValueToString(object obj, PropertyInfo prop)
|
||||
{
|
||||
|
|
@ -583,7 +504,7 @@ namespace Server.Gumps
|
|||
}
|
||||
}
|
||||
|
||||
public static string ValueToString(object o)
|
||||
private static string ValueToString(object o)
|
||||
{
|
||||
if (o == null)
|
||||
{
|
||||
|
|
@ -668,7 +589,7 @@ namespace Server.Gumps
|
|||
{
|
||||
var kvp = groups[i];
|
||||
|
||||
if (!HasAttribute(kvp.Key, TypeofNoSort, false))
|
||||
if (!HasAttribute(kvp.Key, OfNoSort, false))
|
||||
{
|
||||
kvp.Value.Sort(PropertySorter.Instance);
|
||||
}
|
||||
|
|
@ -694,18 +615,6 @@ namespace Server.Gumps
|
|||
|
||||
protected virtual bool ShowAttribute(string name) => true;
|
||||
|
||||
public static CPA GetCPA(PropertyInfo prop)
|
||||
{
|
||||
var attrs = prop.GetCustomAttributes(TypeofCPA, false);
|
||||
|
||||
if (attrs.Length > 0)
|
||||
{
|
||||
return attrs[0] as CPA;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<KeyValuePair<Type, List<PropertyInfo>>> GetGroups(Type objectType, PropertyInfo[] props)
|
||||
{
|
||||
var groups = new Dictionary<Type, List<PropertyInfo>>();
|
||||
|
|
@ -726,7 +635,7 @@ namespace Server.Gumps
|
|||
{
|
||||
var baseType = type?.BaseType;
|
||||
|
||||
if (baseType == TypeofObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null)
|
||||
if (baseType == OfObject || baseType?.GetProperty(prop.Name, prop.PropertyType) == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -895,7 +804,7 @@ namespace Server.Gumps
|
|||
|
||||
int dist;
|
||||
|
||||
for (dist = 0; current != null && current != TypeofObject && current != type; ++dist)
|
||||
for (dist = 0; current != null && current != OfObject && current != type; ++dist)
|
||||
{
|
||||
current = current.BaseType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,44 +3,12 @@ using Server.Commands;
|
|||
using Server.HuePickers;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
|
|
|||
|
|
@ -2,44 +2,12 @@ using System.Reflection;
|
|||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetListOptionGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
private static readonly int EntryCount = 13;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,44 +5,12 @@ using Server.Commands.Generic;
|
|||
using Server.Network;
|
||||
using Server.Prompts;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetObjectGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
|
|
|||
|
|
@ -3,44 +3,12 @@ using Server.Commands;
|
|||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint2DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 105;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,44 +3,12 @@ using Server.Commands;
|
|||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetPoint3DGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int CoordWidth = 70;
|
||||
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth + OffsetSize + CoordWidth;
|
||||
|
||||
|
|
@ -49,6 +17,7 @@ namespace Server.Gumps
|
|||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
|
||||
private readonly Mobile m_Mobile;
|
||||
private readonly object m_Object;
|
||||
private readonly PropertyInfo m_Property;
|
||||
|
|
|
|||
|
|
@ -3,44 +3,12 @@ using System.Reflection;
|
|||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetTimeSpanGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 212;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
|
|
|||
|
|
@ -3,44 +3,12 @@ using System.Collections.Generic;
|
|||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class EditSkillGump : Gump
|
||||
{
|
||||
public static readonly bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly int EntryWidth = 160;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
|
@ -143,40 +111,6 @@ namespace Server.Gumps
|
|||
|
||||
public class SkillsGump : Gump
|
||||
{
|
||||
public static bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
/*
|
||||
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
|
||||
|
||||
|
|
@ -191,17 +125,10 @@ namespace Server.Gumps
|
|||
private static readonly int NameWidth = 107;
|
||||
private static readonly int ValueWidth = 128;
|
||||
|
||||
private static readonly int EntryCount = 15;
|
||||
|
||||
private static readonly int TypeWidth = NameWidth + OffsetSize + ValueWidth;
|
||||
|
||||
private static readonly int TotalWidth =
|
||||
OffsetSize + NameWidth + OffsetSize + ValueWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
|
||||
private static readonly int TotalHeight = OffsetSize + (EntryHeight + OffsetSize) * (EntryCount + 1);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
|
||||
private static readonly int IndentWidth = 12;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,47 +3,12 @@ using System.Collections.Generic;
|
|||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
using static Server.Gumps.PropsConfig;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class WhoGump : Gump
|
||||
{
|
||||
public static bool OldStyle = PropsConfig.OldStyle;
|
||||
|
||||
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
|
||||
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
|
||||
|
||||
public static readonly int TextHue = PropsConfig.TextHue;
|
||||
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
|
||||
|
||||
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
|
||||
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
|
||||
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
|
||||
public static readonly int BackGumpID = PropsConfig.BackGumpID;
|
||||
public static readonly int SetGumpID = PropsConfig.SetGumpID;
|
||||
|
||||
public static readonly int SetWidth = PropsConfig.SetWidth;
|
||||
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
|
||||
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
|
||||
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
|
||||
|
||||
public static readonly int PrevWidth = PropsConfig.PrevWidth;
|
||||
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
|
||||
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
|
||||
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
|
||||
|
||||
public static readonly int NextWidth = PropsConfig.NextWidth;
|
||||
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
|
||||
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
|
||||
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
|
||||
|
||||
public static readonly int OffsetSize = PropsConfig.OffsetSize;
|
||||
|
||||
public static readonly int EntryHeight = PropsConfig.EntryHeight;
|
||||
public static readonly int BorderSize = PropsConfig.BorderSize;
|
||||
|
||||
private static readonly bool PrevLabel = false;
|
||||
private static readonly bool NextLabel = false;
|
||||
|
||||
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
|
||||
private static readonly int PrevLabelOffsetY = 0;
|
||||
|
||||
|
|
@ -54,10 +19,9 @@ namespace Server.Gumps
|
|||
private static readonly int EntryCount = 15;
|
||||
|
||||
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
|
||||
private static readonly int TotalHeight = OffsetSize + (EntryHeight + OffsetSize) * (EntryCount + 1);
|
||||
|
||||
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
|
||||
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
|
||||
|
||||
private readonly List<Mobile> m_Mobiles;
|
||||
|
||||
private Mobile m_Owner;
|
||||
|
|
|
|||
30
Projects/UOContent/Utilities/TypeAttributes.cs
Normal file
30
Projects/UOContent/Utilities/TypeAttributes.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using static Server.Types;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public static class Attributes
|
||||
{
|
||||
public static bool IsConstructible(ConstructorInfo ctor, AccessLevel accessLevel)
|
||||
{
|
||||
var attrs = ctor.GetCustomAttributes(OfConstructible, false);
|
||||
|
||||
return attrs.Length != 0 && accessLevel >= ((ConstructibleAttribute)attrs[0]).AccessLevel;
|
||||
}
|
||||
|
||||
public static CommandPropertyAttribute GetCPA(PropertyInfo p)
|
||||
{
|
||||
var attrs = p.GetCustomAttributes(OfCPA, false);
|
||||
|
||||
if (attrs.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return attrs[0] as CommandPropertyAttribute;
|
||||
}
|
||||
public static bool HasAttribute(Type type, Type check, bool inherit) =>
|
||||
type.GetCustomAttributes(check, inherit).Length > 0;
|
||||
}
|
||||
}
|
||||
107
Projects/UOContent/Utilities/Types.cs
Normal file
107
Projects/UOContent/Utilities/Types.cs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public static class Types
|
||||
{
|
||||
public static readonly Type OfByte = typeof(byte);
|
||||
public static readonly Type OfSByte = typeof(sbyte);
|
||||
public static readonly Type OfShort = typeof(short);
|
||||
public static readonly Type OfUShort = typeof(ushort);
|
||||
public static readonly Type OfInt = typeof(int);
|
||||
public static readonly Type OfUInt = typeof(uint);
|
||||
public static readonly Type OfLong = typeof(long);
|
||||
public static readonly Type OfULong = typeof(ulong);
|
||||
public static readonly Type OfObject = typeof(object);
|
||||
public static readonly Type OfBool = typeof(bool);
|
||||
public static readonly Type OfChar = typeof(char);
|
||||
public static readonly Type OfString = typeof(string);
|
||||
|
||||
public static readonly Type OfSerial = typeof(Serial);
|
||||
public static readonly Type OfTimeSpan = typeof(TimeSpan);
|
||||
public static readonly Type OfPoint3D = typeof(Point3D);
|
||||
public static readonly Type OfPoint2D = typeof(Point2D);
|
||||
public static readonly Type OfEnum = typeof(Enum);
|
||||
public static readonly Type OfType = typeof(Type);
|
||||
|
||||
public static readonly Type OfCPA = typeof(CommandPropertyAttribute);
|
||||
public static readonly Type OfText = typeof(TextDefinition);
|
||||
public static readonly Type OfParsable = typeof(ParsableAttribute);
|
||||
public static readonly Type OfMobile = typeof(Mobile);
|
||||
public static readonly Type OfItem = typeof(Item);
|
||||
public static readonly Type OfCustomEnum = typeof(CustomEnumAttribute);
|
||||
public static readonly Type OfPoison = typeof(Poison);
|
||||
public static readonly Type OfMap = typeof(Map);
|
||||
public static readonly Type OfSkills = typeof(Skills);
|
||||
public static readonly Type OfPropertyObject = typeof(PropertyObjectAttribute);
|
||||
public static readonly Type OfNoSort = typeof(NoSortAttribute);
|
||||
public static readonly Type OfEntity = typeof(IEntity);
|
||||
public static readonly Type OfConstructible = typeof(ConstructibleAttribute);
|
||||
|
||||
public static readonly string[] BoolNames = { "True", "False" };
|
||||
public static readonly object[] BoolValues = { true, false };
|
||||
|
||||
public static readonly string[] PoisonNames = { "None", "Lesser", "Regular", "Greater", "Deadly", "Lethal" };
|
||||
public static readonly object[] PoisonValues =
|
||||
{ null, Poison.Lesser, Poison.Regular, Poison.Greater, Poison.Deadly, Poison.Lethal };
|
||||
|
||||
public static readonly Type[] DecimalTypes =
|
||||
{
|
||||
typeof(float),
|
||||
typeof(double)
|
||||
};
|
||||
|
||||
public static readonly Type[] NumericTypes =
|
||||
{
|
||||
OfByte,
|
||||
OfShort,
|
||||
OfInt,
|
||||
OfLong,
|
||||
OfSByte,
|
||||
OfUShort,
|
||||
OfUInt,
|
||||
OfULong
|
||||
};
|
||||
|
||||
private static readonly Type[] SignedNumerics =
|
||||
{
|
||||
OfLong,
|
||||
OfInt,
|
||||
OfShort,
|
||||
OfSByte
|
||||
};
|
||||
|
||||
private static readonly Type[] UnsignedNumerics =
|
||||
{
|
||||
OfULong,
|
||||
OfUInt,
|
||||
OfUShort,
|
||||
OfByte
|
||||
};
|
||||
|
||||
|
||||
public static readonly Type[] ParseTypes = { OfString };
|
||||
|
||||
public static bool IsSerial(Type t) => t == OfSerial;
|
||||
|
||||
public static bool IsType(Type t) => t == OfType;
|
||||
|
||||
public static bool IsChar(Type t) => t == OfChar;
|
||||
|
||||
public static bool IsString(Type t) => t == OfString;
|
||||
|
||||
public static bool IsText(Type t) => t == OfText;
|
||||
|
||||
public static bool IsEnum(Type t) => t.IsEnum;
|
||||
|
||||
public static bool IsParsable(Type t) => t == OfTimeSpan || t.IsDefined(OfParsable, false);
|
||||
|
||||
public static bool IsNumeric(Type t) => Array.IndexOf(NumericTypes, t) >= 0;
|
||||
|
||||
public static bool IsSignedNumeric(Type t) => Array.IndexOf(SignedNumerics, t) >= 0;
|
||||
|
||||
public static bool IsUnsignedNumeric(Type t) => Array.IndexOf(UnsignedNumerics, t) >= 0;
|
||||
|
||||
public static bool IsEntity(Type t) => OfEntity.IsAssignableFrom(t);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue