Skip to content

Commit

Permalink
Project rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
West14 committed Jun 15, 2021
1 parent 157a301 commit 85a64df
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text.Json.Serialization;
using WolvenKit.Common.Model.Cr2w;

namespace CR2W2JSON
namespace CR2W2JSON.Core
{
class AudioEventArray
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>CR2W2JSON.Core</AssemblyName>
<RootNamespace>CR2W2JSON.Core</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions CR2W2JSON/IParser.cs → CR2W2JSON.Core/IParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using WolvenKit.Common.Model.Cr2w;

namespace CR2W2JSON
namespace CR2W2JSON.Core
{
public interface IParser
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Text.Json.Serialization;
using WolvenKit.Common.Model.Cr2w;

namespace CR2W2JSON
namespace CR2W2JSON.Core
{
class OnScreenEntries
{
Expand Down
180 changes: 90 additions & 90 deletions CR2W2JSON/Program.cs → CR2W2JSON.Core/Program.cs
Original file line number Diff line number Diff line change
@@ -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<FileInfo>("input", "CR2W file"),
new Argument<FileInfo>("output", "JSON file")
};

var locator = ServiceLocator.Default;
locator.RegisterType<ILoggerService, LoggerService>();

rootCommand.Handler = CommandHandler.Create<FileInfo, FileInfo>((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<FileInfo>("input", "CR2W file"),
new Argument<FileInfo>("output", "JSON file")
};

var locator = ServiceLocator.Default;
locator.RegisterType<ILoggerService, LoggerService>();

rootCommand.Handler = CommandHandler.Create<FileInfo, FileInfo>((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;
}
}
}
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
5 changes: 2 additions & 3 deletions CR2W2JSON/VOMapParser.cs → CR2W2JSON.Core/VOMapParser.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion CR2W2JSON.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85a64df

Please sign in to comment.