Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -185,7 +185,8 @@ namespace Server.Gumps
Add(new GumpBackground(x, y, width, height, gumpID));
}
public void AddButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param)
public void AddButton(int x, int y, int normalID, int pressedID, int buttonID,
GumpButtonType type = GumpButtonType.Reply, int param = 0)
{
Add(new GumpButton(x, y, normalID, pressedID, buttonID, type, param));
}
@ -205,34 +206,29 @@ namespace Server.Gumps
Add(new GumpTooltip(number));
}
public void AddHtml(int x, int y, int width, int height, string text, bool background, bool scrollbar)
public void AddHtml(int x, int y, int width, int height, string text, bool background = false, bool scrollbar = false)
{
Add(new GumpHtml(x, y, width, height, text, background, scrollbar));
}
public void AddHtmlLocalized(int x, int y, int width, int height, int number, bool background, bool scrollbar)
public void AddHtmlLocalized(int x, int y, int width, int height, int number, bool background = false, bool scrollbar = false)
{
Add(new GumpHtmlLocalized(x, y, width, height, number, background, scrollbar));
}
public void AddHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background,
bool scrollbar)
public void AddHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background = false,
bool scrollbar = false)
{
Add(new GumpHtmlLocalized(x, y, width, height, number, color, background, scrollbar));
}
public void AddHtmlLocalized(int x, int y, int width, int height, int number, string args, int color,
bool background, bool scrollbar)
bool background = false, bool scrollbar = false)
{
Add(new GumpHtmlLocalized(x, y, width, height, number, args, color, background, scrollbar));
}
public void AddImage(int x, int y, int gumpID)
{
Add(new GumpImage(x, y, gumpID));
}
public void AddImage(int x, int y, int gumpID, int hue)
public void AddImage(int x, int y, int gumpID, int hue = 0)
{
Add(new GumpImage(x, y, gumpID, hue));
}
@ -243,24 +239,13 @@ namespace Server.Gumps
}
public void AddImageTiledButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type,
int param, int itemID, int hue, int width, int height)
{
Add(new GumpImageTileButton(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height));
}
public void AddImageTiledButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type,
int param, int itemID, int hue, int width, int height, int localizedTooltip)
int param, int itemID, int hue, int width, int height, int localizedTooltip = -1)
{
Add(new GumpImageTileButton(x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height,
localizedTooltip));
}
public void AddItem(int x, int y, int itemID)
{
Add(new GumpItem(x, y, itemID));
}
public void AddItem(int x, int y, int itemID, int hue)
public void AddItem(int x, int y, int itemID, int hue = 0)
{
Add(new GumpItem(x, y, itemID, hue));
}
@ -280,12 +265,7 @@ namespace Server.Gumps
Add(new GumpRadio(x, y, inactiveID, activeID, initialState, switchID));
}
public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText)
{
Add(new GumpTextEntry(x, y, width, height, hue, entryID, initialText));
}
public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText, int size)
public void AddTextEntry(int x, int y, int width, int height, int hue, int entryID, string initialText, int size = 0)
{
Add(new GumpTextEntryLimited(x, y, width, height, hue, entryID, initialText, size));
}
@ -390,4 +370,4 @@ namespace Server.Gumps
{
}
}
}
}

View file

@ -37,7 +37,8 @@ namespace Server.Gumps
private GumpButtonType m_Type;
private int m_X, m_Y;
public GumpButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param)
public GumpButton(int x, int y, int normalID, int pressedID, int buttonID,
GumpButtonType type = GumpButtonType.Reply, int param = 0)
{
m_X = x;
m_Y = y;
@ -117,4 +118,4 @@ namespace Server.Gumps
disp.AppendLayout(m_ButtonID);
}
}
}
}

View file

@ -41,33 +41,38 @@ namespace Server.Gumps
}
}
}
protected void Delta(ref uint var, uint val)
{
if (var != val) var = val;
if (var != val)
var = val;
}
protected void Delta(ref int var, int val)
{
if (var != val) var = val;
if (var != val)
var = val;
}
protected void Delta(ref bool var, bool val)
{
if (var != val) var = val;
if (var != val)
var = val;
}
protected void Delta(ref string var, string val)
{
if (var != val) var = val;
if (var != val)
var = val;
}
protected void Delta(ref object[] var, object[] val)
{
if (var != val) var = val;
if (var != val)
var = val;
}
public abstract string Compile(NetState ns);
public abstract void AppendTo(NetState ns, IGumpWriter disp);
}
}
}

View file

@ -43,7 +43,8 @@ namespace Server.Gumps
private int m_Width, m_Height;
private int m_X, m_Y;
public GumpHtmlLocalized(int x, int y, int width, int height, int number, bool background, bool scrollbar)
public GumpHtmlLocalized(int x, int y, int width, int height, int number,
bool background = false, bool scrollbar = false)
{
m_X = x;
m_Y = y;
@ -56,7 +57,8 @@ namespace Server.Gumps
m_Type = GumpHtmlLocalizedType.Plain;
}
public GumpHtmlLocalized(int x, int y, int width, int height, int number, int color, bool background, bool scrollbar)
public GumpHtmlLocalized(int x, int y, int width, int height, int number, int color,
bool background = false, bool scrollbar = false)
{
m_X = x;
m_Y = y;
@ -70,8 +72,8 @@ namespace Server.Gumps
m_Type = GumpHtmlLocalizedType.Color;
}
public GumpHtmlLocalized(int x, int y, int width, int height, int number, string args, int color, bool background,
bool scrollbar)
public GumpHtmlLocalized(int x, int y, int width, int height, int number, string args, int color,
bool background = false, bool scrollbar = false)
{
// Are multiple arguments unsupported? And what about non ASCII arguments?
@ -228,4 +230,4 @@ namespace Server.Gumps
}
}
}
}
}

View file

@ -30,11 +30,7 @@ namespace Server.Gumps
private int m_Hue;
private int m_X, m_Y;
public GumpImage(int x, int y, int gumpID) : this(x, y, gumpID, 0)
{
}
public GumpImage(int x, int y, int gumpID, int hue)
public GumpImage(int x, int y, int gumpID, int hue = 0)
{
m_X = x;
m_Y = y;
@ -68,9 +64,8 @@ namespace Server.Gumps
public override string Compile(NetState ns)
{
if (m_Hue == 0)
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}";
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}";
return m_Hue == 0 ? $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}" :
$"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}";
}
public override void AppendTo(NetState ns, IGumpWriter disp)
@ -87,4 +82,4 @@ namespace Server.Gumps
}
}
}
}
}

View file

@ -41,13 +41,7 @@ namespace Server.Gumps
private int m_X, m_Y;
public GumpImageTileButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param,
int itemID, int hue, int width, int height) : this(x, y, normalID, pressedID, buttonID, type, param, itemID, hue,
width, height, -1)
{
}
public GumpImageTileButton(int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param,
int itemID, int hue, int width, int height, int localizedTooltip)
int itemID, int hue, int width, int height, int localizedTooltip = -1)
{
m_X = x;
m_Y = y;
@ -175,4 +169,4 @@ namespace Server.Gumps
}
}
}
}
}

View file

@ -30,11 +30,7 @@ namespace Server.Gumps
private int m_ItemID;
private int m_X, m_Y;
public GumpItem(int x, int y, int itemID) : this(x, y, itemID, 0)
{
}
public GumpItem(int x, int y, int itemID, int hue)
public GumpItem(int x, int y, int itemID, int hue = 0)
{
m_X = x;
m_Y = y;
@ -68,9 +64,8 @@ namespace Server.Gumps
public override string Compile(NetState ns)
{
if (m_Hue == 0)
return $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}";
return $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}";
return m_Hue == 0 ? $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}" :
$"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}";
}
public override void AppendTo(NetState ns, IGumpWriter disp)
@ -84,4 +79,4 @@ namespace Server.Gumps
disp.AppendLayout(m_Hue);
}
}
}
}

View file

@ -32,7 +32,7 @@ namespace Server.Gumps
private int m_Width, m_Height;
private int m_X, m_Y;
public GumpTextEntryLimited(int x, int y, int width, int height, int hue, int entryID, string initialText, int size)
public GumpTextEntryLimited(int x, int y, int width, int height, int hue, int entryID, string initialText, int size = 0)
{
m_X = x;
m_Y = y;
@ -113,4 +113,4 @@ namespace Server.Gumps
disp.TextEntries++;
}
}
}
}