diff --git a/CR2W2JSON/AudioEventArrayParser.cs b/CR2W2JSON.Core/AudioEventArrayParser.cs similarity index 99% rename from CR2W2JSON/AudioEventArrayParser.cs rename to CR2W2JSON.Core/AudioEventArrayParser.cs index de89736..c2a2ee1 100644 --- a/CR2W2JSON/AudioEventArrayParser.cs +++ b/CR2W2JSON.Core/AudioEventArrayParser.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { class AudioEventArray { diff --git a/CR2W2JSON/CR2W2JSON.csproj b/CR2W2JSON.Core/CR2W2JSON.Core.csproj similarity index 85% rename from CR2W2JSON/CR2W2JSON.csproj rename to CR2W2JSON.Core/CR2W2JSON.Core.csproj index 179aa4c..78ee54a 100644 --- a/CR2W2JSON/CR2W2JSON.csproj +++ b/CR2W2JSON.Core/CR2W2JSON.Core.csproj @@ -3,6 +3,8 @@ Exe net5.0 + CR2W2JSON.Core + CR2W2JSON.Core diff --git a/CR2W2JSON/IParser.cs b/CR2W2JSON.Core/IParser.cs similarity index 56% rename from CR2W2JSON/IParser.cs rename to CR2W2JSON.Core/IParser.cs index fd4fe2c..6b4bde0 100644 --- a/CR2W2JSON/IParser.cs +++ b/CR2W2JSON.Core/IParser.cs @@ -1,6 +1,4 @@ -using WolvenKit.Common.Model.Cr2w; - -namespace CR2W2JSON +namespace CR2W2JSON.Core { public interface IParser { diff --git a/CR2W2JSON/LocDataMapParser.cs b/CR2W2JSON.Core/LocDataMapParser.cs similarity index 96% rename from CR2W2JSON/LocDataMapParser.cs rename to CR2W2JSON.Core/LocDataMapParser.cs index f48e9bc..e0abea5 100644 --- a/CR2W2JSON/LocDataMapParser.cs +++ b/CR2W2JSON.Core/LocDataMapParser.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { public class LocDataMapParser : IParser { diff --git a/CR2W2JSON/OnScreenParser.cs b/CR2W2JSON.Core/OnScreenParser.cs similarity index 98% rename from CR2W2JSON/OnScreenParser.cs rename to CR2W2JSON.Core/OnScreenParser.cs index fb0d106..fed96de 100644 --- a/CR2W2JSON/OnScreenParser.cs +++ b/CR2W2JSON.Core/OnScreenParser.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { class OnScreenEntries { diff --git a/CR2W2JSON/Program.cs b/CR2W2JSON.Core/Program.cs similarity index 96% rename from CR2W2JSON/Program.cs rename to CR2W2JSON.Core/Program.cs index 494ab23..df8cfc8 100644 --- a/CR2W2JSON/Program.cs +++ b/CR2W2JSON.Core/Program.cs @@ -1,90 +1,90 @@ -#nullable enable -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; -using Catel.IoC; -using WolvenKit.Common.Model.Cr2w; -using WolvenKit.Common.Services; -using WolvenKit.RED4.CR2W; -using System.CommandLine; -using System.CommandLine.Invocation; - -namespace CR2W2JSON -{ - class Json - { - [JsonInclude] - [JsonPropertyName("RootType")] - public string RootType; - - [JsonInclude] - [JsonPropertyName("Data")] - public object Data; - } - - class Program - { - [SuppressMessage("ReSharper.DPA", "DPA0002: Excessive memory allocations in SOH", MessageId = "type: System.Reflection.CustomAttributeNamedParameter[]")] - static int Main(string[] args) - { - var rootCommand = new RootCommand - { - new Argument("input", "CR2W file"), - new Argument("output", "JSON file") - }; - - var locator = ServiceLocator.Default; - locator.RegisterType(); - - rootCommand.Handler = CommandHandler.Create((input, output) => - { - var s = new Cp77FileService(); - var CR2W = s.TryReadCr2WFile( - File.OpenRead(input.FullName) - ); - - var vcc = CR2W.Chunks[0].VirtualChildrenChunks[0]; - - var parser = GetParserByType(vcc.REDType, vcc); - if (parser == null) - { - Console.WriteLine("Unknown REDType: " + vcc.REDType); - Environment.Exit(1); - } - - var json = new Json - { - RootType = vcc.REDType, - Data = parser.GetData() - }; - - File.WriteAllText(output.FullName, JsonSerializer.Serialize(json)); - }); - - return rootCommand.InvokeAsync(args).Result; - } - - private static IParser? GetParserByType(string type, ICR2WExport chunk) - { - switch (type) - { - case "audioAudioEventArray": - return new AudioEventArrayParser(chunk); - case "localizationPersistenceOnScreenEntries": - return new OnScreenParser(chunk); - case "localizationPersistenceLocDataMap": - return new LocDataMapParser(chunk); - case "locVoLanguageDataMap": - return new VOLanguageDataMapParser(chunk); - case "locVoiceoverMap": - return new VOMapParser(chunk); - case "locVoiceoverLengthMap": - return new StringIDVariantLengthsReportParser(chunk); - } - - return null; - } - } -} +#nullable enable +using System; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; +using Catel.IoC; +using WolvenKit.Common.Model.Cr2w; +using WolvenKit.Common.Services; +using WolvenKit.RED4.CR2W; + +namespace CR2W2JSON.Core +{ + class Json + { + [JsonInclude] + [JsonPropertyName("RootType")] + public string RootType; + + [JsonInclude] + [JsonPropertyName("Data")] + public object Data; + } + + class Program + { + [SuppressMessage("ReSharper.DPA", "DPA0002: Excessive memory allocations in SOH", MessageId = "type: System.Reflection.CustomAttributeNamedParameter[]")] + static int Main(string[] args) + { + var rootCommand = new RootCommand + { + new Argument("input", "CR2W file"), + new Argument("output", "JSON file") + }; + + var locator = ServiceLocator.Default; + locator.RegisterType(); + + rootCommand.Handler = CommandHandler.Create((input, output) => + { + var s = new Cp77FileService(); + var CR2W = s.TryReadCr2WFile( + File.OpenRead(input.FullName) + ); + + var vcc = CR2W.Chunks[0].VirtualChildrenChunks[0]; + + var parser = GetParserByType(vcc.REDType, vcc); + if (parser == null) + { + Console.WriteLine("Unknown REDType: " + vcc.REDType); + Environment.Exit(1); + } + + var json = new Json + { + RootType = vcc.REDType, + Data = parser.GetData() + }; + + File.WriteAllText(output.FullName, JsonSerializer.Serialize(json)); + }); + + return rootCommand.InvokeAsync(args).Result; + } + + private static IParser? GetParserByType(string type, ICR2WExport chunk) + { + switch (type) + { + case "audioAudioEventArray": + return new AudioEventArrayParser(chunk); + case "localizationPersistenceOnScreenEntries": + return new OnScreenParser(chunk); + case "localizationPersistenceLocDataMap": + return new LocDataMapParser(chunk); + case "locVoLanguageDataMap": + return new VOLanguageDataMapParser(chunk); + case "locVoiceoverMap": + return new VOMapParser(chunk); + case "locVoiceoverLengthMap": + return new StringIDVariantLengthsReportParser(chunk); + } + + return null; + } + } +} diff --git a/CR2W2JSON/StringIDVariantLengthsReportParser.cs b/CR2W2JSON.Core/StringIDVariantLengthsReportParser.cs similarity index 96% rename from CR2W2JSON/StringIDVariantLengthsReportParser.cs rename to CR2W2JSON.Core/StringIDVariantLengthsReportParser.cs index 4bc101f..aac5b04 100644 --- a/CR2W2JSON/StringIDVariantLengthsReportParser.cs +++ b/CR2W2JSON.Core/StringIDVariantLengthsReportParser.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { public class StringIDVariantLengthsReportParser : IParser { diff --git a/CR2W2JSON/VOLanguageDataMapParser.cs b/CR2W2JSON.Core/VOLanguageDataMapParser.cs similarity index 97% rename from CR2W2JSON/VOLanguageDataMapParser.cs rename to CR2W2JSON.Core/VOLanguageDataMapParser.cs index bf75d7c..cab3c69 100644 --- a/CR2W2JSON/VOLanguageDataMapParser.cs +++ b/CR2W2JSON.Core/VOLanguageDataMapParser.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { public class VOLanguageDataMapParser : IParser { diff --git a/CR2W2JSON/VOMapParser.cs b/CR2W2JSON.Core/VOMapParser.cs similarity index 96% rename from CR2W2JSON/VOMapParser.cs rename to CR2W2JSON.Core/VOMapParser.cs index 35113aa..b5166be 100644 --- a/CR2W2JSON/VOMapParser.cs +++ b/CR2W2JSON.Core/VOMapParser.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; using WolvenKit.Common.Model.Cr2w; -namespace CR2W2JSON +namespace CR2W2JSON.Core { public class VOMapParser : IParser { diff --git a/CR2W2JSON.sln b/CR2W2JSON.sln index 8c3e18d..02d7869 100644 --- a/CR2W2JSON.sln +++ b/CR2W2JSON.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31402.337 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CR2W2JSON", "CR2W2JSON\CR2W2JSON.csproj", "{1A857D34-CFFF-42FB-8380-5094F6DC3CE1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CR2W2JSON.Core", "CR2W2JSON.Core\CR2W2JSON.Core.csproj", "{1A857D34-CFFF-42FB-8380-5094F6DC3CE1}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WolvenKit.Common", "WolvenKit.Common\WolvenKit.Common.csproj", "{E4D1FE0D-A2EB-49E6-967D-CE9BA23D41D1}" EndProject