-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
104 additions
and
108 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
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using WolvenKit.Common.Model.Cr2w; | ||
|
||
namespace CR2W2JSON | ||
namespace CR2W2JSON.Core | ||
{ | ||
public interface IParser | ||
{ | ||
|
5 changes: 2 additions & 3 deletions
5
CR2W2JSON/LocDataMapParser.cs → CR2W2JSON.Core/LocDataMapParser.cs
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 |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
...SON/StringIDVariantLengthsReportParser.cs → ...ore/StringIDVariantLengthsReportParser.cs
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
5 changes: 2 additions & 3 deletions
5
CR2W2JSON/VOLanguageDataMapParser.cs → CR2W2JSON.Core/VOLanguageDataMapParser.cs
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