Skip to content

Commit a2d78c9

Browse files
committed
Overhauled Subrecord T4 generation to make later changes easier, can be expanded to other T4 generation
Work toward a universal TemplateClass and TemplateField instead of piecewise implementations
1 parent c31fbb8 commit a2d78c9

344 files changed

Lines changed: 18673 additions & 6103 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ESPSharp/DataTypes/Comparison.cs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace ESPSharp.DataTypes
1616
{
17-
public class Comparison : IESPSerializable, ICloneable<Comparison>, IReferenceContainer
17+
public class Comparison : IESPSerializable, ICloneable<Comparison>, IComparable<Comparison>, IEquatable<Comparison>, IReferenceContainer
1818
{
1919
public ConditionFlags Flags { get; set; }
2020
public ConditionComparisonType Operator { get; set; }
@@ -133,5 +133,62 @@ public Comparison Clone()
133133
{
134134
return new Comparison(this);
135135
}
136+
137+
public int CompareTo(Comparison other)
138+
{
139+
return Operator.CompareTo(other.Operator);
140+
}
141+
142+
public static bool operator >(Comparison objA, Comparison objB)
143+
{
144+
return objA.CompareTo(objB) > 0;
145+
}
146+
147+
public static bool operator >=(Comparison objA, Comparison objB)
148+
{
149+
return objA.CompareTo(objB) >= 0;
150+
}
151+
152+
public static bool operator <(Comparison objA, Comparison objB)
153+
{
154+
return objA.CompareTo(objB) < 0;
155+
}
156+
157+
public static bool operator <=(Comparison objA, Comparison objB)
158+
{
159+
return objA.CompareTo(objB) <= 0;
160+
}
161+
162+
public bool Equals(Comparison other)
163+
{
164+
return Flags == other.Flags &&
165+
Operator == other.Operator &&
166+
Unused == other.Unused &&
167+
ComparisonValue == other.ComparisonValue;
168+
}
169+
170+
public override bool Equals(object obj)
171+
{
172+
Comparison other = obj as Comparison;
173+
if (other == null)
174+
return false;
175+
else
176+
return Equals(other);
177+
}
178+
179+
public override int GetHashCode()
180+
{
181+
return Operator.GetHashCode();
182+
}
183+
184+
public static bool operator ==(Comparison objA, Comparison objB)
185+
{
186+
return objA.Equals(objB);
187+
}
188+
189+
public static bool operator !=(Comparison objA, Comparison objB)
190+
{
191+
return !objA.Equals(objB);
192+
}
136193
}
137194
}

ESPSharp/DataTypes/DateStamp.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.IO;
7+
using System.Xml.Linq;
8+
using ESPSharp.Enums;
9+
using ESPSharp.Enums.Flags;
10+
using ESPSharp.Interfaces;
11+
using ESPSharp.Subrecords;
12+
using ESPSharp.SubrecordCollections;
13+
using ESPSharp.DataTypes;
14+
15+
namespace ESPSharp.DataTypes
16+
{
17+
public partial class DateStamp : IESPSerializable, ICloneable<DateStamp>
18+
{
19+
public static DateStamp Now
20+
{
21+
get
22+
{
23+
DateStamp now = new DateStamp();
24+
now.DayOfMonth = (byte)DateTime.Now.Day;
25+
now.MonthsSince2001 = GetMonthsSince2001();
26+
27+
return now;
28+
}
29+
}
30+
31+
private static byte GetMonthsSince2001()
32+
{
33+
int years = DateTime.Now.Year - 2001;
34+
int months = DateTime.Now.Month + years*12;
35+
36+
return (byte)months;
37+
}
38+
}
39+
}

ESPSharp/DataTypes/Function.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace ESPSharp.DataTypes
1616
{
17-
public class Function : IESPSerializable, ICloneable<Function>, IReferenceContainer
17+
public class Function : IESPSerializable, ICloneable<Function>, IComparable<Function>, IEquatable<Function>, IReferenceContainer
1818
{
1919
#region Dictionary
2020
private static Dictionary<FunctionType, TypeStringArgData> Metadata = new Dictionary<FunctionType, TypeStringArgData>()
@@ -506,5 +506,65 @@ public Function Clone()
506506
{
507507
return new Function(this);
508508
}
509+
510+
public int CompareTo(Function other)
511+
{
512+
return Type.CompareTo(other.Type);
513+
}
514+
515+
public static bool operator >(Function objA, Function objB)
516+
{
517+
return objA.CompareTo(objB) > 0;
518+
}
519+
520+
public static bool operator >=(Function objA, Function objB)
521+
{
522+
return objA.CompareTo(objB) >= 0;
523+
}
524+
525+
public static bool operator <(Function objA, Function objB)
526+
{
527+
return objA.CompareTo(objB) < 0;
528+
}
529+
530+
public static bool operator <=(Function objA, Function objB)
531+
{
532+
return objA.CompareTo(objB) <= 0;
533+
}
534+
535+
public bool Equals(Function other)
536+
{
537+
return Type == other.Type &&
538+
Argument1 == other.Argument1 &&
539+
Arg1Label == other.Arg1Label &&
540+
Arg1Type == other.Arg1Type &&
541+
Argument2 == other.Argument2 &&
542+
Arg2Label == other.Arg2Label &&
543+
Arg2Type == other.Arg2Type;
544+
}
545+
546+
public override bool Equals(object obj)
547+
{
548+
Function other = obj as Function;
549+
if (other == null)
550+
return false;
551+
else
552+
return Equals(other);
553+
}
554+
555+
public override int GetHashCode()
556+
{
557+
return Type.GetHashCode();
558+
}
559+
560+
public static bool operator ==(Function objA, Function objB)
561+
{
562+
return objA.Equals(objB);
563+
}
564+
565+
public static bool operator !=(Function objA, Function objB)
566+
{
567+
return !objA.Equals(objB);
568+
}
509569
}
510570
}

ESPSharp/DataTypes/GeneratedCode/AlternateTexture.cs

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace ESPSharp.DataTypes
1616
{
17-
public partial class AlternateTexture : IESPSerializable, ICloneable<AlternateTexture>, IReferenceContainer
17+
public partial class AlternateTexture : IESPSerializable, ICloneable<AlternateTexture>, IComparable<AlternateTexture>, IEquatable<AlternateTexture>, IReferenceContainer
1818
{
1919
public String Name { get; set; }
2020
public FormID TextureSet { get; set; }
@@ -92,13 +92,69 @@ public void ReadXML(XElement ele, ElderScrollsPlugin master)
9292
}
9393
}
9494

95-
partial void ReadData(ESPReader reader);
96-
97-
partial void WriteData(ESPWriter writer);
98-
9995
public AlternateTexture Clone()
10096
{
10197
return new AlternateTexture(this);
10298
}
99+
100+
public int CompareTo(AlternateTexture other)
101+
{
102+
return Index.CompareTo(other.Index);
103+
}
104+
105+
public static bool operator >(AlternateTexture objA, AlternateTexture objB)
106+
{
107+
return objA.CompareTo(objB) > 0;
108+
}
109+
110+
public static bool operator >=(AlternateTexture objA, AlternateTexture objB)
111+
{
112+
return objA.CompareTo(objB) >= 0;
113+
}
114+
115+
public static bool operator <(AlternateTexture objA, AlternateTexture objB)
116+
{
117+
return objA.CompareTo(objB) < 0;
118+
}
119+
120+
public static bool operator <=(AlternateTexture objA, AlternateTexture objB)
121+
{
122+
return objA.CompareTo(objB) <= 0;
123+
}
124+
125+
public bool Equals(AlternateTexture other)
126+
{
127+
return Name == other.Name &&
128+
TextureSet == other.TextureSet &&
129+
Index == other.Index;
130+
}
131+
132+
public override bool Equals(object obj)
133+
{
134+
AlternateTexture other = obj as AlternateTexture;
135+
if (other == null)
136+
return false;
137+
else
138+
return Equals(other);
139+
}
140+
141+
public override int GetHashCode()
142+
{
143+
return Index.GetHashCode();
144+
}
145+
146+
public static bool operator ==(AlternateTexture objA, AlternateTexture objB)
147+
{
148+
return objA.Equals(objB);
149+
}
150+
151+
public static bool operator !=(AlternateTexture objA, AlternateTexture objB)
152+
{
153+
return !objA.Equals(objB);
154+
}
155+
156+
partial void ReadData(ESPReader reader);
157+
158+
partial void WriteData(ESPWriter writer);
103159
}
104160
}

ESPSharp/DataTypes/GeneratedCode/AlternateTexture.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"Index",
3131
"Index"
3232
);
33+
template.hashKey = tempField;
3334
template.Fields.Add(tempField);
3435
#>
3536
<#@ include file="DataTypeTemplate.t4" once="true" #>

ESPSharp/DataTypes/GeneratedCode/Color.cs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace ESPSharp.DataTypes
1616
{
17-
public partial class Color : IESPSerializable, ICloneable<Color>
17+
public partial class Color : IESPSerializable, ICloneable<Color>, IComparable<Color>, IEquatable<Color>
1818
{
1919
public Byte Red { get; set; }
2020
public Byte Green { get; set; }
@@ -114,5 +114,62 @@ public Color Clone()
114114
{
115115
return new Color(this);
116116
}
117+
118+
public int CompareTo(Color other)
119+
{
120+
return Red.CompareTo(other.Red);
121+
}
122+
123+
public static bool operator >(Color objA, Color objB)
124+
{
125+
return objA.CompareTo(objB) > 0;
126+
}
127+
128+
public static bool operator >=(Color objA, Color objB)
129+
{
130+
return objA.CompareTo(objB) >= 0;
131+
}
132+
133+
public static bool operator <(Color objA, Color objB)
134+
{
135+
return objA.CompareTo(objB) < 0;
136+
}
137+
138+
public static bool operator <=(Color objA, Color objB)
139+
{
140+
return objA.CompareTo(objB) <= 0;
141+
}
142+
143+
public bool Equals(Color other)
144+
{
145+
return Red == other.Red &&
146+
Green == other.Green &&
147+
Blue == other.Blue &&
148+
Alpha_Unused == other.Alpha_Unused;
149+
}
150+
151+
public override bool Equals(object obj)
152+
{
153+
Color other = obj as Color;
154+
if (other == null)
155+
return false;
156+
else
157+
return Equals(other);
158+
}
159+
160+
public override int GetHashCode()
161+
{
162+
return Red.GetHashCode();
163+
}
164+
165+
public static bool operator ==(Color objA, Color objB)
166+
{
167+
return objA.Equals(objB);
168+
}
169+
170+
public static bool operator !=(Color objA, Color objB)
171+
{
172+
return !objA.Equals(objB);
173+
}
117174
}
118175
}

ESPSharp/DataTypes/GeneratedCode/Color.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"Red",
1313
"Red"
1414
);
15+
template.hashKey = tempField;
1516
template.Fields.Add(tempField);
1617

1718
tempField =

0 commit comments

Comments
 (0)