├── .editorconfig ├── .gitattributes ├── .gitignore ├── Directory.Build.props ├── Directory.Packages.props ├── EgoEngineLibrary.sln ├── LICENSE ├── README.md ├── References └── DgvFilterPopup.dll ├── src ├── 010 Templates │ ├── !pkg.bt │ ├── bdl.bt │ ├── binXML.bt │ ├── bxml.bt │ ├── cqtc.bt │ ├── ctf2010.bt │ ├── ctf2011.bt │ ├── ctf2012.bt │ ├── ctfDirt3.bt │ ├── ctfDirtShowdown.bt │ ├── ctfGrid2.bt │ ├── dic.bt │ ├── erp.bt │ ├── erp │ │ ├── GfxMeshRes.bt │ │ ├── GfxModelRes.bt │ │ ├── GfxSRVResource0.bt │ │ ├── GfxSurfaceRes0.bt │ │ ├── GfxSurfaceRes2.bt │ │ └── ModelProxyRes.bt │ ├── gvdb.bt │ ├── jpk.bt │ ├── lng.bt │ ├── nefs1.6.bt │ ├── nefs2.0.bt │ ├── nfs1.5.bt │ ├── pssg.bt │ ├── rm.bt │ ├── tng.bt │ ├── tpk.bt │ └── vcqtc.bt ├── EgoCtfEditor │ ├── DGVColumnFilterContextControl.Designer.cs │ ├── DGVColumnFilterContextControl.cs │ ├── DGVColumnFilterContextControl.resx │ ├── DGVListEditor.Designer.cs │ ├── DGVListEditor.cs │ ├── DGVListEditor.resx │ ├── EgoCtfEditor.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── GameSelect.Designer.cs │ ├── GameSelect.cs │ ├── GameSelect.resx │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── Resources │ │ ├── Ryder25.ico │ │ ├── accept.png │ │ ├── car_add.png │ │ ├── car_delete.png │ │ ├── delete.png │ │ ├── disk.png │ │ └── script_code_red.png ├── EgoDatabaseEditor │ ├── AddMultipleRows.Designer.cs │ ├── AddMultipleRows.cs │ ├── AddMultipleRows.resx │ ├── DataGridViewColumnSelector.cs │ ├── EgoDatabaseEditor.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── ReadME.html │ ├── Resources │ │ ├── RYDERI2.ico │ │ ├── database_go.png │ │ ├── disk.png │ │ ├── folder_database.png │ │ ├── layout_sidebar.png │ │ ├── lorry_add.png │ │ ├── lorry_delete.png │ │ ├── table_add.png │ │ ├── table_delete.png │ │ ├── table_edit.png │ │ ├── table_link.png │ │ ├── table_multiple.png │ │ ├── table_relationship.png │ │ ├── table_row_delete.png │ │ ├── table_row_insert.png │ │ └── wrench.png │ ├── RowEdit.Designer.cs │ ├── RowEdit.cs │ ├── RowEdit.resx │ └── schema │ │ ├── schemaDirt2.xml │ │ ├── schemaDirt3.xml │ │ ├── schemaDirtRally.xml │ │ ├── schemaF12010.xml │ │ ├── schemaF12011.xml │ │ ├── schemaF12012.2.xml │ │ ├── schemaF12012.xml │ │ ├── schemaF12013.xml │ │ ├── schemaF12014.xml │ │ ├── schemaGrid.xml │ │ └── schemaGridAutosport.xml ├── EgoEngineLibrary │ ├── Archive │ │ ├── Erp │ │ │ ├── Data │ │ │ │ ├── ErpFragmentData.cs │ │ │ │ ├── ErpGfxSRVResource.cs │ │ │ │ ├── ErpGfxSRVResource0.cs │ │ │ │ ├── ErpGfxSurfaceFormat.cs │ │ │ │ ├── ErpGfxSurfaceRes.cs │ │ │ │ ├── ErpGfxSurfaceRes0.cs │ │ │ │ ├── ErpGfxSurfaceRes1.cs │ │ │ │ ├── ErpGfxSurfaceRes2.cs │ │ │ │ └── ErpResourceData.cs │ │ │ ├── ErpBinaryReader.cs │ │ │ ├── ErpBinaryWriter.cs │ │ │ ├── ErpCompressionAlgorithm.cs │ │ │ ├── ErpFile.cs │ │ │ ├── ErpFragment.cs │ │ │ └── ErpResource.cs │ │ └── Jpk │ │ │ ├── JpkBinaryReader.cs │ │ │ ├── JpkBinaryWriter.cs │ │ │ ├── JpkEntry.cs │ │ │ └── JpkFile.cs │ ├── Collections │ │ ├── BitHelper.cs │ │ ├── EnumerableHelpers.cs │ │ ├── HashHelpers.cs │ │ ├── OrderedSet.cs │ │ ├── QuadTree.cs │ │ ├── QuadTreeBounds.cs │ │ └── ThrowHelper.cs │ ├── Conversion │ │ ├── BigEndianBitConverter.cs │ │ ├── EndianBitConverter.cs │ │ ├── Endianness.cs │ │ └── LittleEndianBitConverter.cs │ ├── Data │ │ ├── DatabaseBinaryReader.cs │ │ ├── DatabaseBinaryWriter.cs │ │ ├── DatabaseFile.cs │ │ └── Pkg │ │ │ ├── Data │ │ │ ├── PkgBboxData.cs │ │ │ ├── PkgBoolData.cs │ │ │ ├── PkgData.cs │ │ │ ├── PkgDataList.cs │ │ │ ├── PkgFp32Data.cs │ │ │ ├── PkgMat4Data.cs │ │ │ ├── PkgQuatData.cs │ │ │ ├── PkgRgbaData.cs │ │ │ ├── PkgShnmData.cs │ │ │ ├── PkgSi32Data.cs │ │ │ ├── PkgSi64Data.cs │ │ │ ├── PkgStringData.cs │ │ │ ├── PkgUi08Data.cs │ │ │ ├── PkgUi16Data.cs │ │ │ ├── PkgUi32Data.cs │ │ │ ├── PkgUi64Data.cs │ │ │ ├── PkgVec3Data.cs │ │ │ ├── PkgVec4Data.cs │ │ │ └── PkgWoidData.cs │ │ │ ├── PkgArray.cs │ │ │ ├── PkgBinaryReader.cs │ │ │ ├── PkgBinaryWriter.cs │ │ │ ├── PkgChunk.cs │ │ │ ├── PkgComplexValue.cs │ │ │ ├── PkgDataArray.cs │ │ │ ├── PkgDataArrayReference.cs │ │ │ ├── PkgFile.cs │ │ │ ├── PkgObject.cs │ │ │ ├── PkgOffsetType.cs │ │ │ ├── PkgPair.cs │ │ │ ├── PkgRootObject.cs │ │ │ └── PkgValue.cs │ ├── EgoEngineLibrary.csproj │ ├── Formats │ │ ├── Erp │ │ │ └── ErpResourceExporter.cs │ │ ├── Pssg │ │ │ ├── CarExteriorPssgGltfConverter.cs │ │ │ ├── CarInteriorPssgGltfConverter.cs │ │ │ ├── DirtCarExteriorPssgGltfConverter.cs │ │ │ ├── GltfCarExteriorPssgConverter.cs │ │ │ ├── GltfCarInteriorPssgConverter.cs │ │ │ ├── GltfDirtCarExteriorPssgConverter.cs │ │ │ ├── GltfGridCarExteriorPssgConverter.cs │ │ │ ├── GltfVertexMaterial.cs │ │ │ ├── PssgGltfConverter.cs │ │ │ ├── PssgModelWriterState.cs │ │ │ ├── RenderDataSourceReader.cs │ │ │ ├── RenderDataSourceWriter.cs │ │ │ └── ShaderInputInfo.cs │ │ ├── Tpk │ │ │ ├── TpkFile.cs │ │ │ ├── TpkFileExtensions.cs │ │ │ └── TpkImageFormat.cs │ │ └── TrackQuadTree │ │ │ ├── CQuadTree.cs │ │ │ ├── CQuadTreeType.cs │ │ │ ├── CQuadTreeTypeInfo.cs │ │ │ ├── CellQuadTree.cs │ │ │ ├── GltfTrackGroundConverter.cs │ │ │ ├── IQuadTreeTypeInfo.cs │ │ │ ├── MeshOpt.cs │ │ │ ├── QuadTreeDataTriangle.cs │ │ │ ├── QuadTreeMeshData.cs │ │ │ ├── QuadTreeMeshDataBuilder.cs │ │ │ ├── QuadTreeMeshDataView.cs │ │ │ ├── SeparatingAxisTheorem.cs │ │ │ ├── Static │ │ │ ├── CQuadTreeFile.cs │ │ │ ├── CQuadTreeHeader.cs │ │ │ ├── CQuadTreeNode.cs │ │ │ ├── IStaticQuadTreeHeader.cs │ │ │ ├── IStaticQuadTreeNode.cs │ │ │ ├── QuadTreeFile.cs │ │ │ ├── VcQuadTreeFile.cs │ │ │ ├── VcQuadTreeHeader.cs │ │ │ └── VcQuadTreeNode.cs │ │ │ ├── TrackGround.File.cs │ │ │ ├── TrackGround.cs │ │ │ ├── TrackGroundGltfConverter.cs │ │ │ ├── TrackGroundQuadTree.cs │ │ │ ├── VcQuadTree.cs │ │ │ ├── VcQuadTreeType.cs │ │ │ └── VcQuadTreeTypeInfo.cs │ ├── Graphics │ │ ├── BcnExtensions.cs │ │ ├── Dds │ │ │ ├── D3D10_Resource_Dimension.cs │ │ │ ├── DDSHeaderDXT10.cs │ │ │ ├── DXGI_Format.cs │ │ │ ├── DdsFile.cs │ │ │ ├── DdsHeader.cs │ │ │ └── DdsPixelFormat.cs │ │ ├── GraphicsExtensions.cs │ │ ├── PssgAttribute.cs │ │ ├── PssgAttributeCollection.cs │ │ ├── PssgBinaryReader.cs │ │ ├── PssgBinaryWriter.cs │ │ ├── PssgEnumerableExtensions.cs │ │ ├── PssgFile.cs │ │ ├── PssgNode.cs │ │ ├── PssgNodeCollection.cs │ │ └── PssgSchema.cs │ ├── Helper │ │ └── HexHelper.cs │ ├── IO │ │ ├── ConcatenatedStream.cs │ │ ├── EndianBinaryReader.cs │ │ ├── EndianBinaryWriter.cs │ │ └── StreamExtensions.cs │ ├── Language │ │ ├── Bucket.cs │ │ ├── HashEntry.cs │ │ ├── HashTable.cs │ │ ├── Hshs.cs │ │ ├── Hsht.cs │ │ ├── LngB.cs │ │ ├── LngBinaryReader.cs │ │ ├── LngBinaryWriter.cs │ │ ├── LngFile.cs │ │ ├── SidA.cs │ │ ├── SidB.cs │ │ └── SidaEntry.cs │ ├── Resources │ │ ├── Strings.Designer.cs │ │ └── Strings.resx │ ├── Vehicle │ │ ├── CsvFile.cs │ │ ├── CsvStreamReader.cs │ │ ├── CsvStreamWriter.cs │ │ ├── CtfBinaryReader.cs │ │ ├── CtfBinaryWriter.cs │ │ ├── CtfEditorGamePage.cs │ │ ├── CtfEntryInfo.cs │ │ ├── CtfFile.cs │ │ ├── FloatList.cs │ │ ├── PerformanceFile.cs │ │ ├── TngBinaryReader.cs │ │ ├── TngBinaryWriter.cs │ │ ├── TngEntry.cs │ │ ├── TngFile.cs │ │ └── TngInfo.cs │ ├── Xml │ │ ├── BinaryXmlAttribute.cs │ │ ├── BinaryXmlElement.cs │ │ ├── BinaryXmlString.cs │ │ ├── XmlBinaryReader.cs │ │ ├── XmlBinaryWriter.cs │ │ ├── XmlFile.cs │ │ └── XmlType.cs │ └── libzstd.dll ├── EgoErpArchiver │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── EgoErpArchiver.csproj │ ├── GridViewSort.cs │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Properties │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── ReadME.html │ ├── Resources │ │ ├── Ryder25.ico │ │ ├── disk.png │ │ └── folder.png │ ├── View │ │ ├── ProgressDialog.xaml │ │ └── ProgressDialog.xaml.cs │ └── ViewModel │ │ ├── ErpFragmentViewModel.cs │ │ ├── ErpPackageViewModel.cs │ │ ├── ErpResourceViewModel.cs │ │ ├── ErpTextureViewModel.cs │ │ ├── ErpXmlFileViewModel.cs │ │ ├── MainViewModel.cs │ │ ├── PackagesWorkspaceViewModel.cs │ │ ├── ProgressDialogViewModel.cs │ │ ├── RelayCommand.cs │ │ ├── ResourcesWorkspaceViewModel.cs │ │ ├── TexturesWorkspaceViewModel.cs │ │ ├── TreeNodeViewModel.cs │ │ ├── ViewModelBase.cs │ │ ├── WorkspaceViewModel.cs │ │ └── XmlFilesWorkspaceViewModel.cs ├── EgoErpArchiverConsole │ ├── EgoErpArchiverConsole.csproj │ ├── Program.cs │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx ├── EgoFileConverter │ ├── EgoFileConverter.csproj │ ├── Program.cs │ ├── Properties │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── ReadME.html │ ├── Resources │ │ └── Ryder25.ico │ ├── TrackQuadTreeApp.cs │ └── UserPauseFilter.cs ├── EgoJpkArchiver │ ├── EgoJpkArchiver.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── ReadME.html │ └── Resources │ │ ├── Ryder25.ico │ │ ├── disk.png │ │ ├── folder.png │ │ ├── lorry_add.png │ │ └── lorry_delete.png ├── EgoLngEditor │ ├── AddRow.Designer.cs │ ├── AddRow.cs │ ├── AddRow.resx │ ├── EgoLngEditor.csproj │ ├── FindAndReplaceForm.Designer.cs │ ├── FindAndReplaceForm.cs │ ├── FindAndReplaceForm.resx │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── Resources │ │ ├── Ryder25.ico │ │ ├── disk.png │ │ ├── find.png │ │ ├── folder.png │ │ ├── lorry_add.png │ │ ├── lorry_delete.png │ │ ├── table_multiple.png │ │ ├── table_relationship.png │ │ ├── table_row_delete.png │ │ └── table_row_insert.png ├── EgoPssgEditor │ ├── AddAttributeWindow.xaml │ ├── AddAttributeWindow.xaml.cs │ ├── AddNodeWindow.xaml │ ├── AddNodeWindow.xaml.cs │ ├── App.xaml │ ├── App.xaml.cs │ ├── DuplicateTextureWindow.xaml │ ├── DuplicateTextureWindow.xaml.cs │ ├── EgoPssgEditor.csproj │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ ├── Models3d │ │ └── ModelsWorkspaceViewModel.cs │ ├── Properties │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── ReadME.html │ ├── RelayCommand.cs │ ├── Resources │ │ ├── Ryder25.ico │ │ ├── disk.png │ │ ├── folder_image.png │ │ └── image_add.png │ ├── ViewModel │ │ ├── CubeMapWorkspaceViewModel.cs │ │ ├── MainViewModel.cs │ │ ├── NodesWorkspaceViewModel.cs │ │ ├── PssgAttributeViewModel.cs │ │ ├── PssgNodeViewModel.cs │ │ ├── PssgTextureViewModel.cs │ │ ├── TexturesWorkspaceViewModel.cs │ │ ├── ViewModelBase.cs │ │ └── WorkspaceViewModel.cs │ └── schema.xml ├── EgoTngEditor │ ├── EgoTngEditor.csproj │ ├── Form1.Designer.cs │ ├── Form1.cs │ ├── Form1.resx │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── Resources │ │ ├── Ryder25.ico │ │ ├── disk.png │ │ └── folder.png └── Sandbox │ ├── CQuadTreeSandbox.cs │ ├── Program.cs │ ├── Sandbox.csproj │ ├── TpkSandbox.cs │ ├── Utils.cs │ └── VcQuadTreeSandbox.cs └── tests └── EgoEngineLibrary.Tests ├── EgoEngineLibrary.Tests.csproj └── Formats └── TrackQuadTree ├── QuadTreeMeshDataTests.cs └── QuadTreeTriangleTests.cs /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | 7 | 8 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Petar Tasev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ego Engine Modding 2 | A suite of modding applications for the Ego Engine which powers Codemasters' racing game franchises (Dirt, Grid, and 3 | Formula 1). 4 | 5 | The project was started in 2009/2010 with the Ego Database Editor for the game Race Driver: Grid. It has since been 6 | continuously updated to include many other tools. 7 | 8 | ### [Ego CTF Editor](https://petar.page/l/ego-ece-home) 9 | An app to edit CarTuningFile (CTF,CSV) files. 10 | 11 | ### [Ego Database Editor](https://petar.page/l/ego-ede-home) 12 | An app to edit the database.bin file. It contains data for events, ai skill levels, vehicles, teams and etc. 13 | 14 | ### [Ego ERP Archiver](https://petar.page/l/ego-eea-home) 15 | An app to export and import resources from ERP archives. The archives store many different types of data, 16 | including textures. 17 | 18 | ### [Ego File Converter](https://petar.page/l/ego-efc-home) 19 | An app to convert binary XML, lng, tpk and pkg files to common formats. 20 | 21 | ### [Ego JPK Archiver](https://petar.page/l/ego-eja-home) 22 | An app to export and import files in JPK archives. The raceload.jpk file contains physics, damage, and game loading data. 23 | 24 | ### [Ego Language Editor](https://petar.page/l/ego-ele-home) 25 | An app to edit language localization files. 26 | 27 | ### [Ego PSSG Editor](https://petar.page/l/ego-epe-home) 28 | An app to edit PSSG files. These files contain 3D models and textures. 29 | 30 | ## Community 31 | Connect with the modding community. 32 | 33 | - [Ego Engine Modding Discord](https://discord.gg/5bCjMqS) - modding community for all Ego racing games 34 | - [Dirt 3 Discord](https://discord.gg/46KweYnegD) - gaming community for Dirt 3 with downloads section 35 | - [F1 Game Modding Community Discord](https://discord.gg/b3CREU5Kp2) - modding community for F1 2014 and earlier with downloads section 36 | - [Mod DB](https://www.moddb.com/) - general game modding community with downloads section 37 | - [Nexus Mods](https://www.nexusmods.com/) - general game modding community with downloads section 38 | - [OverTake (formerly RaceDepartment)](https://www.overtake.gg/) - sim racing community with modding forums and downloads section 39 | -------------------------------------------------------------------------------- /References/DgvFilterPopup.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/References/DgvFilterPopup.dll -------------------------------------------------------------------------------- /src/010 Templates/binXML.bt: -------------------------------------------------------------------------------- 1 | LittleEndian(); 2 | 3 | int magic; 4 | int restOfFileLength; 5 | 6 | int magic_2; 7 | int section3And4Length; 8 | 9 | int magic_3; 10 | int sectionLength; 11 | local int i = 0; 12 | for (i = 0; i < sectionLength; i++) { 13 | struct string_list s; 14 | i = i - 1 + sizeof(s); 15 | } 16 | 17 | int magic_4; 18 | int sectionLength2; 19 | local int numStrings = sectionLength2/4; 20 | int stringOffsets[numStrings]; 21 | 22 | int magic_5; 23 | int sectionLength3; 24 | local int xmlElementCount = sectionLength3/24; 25 | struct xmlElement elements[xmlElementCount]; 26 | 27 | int magic_6; 28 | int sectionLength4; 29 | local int xmlAttrCount = sectionLength4/8; 30 | struct xmlAttr attributes[xmlAttrCount]; 31 | 32 | struct string_list { 33 | string s; 34 | }; 35 | 36 | struct xmlElement { 37 | int elementNameID; 38 | int elementValueID; 39 | int attributeCount; 40 | int attributeStartID; 41 | int childElementCount; 42 | int childElementStartID; 43 | }; 44 | 45 | struct xmlAttr { 46 | int attributeNameID; 47 | int valueStringID; 48 | }; -------------------------------------------------------------------------------- /src/010 Templates/bxml.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | byte endianness; 14 | if (endianness == 0x00) 15 | { 16 | BigEndian(); 17 | } 18 | else if (endianness == 0x01) 19 | { 20 | LittleEndian(); 21 | } 22 | 23 | char magic[4]; 24 | struct XmlElementInfo 25 | { 26 | int16 elemLength; 27 | byte unk; 28 | byte pad; 29 | int16 attribCount; 30 | }; 31 | 32 | struct XmlElement 33 | { 34 | struct XmlElementInfo elemInfo ; 35 | 36 | if (elemInfo.unk == 0) 37 | { 38 | string name; 39 | 40 | struct XmlAttributes 41 | { 42 | string name; 43 | string value; 44 | } attributes[elemInfo.attribCount] ; 45 | 46 | while (1) 47 | { 48 | struct XmlElement children; 49 | if (children.elemInfo.unk == 5) 50 | { 51 | break; 52 | } 53 | } 54 | } 55 | else if (elemInfo.unk == 1) 56 | { 57 | string value; 58 | } 59 | else if (elemInfo.unk == 5) 60 | { 61 | // end of element 62 | } 63 | } root; -------------------------------------------------------------------------------- /src/010 Templates/dic.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v12.0.1 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: Label DIC files 12 | //------------------------------------------------ 13 | LittleEndian(); 14 | 15 | struct { 16 | char magic[4]; 17 | uint unknown; 18 | char version[4]; 19 | uint numBanks; 20 | } header; 21 | 22 | struct { 23 | uint sampleOffset; 24 | uint numSamples; 25 | char name[16]; 26 | 27 | local int currPos = FTell(); 28 | FSeek(sampleOffset); 29 | 30 | uint unknown; 31 | struct { 32 | uint16 sampleRate; 33 | struct { 34 | uint16 unk0 : 1; 35 | uint16 unk1 : 1; 36 | uint16 unk2 : 1; 37 | uint16 unk3 : 1; 38 | uint16 loop : 1; 39 | uint16 stereo : 1; 40 | uint16 unk6 : 1; 41 | uint16 unk7 : 1; 42 | uint16 unk8 : 1; 43 | uint16 unk9 : 1; 44 | uint16 unk10 : 1; 45 | uint16 unk11 : 1; 46 | uint16 unk12 : 1; 47 | uint16 unk13 : 1; 48 | uint16 unk14 : 1; 49 | uint16 unk15 : 1; 50 | } flags ; 51 | char name[16]; 52 | uint32 size; 53 | } sample[numSamples] ; 54 | char format[4]; 55 | 56 | FSeek(currPos); 57 | 58 | } bank[header.numBanks] ; 59 | -------------------------------------------------------------------------------- /src/010 Templates/erp.bt: -------------------------------------------------------------------------------- 1 | //-------------------------------------- 2 | //--- 010 Editor v5.0 Binary Template 3 | // 4 | // File: erp.bt 5 | // Author: Petar Tasev 6 | // Revision:1.0 7 | // Purpose: Highlight erp files from EGO games. 8 | //-------------------------------------- 9 | LittleEndian(); 10 | 11 | uint32 magic; 12 | int32 version; 13 | int64 padding; 14 | int64 infoOffset; 15 | int64 infoSize; 16 | int64 filesOffset; 17 | int64 padding; 18 | int32 numFiles; 19 | int32 numTempFiles; 20 | 21 | struct 22 | { 23 | int32 fileInfoLength; 24 | int16 fileNameSize; 25 | char fileName[fileNameSize]; 26 | char fileType[16]; 27 | int32 unk; 28 | if (version >= 4) 29 | { 30 | int16 unk2; 31 | } 32 | byte numTempFiles; 33 | 34 | struct 35 | { 36 | char name[4]; 37 | int64 offset; 38 | int64 size; 39 | int32 flags; 40 | local int64 dataSize; 41 | if (version <= 2) 42 | { 43 | dataSize = size; 44 | } 45 | else 46 | { 47 | byte compression; // 0x01=zlib, 0x81=no, 0x00=no 48 | int64 compressedSize; 49 | dataSize = compressedSize; 50 | } 51 | local int64 currPos = FTell(); 52 | FSeek(offset + filesOffset); 53 | byte data[dataSize]; 54 | FSeek(currPos); 55 | } tempFile[numTempFiles] ; 56 | 57 | if (version > 2) 58 | { 59 | char hash[16]; 60 | } 61 | } files[numFiles] ; -------------------------------------------------------------------------------- /src/010 Templates/erp/GfxMeshRes.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | uint32 numMeshes; 14 | uint32 numVBs; 15 | uint32 numIBs; 16 | uint32 numMeshNames; 17 | uint32 numNodeLinks; 18 | 19 | uint32 vertexBufferOffset; 20 | uint32 indexBufferOffset; 21 | uint32 meshNameOffset; 22 | uint32 nodeLinkOffset; 23 | 24 | struct 25 | { 26 | uint32 numVBs; 27 | uint32 unk2; 28 | uint32 unk3; 29 | uint32 ibIndex; 30 | uint32 ibCount; 31 | uint32 ibOffset; 32 | float unk7[4]; 33 | uint32 nodeLinkOffset; 34 | uint32 unk9; 35 | uint32 nameOffset; 36 | uint32 unk11; 37 | uint32 vertexFileOffset; 38 | uint32 unk13; 39 | uint32 unk14; 40 | uint32 unk15; 41 | uint32 unk16; 42 | uint32 unk17; 43 | uint32 unk18; 44 | uint32 unk19; 45 | } meshes[numMeshes]; 46 | 47 | struct {string s;} vbb[numVBs] ; 48 | 49 | struct {string s;} ibb[numIBs] ; 50 | 51 | struct {string meshName;} meshNames[numMeshNames] ; 52 | 53 | struct 54 | { 55 | uint32 nodeIndex; 56 | uint32 meshIndex; 57 | } nodeLinks[numNodeLinks]; -------------------------------------------------------------------------------- /src/010 Templates/erp/GfxModelRes.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | typedef struct 14 | { 15 | float minDist; 16 | float maxDist; 17 | } LOD; 18 | 19 | uint32 numLODDistances; 20 | uint16 numNodes; 21 | uint16 numBoneNodeIndices; 22 | uint32 numNames; 23 | uint32 numFiles; 24 | float unk[4]; 25 | uint32 num6[numLODDistances]; 26 | LOD lodDistances[numLODDistances]; 27 | uint32 num7; 28 | 29 | typedef struct 30 | { 31 | uint32 stringOffset; 32 | uint32 parentIndex; 33 | float pos[3]; 34 | float rot[4]; 35 | float scale[3]; 36 | float transform[16]; 37 | uint32 unk6; 38 | uint32 unk7; 39 | } Node; 40 | 41 | local uint64 strDataOffset; 42 | string readDat(Node& node) 43 | { 44 | FSeek(72 + numNodes * 120 + numBoneNodeIndices * 2 + node.stringOffset); 45 | return ReadString(strDataOffset + node.stringOffset); 46 | } 47 | 48 | Node nodes[numNodes] ; 49 | 50 | int16 boneNodeIndices[numBoneNodeIndices]; 51 | 52 | struct { string meshfile; } files[numFiles]; 53 | 54 | strDataOffset = FTell(); 55 | 56 | struct { string name; } names[numNames]; -------------------------------------------------------------------------------- /src/010 Templates/erp/GfxSRVResource0.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | int32 unknown; 14 | int32 imageType; 15 | int32 unknown2; 16 | uint32 mipMapCount; 17 | int32 unknown3; 18 | int32 unknown4; 19 | 20 | string path; -------------------------------------------------------------------------------- /src/010 Templates/erp/GfxSurfaceRes0.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | int32 unknown; 14 | int32 unknown2; 15 | int32 imageType; 16 | uint32 width; 17 | uint32 height; 18 | int32 unknown3; 19 | uint32 mipMapCount; 20 | uint32 texArraySize; 21 | int32 unknown4; -------------------------------------------------------------------------------- /src/010 Templates/erp/GfxSurfaceRes2.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | local byte hasF12017 = 1; 14 | local byte hasGridLegends = 1; 15 | local byte hasF123 = 1; 16 | if (hasGridLegends) 17 | { 18 | hasF12017 = 1; 19 | } 20 | 21 | if (hasF123) 22 | { 23 | hasGridLegends = 0; 24 | } 25 | 26 | // Actual data start 27 | byte strLength; 28 | char path[strLength]; 29 | if (hasF123) 30 | { 31 | byte unknown4; 32 | } 33 | 34 | uint32 mipCount; 35 | 36 | struct 37 | { 38 | if (hasF123) 39 | { 40 | byte unknown; 41 | } 42 | 43 | byte compression; 44 | uint64 offset; 45 | uint64 packedSize; 46 | uint64 size; 47 | } mips[mipCount] ; 48 | 49 | if (hasGridLegends) 50 | { 51 | byte unknown3; 52 | } 53 | 54 | if (hasF12017) 55 | { 56 | float unknown; 57 | float unknown2; 58 | } -------------------------------------------------------------------------------- /src/010 Templates/erp/ModelProxyRes.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0.2 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | LittleEndian(); 14 | int16 num; 15 | int16 num2; 16 | int32 sLen; 17 | int32 unk2; 18 | 19 | typedef struct 20 | { 21 | uint32 stringOffset; 22 | uint32 parentIndex; 23 | float unk2[3]; 24 | float unk3[4]; 25 | float unk4[3]; 26 | float unk5[16]; 27 | uint32 unk6; 28 | uint32 unk7; 29 | } Dat; 30 | 31 | string readDat(Dat& data) 32 | { 33 | FSeek(12 + num * 120 + num2 * 2 + data.stringOffset); 34 | return ReadString(FTell()); 35 | } 36 | 37 | Dat ddd[num] ; 38 | 39 | int16 unk[num2]; 40 | char strDat[sLen]; -------------------------------------------------------------------------------- /src/010 Templates/gvdb.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v7.0 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | LittleEndian(); 14 | 15 | string bytearrtohex(struct Dat& data) 16 | { 17 | string s; 18 | string temp; 19 | int i; 20 | for (i = 0; i < data.strLen; i++) 21 | { 22 | SPrintf(temp, "%.2X", data.str[i]); 23 | s += temp;//SubStr(temp, 6, 2); 24 | } 25 | return s; 26 | } 27 | 28 | string ReadDat(struct Dat& data) 29 | { 30 | string ret = bytearrtohex(data) + " "; 31 | string s; 32 | SPrintf(s, "%X", data.bb); 33 | //return data.str + " " + s; 34 | SPrintf(s, "%-30s %30s %8s", data.str, ret, s); 35 | return s; 36 | if (data.strLen > 0) 37 | { 38 | } 39 | else 40 | { 41 | return " " + ret + s; 42 | } 43 | } 44 | 45 | char magic[4]; 46 | int32 numEntries; 47 | 48 | struct Dat 49 | { 50 | uint32 bb ; // not sure what this is, but seems to be unique for each value 51 | byte dataType; 52 | uint32 strLen; 53 | byte str[strLen+1]; 54 | //string str ; 55 | } strs[numEntries] ; -------------------------------------------------------------------------------- /src/010 Templates/jpk.bt: -------------------------------------------------------------------------------- 1 | //-------------------------------------- 2 | //--- 010 Editor v3.1 Binary Template 3 | // 4 | // File: jpk.bt 5 | // Author: Petar Tasev 6 | // Revision: 1 7 | // Purpose: Label Ego Engine jpk files 8 | //-------------------------------------- 9 | LittleEndian(); 10 | SetBackColor(cLtGray); 11 | 12 | struct HEADER { 13 | int magic; 14 | int unknown; 15 | int entryCount; 16 | int align; 17 | int unknown; 18 | int sizeToEnd; 19 | int unknown; 20 | int unknown; 21 | } header; 22 | 23 | struct Entry { 24 | int stringOffset ; 25 | int fileSize; 26 | int fileOffset ; 27 | int compressedFileSize; 28 | int unknown; 29 | int unknown; 30 | int pad; 31 | int pad; 32 | 33 | local int64 currentPos = FTell(); 34 | 35 | FSeek(stringOffset); 36 | string name ; 37 | 38 | FSeek(fileOffset); 39 | byte data[fileSize] ; 40 | 41 | FSeek(currentPos); 42 | } entry[header.entryCount] ; 43 | 44 | string entryName(Entry &entry) { 45 | return entry.name; 46 | } -------------------------------------------------------------------------------- /src/010 Templates/lng.bt: -------------------------------------------------------------------------------- 1 | //-------------------------------------- 2 | //--- 010 Editor v3.1.3 Binary Template 3 | // 4 | // File: lng.bt 5 | // Author: Mike 6 | // Purpose: Label ego engine .lng files 7 | //-------------------------------------- 8 | BigEndian(); 9 | 10 | char magic[4]; 11 | int filesize; 12 | 13 | struct HSHS { 14 | char hshs[4]; 15 | int size; 16 | int buckets; 17 | int seed; 18 | int multiplier; 19 | } hshs; 20 | 21 | struct HSHT { 22 | char hsht[4]; 23 | int size; 24 | struct HSHT_Entry { 25 | int bucket; 26 | int count; 27 | } items[size / 8]; 28 | } hsht; 29 | 30 | struct SIDA { 31 | char hsht[4]; 32 | int size; 33 | int entryCount; 34 | struct SIDA_Entry { 35 | int sidb_offset; 36 | int lngb_offset; 37 | } items[size / 8]; 38 | } sida; 39 | 40 | struct SIDB { 41 | char sidb[4]; 42 | int size; 43 | char items[size]; 44 | } sidb; 45 | 46 | struct LNGB { 47 | char lngb[4]; 48 | int size; 49 | char items[size]; 50 | } lngb; -------------------------------------------------------------------------------- /src/010 Templates/rm.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v15.0.1 Binary Template 3 | // 4 | // File: 5 | // Authors: 6 | // Version: 7 | // Purpose: Label track.rm in reducedmechanics.jpk 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | LittleEndian(); 14 | 15 | int32 version; 16 | 17 | struct { 18 | // data 19 | ubyte x[3]; 20 | ubyte y[3]; 21 | ubyte z[3]; 22 | byte xo; 23 | byte yo; 24 | byte zo; 25 | ubyte racingAcrossProportion; 26 | byte leftNormalX; 27 | byte leftNormalZ; 28 | byte rightNormalX; 29 | byte rightNormalZ; 30 | 31 | // decompress 32 | local float bX = ((float)(int32)(((uint32)x[0] << 16) + ((uint32)x[1] << 8) + ((uint32)x[2]) - 0x800000)) / 200.0f; 33 | local float bY = ((float)(int32)(((uint32)y[0] << 16) + ((uint32)y[1] << 8) + ((uint32)y[2]) - 0x800000)) / 200.0f; 34 | local float bZ = ((float)(int32)(((uint32)z[0] << 16) + ((uint32)z[1] << 8) + ((uint32)z[2]) - 0x800000)) / 200.0f; 35 | 36 | local float oX = xo / 50.0f; 37 | local float oY = yo / 100.0f; 38 | local float oZ = zo / 50.0f; 39 | 40 | local float lx = bX - oX; 41 | local float ly = bY - oY; 42 | local float lz = bZ - oZ; 43 | 44 | local float rx = bX + oX; 45 | local float ry = bY + oY; 46 | local float rz = bZ + oZ; 47 | 48 | local float rap = racingAcrossProportion / 255.0f; 49 | 50 | local float lnx = leftNormalX / 127.0f; 51 | local float lnz = leftNormalZ / 127.0f; 52 | local float lny = Sqrt(1.0f - (lnx * lnx + lnz * lnz)); 53 | 54 | local float rnx = rightNormalX / 127.0f; 55 | local float rnz = rightNormalZ / 127.0f; 56 | local float rny = Sqrt(1.0f - (rnx * rnx + rnz * rnz)); 57 | } gates[(FileSize() - 4) / 17] ; 58 | -------------------------------------------------------------------------------- /src/010 Templates/tng.bt: -------------------------------------------------------------------------------- 1 | //-------------------------------------- 2 | //--- 010 Editor v3.1 Binary Template 3 | // 4 | // File: 5 | // Author: 6 | // Revision: 7 | // Purpose: 8 | //-------------------------------------- 9 | LittleEndian(); 10 | 11 | SetBackColor(cLtGray); 12 | 13 | typedef struct { 14 | int stringOffset ; 15 | 16 | local int64 currentPos = FTell(); 17 | FSeek(12 + stringOffset); 18 | string name ; 19 | FSeek(currentPos); 20 | 21 | float val; 22 | float val2; 23 | int num; 24 | } ChildEntry; 25 | 26 | struct { 27 | struct HEADER { 28 | int magic; 29 | int entryCount; 30 | int textLength; 31 | } header; 32 | 33 | FSeek(12 + header.textLength); 34 | 35 | struct Entry { 36 | int stringOffset ; 37 | 38 | local int64 currentPos = FTell(); 39 | FSeek(12 + stringOffset); 40 | string name ; 41 | FSeek(currentPos); 42 | 43 | int16 id; 44 | 45 | int instructionCode; 46 | switch (instructionCode) { 47 | case 0: 48 | float val; 49 | break; 50 | case 1: 51 | int linkedInfoId; 52 | float val; 53 | break; 54 | } 55 | 56 | int instructionCode2; 57 | switch (instructionCode2) { 58 | case 4: 59 | case 1: 60 | case 0: 61 | float val2; 62 | float val3; 63 | break; 64 | case 3: 65 | int linkedInfoId2; 66 | break; 67 | } 68 | 69 | int childCount; 70 | ChildEntry childEntry[childCount] ; 71 | } entry[header.entryCount] ; 72 | } file; 73 | 74 | string entryName(Entry &entry) { 75 | return entry.name; 76 | } 77 | string childEntryName(ChildEntry &entry) { 78 | return entry.name; 79 | } 80 | -------------------------------------------------------------------------------- /src/010 Templates/tpk.bt: -------------------------------------------------------------------------------- 1 | //------------------------------------------------ 2 | //--- 010 Editor v12.0.1 Binary Template 3 | // 4 | // File: tpk.bt 5 | // Authors: 6 | // Version: 7 | // Purpose: 8 | // Category: 9 | // File Mask: 10 | // ID Bytes: 11 | // History: 12 | //------------------------------------------------ 13 | LittleEndian(); 14 | 15 | int unk1; 16 | int unk2; 17 | int unk3; 18 | int unk4; 19 | 20 | int unk5; 21 | int unk6; 22 | int unk7; 23 | int unk8; 24 | 25 | int unk9; 26 | int unk10; 27 | 28 | uint format ; 29 | uint width; 30 | uint height; 31 | uint unk11; 32 | uint length; 33 | 34 | char name[32]; 35 | 36 | float unk12; 37 | uint mipMapCount; 38 | 39 | ubyte data[length]; -------------------------------------------------------------------------------- /src/EgoCtfEditor/EgoCtfEditor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | $(TargetFramework)-windows 4 | WinExe 5 | true 6 | Ego CTF Editor 7 | false 8 | 9 | 10 | 11 | Resources\Ryder25.ico 12 | 13 | 14 | 15 | 16 | ResXFileCodeGenerator 17 | Resources.Designer.cs 18 | Designer 19 | 20 | 21 | True 22 | Resources.resx 23 | True 24 | 25 | 26 | SettingsSingleFileGenerator 27 | Settings.Designer.cs 28 | 29 | 30 | True 31 | Settings.settings 32 | True 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/GameSelect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using EgoEngineLibrary.Vehicle; 4 | 5 | namespace EgoCtfEditor 6 | { 7 | public partial class GameSelect : Form 8 | { 9 | public int GameID 10 | { 11 | get { return gameComboBox.SelectedIndex; } 12 | } 13 | 14 | public GameSelect() 15 | { 16 | InitializeComponent(); 17 | gameComboBox.DataSource = Enum.GetNames(typeof(CtfEditorMainTabs)); 18 | gameComboBox.SelectedIndex = 0; 19 | } 20 | 21 | private void button_Click(object sender, EventArgs e) 22 | { 23 | if (gameComboBox.SelectedItem == null) 24 | { 25 | this.DialogResult = System.Windows.Forms.DialogResult.None; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgoCtfEditor 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main(string[] args) 13 | { 14 | ApplicationConfiguration.Initialize(); 15 | System.Collections.Generic.List a = new System.Collections.Generic.List(args); 16 | if (args.Length > 0) 17 | { 18 | using (GameSelect gs = new GameSelect()) 19 | { 20 | if (gs.ShowDialog() == DialogResult.OK) 21 | { 22 | a.Add(gs.GameID.ToString()); 23 | } 24 | else 25 | { 26 | a.Add((-1).ToString()); 27 | } 28 | } 29 | } 30 | Application.Run(new Form1(a.ToArray())); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Ego CTF Editor")] 9 | [assembly: AssemblyDescription("Edit car tuning files from EGO Engine games.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Petar Tasev")] 12 | [assembly: AssemblyProduct("Ego CTF Editor")] 13 | [assembly: AssemblyCopyright("Copyright © Petar Tasev 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("a0ce6aa5-ba38-4b9c-ad35-dd421e1b59c9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("4.2.2016.0920")] 36 | [assembly: AssemblyFileVersion("4.2.2016.0920")] 37 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoCtfEditor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/accept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/accept.png -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/car_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/car_add.png -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/car_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/car_delete.png -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/delete.png -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoCtfEditor/Resources/script_code_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoCtfEditor/Resources/script_code_red.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/AddMultipleRows.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace EgoDatabaseEditor { 11 | public partial class AddMultipleRows : Form { 12 | public int Amount { 13 | get { 14 | try { 15 | return Convert.ToInt32(amountTextBox.Text); 16 | } 17 | catch { 18 | return -1; 19 | } 20 | } 21 | } 22 | 23 | public AddMultipleRows() { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgoDatabaseEditor 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main(string[] Args) 13 | { 14 | ApplicationConfiguration.Initialize(); 15 | Application.Run(new Form1(Args)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/RYDERI2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/RYDERI2.ico -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/database_go.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/database_go.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/folder_database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/folder_database.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/layout_sidebar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/layout_sidebar.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/lorry_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/lorry_add.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/lorry_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/lorry_delete.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_add.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_delete.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_edit.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_link.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_multiple.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_relationship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_relationship.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_row_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_row_delete.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/table_row_insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/table_row_insert.png -------------------------------------------------------------------------------- /src/EgoDatabaseEditor/Resources/wrench.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoDatabaseEditor/Resources/wrench.png -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpFragmentData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Archive.Erp.Data 8 | { 9 | public abstract class ErpFragmentData 10 | { 11 | public abstract void FromFragment(ErpFragment fragment); 12 | public abstract void ToFragment(ErpFragment fragment); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpGfxSRVResource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Archive.Erp.Data 8 | { 9 | public class ErpGfxSRVResource : ErpResourceData 10 | { 11 | public ErpGfxSRVResource0 Fragment0 { get; set; } 12 | 13 | public ErpGfxSurfaceRes SurfaceRes { get; set; } 14 | 15 | public ErpGfxSRVResource() 16 | { 17 | Fragment0 = new ErpGfxSRVResource0(); 18 | SurfaceRes = new ErpGfxSurfaceRes(); 19 | } 20 | 21 | public override void FromResource(ErpResource resource) 22 | { 23 | Fragment0.FromFragment(resource.GetFragment("temp", 0)); 24 | SurfaceRes.FromResource(resource.ParentFile.FindResource(Fragment0.SurfaceResourceName)); 25 | } 26 | 27 | public override void Read(ErpBinaryReader reader) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | public override void Write(ErpBinaryWriter writer) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | 37 | public override void ToResource(ErpResource resource) 38 | { 39 | Fragment0.ToFragment(resource.GetFragment("temp", 0)); 40 | SurfaceRes.ToResource(resource.ParentFile.FindResource(Fragment0.SurfaceResourceName)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpGfxSRVResource0.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | using EgoEngineLibrary.Conversion; 9 | 10 | namespace EgoEngineLibrary.Archive.Erp.Data 11 | { 12 | public class ErpGfxSRVResource0 : ErpFragmentData 13 | { 14 | public int Unknown { get; set; } 15 | public ErpGfxSurfaceFormat ImageType { get; set; } 16 | public int Unknown2 { get; set; } 17 | public uint MipMapCount { get; set; } 18 | public int Unknown3 { get; set; } 19 | public int Unknown4 { get; set; } 20 | public string SurfaceResourceName { get; set; } 21 | 22 | public ErpGfxSRVResource0() 23 | { 24 | Unknown = 5; 25 | ImageType = ErpGfxSurfaceFormat.DXT5_SRGB; 26 | Unknown2 = 0; 27 | MipMapCount = 1; 28 | Unknown3 = 0; 29 | Unknown4 = 0; 30 | SurfaceResourceName = string.Empty; 31 | } 32 | 33 | public override void FromFragment(ErpFragment fragment) 34 | { 35 | using var memData = fragment.GetDataStream(true); 36 | using var reader = new ErpBinaryReader(memData); 37 | Unknown = reader.ReadInt32(); 38 | ImageType = (ErpGfxSurfaceFormat)reader.ReadInt32(); 39 | Unknown2 = reader.ReadInt32(); 40 | MipMapCount = reader.ReadUInt32(); 41 | Unknown3 = reader.ReadInt32(); 42 | Unknown4 = reader.ReadInt32(); 43 | SurfaceResourceName = reader.ReadString(); 44 | } 45 | 46 | public override void ToFragment(ErpFragment fragment) 47 | { 48 | using var newData = new MemoryStream(); 49 | using var writer = new ErpBinaryWriter(EndianBitConverter.Little, newData); 50 | writer.Write(Unknown); 51 | writer.Write((int)ImageType); 52 | writer.Write(Unknown2); 53 | writer.Write(MipMapCount); 54 | writer.Write(Unknown3); 55 | writer.Write(Unknown4); 56 | writer.Write(SurfaceResourceName); 57 | 58 | fragment.SetData(newData.ToArray()); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpGfxSurfaceFormat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Archive.Erp.Data 8 | { 9 | public enum ErpGfxSurfaceFormat 10 | { 11 | ABGR8 = 15, 12 | DXT1 = 52, 13 | DXT1_SRGB = 54, 14 | DXT5 = 55, 15 | DXT5_SRGB = 57, 16 | // not sure anymore which is BC2/DXT3 and which is BC3/DXT5 17 | BC2_SRGB = 62, 18 | ATI1 = 63, 19 | ATI2 = 65, 20 | BC6 = 67, 21 | BC7 = 69, 22 | BC7_SRGB = 70 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpGfxSurfaceRes1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Archive.Erp.Data 8 | { 9 | public class ErpGfxSurfaceRes1 : ErpFragmentData 10 | { 11 | public byte[] Data { get; set; } = Array.Empty(); 12 | 13 | public override void FromFragment(ErpFragment fragment) 14 | { 15 | Data = fragment.GetDataArray(true); 16 | } 17 | 18 | public override void ToFragment(ErpFragment fragment) 19 | { 20 | fragment.SetData(Data); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/Data/ErpResourceData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Archive.Erp.Data 8 | { 9 | public abstract class ErpResourceData 10 | { 11 | public abstract void Read(ErpBinaryReader reader); 12 | public abstract void Write(ErpBinaryWriter writer); 13 | 14 | public abstract void FromResource(ErpResource resource); 15 | public abstract void ToResource(ErpResource resource); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/ErpBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Archive.Erp 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class ErpBinaryReader : EndianBinaryReader 12 | { 13 | public ErpBinaryReader(System.IO.Stream stream) 14 | : base(EndianBitConverter.Little, stream) 15 | { 16 | 17 | } 18 | public ErpBinaryReader(EndianBitConverter bitConverter, System.IO.Stream stream) 19 | : base(bitConverter, stream) 20 | { 21 | 22 | } 23 | 24 | public new string ReadString() 25 | { 26 | List fnBytes = new List(); 27 | byte filenameByte = this.ReadByte(); 28 | 29 | while (filenameByte != 0x00) 30 | { 31 | fnBytes.Add(filenameByte); 32 | filenameByte = this.ReadByte(); 33 | } 34 | 35 | return Encoding.UTF8.GetString(fnBytes.ToArray()); 36 | } 37 | 38 | public string ReadString(int length) 39 | { 40 | byte[] bytes = this.ReadBytes(length); 41 | 42 | int startEnd = bytes.Length; 43 | for (int i = 0; i < bytes.Length; ++i) 44 | { 45 | if (bytes[i] == 0x00) 46 | { 47 | startEnd = i; 48 | break; 49 | } 50 | } 51 | 52 | return Encoding.UTF8.GetString(bytes, 0, startEnd); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/ErpBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Archive.Erp 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class ErpBinaryWriter : EndianBinaryWriter 12 | { 13 | public ErpBinaryWriter(EndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public new void Write(string str) 19 | { 20 | byte[] data = Encoding.UTF8.GetBytes(str); 21 | this.Write(data); 22 | this.Write((byte)0x0); 23 | } 24 | public void Write(string str, int length) 25 | { 26 | byte[] data = Encoding.UTF8.GetBytes(str); 27 | this.Write(data); 28 | 29 | length = length - data.Length; 30 | if (length > 0) 31 | { 32 | this.Write(new byte[length]); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Erp/ErpCompressionAlgorithm.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Archive.Erp; 2 | 3 | public enum ErpCompressionAlgorithm : byte 4 | { 5 | None, 6 | Zlib = 0x01, 7 | 8 | /// 9 | /// This was introduced in Grid Legends. 10 | /// 11 | ZStandard2 = 0x03, 12 | 13 | ZStandard = 0x10, 14 | 15 | /// 16 | /// This was introduced in F1 23. 17 | /// 18 | ZStandard3 = 0x11, 19 | 20 | None2 = 0x81, 21 | None3 = 0x90, 22 | 23 | /// 24 | /// This was introduced in F1 23. 25 | /// 26 | None4 = 0x91 27 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Jpk/JpkBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Archive.Jpk 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class JpkBinaryReader : EndianBinaryReader 12 | { 13 | public JpkBinaryReader(EndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public new string ReadString() 19 | { 20 | List fnBytes = new List(); 21 | byte filenameByte; 22 | 23 | while ((filenameByte = this.ReadByte()) != 0x00) 24 | { 25 | fnBytes.Add(filenameByte); 26 | } 27 | 28 | return Encoding.UTF8.GetString(fnBytes.ToArray()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Archive/Jpk/JpkBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Archive.Jpk 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class JpkBinaryWriter : EndianBinaryWriter 12 | { 13 | public JpkBinaryWriter(LittleEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public void WriteObject(object data) 19 | { 20 | if (data.GetType() == typeof(int)) 21 | { 22 | Write((int)data); 23 | } 24 | else if (data.GetType() == typeof(float)) 25 | { 26 | Write((float)data); 27 | } 28 | else 29 | { 30 | throw new Exception("The writer does not recognize this data type! (" + data.GetType() + ")"); 31 | } 32 | } 33 | public new void Write(string str) 34 | { 35 | byte[] data = Encoding.UTF8.GetBytes(str); 36 | this.Write(data); 37 | this.Write((byte)0x0); 38 | } 39 | public void WriteTerminatedString(string s, byte terminator) 40 | { 41 | this.Write(Encoding.UTF8.GetBytes(s)); 42 | this.Write(terminator); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Collections/BitHelper.cs: -------------------------------------------------------------------------------- 1 | // https://github.com/dotnet/runtime/blob/64f5b0a2643bf63b8b13cd2ed01b58d5629aa812/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | 5 | using System.Diagnostics; 6 | 7 | namespace System.Collections.Generic 8 | { 9 | internal ref struct BitHelper 10 | { 11 | private const int IntSize = sizeof(int) * 8; 12 | private readonly Span _span; 13 | 14 | internal BitHelper(Span span, bool clear) 15 | { 16 | if (clear) 17 | { 18 | span.Clear(); 19 | } 20 | _span = span; 21 | } 22 | 23 | internal void MarkBit(int bitPosition) 24 | { 25 | Debug.Assert(bitPosition >= 0); 26 | 27 | uint bitArrayIndex = (uint)bitPosition / IntSize; 28 | 29 | // Workaround for https://github.com/dotnet/runtime/issues/72004 30 | Span span = _span; 31 | if (bitArrayIndex < (uint)span.Length) 32 | { 33 | span[(int)bitArrayIndex] |= (1 << (int)((uint)bitPosition % IntSize)); 34 | } 35 | } 36 | 37 | internal bool IsMarked(int bitPosition) 38 | { 39 | Debug.Assert(bitPosition >= 0); 40 | 41 | uint bitArrayIndex = (uint)bitPosition / IntSize; 42 | 43 | // Workaround for https://github.com/dotnet/runtime/issues/72004 44 | ReadOnlySpan span = _span; 45 | return 46 | bitArrayIndex < (uint)span.Length && 47 | (span[(int)bitArrayIndex] & (1 << ((int)((uint)bitPosition % IntSize)))) != 0; 48 | } 49 | 50 | /// How many ints must be allocated to represent n bits. Returns (n+31)/32, but avoids overflow. 51 | internal static int ToIntArrayLength(int n) => n > 0 ? ((n - 1) / IntSize + 1) : 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Collections/EnumerableHelpers.cs: -------------------------------------------------------------------------------- 1 | // https://github.com/dotnet/runtime/blob/64f5b0a2643bf63b8b13cd2ed01b58d5629aa812/src/libraries/Common/src/System/Collections/Generic/EnumerableHelpers.cs 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace EgoEngineLibrary.Collections; 9 | 10 | internal class EnumerableHelpers 11 | { 12 | /// Gets an enumerator singleton for an empty collection. 13 | internal static IEnumerator GetEmptyEnumerator() => 14 | ((IEnumerable)Array.Empty()).GetEnumerator(); 15 | } 16 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Collections/QuadTreeBounds.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace EgoEngineLibrary.Collections; 4 | 5 | public readonly record struct QuadTreeBounds(Vector2 Min, Vector2 Max) 6 | { 7 | public Vector2 Size => Max - Min; 8 | 9 | public Vector2 HalfSize => Size * 0.5f; 10 | } 11 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Collections/ThrowHelper.cs: -------------------------------------------------------------------------------- 1 | // https://github.com/dotnet/runtime/blob/64f5b0a2643bf63b8b13cd2ed01b58d5629aa812/src/libraries/System.Collections/src/System/Collections/ThrowHelper.cs 2 | // Licensed to the .NET Foundation under one or more agreements. 3 | // The .NET Foundation licenses this file to you under the MIT license. 4 | 5 | using System.Collections.Generic; 6 | using System.Diagnostics.CodeAnalysis; 7 | 8 | using EgoEngineLibrary.Resources; 9 | 10 | namespace System.Collections 11 | { 12 | internal static class ThrowHelper 13 | { 14 | /// Throws an exception for a key not being found in the dictionary. 15 | [DoesNotReturn] 16 | internal static void ThrowKeyNotFound(TKey key) => 17 | throw new KeyNotFoundException(string.Format(Strings.Arg_KeyNotFoundWithKey, key)); 18 | 19 | /// Throws an exception for trying to insert a duplicate key into the dictionary. 20 | [DoesNotReturn] 21 | internal static void ThrowDuplicateKey(TKey key) => 22 | throw new ArgumentException(string.Format(Strings.Argument_AddingDuplicate, key), nameof(key)); 23 | 24 | /// Throws an exception when erroneous concurrent use of a collection is detected. 25 | [DoesNotReturn] 26 | internal static void ThrowConcurrentOperation() => 27 | throw new InvalidOperationException(Strings.InvalidOperation_ConcurrentOperationsNotSupported); 28 | 29 | /// Throws an exception for an index being out of range. 30 | [DoesNotReturn] 31 | internal static void ThrowIndexArgumentOutOfRange() => 32 | throw new ArgumentOutOfRangeException("index"); 33 | 34 | /// Throws an exception for a version check failing during enumeration. 35 | [DoesNotReturn] 36 | internal static void ThrowVersionCheckFailed() => 37 | throw new InvalidOperationException(Strings.InvalidOperation_EnumFailedVersion); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Conversion/Endianness.cs: -------------------------------------------------------------------------------- 1 | // MiscUtil r285, February 26th 2009 2 | // Copyright (c) 2004-2008 Jon Skeet and Marc Gravell. 3 | // All rights reserved. 4 | 5 | namespace EgoEngineLibrary.Conversion 6 | { 7 | /// 8 | /// Endianness of a converter 9 | /// 10 | public enum Endianness 11 | { 12 | /// 13 | /// Little endian - least significant byte first 14 | /// 15 | LittleEndian, 16 | /// 17 | /// Big endian - most significant byte first 18 | /// 19 | BigEndian 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/DatabaseBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Data 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | 12 | public class DatabaseBinaryReader : EndianBinaryReader 13 | { 14 | public DatabaseBinaryReader(EndianBitConverter bitConverter, Stream stream) 15 | : base(bitConverter, stream) 16 | { 17 | } 18 | 19 | public string ReadDatabaseString(int maxLength) 20 | { 21 | int num = maxLength % 4; 22 | int count = (num == 3) ? (maxLength + 5) : (maxLength + (4 - num)); 23 | return Encoding.UTF8.GetString(base.ReadBytes(count)).TrimEnd(new char[1]); 24 | } 25 | 26 | public string ReadTerminatedString(byte terminator) 27 | { 28 | List list = new List(); 29 | for (byte i = base.ReadByte(); i != terminator; i = base.ReadByte()) 30 | { 31 | list.Add(i); 32 | } 33 | return Encoding.UTF8.GetString(list.ToArray()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/DatabaseBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Data 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | 12 | public class DatabaseBinaryWriter : EndianBinaryWriter 13 | { 14 | public DatabaseBinaryWriter(EndianBitConverter bitConverter, Stream stream) 15 | : base(bitConverter, stream) 16 | { 17 | } 18 | 19 | public void WriteDatabaseString(string s, int maxLength) 20 | { 21 | byte[] bytes = Encoding.UTF8.GetBytes(s); 22 | base.Write(bytes); 23 | int num = maxLength % 4; 24 | int num2 = ((num == 3) ? (maxLength + 5) : (maxLength + (4 - num))) - bytes.Length; 25 | while (num2-- > 0) 26 | { 27 | base.Write((byte)0); 28 | } 29 | } 30 | 31 | public void WriteTerminatedString(string s, byte terminator) 32 | { 33 | base.Write(Encoding.UTF8.GetBytes(s)); 34 | base.Write(terminator); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgBoolData.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgBoolData : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "bool"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 1; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public PkgBoolData(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadBoolean()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = bool.Parse(data); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgDataList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace EgoEngineLibrary.Data.Pkg.Data 4 | { 5 | public abstract class PkgDataList : PkgData 6 | { 7 | protected readonly List values; 8 | 9 | protected abstract uint DataByteSize { get; } 10 | 11 | public PkgDataList(PkgFile parentFile) 12 | : base(parentFile) 13 | { 14 | values = new List(); 15 | } 16 | 17 | protected uint ReadHeader(PkgBinaryReader reader) 18 | { 19 | var numData = reader.ReadUInt32(); 20 | _ = reader.ReadUInt32(); // bytesPerData 21 | return numData; 22 | } 23 | protected void WriteHeader(PkgBinaryWriter writer) 24 | { 25 | writer.Write(new byte[GetPaddingLength((int)writer.BaseStream.Position)]); 26 | writer.Write(ChunkType, 4); 27 | writer.Write(Type, 4); 28 | 29 | writer.Write((uint)values.Count); 30 | writer.Write(DataByteSize); 31 | } 32 | 33 | internal override void UpdateOffsets() 34 | { 35 | PkgValue._offset += 16 + values.Count * (int)DataByteSize; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgFp32Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Newtonsoft.Json; 7 | using System.Globalization; 8 | 9 | namespace EgoEngineLibrary.Data.Pkg.Data 10 | { 11 | public class PkgFp32Data : PkgDataList 12 | { 13 | public override string Type 14 | { 15 | get 16 | { 17 | return "fp32"; 18 | } 19 | } 20 | 21 | protected override uint DataByteSize 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public override int Align 30 | { 31 | get 32 | { 33 | return 4; 34 | } 35 | } 36 | 37 | public PkgFp32Data(PkgFile parentFile) 38 | : base(parentFile) 39 | { 40 | } 41 | 42 | public override void Read(PkgBinaryReader reader) 43 | { 44 | UInt32 numData = ReadHeader(reader); 45 | 46 | for (int i = 0; i < numData; ++i) 47 | { 48 | values.Add(reader.ReadSingle()); 49 | } 50 | } 51 | public override void Write(PkgBinaryWriter writer) 52 | { 53 | WriteHeader(writer); 54 | 55 | foreach (float f in values) 56 | { 57 | writer.Write(f); 58 | } 59 | } 60 | 61 | public override string GetData(Int32 index) 62 | { 63 | return Type + " " + values[index].ToString("0.##################", CultureInfo.InvariantCulture); 64 | } 65 | public override Int32 SetData(string data) 66 | { 67 | float res = Single.Parse(data, CultureInfo.InvariantCulture); 68 | int index = values.IndexOf(res); 69 | 70 | if (index >= 0) 71 | { 72 | return index; 73 | } 74 | else 75 | { 76 | index = values.Count; 77 | values.Add(res); 78 | return index; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgRgbaData.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgRgbaData : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "rgba"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 4; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public PkgRgbaData(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadUInt32()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index].ToString("X"); 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = uint.Parse(data, System.Globalization.NumberStyles.HexNumber); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgShnmData.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgShnmData : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "shnm"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 16; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 16; 26 | } 27 | } 28 | 29 | public PkgShnmData(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadString(16)); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val, 16); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var index = values.IndexOf(data); 60 | 61 | if (index >= 0) 62 | { 63 | return index; 64 | } 65 | else 66 | { 67 | index = values.Count; 68 | values.Add(data); 69 | return index; 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgSi32Data.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgSi32Data : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "si32"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 4; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public PkgSi32Data(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadInt32()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = int.Parse(data); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgSi64Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Data.Pkg.Data 8 | { 9 | public class PkgSi64Data : PkgDataList 10 | { 11 | public override string Type 12 | { 13 | get 14 | { 15 | return "si64"; 16 | } 17 | } 18 | 19 | protected override uint DataByteSize 20 | { 21 | get 22 | { 23 | return 8; 24 | } 25 | } 26 | 27 | public override int Align 28 | { 29 | get 30 | { 31 | return 8; 32 | } 33 | } 34 | 35 | public PkgSi64Data(PkgFile parentFile) 36 | : base(parentFile) 37 | { 38 | } 39 | 40 | public override void Read(PkgBinaryReader reader) 41 | { 42 | UInt32 numData = ReadHeader(reader); 43 | 44 | for (int i = 0; i < numData; ++i) 45 | { 46 | values.Add(reader.ReadInt64()); 47 | } 48 | } 49 | public override void Write(PkgBinaryWriter writer) 50 | { 51 | WriteHeader(writer); 52 | 53 | foreach (Int64 val in values) 54 | { 55 | writer.Write(val); 56 | } 57 | } 58 | 59 | public override string GetData(Int32 index) 60 | { 61 | return Type + " " + values[index]; 62 | } 63 | public override Int32 SetData(string data) 64 | { 65 | Int64 res = Int64.Parse(data); 66 | int index = values.IndexOf(res); 67 | 68 | if (index >= 0) 69 | { 70 | return index; 71 | } 72 | else 73 | { 74 | index = values.Count; 75 | values.Add(res); 76 | return index; 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgUi08Data.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgUi08Data : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "ui08"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 1; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public PkgUi08Data(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadByte()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = byte.Parse(data); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgUi16Data.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgUi16Data : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "ui16"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 2; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 4; 26 | } 27 | } 28 | 29 | public PkgUi16Data(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadUInt16()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = ushort.Parse(data); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgUi32Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Data.Pkg.Data 8 | { 9 | public class PkgUi32Data : PkgDataList 10 | { 11 | public override string Type 12 | { 13 | get 14 | { 15 | return "ui32"; 16 | } 17 | } 18 | 19 | protected override uint DataByteSize 20 | { 21 | get 22 | { 23 | return 4; 24 | } 25 | } 26 | 27 | public override int Align 28 | { 29 | get 30 | { 31 | return 4; 32 | } 33 | } 34 | 35 | public PkgUi32Data(PkgFile parentFile) 36 | : base(parentFile) 37 | { 38 | } 39 | 40 | public override void Read(PkgBinaryReader reader) 41 | { 42 | UInt32 numData = ReadHeader(reader); 43 | 44 | for (int i = 0; i < numData; ++i) 45 | { 46 | values.Add(reader.ReadUInt32()); 47 | } 48 | } 49 | public override void Write(PkgBinaryWriter writer) 50 | { 51 | WriteHeader(writer); 52 | 53 | foreach (UInt32 val in values) 54 | { 55 | writer.Write(val); 56 | } 57 | } 58 | 59 | public override string GetData(Int32 index) 60 | { 61 | return Type + " " + values[index]; 62 | } 63 | public override Int32 SetData(string data) 64 | { 65 | UInt32 res = UInt32.Parse(data); 66 | int index = values.IndexOf(res); 67 | 68 | if (index >= 0) 69 | { 70 | return index; 71 | } 72 | else 73 | { 74 | index = values.Count; 75 | values.Add(res); 76 | return index; 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgUi64Data.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Data.Pkg.Data 2 | { 3 | public class PkgUi64Data : PkgDataList 4 | { 5 | public override string Type 6 | { 7 | get 8 | { 9 | return "ui64"; 10 | } 11 | } 12 | 13 | protected override uint DataByteSize 14 | { 15 | get 16 | { 17 | return 8; 18 | } 19 | } 20 | 21 | public override int Align 22 | { 23 | get 24 | { 25 | return 8; 26 | } 27 | } 28 | 29 | public PkgUi64Data(PkgFile parentFile) 30 | : base(parentFile) 31 | { 32 | } 33 | 34 | public override void Read(PkgBinaryReader reader) 35 | { 36 | var numData = ReadHeader(reader); 37 | 38 | for (var i = 0; i < numData; ++i) 39 | { 40 | values.Add(reader.ReadUInt64()); 41 | } 42 | } 43 | public override void Write(PkgBinaryWriter writer) 44 | { 45 | WriteHeader(writer); 46 | 47 | foreach (var val in values) 48 | { 49 | writer.Write(val); 50 | } 51 | } 52 | 53 | public override string GetData(int index) 54 | { 55 | return Type + " " + values[index]; 56 | } 57 | public override int SetData(string data) 58 | { 59 | var res = ulong.Parse(data); 60 | var index = values.IndexOf(res); 61 | 62 | if (index >= 0) 63 | { 64 | return index; 65 | } 66 | else 67 | { 68 | index = values.Count; 69 | values.Add(res); 70 | return index; 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/Data/PkgWoidData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Data.Pkg.Data 4 | { 5 | public class PkgWoidData : PkgDataList 6 | { 7 | public override string Type 8 | { 9 | get 10 | { 11 | return "woid"; 12 | } 13 | } 14 | 15 | protected override uint DataByteSize 16 | { 17 | get 18 | { 19 | return 16; 20 | } 21 | } 22 | 23 | public override int Align 24 | { 25 | get 26 | { 27 | return 16; 28 | } 29 | } 30 | 31 | public PkgWoidData(PkgFile parentFile) 32 | : base(parentFile) 33 | { 34 | } 35 | 36 | public override void Read(PkgBinaryReader reader) 37 | { 38 | var numData = ReadHeader(reader); 39 | 40 | for (var i = 0; i < numData; ++i) 41 | { 42 | values.Add(Convert.ToBase64String(reader.ReadBytes(16), Base64FormattingOptions.None)); 43 | } 44 | } 45 | public override void Write(PkgBinaryWriter writer) 46 | { 47 | WriteHeader(writer); 48 | 49 | foreach (var val in values) 50 | { 51 | writer.Write(Convert.FromBase64String(val)); 52 | } 53 | } 54 | 55 | public override string GetData(int index) 56 | { 57 | return Type + " " + values[index]; 58 | } 59 | public override int SetData(string data) 60 | { 61 | var index = values.IndexOf(data); 62 | 63 | if (index >= 0) 64 | { 65 | return index; 66 | } 67 | else 68 | { 69 | index = values.Count; 70 | values.Add(data); 71 | return index; 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | using EgoEngineLibrary.Conversion; 8 | using EgoEngineLibrary.IO; 9 | 10 | namespace EgoEngineLibrary.Data.Pkg 11 | { 12 | public class PkgBinaryReader : EndianBinaryReader 13 | { 14 | public PkgBinaryReader(System.IO.Stream stream) 15 | : base(EndianBitConverter.Little, stream, Encoding.UTF8, false) 16 | { 17 | } 18 | public PkgBinaryReader(EndianBitConverter bitConverter, System.IO.Stream stream) 19 | : base(bitConverter, stream, Encoding.UTF8, false) 20 | { 21 | 22 | } 23 | 24 | public PkgOffsetType ReadOffsetType() 25 | { 26 | PkgOffsetType offsetType = new PkgOffsetType(); 27 | UInt32 temp = ReadUInt32(); 28 | offsetType.Type = (Byte)(temp >> 24); 29 | offsetType.Offset = (Int32)(temp & 0x00FFFFFF); 30 | return offsetType; 31 | } 32 | 33 | public new string ReadString() 34 | { 35 | Byte strLength = ReadByte(); 36 | string s = Encoding.GetString(ReadBytes(strLength)); 37 | ReadByte(); 38 | 39 | return s; 40 | } 41 | 42 | public string ReadString(int length) 43 | { 44 | byte[] bytes = this.ReadBytes(length); 45 | 46 | int startEnd = bytes.Length; 47 | for (int i = 0; i < bytes.Length; ++i) 48 | { 49 | if (bytes[i] == 0x00) 50 | { 51 | startEnd = i; 52 | break; 53 | } 54 | } 55 | 56 | return Encoding.GetString(bytes, 0, startEnd); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | using EgoEngineLibrary.Conversion; 5 | using EgoEngineLibrary.IO; 6 | 7 | namespace EgoEngineLibrary.Data.Pkg 8 | { 9 | public class PkgBinaryWriter : EndianBinaryWriter 10 | { 11 | public PkgBinaryWriter(System.IO.Stream stream) 12 | : base(EndianBitConverter.Little, stream, Encoding.UTF8, false) 13 | { 14 | } 15 | public PkgBinaryWriter(EndianBitConverter bitConverter, System.IO.Stream stream) 16 | : base(bitConverter, stream, Encoding.UTF8, false) 17 | { 18 | } 19 | 20 | public void Write(PkgOffsetType offsetType) 21 | { 22 | var temp = (uint)offsetType.Type << 24; 23 | temp += (uint)offsetType.Offset & 0x00FFFFFF; 24 | Write(temp); 25 | } 26 | 27 | public new void Write(string str) 28 | { 29 | var data = Encoding.GetBytes(str); 30 | Write(Convert.ToByte(data.Length)); 31 | Write(data); 32 | Write((byte)0x0); 33 | } 34 | public void Write(string str, int length) 35 | { 36 | var data = Encoding.GetBytes(str); 37 | Write(data); 38 | 39 | length -= data.Length; 40 | if (length > 0) 41 | { 42 | Write(new byte[length]); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgChunk.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoEngineLibrary.Data.Pkg 9 | { 10 | public abstract class PkgChunk 11 | { 12 | readonly PkgFile parentFile; 13 | 14 | public PkgFile ParentFile 15 | { 16 | get 17 | { 18 | return parentFile; 19 | } 20 | } 21 | 22 | protected abstract string ChunkType { get; } 23 | 24 | public PkgChunk(PkgFile parentFile) 25 | { 26 | this.parentFile = parentFile; 27 | } 28 | 29 | public abstract void Read(PkgBinaryReader reader); 30 | public abstract void Write(PkgBinaryWriter writer); 31 | internal abstract void UpdateOffsets(); 32 | 33 | public abstract void FromJson(JsonTextReader reader); 34 | public abstract void ToJson(JsonTextWriter writer); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgComplexValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Newtonsoft.Json; 7 | 8 | namespace EgoEngineLibrary.Data.Pkg 9 | { 10 | public abstract class PkgComplexValue : PkgChunk 11 | { 12 | public PkgComplexValue(PkgFile parentFile) 13 | : base(parentFile) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgDataArray.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Data.Pkg.Data; 2 | 3 | namespace EgoEngineLibrary.Data.Pkg 4 | { 5 | public class PkgDataArray : PkgArray 6 | { 7 | protected override string ChunkType 8 | { 9 | get 10 | { 11 | return "!vca"; 12 | } 13 | } 14 | 15 | public PkgDataArray(PkgFile parentFile) 16 | : base(parentFile) 17 | { 18 | } 19 | 20 | internal override void UpdateOffsets() 21 | { 22 | PkgValue._offset += 8 + 4 * Elements.Count; 23 | 24 | foreach (PkgValue val in Elements) 25 | { 26 | UpdatePaddingLength(val); 27 | val.UpdateOffsets(); 28 | } 29 | } 30 | private void UpdatePaddingLength(PkgValue val) 31 | { 32 | int padding; 33 | 34 | PkgData data = (PkgData)val.ComplexValueData; 35 | padding = data.GetPaddingLength(PkgValue._offset); 36 | 37 | PkgValue._offset += padding; 38 | } 39 | 40 | public string GetData(PkgOffsetType offsetType) 41 | { 42 | return ((PkgData)Elements[offsetType.Type].ComplexValueData).GetData(offsetType.Offset); 43 | } 44 | public void SetData(string data, PkgOffsetType offsetType) 45 | { 46 | string type = data.Remove(4); 47 | 48 | offsetType.Type = (byte)AddData(type); 49 | 50 | offsetType.Offset = ((PkgData)Elements[offsetType.Type].ComplexValueData).SetData(data.Substring(5)); 51 | } 52 | private int AddData(string type) 53 | { 54 | int typeIndex = Elements.FindIndex(x => ((PkgData)x.ComplexValueData).Type == type); 55 | 56 | if (typeIndex < 0) 57 | { 58 | typeIndex = (byte)Elements.Count; 59 | 60 | PkgValue val = new PkgValue(ParentFile); 61 | val.ValueOffsetType.Type = 128; 62 | val.ComplexValueData = PkgData.Create(ParentFile, type); 63 | Elements.Add(val); 64 | 65 | return typeIndex; 66 | } 67 | else 68 | { 69 | return typeIndex; 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgDataArrayReference.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace EgoEngineLibrary.Data.Pkg 4 | { 5 | public class PkgDataArrayReference : PkgComplexValue 6 | { 7 | protected override string ChunkType 8 | { 9 | get 10 | { 11 | return "!iar"; 12 | } 13 | } 14 | 15 | string reference; 16 | 17 | public PkgDataArrayReference(PkgFile parentFile) 18 | : base(parentFile) 19 | { 20 | reference = string.Empty; 21 | } 22 | 23 | public override void Read(PkgBinaryReader reader) 24 | { 25 | reference = reader.ReadString(8); 26 | } 27 | public override void Write(PkgBinaryWriter writer) 28 | { 29 | writer.Write(ChunkType, 4); 30 | writer.Write(reference, 8); 31 | } 32 | 33 | internal override void UpdateOffsets() 34 | { 35 | PkgValue._offset += 12; 36 | } 37 | 38 | public override void FromJson(JsonTextReader reader) 39 | { 40 | reference = ((string?)reader.Value)?.Substring(5) ?? string.Empty; 41 | } 42 | public override void ToJson(JsonTextWriter writer) 43 | { 44 | writer.WriteValue(ChunkType + " " + reference); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Data/Pkg/PkgOffsetType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Data.Pkg 8 | { 9 | public class PkgOffsetType 10 | { 11 | public Int32 Offset { get; set; } 12 | public Byte Type { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/EgoEngineLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | enable 5 | en-US 6 | Ego Engine Library 7 | Petar Tasev 8 | Petar Tasev 9 | 15.0.0 10 | 11 | Copyright © Petar Tasev 2019 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | PreserveNewest 29 | 30 | 31 | 32 | 33 | 34 | ResXFileCodeGenerator 35 | Strings.Designer.cs 36 | 37 | 38 | 39 | 40 | 41 | True 42 | True 43 | Strings.resx 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/Pssg/DirtCarExteriorPssgGltfConverter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoEngineLibrary.Formats.Pssg 9 | { 10 | // Dirt 1 car exterior is similar to interior except it uses VISIBLERENDERNODE instead 11 | public sealed class DirtCarExteriorPssgGltfConverter : CarInteriorPssgGltfConverter 12 | { 13 | private class DirtExportState : ExportState 14 | { 15 | public DirtExportState() 16 | { 17 | RenderNodeName = "VISIBLERENDERNODE"; 18 | } 19 | } 20 | 21 | public new static bool SupportsPssg(PssgFile pssg) 22 | { 23 | return pssg.FindNodes("VISIBLERENDERNODE").Any(); 24 | } 25 | 26 | protected override ExportState CreateState() 27 | { 28 | return new DirtExportState(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/Pssg/GltfDirtCarExteriorPssgConverter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoEngineLibrary.Formats.Pssg 9 | { 10 | public sealed class GltfDirtCarExteriorPssgConverter : GltfCarInteriorPssgConverter 11 | { 12 | private class DirtImportState : ImportState 13 | { 14 | public DirtImportState(PssgNode rdsLib, PssgNode ribLib, Dictionary shaderGroupMap) 15 | : base(rdsLib, ribLib, shaderGroupMap) 16 | { 17 | RenderNodeName = "VISIBLERENDERNODE"; 18 | } 19 | } 20 | 21 | public new static bool SupportsPssg(PssgFile pssg) 22 | { 23 | return pssg.FindNodes("VISIBLERENDERNODE").Any(); 24 | } 25 | 26 | protected override ImportState CreateState(PssgNode rdsLib, PssgNode ribLib, Dictionary shaderGroupMap) 27 | { 28 | return new DirtImportState(rdsLib, ribLib, shaderGroupMap); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/Pssg/PssgModelWriterState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Formats.Pssg 4 | { 5 | public abstract class PssgModelWriterState 6 | { 7 | public uint DataBlockCount { get; set; } 8 | 9 | public uint RenderStreamCount { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/Tpk/TpkImageFormat.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Formats.Tpk; 2 | 3 | public enum TpkImageFormat 4 | { 5 | Bgra = 16, 6 | Dxt1 = 22, 7 | Dxt3 = 23, 8 | Dxt5 = 24, 9 | } 10 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/CQuadTree.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | using EgoEngineLibrary.Collections; 4 | 5 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 6 | 7 | public class CQuadTree : CellQuadTree 8 | { 9 | public static CQuadTree Create(QuadTreeMeshData data) 10 | { 11 | var boundsMin = data.BoundsMin - CellQuadTree.Padding; 12 | var boundsMax = data.BoundsMax + CellQuadTree.Padding; 13 | var qt = new CQuadTree(boundsMin, boundsMax, data); 14 | for (var i = 0; i < qt._data.Triangles.Count; ++i) 15 | { 16 | qt.Add(i); 17 | } 18 | 19 | return qt; 20 | } 21 | 22 | private CQuadTree(Vector3 boundsMin, Vector3 boundsMax, QuadTreeMeshData data) 23 | : base(boundsMin, boundsMax, data, 12) 24 | { 25 | } 26 | 27 | protected override CQuadTree CreateChild(QuadTreeBounds bounds) 28 | { 29 | return new CQuadTree( 30 | new Vector3(bounds.Min.X, BoundsMin.Y, bounds.Min.Y), 31 | new Vector3(bounds.Max.X, BoundsMax.Y, bounds.Max.Y), Data) { Level = Level + 1 }; 32 | } 33 | 34 | protected override bool ShouldSplit() 35 | { 36 | // 16 tris is closest to CM's implementation, but creation is slow due to too many node splits 37 | return _triangleIndices.Count > 64; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/CQuadTreeType.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 2 | 3 | public enum CQuadTreeType 4 | { 5 | Dirt 6 | } 7 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/IQuadTreeTypeInfo.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 2 | 3 | public interface IQuadTreeTypeInfo 4 | { 5 | bool NegativeTriangles { get; } 6 | 7 | bool NegativeVertices { get; } 8 | 9 | bool NegativeMaterials { get; } 10 | 11 | int MaxMaterials { get; } 12 | 13 | int GetSheetInfo(ref string material); 14 | 15 | string GetMaterial(string material, int sheetInfo); 16 | 17 | int GetTriangleIndexOffset(int minIndex, int index); 18 | 19 | bool ShouldSplit(QuadTreeMeshDataView data); 20 | } 21 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/QuadTreeDataTriangle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | 4 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 5 | 6 | public record struct QuadTreeTriangle(int A, int B, int C, int MaterialIndex) 7 | { 8 | public int this[int index] 9 | { 10 | get 11 | { 12 | return index switch 13 | { 14 | 0 => A, 15 | 1 => B, 16 | 2 => C, 17 | _ => throw new ArgumentOutOfRangeException(nameof(index)) 18 | }; 19 | } 20 | set 21 | { 22 | switch (index) 23 | { 24 | case 0: 25 | A = value; 26 | break; 27 | case 1: 28 | B = value; 29 | break; 30 | case 2: 31 | C = value; 32 | break; 33 | default: 34 | throw new ArgumentOutOfRangeException(nameof(index)); 35 | } 36 | } 37 | } 38 | 39 | public void EnsureFirstIndexLowest() 40 | { 41 | if (B < A) 42 | { 43 | if (B < C) 44 | { 45 | (A, B, C) = (B, C, A); 46 | } 47 | else 48 | { 49 | (A, B, C) = (C, A, B); 50 | } 51 | } 52 | else if (C < A) 53 | { 54 | if (C < B) 55 | { 56 | (A, B, C) = (C, A, B); 57 | } 58 | else 59 | { 60 | (A, B, C) = (B, C, A); 61 | } 62 | } 63 | } 64 | } 65 | 66 | public readonly record struct QuadTreeDataTriangle(Vector3 Position0, Vector3 Position1, Vector3 Position2, string Material) 67 | { 68 | public (Vector3 BoundsMin, Vector3 BoundsMax) GetBounds() 69 | { 70 | var boundsMin = Vector3.Min(Vector3.Min(Position0, Position1), Position2); 71 | var boundsMax = Vector3.Max(Vector3.Max(Position0, Position1), Position2); 72 | return (boundsMin, boundsMax); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/QuadTreeMeshDataView.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using EgoEngineLibrary.Collections; 4 | 5 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 6 | 7 | public class QuadTreeMeshDataView 8 | { 9 | private readonly QuadTreeMeshData _data; 10 | private readonly OrderedSet _triangleIndices; 11 | private readonly OrderedSet _vertexIndices; 12 | private readonly OrderedSet _materialIndices; 13 | 14 | public IReadOnlyCollection TriangleIndices => _triangleIndices; 15 | 16 | public int NumVertices => _vertexIndices.Count; 17 | 18 | public int NumMaterials => _materialIndices.Count; 19 | 20 | public QuadTreeMeshDataView(QuadTreeMeshData data) 21 | { 22 | _data = data; 23 | _triangleIndices = []; 24 | _vertexIndices = []; 25 | _materialIndices = []; 26 | } 27 | 28 | public void Add(int data) 29 | { 30 | if (!_triangleIndices.Add(data)) 31 | { 32 | return; 33 | } 34 | 35 | var tri = _data.Triangles[data]; 36 | _vertexIndices.Add(tri.A); 37 | _vertexIndices.Add(tri.B); 38 | _vertexIndices.Add(tri.C); 39 | 40 | _materialIndices.Add(tri.MaterialIndex); 41 | } 42 | 43 | public void Clear() 44 | { 45 | _triangleIndices.Clear(); 46 | _vertexIndices.Clear(); 47 | _materialIndices.Clear(); 48 | } 49 | 50 | public QuadTreeMeshData ToData() 51 | { 52 | var data = new QuadTreeMeshDataBuilder(_data.TypeInfo); 53 | foreach (var index in _triangleIndices) 54 | { 55 | data.Add(_data.DataTriangles[index]); 56 | } 57 | 58 | return data.Build(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/CQuadTreeHeader.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 4 | 5 | public struct CQuadTreeHeader : IStaticQuadTreeHeader 6 | { 7 | public Vector3 BoundMin { get; set; } 8 | 9 | public Vector3 BoundMax { get; set; } 10 | 11 | public int NumTriangles { get; set; } 12 | 13 | public int NumVertices { get; set; } 14 | 15 | public int NumMaterials { get; set; } 16 | 17 | public uint VerticesOffset { get; set; } 18 | 19 | public uint NodesOffset { get; set; } 20 | 21 | public uint TrianglesOffset { get; set; } 22 | 23 | public uint TriangleReferencesOffset { get; set; } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/CQuadTreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 4 | 5 | public struct CQuadTreeNode : IStaticQuadTreeNode 6 | { 7 | private const int MaxTriangleListOffset = 0x7FFFFE; 8 | private const int MaxChildIndex = 0x7FFFFF; 9 | private const int LeafBit = 0x800000; 10 | private const int LeafWithoutTrianglesId = 0xFFFFFF; 11 | public const int MaxNodes = MaxChildIndex + 4; 12 | 13 | private byte _data0; 14 | private byte _data1; 15 | private byte _data2; 16 | 17 | private int ChildIndexOrTriangleListOffset 18 | { 19 | get => (_data0 << 16) | (_data1 << 8) | _data2; 20 | set 21 | { 22 | _data0 = (byte)(value >> 16); 23 | _data1 = (byte)(value >> 8); 24 | _data2 = (byte)value; 25 | } 26 | } 27 | 28 | public int TriangleListOffset 29 | { 30 | get => ChildIndexOrTriangleListOffset & (~LeafBit); 31 | set 32 | { 33 | if (value == -1) 34 | { 35 | ChildIndexOrTriangleListOffset = LeafWithoutTrianglesId; 36 | return; 37 | } 38 | 39 | ArgumentOutOfRangeException.ThrowIfNegative(value); 40 | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, MaxTriangleListOffset, nameof(TriangleListOffset)); 41 | ChildIndexOrTriangleListOffset = value | LeafBit; 42 | } 43 | } 44 | 45 | public int ChildIndex 46 | { 47 | get => ChildIndexOrTriangleListOffset; 48 | set 49 | { 50 | ArgumentOutOfRangeException.ThrowIfNegative(value); 51 | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, MaxChildIndex, nameof(ChildIndex)); 52 | 53 | ChildIndexOrTriangleListOffset = value; 54 | } 55 | } 56 | 57 | public bool IsLeaf => (ChildIndexOrTriangleListOffset & LeafBit) != 0; 58 | 59 | public bool HasTriangles => IsLeaf && ChildIndexOrTriangleListOffset != LeafWithoutTrianglesId; 60 | } 61 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/IStaticQuadTreeHeader.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 4 | 5 | public interface IStaticQuadTreeHeader 6 | { 7 | Vector3 BoundMin { get; } 8 | 9 | Vector3 BoundMax { get; } 10 | 11 | int NumTriangles { get; } 12 | 13 | int NumVertices { get; } 14 | 15 | int NumMaterials { get; } 16 | 17 | uint VerticesOffset { get; } 18 | 19 | uint NodesOffset { get; } 20 | 21 | uint TrianglesOffset { get; } 22 | 23 | uint TriangleReferencesOffset { get; } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/IStaticQuadTreeNode.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 2 | 3 | public interface IStaticQuadTreeNode 4 | { 5 | int TriangleListOffset { get; } 6 | 7 | int ChildIndex { get; } 8 | 9 | bool IsLeaf { get; } 10 | 11 | bool HasTriangles { get; } 12 | } 13 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/VcQuadTreeHeader.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 4 | 5 | public struct VcQuadTreeHeader : IStaticQuadTreeHeader 6 | { 7 | public Vector3 BoundMin { get; set; } 8 | 9 | public Vector3 BoundMax { get; set; } 10 | 11 | public int NumTriangles { get; set; } 12 | 13 | public int NumVertices { get; set; } 14 | 15 | public int NumMaterials { get; set; } 16 | 17 | public uint VerticesOffset { get; set; } 18 | 19 | public uint NodesOffset { get; set; } 20 | 21 | public uint TrianglesOffset { get; set; } 22 | 23 | public uint TriangleReferencesOffset { get; set; } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/Static/VcQuadTreeNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Formats.TrackQuadTree.Static; 4 | 5 | public struct VcQuadTreeNode : IStaticQuadTreeNode 6 | { 7 | private const int MaxTriangleListOffset = 0x7FFE; 8 | private const int MaxChildIndex = 0x7FFF; 9 | private const int LeafBit = 0x8000; 10 | private const int LeafWithoutTrianglesId = 0xFFFF; 11 | public const int MaxNodes = MaxChildIndex + 4; 12 | 13 | byte Data0 { get; set; } 14 | byte Data1 { get; set; } 15 | 16 | private int ChildIndexOrTriangleListOffset 17 | { 18 | get => (Data0 << 8) | Data1; 19 | set 20 | { 21 | Data0 = (byte)((value >> 8) & 0xFF); 22 | Data1 = (byte)(value & 0xFF); 23 | } 24 | } 25 | 26 | public int TriangleListOffset 27 | { 28 | get => ChildIndexOrTriangleListOffset & (~LeafBit); 29 | set 30 | { 31 | if (value == -1) 32 | { 33 | ChildIndexOrTriangleListOffset = LeafWithoutTrianglesId; 34 | return; 35 | } 36 | 37 | ArgumentOutOfRangeException.ThrowIfNegative(value); 38 | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, MaxTriangleListOffset, nameof(TriangleListOffset)); 39 | ChildIndexOrTriangleListOffset = value | LeafBit; 40 | } 41 | } 42 | 43 | public int ChildIndex 44 | { 45 | get => ChildIndexOrTriangleListOffset; 46 | set 47 | { 48 | ArgumentOutOfRangeException.ThrowIfNegative(value); 49 | ArgumentOutOfRangeException.ThrowIfGreaterThan(value, MaxChildIndex, nameof(ChildIndex)); 50 | 51 | ChildIndexOrTriangleListOffset = value; 52 | } 53 | } 54 | 55 | public bool IsLeaf => (ChildIndexOrTriangleListOffset & LeafBit) != 0; 56 | 57 | public bool HasTriangles => IsLeaf && ChildIndexOrTriangleListOffset != LeafWithoutTrianglesId; 58 | } 59 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/VcQuadTree.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | using EgoEngineLibrary.Collections; 4 | 5 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 6 | 7 | public class VcQuadTree : CellQuadTree 8 | { 9 | public static VcQuadTree Create(QuadTreeMeshData data) 10 | { 11 | var boundsMin = data.BoundsMin - CellQuadTree.Padding; 12 | var boundsMax = data.BoundsMax + CellQuadTree.Padding; 13 | var qt = new VcQuadTree(boundsMin, boundsMax, data); 14 | for (var i = 0; i < qt._data.Triangles.Count; ++i) 15 | { 16 | qt.Add(i); 17 | } 18 | 19 | return qt; 20 | } 21 | 22 | private VcQuadTree(Vector3 boundsMin, Vector3 boundsMax, QuadTreeMeshData data) 23 | : base(boundsMin, boundsMax, data, 16) 24 | { 25 | } 26 | 27 | protected override VcQuadTree CreateChild(QuadTreeBounds bounds) 28 | { 29 | return new VcQuadTree( 30 | new Vector3(bounds.Min.X, BoundsMin.Y, bounds.Min.Y), 31 | new Vector3(bounds.Max.X, BoundsMax.Y, bounds.Max.Y), Data) { Level = Level + 1 }; 32 | } 33 | 34 | protected override bool ShouldSplit() 35 | { 36 | return _triangleIndices.Count > 64; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Formats/TrackQuadTree/VcQuadTreeType.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Formats.TrackQuadTree; 2 | 3 | public enum VcQuadTreeType 4 | { 5 | /// 6 | /// RD:G and Dirt 2, F1 2014. 7 | /// 8 | RaceDriverGrid, 9 | Dirt3, 10 | DirtShowdown 11 | } 12 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/BcnExtensions.cs: -------------------------------------------------------------------------------- 1 | using BCnEncoder.Decoder; 2 | using BCnEncoder.Shared.ImageFiles; 3 | using SixLabors.ImageSharp; 4 | using SixLabors.ImageSharp.PixelFormats; 5 | using System; 6 | using System.Numerics; 7 | using System.Runtime.InteropServices; 8 | 9 | namespace EgoEngineLibrary.Graphics 10 | { 11 | public static class BcnExtensions 12 | { 13 | public static void DecodeDdsToPixels(this BcDecoder decoder, DdsFile dds, Span pixels) 14 | where TPixel : unmanaged, IPixel 15 | { 16 | var width = (int)dds.header.dwWidth; 17 | var height = (int)dds.header.dwHeight; 18 | if (decoder.IsHdrFormat(dds)) 19 | { 20 | var source = decoder.DecodeHdr(dds).AsSpan(); 21 | for (var r = 0; r < height; ++r) 22 | { 23 | var start = r * width; 24 | var destRow = pixels.Slice(start, width); 25 | var sorcRow = source.Slice(start, width); 26 | for (var c = 0; c < destRow.Length; ++c) 27 | { 28 | ref var destPixel = ref destRow[c]; 29 | ref var sorcPixel = ref sorcRow[c]; 30 | 31 | var rgbVal = sorcPixel.ToVector3(); 32 | destPixel.FromScaledVector4(new Vector4(rgbVal, 1)); 33 | } 34 | } 35 | } 36 | else 37 | { 38 | var source = MemoryMarshal.Cast(decoder.Decode(dds)); 39 | for (var r = 0; r < height; r++) 40 | { 41 | var start = r * width; 42 | var destRow = pixels.Slice(start, width); 43 | var sorcRow = source.Slice(start, width); 44 | PixelOperations.Instance.To(Configuration.Default, sorcRow, destRow); 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/Dds/D3D10_Resource_Dimension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Graphics.Dds 8 | { 9 | public enum D3D10_Resource_Dimension 10 | { 11 | D3D10_RESOURCE_DIMENSION_UNKNOWN = 0, 12 | D3D10_RESOURCE_DIMENSION_BUFFER = 1, 13 | D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, 14 | D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, 15 | D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/Dds/DDSHeaderDXT10.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Graphics.Dds 8 | { 9 | public struct DDSHeaderDXT10 10 | { 11 | public DXGI_Format dxgiFormat; 12 | public D3D10_Resource_Dimension resourceDimension; 13 | public UInt32 miscFlag; 14 | public UInt32 arraySize; 15 | public UInt32 miscFlags2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/Dds/DdsHeader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Graphics.Dds; 4 | 5 | public struct DdsHeader 6 | { 7 | public UInt32 size; 8 | public Flags flags; 9 | public UInt32 height; 10 | public UInt32 width; 11 | public UInt32 pitchOrLinearSize; 12 | public UInt32 depth; 13 | public UInt32 mipMapCount; 14 | public UInt32[] reserved1; // = new uint[11] 15 | public DdsPixelFormat ddspf; 16 | public Caps caps; 17 | public Caps2 caps2; 18 | public UInt32 caps3; 19 | public UInt32 caps4; 20 | public UInt32 reserved2; 21 | 22 | [Flags] 23 | public enum Flags : UInt32 24 | { 25 | DDSD_CAPS = 0x1, 26 | DDSD_HEIGHT = 0x2, 27 | DDSD_WIDTH = 0x4, 28 | DDSD_PITCH = 0x8, 29 | DDSD_PIXELFORMAT = 0x1000, 30 | DDSD_MIPMAPCOUNT = 0x20000, 31 | DDSD_LINEARSIZE = 0x80000, 32 | DDSD_DEPTH = 0x800000 33 | } 34 | 35 | [Flags] 36 | public enum Caps : UInt32 37 | { 38 | DDSCAPS_COMPLEX = 0x8, 39 | DDSCAPS_MIPMAP = 0x400000, 40 | DDSCAPS_TEXTURE = 0x1000 41 | } 42 | 43 | [Flags] 44 | public enum Caps2 : UInt32 45 | { 46 | DDSCAPS2_CUBEMAP = 0x200, 47 | DDSCAPS2_CUBEMAP_POSITIVEX = 0x400, 48 | DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800, 49 | DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000, 50 | DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000, 51 | DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000, 52 | DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000, 53 | DDSCAPS2_VOLUME = 0x200000 54 | } 55 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/Dds/DdsPixelFormat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace EgoEngineLibrary.Graphics.Dds; 4 | 5 | public struct DdsPixelFormat 6 | { 7 | public UInt32 size; 8 | public Flags flags; 9 | public UInt32 fourCC; 10 | public UInt32 rGBBitCount; 11 | public UInt32 rBitMask; 12 | public UInt32 gBitMask; 13 | public UInt32 bBitMask; 14 | public UInt32 aBitMask; 15 | 16 | [Flags] 17 | public enum Flags : UInt32 18 | { 19 | DDPF_ALPHAPIXELS = 0x1, 20 | DDPF_ALPHA = 0x2, 21 | DDPF_FOURCC = 0x4, 22 | DDPF_RGB = 0x40, 23 | DDPF_YUV = 0x200, 24 | DDPF_LUMINANCE = 0x20000 25 | } 26 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/PssgAttributeCollection.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Graphics 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | public class PssgAttributeCollection : IEnumerable 10 | { 11 | private List attributes; 12 | 13 | public PssgAttributeCollection() 14 | { 15 | attributes = new List(); 16 | } 17 | public PssgAttributeCollection(int capacity) 18 | { 19 | attributes = new List(capacity); 20 | } 21 | 22 | public PssgAttribute this[string attributeName] 23 | { 24 | get 25 | { 26 | for (int i = 0; i < attributes.Count; i++) 27 | { 28 | if (string.Equals(attributes[i].Name, attributeName, StringComparison.Ordinal)) 29 | { 30 | return attributes[i]; 31 | } 32 | } 33 | 34 | throw new ArgumentOutOfRangeException(nameof(attributeName)); 35 | } 36 | } 37 | 38 | internal bool Contains(string attributeName) 39 | { 40 | for (int i = 0; i < attributes.Count; i++) 41 | { 42 | if (string.Equals(attributes[i].Name, attributeName, StringComparison.Ordinal)) 43 | { 44 | return true; 45 | } 46 | } 47 | 48 | return false; 49 | } 50 | 51 | internal void Add(PssgAttribute attribute) 52 | { 53 | this.attributes.Add(attribute); 54 | } 55 | internal void Remove(PssgAttribute attribute) 56 | { 57 | this.attributes.Remove(attribute); 58 | } 59 | 60 | public int Count 61 | { 62 | get { return attributes.Count; } 63 | } 64 | 65 | public IEnumerator GetEnumerator() 66 | { 67 | return attributes.GetEnumerator(); 68 | } 69 | 70 | IEnumerator IEnumerable.GetEnumerator() 71 | { 72 | return GetEnumerator(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/PssgEnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoEngineLibrary.Graphics 8 | { 9 | public static class PssgEnumerableExtensions 10 | { 11 | public static IEnumerable FindNodes(this IEnumerable nodes, string nodeName) 12 | { 13 | foreach (var node in nodes) 14 | { 15 | if (node.Name == nodeName) 16 | { 17 | yield return node; 18 | } 19 | } 20 | } 21 | 22 | public static IEnumerable FindNodes(this IEnumerable nodes, string nodeName, string attributeName) 23 | { 24 | foreach (var node in nodes) 25 | { 26 | if (node.Name == nodeName && 27 | node.HasAttribute(attributeName)) 28 | { 29 | yield return node; 30 | } 31 | } 32 | } 33 | 34 | public static IEnumerable FindNodes(this IEnumerable nodes, string nodeName, string attributeName, T attributeValue) 35 | where T : notnull 36 | { 37 | foreach (var node in nodes) 38 | { 39 | if (node.Name == nodeName && 40 | node.HasAttribute(attributeName) && 41 | node.Attributes[attributeName].GetValue().Equals(attributeValue)) 42 | { 43 | yield return node; 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Graphics/PssgNodeCollection.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Graphics 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | public class PssgNodeCollection : IEnumerable 10 | { 11 | private List nodes; 12 | 13 | public PssgNodeCollection() 14 | { 15 | nodes = new List(); 16 | } 17 | public PssgNodeCollection(int capacity) 18 | { 19 | nodes = new List(capacity); 20 | } 21 | 22 | public PssgNode this[int index] 23 | { 24 | get 25 | { 26 | return nodes[index]; 27 | } 28 | } 29 | public PssgNode this[string nodeName] 30 | { 31 | get 32 | { 33 | for (int i = 0; i < nodes.Count; i++) 34 | { 35 | if (string.Equals(nodes[i].Name, nodeName, StringComparison.Ordinal)) 36 | { 37 | return nodes[i]; 38 | } 39 | } 40 | 41 | throw new ArgumentOutOfRangeException(nameof(nodeName)); 42 | } 43 | } 44 | 45 | internal void Add(PssgNode node) 46 | { 47 | this.nodes.Add(node); 48 | } 49 | internal PssgNode? Set(PssgNode node, PssgNode newNode) 50 | { 51 | for (int i = 0; i < this.nodes.Count; i++) 52 | { 53 | if (object.ReferenceEquals(this.nodes[i], node)) 54 | { 55 | return this.nodes[i] = newNode; 56 | } 57 | } 58 | 59 | return null; 60 | } 61 | internal bool Remove(PssgNode node) 62 | { 63 | return this.nodes.Remove(node); 64 | } 65 | 66 | public int Count 67 | { 68 | get { return nodes.Count; } 69 | } 70 | 71 | public IEnumerator GetEnumerator() 72 | { 73 | return nodes.GetEnumerator(); 74 | } 75 | 76 | IEnumerator IEnumerable.GetEnumerator() 77 | { 78 | return GetEnumerator(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/IO/StreamExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace EgoEngineLibrary.IO; 5 | 6 | public static class StreamExtensions 7 | { 8 | public static void ReadExactly(this Stream stream, Span buffer) 9 | { 10 | ArgumentNullException.ThrowIfNull(stream); 11 | 12 | var totalRead = 0; 13 | var count = buffer.Length; 14 | while (totalRead < count) 15 | { 16 | var readCount = stream.Read(buffer[totalRead..]); 17 | if (readCount == 0) 18 | { 19 | throw new EndOfStreamException("The end of the stream is reached."); 20 | } 21 | 22 | totalRead += readCount; 23 | } 24 | } 25 | 26 | public static bool TryReadExactly(this Stream stream, Span buffer) 27 | { 28 | ArgumentNullException.ThrowIfNull(stream); 29 | 30 | var totalRead = 0; 31 | var count = buffer.Length; 32 | while (totalRead < count) 33 | { 34 | var readCount = stream.Read(buffer[totalRead..]); 35 | if (readCount == 0) 36 | { 37 | return false; 38 | } 39 | 40 | totalRead += readCount; 41 | } 42 | 43 | return true; 44 | } 45 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/Bucket.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class Bucket 9 | { 10 | public int count; 11 | public List itemOffsets; 12 | 13 | public Bucket() 14 | { 15 | count = 0; 16 | itemOffsets = new List(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/HashEntry.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class HashEntry 9 | { 10 | public string Key; 11 | public string Value; 12 | 13 | public HashEntry() 14 | { 15 | Key = string.Empty; 16 | Value = string.Empty; 17 | } 18 | public HashEntry(string key, string value) 19 | { 20 | Key = key; 21 | Value = value; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/HashTable.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | public class HashTable : IEnumerable 10 | { 11 | private int Bucket; 12 | private List Entry; 13 | public int Count 14 | { 15 | get { return Entry.Count; } 16 | } 17 | 18 | public HashTable() 19 | { 20 | Bucket = 0; 21 | Entry = new List(); 22 | } 23 | public HashTable(int bucket, int count) 24 | { 25 | Bucket = bucket; 26 | Entry = new List(count); 27 | } 28 | 29 | public void Add(HashEntry entry) 30 | { 31 | Entry.Add(entry); 32 | } 33 | public void RemoveAt(int index) 34 | { 35 | Entry.RemoveAt(index); 36 | } 37 | 38 | public HashEntry this[int index] 39 | { 40 | get { return Entry[index]; } 41 | set { Entry[index] = value; } 42 | } 43 | 44 | public IEnumerator GetEnumerator() 45 | { 46 | foreach (HashEntry entry in Entry) 47 | { 48 | yield return entry; 49 | } 50 | } 51 | IEnumerator IEnumerable.GetEnumerator() 52 | { 53 | return GetEnumerator(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/Hshs.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class Hshs 9 | { 10 | public int Magic; 11 | public int Size; 12 | public uint Buckets; 13 | public uint Seed; 14 | public uint Multiplier; 15 | 16 | public Hshs(LngBinaryReader b) 17 | { 18 | Magic = b.ReadInt32(); 19 | Size = b.ReadInt32(); 20 | Buckets = b.ReadUInt32(); 21 | Seed = b.ReadUInt32(); 22 | Multiplier = b.ReadUInt32(); 23 | } 24 | public Hshs(int m, uint b, uint s, uint mult) 25 | { 26 | Magic = m; 27 | Size = 12; 28 | Buckets = b; 29 | Seed = s; 30 | Multiplier = mult; 31 | } 32 | 33 | public void Write(LngBinaryWriter writer) 34 | { 35 | writer.Write(Magic); 36 | writer.Write(Size); 37 | writer.Write(Buckets); 38 | writer.Write(Seed); 39 | writer.Write(Multiplier); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/LngB.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class LngB 9 | { 10 | public int Magic; 11 | public int Size; 12 | 13 | public LngB(LngBinaryReader b) 14 | { 15 | Magic = b.ReadInt32(); 16 | Size = b.ReadInt32(); 17 | } 18 | public LngB(int m) 19 | { 20 | Magic = m; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/LngBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Language 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class LngBinaryReader : EndianBinaryReader 12 | { 13 | public LngBinaryReader(BigEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public string ReadTerminatedString(byte terminator) 19 | { 20 | string filename = ""; 21 | List fnBytes = new List(); 22 | byte filenameByte = this.ReadByte(); 23 | while (filenameByte != terminator) 24 | { 25 | filename += (char)filenameByte; 26 | fnBytes.Add(filenameByte); 27 | filenameByte = this.ReadByte(); 28 | } 29 | return Encoding.UTF8.GetString(fnBytes.ToArray()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/LngBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Language 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class LngBinaryWriter : EndianBinaryWriter 12 | { 13 | public LngBinaryWriter(BigEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public void WriteTerminatedString(string s, byte terminator) 19 | { 20 | this.Write(Encoding.UTF8.GetBytes(s)); 21 | this.Write(terminator); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/SidA.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class SidA 9 | { 10 | public int Magic; 11 | public int Size; 12 | public SidaEntry[] Entry; 13 | 14 | public SidA(LngBinaryReader b) 15 | { 16 | Magic = b.ReadInt32(); 17 | Size = b.ReadInt32(); 18 | Entry = new SidaEntry[b.ReadInt32()]; 19 | for (int i = 0; i < Entry.Length; i++) 20 | { 21 | Entry[i].KeyOffset = b.ReadInt32(); 22 | Entry[i].ValueOffset = b.ReadInt32(); 23 | } 24 | } 25 | public SidA(int m) 26 | { 27 | Magic = m; 28 | Entry = Array.Empty(); 29 | } 30 | 31 | public void Write(LngBinaryWriter writer) 32 | { 33 | writer.Write(Magic); 34 | writer.Write(Size); 35 | writer.Write(Entry.Length); 36 | for (int i = 0; i < Entry.Length; i++) 37 | { 38 | writer.Write(Entry[i].KeyOffset); 39 | writer.Write(Entry[i].ValueOffset); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/SidB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace EgoEngineLibrary.Language 3 | { 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class SidB 9 | { 10 | public int Magic; 11 | public int Size; 12 | 13 | public SidB(LngBinaryReader b) 14 | { 15 | Magic = b.ReadInt32(); 16 | Size = b.ReadInt32(); 17 | } 18 | public SidB(int m) 19 | { 20 | Magic = m; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Language/SidaEntry.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Language 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public struct SidaEntry 9 | { 10 | public int KeyOffset; 11 | public int ValueOffset; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/CsvStreamReader.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Vehicle 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Globalization; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | public class CsvStreamReader : System.IO.StreamReader 10 | { 11 | public CsvStreamReader(System.IO.Stream stream) 12 | : base(stream, Encoding.UTF8) 13 | { 14 | } 15 | 16 | public object ReadEntryData(string type, string entry, string name) 17 | { 18 | switch (type) 19 | { 20 | case "int": 21 | if (string.IsNullOrEmpty(entry)) 22 | return string.Empty; 23 | return Convert.ToInt32(entry, CultureInfo.InvariantCulture); 24 | case "float": 25 | if (string.IsNullOrEmpty(entry)) 26 | return string.Empty; 27 | return Convert.ToSingle(entry, CultureInfo.InvariantCulture); 28 | case "double": 29 | if (string.IsNullOrEmpty(entry)) 30 | return string.Empty; 31 | return Convert.ToDouble(entry, CultureInfo.InvariantCulture); 32 | case "string": 33 | return entry; 34 | default: 35 | throw new Exception("An entry in the ctfSchema file has an incorrect type!"); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/CsvStreamWriter.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Vehicle 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Globalization; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | public class CsvStreamWriter : System.IO.StreamWriter 10 | { 11 | public CsvStreamWriter(System.IO.Stream stream) 12 | : base(stream, new System.Text.UTF8Encoding(false)) 13 | { 14 | } 15 | 16 | public void WriteEntryData(string type, object data) 17 | { 18 | switch (type) 19 | { 20 | case "int": 21 | Write(string.Format(CultureInfo.InvariantCulture, "{0:d}", data)); 22 | break; 23 | case "float": 24 | case "double": 25 | Write(string.Format(CultureInfo.InvariantCulture, "{0:f6}", data)); 26 | break; 27 | case "string": 28 | Write(string.Format(CultureInfo.InvariantCulture, "{0}", data)); 29 | break; 30 | default: 31 | throw new Exception("An entry in the ctfSchema file has an incorrect type!"); 32 | } 33 | Write(','); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/CtfBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Vehicle 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class CtfBinaryReader : EndianBinaryReader 12 | { 13 | public CtfBinaryReader(LittleEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public object ReadEntryData(string type) 19 | { 20 | switch (type) 21 | { 22 | case "int": 23 | return ReadInt32(); 24 | case "float": 25 | return ReadSingle(); 26 | case "double": 27 | return ReadDouble(); 28 | case "bool": 29 | return Convert.ToBoolean(ReadInt32()); 30 | case "string": 31 | return ReadTerminatedString(new byte()); 32 | case "float-list": 33 | return ReadFloatList(); 34 | default: 35 | throw new Exception("An entry in the ctfSchema file has an incorrect type!"); 36 | } 37 | } 38 | public string ReadTerminatedString(byte terminator) 39 | { 40 | List strBytes = new List(); 41 | do 42 | { 43 | strBytes.Add(ReadByte()); 44 | } while (strBytes[strBytes.Count - 1] != terminator); 45 | strBytes.RemoveAt(strBytes.Count - 1); 46 | return Encoding.UTF8.GetString(strBytes.ToArray()); 47 | } 48 | public FloatList ReadFloatList() 49 | { 50 | FloatList fList; 51 | fList.count = ReadInt32(); 52 | fList.step = ReadSingle(); 53 | fList.items = new float[fList.count]; 54 | for (int i = 0; i < fList.items.Length; i++) 55 | { 56 | fList.items[i] = ReadSingle(); 57 | } 58 | return fList; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/CtfBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Vehicle 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class CtfBinaryWriter : EndianBinaryWriter 12 | { 13 | public CtfBinaryWriter(LittleEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public void WriteEntryData(string type, object data) 19 | { 20 | switch (type) 21 | { 22 | case "int": 23 | Write((int)data); 24 | break; 25 | case "float": 26 | Write((float)data); 27 | break; 28 | case "double": 29 | Write((double)data); 30 | break; 31 | case "bool": 32 | Write(Convert.ToInt32((bool)data)); 33 | break; 34 | case "string": 35 | WriteTerminatedString((string)data, new byte()); 36 | break; 37 | case "float-list": 38 | WriteFloatList((FloatList)data); 39 | break; 40 | default: 41 | throw new Exception("An entry in the ctfSchema file has an incorrect type!"); 42 | } 43 | } 44 | public void WriteTerminatedString(string s, byte terminator) 45 | { 46 | this.Write(Encoding.UTF8.GetBytes(s)); 47 | this.Write(terminator); 48 | } 49 | public void WriteFloatList(FloatList fList) 50 | { 51 | Write(fList.count); 52 | Write(fList.step); 53 | for (int i = 0; i < fList.items.Length; i++) 54 | { 55 | Write(fList.items[i]); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/FloatList.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Vehicle 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public struct FloatList 9 | { 10 | public int count; 11 | public float step; 12 | public float[] items; 13 | 14 | public static bool operator ==(FloatList x, FloatList y) 15 | { 16 | if (x.count == y.count && x.step == y.step && Enumerable.SequenceEqual(x.items, y.items)) 17 | { 18 | return true; 19 | } 20 | else 21 | { 22 | return false; 23 | } 24 | } 25 | public static bool operator !=(FloatList x, FloatList y) 26 | { 27 | return !(x == y); 28 | } 29 | 30 | public override bool Equals(object? obj) 31 | { 32 | return obj is FloatList && this == (FloatList)obj; 33 | } 34 | 35 | public override int GetHashCode() 36 | { 37 | return count.GetHashCode() ^ step.GetHashCode() ^ items.GetHashCode(); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/PerformanceFile.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Vehicle 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | public class PerformanceFile 9 | { 10 | public string name; 11 | public string fileName; 12 | public CtfEditorGamePage parentPage; 13 | public bool hasChanges; 14 | public SortedDictionary entry = new SortedDictionary(); 15 | 16 | protected PerformanceFile(string _fileName, System.IO.Stream fileStream, CtfEditorGamePage _page) 17 | { 18 | name = System.IO.Path.GetFileName(_fileName); 19 | fileName = _fileName; 20 | parentPage = _page; 21 | hasChanges = false; 22 | } 23 | 24 | public virtual void Write(string _fileName, System.IO.FileStream fileStream) 25 | { 26 | name = System.IO.Path.GetFileName(_fileName); 27 | fileName = _fileName; 28 | hasChanges = false; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/TngBinaryReader.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Vehicle 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class TngBinaryReader : EndianBinaryReader 12 | { 13 | public TngBinaryReader(LittleEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public string ReadTerminatedString(byte terminator) 19 | { 20 | List strBytes = new List(); 21 | do 22 | { 23 | strBytes.Add(ReadByte()); 24 | } while (strBytes[strBytes.Count - 1] != terminator); 25 | strBytes.RemoveAt(strBytes.Count - 1); 26 | return Encoding.UTF8.GetString(strBytes.ToArray()); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/TngBinaryWriter.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Conversion; 2 | using EgoEngineLibrary.IO; 3 | 4 | namespace EgoEngineLibrary.Vehicle 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | 11 | public class TngBinaryWriter : EndianBinaryWriter 12 | { 13 | public TngBinaryWriter(LittleEndianBitConverter bitConverter, System.IO.Stream stream) 14 | : base(bitConverter, stream) 15 | { 16 | } 17 | 18 | public void WriteObject(object data) 19 | { 20 | if (data.GetType() == typeof(int)) 21 | { 22 | Write((int)data); 23 | } 24 | else if (data.GetType() == typeof(float)) 25 | { 26 | Write((float)data); 27 | } 28 | else 29 | { 30 | throw new Exception("The writer does not recognize this data type! (" + data.GetType() + ")"); 31 | } 32 | } 33 | public void WriteTerminatedString(string s, byte terminator) 34 | { 35 | this.Write(Encoding.UTF8.GetBytes(s)); 36 | this.Write(terminator); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Vehicle/TngInfo.cs: -------------------------------------------------------------------------------- 1 | //namespace EgoEngineLibrary.Vehicle 2 | //{ 3 | // using System; 4 | // using System.Collections.Generic; 5 | // using System.Linq; 6 | // using System.Text; 7 | 8 | // public class TngInfo 9 | // { 10 | // public int Id; 11 | // public string Name; 12 | // public bool IsParent; 13 | 14 | // public TngInfo() 15 | // { 16 | // Id = 0; 17 | // Name = string.Empty; 18 | // IsParent = false; 19 | // } 20 | // public TngInfo(TngBinaryReader reader, TngFile file) 21 | // { 22 | // Id = (int)reader.BaseStream.Position - 12; 23 | // Name = reader.ReadTerminatedString(0x00); 24 | // IsParent = Name.Contains('/'); 25 | 26 | // file.TngInfo.Add(Id, this); 27 | // } 28 | // } 29 | //} 30 | -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Xml/BinaryXmlAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace EgoEngineLibrary.Xml; 4 | 5 | public struct BinaryXmlAttribute 6 | { 7 | public int nameID; 8 | public int valueID; 9 | 10 | public XmlAttribute CreateAttribute(XmlDocument doc, BinaryXmlString strings) 11 | { 12 | var attr = doc.CreateAttribute(strings[nameID]); 13 | attr.Value = strings[valueID]; 14 | return attr; 15 | } 16 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Xml/BinaryXmlElement.cs: -------------------------------------------------------------------------------- 1 | using System.Xml; 2 | 3 | namespace EgoEngineLibrary.Xml; 4 | 5 | public struct BinaryXmlElement 6 | { 7 | public int elementNameId; 8 | public int elementValueId; 9 | public int attributeCount; 10 | public int attributeStartId; 11 | public int childElementCount; 12 | public int childElementStartId; 13 | 14 | public XmlElement CreateElement(XmlDocument doc, BinaryXmlString strings, BinaryXmlElement[] elements, 15 | BinaryXmlAttribute[] attributes) 16 | { 17 | var element = doc.CreateElement(strings[elementNameId]); 18 | for (var i = attributeStartId; i < attributeStartId + attributeCount; i++) 19 | { 20 | element.Attributes.Append(attributes[i].CreateAttribute(doc, strings)); 21 | } 22 | 23 | for (var i = childElementStartId; i < childElementStartId + childElementCount; i++) 24 | { 25 | element.AppendChild(elements[i].CreateElement(doc, strings, elements, attributes)); 26 | } 27 | 28 | // Don't allow TextNode if the Element has ChildElements 29 | if (elementValueId > 0 && childElementCount == 0) 30 | { 31 | element.AppendChild(doc.CreateTextNode(strings[elementValueId])); 32 | } 33 | 34 | return element; 35 | } 36 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Xml/BinaryXmlString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace EgoEngineLibrary.Xml; 5 | 6 | public class BinaryXmlString 7 | { 8 | private string[] _values; 9 | 10 | public BinaryXmlString() 11 | { 12 | _values = Array.Empty(); 13 | } 14 | 15 | // Reads all the strings available in the binary xml file 16 | // First Part is string data 17 | // Second part is position index of string data, not used by program 18 | public void Read(XmlBinaryReader reader) 19 | { 20 | // Section 3 21 | reader.ReadInt32(); 22 | var len = reader.ReadInt32(); 23 | var endPos = len + reader.BaseStream.Position; 24 | var vals = new List(); 25 | while (reader.BaseStream.Position < endPos) 26 | { 27 | var str = reader.ReadTerminatedString(); 28 | //if (!string.IsNullOrEmpty(str)) 29 | //{ 30 | vals.Add(str); 31 | //} 32 | } 33 | _values = vals.ToArray(); 34 | //System.Windows.Forms.MessageBox.Show(values.Length.ToString()); 35 | 36 | // Section 4 37 | reader.ReadInt32(); 38 | var len2 = reader.ReadInt32(); 39 | reader.Seek(len2, System.IO.SeekOrigin.Current); 40 | } 41 | 42 | public string this[int index] => _values[index]; 43 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/Xml/XmlType.cs: -------------------------------------------------------------------------------- 1 | namespace EgoEngineLibrary.Xml; 2 | 3 | public enum XmlType 4 | { 5 | Text, 6 | BinXml, 7 | BxmlBig, 8 | BxmlLittle 9 | } -------------------------------------------------------------------------------- /src/EgoEngineLibrary/libzstd.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoEngineLibrary/libzstd.dll -------------------------------------------------------------------------------- /src/EgoErpArchiver/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 2 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using EgoErpArchiver.ViewModel; 2 | using System.Windows; 3 | 4 | namespace EgoErpArchiver 5 | { 6 | /// 7 | /// Interaction logic for App.xaml 8 | /// 9 | public partial class App : Application 10 | { 11 | private void Application_Startup(object sender, StartupEventArgs e) 12 | { 13 | var mainVM = (MainViewModel)Current.Resources["MainVM"]; 14 | Current.Resources.Add("CommandLineArgs", e.Args); 15 | mainVM.ParseCommandLineArguments(); 16 | 17 | var wnd = new MainWindow(); 18 | wnd.Show(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoErpArchiver.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string F12016Dir { 30 | get { 31 | return ((string)(this["F12016Dir"])); 32 | } 33 | set { 34 | this["F12016Dir"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("2")] 41 | public int StartingTab { 42 | get { 43 | return ((int)(this["StartingTab"])); 44 | } 45 | set { 46 | this["StartingTab"] = value; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 2 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoErpArchiver/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoErpArchiver/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoErpArchiver/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoErpArchiver/Resources/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoErpArchiver/Resources/folder.png -------------------------------------------------------------------------------- /src/EgoErpArchiver/View/ProgressDialog.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/View/ProgressDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace EgoErpArchiver.View 16 | { 17 | /// 18 | /// Interaction logic for ProgressDialog.xaml 19 | /// 20 | public partial class ProgressDialog : Window 21 | { 22 | public ProgressDialog() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void statusTextBox_TextChanged(object sender, TextChangedEventArgs e) 28 | { 29 | scrollViewer.ScrollToBottom(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/ViewModel/ErpFragmentViewModel.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Archive.Erp; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoErpArchiver.ViewModel 9 | { 10 | public class ErpFragmentViewModel : TreeNodeViewModel 11 | { 12 | readonly ErpFragment fragment; 13 | 14 | public override string DisplayName 15 | { 16 | get 17 | { 18 | return Fragment.Name; 19 | } 20 | } 21 | 22 | public override ulong? Size 23 | { 24 | get 25 | { 26 | return Fragment.Size; 27 | } 28 | } 29 | 30 | public override ulong? PackedSize 31 | { 32 | get 33 | { 34 | return Fragment.PackedSize; 35 | } 36 | } 37 | 38 | public ErpFragment Fragment 39 | { 40 | get { return fragment; } 41 | } 42 | 43 | public ErpFragmentViewModel(ErpFragment fragment) 44 | { 45 | this.fragment = fragment; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/ViewModel/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Input; 8 | 9 | namespace EgoErpArchiver.ViewModel 10 | { 11 | /// 12 | /// A command whose sole purpose is to 13 | /// relay its functionality to other 14 | /// objects by invoking delegates. The 15 | /// default return value for the CanExecute 16 | /// method is 'true'. 17 | /// 18 | public class RelayCommand : ICommand 19 | { 20 | #region Fields 21 | 22 | readonly Action _execute; 23 | readonly Predicate _canExecute; 24 | 25 | #endregion // Fields 26 | 27 | #region Constructors 28 | 29 | /// 30 | /// Creates a new command that can always execute. 31 | /// 32 | /// The execution logic. 33 | public RelayCommand(Action execute) 34 | : this(execute, null) 35 | { 36 | } 37 | 38 | /// 39 | /// Creates a new command. 40 | /// 41 | /// The execution logic. 42 | /// The execution status logic. 43 | public RelayCommand(Action execute, Predicate canExecute) 44 | { 45 | if (execute == null) 46 | throw new ArgumentNullException("execute"); 47 | 48 | _execute = execute; 49 | _canExecute = canExecute; 50 | } 51 | 52 | #endregion // Constructors 53 | 54 | #region ICommand Members 55 | 56 | [DebuggerStepThrough] 57 | public bool CanExecute(object parameter) 58 | { 59 | return _canExecute == null ? true : _canExecute(parameter); 60 | } 61 | 62 | public event EventHandler CanExecuteChanged 63 | { 64 | add { CommandManager.RequerySuggested += value; } 65 | remove { CommandManager.RequerySuggested -= value; } 66 | } 67 | 68 | public void Execute(object parameter) 69 | { 70 | _execute(parameter); 71 | } 72 | 73 | #endregion // ICommand Members 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/ViewModel/TreeNodeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace EgoErpArchiver.ViewModel 9 | { 10 | public abstract class TreeNodeViewModel : ViewModelBase 11 | { 12 | public virtual string ResourceType 13 | { 14 | get { return null; } 15 | } 16 | 17 | public virtual ulong? Size 18 | { 19 | get { return null; } 20 | } 21 | 22 | public virtual ulong? PackedSize 23 | { 24 | get { return null; } 25 | } 26 | 27 | public virtual string FullPath 28 | { 29 | get { return null; } 30 | } 31 | 32 | public virtual void UpdateSize() 33 | { 34 | OnPropertyChanged("Size"); 35 | OnPropertyChanged("PackedSize"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/EgoErpArchiver/ViewModel/WorkspaceViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace EgoErpArchiver.ViewModel 8 | { 9 | public abstract class WorkspaceViewModel : ViewModelBase 10 | { 11 | protected readonly MainViewModel mainView; 12 | 13 | public WorkspaceViewModel(MainViewModel mainView) 14 | { 15 | this.mainView = mainView; 16 | } 17 | 18 | public abstract void LoadData(object data); 19 | 20 | public abstract void ClearData(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/EgoErpArchiverConsole/EgoErpArchiverConsole.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Exe 4 | Ego ERP Archiver Console 5 | false 6 | 7 | 8 | 9 | 10 | True 11 | True 12 | Resources.resx 13 | 14 | 15 | 16 | 17 | 18 | ResXFileCodeGenerator 19 | Resources.Designer.cs 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/EgoErpArchiverConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Ego ERP Archiver Console")] 9 | [assembly: AssemblyDescription("Console application to import/export ERP archives.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Petar Tasev")] 12 | [assembly: AssemblyProduct("Ego ERP Archiver Console")] 13 | [assembly: AssemblyCopyright("Copyright © Petar Tasev 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("b8c89f96-cb92-4214-957a-42148ee94c1f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.2016.1004")] 36 | [assembly: AssemblyFileVersion("1.0.2016.1004")] 37 | -------------------------------------------------------------------------------- /src/EgoFileConverter/EgoFileConverter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Exe 4 | ego-file-converter 5 | 6 | 7 | 8 | Resources\Ryder25.ico 9 | Copyright © Petar Tasev 2016 - 2024 10 | Petar Tasev 11 | Petar Tasev 12 | 4.0.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Always 22 | 23 | 24 | 25 | 26 | 27 | True 28 | True 29 | Resources.resx 30 | 31 | 32 | 33 | 34 | 35 | ResXFileCodeGenerator 36 | Resources.Designer.cs 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | all 47 | runtime; build; native; contentfiles; analyzers; buildtransitive 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/EgoFileConverter/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoFileConverter/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoFileConverter/UserPauseFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | using ConsoleAppFramework; 7 | 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace EgoFileConverter; 11 | 12 | internal class UserPauseFilter(ConsoleAppFilter next, ILogger logger) : ConsoleAppFilter(next) 13 | { 14 | public override async Task InvokeAsync(ConsoleAppContext context, CancellationToken cancellationToken) 15 | { 16 | var startTimestamp = Stopwatch.GetTimestamp(); 17 | try 18 | { 19 | await Next.InvokeAsync(context, cancellationToken); 20 | } 21 | catch (Exception ex) 22 | { 23 | logger.LogError(ex, null); 24 | } 25 | finally 26 | { 27 | Console.WriteLine(); 28 | logger.LogInformation("Elapsed time: {ElapsedTime}", Stopwatch.GetElapsedTime(startTimestamp)); 29 | logger.LogInformation("Press any key to exit..."); 30 | Console.ReadKey(true); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/EgoJpkArchiver/EgoJpkArchiver.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(TargetFramework)-windows 4 | WinExe 5 | true 6 | Ego JPK Archiver 7 | 8 | 9 | 10 | Resources\Ryder25.ico 11 | Ego JPK Archiver 12 | Ego JPK Archiver 13 | 2.1.0 14 | Petar Tasev 15 | Petar Tasev 16 | Copyright © Petar Tasev 2015 - 2024 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | ResXFileCodeGenerator 30 | Resources.Designer.cs 31 | Designer 32 | 33 | 34 | True 35 | Resources.resx 36 | True 37 | 38 | 39 | SettingsSingleFileGenerator 40 | Settings.Designer.cs 41 | 42 | 43 | True 44 | Settings.settings 45 | True 46 | 47 | 48 | 49 | Always 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgoJpkArchiver; 5 | 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main(string[] Args) 13 | { 14 | ApplicationConfiguration.Initialize(); 15 | Application.Run(new Form1(Args)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoJpkArchiver.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoJpkArchiver/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoJpkArchiver/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Resources/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoJpkArchiver/Resources/folder.png -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Resources/lorry_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoJpkArchiver/Resources/lorry_add.png -------------------------------------------------------------------------------- /src/EgoJpkArchiver/Resources/lorry_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoJpkArchiver/Resources/lorry_delete.png -------------------------------------------------------------------------------- /src/EgoLngEditor/AddRow.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | using System.Data; 3 | using EgoEngineLibrary.Language; 4 | 5 | namespace EgoLngEditor { 6 | public partial class AddRow : Form { 7 | LngFile file; 8 | public string Key { 9 | get { return textBox1.Text; } 10 | } 11 | public string Value { 12 | get { return richTextBox2.Text; } 13 | } 14 | 15 | public AddRow(LngFile _file) { 16 | InitializeComponent(); 17 | file = _file; 18 | textBox1.SelectAll(); 19 | } 20 | 21 | private void okButton_Click(object sender, System.EventArgs e) { 22 | //if (DT.Select("LNG_Key = '" + this.Key + "'").Length > 0) { 23 | //MessageBox.Show(file[this.Key]); 24 | if (file.ContainsKey(this.Key)) 25 | { 26 | MessageBox.Show("Please use a unique key, the one you have provided is already taken", "Unique ID", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 27 | this.DialogResult = DialogResult.None; 28 | return; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/EgoLngEditor/EgoLngEditor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | $(TargetFramework)-windows 4 | WinExe 5 | true 6 | Ego Language Editor 7 | false 8 | 9 | 10 | 11 | Resources\Ryder25.ico 12 | 13 | 14 | 15 | 16 | ..\..\References\DgvFilterPopup.dll 17 | 18 | 19 | 20 | 21 | 22 | ResXFileCodeGenerator 23 | Resources.Designer.cs 24 | Designer 25 | 26 | 27 | True 28 | Resources.resx 29 | True 30 | 31 | 32 | SettingsSingleFileGenerator 33 | Settings.Designer.cs 34 | 35 | 36 | True 37 | Settings.settings 38 | True 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/EgoLngEditor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgoLngEditor 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main(string[] args) 13 | { 14 | ApplicationConfiguration.Initialize(); 15 | Application.Run(new Form1(args)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/EgoLngEditor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Ego Language Editor")] 9 | [assembly: AssemblyDescription("Provides a nice GUI to edit language files from the EGO engine.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Petar Tasev")] 12 | [assembly: AssemblyProduct("Ego Language Editor")] 13 | [assembly: AssemblyCopyright("Copyright © Petar Tasev 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f8c43532-9522-4d5a-ba4f-0f5a7f826bd8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("4.0.2015.0918")] 36 | [assembly: AssemblyFileVersion("4.0.2015.0918")] 37 | -------------------------------------------------------------------------------- /src/EgoLngEditor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoLngEditor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EgoLngEditor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/find.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/folder.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/lorry_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/lorry_add.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/lorry_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/lorry_delete.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/table_multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/table_multiple.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/table_relationship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/table_relationship.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/table_row_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/table_row_delete.png -------------------------------------------------------------------------------- /src/EgoLngEditor/Resources/table_row_insert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoLngEditor/Resources/table_row_insert.png -------------------------------------------------------------------------------- /src/EgoPssgEditor/AddAttributeWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/AddNodeWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/AddNodeWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Shapes; 15 | 16 | namespace EgoPssgEditor 17 | { 18 | /// 19 | /// Interaction logic for AddNodeWindow.xaml 20 | /// 21 | public partial class AddNodeWindow : Window 22 | { 23 | public AddNodeWindow() 24 | { 25 | InitializeComponent(); 26 | 27 | // NodeInfo Combo 28 | nodeNameComboBox.ItemsSource = (PssgSchema.GetNodeNames()); 29 | // Select 30 | nodeNameComboBox.SelectedIndex = 0; 31 | } 32 | 33 | private void okButton_Click(object sender, RoutedEventArgs e) 34 | { 35 | this.DialogResult = true; 36 | } 37 | 38 | public string NodeName 39 | { 40 | get { return nodeNameComboBox.Text; } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Threading; 3 | using System.Windows; 4 | 5 | namespace EgoPssgEditor 6 | { 7 | /// 8 | /// Interaction logic for App.xaml 9 | /// 10 | public partial class App : Application 11 | { 12 | public App() 13 | { 14 | var culture = new CultureInfo("en-US"); 15 | 16 | Thread.CurrentThread.CurrentCulture = culture; 17 | Thread.CurrentThread.CurrentUICulture = culture; 18 | CultureInfo.DefaultThreadCurrentCulture = culture; 19 | CultureInfo.DefaultThreadCurrentUICulture = culture; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/EgoPssgEditor/DuplicateTextureWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/DuplicateTextureWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Shapes; 15 | 16 | namespace EgoPssgEditor 17 | { 18 | /// 19 | /// Interaction logic for DuplicateTextureWindow.xaml 20 | /// 21 | public partial class DuplicateTextureWindow : Window 22 | { 23 | public DuplicateTextureWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | private void okButton_Click(object sender, RoutedEventArgs e) 29 | { 30 | if (string.IsNullOrEmpty(TextureName) || string.IsNullOrWhiteSpace(TextureName)) 31 | { 32 | this.DialogResult = null; 33 | } 34 | else 35 | { 36 | this.DialogResult = true; 37 | } 38 | } 39 | 40 | public string TextureName 41 | { 42 | get { return textureNameTextBox.Text; } 43 | set { textureNameTextBox.Text = value; } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoPssgEditor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Input; 8 | 9 | namespace EgoPssgEditor 10 | { 11 | /// 12 | /// A command whose sole purpose is to 13 | /// relay its functionality to other 14 | /// objects by invoking delegates. The 15 | /// default return value for the CanExecute 16 | /// method is 'true'. 17 | /// 18 | public class RelayCommand : ICommand 19 | { 20 | #region Fields 21 | 22 | readonly Action _execute; 23 | readonly Predicate _canExecute; 24 | 25 | #endregion // Fields 26 | 27 | #region Constructors 28 | 29 | /// 30 | /// Creates a new command that can always execute. 31 | /// 32 | /// The execution logic. 33 | public RelayCommand(Action execute) 34 | : this(execute, null) 35 | { 36 | } 37 | 38 | /// 39 | /// Creates a new command. 40 | /// 41 | /// The execution logic. 42 | /// The execution status logic. 43 | public RelayCommand(Action execute, Predicate canExecute) 44 | { 45 | if (execute == null) 46 | throw new ArgumentNullException("execute"); 47 | 48 | _execute = execute; 49 | _canExecute = canExecute; 50 | } 51 | 52 | #endregion // Constructors 53 | 54 | #region ICommand Members 55 | 56 | [DebuggerStepThrough] 57 | public bool CanExecute(object parameter) 58 | { 59 | return _canExecute == null ? true : _canExecute(parameter); 60 | } 61 | 62 | public event EventHandler CanExecuteChanged 63 | { 64 | add { CommandManager.RequerySuggested += value; } 65 | remove { CommandManager.RequerySuggested -= value; } 66 | } 67 | 68 | public void Execute(object parameter) 69 | { 70 | _execute(parameter); 71 | } 72 | 73 | #endregion // ICommand Members 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoPssgEditor/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoPssgEditor/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoPssgEditor/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoPssgEditor/Resources/folder_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoPssgEditor/Resources/folder_image.png -------------------------------------------------------------------------------- /src/EgoPssgEditor/Resources/image_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoPssgEditor/Resources/image_add.png -------------------------------------------------------------------------------- /src/EgoPssgEditor/ViewModel/PssgAttributeViewModel.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoPssgEditor.ViewModel 9 | { 10 | public class PssgAttributeViewModel : ViewModelBase 11 | { 12 | readonly PssgAttribute attribute; 13 | readonly PssgNodeViewModel parent; 14 | 15 | public PssgAttribute Attribute 16 | { 17 | get { return attribute; } 18 | } 19 | public PssgNodeViewModel Parent 20 | { 21 | get { return parent; } 22 | } 23 | 24 | public override string DisplayName 25 | { 26 | get { return attribute.Name; } 27 | } 28 | public string DisplayValue 29 | { 30 | get { return attribute.DisplayValue; } 31 | set { attribute.DisplayValue = value; } 32 | } 33 | 34 | public PssgAttributeViewModel(PssgAttribute attribute, PssgNodeViewModel parent) 35 | { 36 | this.attribute = attribute; 37 | this.parent = parent; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/EgoPssgEditor/ViewModel/WorkspaceViewModel.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Graphics; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace EgoPssgEditor.ViewModel 9 | { 10 | public abstract class WorkspaceViewModel : ViewModelBase 11 | { 12 | protected readonly MainViewModel mainView; 13 | 14 | public WorkspaceViewModel(MainViewModel mainView) 15 | { 16 | this.mainView = mainView; 17 | } 18 | 19 | public abstract void LoadData(object data); 20 | 21 | public abstract void ClearData(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/EgoTngEditor/EgoTngEditor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | $(TargetFramework)-windows 4 | WinExe 5 | true 6 | Ego TNG Editor 7 | false 8 | 9 | 10 | 11 | Resources\Ryder25.ico 12 | 13 | 14 | 15 | 16 | ResXFileCodeGenerator 17 | Resources.Designer.cs 18 | Designer 19 | 20 | 21 | True 22 | Resources.resx 23 | True 24 | 25 | 26 | SettingsSingleFileGenerator 27 | Settings.Designer.cs 28 | 29 | 30 | True 31 | Settings.settings 32 | True 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/EgoTngEditor/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace EgoTngEditor 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main(string[] args) 13 | { 14 | ApplicationConfiguration.Initialize(); 15 | Application.Run(new Form1(args)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/EgoTngEditor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Ego TNG Editor")] 9 | [assembly: AssemblyDescription("Edit Tng files from the Ego Engine.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Petar Tasev")] 12 | [assembly: AssemblyProduct("Ego TNG Editor")] 13 | [assembly: AssemblyCopyright("Copyright © Petar Tasev 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("52e1bab3-5efa-49fd-9012-3cbc52fb47bc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.2013.0526")] 36 | [assembly: AssemblyFileVersion("1.0.2013.0526")] 37 | -------------------------------------------------------------------------------- /src/EgoTngEditor/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace EgoTngEditor.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/EgoTngEditor/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/EgoTngEditor/Resources/Ryder25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoTngEditor/Resources/Ryder25.ico -------------------------------------------------------------------------------- /src/EgoTngEditor/Resources/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoTngEditor/Resources/disk.png -------------------------------------------------------------------------------- /src/EgoTngEditor/Resources/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EgoEngineModding/Ego-Engine-Modding/b54f6c1ade7b5e1295a81008b578fc7a52964f4c/src/EgoTngEditor/Resources/folder.png -------------------------------------------------------------------------------- /src/Sandbox/Program.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Xml; 2 | 3 | namespace Sandbox; 4 | 5 | internal class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | VcQuadTreeSandbox.Run(args); 10 | } 11 | 12 | private static void XmlSandbox() 13 | { 14 | var files = Utils.GetFiles(@"C:\Games\Steam\steamapps\common\F1 2012"); 15 | foreach (var f in files) 16 | { 17 | try 18 | { 19 | using var fs = new FileStream(f, FileMode.Open, FileAccess.Read, FileShare.Read); 20 | var isXmlFile = XmlFile.IsXmlFile(fs); 21 | // if (f.EndsWith("reflections.xml")) 22 | // { 23 | // int a = 55; 24 | // } 25 | Console.WriteLine($"{f} {isXmlFile}"); 26 | var xml = new XmlFile(fs); 27 | //Console.WriteLine(xml.type); 28 | 29 | if (xml.Type != XmlType.Text) 30 | { 31 | using var ms = new MemoryStream(); 32 | xml.Write(ms); 33 | 34 | var mso = new MemoryStream(); 35 | fs.Seek(0, SeekOrigin.Begin); 36 | fs.CopyTo(mso); 37 | mso.Seek(0, SeekOrigin.Begin); 38 | ms.Seek(0, SeekOrigin.Begin); 39 | var orig = mso.ToArray(); 40 | var writ = ms.ToArray(); 41 | if (!orig.SequenceEqual(writ)) 42 | { 43 | throw new InvalidOperationException(); 44 | } 45 | } 46 | } 47 | catch (Exception e) 48 | { 49 | using var fs = new FileStream(f, FileMode.Open, FileAccess.Read, FileShare.Read); 50 | var type = XmlFile.GetXmlType(fs); 51 | if (type != XmlType.Text) 52 | { 53 | Console.WriteLine(e); 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Sandbox/Sandbox.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Sandbox/TpkSandbox.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Formats.Tpk; 2 | 3 | namespace Sandbox; 4 | 5 | public class TpkSandbox 6 | { 7 | public static void Run() 8 | { 9 | //foreach (var f in Directory.GetFiles(@"C:\Games\Steam\steamapps\common\Dirt 2\frontend\ts", "*.tpk", SearchOption.TopDirectoryOnly)) 10 | //foreach (var f in Directory.GetFiles(@"C:\Games\Steam\steamapps\common\DiRT 3 Complete Edition\frontend\ts", "*.tpk", SearchOption.TopDirectoryOnly)) 11 | //foreach (var f in Directory.GetFiles(@"C:\Games\Steam\steamapps\common\F1 2012\frontend\ts", "*.tpk", SearchOption.TopDirectoryOnly)) 12 | foreach (var f in Directory.GetFiles(@"C:\Games\Steam\steamapps\common\F1 2014\frontend\ts", "*.tpk", SearchOption.TopDirectoryOnly)) 13 | { 14 | var fName = Path.GetFileName(f); 15 | using var fsi = File.Open(f, FileMode.Open, FileAccess.Read, FileShare.Read); 16 | var tpk = new TpkFile(); 17 | tpk.Read(fsi); 18 | 19 | if (!Enum.IsDefined(tpk.Format)) 20 | { 21 | Console.WriteLine($"{fName}\t frmt {tpk.Format}"); 22 | } 23 | 24 | if (tpk.Name != Path.GetFileNameWithoutExtension(f)) 25 | { 26 | Console.WriteLine($"{fName}\t name {tpk.Name}"); 27 | } 28 | 29 | if (tpk.Unk11 != 0) 30 | { 31 | Console.WriteLine($"{fName}\t u11 {tpk.Unk11}"); 32 | } 33 | 34 | if (tpk.Unk12 != 1.0) 35 | { 36 | Console.WriteLine($"{fName}\t u12 {tpk.Unk12}"); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Sandbox/Utils.cs: -------------------------------------------------------------------------------- 1 | namespace Sandbox; 2 | 3 | public static class Utils 4 | { 5 | public static IEnumerable GetFiles(string filter, params string[] gameFolders) 6 | { 7 | var files = Enumerable.Empty(); 8 | foreach (var folder in gameFolders) 9 | { 10 | var folderFiles = Directory.EnumerateFiles(folder, filter, SearchOption.AllDirectories); 11 | files = files.Concat(folderFiles); 12 | } 13 | 14 | return files; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/EgoEngineLibrary.Tests/EgoEngineLibrary.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | enable 5 | enable 6 | 7 | false 8 | true 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/EgoEngineLibrary.Tests/Formats/TrackQuadTree/QuadTreeTriangleTests.cs: -------------------------------------------------------------------------------- 1 | using EgoEngineLibrary.Formats.TrackQuadTree; 2 | 3 | namespace EgoEngineLibrary.Tests.Formats.TrackQuadTree; 4 | 5 | public class QuadTreeTriangleTests 6 | { 7 | 8 | [Theory] 9 | [InlineData(0, 1, 2, 0, 1, 2)] 10 | [InlineData(0, 2, 1, 0, 2, 1)] 11 | [InlineData(1, 0, 2, 0, 2, 1)] 12 | [InlineData(1, 2, 0, 0, 1, 2)] 13 | [InlineData(2, 0, 1, 0, 1, 2)] 14 | [InlineData(2, 1, 0, 0, 2, 1)] 15 | public void PatchUp_Test(int a, int b, int c, int a2, int b2, int c2) 16 | { 17 | // Arrange 18 | var t = new QuadTreeTriangle(a, b, c, 5); 19 | 20 | // Act 21 | t.EnsureFirstIndexLowest(); 22 | 23 | // Assert 24 | Assert.Equal(a2, t.A); 25 | Assert.Equal(b2, t.B); 26 | Assert.Equal(c2, t.C); 27 | Assert.Equal(5, t.MaterialIndex); 28 | } 29 | } 30 | --------------------------------------------------------------------------------