- Improved TextDefinition formatting for staff use (props gump, set gump, get command).
- Improved parsing of TextDefinition from string.
This commit is contained in:
parent
a0e13d5007
commit
2f06b89f8f
4 changed files with 49 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ namespace Server.Gumps
|
|||
|
||||
if ( val == null )
|
||||
initialText = "";
|
||||
else if ( val is TextDefinition )
|
||||
initialText = ((TextDefinition)val).GetValue();
|
||||
else
|
||||
initialText = val.ToString();
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue