mirror of
https://github.com/xivdev/EXDSchema.git
synced 2025-06-06 16:17:46 +00:00
Minor cleanup on converter
This commit is contained in:
parent
ee23d7f3fe
commit
f1295ec1f7
3 changed files with 41 additions and 17 deletions
|
@ -30,7 +30,5 @@ public class ColumnInfo
|
||||||
Targets = targets;
|
Targets = targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override string ToString() => $"{Name} ({Index}@{BitOffset / 8}&{BitOffset % 8}) {Type} {IsArrayMember} {ArrayIndex}";
|
public override string ToString() => $"{Name} ({Index}@{BitOffset / 8}&{BitOffset % 8}) {Type} {IsArrayMember} {ArrayIndex}";
|
||||||
}
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
namespace SchemaConverter;
|
|
||||||
|
|
||||||
public class DetectedArraySpecs
|
|
||||||
{
|
|
||||||
public int Count;
|
|
||||||
public int StartOffset { get; set; }
|
|
||||||
public int EndOffset { get; set; }
|
|
||||||
public List<ColumnInfo> Members { get; set; } = new();
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Lumina;
|
using Lumina;
|
||||||
using Lumina.Data.Files.Excel;
|
using Lumina.Data.Files.Excel;
|
||||||
using Lumina.Data.Structs.Excel;
|
using Lumina.Data.Structs.Excel;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -55,7 +55,7 @@ public class SchemaConverter
|
||||||
}
|
}
|
||||||
var result = Convert(exh, oldSchemaPath, newSchemaPath);
|
var result = Convert(exh, oldSchemaPath, newSchemaPath);
|
||||||
var strResult = result ? "succeeded!" : "failed...";
|
var strResult = result ? "succeeded!" : "failed...";
|
||||||
Console.WriteLine($"Conversion of {sheetName} {strResult}");
|
// Console.WriteLine($"Conversion of {sheetName} {strResult}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class SchemaConverter
|
||||||
}
|
}
|
||||||
if (oldSchema.Definitions.Count == 0)
|
if (oldSchema.Definitions.Count == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{exh.FilePath.Path} has no column definitions in old schema!");
|
// Console.WriteLine($"{exh.FilePath.Path} has no column definitions in old schema!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and parse the old schema to supplement exh information
|
// Load and parse the old schema to supplement exh information
|
||||||
|
@ -97,7 +97,7 @@ public class SchemaConverter
|
||||||
{
|
{
|
||||||
Name = $"Unknown{i}",
|
Name = $"Unknown{i}",
|
||||||
Index = i,
|
Index = i,
|
||||||
Type = definition.Type == ExcelColumnDataType.Int64 ? null : "quad",
|
Type = definition.Type == ExcelColumnDataType.Int64 ? "quad" : "null",
|
||||||
DataType = definition.IsBoolType ? ExcelColumnDataType.Bool : definition.Type,
|
DataType = definition.IsBoolType ? ExcelColumnDataType.Bool : definition.Type,
|
||||||
BitOffset = Util.GetBitOffset(definition.Offset, definition.Type)
|
BitOffset = Util.GetBitOffset(definition.Offset, definition.Type)
|
||||||
});
|
});
|
||||||
|
@ -105,6 +105,19 @@ public class SchemaConverter
|
||||||
}
|
}
|
||||||
|
|
||||||
columnInfos.Sort((c1, c2) => c1.BitOffset.CompareTo(c2.BitOffset));
|
columnInfos.Sort((c1, c2) => c1.BitOffset.CompareTo(c2.BitOffset));
|
||||||
|
|
||||||
|
var columnCountsByName = new Dictionary<string, int>();
|
||||||
|
for (int i = 0; i < columnInfos.Count; i++)
|
||||||
|
{
|
||||||
|
if (columnCountsByName.TryGetValue(columnInfos[i].Name, out var count))
|
||||||
|
columnCountsByName[columnInfos[i].Name] = count + 1;
|
||||||
|
else
|
||||||
|
columnCountsByName[columnInfos[i].Name] = 1;
|
||||||
|
}
|
||||||
|
if (columnCountsByName.Any(c => c.Value > 1))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{oldSchema.SheetName} is a shitty fucking stupid sheet!");
|
||||||
|
}
|
||||||
|
|
||||||
var name = oldSchema?.SheetName;
|
var name = oldSchema?.SheetName;
|
||||||
if (name == null)
|
if (name == null)
|
||||||
|
@ -135,13 +148,35 @@ public class SchemaConverter
|
||||||
field.Type = FieldType.Link;
|
field.Type = FieldType.Link;
|
||||||
newSchema.Fields.Add(field);
|
newSchema.Fields.Add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlaceArray(newSchema);
|
||||||
|
|
||||||
var newSchemaStr = SerializeUtil3.Serialize(newSchema);
|
var newSchemaStr = SerializeUtil.Serialize(newSchema);
|
||||||
File.WriteAllText(newSchemaPath, newSchemaStr);
|
File.WriteAllText(newSchemaPath, newSchemaStr);
|
||||||
|
// Console.WriteLine(newSchemaStr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private static void PlaceArray(New.Sheet sheet)
|
||||||
|
// {
|
||||||
|
// var seenColumns = new Dictionary<string, int>();
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < sheet.Fields.Count; i++)
|
||||||
|
// {
|
||||||
|
// var field = sheet.Fields[i];
|
||||||
|
//
|
||||||
|
// // How many times does it occur?
|
||||||
|
// var occurrences = sheet.Fields.Count(f => f.Name == field.Name);
|
||||||
|
//
|
||||||
|
// // When does it occur?
|
||||||
|
// var firstOccurrence = seenColumns.
|
||||||
|
// var distance = sheet.Fields.FindIndex(i + 1, f => f.Name == field.Name) - i;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
private static void Emit(List<ColumnInfo> infos, Old.Sheet sheet)
|
private static void Emit(List<ColumnInfo> infos, Old.Sheet sheet)
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
|
@ -153,7 +188,7 @@ public class SchemaConverter
|
||||||
{
|
{
|
||||||
infos.Add(new ColumnInfo {Name = $"Unknown{i}", Index = i });
|
infos.Add(new ColumnInfo {Name = $"Unknown{i}", Index = i });
|
||||||
}
|
}
|
||||||
Console.WriteLine($"{sheet.SheetName}: skipped and generated {definition.Index - index} columns from {index} to {definition.Index}");
|
// Console.WriteLine($"{sheet.SheetName}: skipped and generated {definition.Index - index} columns from {index} to {definition.Index}");
|
||||||
}
|
}
|
||||||
index = (int)definition.Index;
|
index = (int)definition.Index;
|
||||||
if (definition.Type == null)
|
if (definition.Type == null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue