-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
286 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
namespace I3DShapesTool | ||
{ | ||
class I3DShape | ||
public class I3DShape | ||
{ | ||
public int Type { get; } | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9DFD6611-B506-4F53-961E-912DCE4EFD9E}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>I3DShapesToolTest</RootNamespace> | ||
<AssemblyName>I3DShapesToolTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath> | ||
<IsCodedUITest>False</IsCodedUITest> | ||
<TestProjectType>UnitTest</TestProjectType> | ||
<NuGetPackageImportStamp> | ||
</NuGetPackageImportStamp> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="SteamHelper.cs" /> | ||
<Compile Include="UnitTest.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\I3DShapesTool\I3DShapesTool.csproj"> | ||
<Project>{0e254dd0-b7e2-4009-a460-ed817130aafd}</Project> | ||
<Name>I3DShapesTool</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.props'))" /> | ||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets'))" /> | ||
</Target> | ||
<Import Project="..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.3.2\build\net45\MSTest.TestAdapter.targets')" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: AssemblyTitle("I3DShapesToolTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("I3DShapesToolTest")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
[assembly: ComVisible(false)] | ||
|
||
[assembly: Guid("9dfd6611-b506-4f53-961e-912dce4efd9e")] | ||
|
||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Microsoft.Win32; | ||
|
||
namespace I3DShapesToolTest | ||
{ | ||
class SteamHelper | ||
{ | ||
private static List<string> steamGameDirs; | ||
|
||
public static void LoadSteamGameDirectories() | ||
{ | ||
steamGameDirs = new List<string>(); | ||
const string steam32 = "SOFTWARE\\VALVE\\"; | ||
const string steam64 = "SOFTWARE\\Wow6432Node\\Valve\\"; | ||
var key32 = Registry.LocalMachine.OpenSubKey(steam32); | ||
var key64 = Registry.LocalMachine.OpenSubKey(steam64); | ||
if (key64?.ToString() == null || key64.ToString() == "") | ||
{ | ||
foreach (var k32SubKey in key32.GetSubKeyNames()) | ||
{ | ||
using (var subKey = key32.OpenSubKey(k32SubKey)) | ||
{ | ||
var steam32Path = subKey?.GetValue("InstallPath").ToString(); | ||
var config32Path = $"{steam32Path}/steamapps/libraryfolders.vdf"; | ||
const string driveRegex = @"[A-Z]:\\"; | ||
if (!File.Exists(config32Path)) continue; | ||
var configLines = File.ReadAllLines(config32Path); | ||
foreach (var item in configLines) | ||
{ | ||
//Console.WriteLine($"32: {item}"); | ||
var match = Regex.Match(item, driveRegex); | ||
if (item == string.Empty || !match.Success) continue; | ||
var matched = match.ToString(); | ||
var item2 = item.Substring(item.IndexOf(matched, StringComparison.Ordinal)); | ||
item2 = item2.Replace("\\\\", "\\"); | ||
item2 = item2.Replace("\"", "\\steamapps\\common\\"); | ||
steamGameDirs.Add(item2); | ||
} | ||
steamGameDirs.Add($"{steam32Path}\\steamapps\\common\\"); | ||
} | ||
} | ||
} | ||
foreach (var k64SubKey in key64.GetSubKeyNames()) | ||
{ | ||
using (var subKey = key64.OpenSubKey(k64SubKey)) | ||
{ | ||
var steam64Path = subKey?.GetValue("InstallPath").ToString(); | ||
var config64Path = $"{steam64Path}/steamapps/libraryfolders.vdf"; | ||
const string driveRegex = @"[A-Z]:\\"; | ||
if (!File.Exists(config64Path)) continue; | ||
var configLines = File.ReadAllLines(config64Path); | ||
foreach (var item in configLines) | ||
{ | ||
//Console.WriteLine($"64: {item}"); | ||
var match = Regex.Match(item, driveRegex); | ||
if (item == string.Empty || !match.Success) continue; | ||
var matched = match.ToString(); | ||
var item2 = item.Substring(item.IndexOf(matched, StringComparison.Ordinal)); | ||
item2 = item2.Replace("\\\\", "\\"); | ||
item2 = item2.Replace("\"", "\\steamapps\\common\\"); | ||
steamGameDirs.Add(item2); | ||
} | ||
steamGameDirs.Add($"{steam64Path}\\steamapps\\common\\"); | ||
} | ||
} | ||
} | ||
|
||
public static string GetGameDirectory(string gameFolderName) | ||
{ | ||
foreach (var steamGameDir in steamGameDirs) | ||
{ | ||
if (Directory.Exists(Path.Combine(steamGameDir, gameFolderName))) | ||
return Path.Combine(steamGameDir, gameFolderName); | ||
} | ||
|
||
Assert.Inconclusive($"{gameFolderName} not found installed."); | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.IO; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using I3DShapesTool; | ||
|
||
namespace I3DShapesToolTest | ||
{ | ||
[TestClass] | ||
public class UnitTest | ||
{ | ||
[TestInitialize] | ||
public void TestInit() | ||
{ | ||
SteamHelper.LoadSteamGameDirectories(); | ||
} | ||
|
||
private static void AssertShapesFile(I3DShapesFile file, int seed, int version, int shapeCount) | ||
{ | ||
Assert.AreEqual(seed, file.Seed, "Unexpected seed"); | ||
Assert.AreEqual(version, file.Version, "Unexpected version"); | ||
Assert.AreEqual(shapeCount, file.ShapeCount, "Unexpected shape count"); | ||
} | ||
|
||
private static void AssertShape(I3DShape shape, string name, uint shapeId, int vertexCount, int faceCount) | ||
{ | ||
Assert.AreEqual(name, shape.Name); | ||
Assert.AreEqual(shapeId, shape.ShapeId); | ||
Assert.AreEqual(vertexCount, shape.Positions.Length); | ||
Assert.AreEqual(vertexCount, shape.Normals.Length); | ||
Assert.AreEqual(vertexCount, shape.UVs.Length); | ||
Assert.AreEqual(faceCount, shape.Triangles.Length); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFS19_1() | ||
{ | ||
var gameFolder = SteamHelper.GetGameDirectory("Farming Simulator 19"); | ||
|
||
var file = new I3DShapesFile(); | ||
file.Load(Path.Combine(gameFolder, @"data\vehicles\magsi\telehandlerBaleFork\telehandlerBaleFork.i3d.shapes")); | ||
AssertShapesFile(file, 201, 5, 9); | ||
AssertShape(file.Shapes[0], "colPartBackShape1", 4, 24, 12); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFS17_1() | ||
{ | ||
var gameFolder = SteamHelper.GetGameDirectory("Farming Simulator 17"); | ||
|
||
var file = new I3DShapesFile(); | ||
file.Load(Path.Combine(gameFolder, @"data\vehicles\tools\magsi\wheelLoaderLogFork.i3d.shapes")); | ||
AssertShapesFile(file, 49, 5, 12); | ||
AssertShape(file.Shapes[0], "wheelLoaderLogForkShape", 1, 24, 12); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFS15_1() | ||
{ | ||
var gameFolder = SteamHelper.GetGameDirectory("Farming Simulator 15"); | ||
|
||
var file = new I3DShapesFile(); | ||
file.Load(Path.Combine(gameFolder, @"data\vehicles\tools\grimme\grimmeFT300.i3d.shapes")); | ||
AssertShapesFile(file, 188, 3, 16); | ||
AssertShape(file.Shapes[0], "grimmeFTShape300", 1, 40, 20); | ||
} | ||
|
||
[TestMethod] | ||
public void TestFS13_1() | ||
{ | ||
var gameFolder = SteamHelper.GetGameDirectory("Farming Simulator 2013"); | ||
|
||
var file = new I3DShapesFile(); | ||
file.Load(Path.Combine(gameFolder, @"data\vehicles\tools\kuhn\kuhnGA4521GM.i3d.shapes")); | ||
AssertShapesFile(file, 68, 2, 32); | ||
AssertShape(file.Shapes[0], "blanketBarShape2", 26, 68, 44); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net461" /> | ||
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net461" /> | ||
</packages> |