Skip to content

Commit ed61063

Browse files
committed
Switched over to using Text Templating to set up records, subrecords, and subrecord collections
Updated namespaces on most classes Implemented menu icons and classes
1 parent d3d5304 commit ed61063

61 files changed

Lines changed: 3216 additions & 633 deletions

Some content is hidden

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

ESPSharp/ESPReader.cs

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,62 +26,30 @@ public string PeekTag()
2626
return peek;
2727
}
2828

29-
public string ReadNullTermString(int length)
29+
public T ReadEnum<T>()
3030
{
31-
string outString = new string(ReadChars(length - 1));
32-
ReadByte();
33-
return outString;
34-
}
35-
36-
public T ReadSimpleSubrecord<T>()
37-
{
38-
string Tag = ReadTag();
39-
int size = ReadUInt16();
40-
41-
string typeT = typeof(T).ToString();
31+
Type enumType = Enum.GetUnderlyingType(typeof(T));
4232

43-
switch (typeT)
33+
switch (enumType.FullName)
4434
{
4535
case "System.Byte":
46-
Debug.Assert(size == 1);
4736
return (T)(object)ReadByte();
4837
case "System.SByte":
49-
Debug.Assert(size == 1);
5038
return (T)(object)ReadSByte();
51-
case "System.Char":
52-
Debug.Assert(size == 1);
53-
return (T)(object)ReadChar();
5439
case "System.UInt16":
55-
Debug.Assert(size == 2);
5640
return (T)(object)ReadUInt16();
5741
case "System.Int16":
58-
Debug.Assert(size == 2);
5942
return (T)(object)ReadInt16();
6043
case "System.UInt32":
61-
Debug.Assert(size == 4);
6244
return (T)(object)ReadUInt32();
6345
case "System.Int32":
64-
Debug.Assert(size == 4);
6546
return (T)(object)ReadInt32();
66-
case "System.Single":
67-
Debug.Assert(size == 4);
68-
return (T)(object)ReadSingle();
6947
case "System.UInt64":
70-
Debug.Assert(size == 8);
7148
return (T)(object)ReadUInt64();
7249
case "System.Int64":
73-
Debug.Assert(size == 8);
7450
return (T)(object)ReadInt64();
75-
case "System.Byte[]":
76-
return (T)(object)ReadBytes(size);
77-
case "System.Char[]":
78-
return (T)(object)ReadChars(size);
79-
case "System.String":
80-
string outString = new String(ReadChars(size - 1));
81-
ReadByte();
82-
return (T)(object)outString;
8351
default:
84-
throw new NotImplementedException(typeT + " is not yet implemented.");
52+
throw new NotImplementedException(enumType + " is not yet implemented.");
8553
}
8654
}
8755
}

ESPSharp/ESPSharp.csproj

Lines changed: 98 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
<Reference Include="System.Xml" />
4343
</ItemGroup>
4444
<ItemGroup>
45-
<Compile Include="EnumsAndFlags\GameSettingType.cs" />
45+
<Compile Include="Enums\Flags\ActorValues.cs" />
46+
<Compile Include="Enums\Flags\ClassDataFlag.cs" />
47+
<Compile Include="Enums\Flags\ServicesFlag.cs" />
48+
<Compile Include="Enums\Flags\TXSTFlags.cs" />
49+
<Compile Include="Enums\GameSettingType.cs" />
50+
<Compile Include="Enums\GlobalVarType.cs" />
51+
<Compile Include="Enums\Skills.cs" />
4652
<Compile Include="ESPReader.cs" />
4753
<Compile Include="ESPWriter.cs" />
4854
<Compile Include="Groups\CellGroup.cs" />
@@ -53,39 +59,123 @@
5359
<Compile Include="Extensions.cs" />
5460
<Compile Include="Groups\ExteriorCellBlock.cs" />
5561
<Compile Include="Groups\ExteriorCellSubBlock.cs" />
56-
<Compile Include="EnumsAndFlags\GroupType.cs" />
62+
<Compile Include="Enums\GroupType.cs" />
5763
<Compile Include="Groups\InteriorCellBlock.cs" />
5864
<Compile Include="Groups\InteriorCellSubBlock.cs" />
59-
<Compile Include="EnumsAndFlags\RecordFlag.cs" />
65+
<Compile Include="Enums\Flags\RecordFlag.cs" />
6066
<Compile Include="FormID.cs" />
6167
<Compile Include="Group.cs" />
6268
<Compile Include="Interfaces\IEditorID.cs" />
6369
<Compile Include="Interfaces\IReferenceContainer.cs" />
64-
<Compile Include="Records\Header.cs" />
6570
<Compile Include="ISubgroup.cs" />
6671
<Compile Include="Properties\AssemblyInfo.cs" />
6772
<Compile Include="Record.cs" />
6873
<Compile Include="Groups\TopGroup.cs" />
6974
<Compile Include="Groups\TopicGroup.cs" />
7075
<Compile Include="Groups\WorldGroup.cs" />
71-
<Compile Include="Records\GenericRecord.cs" />
7276
<Compile Include="Records\GameSetting.cs" />
73-
<Compile Include="Records\TextureSet.cs" />
77+
<Compile Include="Records\GeneratedCode\Class.cs">
78+
<AutoGen>True</AutoGen>
79+
<DesignTime>True</DesignTime>
80+
<DependentUpon>Class.tt</DependentUpon>
81+
</Compile>
82+
<Compile Include="Records\GeneratedCode\GameSetting.cs">
83+
<AutoGen>True</AutoGen>
84+
<DesignTime>True</DesignTime>
85+
<DependentUpon>GameSetting.tt</DependentUpon>
86+
</Compile>
87+
<Compile Include="Records\GeneratedCode\GlobalVariable.cs">
88+
<AutoGen>True</AutoGen>
89+
<DesignTime>True</DesignTime>
90+
<DependentUpon>GlobalVariable.tt</DependentUpon>
91+
</Compile>
92+
<Compile Include="Records\GeneratedCode\MenuIcon.cs">
93+
<AutoGen>True</AutoGen>
94+
<DesignTime>True</DesignTime>
95+
<DependentUpon>MenuIcon.tt</DependentUpon>
96+
</Compile>
97+
<Compile Include="Records\GenericRecord.cs" />
98+
<Compile Include="Records\GeneratedCode\Header.cs">
99+
<AutoGen>True</AutoGen>
100+
<DesignTime>True</DesignTime>
101+
<DependentUpon>Header.tt</DependentUpon>
102+
</Compile>
103+
<Compile Include="Records\GeneratedCode\TextureSet.cs">
104+
<AutoGen>True</AutoGen>
105+
<DesignTime>True</DesignTime>
106+
<DependentUpon>TextureSet.tt</DependentUpon>
107+
</Compile>
74108
<Compile Include="Subrecord.cs" />
75109
<Compile Include="SubrecordCollection.cs" />
76-
<Compile Include="SubrecordCollection\MasterFileData.cs" />
110+
<Compile Include="SubrecordCollections\GeneratedCode\MasterFileData.cs">
111+
<AutoGen>True</AutoGen>
112+
<DesignTime>True</DesignTime>
113+
<DependentUpon>MasterFileData.tt</DependentUpon>
114+
</Compile>
115+
<Compile Include="Subrecords\Attributes.cs">
116+
<AutoGen>True</AutoGen>
117+
<DesignTime>True</DesignTime>
118+
<DependentUpon>Attributes.tt</DependentUpon>
119+
</Compile>
120+
<Compile Include="Subrecords\ClassData.cs">
121+
<AutoGen>True</AutoGen>
122+
<DesignTime>True</DesignTime>
123+
<DependentUpon>ClassData.tt</DependentUpon>
124+
</Compile>
77125
<Compile Include="Subrecords\DecalData.cs" />
78126
<Compile Include="Subrecords\FormArray.cs" />
79127
<Compile Include="Subrecords\ObjectBounds.cs" />
80128
<Compile Include="Subrecords\PluginHeader.cs" />
129+
<Compile Include="Subrecords\SimpleSubrecord.cs" />
81130
<Compile Include="Subrecords\UndecodedSubrecord.cs" />
82131
<Compile Include="Utility.cs" />
83132
<Compile Include="Zlib.cs" />
84133
</ItemGroup>
85134
<ItemGroup>
86135
<None Include="ClassDiagram.cd" />
136+
<None Include="Records\GeneratedCode\Class.tt">
137+
<Generator>TextTemplatingFileGenerator</Generator>
138+
<LastGenOutput>Class.cs</LastGenOutput>
139+
</None>
140+
<None Include="Records\GeneratedCode\GameSetting.tt">
141+
<Generator>TextTemplatingFileGenerator</Generator>
142+
<LastGenOutput>GameSetting.cs</LastGenOutput>
143+
</None>
144+
<None Include="Records\GeneratedCode\GlobalVariable.tt">
145+
<Generator>TextTemplatingFileGenerator</Generator>
146+
<LastGenOutput>GlobalVariable.cs</LastGenOutput>
147+
</None>
148+
<None Include="Records\GeneratedCode\Header.tt">
149+
<Generator>TextTemplatingFileGenerator</Generator>
150+
<LastGenOutput>Header.cs</LastGenOutput>
151+
</None>
152+
<None Include="Records\GeneratedCode\MenuIcon.tt">
153+
<Generator>TextTemplatingFileGenerator</Generator>
154+
<LastGenOutput>MenuIcon.cs</LastGenOutput>
155+
</None>
156+
<None Include="Records\GeneratedCode\RecordTemplate.t4" />
157+
<None Include="Records\GeneratedCode\TextureSet.tt">
158+
<Generator>TextTemplatingFileGenerator</Generator>
159+
<LastGenOutput>TextureSet.cs</LastGenOutput>
160+
</None>
161+
<None Include="SubrecordCollections\GeneratedCode\MasterFileData.tt">
162+
<Generator>TextTemplatingFileGenerator</Generator>
163+
<LastGenOutput>MasterFileData.cs</LastGenOutput>
164+
</None>
165+
<None Include="SubrecordCollections\GeneratedCode\SubrecordCollectionTemplate.t4" />
166+
<None Include="Subrecords\Attributes.tt">
167+
<Generator>TextTemplatingFileGenerator</Generator>
168+
<LastGenOutput>Attributes.cs</LastGenOutput>
169+
</None>
170+
<None Include="Subrecords\ClassData.tt">
171+
<Generator>TextTemplatingFileGenerator</Generator>
172+
<LastGenOutput>ClassData.cs</LastGenOutput>
173+
</None>
174+
<None Include="Subrecords\SubrecordTemplate.t4" />
175+
</ItemGroup>
176+
<ItemGroup>
177+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
87178
</ItemGroup>
88-
<ItemGroup />
89179
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
90180
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
91181
Other similar extension points exist, see Microsoft.Common.targets.

ESPSharp/ESPWriter.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,5 @@ public void WriteTag(string Tag)
1616
{
1717
Write(Utility.DesanitizeTag(Tag).ToCharArray());
1818
}
19-
20-
public void WriteSimpleSubrecord<T>(T Value, string Tag)
21-
{
22-
string typeT = typeof(T).ToString();
23-
24-
WriteTag(Tag);
25-
26-
switch (typeT)
27-
{
28-
case "System.Byte":
29-
Write((ushort)1);
30-
Write((byte)(object)Value);
31-
break;
32-
case "System.SByte":
33-
Write((ushort)1);
34-
Write((sbyte)(object)Value);
35-
break;
36-
case "System.Char":
37-
Write((ushort)1);
38-
Write((char)(object)Value);
39-
break;
40-
case "System.UInt16":
41-
Write((ushort)2);
42-
Write((ushort)(object)Value);
43-
break;
44-
case "System.Int16":
45-
Write((ushort)2);
46-
Write((short)(object)Value);
47-
break;
48-
case "System.UInt32":
49-
Write((ushort)4);
50-
Write((uint)(object)Value);
51-
break;
52-
case "System.Int32":
53-
Write((ushort)4);
54-
Write((int)(object)Value);
55-
break;
56-
case "System.Single":
57-
Write((ushort)4);
58-
Write((float)(object)Value);
59-
break;
60-
case "System.UInt64":
61-
Write((ushort)8);
62-
Write((ulong)(object)Value);
63-
break;
64-
case "System.Int64":
65-
Write((ushort)8);
66-
Write((long)(object)Value);
67-
break;
68-
case "System.Byte[]":
69-
Write((ushort)((byte[])(object)Value).Length);
70-
Write((byte[])(object)Value);
71-
break;
72-
case "System.Char[]":
73-
Write((ushort)((char[])(object)Value).Length);
74-
Write((char[])(object)Value);
75-
break;
76-
case "System.String":
77-
Write((ushort)(((string)(object)Value).Length + 1));
78-
Write(((string)(object)Value).ToCharArray());
79-
Write((byte)0);
80-
break;
81-
}
82-
}
8319
}
8420
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ESPSharp.Enums
8+
{
9+
public enum ActorValues : int
10+
{
11+
None = -1,
12+
Aggression,
13+
Confidence,
14+
Energy,
15+
Responsibility,
16+
Mood,
17+
Strength,
18+
Perception,
19+
Endurance,
20+
Charisma,
21+
Intelligence,
22+
Agility,
23+
Luck,
24+
ActionPoints,
25+
CarryWeight,
26+
CriticalChance,
27+
HealRate,
28+
Health,
29+
MeleeDamage,
30+
DamageResistance,
31+
PoisonResistance,
32+
RadResistance,
33+
SpeedMultiplier,
34+
Fatigue,
35+
Karma,
36+
XP,
37+
PerceptionCondition,
38+
EnduranceCondition,
39+
LeftAttackCondition,
40+
RightAttackCondition,
41+
LeftMobilityCondition,
42+
RightMobilityCondition,
43+
BrainCondition,
44+
Barter,
45+
BigGuns_Unused,
46+
EnergyWeapons,
47+
Explosives,
48+
Lockpick,
49+
Medicine,
50+
MeleeWeapons,
51+
Repair,
52+
Science,
53+
Guns,
54+
Sneak,
55+
Speech,
56+
Survival,
57+
Unarmed,
58+
InventoryWeight,
59+
Paralysis,
60+
Invisibility,
61+
Chameleon,
62+
NightEye,
63+
Turbo,
64+
FireResistance,
65+
WaterBreathing,
66+
RadLevel,
67+
BloodyMess,
68+
UnarmedDamage,
69+
Assistance,
70+
ElectricResistance,
71+
FrostResistance,
72+
EnergyResistance,
73+
EMPResistance,
74+
IgnoreCrippledLimbs = 72,
75+
Dehydration,
76+
Hunger,
77+
SleepDeprivation,
78+
Damage
79+
}
80+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace ESPSharp.Enums.Flags
8+
{
9+
[Flags]
10+
public enum ClassDataFlag : uint
11+
{
12+
Playable = 0x01,
13+
Guard = 0x02
14+
}
15+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22

3-
namespace ESPSharp
3+
namespace ESPSharp.Enums.Flags
44
{
5-
[FlagsAttribute]
5+
[Flags]
66
public enum RecordFlag : uint
77
{
88
IsMasterFile = 0x00000001,

0 commit comments

Comments
 (0)