Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -11,11 +11,11 @@ namespace Server.Gumps
Parse(xml);
}
public ParentNode Parent{ get; }
public ParentNode Parent { get; }
public string Name{ get; private set; }
public string Name { get; private set; }
public Point3D Location{ get; private set; }
public Point3D Location { get; private set; }
private void Parse(XmlTextReader xml)
{

View file

@ -44,7 +44,8 @@ namespace Server.Gumps
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static bool PrevLabel = false, NextLabel = false;
private static readonly bool PrevLabel = false;
private static readonly bool NextLabel = false;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
@ -60,10 +61,10 @@ namespace Server.Gumps
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private ParentNode m_Node;
private int m_Page;
private readonly ParentNode m_Node;
private readonly int m_Page;
private LocationTree m_Tree;
private readonly LocationTree m_Tree;
private GoGump(int page, Mobile from, LocationTree tree, ParentNode node) : base(50, 50)
{
@ -194,42 +195,42 @@ namespace Server.Gumps
switch (info.ButtonID)
{
case 1:
{
if (m_Node.Parent != null)
from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent));
break;
}
case 2:
{
if (m_Page > 0)
from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node));
break;
}
case 3:
{
if ((m_Page + 1) * EntryCount < m_Node.Children.Length)
from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node));
break;
}
default:
{
int index = info.ButtonID - 4;
if (index >= 0 && index < m_Node.Children.Length)
{
IGoNode o = m_Node.Children[index];
if (m_Node.Parent != null)
from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent));
if (o is ParentNode node)
from.SendGump(new GoGump(0, from, m_Tree, node));
else
from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map);
break;
}
case 2:
{
if (m_Page > 0)
from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node));
break;
}
break;
}
case 3:
{
if ((m_Page + 1) * EntryCount < m_Node.Children.Length)
from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node));
break;
}
default:
{
int index = info.ButtonID - 4;
if (index >= 0 && index < m_Node.Children.Length)
{
IGoNode o = m_Node.Children[index];
if (o is ParentNode node)
from.SendGump(new GoGump(0, from, m_Tree, node));
else
from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map);
}
break;
}
}
}
}

View file

@ -23,11 +23,11 @@ namespace Server.Gumps
}
}
public Dictionary<Mobile, ParentNode> LastBranch{ get; }
public Dictionary<Mobile, ParentNode> LastBranch { get; }
public Map Map{ get; }
public Map Map { get; }
public ParentNode Root{ get; }
public ParentNode Root { get; }
private ParentNode Parse(XmlTextReader xml)
{

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Xml;
@ -5,31 +6,31 @@ namespace Server.Gumps
{
public interface IGoNode
{
ParentNode Parent{ get; }
string Name{ get; }
ParentNode Parent { get; }
string Name { get; }
}
public class ParentNode : IGoNode
{
public ParentNode(XmlTextReader xml, ParentNode parent)
{
Parent = parent;
Parse(xml);
}
public ParentNode Parent{ get; }
public ParentNode Parent { get; }
public IGoNode[] Children{ get; private set; }
public IGoNode[] Children { get; private set; }
public string Name{ get; private set; }
public string Name { get; private set; }
private void Parse(XmlTextReader xml)
{
Name = xml.MoveToAttribute("name") ? xml.Value : "empty";
if (xml.IsEmptyElement)
Children = new IGoNode[0];
Children = Array.Empty<IGoNode>();
else
{
List<IGoNode> children = new List<IGoNode>();
@ -49,4 +50,4 @@ namespace Server.Gumps
}
}
}
}
}