Files
korenkonder_PD_Tool/PD_Tool/classes/TBL.cs
T
korenkonder 85a22ea0f7 Release v0.4.9.9
A3DA, Bloom, Color Correction, DOF, Light, MotHead
2020-11-19 23:22:25 +03:00

60 lines
2.1 KiB
C#

using System;
using KKdBaseLib;
using KKdMainLib;
using KKdMainLib.IO;
using KKdFARC = KKdMainLib.FARC;
namespace PD_Tool
{
public class TBL
{
public static void Processor(bool json)
{
Console.Title = "Table Converter";
Program.Choose(1, "tbl", out string[] fileNames);
if (fileNames.Length < 1) return;
string filepath, ext;
Tables tbl;
foreach (string file in fileNames)
using (tbl = new Tables())
{
filepath = Path.RemoveExtension(file);
ext = Path.GetExtension(file).ToLower();
Console.Title = "Table Converter: " + Path.GetFileNameWithoutExtension(file);
if (ext == ".bin")
{
tbl.BINReader (filepath);
tbl.MsgPackWriter(filepath, json);
}
else if (ext == ".farc")
using (KKdFARC farc = new KKdFARC(file))
FARCProcessor(ref tbl, farc, filepath, json);
else if (ext == ".json" || ext == ".mp")
{
tbl.MsgPackReader(filepath, ext == ".json");
tbl.BINWriter (filepath);
}
}
}
private static void FARCProcessor(ref Tables tbl, KKdFARC farc, string filepath, bool json)
{
if (!farc.HeaderReader()) return;
if (!farc.HasFiles) return;
int file = -1;
KKdList<string> list = KKdList<string>.New;
for (int i = 0; i < farc.Files.Count; i++)
if (farc.Files[i].Name.ToLower().EndsWith(".bin")) { file = i; break; }
if (file == -1) return;
farc.Unpack(false);
tbl.BINReader (farc.Files[file].Data);
tbl.MsgPackWriter(filepath.Replace(Path.GetFileName(filepath),
Path.GetFileNameWithoutExtension(farc.Files[file].Name)), json);
}
}
}