Client.Common - remove various redundant codez

This commit is contained in:
adelikat 2017-05-10 13:37:04 -05:00
parent f942a409d7
commit 429b066955
15 changed files with 59 additions and 69 deletions

View File

@ -200,7 +200,7 @@ namespace BizHawk.Client.Common
private long _total; // bytes written so far private long _total; // bytes written so far
public WStream(RangBuffer r) public WStream(RangBuffer r)
{ {
this._r = r; _r = r;
} }
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)
@ -260,7 +260,7 @@ namespace BizHawk.Client.Common
private long _total; // bytes read so far private long _total; // bytes read so far
public RStream(RangBuffer r) public RStream(RangBuffer r)
{ {
this._r = r; _r = r;
} }
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)

View File

@ -8,9 +8,6 @@ namespace BizHawk.Client.Common
{ {
public class LuaDocumentation : List<LibraryFunction> public class LuaDocumentation : List<LibraryFunction>
{ {
public LuaDocumentation()
: base() { }
public string ToTASVideosWikiMarkup() public string ToTASVideosWikiMarkup()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.Common
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
this.Sort(); Sort();
ForEach(subtitle => sb.AppendLine(subtitle.ToString())); ForEach(subtitle => sb.AppendLine(subtitle.ToString()));
return sb.ToString(); return sb.ToString();
} }
@ -67,7 +67,7 @@ namespace BizHawk.Client.Common
public new void Sort() public new void Sort()
{ {
this.Sort((x, y) => Sort((x, y) =>
{ {
int result = x.Frame.CompareTo(y.Frame); int result = x.Frame.CompareTo(y.Frame);
return result != 0 ? result : x.Y.CompareTo(y.Y); return result != 0 ? result : x.Y.CompareTo(y.Y);

View File

@ -169,7 +169,7 @@ namespace BizHawk.Client.Common
{ {
if (def.BoolButtons.Contains(key)) if (def.BoolButtons.Contains(key))
{ {
this.MyBoolButtons[key] = trimmed[iterator] != '.'; MyBoolButtons[key] = trimmed[iterator] != '.';
iterator++; iterator++;
} }
else if (def.FloatControls.Contains(key)) else if (def.FloatControls.Contains(key))

View File

@ -9,7 +9,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
return this.ContainsKey(key) ? base[key] : ""; return ContainsKey(key) ? base[key] : "";
} }
set set

View File

@ -264,7 +264,7 @@ namespace BizHawk.Client.Common
private bool IsGenesis6Button() private bool IsGenesis6Button()
{ {
return this.Definition.BoolButtons.Contains("P1 X"); return Definition.BoolButtons.Contains("P1 X");
} }
private void Force(string button, bool state) private void Force(string button, bool state)

View File

@ -128,7 +128,7 @@ namespace BizHawk.Client.Common
{ {
get get
{ {
return this.ContainsKey(key) ? base[key] : ""; return ContainsKey(key) ? base[key] : "";
} }
set set
@ -176,7 +176,7 @@ namespace BizHawk.Client.Common
{ {
var splitLine = line.Split(new[] { ' ' }, 2); var splitLine = line.Split(new[] { ' ' }, 2);
if (HeaderKeys.Contains(splitLine[0]) && !this.ContainsKey(splitLine[0])) if (HeaderKeys.Contains(splitLine[0]) && !ContainsKey(splitLine[0]))
{ {
Add(splitLine[0], splitLine[1]); Add(splitLine[0], splitLine[1]);
} }

View File

@ -289,7 +289,7 @@ namespace BizHawk.Client.Common
if ((controlState & 0xFC) != 0) if ((controlState & 0xFC) != 0)
{ {
Result.Warnings.Add("Ignored toggle hack flag on frame " + frame.ToString()); Result.Warnings.Add("Ignored toggle hack flag on frame " + frame);
} }
movie.AppendFrame(controllers); movie.AppendFrame(controllers);
@ -422,7 +422,7 @@ namespace BizHawk.Client.Common
if ((controlState & 0xFC) != 0) if ((controlState & 0xFC) != 0)
{ {
Result.Warnings.Add("Ignored toggle hack flag on frame " + frame.ToString()); Result.Warnings.Add("Ignored toggle hack flag on frame " + frame);
} }
// Each controller is terminated with a pipeline. // Each controller is terminated with a pipeline.

View File

@ -379,7 +379,7 @@ namespace BizHawk.Client.Common
if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting. if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
{ {
this.SwitchToPlay(); SwitchToPlay();
} }
} }
@ -409,7 +409,7 @@ namespace BizHawk.Client.Common
if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting. if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
{ {
this.SwitchToPlay(); SwitchToPlay();
} }
} }

View File

@ -267,7 +267,7 @@ namespace BizHawk.Client.Common
} }
// Movie should always have a state at frame 0. // Movie should always have a state at frame 0.
if (!this.StartsFromSavestate && Global.Emulator.Frame == 0) if (!StartsFromSavestate && Global.Emulator.Frame == 0)
StateManager.Capture(); StateManager.Capture();
} }
} }

View File

@ -224,11 +224,6 @@ namespace BizHawk.Client.Common
} }
} }
public override IController GetInputState(int frame)
{
return base.GetInputState(frame);
}
public void GreenzoneCurrentFrame() public void GreenzoneCurrentFrame()
{ {
if (Global.Emulator.Frame > LastValidFrame) if (Global.Emulator.Frame > LastValidFrame)

View File

@ -39,7 +39,7 @@ namespace BizHawk.Client.Common
public override int GetHashCode() public override int GetHashCode()
{ {
return this.Frame.GetHashCode(); return Frame.GetHashCode();
} }
public override bool Equals(object obj) public override bool Equals(object obj)
@ -50,7 +50,7 @@ namespace BizHawk.Client.Common
} }
else if (obj is TasMovieMarker) else if (obj is TasMovieMarker)
{ {
return this.Frame == (obj as TasMovieMarker).Frame; return Frame == (obj as TasMovieMarker).Frame;
} }
else else
{ {
@ -81,7 +81,7 @@ namespace BizHawk.Client.Common
public TasMovieMarkerList DeepClone() public TasMovieMarkerList DeepClone()
{ {
TasMovieMarkerList ret = new TasMovieMarkerList(_movie); TasMovieMarkerList ret = new TasMovieMarkerList(_movie);
for (int i = 0; i < this.Count; i++) for (int i = 0; i < Count; i++)
ret.Add(new TasMovieMarker(this[i].Frame, this[i].Message)); ret.Add(new TasMovieMarker(this[i].Frame, this[i].Message));
return ret; return ret;
@ -133,7 +133,7 @@ namespace BizHawk.Client.Common
if (!fromHistory) if (!fromHistory)
_movie.ChangeLog.AddMarkerChange(item); _movie.ChangeLog.AddMarkerChange(item);
base.Add(item); base.Add(item);
this.Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame)); Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame));
OnListChanged(NotifyCollectionChangedAction.Add); OnListChanged(NotifyCollectionChangedAction.Add);
} }
} }
@ -165,7 +165,7 @@ namespace BizHawk.Client.Common
if (!fromHistory) if (!fromHistory)
_movie.ChangeLog.AddMarkerChange(item); _movie.ChangeLog.AddMarkerChange(item);
base.Insert(index, item); base.Insert(index, item);
this.Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame)); Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame));
OnListChanged(NotifyCollectionChangedAction.Add); OnListChanged(NotifyCollectionChangedAction.Add);
} }
@ -178,7 +178,7 @@ namespace BizHawk.Client.Common
_movie.ChangeLog.EndBatch(); _movie.ChangeLog.EndBatch();
base.InsertRange(index, collection); base.InsertRange(index, collection);
this.Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame)); Sort((m1, m2) => m1.Frame.CompareTo(m2.Frame));
OnListChanged(NotifyCollectionChangedAction.Add); OnListChanged(NotifyCollectionChangedAction.Add);
} }
@ -284,7 +284,7 @@ namespace BizHawk.Client.Common
public int FindIndex(string markerName) public int FindIndex(string markerName)
{ {
return this.FindIndex(m => m.Message == markerName); return FindIndex(m => m.Message == markerName);
} }
public bool IsMarker(int frame) public bool IsMarker(int frame)

View File

@ -48,18 +48,16 @@ namespace BizHawk.Client.Common
{ {
if (IsDiplayTypeAvailable(type)) if (IsDiplayTypeAvailable(type))
{ {
this._domain = domain; _domain = domain;
this._address = address; _address = address;
this._size = size; _size = size;
this._type = type; _type = type;
this._bigEndian = bigEndian; _bigEndian = bigEndian;
this._notes = note; _notes = note;
return;
} }
else else
{ {
throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", type.ToString()), nameof(type)); throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", type), nameof(type));
} }
} }
@ -67,7 +65,7 @@ namespace BizHawk.Client.Common
#region Methods #region Methods
#region Static #region Static
/// <summary> /// <summary>
/// Generate sa <see cref="Watch"/> from a given string /// Generate sa <see cref="Watch"/> from a given string
@ -214,14 +212,13 @@ namespace BizHawk.Client.Common
{ {
return false; return false;
} }
else if (object.ReferenceEquals(a, b))
if (object.ReferenceEquals(a, b))
{ {
return true; return true;
} }
else
{ return a.Equals(b);
return a.Equals(b);
}
} }
/// <summary> /// <summary>
@ -236,14 +233,13 @@ namespace BizHawk.Client.Common
{ {
return false; return false;
} }
else if (object.ReferenceEquals(a, b))
if (object.ReferenceEquals(a, b))
{ {
return true; return true;
} }
else
{ return a.Equals(b);
return a.Equals(b);
}
} }
/// <summary> /// <summary>
@ -451,9 +447,9 @@ namespace BizHawk.Client.Common
} }
else else
{ {
return this._domain == other._domain && return _domain == other._domain &&
this._address == other._address && _address == other._address &&
this._size == other._size; _size == other._size;
} }
} }
@ -469,9 +465,9 @@ namespace BizHawk.Client.Common
public bool Equals(Cheat other) public bool Equals(Cheat other)
{ {
return !object.ReferenceEquals(other, null) && return !object.ReferenceEquals(other, null) &&
this._domain == other.Domain && _domain == other.Domain &&
this._address == other.Address && _address == other.Address &&
this._size == other.Size; _size == other.Size;
} }
#endregion IEquatable<Cheat> #endregion IEquatable<Cheat>
@ -487,27 +483,27 @@ namespace BizHawk.Client.Common
/// <exception cref="InvalidOperationException">Occurs when you try to compare two <see cref="Watch"/> throughout different <see cref="MemoryDomain"/></exception> /// <exception cref="InvalidOperationException">Occurs when you try to compare two <see cref="Watch"/> throughout different <see cref="MemoryDomain"/></exception>
public int CompareTo(Watch other) public int CompareTo(Watch other)
{ {
if (this._domain != other._domain) if (_domain != other._domain)
{ {
throw new InvalidOperationException("Watch cannot be compared through different domain"); throw new InvalidOperationException("Watch cannot be compared through different domain");
} }
if (this.Equals(other)) if (Equals(other))
{ {
return 0; return 0;
} }
else if (object.ReferenceEquals(other, null))
if (object.ReferenceEquals(other, null))
{ {
return 1; return 1;
} }
else if (_address.Equals(other._address))
if (_address.Equals(other._address))
{ {
return ((int)_size).CompareTo((int)other._size); return ((int)_size).CompareTo((int)other._size);
} }
else
{ return _address.CompareTo(other._address);
return _address.CompareTo(other._address);
}
} }
#endregion IComparable<Watch> #endregion IComparable<Watch>
@ -538,7 +534,7 @@ namespace BizHawk.Client.Common
/// <returns><see cref="int"/> that can serves as a unique representation of current Watch</returns> /// <returns><see cref="int"/> that can serves as a unique representation of current Watch</returns>
public override int GetHashCode() public override int GetHashCode()
{ {
return this.Domain.GetHashCode() + (int)(this.Address); return Domain.GetHashCode() + (int)(Address);
} }
/// <summary> /// <summary>
@ -690,7 +686,7 @@ namespace BizHawk.Client.Common
} }
else else
{ {
throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", value.ToString())); throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", value));
} }
} }
} }
@ -704,6 +700,7 @@ namespace BizHawk.Client.Common
{ {
return _domain; return _domain;
} }
internal set internal set
{ {
if (value != null && _domain.Name == value.Name) if (value != null && _domain.Name == value.Name)

View File

@ -40,14 +40,14 @@ namespace BizHawk.Client.Common
{ {
if (value == 0) if (value == 0)
{ {
this._value = GetWord(); _value = GetWord();
} }
else else
{ {
this._value = value; _value = value;
} }
this._previous = previous; _previous = previous;
this._changecount = changeCount; _changecount = changeCount;
} }
#endregion #endregion

View File

@ -61,6 +61,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGB/@EntryIndexedValue">SGB</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGB/@EntryIndexedValue">SGB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SGX/@EntryIndexedValue">SGX</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SNES/@EntryIndexedValue">SNES</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TAS/@EntryIndexedValue">TAS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TI/@EntryIndexedValue">TI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TIA/@EntryIndexedValue">TIA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TIA/@EntryIndexedValue">TIA</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VBA/@EntryIndexedValue">VBA</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VBA/@EntryIndexedValue">VBA</s:String>