diff --git a/Scripts/Commands/Properties.cs b/Scripts/Commands/Properties.cs index 0ce755899..aca09945b 100644 --- a/Scripts/Commands/Properties.cs +++ b/Scripts/Commands/Properties.cs @@ -317,6 +317,8 @@ namespace Server.Commands toString = String.Format( "'{0}' ({1} [0x{1:X}])", value, (int) value ); else if ( IsString( type ) ) toString = ( (string) value == "null" ? @"@""null""" : String.Format( "\"{0}\"", value ) ); + else if ( IsText( type ) ) + toString = ( (TextDefinition) value ).Format( false ); else toString = value.ToString(); @@ -377,6 +379,13 @@ namespace Server.Commands return ( t == typeofString ); } + private static Type typeofText = typeof( TextDefinition ); + + private static bool IsText( Type t ) + { + return ( t == typeofText ); + } + private static bool IsEnum( Type t ) { return t.IsEnum; diff --git a/Scripts/Gumps/Properties/PropsGump.cs b/Scripts/Gumps/Properties/PropsGump.cs index 514d3460f..58beaf164 100644 --- a/Scripts/Gumps/Properties/PropsGump.cs +++ b/Scripts/Gumps/Properties/PropsGump.cs @@ -510,6 +510,10 @@ namespace Server.Gumps { return ((Type)o).Name; } + else if ( o is TextDefinition ) + { + return ((TextDefinition)o).Format( true ); + } else { return o.ToString(); diff --git a/Scripts/Gumps/Properties/SetGump.cs b/Scripts/Gumps/Properties/SetGump.cs index 552a8dfa8..456c42a86 100644 --- a/Scripts/Gumps/Properties/SetGump.cs +++ b/Scripts/Gumps/Properties/SetGump.cs @@ -77,6 +77,8 @@ namespace Server.Gumps if ( val == null ) initialText = ""; + else if ( val is TextDefinition ) + initialText = ((TextDefinition)val).GetValue(); else initialText = val.ToString(); diff --git a/Scripts/Misc/TextDefinition.cs b/Scripts/Misc/TextDefinition.cs index 91bb1585b..fa4e0a98c 100644 --- a/Scripts/Misc/TextDefinition.cs +++ b/Scripts/Misc/TextDefinition.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using Server; using Server.Gumps; @@ -34,11 +35,31 @@ namespace Server public override string ToString() { if ( m_Number > 0 ) - return "#" + m_Number.ToString(); + return String.Concat( "#", m_Number.ToString() ); else if ( m_String != null ) return m_String; - return "(empty)"; + return ""; + } + + public string Format( bool propsGump ) + { + if ( m_Number > 0 ) + return String.Format( "{0} (0x{0:X})", m_Number ); + else if ( m_String != null ) + return String.Format( "\"{0}\"", m_String ); + + return propsGump ? "-empty-" : "empty"; + } + + public string GetValue() + { + if ( m_Number > 0 ) + return m_Number.ToString(); + else if ( m_String != null ) + return m_String; + + return ""; } public static void Serialize( GenericWriter writer, TextDefinition def ) @@ -155,8 +176,17 @@ namespace Server { if ( value == null ) return null; - else if ( value.StartsWith( "#" ) ) - return new TextDefinition( Utility.ToInt32( value.Substring( 1 ) ) ); + + int i; + bool isInteger; + + if ( value.StartsWith( "0x" ) ) + isInteger = int.TryParse( value.Substring( 2 ), NumberStyles.HexNumber, null, out i ); + else + isInteger = int.TryParse( value, out i ); + + if ( isInteger ) + return new TextDefinition( i ); else return new TextDefinition( value ); }