Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -2,49 +2,50 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server.Network;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class SetCustomEnumGump : SetListOptionGump
|
||||
{
|
||||
private string[] m_Names;
|
||||
public class SetCustomEnumGump : SetListOptionGump
|
||||
{
|
||||
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 )
|
||||
{
|
||||
m_Names = 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)
|
||||
{
|
||||
m_Names = names;
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState sender, RelayInfo relayInfo )
|
||||
{
|
||||
int index = relayInfo.ButtonID - 1;
|
||||
public override void OnResponse(NetState sender, RelayInfo relayInfo)
|
||||
{
|
||||
int index = relayInfo.ButtonID - 1;
|
||||
|
||||
if ( index >= 0 && index < m_Names.Length )
|
||||
{
|
||||
try
|
||||
{
|
||||
MethodInfo info = m_Property.PropertyType.GetMethod( "Parse", new[]{ typeof( string ) } );
|
||||
if (index >= 0 && index < m_Names.Length)
|
||||
try
|
||||
{
|
||||
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, info.Invoke( null, new object[] { m_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, m_Names[index], false ), true );
|
||||
if (info != null)
|
||||
result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name,
|
||||
info.Invoke(null, new object[] { m_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, m_Names[index], false), true);
|
||||
|
||||
m_Mobile.SendMessage( result );
|
||||
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." );
|
||||
}
|
||||
}
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue