mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-29 21:36:36 -05:00
add updated bcsv specs, show in columns
This commit is contained in:
@@ -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++)
|
||||
|
||||
@@ -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}";
|
||||
}
|
||||
}
|
||||
|
||||
40
NHSE.Parsing/Properties/Resources.Designer.cs
generated
40
NHSE.Parsing/Properties/Resources.Designer.cs
generated
@@ -63,28 +63,32 @@ internal class Resources {
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to from bcsv import *
|
||||
///
|
||||
///enum_8c2aec6a = (
|
||||
/// ('Before', '前日'),
|
||||
/// ('Skip' , '中止'),
|
||||
/// ('Same' , '同時開催'),
|
||||
///enum_009fa2d460ce_286d6aa2ee6b = (
|
||||
/// ('EC', '東進入禁止'),
|
||||
/// ('WC', '西進入禁止'),
|
||||
/// ('3B', '東西進入可'),
|
||||
///)
|
||||
///
|
||||
///enum_GroundedItemType = (
|
||||
/// ('All' , '全部'),
|
||||
/// ('TreeOak' , '植物:木:広葉樹'),
|
||||
/// ('TreeOakStump' , '植物:木:広葉樹:切り株'),
|
||||
/// ('TreeCedar' , '植物:木:針葉樹'),
|
||||
/// ('TreeCedarStump' , '植物:木:針葉樹:切り株'),
|
||||
/// ('TreePalm' , '植物:木:ヤシの木'),
|
||||
/// ('TreePalmStump' , '植物:木:ヤシの木:切り株'),
|
||||
/// ('TreeBamboo' , '植物:木:竹'),
|
||||
/// ('TreeBambooStump', '植物:木:竹:切り株'),
|
||||
/// ('TreeFruit' , '植物:木:果物'),
|
||||
/// ('TreeEasterEgg' , [rest of string was truncated]";.
|
||||
///enum_01016811d685_37fe72043e75 = (
|
||||
/// ('KeepSwimming' , '回遊:通常'),
|
||||
/// ('Float' , '待機'),
|
||||
/// ('RoundsSwimming', '回遊:見回り'),
|
||||
/// ('ChasePlayer' , 'プレイヤーサーチ'),
|
||||
/// ('Legion' , '大群'),
|
||||
/// ('Predator' , '捕食者'),
|
||||
/// ('AntiStream' , '抗水流'),
|
||||
/// ('SwimAndWait' , '回遊&待機'),
|
||||
///)
|
||||
///
|
||||
///enum_017c76af34f4_35ed35a1a2a5 = (
|
||||
/// ('Light' , '軽い'),
|
||||
/// ('Normal' , '通常'),
|
||||
/// ('Heavy' , '重い'),
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string specs_111 {
|
||||
internal static string specs_120 {
|
||||
get {
|
||||
return ResourceManager.GetString("specs_111", resourceCulture);
|
||||
return ResourceManager.GetString("specs_120", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
6971
NHSE.Parsing/Resources/specs_120.txt
Normal file
6971
NHSE.Parsing/Resources/specs_120.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user