Changes properties to use automatic property initializers

This commit is contained in:
Kamron Batman 2018-09-14 15:23:29 -07:00
parent f0a48ad431
commit 06fa31a7bf
623 changed files with 13072 additions and 19304 deletions

View file

@ -4,17 +4,14 @@ namespace Server.Gumps
{
public abstract class BaseGridGump : Gump
{
private int m_CurrentX, m_CurrentY;
private int m_CurrentPage;
protected GumpBackground m_Background;
protected GumpImageTiled m_Offset;
public int CurrentPage => m_CurrentPage;
public int CurrentPage { get; private set; }
public int CurrentX => m_CurrentX;
public int CurrentX { get; private set; }
public int CurrentY => m_CurrentY;
public int CurrentY { get; private set; }
public BaseGridGump( int x, int y ) : base( x, y )
{
@ -78,20 +75,20 @@ namespace Server.Gumps
public void FinishPage()
{
if ( m_Background != null )
m_Background.Height = m_CurrentY + EntryHeight + OffsetSize + BorderSize;
m_Background.Height = CurrentY + EntryHeight + OffsetSize + BorderSize;
if ( m_Offset != null )
m_Offset.Height = m_CurrentY + EntryHeight + OffsetSize - BorderSize;
m_Offset.Height = CurrentY + EntryHeight + OffsetSize - BorderSize;
}
public void AddNewPage()
{
FinishPage();
m_CurrentX = BorderSize + OffsetSize;
m_CurrentY = BorderSize + OffsetSize;
CurrentX = BorderSize + OffsetSize;
CurrentY = BorderSize + OffsetSize;
AddPage( ++m_CurrentPage );
AddPage( ++CurrentPage );
m_Background = new GumpBackground( 0, 0, 100, 100, BackGumpID );
Add( m_Background );
@ -102,20 +99,20 @@ namespace Server.Gumps
public void AddNewLine()
{
m_CurrentY += EntryHeight + OffsetSize;
m_CurrentX = BorderSize + OffsetSize;
CurrentY += EntryHeight + OffsetSize;
CurrentX = BorderSize + OffsetSize;
}
public void IncreaseX( int width )
{
m_CurrentX += width + OffsetSize;
CurrentX += width + OffsetSize;
width = m_CurrentX + BorderSize;
width = CurrentX + BorderSize;
if ( m_Background != null && width > m_Background.Width )
m_Background.Width = width;
width = m_CurrentX - BorderSize;
width = CurrentX - BorderSize;
if ( m_Offset != null && width > m_Offset.Width )
m_Offset.Width = width;
@ -123,16 +120,16 @@ namespace Server.Gumps
public void AddEntryLabel( int width, string text )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddLabelCropped( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, TextHue, text );
AddImageTiled( CurrentX, CurrentY, width, EntryHeight, EntryGumpID );
AddLabelCropped( CurrentX + TextOffsetX, CurrentY, width - TextOffsetX, EntryHeight, TextHue, text );
IncreaseX( width );
}
public void AddEntryHtml( int width, string text )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddHtml( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, text, false, false );
AddImageTiled( CurrentX, CurrentY, width, EntryHeight, EntryGumpID );
AddHtml( CurrentX + TextOffsetX, CurrentY, width - TextOffsetX, EntryHeight, text, false, false );
IncreaseX( width );
}
@ -144,14 +141,14 @@ namespace Server.Gumps
public void AddEntryHeader( int width, int spannedEntries )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
AddImageTiled( CurrentX, CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
IncreaseX( width );
}
public void AddBlankLine()
{
if ( m_Offset != null )
AddImageTiled( m_Offset.X, m_CurrentY, m_Offset.Width, EntryHeight, BackGumpID + 4 );
AddImageTiled( m_Offset.X, CurrentY, m_Offset.Width, EntryHeight, BackGumpID + 4 );
AddNewLine();
}
@ -163,24 +160,24 @@ namespace Server.Gumps
public void AddEntryButton( int width, int normalID, int pressedID, int buttonID, int buttonWidth, int buttonHeight, int spannedEntries )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
AddButton( m_CurrentX + ((width - buttonWidth) / 2), m_CurrentY + (((EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)) - buttonHeight) / 2), normalID, pressedID, buttonID, GumpButtonType.Reply, 0 );
AddImageTiled( CurrentX, CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
AddButton( CurrentX + ((width - buttonWidth) / 2), CurrentY + (((EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)) - buttonHeight) / 2), normalID, pressedID, buttonID, GumpButtonType.Reply, 0 );
IncreaseX( width );
}
public void AddEntryPageButton( int width, int normalID, int pressedID, int page, int buttonWidth, int buttonHeight )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, HeaderGumpID );
AddButton( m_CurrentX + ((width - buttonWidth) / 2), m_CurrentY + ((EntryHeight - buttonHeight) / 2), normalID, pressedID, 0, GumpButtonType.Page, page );
AddImageTiled( CurrentX, CurrentY, width, EntryHeight, HeaderGumpID );
AddButton( CurrentX + ((width - buttonWidth) / 2), CurrentY + ((EntryHeight - buttonHeight) / 2), normalID, pressedID, 0, GumpButtonType.Page, page );
IncreaseX( width );
}
public void AddEntryText( int width, int entryID, string initialText )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddTextEntry( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, TextHue, entryID, initialText );
AddImageTiled( CurrentX, CurrentY, width, EntryHeight, EntryGumpID );
AddTextEntry( CurrentX + TextOffsetX, CurrentY, width - TextOffsetX, EntryHeight, TextHue, entryID, initialText );
IncreaseX( width );
}

View file

@ -47,9 +47,7 @@ namespace Server.Gumps
public class BaseImageTileButtonsGump : Gump
{
private ImageTileButtonInfo[] m_Buttons;
protected ImageTileButtonInfo[] Buttons => m_Buttons;
protected ImageTileButtonInfo[] Buttons { get; }
protected virtual int XItems => 2;
protected virtual int YItems => 5;
@ -59,7 +57,7 @@ namespace Server.Gumps
}
public BaseImageTileButtonsGump( TextDefinition header, ImageTileButtonInfo[] buttons ) : base( 10, 10 ) //Coords are 0, o on OSI, intentional difference
{
m_Buttons = buttons;
Buttons = buttons;
AddPage( 0 );
int x = XItems * 250;

View file

@ -15,58 +15,54 @@ namespace Server.Gumps
public class CAGObject : CAGNode
{
private Type m_Type;
private int m_ItemID;
private int m_Hue;
private CAGCategory m_Parent;
public Type Type { get; }
public Type Type => m_Type;
public int ItemID => m_ItemID;
public int Hue => m_Hue;
public CAGCategory Parent => m_Parent;
public int ItemID { get; }
public override string Caption => ( m_Type == null ? "bad type" : m_Type.Name );
public int Hue { get; }
public CAGCategory Parent { get; }
public override string Caption => ( Type == null ? "bad type" : Type.Name );
public override void OnClick( Mobile from, int page )
{
if ( m_Type == null )
if ( Type == null )
{
from.SendMessage( "That is an invalid type name." );
}
else
{
CommandSystem.Handle( from, $"{CommandSystem.Prefix}Add {m_Type.Name}");
CommandSystem.Handle( from, $"{CommandSystem.Prefix}Add {Type.Name}");
from.SendGump( new CategorizedAddGump( from, m_Parent, page ) );
from.SendGump( new CategorizedAddGump( from, Parent, page ) );
}
}
public CAGObject( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
Parent = parent;
if ( xml.MoveToAttribute( "type" ) )
m_Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );
Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );
if ( xml.MoveToAttribute( "gfx" ) )
m_ItemID = XmlConvert.ToInt32( xml.Value );
ItemID = XmlConvert.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "hue" ) )
m_Hue = XmlConvert.ToInt32( xml.Value );
Hue = XmlConvert.ToInt32( xml.Value );
}
}
public class CAGCategory : CAGNode
{
private string m_Title;
private CAGNode[] m_Nodes;
private CAGCategory m_Parent;
public string Title { get; }
public string Title => m_Title;
public CAGNode[] Nodes => m_Nodes;
public CAGCategory Parent => m_Parent;
public CAGNode[] Nodes { get; }
public override string Caption => m_Title;
public CAGCategory Parent { get; }
public override string Caption => Title;
public override void OnClick( Mobile from, int page )
{
@ -75,25 +71,25 @@ namespace Server.Gumps
private CAGCategory()
{
m_Title = "no data";
m_Nodes = new CAGNode[0];
Title = "no data";
Nodes = new CAGNode[0];
}
public CAGCategory( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
Parent = parent;
if ( xml.MoveToAttribute( "title" ) )
m_Title = xml.Value;
Title = xml.Value;
else
m_Title = "empty";
Title = "empty";
if ( m_Title == "Docked" )
m_Title = "Docked 2";
if ( Title == "Docked" )
Title = "Docked 2";
if ( xml.IsEmptyElement )
{
m_Nodes = new CAGNode[0];
Nodes = new CAGNode[0];
}
else
{
@ -112,7 +108,7 @@ namespace Server.Gumps
xml.Skip();
}
m_Nodes = (CAGNode[])nodes.ToArray( typeof( CAGNode ) );
Nodes = (CAGNode[])nodes.ToArray( typeof( CAGNode ) );
}
}

View file

@ -4,14 +4,9 @@ namespace Server.Gumps
{
public class ChildNode
{
private ParentNode m_Parent;
private string m_Name;
private Point3D m_Location;
public ChildNode( XmlTextReader xml, ParentNode parent )
{
m_Parent = parent;
Parent = parent;
Parse( xml );
}
@ -19,9 +14,9 @@ namespace Server.Gumps
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
m_Name = xml.Value;
Name = xml.Value;
else
m_Name = "empty";
Name = "empty";
int x = 0, y = 0, z = 0;
@ -34,13 +29,13 @@ namespace Server.Gumps
if ( xml.MoveToAttribute( "z" ) )
z = Utility.ToInt32( xml.Value );
m_Location = new Point3D( x, y, z );
Location = new Point3D( x, y, z );
}
public ParentNode Parent => m_Parent;
public ParentNode Parent { get; }
public string Name => m_Name;
public string Name { get; private set; }
public Point3D Location => m_Location;
public Point3D Location { get; private set; }
}
}

View file

@ -6,14 +6,10 @@ namespace Server.Gumps
{
public class LocationTree
{
private Map m_Map;
private ParentNode m_Root;
private Dictionary<Mobile, ParentNode> m_LastBranch;
public LocationTree( string fileName, Map map )
{
m_LastBranch = new Dictionary<Mobile, ParentNode>();
m_Map = map;
LastBranch = new Dictionary<Mobile, ParentNode>();
Map = map;
string path = Path.Combine( "Data/Locations/", fileName );
@ -23,17 +19,17 @@ namespace Server.Gumps
xml.WhitespaceHandling = WhitespaceHandling.None;
m_Root = Parse( xml );
Root = Parse( xml );
xml.Close();
}
}
public Dictionary<Mobile, ParentNode> LastBranch => m_LastBranch;
public Dictionary<Mobile, ParentNode> LastBranch { get; }
public Map Map => m_Map;
public Map Map { get; }
public ParentNode Root => m_Root;
public ParentNode Root { get; }
private ParentNode Parse( XmlTextReader xml )
{

View file

@ -5,14 +5,9 @@ namespace Server.Gumps
{
public class ParentNode
{
private ParentNode m_Parent;
private object[] m_Children;
private string m_Name;
public ParentNode( XmlTextReader xml, ParentNode parent )
{
m_Parent = parent;
Parent = parent;
Parse( xml );
}
@ -20,13 +15,13 @@ namespace Server.Gumps
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
m_Name = xml.Value;
Name = xml.Value;
else
m_Name = "empty";
Name = "empty";
if ( xml.IsEmptyElement )
{
m_Children = new object[0];
Children = new object[0];
}
else
{
@ -49,14 +44,14 @@ namespace Server.Gumps
}
}
m_Children = children.ToArray();
Children = children.ToArray();
}
}
public ParentNode Parent => m_Parent;
public ParentNode Parent { get; }
public object[] Children => m_Children;
public object[] Children { get; private set; }
public string Name => m_Name;
public string Name { get; private set; }
}
}

View file

@ -8,11 +8,9 @@ namespace Server.Guilds
{
public abstract class BaseGuildGump : Gump
{
private Guild m_Guild;
private PlayerMobile m_Player;
protected Guild guild { get; }
protected Guild guild => m_Guild;
protected PlayerMobile player => m_Player;
protected PlayerMobile player { get; }
public BaseGuildGump( PlayerMobile pm, Guild g ) : this( pm, g, 10, 10 )
{
@ -20,8 +18,8 @@ namespace Server.Guilds
public BaseGuildGump( PlayerMobile pm, Guild g, int x, int y ) : base( x, y )
{
m_Guild = g;
m_Player = pm;
guild = g;
player = pm;
pm.CloseGump( typeof( BaseGuildGump ) );
}

View file

@ -188,18 +188,17 @@ namespace Server.Guilds
}
public struct InfoField<T>
{
private TextDefinition m_Name;
private int m_Width;
private IComparer<T> m_Comparer;
public TextDefinition Name { get; }
public int Width { get; }
public IComparer<T> Comparer { get; }
public TextDefinition Name => m_Name;
public int Width => m_Width;
public IComparer<T> Comparer => m_Comparer;
public InfoField( TextDefinition name, int width, IComparer<T> comparer )
{
m_Name = name;
m_Width = width;
m_Comparer = comparer;
Name = name;
Width = width;
Comparer = comparer;
}
}
}

View file

@ -302,12 +302,6 @@ namespace Server.Gumps
private class CustomItem
{
private Type m_Type;
private int m_ItemID;
private int m_LocNum;
private int m_ArtNum;
private bool m_LongText;
public CustomItem( int itemID, int loc ) : this( null, itemID, loc, 0, false )
{
}
@ -326,23 +320,23 @@ namespace Server.Gumps
public CustomItem( Type type, int itemID, int loc, int art, bool longText )
{
m_Type = type;
m_ItemID = itemID;
m_LocNum = loc;
m_ArtNum = art;
m_LongText = longText;
Type = type;
ItemID = itemID;
LocNumber = loc;
ArtNumber = art;
LongText = longText;
}
public Item Create()
{
if ( m_Type == null )
if ( Type == null )
return null;
Item i = null;
try
{
ConstructorInfo ctor = m_Type.GetConstructor( new Type[0] );
ConstructorInfo ctor = Type.GetConstructor( new Type[0] );
if ( ctor != null )
i = ctor.Invoke( null ) as Item;
}
@ -353,32 +347,34 @@ namespace Server.Gumps
return i;
}
public Type Type => m_Type;
public int ItemID => m_ItemID;
public int LocNumber => m_LocNum;
public int ArtNumber => m_ArtNum;
public bool LongText => m_LongText;
public Type Type { get; }
public int ItemID { get; }
public int LocNumber { get; }
public int ArtNumber { get; }
public bool LongText { get; }
}
private class CustomCategory
{
private CustomItem[] m_Entries;
private Layer m_Layer;
private bool m_CanDye;
private int m_LocNum;
public CustomCategory( Layer layer, int loc, bool canDye, CustomItem[] items )
{
m_Entries = items;
m_CanDye = canDye;
m_Layer = layer;
m_LocNum = loc;
Entries = items;
CanDye = canDye;
Layer = layer;
LocNumber = loc;
}
public bool CanDye => m_CanDye;
public CustomItem[] Entries => m_Entries;
public Layer Layer => m_Layer;
public int LocNumber => m_LocNum;
public bool CanDye { get; }
public CustomItem[] Entries { get; }
public Layer Layer { get; }
public int LocNumber { get; }
}
private static CustomCategory[] Categories = {
@ -783,16 +779,14 @@ namespace Server.Gumps
private class HairOrBeard
{
private int m_ItemID;
private int m_Name;
public int ItemID { get; }
public int ItemID => m_ItemID;
public int Name => m_Name;
public int Name { get; }
public HairOrBeard( int itemID, int name )
{
m_ItemID = itemID;
m_Name = name;
ItemID = itemID;
Name = name;
}
}

View file

@ -26,22 +26,24 @@ namespace Server.Gumps
public static readonly PolymorphEntry Daemon = new PolymorphEntry( 8403, 0x09, 1015253, 25, 8 );
private int m_Art, m_Body, m_Num, m_X, m_Y;
private PolymorphEntry( int Art, int Body, int LocNum, int X, int Y )
{
m_Art = Art;
m_Body = Body;
m_Num = LocNum;
m_X = X;
m_Y = Y;
ArtID = Art;
BodyID = Body;
LocNumber = LocNum;
this.X = X;
this.Y = Y;
}
public int ArtID => m_Art;
public int BodyID => m_Body;
public int LocNumber => m_Num;
public int X => m_X;
public int Y => m_Y;
public int ArtID { get; }
public int BodyID { get; }
public int LocNumber { get; }
public int X { get; }
public int Y { get; }
}
@ -49,17 +51,15 @@ namespace Server.Gumps
{
private class PolymorphCategory
{
private int m_Num;
private PolymorphEntry[] m_Entries;
public PolymorphCategory( int num, params PolymorphEntry[] entries )
{
m_Num = num;
m_Entries = entries;
LocNumber = num;
Entries = entries;
}
public PolymorphEntry[] Entries => m_Entries;
public int LocNumber => m_Num;
public PolymorphEntry[] Entries { get; }
public int LocNumber { get; }
}
private static PolymorphCategory[] Categories = {

View file

@ -228,15 +228,13 @@ namespace Server.Gumps
private class InternalEntry : IComparable
{
private int m_Body;
private int m_ItemID;
private string m_Name;
private string m_DisplayName;
public int Body { get; }
public int Body => m_Body;
public int ItemID => m_ItemID;
public string Name => m_Name;
public string DisplayName => m_DisplayName;
public int ItemID { get; }
public string Name { get; }
public string DisplayName { get; }
private static string[] m_GroupNames = {
"ogres_", "ettins_", "walking_dead_", "gargoyles_",
@ -258,32 +256,32 @@ namespace Server.Gumps
public InternalEntry( int body, int itemID, string name )
{
m_Body = body;
m_ItemID = itemID;
m_Name = name;
Body = body;
ItemID = itemID;
Name = name;
m_DisplayName = name.ToLower();
DisplayName = name.ToLower();
for( int i = 0; i < m_GroupNames.Length; ++i )
{
if ( m_DisplayName.StartsWith( m_GroupNames[i] ) )
if ( DisplayName.StartsWith( m_GroupNames[i] ) )
{
m_DisplayName = m_DisplayName.Substring( m_GroupNames[i].Length );
DisplayName = DisplayName.Substring( m_GroupNames[i].Length );
break;
}
}
m_DisplayName = m_DisplayName.Replace( '_', ' ' );
DisplayName = DisplayName.Replace( '_', ' ' );
}
public int CompareTo( object obj )
{
InternalEntry comp = (InternalEntry)obj;
int v = m_Name.CompareTo( comp.m_Name );
int v = Name.CompareTo( comp.Name );
if ( v == 0 )
m_Body.CompareTo( comp.m_Body );
Body.CompareTo( comp.Body );
return v;
}

View file

@ -20,23 +20,21 @@ namespace Server.Gumps
public class RewardGump : Gump
{
private TextDefinition m_Title;
private IRewardEntry[] m_Rewards;
private int m_Points;
private RewardPickedHandler m_OnPicked;
public TextDefinition Title { get; }
public TextDefinition Title => m_Title;
public IRewardEntry[] Rewards => m_Rewards;
public int Points => m_Points;
public RewardPickedHandler OnPicked => m_OnPicked;
public IRewardEntry[] Rewards { get; }
public int Points { get; }
public RewardPickedHandler OnPicked { get; }
public RewardGump( TextDefinition title, IRewardEntry[] rewards, int points, RewardPickedHandler onPicked )
: base( 250, 50 )
{
m_Title = title;
m_Rewards = rewards;
m_Points = points;
m_OnPicked = onPicked;
Title = title;
Rewards = rewards;
Points = points;
OnPicked = onPicked;
AddPage( 0 );
@ -49,13 +47,13 @@ namespace Server.Gumps
AddImage( 32, 33, 0x2635 );
AddImageTiled( 70, 55, 230, 2, 0x23C5 );
if ( m_Title.String != null )
AddHtml( 70, 35, 270, 20, m_Title.String, false, false );
else if ( m_Title.Number != 0 )
AddHtmlLocalized( 70, 35, 270, 20, m_Title.Number, 1, false, false );
if ( Title.String != null )
AddHtml( 70, 35, 270, 20, Title.String, false, false );
else if ( Title.Number != 0 )
AddHtmlLocalized( 70, 35, 270, 20, Title.Number, 1, false, false );
AddHtmlLocalized( 50, 65, 150, 20, 1072843, 1, false, false ); // Your Reward Points:
AddLabel( 230, 65, 0x64, m_Points.ToString() );
AddLabel( 230, 65, 0x64, Points.ToString() );
AddImageTiled( 35, 85, 270, 2, 0x23C5 );
AddHtmlLocalized( 35, 90, 270, 20, 1072844, 1, false, false ); // Please Choose a Reward:
@ -64,9 +62,9 @@ namespace Server.Gumps
int offset = 110;
int page = 1;
for ( int i = 0; i < m_Rewards.Length; ++i )
for ( int i = 0; i < Rewards.Length; ++i )
{
IRewardEntry entry = m_Rewards[i];
IRewardEntry entry = Rewards[i];
Rectangle2D bounds = ItemBounds.Table[entry.ItemID];
int height = Math.Max( 36, bounds.Height );
@ -84,7 +82,7 @@ namespace Server.Gumps
offset = 110;
}
bool available = ( entry.Price <= m_Points );
bool available = ( entry.Price <= Points );
int half = offset + ( height / 2 );
if ( available )
@ -118,11 +116,11 @@ namespace Server.Gumps
choice -= 100;
if ( choice >= 0 && choice < m_Rewards.Length )
if ( choice >= 0 && choice < Rewards.Length )
{
IRewardEntry entry = m_Rewards[choice];
IRewardEntry entry = Rewards[choice];
if ( entry.Price <= m_Points )
if ( entry.Price <= Points )
sender.Mobile.SendGump( new RewardConfirmGump( this, choice, entry ) );
}
}

View file

@ -11,9 +11,7 @@ namespace Server.Gumps
{
public class RunebookGump : Gump
{
private Runebook m_Book;
public Runebook Book => m_Book;
public Runebook Book { get; }
public int GetMapHue( Map map )
{
@ -70,11 +68,11 @@ namespace Server.Gumps
// Charges
AddHtmlLocalized( 140, 40, 80, 18, 1011296, false, false ); // Charges:
AddHtml( 220, 40, 30, 18, m_Book.CurCharges.ToString(), false, false );
AddHtml( 220, 40, 30, 18, Book.CurCharges.ToString(), false, false );
// Max charges
AddHtmlLocalized( 300, 40, 100, 18, 1011297, false, false ); // Max Charges:
AddHtml( 400, 40, 30, 18, m_Book.MaxCharges.ToString(), false, false );
AddHtml( 400, 40, 30, 18, Book.MaxCharges.ToString(), false, false );
}
private void AddIndex()
@ -87,7 +85,7 @@ namespace Server.Gumps
AddHtmlLocalized( 158, 22, 100, 18, 1011299, false, false ); // Rename book
// List of entries
List<RunebookEntry> entries = m_Book.Entries;
List<RunebookEntry> entries = Book.Entries;
for ( int i = 0; i < 16; ++i )
{
@ -124,9 +122,9 @@ namespace Server.Gumps
string desc;
int hue;
if ( index < m_Book.Entries.Count )
if ( index < Book.Entries.Count )
{
RunebookEntry e = (RunebookEntry)m_Book.Entries[index];
RunebookEntry e = (RunebookEntry)Book.Entries[index];
desc = GetName( e.Description );
hue = GetMapHue( e.Map );
@ -147,7 +145,7 @@ namespace Server.Gumps
AddHtmlLocalized( 150 + (half * 160), 115, 100, 18, 1011298, false, false ); // Drop rune
// Set as default button
int defButtonID = e != m_Book.Default ? 2361 : 2360;
int defButtonID = e != Book.Default ? 2361 : 2360;
AddButton( 160 + (half * 140), 20, defButtonID, defButtonID, 2 + (index * 6) + 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 175 + (half * 140), 15, 100, 18, 1011300, false, false ); // Set default
@ -184,7 +182,7 @@ namespace Server.Gumps
public RunebookGump( Mobile from, Runebook book ) : base( 150, 200 )
{
m_Book = book;
Book = book;
AddBackground();
AddIndex();
@ -257,9 +255,9 @@ namespace Server.Gumps
{
Mobile from = state.Mobile;
if ( m_Book.Deleted || !from.InRange( m_Book.GetWorldLocation(), (Core.ML ? 3 : 1) ) || !Multis.DesignContext.Check( from ) )
if ( Book.Deleted || !from.InRange( Book.GetWorldLocation(), (Core.ML ? 3 : 1) ) || !Multis.DesignContext.Check( from ) )
{
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
return;
}
@ -267,14 +265,14 @@ namespace Server.Gumps
if ( buttonID == 1 ) // Rename book
{
if ( !m_Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster )
if ( !Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster )
{
from.SendLocalizedMessage( 502414 ); // Please enter a title for the runebook:
from.Prompt = new InternalPrompt( m_Book );
from.Prompt = new InternalPrompt( Book );
}
else
{
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
from.SendLocalizedMessage( 502413, null, 0x35 ); // That cannot be done while the book is locked down.
}
@ -286,18 +284,18 @@ namespace Server.Gumps
int index = buttonID / 6;
int type = buttonID % 6;
if ( index >= 0 && index < m_Book.Entries.Count )
if ( index >= 0 && index < Book.Entries.Count )
{
RunebookEntry e = (RunebookEntry)m_Book.Entries[index];
RunebookEntry e = (RunebookEntry)Book.Entries[index];
switch ( type )
{
case 0: // Use charges
{
if ( m_Book.CurCharges <= 0 )
if ( Book.CurCharges <= 0 )
{
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendGump( new RunebookGump( from, Book ) );
from.SendLocalizedMessage( 502412 ); // There are no charges left on that item.
}
@ -314,27 +312,27 @@ namespace Server.Gumps
from.SendMessage( location );
}
m_Book.OnTravel();
new RecallSpell( from, m_Book, e, m_Book ).Cast();
Book.OnTravel();
new RecallSpell( from, Book, e, Book ).Cast();
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
}
break;
}
case 1: // Drop rune
{
if ( !m_Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster )
if ( !Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster )
{
m_Book.DropRune( from, e, index );
Book.DropRune( from, e, index );
from.CloseGump( typeof( RunebookGump ) );
if ( !Core.ML )
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendGump( new RunebookGump( from, Book ) );
}
else
{
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
from.SendLocalizedMessage( 502413, null, 0x35 ); // That cannot be done while the book is locked down.
}
@ -343,12 +341,12 @@ namespace Server.Gumps
}
case 2: // Set default
{
if ( m_Book.CheckAccess( from ) )
if ( Book.CheckAccess( from ) )
{
m_Book.Default = e;
Book.Default = e;
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendGump( new RunebookGump( from, Book ) );
from.SendLocalizedMessage( 502417 ); // New default location set.
}
@ -370,7 +368,7 @@ namespace Server.Gumps
from.SendMessage( location );
}
m_Book.OnTravel();
Book.OnTravel();
new RecallSpell( from, null, e, null ).Cast();
}
else
@ -378,7 +376,7 @@ namespace Server.Gumps
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
break;
}
@ -397,7 +395,7 @@ namespace Server.Gumps
from.SendMessage( location );
}
m_Book.OnTravel();
Book.OnTravel();
new GateTravelSpell( from, null, e ).Cast();
}
else
@ -405,7 +403,7 @@ namespace Server.Gumps
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
break;
}
@ -426,7 +424,7 @@ namespace Server.Gumps
from.SendMessage( location );
}
m_Book.OnTravel();
Book.OnTravel();
new SacredJourneySpell( from, null, e, null ).Cast();
}
else
@ -435,14 +433,14 @@ namespace Server.Gumps
}
}
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
break;
}
}
}
else
m_Book.Openers.Remove( from );
Book.Openers.Remove( from );
}
}
}

View file

@ -425,18 +425,16 @@ namespace Server.Gumps
public class SkillsGumpGroup
{
private string m_Name;
private SkillName[] m_Skills;
public string Name { get; }
public string Name => m_Name;
public SkillName[] Skills => m_Skills;
public SkillName[] Skills { get; }
public SkillsGumpGroup( string name, SkillName[] skills )
{
m_Name = name;
m_Skills = skills;
Name = name;
Skills = skills;
Array.Sort( m_Skills, new SkillNameComparer() );
Array.Sort( Skills, new SkillNameComparer() );
}
private class SkillNameComparer : IComparer
@ -457,88 +455,87 @@ namespace Server.Gumps
}
}
private static SkillsGumpGroup[] m_Groups = {
new SkillsGumpGroup( "Crafting", new[]
{
SkillName.Alchemy,
SkillName.Blacksmith,
SkillName.Cartography,
SkillName.Carpentry,
SkillName.Cooking,
SkillName.Fletching,
SkillName.Inscribe,
SkillName.Tailoring,
SkillName.Tinkering,
SkillName.Imbuing
} ),
new SkillsGumpGroup( "Bardic", new[]
{
SkillName.Discordance,
SkillName.Musicianship,
SkillName.Peacemaking,
SkillName.Provocation
} ),
new SkillsGumpGroup( "Magical", new[]
{
SkillName.Chivalry,
SkillName.EvalInt,
SkillName.Magery,
SkillName.MagicResist,
SkillName.Meditation,
SkillName.Necromancy,
SkillName.SpiritSpeak,
SkillName.Ninjitsu,
SkillName.Bushido,
SkillName.Spellweaving,
SkillName.Mysticism
} ),
new SkillsGumpGroup( "Miscellaneous", new[]
{
SkillName.Camping,
SkillName.Fishing,
SkillName.Focus,
SkillName.Healing,
SkillName.Herding,
SkillName.Lockpicking,
SkillName.Lumberjacking,
SkillName.Mining,
SkillName.Snooping,
SkillName.Veterinary
} ),
new SkillsGumpGroup( "Combat Ratings", new[]
{
SkillName.Archery,
SkillName.Fencing,
SkillName.Macing,
SkillName.Parry,
SkillName.Swords,
SkillName.Tactics,
SkillName.Wrestling,
SkillName.Throwing
} ),
new SkillsGumpGroup( "Actions", new[]
{
SkillName.AnimalTaming,
SkillName.Begging,
SkillName.DetectHidden,
SkillName.Hiding,
SkillName.RemoveTrap,
SkillName.Poisoning,
SkillName.Stealing,
SkillName.Stealth,
SkillName.Tracking
} ),
new SkillsGumpGroup( "Lore & Knowledge", new[]
{
SkillName.Anatomy,
SkillName.AnimalLore,
SkillName.ArmsLore,
SkillName.Forensics,
SkillName.ItemID,
SkillName.TasteID
} )
};
public static SkillsGumpGroup[] Groups => m_Groups;
public static SkillsGumpGroup[] Groups { get; } =
{
new SkillsGumpGroup( "Crafting", new[]
{
SkillName.Alchemy,
SkillName.Blacksmith,
SkillName.Cartography,
SkillName.Carpentry,
SkillName.Cooking,
SkillName.Fletching,
SkillName.Inscribe,
SkillName.Tailoring,
SkillName.Tinkering,
SkillName.Imbuing
} ),
new SkillsGumpGroup( "Bardic", new[]
{
SkillName.Discordance,
SkillName.Musicianship,
SkillName.Peacemaking,
SkillName.Provocation
} ),
new SkillsGumpGroup( "Magical", new[]
{
SkillName.Chivalry,
SkillName.EvalInt,
SkillName.Magery,
SkillName.MagicResist,
SkillName.Meditation,
SkillName.Necromancy,
SkillName.SpiritSpeak,
SkillName.Ninjitsu,
SkillName.Bushido,
SkillName.Spellweaving,
SkillName.Mysticism
} ),
new SkillsGumpGroup( "Miscellaneous", new[]
{
SkillName.Camping,
SkillName.Fishing,
SkillName.Focus,
SkillName.Healing,
SkillName.Herding,
SkillName.Lockpicking,
SkillName.Lumberjacking,
SkillName.Mining,
SkillName.Snooping,
SkillName.Veterinary
} ),
new SkillsGumpGroup( "Combat Ratings", new[]
{
SkillName.Archery,
SkillName.Fencing,
SkillName.Macing,
SkillName.Parry,
SkillName.Swords,
SkillName.Tactics,
SkillName.Wrestling,
SkillName.Throwing
} ),
new SkillsGumpGroup( "Actions", new[]
{
SkillName.AnimalTaming,
SkillName.Begging,
SkillName.DetectHidden,
SkillName.Hiding,
SkillName.RemoveTrap,
SkillName.Poisoning,
SkillName.Stealing,
SkillName.Stealth,
SkillName.Tracking
} ),
new SkillsGumpGroup( "Lore & Knowledge", new[]
{
SkillName.Anatomy,
SkillName.AnimalLore,
SkillName.ArmsLore,
SkillName.Forensics,
SkillName.ItemID,
SkillName.TasteID
} )
};
}
}