servuo/Scripts/Gumps/Props/SetCustomEnumGump.cs
VitaNex 7851c5e88c + Removed most file header regions.
+ Add MONO to Makefile compile definitions.
+ Update Ultima SDK to support MONO compile definition.
+ Rename Properties Gump parent directory to prevent VS issues.
+ Console error messages will now use red instead of dark red font.
+ Add crash state handler function to Core.
+ AI optimizations and housekeeping.
+ Context Menu optimizations and housekeeping.
+ Add ability to drop throttled packets.
+ Add string parsing support to Rectangle3D.
+ Optimize guild messages and chat.
+ IAddon implements IChopable.
+ Add more flexibility for altering Mobile names.
+ Add ability to enable or disable OPL for individual mobiles.
+ Optimize damaging regions and ensure timers are removed properly.
+ Update Welcome Timer with more intuitive message groups.
+ Normalize all virtue related objects to the Server.Services.Virtues namespace.
+ Add ability for ISpawner to append OPL and Context Menus to their spawn.
+ Add EventSink events for obtaining items, equipping items, context menus, and world broadcasts.
+ Add ability to lock a creature's direction and movement regardless of AI manipulation.
+ Add ability to dynamically change a creature's approach range and wait state.
+ Add extended enumeration features for AOS attributes.
+ Add ability to control whether creatures have blood, and its color.
+ Expose corpse flag manipulation methods.
+ Add ability to prevent criminal action when looting a corpse.
+ Corpse will now be permanently tagged as murderer at time of death if owner is a murderer.
+ Add TextDefinition support for Commodity Deed descriptions.
+ House add-on and component optimizations and housekeeping.
+ Item light is no longer backed by the direction property.
+ ITool implements IEntity.
+ Prevent trading of Siege Bless items.
+ Guards are naturally be immune to guards.
+ Siege Shard initialization housekeeping.
+ Character Creation housekeeping.
+ Generic commands housekeeping.
+ Add Mark command for staff.
2018-07-19 22:12:52 +01:00

93 lines
No EOL
2.2 KiB
C#

#region References
using System;
using System.Collections;
using System.Reflection;
using Server.Commands;
using Server.Network;
#endregion
namespace Server.Gumps
{
public class SetCustomEnumGump : SetListOptionGump
{
private static readonly Type typeofIDynamicEnum = typeof(IDynamicEnum);
private readonly string[] _Names;
public SetCustomEnumGump(
PropertyInfo prop,
Mobile mobile,
object o,
Stack stack,
int propspage,
ArrayList list,
string[] names)
: base(prop, mobile, o, stack, propspage, list, names, null)
{
_Names = names;
}
public override void OnResponse(NetState sender, RelayInfo relayInfo)
{
var index = relayInfo.ButtonID - 1;
if (index >= 0 && index < _Names.Length)
{
try
{
var info = m_Property.PropertyType.GetMethod("Parse", new[] {typeof(string)});
var result = "";
if (info != null)
{
result = Properties.SetDirect(
m_Mobile,
m_Object,
m_Object,
m_Property,
m_Property.Name,
info.Invoke(null, new object[] {_Names[index]}),
true);
}
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, _Names[index], false),
true);
}
else if (typeofIDynamicEnum.IsAssignableFrom(m_Property.PropertyType))
{
var ienum = (IDynamicEnum)m_Property.GetValue(m_Object, null);
if (ienum != null)
{
ienum.Value = _Names[index];
}
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, ienum, true);
}
m_Mobile.SendMessage(result);
if (result == "Property has been set.")
{
PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
}
}
catch
{
m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
}
}
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
}
}
}