Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,123 +1,124 @@
using System;
using Server.Gumps;
using Server.Misc;
using Server.Network;
namespace Server.Items
{
public class NameChangeDeed : Item
{
public override string DefaultName => "a name change deed";
public class NameChangeDeed : Item
{
[Constructible]
public NameChangeDeed() : base(0x14F0)
{
LootType = LootType.Blessed;
}
[Constructible]
public NameChangeDeed() : base( 0x14F0 )
{
LootType = LootType.Blessed;
}
public NameChangeDeed(Serial serial) : base(serial)
{
}
public NameChangeDeed( Serial serial ) : base( serial )
{
}
public override string DefaultName => "a name change deed";
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
}
writer.Write(0); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
if ( RootParent == from )
{
from.CloseGump( typeof( NameChangeDeedGump ) );
from.SendGump( new NameChangeDeedGump( this ) );
}
else
from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
}
}
public override void OnDoubleClick(Mobile from)
{
if (RootParent == from)
{
from.CloseGump(typeof(NameChangeDeedGump));
from.SendGump(new NameChangeDeedGump(this));
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
}
public class NameChangeDeedGump : Gump
{
Item m_Sender;
public class NameChangeDeedGump : Gump
{
private Item m_Sender;
public void AddBlackAlpha( int x, int y, int width, int height )
{
AddImageTiled( x, y, width, height, 2624 );
AddAlphaRegion( x, y, width, height );
}
public NameChangeDeedGump(Item sender) : base(50, 50)
{
m_Sender = sender;
public void AddTextField( int x, int y, int width, int height, int index )
{
AddBackground( x - 2, y - 2, width + 4, height + 4, 0x2486 );
AddTextEntry( x + 2, y + 2, width - 4, height - 4, 0, index, "" );
}
Closable = true;
Dragable = true;
Resizable = false;
public string Center( string text )
{
return $"<CENTER>{text}</CENTER>";
}
AddPage(0);
public string Color( string text, int color )
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
AddBlackAlpha(10, 120, 250, 85);
AddHtml(10, 125, 250, 20, Color(Center("Name Change Deed"), 0xFFFFFF), false, false);
public void AddButtonLabeled( int x, int y, int buttonID, string text )
{
AddButton( x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
AddHtml( x + 35, y, 240, 20, Color( text, 0xFFFFFF ), false, false );
}
AddLabel(73, 15, 1152, "");
AddLabel(20, 150, 0x480, "New Name:");
AddTextField(100, 150, 150, 20, 0);
public NameChangeDeedGump( Item sender ) : base( 50, 50 )
{
m_Sender = sender;
AddButtonLabeled(75, 180, 1, "Submit");
}
Closable=true;
Dragable=true;
Resizable=false;
public void AddBlackAlpha(int x, int y, int width, int height)
{
AddImageTiled(x, y, width, height, 2624);
AddAlphaRegion(x, y, width, height);
}
AddPage(0);
public void AddTextField(int x, int y, int width, int height, int index)
{
AddBackground(x - 2, y - 2, width + 4, height + 4, 0x2486);
AddTextEntry(x + 2, y + 2, width - 4, height - 4, 0, index, "");
}
AddBlackAlpha( 10, 120, 250, 85 );
AddHtml( 10, 125, 250, 20, Color( Center( "Name Change Deed" ), 0xFFFFFF ), false, false );
public string Center(string text)
{
return $"<CENTER>{text}</CENTER>";
}
AddLabel( 73, 15, 1152, "" );
AddLabel( 20, 150, 0x480, "New Name:" );
AddTextField( 100, 150, 150, 20, 0 );
public string Color(string text, int color)
{
return $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";
}
AddButtonLabeled( 75, 180, 1, "Submit" );
}
public void AddButtonLabeled(int x, int y, int buttonID, string text)
{
AddButton(x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0);
AddHtml(x + 35, y, 240, 20, Color(text, 0xFFFFFF), false, false);
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_Sender == null || m_Sender.Deleted || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile )
return;
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Sender == null || m_Sender.Deleted || info.ButtonID != 1 || m_Sender.RootParent != sender.Mobile)
return;
Mobile m = sender.Mobile;
TextRelay nameEntry = info.GetTextEntry( 0 );
Mobile m = sender.Mobile;
TextRelay nameEntry = info.GetTextEntry(0);
string newName = nameEntry?.Text.Trim();
string newName = nameEntry?.Text.Trim();
if ( !NameVerification.Validate( newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote ) )
{
m.SendMessage( "That name is unacceptable." );
return;
}
m.RawName = newName;
m.SendMessage( "Your name has been changed!" );
m.SendMessage($"You are now known as {newName}");
m_Sender.Delete();
}
}
if (!NameVerification.Validate(newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
{
m.SendMessage("That name is unacceptable.");
return;
}
m.RawName = newName;
m.SendMessage("Your name has been changed!");
m.SendMessage($"You are now known as {newName}");
m_Sender.Delete();
}
}
}