Skip to content

Commit

Permalink
Modified sorting code to allow for layered sorting
Browse files Browse the repository at this point in the history
Finalized everything
Perfect read write xml and binary
Sorting for everything that needs it
  • Loading branch information
CGarrison89 committed Jul 22, 2015
1 parent f095ca1 commit deda3c5
Show file tree
Hide file tree
Showing 225 changed files with 910 additions and 391 deletions.
12 changes: 10 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/AlternateTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,16 @@ public object Clone()

public int CompareTo(AlternateTexture other)
{
return Index.CompareTo(other.Index);
}
int result = 0;

if (result == 0 && Name != null && other.Name != null)
result = Name.CompareTo(other.Name);

if (result == 0 && Index != null && other.Index != null)
result = Index.CompareTo(other.Index);

return result;
}

public static bool operator >(AlternateTexture objA, AlternateTexture objB)
{
Expand Down
4 changes: 2 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/AlternateTexture.tt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<#
ClassTemplate template = new ClassTemplate();
template.ClassName = "AlternateTexture";
//template.implementReadData = false;
//template.implementWriteData = false;

ClassField tempField;

Expand All @@ -12,6 +10,7 @@
"Name",
"Name"
);
tempField.sortIndex = 0;
tempField.implementReadData = false;
tempField.implementWriteData = false;
template.Fields.Add(tempField);
Expand All @@ -30,6 +29,7 @@
"Index",
"Index"
);
tempField.sortIndex = 1;
template.hashKey = tempField;
template.Fields.Add(tempField);
#>
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ public object Clone()

public int CompareTo(Color other)
{
return Red.CompareTo(other.Red);
}
int result = 0;

return result;
}

public static bool operator >(Color objA, Color objB)
{
Expand Down
11 changes: 9 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/DataTypeTemplate.t4
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ namespace ESPSharp.DataTypes
<# if(template.isComparable) { #>
public int CompareTo(<#= template.ClassName #> other)
{
<# WriteCompareHashKeyCommand(template); #>
}
int result = 0;
<# foreach (var field in template.Fields.Where(f => f.sortIndex >= 0).OrderBy(o => o.sortIndex)) { #>

if (result == 0 && <#= field.Name#> != null && other.<#= field.Name#> != null)
<# WriteCompareCommand(field); #>
<# } #>

return result;
}

public static bool operator >(<#= template.ClassName #> objA, <#= template.ClassName #> objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/DateStamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public object Clone()

public int CompareTo(DateStamp other)
{
return MonthsSince2001.CompareTo(other.MonthsSince2001);
}
int result = 0;

return result;
}

public static bool operator >(DateStamp objA, DateStamp objB)
{
Expand Down
9 changes: 7 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/FormID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ public object Clone()

public int CompareTo(FormID other)
{
return RawValue.CompareTo(other.RawValue);
}
int result = 0;

if (result == 0 && RawValue != null && other.RawValue != null)
result = RawValue.CompareTo(other.RawValue);

return result;
}

public static bool operator >(FormID objA, FormID objB)
{
Expand Down
1 change: 1 addition & 0 deletions ESPSharp/DataTypes/GeneratedCode/FormID.tt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
tempField.implementReadXML = false;
tempField.implementWriteXML = false;
template.hashKey = tempField;
tempField.sortIndex = 0;
tempField.isReadOnly = true;
template.Fields.Add(tempField);
#>
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/IMADTimeColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ public object Clone()

public int CompareTo(IMADTimeColor other)
{
return Time.CompareTo(other.Time);
}
int result = 0;

return result;
}

public static bool operator >(IMADTimeColor objA, IMADTimeColor objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/IMADTimeValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public object Clone()

public int CompareTo(IMADTimeValue other)
{
return Time.CompareTo(other.Time);
}
int result = 0;

return result;
}

public static bool operator >(IMADTimeValue objA, IMADTimeValue objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/NavMeshDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ public object Clone()

public int CompareTo(NavMeshDoor other)
{
return Door.CompareTo(other.Door);
}
int result = 0;

return result;
}

public static bool operator >(NavMeshDoor objA, NavMeshDoor objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/NavMeshExternalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ public object Clone()

public int CompareTo(NavMeshExternalConnection other)
{
return NavigationMesh.CompareTo(other.NavigationMesh);
}
int result = 0;

return result;
}

public static bool operator >(NavMeshExternalConnection objA, NavMeshExternalConnection objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/NavMeshTriangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ public object Clone()

public int CompareTo(NavMeshTriangle other)
{
return Vertex1.CompareTo(other.Vertex1);
}
int result = 0;

return result;
}

public static bool operator >(NavMeshTriangle objA, NavMeshTriangle objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/RegionGrass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public object Clone()

public int CompareTo(RegionGrass other)
{
return Form.CompareTo(other.Form);
}
int result = 0;

return result;
}

public static bool operator >(RegionGrass objA, RegionGrass objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/RegionObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ public object Clone()

public int CompareTo(RegionObject other)
{
return Object.CompareTo(other.Object);
}
int result = 0;

return result;
}

public static bool operator >(RegionObject objA, RegionObject objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/RegionSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ public object Clone()

public int CompareTo(RegionSound other)
{
return Sound.CompareTo(other.Sound);
}
int result = 0;

return result;
}

public static bool operator >(RegionSound objA, RegionSound objB)
{
Expand Down
27 changes: 25 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/StaticPlacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,31 @@ public object Clone()

public int CompareTo(StaticPlacement other)
{
return PositionX.CompareTo(other.PositionX);
}
int result = 0;

if (result == 0 && PositionZ != null && other.PositionZ != null)
result = PositionZ.CompareTo(other.PositionZ);

if (result == 0 && PositionX != null && other.PositionX != null)
result = PositionX.CompareTo(other.PositionX);

if (result == 0 && PositionY != null && other.PositionY != null)
result = PositionY.CompareTo(other.PositionY);

if (result == 0 && RotationX != null && other.RotationX != null)
result = RotationX.CompareTo(other.RotationX);

if (result == 0 && RotationY != null && other.RotationY != null)
result = RotationY.CompareTo(other.RotationY);

if (result == 0 && RotationZ != null && other.RotationZ != null)
result = RotationZ.CompareTo(other.RotationZ);

if (result == 0 && Scale != null && other.Scale != null)
result = Scale.CompareTo(other.Scale);

return result;
}

public static bool operator >(StaticPlacement objA, StaticPlacement objB)
{
Expand Down
7 changes: 7 additions & 0 deletions ESPSharp/DataTypes/GeneratedCode/StaticPlacement.tt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"PositionX",
"Position/X"
);
tempField.sortIndex = 1;
template.hashKey = tempField;
template.Fields.Add(tempField);

Expand All @@ -19,6 +20,7 @@
"PositionY",
"Position/Y"
);
tempField.sortIndex = 2;
template.Fields.Add(tempField);

tempField =
Expand All @@ -27,6 +29,7 @@
"PositionZ",
"Position/Z"
);
tempField.sortIndex = 0;
template.Fields.Add(tempField);

tempField =
Expand All @@ -35,6 +38,7 @@
"RotationX",
"Rotation/X"
);
tempField.sortIndex = 3;
template.Fields.Add(tempField);

tempField =
Expand All @@ -43,6 +47,7 @@
"RotationY",
"Rotation/Y"
);
tempField.sortIndex = 4;
template.Fields.Add(tempField);

tempField =
Expand All @@ -51,6 +56,7 @@
"RotationZ",
"Rotation/Z"
);
tempField.sortIndex = 5;
template.Fields.Add(tempField);

tempField =
Expand All @@ -59,6 +65,7 @@
"Scale",
"Scale"
);
tempField.sortIndex = 6;
template.Fields.Add(tempField);
#>
<#@ include file="DataTypeTemplate.t4" once="true" #>
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/TimeOfDayColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ public object Clone()

public int CompareTo(TimeOfDayColors other)
{
return Sunrise.CompareTo(other.Sunrise);
}
int result = 0;

return result;
}

public static bool operator >(TimeOfDayColors objA, TimeOfDayColors objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/WeatherChance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public object Clone()

public int CompareTo(WeatherChance other)
{
return Weather.CompareTo(other.Weather);
}
int result = 0;

return result;
}

public static bool operator >(WeatherChance objA, WeatherChance objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/XYFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public object Clone()

public int CompareTo(XYFloat other)
{
return X.CompareTo(other.X);
}
int result = 0;

return result;
}

public static bool operator >(XYFloat objA, XYFloat objB)
{
Expand Down
6 changes: 4 additions & 2 deletions ESPSharp/DataTypes/GeneratedCode/XYZFloat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ public object Clone()

public int CompareTo(XYZFloat other)
{
return X.CompareTo(other.X);
}
int result = 0;

return result;
}

public static bool operator >(XYZFloat objA, XYZFloat objB)
{
Expand Down
4 changes: 4 additions & 0 deletions ESPSharp/Records/GeneratedCode/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ public override void WriteData(ESPWriter writer)
if (BaseStats != null)
BaseStats.WriteBinary(writer);
if (Factions != null)
{
Factions.Sort();
foreach (var item in Factions)
item.WriteBinary(writer);
}
if (DeathItem != null)
DeathItem.WriteBinary(writer);
if (VoiceType != null)
Expand Down Expand Up @@ -458,6 +461,7 @@ public override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
ele.TryPathTo("Factions", true, out subEle);
List<string> xmlNames = new List<string>{"Faction"};
int i = 0;
Factions.Sort();
foreach (var entry in Factions)
{
i = i % xmlNames.Count();
Expand Down
1 change: 1 addition & 0 deletions ESPSharp/Records/GeneratedCode/Creature.tt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"Factions",
"Factions"
);
tempField.isSorted = true;
tempField.XMLSubNames = new List<string>{"Faction"};
template.Fields.Add(tempField);

Expand Down
Loading

0 comments on commit deda3c5

Please sign in to comment.