add updated bcsv specs, show in columns

This commit is contained in:
Kurt
2020-05-06 18:19:24 -07:00
parent 5779b65b9b
commit 8cda44eb9a
6 changed files with 7051 additions and 6391 deletions

View File

@@ -8,7 +8,7 @@ namespace NHSE.Parsing
{
public class BCSV
{
private static readonly BCSVEnumDictionary EnumLookup = new BCSVEnumDictionary(Resources.specs_111.Split('\n'));
public static readonly BCSVEnumDictionary EnumLookup = new BCSVEnumDictionary(Resources.specs_120.Split('\n'));
public const int MAGIC = 0x42435356; // BCSV
@@ -91,7 +91,7 @@ private int GetFieldLength(in int i)
public string[] ReadCSV(string delim = "\t")
{
var result = new string[EntryCount + 1];
result[0] = string.Join(delim, FieldOffsets.Select(z => $"0x{z.ColumnKey:X8}"));
result[0] = string.Join(delim, FieldOffsets.Select(z => EnumLookup[z.ColumnKey]));
var start = GetFirstEntryOffset();
for (int entry = 0; entry < EntryCount; entry++)

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NHSE.Core;
namespace NHSE.Parsing
{
@@ -12,27 +14,61 @@ public BCSVEnumDictionary(IEnumerable<string> lines)
foreach (var line in lines)
{
var trim = line.Trim();
if (!trim.StartsWith("("))
continue;
if (!trim.EndsWith("),"))
continue;
var text = trim.Split('\'')[1];
if (text.Length == 0)
continue;
var hash = CRC32.Compute(text);
if (Lookup.TryGetValue(hash, out var exist))
{
if (exist == text)
continue;
Console.WriteLine($"Duplicate KVP: {exist} -- old, {text} -- new.");
continue;
}
Lookup.Add(hash, text);
if (trim.StartsWith("("))
AddEnumName(trim);
if (trim.Contains(" = "))
AddColumnName(trim);
}
}
private void AddColumnName(string trim)
{
if (!trim.EndsWith(")"))
return;
if (trim.StartsWith("_"))
return;
var text = trim.Split(new [] {" = "}, 0);
var name = text[0];
var value = text[1].Substring(text[1].IndexOf('(') + 1);
value = value.Substring(2, value.Length - 3);
var hex = StringUtil.GetHexValue(value);
if (Lookup.TryGetValue(hex, out var exist))
{
if (exist == name)
return;
Console.WriteLine($"Duplicate KVP: {exist} -- old, {name} -- new.");
return;
}
Lookup.Add(hex, name);
}
private void AddEnumName(string trim)
{
if (!trim.EndsWith("),"))
return;
var text = trim.Split('\'')[1];
if (text.Length == 0)
return;
var hash = CRC32.Compute(text);
if (Lookup.TryGetValue(hash, out var exist))
{
if (exist == text)
return;
Console.WriteLine($"Duplicate KVP: {exist} -- old, {text} -- new.");
return;
}
Lookup.Add(hash, text);
}
public IEnumerable<string> Dump() => Lookup.Select(z => $"{z.Key:X8}\t{z.Value}");
public string this[uint key] => Lookup.TryGetValue(key, out var val) ? val : $"0x{key:X8}";
}
}

View File

@@ -63,28 +63,32 @@ internal class Resources {
/// <summary>
/// Looks up a localized string similar to from bcsv import *
///
///enum_8c2aec6a = (
/// (&apos;Before&apos;, &apos;前日&apos;),
/// (&apos;Skip&apos; , &apos;中止&apos;),
/// (&apos;Same&apos; , &apos;同時開催&apos;),
///enum_009fa2d460ce_286d6aa2ee6b = (
/// (&apos;EC&apos;, &apos;東進入禁止&apos;),
/// (&apos;WC&apos;, &apos;西進入禁止&apos;),
/// (&apos;3B&apos;, &apos;東西進入可&apos;),
///)
///
///enum_GroundedItemType = (
/// (&apos;All&apos; , &apos;全部&apos;),
/// (&apos;TreeOak&apos; , &apos;植物:木:広葉樹&apos;),
/// (&apos;TreeOakStump&apos; , &apos;植物:木:広葉樹:切り株&apos;),
/// (&apos;TreeCedar&apos; , &apos;植物:木:針葉樹&apos;),
/// (&apos;TreeCedarStump&apos; , &apos;植物:木:針葉樹:切り株&apos;),
/// (&apos;TreePalm&apos; , &apos;植物:木:ヤシの木&apos;),
/// (&apos;TreePalmStump&apos; , &apos;植物:木:ヤシの木:切り株&apos;),
/// (&apos;TreeBamboo&apos; , &apos;植物:木:竹&apos;),
/// (&apos;TreeBambooStump&apos;, &apos;植物:木:竹:切り株&apos;),
/// (&apos;TreeFruit&apos; , &apos;植物:木:果物&apos;),
/// (&apos;TreeEasterEgg&apos; , [rest of string was truncated]&quot;;.
///enum_01016811d685_37fe72043e75 = (
/// (&apos;KeepSwimming&apos; , &apos;回遊:通常&apos;),
/// (&apos;Float&apos; , &apos;待機&apos;),
/// (&apos;RoundsSwimming&apos;, &apos;回遊:見回り&apos;),
/// (&apos;ChasePlayer&apos; , &apos;プレイヤーサーチ&apos;),
/// (&apos;Legion&apos; , &apos;大群&apos;),
/// (&apos;Predator&apos; , &apos;捕食者&apos;),
/// (&apos;AntiStream&apos; , &apos;抗水流&apos;),
/// (&apos;SwimAndWait&apos; , &apos;回遊&待機&apos;),
///)
///
///enum_017c76af34f4_35ed35a1a2a5 = (
/// (&apos;Light&apos; , &apos;軽い&apos;),
/// (&apos;Normal&apos; , &apos;通常&apos;),
/// (&apos;Heavy&apos; , &apos;重い&apos;),
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string specs_111 {
internal static string specs_120 {
get {
return ResourceManager.GetString("specs_111", resourceCulture);
return ResourceManager.GetString("specs_120", resourceCulture);
}
}
}

View File

@@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="specs_111" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\specs_111.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<data name="specs_120" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\specs_120.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff