From 87d4862af59680f3ca67b3ac33a607a4ed3db948 Mon Sep 17 00:00:00 2001 From: KujiKita Date: Wed, 21 Aug 2019 03:04:19 +0300 Subject: [PATCH] Release v0.4.7.2 A3DA, BLT, CCT, DEX, DFT, LIT, Mot, SprDB --- {KKdMainLib/F2nd => KKdBaseLib/F2}/ENRS.cs | 24 +- {KKdMainLib/F2nd => KKdBaseLib/F2}/Header.cs | 4 +- {KKdMainLib/F2nd => KKdBaseLib/F2}/POF.cs | 4 +- KKdBaseLib/F2/Struct.cs | 18 + KKdBaseLib/Half.cs | 4 + KKdBaseLib/IKF.cs | 115 ++++++ KKdBaseLib/IKeyFrame.cs | 142 -------- KKdBaseLib/KKdBaseLib.csproj | 6 +- KKdBaseLib/MsgPack.cs | 144 ++++++-- KKdBaseLib/Pointer.cs | 2 +- KKdBaseLib/Properties/AssemblyInfo.cs | 4 +- KKdBaseLib/Vector3.cs | 3 +- KKdBaseLib/Vector4.cs | 3 +- KKdBaseLib/bin/KKdBaseLib.dll | Bin 46080 -> 0 bytes KKdMainLib/A3DA.cs | 348 ++++++++----------- KKdMainLib/Aet.cs | 8 +- KKdMainLib/DB/Aet.cs | 2 +- KKdMainLib/DB/Auth.cs | 2 +- KKdMainLib/DB/Spr.cs | 30 +- KKdMainLib/DEX.cs | 60 ++-- KKdMainLib/DIVAFILE.cs | 2 - KKdMainLib/DataBank.cs | 42 +-- KKdMainLib/Extensions.cs | 65 +++- KKdMainLib/F2/Bloom.cs | 65 ++++ KKdMainLib/F2/ColorCorrection.cs | 73 ++++ KKdMainLib/F2/DOF.cs | 69 ++++ KKdMainLib/F2/Light.cs | 130 +++++++ KKdMainLib/F2nd/Struct.cs | 69 ---- KKdMainLib/IO/Extensions.cs | 25 ++ KKdMainLib/IO/JSON.cs | 36 +- KKdMainLib/IO/MP.cs | 4 +- KKdMainLib/IO/Stream.cs | 4 +- KKdMainLib/KKdMainLib.csproj | 9 +- KKdMainLib/Main.cs | 41 +-- KKdMainLib/Mot.cs | 327 +++++++++++++++++ KKdMainLib/Properties/AssemblyInfo.cs | 4 +- KKdMainLib/STR.cs | 4 +- KKdSoundLib/VAG.cs | 1 - PD_Tool/PD_Tool.csproj | 7 +- PD_Tool/Program.cs | 83 ++++- PD_Tool/Properties/AssemblyInfo.cs | 4 +- PD_Tool/classes/Tools/BLT.cs | 33 ++ PD_Tool/classes/Tools/CCT.cs | 33 ++ PD_Tool/classes/Tools/DEX.cs | 16 +- PD_Tool/classes/Tools/DFT.cs | 33 ++ PD_Tool/classes/Tools/LIT.cs | 33 ++ PD_Tool/classes/Tools/MOT.cs | 40 +++ 47 files changed, 1538 insertions(+), 637 deletions(-) rename {KKdMainLib/F2nd => KKdBaseLib/F2}/ENRS.cs (97%) rename {KKdMainLib/F2nd => KKdBaseLib/F2}/Header.cs (91%) rename {KKdMainLib/F2nd => KKdBaseLib/F2}/POF.cs (98%) create mode 100644 KKdBaseLib/F2/Struct.cs create mode 100644 KKdBaseLib/IKF.cs delete mode 100644 KKdBaseLib/IKeyFrame.cs delete mode 100644 KKdBaseLib/bin/KKdBaseLib.dll create mode 100644 KKdMainLib/F2/Bloom.cs create mode 100644 KKdMainLib/F2/ColorCorrection.cs create mode 100644 KKdMainLib/F2/DOF.cs create mode 100644 KKdMainLib/F2/Light.cs delete mode 100644 KKdMainLib/F2nd/Struct.cs create mode 100644 KKdMainLib/Mot.cs create mode 100644 PD_Tool/classes/Tools/BLT.cs create mode 100644 PD_Tool/classes/Tools/CCT.cs create mode 100644 PD_Tool/classes/Tools/DFT.cs create mode 100644 PD_Tool/classes/Tools/LIT.cs create mode 100644 PD_Tool/classes/Tools/MOT.cs diff --git a/KKdMainLib/F2nd/ENRS.cs b/KKdBaseLib/F2/ENRS.cs similarity index 97% rename from KKdMainLib/F2nd/ENRS.cs rename to KKdBaseLib/F2/ENRS.cs index 98bd175..9fb21be 100644 --- a/KKdMainLib/F2nd/ENRS.cs +++ b/KKdBaseLib/F2/ENRS.cs @@ -1,6 +1,4 @@ -using KKdBaseLib; - -namespace KKdMainLib.F2nd +namespace KKdBaseLib.F2 { public struct ENRS { @@ -10,22 +8,13 @@ namespace KKdMainLib.F2nd public int Repeat; public SubENRS[] Sub; - public struct SubENRS - { - public int Skip; - public int Reverse; - public Type Type; - - public override string ToString() => "Skip: " + Skip + "; Reverse: " + Reverse + "; Type: " + Type; - } - public static unsafe ENRS[] Read(byte[] data) { byte* ptr = data.GetPtr(); int i, i0; int ENRSCount = ((int*)ptr)[1]; ENRS[] ENRSArr = new ENRS[ENRSCount]; - ptr = ptr + 0x10; + ptr += 0x10; ENRS ENR = new ENRS(); for (i = 0; i < ENRSCount; i++) @@ -98,6 +87,15 @@ namespace KKdMainLib.F2nd Invalid = 0b11000000, } + public struct SubENRS + { + public int Skip; + public int Reverse; + public Type Type; + + public override string ToString() => "Skip: " + Skip + "; Reverse: " + Reverse + "; Type: " + Type; + } + public override string ToString() => "Offset: " + Offset + "; Count: " + Count + "; " + "Size: " + Size + "; Repeat: " + Repeat; } diff --git a/KKdMainLib/F2nd/Header.cs b/KKdBaseLib/F2/Header.cs similarity index 91% rename from KKdMainLib/F2nd/Header.cs rename to KKdBaseLib/F2/Header.cs index 84bbe80..5aea5c1 100644 --- a/KKdMainLib/F2nd/Header.cs +++ b/KKdBaseLib/F2/Header.cs @@ -1,6 +1,4 @@ -using KKdBaseLib; - -namespace KKdMainLib.F2nd +namespace KKdBaseLib.F2 { public struct Header { diff --git a/KKdMainLib/F2nd/POF.cs b/KKdBaseLib/F2/POF.cs similarity index 98% rename from KKdMainLib/F2nd/POF.cs rename to KKdBaseLib/F2/POF.cs index 5a22cca..b2797fd 100644 --- a/KKdMainLib/F2nd/POF.cs +++ b/KKdBaseLib/F2/POF.cs @@ -1,6 +1,4 @@ -using KKdBaseLib; - -namespace KKdMainLib.F2nd +namespace KKdBaseLib.F2 { public struct POF { diff --git a/KKdBaseLib/F2/Struct.cs b/KKdBaseLib/F2/Struct.cs new file mode 100644 index 0000000..1036e94 --- /dev/null +++ b/KKdBaseLib/F2/Struct.cs @@ -0,0 +1,18 @@ +namespace KKdBaseLib.F2 +{ + public struct Struct + { + public Header Header; + public byte[] Data; + public Struct[] SubStructs; + public bool EOFC; + public ENRS[] ENRS; + public KKdList POF; + + public long DataOffset; + + public override string ToString() => Header.ToString() + (SubStructs != null ? + "; SubStructs: " + SubStructs.Length : "") + (ENRS != null ? "; Has ENRS" : "") + + (POF.NotNull ? "; Has POF" : "") + (EOFC ? "; Has EOFC" : ""); + } +} diff --git a/KKdBaseLib/Half.cs b/KKdBaseLib/Half.cs index 5b176e6..8a69c02 100644 --- a/KKdBaseLib/Half.cs +++ b/KKdBaseLib/Half.cs @@ -10,6 +10,8 @@ namespace KKdBaseLib public static explicit operator ushort(Half bits) => bits._value; + public static explicit operator float(Half h) => (float)(double)h; + public static explicit operator double(Half h) { if (h._value == 0x0000) return +0; @@ -29,6 +31,8 @@ namespace KKdBaseLib return d; } + public static explicit operator Half( float val) => (Half)(double)val; + public static explicit operator Half(double val) { Half h = new Half(); diff --git a/KKdBaseLib/IKF.cs b/KKdBaseLib/IKF.cs new file mode 100644 index 0000000..d936081 --- /dev/null +++ b/KKdBaseLib/IKF.cs @@ -0,0 +1,115 @@ +namespace KKdBaseLib +{ + public interface IKF + { + TKey F { get; set; } + + IKF Check(); + string ToString(); + string ToString(bool Brackets); + } + + public struct KFT0 : IKF + { + public TKey F { get; set; } + + public KFT0(TKey F = default) + { this.F = F; } + + public KFT0 ToT0() => this; + public KFT1 ToT1() => new KFT1(F); + public KFT2 ToT2() => new KFT2(F); + public KFT3 ToT3() => new KFT3(F); + + public IKF Check() => this; + + public override string ToString() => ToString(true); + public string ToString(bool Brackets = true) => + Extensions.ToString(F); + } + + public struct KFT1 : IKF + { + public TKey F { get; set; } + public TVal V; + + public KFT1(TKey F = default, TVal V = default) + { this.F = F; this.V = V; } + + public KFT0 ToT0() => new KFT0(F); + public KFT1 ToT1() => this; + public KFT2 ToT2() => new KFT2(F, V); + public KFT3 ToT3() => new KFT3(F, V); + + public IKF Check() => + V.Equals(default(TVal)) ? (IKF)ToT0() : this; + + public override string ToString() => ToString(true); + public string ToString(bool Brackets = true) => + (Brackets ? "(" : "") + Extensions.ToString(F) + "," + + Extensions.ToString(V) + (Brackets ? ")" : ""); + } + + public struct KFT2 : IKF + { + public TKey F { get; set; } + public TVal V; + public TVal T; + + public KFT2(TKey F = default, TVal V = default, TVal T = default) + { this.F = F; this.V = V; this.T = T; } + + public KFT0 ToT0() => new KFT0(F); + public KFT1 ToT1() => new KFT1(F, V); + public KFT2 ToT2() => this; + public KFT3 ToT3() => new KFT3(F, V, T, T); + + public KFT3 ToT3(IKF Previous) => + Previous is KFT2 PreviousT2 ? + new KFT3(F, V, PreviousT2.T, T) : + new KFT3(F, V, T, T); + + public IKF Check() => + T.Equals(default(TVal)) ? (V.Equals(default(TVal)) ? + (IKF)ToT0() : ToT1()) : this; + + public override string ToString() => ToString(true); + public string ToString(bool Brackets) => + (Brackets ? "(" : "") + Extensions.ToString(F) + "," + Extensions. + ToString(V) + "," + Extensions.ToString(T) + (Brackets ? ")" : ""); + } + + public struct KFT3 : IKF + { + public TKey F { get; set; } + public TVal V; + public TVal T1; + public TVal T2; + + public KFT3(TKey F = default, TVal V = default, TVal T1 = default, TVal T2 = default) + { this.F = F; this.V = V; this.T1 = T1; this.T2 = T2; } + + public KFT0 ToT0() => new KFT0(F); + public KFT1 ToT1() => new KFT1(F, V); + public KFT2 ToT2() => new KFT2(F, V, T1); + public KFT3 ToT3() => this; + + public IKF Check() => + T1.Equals(default(TVal)) && T2.Equals(default(TVal)) ? + (V.Equals(default(TVal)) ? ToT0() : (IKF)ToT1()) : + T1.Equals(T2) ? (IKF)ToT2() : this; + + public override string ToString() => ToString(true); + public string ToString(bool Brackets) => + (Brackets ? "(" : "") + Extensions.ToString(F) + "," + Extensions.ToString(V) + "," + + Extensions.ToString(T1) + "," + Extensions.ToString(T2) + (Brackets ? ")" : ""); + + public IKF ToT2(IKF Previous, out IKF Current) + { + Current = Previous is KFT2 PreviousT2 + ? new KFT2(PreviousT2.F, PreviousT2.V, T1) + : new KFT2(F, V, T1); + return new KFT2(F, V, T2); + } + } +} diff --git a/KKdBaseLib/IKeyFrame.cs b/KKdBaseLib/IKeyFrame.cs deleted file mode 100644 index 1896754..0000000 --- a/KKdBaseLib/IKeyFrame.cs +++ /dev/null @@ -1,142 +0,0 @@ -namespace KKdBaseLib -{ - public interface IKeyFrame - { - TKey Frame { get; set; } - - IKeyFrame Check(); - IKeyFrame ToKeyFrameT0(); - IKeyFrame ToKeyFrameT1(); - IKeyFrame ToKeyFrameT2(); - IKeyFrame ToKeyFrameT3(); - string ToString(); - string ToString(bool Brackets); - } - - public struct KeyFrameT0 : IKeyFrame - { - public TKey Frame { get; set; } - - public IKeyFrame ToKeyFrameT0() => - new KeyFrameT0 { Frame = Frame }; - public IKeyFrame ToKeyFrameT1() => - new KeyFrameT1 { Frame = Frame }; - public IKeyFrame ToKeyFrameT2() => - new KeyFrameT2 { Frame = Frame }; - public IKeyFrame ToKeyFrameT3() => - new KeyFrameT3 { Frame = Frame }; - - public IKeyFrame Check() => this; - - public override string ToString() => - Extensions.ToString(Frame); - public string ToString(bool Brackets) => - Extensions.ToString(Frame); - } - - public struct KeyFrameT1 : IKeyFrame - { - public TKey Frame { get; set; } - public TVal Value; - - public IKeyFrame ToKeyFrameT0() => - new KeyFrameT0 { Frame = Frame }; - public IKeyFrame ToKeyFrameT1() => - new KeyFrameT1 { Frame = Frame, Value = Value }; - public IKeyFrame ToKeyFrameT2() => - new KeyFrameT2 { Frame = Frame, Value = Value }; - public IKeyFrame ToKeyFrameT3() => - new KeyFrameT3 { Frame = Frame, Value = Value }; - - public IKeyFrame Check() => - Value.Equals(default(TVal)) ? ToKeyFrameT0() : (this); - - public override string ToString() => ToString(true); - public string ToString(bool Brackets) => - (Brackets ? "(" : "") + Extensions.ToString(Frame) + "," + - Extensions.ToString(Value) + (Brackets ? ")" : ""); - } - - public struct KeyFrameT2 : IKeyFrame - { - public TKey Frame { get; set; } - public TVal Value; - public TVal Interpolation; - - public IKeyFrame ToKeyFrameT0() => - new KeyFrameT0 { Frame = Frame }; - public IKeyFrame ToKeyFrameT1() => - new KeyFrameT1 { Frame = Frame, Value = Value }; - public IKeyFrame ToKeyFrameT2() => - new KeyFrameT2 { Frame = Frame, Value = Value, - Interpolation = Interpolation}; - public IKeyFrame ToKeyFrameT3() => - new KeyFrameT3 { Frame = Frame, Value = Value, - Interpolation1 = Interpolation, Interpolation2 = Interpolation }; - - public IKeyFrame ToKeyFrameT3(IKeyFrame Previous) => - Previous is KeyFrameT2 PreviousT2 ? - new KeyFrameT3 { Frame = Frame, Value = Value, - Interpolation1 = PreviousT2.Interpolation, Interpolation2 = Interpolation } : - new KeyFrameT3 { Frame = Frame, Value = Value, - Interpolation1 = Interpolation, Interpolation2 = Interpolation }; - - public IKeyFrame Check() - { - if (Value.Equals(default(TVal)) && Interpolation.Equals(default(TVal))) return ToKeyFrameT0(); - else if ( Interpolation.Equals(default(TVal))) return ToKeyFrameT1(); - return this; - } - - public override string ToString() => ToString(true); - public string ToString(bool Brackets) => - (Brackets ? "(" : "") + Extensions.ToString(Frame) + "," + Extensions. - ToString(Value) + "," + Extensions.ToString(Interpolation) + (Brackets ? ")" : ""); - } - - public struct KeyFrameT3 : IKeyFrame - { - public TKey Frame { get; set; } - public TVal Value; - public TVal Interpolation1; - public TVal Interpolation2; - - public IKeyFrame ToKeyFrameT0() => - new KeyFrameT0 { Frame = Frame }; - public IKeyFrame ToKeyFrameT1() => - new KeyFrameT1 { Frame = Frame, Value = Value }; - public IKeyFrame ToKeyFrameT2() => - new KeyFrameT2 { Frame = Frame, Value = Value, Interpolation = Interpolation1 }; - public IKeyFrame ToKeyFrameT3() => - new KeyFrameT3 { Frame = Frame, Value = Value, - Interpolation1 = Interpolation1, Interpolation2 = Interpolation2 }; - - public IKeyFrame Check() - { - if (Value.Equals(default(TVal)) && Interpolation1.Equals(default(TVal)) && - Interpolation2.Equals(default(TVal))) return ToKeyFrameT0(); - else if (Interpolation1.Equals(default(TVal)) && - Interpolation2.Equals(default(TVal))) return ToKeyFrameT1(); - else if (Interpolation1.Equals(Interpolation2)) - return ToKeyFrameT2(); - return this; - } - - public override string ToString() => ToString(true); - public string ToString(bool Brackets) => - (Brackets ? "(" : "") + Extensions.ToString(Frame) + "," + Extensions.ToString(Value) + "," + - Extensions.ToString(Interpolation1) + "," + Extensions.ToString(Interpolation2) + (Brackets ? ")" : ""); - - public IKeyFrame ToKeyFrameT2(IKeyFrame - Previous, out IKeyFrame Current) - { - Current = Previous is KeyFrameT2 PreviousT2 - ? new KeyFrameT2 { Frame = PreviousT2.Frame, - Value = PreviousT2.Value, Interpolation = Interpolation1 } - : new KeyFrameT2 { Frame = Frame, - Value = Value, Interpolation = Interpolation1 }; - return new KeyFrameT2 { Frame = Frame, - Value = Value, Interpolation = Interpolation2 }; - } - } -} diff --git a/KKdBaseLib/KKdBaseLib.csproj b/KKdBaseLib/KKdBaseLib.csproj index e244ba1..0a4c9e4 100644 --- a/KKdBaseLib/KKdBaseLib.csproj +++ b/KKdBaseLib/KKdBaseLib.csproj @@ -39,11 +39,15 @@ IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006 + + + + - + diff --git a/KKdBaseLib/MsgPack.cs b/KKdBaseLib/MsgPack.cs index c3a50a3..c9e5b37 100644 --- a/KKdBaseLib/MsgPack.cs +++ b/KKdBaseLib/MsgPack.cs @@ -119,30 +119,126 @@ namespace KKdBaseLib public float ReadSingle(string Name) => ReadNSingle(Name).GetValueOrDefault(); public double ReadDouble(string Name) => ReadNDouble(Name).GetValueOrDefault(); - public bool? ReadNBoolean(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack.ReadNBoolean() : null; - public sbyte? ReadNInt8(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt8 () : null; - public byte? ReadNUInt8(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt8 () : null; - public short? ReadNInt16(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt16() : null; - public ushort? ReadNUInt16(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt16() : null; - public int? ReadNInt32(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt32() : null; - public uint? ReadNUInt32(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt32() : null; - public long? ReadNInt64(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNInt64() : null; - public ulong? ReadNUInt64(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNUInt64() : null; - public float? ReadNSingle(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNSingle() : null; - public double? ReadNDouble(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadNDouble() : null; - public string ReadString(string Name) => - Element(Name, out MsgPack MsgPack) ? MsgPack. ReadString() : null; + public bool? ReadNBoolean(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is bool Boolean) return Boolean; + return null; + } + public sbyte? ReadNInt8(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return ( sbyte) UInt8 ; + return null; + } + public byte? ReadNUInt8(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return ( byte) Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + return null; + } + public short? ReadNInt16(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return Int16; + else if (MsgPack.Object is ushort UInt16) return ( short) UInt16; + return null; + } + public ushort? ReadNUInt16(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return (ushort) Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return (ushort) Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + return null; + } + public int? ReadNInt32(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return Int32; + else if (MsgPack.Object is uint UInt32) return ( int) UInt32; + return null; + } + public uint? ReadNUInt32(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return ( uint) Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return ( uint) Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return ( uint) Int32; + else if (MsgPack.Object is uint UInt32) return UInt32; + return null; + } + public long? ReadNInt64(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return Int32; + else if (MsgPack.Object is uint UInt32) return UInt32; + else if (MsgPack.Object is long Int64) return Int64; + else if (MsgPack.Object is ulong UInt64) return ( long) UInt64; + return null; + } + public ulong? ReadNUInt64(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return ( ulong) Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return ( ulong) Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return ( ulong) Int32; + else if (MsgPack.Object is uint UInt32) return UInt32; + else if (MsgPack.Object is long Int64) return ( ulong) Int64; + else if (MsgPack.Object is ulong UInt64) return UInt64; + return null; + } + public float? ReadNSingle(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return Int32; + else if (MsgPack.Object is uint UInt32) return UInt32; + else if (MsgPack.Object is long Int64) return Int64; + else if (MsgPack.Object is float Float32) return Float32; + else if (MsgPack.Object is double Float64) return ( float)Float64; + return null; + } + public double? ReadNDouble(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is sbyte Int8 ) return Int8 ; + else if (MsgPack.Object is byte UInt8 ) return UInt8 ; + else if (MsgPack.Object is short Int16) return Int16; + else if (MsgPack.Object is ushort UInt16) return UInt16; + else if (MsgPack.Object is int Int32) return Int32; + else if (MsgPack.Object is uint UInt32) return UInt32; + else if (MsgPack.Object is long Int64) return Int64; + else if (MsgPack.Object is float Float32) return Float32; + else if (MsgPack.Object is double Float64) return Float64; + return null; + } + public string ReadString(string Name) + { + if (Element(Name, out MsgPack MsgPack)) + if (MsgPack.Object is string String) return String; + return null; + } public bool ReadBoolean() => ReadNBoolean().GetValueOrDefault(); public sbyte ReadInt8() => ReadNInt8().GetValueOrDefault(); diff --git a/KKdBaseLib/Pointer.cs b/KKdBaseLib/Pointer.cs index 4bd391b..f61c166 100644 --- a/KKdBaseLib/Pointer.cs +++ b/KKdBaseLib/Pointer.cs @@ -11,7 +11,7 @@ public struct CountPointer { public int Count { get => Entries != null ? Entries.Length : 0; - set => Entries = new T[value]; } + set => Entries = value < 0 ? null : new T[value]; } public int Offset; public T[] Entries; diff --git a/KKdBaseLib/Properties/AssemblyInfo.cs b/KKdBaseLib/Properties/AssemblyInfo.cs index 170a8c3..e10f814 100644 --- a/KKdBaseLib/Properties/AssemblyInfo.cs +++ b/KKdBaseLib/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("437F63F1-8C23-429E-AB14-38B85C9EDB16")] -[assembly: AssemblyVersion("0.0.1.1")] -[assembly: AssemblyFileVersion("0.0.1.1")] +[assembly: AssemblyVersion("0.4.7.2")] +[assembly: AssemblyFileVersion("0.4.7.2")] diff --git a/KKdBaseLib/Vector3.cs b/KKdBaseLib/Vector3.cs index 90cb26f..9157b20 100644 --- a/KKdBaseLib/Vector3.cs +++ b/KKdBaseLib/Vector3.cs @@ -71,6 +71,7 @@ public bool Equals(Vector3 other) => X == other.X && Y == other.Y && Z == other.Z; - public override string ToString() => "X: " + X + "; Y: " + Y + "; Z: " + Z; + public override string ToString() => $"{X},{Y},{Z}"; + public string ToString(int d) => $"{X.Round(d)},{Y.Round(d)},{Z.Round(d)}"; } } diff --git a/KKdBaseLib/Vector4.cs b/KKdBaseLib/Vector4.cs index a76716d..9961aa6 100644 --- a/KKdBaseLib/Vector4.cs +++ b/KKdBaseLib/Vector4.cs @@ -71,6 +71,7 @@ public bool Equals(Vector4 other) => X == other.X && Y == other.Y && Z == other.Z && W == other.W; - public override string ToString() => "X: " + X + "; Y: " + Y + "; Z: " + Z + "; W: " + W; + public override string ToString() => $"{X},{Y},{Z},{W}"; + public string ToString(int d) => $"{X.Round(d)},{Y.Round(d)},{Z.Round(d)},{W.Round(d)}"; } } diff --git a/KKdBaseLib/bin/KKdBaseLib.dll b/KKdBaseLib/bin/KKdBaseLib.dll deleted file mode 100644 index cc7a89e00243db8880c98df7c61a5567ee22fa07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 46080 zcmd?S34Bf0*FU_^x%ZxPhs>iPktpHHC}I`_2|`2=L<~v96(MpX1Bo$)q8c-8sgfG1 zR1Kx7sufjjX;q8XOsZOKwM0?0n*7&VXWx^Xgg(Fj^S;mfe?RYg$=d6?*4lfo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ogqW{avr0%Y_5k~aYIZor?v<}LwF>!4new2NwwIu~m6JZQX5K%>J?Uj5FF7_dx3 zX9IhhAS=ENf&{WQG)e00T)=#(QMG~C0<93pRWRlTIGkutPC%OK)j?3Pdk}I0cq0k+ zkD-zf(DbvetretlI|AKqKpLR4zmq!6Z`5}?)D@)q{bLQOJt__y TransT0) - { - if (F16 && CompressF16 > 0) - { IO.Write((ushort)TransT0.Frame); IO.Write((ushort)0); } - else - { IO.Write(( float)TransT0.Frame); IO.Write(( float)0); } - if (F16 && CompressF16 == 2) IO.Write(0 ); - else IO.Write(0L); - } - else if (Key.Trans[i] is KeyFrameT1 TransT1) - { - if (F16 && CompressF16 > 0) - { IO.Write((ushort)TransT1.Frame); IO.Write(( Half)TransT1.Value); } - else - { IO.Write(( float)TransT1.Frame); IO.Write((float)TransT1.Value); } - if (F16 && CompressF16 == 2) IO.Write(0 ); - else IO.Write(0L); - } - else if (Key.Trans[i] is KeyFrameT2 TransT2) - { - if (F16 && CompressF16 > 0) - { IO.Write((ushort)TransT2.Frame); IO.Write(( Half)TransT2.Value); } - else - { IO.Write(( float)TransT2.Frame); IO.Write((float)TransT2.Value); } - if (F16 && CompressF16 == 2) - { IO.Write(( Half)TransT2.Interpolation); IO.Write(( Half)TransT2.Interpolation); } - else - { IO.Write(( float)TransT2.Interpolation); IO.Write((float)TransT2.Interpolation); } - } - else if (Key.Trans[i] is KeyFrameT3 TransT3) - { - if (F16 && CompressF16 > 0) - { IO.Write((ushort)TransT3.Frame); IO.Write(( Half)TransT3.Value); } - else - { IO.Write(( float)TransT3.Frame); IO.Write((float)TransT3.Value); } - if (F16 && CompressF16 == 2) - { IO.Write(( Half)TransT3.Interpolation1); IO.Write(( Half)TransT3.Interpolation2); } - else - { IO.Write(( float)TransT3.Interpolation1); IO.Write((float)TransT3.Interpolation2); } - } + ref KFT3 KF = ref Key.Trans[i]; + if (F16 && CompressF16 > 0) + { IO.Write((ushort)KF.F ); IO.Write(( Half)KF.V ); } + else + { IO.Write(( float)KF.F ); IO.Write((float)KF.V ); } + if (F16 && CompressF16 == 2) + { IO.Write(( Half)KF.T1); IO.Write(( Half)KF.T2); } + else + { IO.Write(( float)KF.T1); IO.Write((float)KF.T2); } } } else @@ -1314,8 +1283,8 @@ namespace KKdMainLib.A3DA if (!UsedValues.ContainsValue(Key.Value) || !A3DCOpt) { Key.BinOffset = IO.Position; - IO.Write( Key.Type ); - IO.Write((float?)Key.Value); + IO.Write(( int)Key.Type ); + IO.Write((float)Key.Value); if (A3DCOpt) { UsedValues.Add(Key.BinOffset, Key.Value); } return; @@ -1328,7 +1297,7 @@ namespace KKdMainLib.A3DA public void MsgPackReader(string file, bool JSON) { MsgPack MsgPack = file.ReadMPAllAtOnce(JSON); - if (!MsgPack.Element("A3D", out MsgPack A3D)) { MsgPack = MsgPack.New; return; } + if (!MsgPack.Element("A3D", out MsgPack A3D)) { MsgPack.Dispose(); return; } MsgPackReader(A3D); } @@ -1989,14 +1958,13 @@ namespace KKdMainLib.A3DA public static Key ReadKey(this Dictionary Dict, string Temp) { Key Key = new Key(); - Dict.FindValue(out Key.BinOffset, Temp + BO ); - Dict.FindValue(out Key.Type , Temp + "type"); + if ( Dict.FindValue(out Key.BinOffset, Temp + BO )) return Key; + if (!Dict.FindValue(out int Type , Temp + "type")) return null; - if (Key.BinOffset == null && Key.Type == null) return null; - if (Key.Type == null) return Key; - if (Key.Type == 0x0000) return Key; - - if (Key.Type == 0x0001) { Dict.FindValue(out Key.Value, Temp + "value"); return Key; } + if (Key.BinOffset != null) return null; + Key.Type = (Key.Interpolation)Type; + if (Type == 0x0000) return Key; + if (Type == 0x0001) { Dict.FindValue(out Key.Value, Temp + "value"); return Key; } int i = 0; Dict.FindValue(out Key.EPTypePost, Temp + "ep_type_post"); @@ -2006,66 +1974,60 @@ namespace KKdMainLib.A3DA if (Dict.StartsWith(Temp + "raw_data")) Dict.FindValue(out Key.RawData.KeyType, Temp + "raw_data_key_type"); - if (Key.Length != null) - { - int Type; - Key.Trans = new IKeyFrame[(int)Key.Length]; - for (i = 0; i < Key.Length; i++) - if (Dict.FindValue(out value, Temp + "key" + d + i + d + "data")) - { - dataArray = value.Replace("(", "").Replace(")", "").Split(','); - Type = dataArray.Length - 1; - if (Type == 0) Key.Trans[i] = new KeyFrameT0 - { Frame = dataArray[0].ToDouble() }; - else if (Type == 1) Key.Trans[i] = new KeyFrameT1 - { Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble() }; - else if (Type == 2) Key.Trans[i] = new KeyFrameT2 - { Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble(), - Interpolation = dataArray[2].ToDouble() }; - else if (Type == 3) Key.Trans[i] = new KeyFrameT3 - { Frame = dataArray[0].ToDouble(), Value = dataArray[1].ToDouble(), - Interpolation1 = dataArray[2].ToDouble(), - Interpolation2 = dataArray[3].ToDouble() }; - Key.Trans[i] = Key.Trans[i].Check(); - } - } - else if (Key.RawData.KeyType != null) + if (Key.RawData.KeyType != 0) { + ref string[] ValueList = ref Key.RawData.ValueList; Dict.FindValue(out Key.RawData.ValueType, Temp + "raw_data.value_type"); if (Dict.FindValue(out value, Temp + "raw_data.value_list")) - Key.RawData.ValueList = value.Split(','); + ValueList = value.Split(','); Dict.FindValue(out Key.RawData.ValueListSize, Temp + "raw_data.value_list_size"); value = ""; - int DS = (int)Key.RawData.KeyType + 1; + int DS = Key.RawData.KeyType + 1; Key.Length = Key.RawData.ValueListSize / DS; - Key.Trans = new IKeyFrame[(int)Key.Length]; + Key.Trans = new KFT3[Key.Length]; if (Key.RawData.KeyType == 0) for (i = 0; i < Key.Length; i++) - Key.Trans[i] = new KeyFrameT0 - { Frame = Key.RawData.ValueList[i * DS + 0].ToDouble() }.Check(); + Key.Trans[i] = new KFT3 + (ValueList[i * DS + 0].ToDouble()); else if (Key.RawData.KeyType == 1) for (i = 0; i < Key.Length; i++) - Key.Trans[i] = new KeyFrameT1 - { Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(), - Value = Key.RawData.ValueList[i * DS + 1].ToDouble() }.Check(); + Key.Trans[i] = new KFT3 + (ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble()); else if (Key.RawData.KeyType == 2) for (i = 0; i < Key.Length; i++) - Key.Trans[i] = new KeyFrameT2 - { Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(), - Value = Key.RawData.ValueList[i * DS + 1].ToDouble(), - Interpolation = Key.RawData.ValueList[i * DS + 2].ToDouble() }.Check(); + Key.Trans[i] = new KFT3 + (ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble(), + ValueList[i * DS + 2].ToDouble(), ValueList[i * DS + 2].ToDouble()); else if (Key.RawData.KeyType == 3) for (i = 0; i < Key.Length; i++) - Key.Trans[i] = new KeyFrameT3 - { Frame = Key.RawData.ValueList[i * DS + 0].ToDouble(), - Value = Key.RawData.ValueList[i * DS + 1].ToDouble(), - Interpolation1 = Key.RawData.ValueList[i * DS + 2].ToDouble(), - Interpolation2 = Key.RawData.ValueList[i * DS + 3].ToDouble() }.Check(); + Key.Trans[i] = new KFT3 + (ValueList[i * DS + 0].ToDouble(), ValueList[i * DS + 1].ToDouble(), + ValueList[i * DS + 2].ToDouble(), ValueList[i * DS + 3].ToDouble()); - for (i = 0; i < Key.Length; i++) Key.Trans[i].Check(); Key.RawData.ValueList = null; } + else + { + Key.Trans = new KFT3[Key.Length]; + for (i = 0; i < Key.Length; i++) + { + if (!Dict.FindValue(out value, Temp + "key" + d + i + d + "data")) continue; + + dataArray = value.Replace("(", "").Replace(")", "").Split(','); + Type = dataArray.Length - 1; + if (Type == 0) Key.Trans[i] = new KFT3 + (dataArray[0].ToDouble()); + else if (Type == 1) Key.Trans[i] = new KFT3 + (dataArray[0].ToDouble(), dataArray[1].ToDouble()); + else if (Type == 2) Key.Trans[i] = new KFT3 + (dataArray[0].ToDouble(), dataArray[1].ToDouble(), + dataArray[2].ToDouble(), dataArray[2].ToDouble()); + else if (Type == 3) Key.Trans[i] = new KFT3 + (dataArray[0].ToDouble(), dataArray[1].ToDouble(), + dataArray[2].ToDouble(), dataArray[3].ToDouble()); + } + } return Key; } @@ -2105,7 +2067,7 @@ namespace KKdMainLib.A3DA public static void Write(this Stream IO, Key Key, string Temp, bool A3DC = false) { - if (Key == null) return; + if (Key == null || Key.Type == null) return; if (A3DC) { IO.Write(Temp + BO + "=", Key.BinOffset); return; } @@ -2113,69 +2075,65 @@ namespace KKdMainLib.A3DA if (Key.Trans != null) if (Key.Trans.Length == 0) { - IO.Write(Temp + "type=", Key.Type); + IO.Write(Temp + "type=", (int)Key.Type); if (Key.Type > 0) IO.Write(Temp + "value=", Key.Value); return; } if (Key.EPTypePost != null) IO.Write(Temp + "ep_type_post=", Key.EPTypePost); if (Key.EPTypePre != null) IO.Write(Temp + "ep_type_pre=" , Key.EPTypePre ); - if (Key.RawData.KeyType == null && Key.Trans != null) + if (Key.RawData.KeyType == 0 && Key.Trans != null) { + IKF KF; SO = Key.Trans.Length.SortWriter(); for (i = 0; i < Key.Trans.Length; i++) { SOi = SO[i]; - IO.Write(Temp + "key" + d + SOi + d + "data=", Key.Trans[SOi].ToString()); - if (Key.Trans[SOi] is KeyFrameT0) - IO.Write(Temp + "key" + d + SOi + d + "type=", 0); - else if (Key.Trans[SOi] is KeyFrameT1) - IO.Write(Temp + "key" + d + SOi + d + "type=", 1); - else if (Key.Trans[SOi] is KeyFrameT2) - IO.Write(Temp + "key" + d + SOi + d + "type=", 2); - else if (Key.Trans[SOi] is KeyFrameT3) - IO.Write(Temp + "key" + d + SOi + d + "type=", 3); + KF = Key.Trans[SOi].Check(); + IO.Write(Temp + "key" + d + SOi + d + "data=", KF.ToString()); + int Type = 0; + if (KF is KFT0) Type = 0; + else if (KF is KFT1) Type = 1; + else if (KF is KFT2) Type = 2; + else if (KF is KFT3) Type = 3; + IO.Write(Temp + "key" + d + SOi + d + "type=", Type); } IO.Write(Temp + "key.length=", Key.Length); if (Key.Max != null) IO.Write(Temp + "max=", Key.Max); } else if (Key.Trans != null) { - Key.RawData.KeyType = 0; + int Length = Key.Trans.Length; + ref int KeyType = ref Key.RawData.KeyType; + KeyType = 0; + IKF KF; if (Key.Max != null) IO.Write(Temp + "max=", Key.Max); - for (i = 0; i < Key.Trans.Length; i++) + for (i = 0; i < Length; i++) { - if (Key.Trans[i] is KeyFrameT0 && - Key.RawData.KeyType < 0) Key.RawData.KeyType = 0; - else if (Key.Trans[i] is KeyFrameT1 && - Key.RawData.KeyType < 1) Key.RawData.KeyType = 1; - else if (Key.Trans[i] is KeyFrameT2 && - Key.RawData.KeyType < 2) Key.RawData.KeyType = 2; - else if (Key.Trans[i] is KeyFrameT3 && - Key.RawData.KeyType < 3) break; + KF = Key.Trans[i].Check(); + if (KF is KFT0 && KeyType < 0) KeyType = 0; + else if (KF is KFT1 && KeyType < 1) KeyType = 1; + else if (KF is KFT2 && KeyType < 2) KeyType = 2; + else if (KF is KFT3 && KeyType < 3) break; } - Key.RawData.ValueListSize = Key.Trans.Length * (Key.RawData.KeyType + 1); + Key.RawData.ValueListSize = Length * KeyType + Length; IO.Write(Temp + "raw_data.value_list="); - if (Key.RawData.KeyType == 0) for (i = 0; i < Key.Trans.Length; i++) - IO.Write(Key.Trans[i].ToKeyFrameT0().ToString(false) + - ((i + 1 < Key.Trans.Length) ? "," : "")); - else if (Key.RawData.KeyType == 1) for (i = 0; i < Key.Trans.Length; i++) - IO.Write(Key.Trans[i].ToKeyFrameT1().ToString(false) + - ((i + 1 < Key.Trans.Length) ? "," : "")); - else if (Key.RawData.KeyType == 2) for (i = 0; i < Key.Trans.Length; i++) - IO.Write(Key.Trans[i].ToKeyFrameT2().ToString(false) + - ((i + 1 < Key.Trans.Length) ? "," : "")); - else if (Key.RawData.KeyType == 3) for (i = 0; i < Key.Trans.Length; i++) - IO.Write(Key.Trans[i].ToKeyFrameT3().ToString(false) + - ((i + 1 < Key.Trans.Length) ? "," : "")); + if (KeyType == 0) for (i = 0; i < Length; i++) + IO.Write(Key.Trans[i].ToT0().ToString(false) + ((i + 1 < Length) ? "," : "")); + else if (KeyType == 1) for (i = 0; i < Length; i++) + IO.Write(Key.Trans[i].ToT1().ToString(false) + ((i + 1 < Length) ? "," : "")); + else if (KeyType == 2) for (i = 0; i < Length; i++) + IO.Write(Key.Trans[i].ToT2().ToString(false) + ((i + 1 < Length) ? "," : "")); + else if (KeyType == 3) for (i = 0; i < Length; i++) + IO.Write(Key.Trans[i].ToT3().ToString(false) + ((i + 1 < Length) ? "," : "")); IO.Position--; IO.Write('\n'); IO.Write(Temp + "raw_data.value_list_size=", Key.RawData.ValueListSize); IO.Write(Temp + "raw_data.value_type=" , Key.RawData.ValueType ); IO.Write(Temp + "raw_data_key_type=" , Key.RawData. KeyType ); } - IO.Write(Temp + "type=", Key.Type & 0xFF); - if (Key.RawData.KeyType == null && Key.Trans == null && Key.Value != null) + IO.Write(Temp + "type=", (int)Key.Type); + if (Key.RawData.KeyType == 0 && Key.Trans == null && Key.Value != null) if (Key.Value != 0) IO.Write(Temp + "value=", Key.Value); } @@ -2213,38 +2171,36 @@ namespace KKdMainLib.A3DA if (Key.BinOffset == null || Key.BinOffset < 0) return; IO.Position = (int)Key.BinOffset; - Key.Type = IO.ReadInt32(); + int Type = IO.ReadInt32(); Key.Value = IO.ReadSingle(); - if (Key.Type == 0x0000 || Key.Type == 0x0001) return; + Key.Type = (Key.Interpolation)(Type & 0xFF); + if (Key.Type < Key.Interpolation.Lerp) return; Key.Max = IO.ReadSingle(); Key.Length = IO.ReadInt32 (); - if (Key.Type >> 8 != 0) + if (Type >> 8 != 0) { - Key.EPTypePost = (Key.Type >> 12) & 0xF; - Key.EPTypePre = (Key.Type >> 8) & 0xF; + Key.EPTypePost = (Type >> 12) & 0xF; + Key.EPTypePre = (Type >> 8) & 0xF; if (Key.EPTypePost == 0) Key.EPTypePost = null; if (Key.EPTypePre == 0) Key.EPTypePre = null; } - Key.Type &= 0xFF; - Key.Trans = new IKeyFrame[(int)Key.Length]; - KeyFrameT3 Temp; + Key.Trans = new KFT3[Key.Length]; + KFT3 Temp; for (int i = 0; i < Key.Length; i++) { - Temp = new KeyFrameT3(); + Temp = new KFT3(); if (F16 && C_F16 > 0) - { Temp.Frame = IO.ReadUInt16(); Temp.Value = (double)IO.ReadHalf (); } + { Temp.F = IO.ReadUInt16(); Temp.V = (double)IO.ReadHalf (); } else - { Temp.Frame = IO.ReadSingle(); Temp.Value = IO.ReadSingle(); } + { Temp.F = IO.ReadSingle(); Temp.V = IO.ReadSingle(); } if (F16 && C_F16 == 2) - { Temp.Interpolation1 = (double)IO.ReadHalf (); - Temp.Interpolation2 = (double)IO.ReadHalf (); } + { Temp.T1 = (double)IO.ReadHalf (); Temp.T2 = (double)IO.ReadHalf (); } else - { Temp.Interpolation1 = IO.ReadSingle(); - Temp.Interpolation2 = IO.ReadSingle(); } + { Temp.T1 = IO.ReadSingle(); Temp.T2 = IO.ReadSingle(); } - Key.Trans[i] = Temp.Check(); + Key.Trans[i] = Temp; } } @@ -2310,47 +2266,36 @@ namespace KKdMainLib.A3DA { if (k.Object == null) return null; - Key Key = new Key { EPTypePost = k.ReadNInt32("EPTypePost"), - EPTypePre = k.ReadNInt32("EPTypePre"), Max = k.ReadNDouble("Max"), - Type = k.ReadNInt32("Type"), Value = k.ReadNDouble("Value") }; + Key Key = new Key { EPTypePost = k.ReadNInt32("EPTypePost"), EPTypePre = + k.ReadNInt32("EPTypePre"), Max = k.ReadNDouble("Max"), Value = k.ReadNDouble("Value") }; + if (!Enum.TryParse(k.ReadString("Type"), out Key.Interpolation Type)) { Key.Value = null; return Key; } + Key.Type = Type; + if (Key.Type == 0) { Key.Value = 0; return Key; } + else if (Key.Type < Key.Interpolation.Lerp) return Key; + if (k.ReadBoolean("RawData")) Key.RawData = new Key.RawD() { KeyType = -1, ValueType = "float" }; - if (Key.Type == 0) Key.Value = 0.0; - - if (Key.Type < 2) return Key; - if (!k.ElementArray("Trans", out MsgPack Trans)) return Key; Key.Length = Trans.Array.Length; - Key.Trans = new IKeyFrame[Key.Length.Value]; + Key.Trans = new KFT3[Key.Length]; for (int i = 0; i < Key.Length; i++) { if (Trans[i].Array == null) continue; else if (Trans[i].Array.Length == 0) continue; else if (Trans[i].Array.Length == 1) - Key.Trans[i] = new KeyFrameT0 - { Frame = Trans[i][0].ReadDouble() }; + Key.Trans[i] = new KFT3 + (Trans[i][0].ReadDouble()); else if (Trans[i].Array.Length == 2) - Key.Trans[i] = new KeyFrameT1 - { - Frame = Trans[i][0].ReadDouble(), - Value = Trans[i][1].ReadDouble(), - }; + Key.Trans[i] = new KFT3 + (Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble()); else if (Trans[i].Array.Length == 3) - Key.Trans[i] = new KeyFrameT2 - { - Frame = Trans[i][0].ReadDouble(), - Value = Trans[i][1].ReadDouble(), - Interpolation = Trans[i][2].ReadDouble(), - }; + Key.Trans[i] = new KFT3 + (Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble(), + Trans[i][2].ReadDouble(), Trans[i][2].ReadDouble()); else if (Trans[i].Array.Length == 4) - Key.Trans[i] = new KeyFrameT3 - { - Frame = Trans[i][0].ReadDouble(), - Value = Trans[i][1].ReadDouble(), - Interpolation1 = Trans[i][2].ReadDouble(), - Interpolation2 = Trans[i][3].ReadDouble(), - }; - Key.Trans[i] = Key.Trans[i].Check(); + Key.Trans[i] = new KFT3 + (Trans[i][0].ReadDouble(), Trans[i][1].ReadDouble(), + Trans[i][2].ReadDouble(), Trans[i][3].ReadDouble()); } return Key; } @@ -2381,32 +2326,32 @@ namespace KKdMainLib.A3DA public static MsgPack Add(this MsgPack MsgPack, string name, Key Key) { - if (Key == null) return MsgPack; - if (Key.Type == null) return MsgPack; + if (Key == null || Key.Type == null) return MsgPack; - MsgPack Keys = new MsgPack(name).Add("Type", Key.Type); - if (Key.Trans != null) + MsgPack Keys = new MsgPack(name).Add("Type", Key.Type.ToString()); + if (Key.Trans != null && Key.Type != Key.Interpolation.Null) { Keys = Keys.Add("Max", Key.Max).Add("EPTypePost", Key.EPTypePost).Add("EPTypePre", Key.EPTypePre); - if (Key.RawData.KeyType != null) Keys.Add("RawData", true); + if (Key.RawData.KeyType != 0) Keys.Add("RawData", true); MsgPack Trans = new MsgPack(Key.Trans.Length, "Trans"); for (int i = 0; i < Key.Trans.Length; i++) - if (Key.Trans[i] is KeyFrameT0 KeyFrameT0) + { + IKF KF = Key.Trans[i].Check(); + if (KF is KFT0 KFT0) Trans[i] = new MsgPack(null, new MsgPack[] - { (MsgPack)KeyFrameT0.Frame }); - else if (Key.Trans[i] is KeyFrameT1 KeyFrameT1) + { (MsgPack)KFT0.F }); + else if (KF is KFT1 KFT1) Trans[i] = new MsgPack(null, new MsgPack[] - { (MsgPack)KeyFrameT1.Frame, (MsgPack)KeyFrameT1.Value }); - else if (Key.Trans[i] is KeyFrameT2 KeyFrameT2) + { (MsgPack)KFT1.F, (MsgPack)KFT1.V }); + else if (KF is KFT2 KFT2) Trans[i] = new MsgPack(null, new MsgPack[] - { (MsgPack)KeyFrameT2.Frame, (MsgPack)KeyFrameT2.Value, - (MsgPack)KeyFrameT2.Interpolation }); - else if (Key.Trans[i] is KeyFrameT3 KeyFrameT3) + { (MsgPack)KFT2.F, (MsgPack)KFT2.V, (MsgPack)KFT2.T }); + else if (KF is KFT3 KFT3) Trans[i] = new MsgPack(null, new MsgPack[] - { (MsgPack)KeyFrameT3.Frame, (MsgPack)KeyFrameT3.Value, - (MsgPack)KeyFrameT3.Interpolation1, (MsgPack)KeyFrameT3.Interpolation2 }); + { (MsgPack)KFT3.F, (MsgPack)KFT3.V, (MsgPack)KFT3.T1, (MsgPack)KFT3.T2, }); + } Keys.Add(Trans); } else if (Key.Value != 0) Keys.Add("Value", Key.Value); @@ -2550,23 +2495,32 @@ namespace KKdMainLib.A3DA public class Key { - public int? Type; - public int? Length; + public Interpolation? Type; + public int Length; public int? BinOffset; public int? EPTypePre; public int? EPTypePost; public double? Max; public double? Value; public RawD RawData; - public IKeyFrame[] Trans; + public KFT3[] Trans; public struct RawD { - public int? KeyType; - public int? ValueListSize; + public int KeyType; + public int ValueListSize; public string ValueType; public string[] ValueList; } + + public enum Interpolation + { + Null = 0, + Value = 1, + Lerp = 2, + Hermite = 3, + Hold = 4, + } } public struct Light diff --git a/KKdMainLib/Aet.cs b/KKdMainLib/Aet.cs index ad29ae2..c1714b1 100644 --- a/KKdMainLib/Aet.cs +++ b/KKdMainLib/Aet.cs @@ -1,8 +1,8 @@ //Original: AetSet.bt Version: 2.0 by samyuu using KKdBaseLib; +using KKdMainLib.F2; using KKdMainLib.IO; -using KKdMainLib.F2nd; namespace KKdMainLib.Aet { @@ -200,8 +200,7 @@ namespace KKdMainLib.Aet { IO.Align(0x10); Aet.Unknown.Offset = IO.Position; - for (i = 0; i < Aet.Unknown.Count * 10; i++) - IO.Write(0L); + for (i = 0; i < Aet.Unknown.Count * 10; i++) IO.Write(0L); } IO.Align(0x10); @@ -213,7 +212,7 @@ namespace KKdMainLib.Aet for (i = 0; i < NullValPointers.Count; i++) { IO.Position = NullValPointers[i]; - IO.Write(ReturnPosition + i * 4); + IO.Write(ReturnPosition + i << 2); } for (i = 0; i < Aet.Layers.Count; i++) @@ -861,7 +860,6 @@ namespace KKdMainLib.Aet public struct AetHeader { public Pointer[] Data; - public POF POF; } public struct AetData diff --git a/KKdMainLib/DB/Aet.cs b/KKdMainLib/DB/Aet.cs index 7b78d99..0700119 100644 --- a/KKdMainLib/DB/Aet.cs +++ b/KKdMainLib/DB/Aet.cs @@ -198,7 +198,7 @@ namespace KKdMainLib.DB for (int i = 0; i < AetSets.Length; i++) AetSets[i].ReadMsgPack(AetDB[i]); } - MsgPack = MsgPack.New; + MsgPack.Dispose(); } diff --git a/KKdMainLib/DB/Auth.cs b/KKdMainLib/DB/Auth.cs index 28000e1..cde7e0e 100644 --- a/KKdMainLib/DB/Auth.cs +++ b/KKdMainLib/DB/Auth.cs @@ -117,7 +117,7 @@ namespace KKdMainLib.DB } } } - MsgPack = MsgPack.New; + MsgPack.Dispose(); } public void MsgPackWriter(string file, bool JSON) diff --git a/KKdMainLib/DB/Spr.cs b/KKdMainLib/DB/Spr.cs index 6fdd90b..3522f65 100644 --- a/KKdMainLib/DB/Spr.cs +++ b/KKdMainLib/DB/Spr.cs @@ -143,13 +143,13 @@ namespace KKdMainLib.DB if (set.Id == null) while (true) { if (!SetIds.Contains(i1)) { SpriteSets[i].Id = i1; SetIds.Add(i1); break; } i1++; } - for (i0 = 0, i1 = 0; i0 < set. Sprites.Length; i0++) - if (set. Sprites[i0].Id == null) while (true) { if (!Ids.Contains(i1)) - { SpriteSets[i]. Sprites[i0].Id = i1; Ids.Add(i1); break; } i1++; } - for (i0 = 0, i1 = 0; i0 < set.Textures.Length; i0++) - if (set.Textures[i0].Id == null) while (true) { if (!Ids.Contains(i1)) - { SpriteSets[i].Textures[i0].Id = i1; Ids.Add(i1); break; } i1++; } + while (set.Textures[i0].Id == null) + if (!Ids.Contains(i1)) Ids.Add((int)(SpriteSets[i].Textures[i0].Id = i1)); else i1++; + + for (i0 = 0, i1 = 0; i0 < set. Sprites.Length; i0++) + while (set. Sprites[i0].Id == null) + if (!Ids.Contains(i1)) Ids.Add((int)(SpriteSets[i]. Sprites[i0].Id = i1)); else i1++; } Ids = null; @@ -175,18 +175,20 @@ namespace KKdMainLib.DB for (i = 0; i < SpriteSets.Length; i++) { if (NotAdd.Contains(i)) continue; - SpriteSets[i]. NameOffset = IO.Position; IO.Write(SpriteSets[i]. Name + "\0"); - SpriteSets[i].FileNameOffset = IO.Position; IO.Write(SpriteSets[i].FileName + "\0"); + for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++) + { SpriteSets[i].Textures[i0].NameOffset = IO.Position; + IO.Write(SpriteSets[i].Textures[i0].Name + "\0"); } + + for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++) + { SpriteSets[i]. Sprites[i0].NameOffset = IO.Position; + IO.Write(SpriteSets[i]. Sprites[i0].Name + "\0"); } } for (i = 0; i < SpriteSets.Length; i++) { if (NotAdd.Contains(i)) continue; - for (i0 = 0; i0 < SpriteSets[i].Textures.Length; i0++) - { SpriteSets[i].Textures[i0].NameOffset = IO.Position; IO.Write(SpriteSets[i].Textures[i0].Name + "\0"); } - - for (i0 = 0; i0 < SpriteSets[i]. Sprites.Length; i0++) - { SpriteSets[i]. Sprites[i0].NameOffset = IO.Position; IO.Write(SpriteSets[i]. Sprites[i0].Name + "\0"); } + SpriteSets[i]. NameOffset = IO.Position; IO.Write(SpriteSets[i]. Name + "\0"); + SpriteSets[i].FileNameOffset = IO.Position; IO.Write(SpriteSets[i].FileName + "\0"); } IO.Align(0x08, true); @@ -235,7 +237,7 @@ namespace KKdMainLib.DB for (int i = 0; i < SpriteSets.Length; i++) SpriteSets[i].ReadMsgPack(SprDB[i]); } - MsgPack = MsgPack.New; + MsgPack.Dispose(); } public void MsgPackWriter(string file, bool JSON) diff --git a/KKdMainLib/DEX.cs b/KKdMainLib/DEX.cs index e569e64..040be1d 100644 --- a/KKdMainLib/DEX.cs +++ b/KKdMainLib/DEX.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using KKdBaseLib; +using KKdBaseLib.F2; using KKdMainLib.IO; -using KKdMainLib.F2nd; namespace KKdMainLib { @@ -24,18 +24,16 @@ namespace KKdMainLib Header.Format = Format.F; Header.SectionSignature = IO.ReadInt32(); if (Header.SectionSignature == 0x43505845) - Header = IO.ReadHeader(true); - if (Header.SectionSignature != 0x64) - return 0; + Header = IO.ReadHeader(true, true); + if (Header.SectionSignature != 0x64) return 0; - Offset = IO.Position - 0x4; + IO.Offset = IO.Position - 0x4; Dex = new EXP[IO.ReadInt32()]; int DEXOffset = IO.ReadInt32(); - if (IO.ReadInt32() == 0x00) Header.Format = Format.X; int DEXNameOffset = IO.ReadInt32(); - if (Header.IsX) IO.ReadInt32(); + if (DEXNameOffset == 0x00) { Header.Format = Format.X; DEXNameOffset = (int)IO.ReadInt64(); } - IO.Seek(DEXOffset + Offset, 0); + IO.Seek(DEXOffset, 0); for (int i0 = 0; i0 < Dex.Length; i0++) Dex[i0] = new EXP { Main = new List(), Eyes = new List() }; @@ -46,7 +44,7 @@ namespace KKdMainLib Dex[i0].EyesOffset = IO.ReadInt32(); if (Header.IsX) IO.ReadInt32(); } - IO.Seek(DEXNameOffset + Offset, 0); + IO.Seek(DEXNameOffset, 0); for (int i0 = 0; i0 < Dex.Length; i0++) { Dex[i0].NameOffset = IO.ReadInt32(); @@ -70,7 +68,7 @@ namespace KKdMainLib break; } - IO.Seek(Dex[i0].EyesOffset + Offset, 0); + IO.Seek(Dex[i0].EyesOffset, 0); while(true) { element.Frame = IO.ReadSingle(); @@ -80,12 +78,10 @@ namespace KKdMainLib element.Trans = IO.ReadSingle(); Dex[i0].Eyes.Add(element); - if (element.Frame == 999999 || element.Both == 0xFFFF) - break; + if (element.Frame == 999999 || element.Both == 0xFFFF) break; } - IO.Seek(Dex[i0].NameOffset + Offset, 0); - Dex[i0].Name = IO.NullTerminatedUTF8(); + Dex[i0].Name = IO.ReadStringAtOffset(Dex[i0].NameOffset); } IO.Close(); @@ -172,7 +168,7 @@ namespace KKdMainLib IO.Close(); } - public void MsgPackReader(string file, bool JSON) + public int MsgPackReader(string file, bool JSON) { int i0 = 0; int i1 = 0; @@ -180,7 +176,7 @@ namespace KKdMainLib Header = new Header(); MsgPack MsgPack = file.ReadMPAllAtOnce(JSON); - if (!MsgPack.ElementArray("Dex", out MsgPack Dex)) return; + if (!MsgPack.ElementArray("Dex", out MsgPack Dex)) return 0; this.Dex = new EXP[Dex.Array.Length]; for (i0 = 0; i0 < this.Dex.Length; i0++) @@ -191,23 +187,19 @@ namespace KKdMainLib { this.Dex[i0].Main = new List(); for (i1 = 0; i1 < Main.Array.Length; i1++) - this.Dex[i0].Main.Add(ReadEXP(Main[i1])); + this.Dex[i0].Main.Add(EXPElement.Read(Main[i1])); } if (Dex[i0].ElementArray("Eyes", out MsgPack Eyes)) { this.Dex[i0].Eyes = new List(); for (i1 = 0; i1 < Eyes.Array.Length; i1++) - this.Dex[i0].Eyes.Add(ReadEXP(Eyes[i1])); + this.Dex[i0].Eyes.Add(EXPElement.Read(Eyes[i1])); } } - MsgPack = MsgPack.New; + MsgPack.Dispose(); + return 1; } - private EXPElement ReadEXP(MsgPack mp) => - new EXPElement() { Frame = mp.ReadSingle("F"), Both = mp.ReadUInt16("B"), - ID = mp.ReadUInt16("I"), Value = mp.ReadSingle("V"), - Trans = mp.ReadSingle("T") }; - public void MsgPackWriter(string file, bool JSON) { int i0 = 0; @@ -218,12 +210,12 @@ namespace KKdMainLib MsgPack EXP = MsgPack.New.Add("Name", this.Dex[i0].Name); MsgPack Main = new MsgPack(this.Dex[i0].Main.Count, "Main"); for (i1 = 0; i1 < this.Dex[i0].Main.Count; i1++) - Main[i1] = WriteEXP(this.Dex[i0].Main[i1]); + Main[i1] = this.Dex[i0].Main[i1].Write(); EXP.Add(Main); MsgPack Eyes = new MsgPack(this.Dex[i0].Eyes.Count, "Eyes"); for (i1 = 0; i1 < this.Dex[i0].Eyes.Count; i1++) - Eyes[i1] = WriteEXP(this.Dex[i0].Eyes[i1]); + Eyes[i1] = this.Dex[i0].Eyes[i1].Write(); EXP.Add(Eyes); Dex[i0] = EXP; } @@ -231,10 +223,6 @@ namespace KKdMainLib Dex.Write(true, file, JSON); } - private MsgPack WriteEXP(EXPElement element) => - MsgPack.New.Add("F", element.Frame).Add("B", element.Both ).Add("I", element.ID ) - .Add("V", element.Value).Add("T", element.Trans); - public struct EXP { public int MainOffset; @@ -243,6 +231,8 @@ namespace KKdMainLib public string Name; public List Main; public List Eyes; + + public override string ToString() => Name; } public struct EXPElement @@ -252,6 +242,16 @@ namespace KKdMainLib public ushort ID; public float Value; public float Trans; + + public static EXPElement Read(MsgPack msg) => + new EXPElement() { Frame = msg.ReadSingle("F"), Both = msg.ReadUInt16("B"), + ID = msg.ReadUInt16("I"), Value = msg.ReadSingle("V"), + Trans = msg.ReadSingle("T"), }; + + public MsgPack Write() => + MsgPack.New.Add("F", Frame).Add("B", Both ) + .Add("I", ID).Add("V", Value) + .Add("T", Trans); } } } diff --git a/KKdMainLib/DIVAFILE.cs b/KKdMainLib/DIVAFILE.cs index 16ccf36..7b6d763 100644 --- a/KKdMainLib/DIVAFILE.cs +++ b/KKdMainLib/DIVAFILE.cs @@ -14,7 +14,6 @@ namespace KKdMainLib public static void Decrypt(this string file) { - Console.Title = "DIVAFILE Decrypt - File: " + Path.GetFileName(file); Stream IO = File.OpenReader(file); if (IO.ReadInt64() != 0x454C494641564944) { IO.Close(); return; } @@ -39,7 +38,6 @@ namespace KKdMainLib public static void Encrypt(this string file) { - Console.Title = "DIVAFILE Encrypt - File: " + Path.GetFileName(file); Stream IO = File.OpenReader(file); int FileLengthOrigin = IO.Length; int FileLength = FileLengthOrigin.Align(16); diff --git a/KKdMainLib/DataBank.cs b/KKdMainLib/DataBank.cs index a3efbb6..6173261 100644 --- a/KKdMainLib/DataBank.cs +++ b/KKdMainLib/DataBank.cs @@ -100,13 +100,13 @@ namespace KKdMainLib Success = true; } - MsgPack = MsgPack.New; + MsgPack.Dispose(); } public void MsgPackWriter(string file, bool JSON, bool Compact = true) { if (!Success) return; - MsgPack msgPack = MsgPack.New; + MsgPack MsgPack = MsgPack.New; if (file.Contains("psrData")) { @@ -114,23 +114,23 @@ namespace KKdMainLib { MsgPack psrData = new MsgPack(psrDat.Length, "psrData"); for (i = 0; i < psrDat.Length; i++) psrData[i] = psrDat[i].WriteMP(); - msgPack.Add(psrData); + MsgPack.Add(psrData); } - else msgPack.Add(new MsgPack("psrData", null)); + else MsgPack.Add(new MsgPack("psrData", null)); } else if (file.Contains("PvList")) { if (pvList != null) { - if (Compact) msgPack.Add("Compact", Compact); + if (Compact) MsgPack.Add("Compact", Compact); MsgPack PvList = new MsgPack(pvList.Length, "PvList"); for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP(Compact); - msgPack.Add(PvList); + MsgPack.Add(PvList); } - else msgPack.Add(new MsgPack("PvList", null)); + else MsgPack.Add(new MsgPack("PvList", null)); } - msgPack.Write(file, JSON).Dispose(); + MsgPack.Write(file, JSON).Dispose(); } public static string UrlEncode(string value) => @@ -278,25 +278,25 @@ namespace KKdMainLib public MsgPack WriteMP(bool Compact) { - MsgPack msgPack = MsgPack.New; - msgPack.Add("ID", PV_ID); - if (!Enable) msgPack.Add("Enable", Enable); - if ( Extra ) msgPack.Add("Extra" , Extra ); + MsgPack MsgPack = MsgPack.New; + MsgPack.Add("ID", PV_ID); + if (!Enable) MsgPack.Add("Enable", Enable); + if ( Extra ) MsgPack.Add("Extra" , Extra ); if (Compact) { - if (AdvDemoStart.WriteLower) msgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt()); - if (AdvDemoEnd .WriteLower) msgPack.Add("AdvDemoEnd" , AdvDemoEnd .WriteInt()); - if (StartShow .WriteLower) msgPack.Add("StartShow" , StartShow .WriteInt()); - if ( EndShow .WriteUpper) msgPack.Add( "EndShow" , EndShow .WriteInt()); + if (AdvDemoStart.WriteLower) MsgPack.Add("AdvDemoStart", AdvDemoStart.WriteInt()); + if (AdvDemoEnd .WriteLower) MsgPack.Add("AdvDemoEnd" , AdvDemoEnd .WriteInt()); + if (StartShow .WriteLower) MsgPack.Add("StartShow" , StartShow .WriteInt()); + if ( EndShow .WriteUpper) MsgPack.Add( "EndShow" , EndShow .WriteInt()); } else { - if (AdvDemoStart.WriteLower) msgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart")); - if (AdvDemoEnd .WriteLower) msgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" )); - if (StartShow .WriteLower) msgPack.Add(StartShow .WriteMP("StartShow" )); - if ( EndShow .WriteUpper) msgPack.Add( EndShow .WriteMP( "EndShow" )); + if (AdvDemoStart.WriteLower) MsgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart")); + if (AdvDemoEnd .WriteLower) MsgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" )); + if (StartShow .WriteLower) MsgPack.Add(StartShow .WriteMP("StartShow" )); + if ( EndShow .WriteUpper) MsgPack.Add( EndShow .WriteMP( "EndShow" )); } - return msgPack; + return MsgPack; } public override string ToString() => diff --git a/KKdMainLib/Extensions.cs b/KKdMainLib/Extensions.cs index 0d136dd..ecf351c 100644 --- a/KKdMainLib/Extensions.cs +++ b/KKdMainLib/Extensions.cs @@ -1,6 +1,6 @@ using KKdBaseLib; +using KKdBaseLib.F2; using KKdMainLib.IO; -using KKdMainLib.F2nd; namespace KKdMainLib { @@ -76,6 +76,57 @@ namespace KKdMainLib stream.WriteEOFC(ID); } } + + public static class StructExtensions + { + public static Struct ReadStruct(byte[] Data) + { + Stream stream = File.OpenReader(Data); + Struct Struct = stream.ReadStruct(stream.ReadHeader(false)); + stream.Close(); + return Struct; + } + + public static Struct ReadStruct(this Stream stream, Header Header) + { + Struct Struct = new Struct { Header = Header, DataOffset = + stream.Position, Data = stream.ReadBytes(Header.SectionSize) }; + int ID = Header.ID; + + KKdList SubStructs = KKdList.New; + long Length = stream.Length - stream.Position; + long Position = 0; + while (Length > Position) + { + Header = stream.ReadHeader(false); + Position += Header.Length + Header.DataSize; + if (Header.ID == ID && Header.Signature == 0x43464F45) + { Struct.EOFC = true; break; } + else if (Header.ID == 0 && (Header.Signature == 0x30464F50 || + Header.Signature == 0x31464F50 || Header.Signature == 0x53524E45)) + SubStructs.Add(new Struct { Header = Header, DataOffset = + stream.Position, Data = stream.ReadBytes(Header.SectionSize) }); + else if (Header.ID <= ID) + { stream.LongPosition -= Header.Length; break; } + else SubStructs.Add(stream.ReadStruct(Header)); + } + + for (int i = 0; i < SubStructs.Capacity; i++) + { + string Sig = SubStructs[i].Header.ToString(); + if (Sig == "ENRS" || Sig == "EOFC" || Sig == "POF0" || Sig == "POF1") + { + if (Sig == "EOFC") Struct.EOFC = true; + else if (Sig == "ENRS") Struct.ENRS = ENRS.Read(SubStructs[i].Data); + else Struct.POF = POF .Read(SubStructs[i].Data, Sig == "POF1"); + SubStructs.RemoveAt(i); SubStructs.Capacity--; i--; + } + } + + if (SubStructs.Capacity > 0) Struct.SubStructs = SubStructs.ToArray(); + return Struct; + } + } public static class MPExt { @@ -84,10 +135,10 @@ namespace KKdMainLib MsgPack MsgPack; if (JSON) { JSON IO = new JSON(File.OpenReader(array)); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read( ); IO.Close(); } else { MP IO = new MP(File.OpenReader(array)); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read(true); IO.Close(); } return MsgPack; } @@ -96,10 +147,10 @@ namespace KKdMainLib MsgPack MsgPack; if (JSON) { JSON IO = new JSON(File.OpenReader(file + ".json", true)); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read( ); IO.Close(); } else { MP IO = new MP(File.OpenReader(file + ".mp" , true)); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read(true); IO.Close(); } return MsgPack; } @@ -108,10 +159,10 @@ namespace KKdMainLib MsgPack MsgPack; if (JSON) { JSON IO = new JSON(File.OpenReader(file + ".json")); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read( ); IO.Close(); } else { MP IO = new MP(File.OpenReader(file + ".mp" )); - MsgPack = IO.Read(); IO.Close(); } + MsgPack = IO.Read(true); IO.Close(); } return MsgPack; } diff --git a/KKdMainLib/F2/Bloom.cs b/KKdMainLib/F2/Bloom.cs new file mode 100644 index 0000000..1236a8e --- /dev/null +++ b/KKdMainLib/F2/Bloom.cs @@ -0,0 +1,65 @@ +using KKdBaseLib; +using KKdBaseLib.F2; +using KKdMainLib.IO; + +namespace KKdMainLib.F2 +{ + public struct Bloom + { + public CountPointer BLTs; + private Stream IO; + private Header Header; + private int i; + + public void BLTReader(string file) + { + BLTs = default; + IO = File.OpenReader(file + ".blt", true); + Header = IO.ReadHeader(); + if (Header.Signature != 0x544D4C42 || Header.InnerSignature != 0x3) return; + IO.Position -= 0x4; + + BLTs = IO.ReadCountPointerEndian(); + if (BLTs.Count < 1) { IO.Close(); BLTs.Count = -1; return; } + + if (BLTs.Count > 0 && BLTs.Offset == 0) { IO.Close(); BLTs.Count = -1; return; } + + IO.Position = BLTs.Offset; + for (i = 0; i < BLTs.Count; i++) + { + ref BLT BLT = ref BLTs.Entries[i]; + IO.ReadInt32Endian(); + BLT.Color .X = IO.ReadSingleEndian(); + BLT.Color .Y = IO.ReadSingleEndian(); + BLT.Color .Z = IO.ReadSingleEndian(); + BLT.Brightpass.X = IO.ReadSingleEndian(); + BLT.Brightpass.Y = IO.ReadSingleEndian(); + BLT.Brightpass.Z = IO.ReadSingleEndian(); + BLT.Range = IO.ReadSingleEndian(); + } + IO.Close(); + } + + public void TXTWriter(string file) + { + if (BLTs.Count < 1) return; + + IO = File.OpenWriter(); + IO.WriteShiftJIS("ID,ColorR,ColorG,ColorB,BrightpassR,BrightpassG,BrightpassB,Range\n"); + for (i = 0; i < BLTs.Count; i++) + IO.Write(i + "," + BLTs[i] + "\n"); + File.WriteAllBytes(file + "_bloom.txt", IO.ToArray(true)); + } + + public struct BLT + { + public Vector3 Color; + public Vector3 Brightpass; + public float Range; + + public override string ToString() => Color .ToString(6) + "," + + Brightpass.ToString(6) + "," + + Range .ToString(6); + } + } +} diff --git a/KKdMainLib/F2/ColorCorrection.cs b/KKdMainLib/F2/ColorCorrection.cs new file mode 100644 index 0000000..10fac8a --- /dev/null +++ b/KKdMainLib/F2/ColorCorrection.cs @@ -0,0 +1,73 @@ +using KKdBaseLib; +using KKdBaseLib.F2; +using KKdMainLib.IO; + +namespace KKdMainLib.F2 +{ + public struct ColorCorrection + { + public CountPointer CCTs; + private Stream IO; + private Header Header; + private int i; + + public void CCTReader(string file) + { + CCTs = default; + IO = File.OpenReader(file + ".cct", true); + Header = IO.ReadHeader(); + if (Header.Signature != 0x54524343 || Header.InnerSignature != 0x3) return; + IO.Position -= 0x4; + + CCTs = IO.ReadCountPointerEndian(); + if (CCTs.Count < 1) { IO.Close(); CCTs.Count = -1; return; } + + if (CCTs.Count > 0 && CCTs.Offset == 0) { IO.Close(); CCTs.Count = -1; return; } + + IO.Position = CCTs.Offset; + for (i = 0; i < CCTs.Count; i++) + { + ref CCT CCT = ref CCTs.Entries[i]; + IO.ReadInt32Endian(); + CCT.Hue = IO.ReadSingleEndian(); + CCT.Saturation = IO.ReadSingleEndian(); + CCT.Lightness = IO.ReadSingleEndian(); + CCT.Exposure = IO.ReadSingleEndian(); + CCT.Gamma.X = IO.ReadSingleEndian(); + CCT.Gamma.Y = IO.ReadSingleEndian(); + CCT.Gamma.Z = IO.ReadSingleEndian(); + CCT.Contrast = IO.ReadSingleEndian(); + } + + IO.Close(); + } + + public void TXTWriter(string file) + { + if (CCTs.Count < 1) return; + + IO = File.OpenWriter(); + IO.WriteShiftJIS("ID,Hue,Saturation,Lightness,Exposure,GammaR,GammaG,GammaB,Contrast\n"); + for (i = 0; i < CCTs.Count; i++) + IO.Write(i + "," + CCTs[i] + "\n"); + File.WriteAllBytes(file + "_cc.txt", IO.ToArray(true)); + } + + public struct CCT + { + public float Hue; + public float Saturation; + public float Lightness; + public float Exposure; + public Vector3 Gamma; + public float Contrast; + + public override string ToString() => Hue .ToString(6) + "," + + Saturation.ToString(6) + "," + + Lightness .ToString(6) + "," + + Exposure .ToString(6) + "," + + Gamma .ToString(6) + "," + + Contrast .ToString(6); + } + } +} diff --git a/KKdMainLib/F2/DOF.cs b/KKdMainLib/F2/DOF.cs new file mode 100644 index 0000000..529426d --- /dev/null +++ b/KKdMainLib/F2/DOF.cs @@ -0,0 +1,69 @@ +using KKdBaseLib; +using KKdBaseLib.F2; +using KKdMainLib.IO; + +namespace KKdMainLib.F2 +{ + public struct DOF + { + public CountPointer DFTs; + private Stream IO; + private Header Header; + private int i; + + public void DFTReader(string file) + { + DFTs = default; + IO = File.OpenReader(file + ".dft", true); + Header = IO.ReadHeader(); + if (Header.Signature != 0x54464F44 || Header.InnerSignature != 0x3) return; + IO.Position -= 0x4; + + DFTs = IO.ReadCountPointerEndian(); + if (DFTs.Count < 1) { IO.Close(); DFTs.Count = -1; return; } + + if (DFTs.Count > 0 && DFTs.Offset == 0) { IO.Close(); DFTs.Count = -1; return; } + + IO.Position = DFTs.Offset; + for (i = 0; i < DFTs.Count; i++) + { + ref DFT DFT = ref DFTs.Entries[i]; + IO.ReadInt32Endian(); + DFT. Focus = IO.ReadSingleEndian(); + DFT. FocusRange = IO.ReadSingleEndian(); + DFT.FuzzingRange = IO.ReadSingleEndian(); + DFT.Ratio = IO.ReadSingleEndian(); + DFT.Quality = IO.ReadSingleEndian(); + if (IO.IsX) IO.ReadInt32(); + } + + IO.Close(); + } + + public void TXTWriter(string file) + { + if (DFTs.Count < 1) return; + + IO = File.OpenWriter(); + IO.WriteShiftJIS("ID,Focus,FocusRange,FuzzingRange,Ratio,Quality\n"); + for (i = 0; i < DFTs.Count; i++) + IO.Write(i + "," + DFTs[i] + "\n"); + File.WriteAllBytes(file + "_dof.txt", IO.ToArray(true)); + } + + public struct DFT + { + public float Focus; + public float FocusRange; + public float FuzzingRange; + public float Ratio; + public float Quality; + + public override string ToString() => Focus .ToString(6) + "," + + FocusRange.ToString(6) + "," + + FuzzingRange.ToString(6) + "," + + Ratio .ToString(6) + "," + + Quality .ToString(6); + } + } +} diff --git a/KKdMainLib/F2/Light.cs b/KKdMainLib/F2/Light.cs new file mode 100644 index 0000000..f2e3253 --- /dev/null +++ b/KKdMainLib/F2/Light.cs @@ -0,0 +1,130 @@ +using KKdBaseLib; +using KKdBaseLib.F2; +using KKdMainLib.IO; + +namespace KKdMainLib.F2 +{ + public struct Light + { + public CountPointer> LITs; + private Stream IO; + private Header Header; + private int i, i0; + + public void LITReader(string file) + { + LITs = default; + IO = File.OpenReader(file + ".lit", true); + Header = IO.ReadHeader(); + if (Header.Signature != 0x4354494C || Header.InnerSignature != 0x2 || + Header.SectionSignature != 0x2) return; + + LITs = IO.ReadCountPointerEndian>(); + if (LITs.Count < 1) { IO.Close(); LITs.Count = -1; return; } + + IO.Position = LITs.Offset; + for (i = 0; i < LITs.Count; i++) + { + LITs[i] = IO.ReadCountPointerX(); + if ((LITs[i].Count > 0 || LITs[i].Offset == 0) && !IO.IsX) { IO.Close(); LITs.Count = -1; return; } + } + + for (i = 0; i < LITs.Count; i++) + { + IO.Position = LITs[i].Offset; + for (i0 = 0; i0 < LITs[i].Count; i0++) + { + ref LIT LIT = ref LITs.Entries[i].Entries[i0]; + LIT.Id = (Id )IO.ReadInt32Endian(); + LIT.Flags = (Flags)IO.ReadInt32Endian(); + LIT.Type = (Type )IO.ReadInt32Endian(); + if (IO.IsX) { IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt64(); } + LIT.Ambient .X = IO.ReadSingleEndian(); + LIT.Ambient .Y = IO.ReadSingleEndian(); + LIT.Ambient .Z = IO.ReadSingleEndian(); + LIT.Ambient .W = IO.ReadSingleEndian(); + LIT.Diffuse .X = IO.ReadSingleEndian(); + LIT.Diffuse .Y = IO.ReadSingleEndian(); + LIT.Diffuse .Z = IO.ReadSingleEndian(); + LIT.Diffuse .W = IO.ReadSingleEndian(); + LIT.Specular .X = IO.ReadSingleEndian(); + LIT.Specular .Y = IO.ReadSingleEndian(); + LIT.Specular .Z = IO.ReadSingleEndian(); + LIT.Specular .W = IO.ReadSingleEndian(); + LIT.Position .X = IO.ReadSingleEndian(); + LIT.Position .Y = IO.ReadSingleEndian(); + LIT.Position .Z = IO.ReadSingleEndian(); + LIT.ToneCurve.X = IO.ReadSingleEndian(); + LIT.ToneCurve.Y = IO.ReadSingleEndian(); + LIT.ToneCurve.Z = IO.ReadSingleEndian(); + if (IO.IsX) { IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt64(); + IO.ReadInt64(); IO.ReadInt64(); IO.ReadInt32(); } + } + } + IO.Close(); + } + + public void TXTWriter(string file) + { + i = 0; + if (LITs.Count < 1) return; + + IO = File.OpenWriter(); + IO.WriteShiftJIS("Type,AmbientR,AmbientG,AmbientB,DiffuseR,DiffuseG,DiffuseB,SpecularR,SpecularG," + + "SpecularB,SpecularA,PosX,PosY,PosZ,ToneCurveBegin,ToneCurveEnd,ToneCurveBlendRate," + + (file.EndsWith("_chara") ? "コメント" : "ID") + "\n"); + for (i0 = 0; i0 < LITs[i].Count; i0++) + IO.Write(LITs[i][i0] + "," + i + "\n"); + File.WriteAllBytes(file + "_light.txt", IO.ToArray(true)); + } + + public struct LIT + { + public Id Id; + public Flags Flags; + public Type Type; + public Vector4 Ambient; + public Vector4 Diffuse; + public Vector4 Specular; + public Vector3 Position; + public Vector3 ToneCurve; + + public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," + + ((Flags & Flags.Ambient ) == 0 ? ",,," : Ambient .ToString(6) + ",") + + ((Flags & Flags.Diffuse ) == 0 ? ",,," : Diffuse .ToString(6) + ",") + + ((Flags & Flags.Specular ) == 0 ? ",,,," : Specular .ToString(6) + ",") + + ((Flags & Flags.Position ) == 0 ? ",,," : Position .ToString(6) + ",") + + ((Flags & Flags.ToneCurve) == 0 ? ",,," : ToneCurve.ToString(6)); + } + + public enum Id : int + { + CHARA = 0, + STAGE = 1, + SUN = 2, + REFLECT = 3, + SHADOW = 4, + CHARA_COLOR = 5, + CHARA_F = 6, + PROJECTION = 7, + } + + public enum Type : int + { + OFF = 0, + PARALLEL = 1, + POINT = 2, + SPOT = 3, + } + + public enum Flags : int + { + Type = 0b0000000001, + Ambient = 0b0000000010, + Diffuse = 0b0000000100, + Specular = 0b0000001000, + Position = 0b0000010000, + ToneCurve = 0b1000000000, + } + } +} diff --git a/KKdMainLib/F2nd/Struct.cs b/KKdMainLib/F2nd/Struct.cs deleted file mode 100644 index 402d14a..0000000 --- a/KKdMainLib/F2nd/Struct.cs +++ /dev/null @@ -1,69 +0,0 @@ -using KKdBaseLib; -using KKdMainLib.IO; - -namespace KKdMainLib.F2nd -{ - public struct Struct - { - public Header Header; - public byte[] Data; - public Struct[] SubStructs; - public bool EOFC; - public ENRS[] ENRS; - public KKdList POF; - - public long DataOffset; - - public override string ToString() => Header.ToString() + (SubStructs != null ? - "; SubStructs: " + SubStructs.Length : "")+ (ENRS != null ? "; Has ENRS" : "") + - (POF.NotNull ? "; Has POF" : "") + (EOFC ? "; Has EOFC" : ""); - - public static Struct ReadStruct(byte[] Data) - { - Stream stream = File.OpenReader(Data); - Struct Struct = ReadStruct(ref stream, stream.ReadHeader(false)); - stream.Close(); - return Struct; - } - - private static Struct ReadStruct(ref Stream stream, Header Header) - { - Struct Struct = new Struct { Header = Header, DataOffset = - stream.Position, Data = stream.ReadBytes(Header.SectionSize) }; - int ID = Header.ID; - - KKdList SubStructs = KKdList.New; - long Length = stream.Length - stream.Position; - long Position = 0; - while (Length > Position) - { - Header = stream.ReadHeader(false); - Position += Header.Length + Header.DataSize; - if (Header.ID == ID && Header.Signature == 0x43464F45) - { Struct.EOFC = true; break; } - else if (Header.ID == 0 && (Header.Signature == 0x30464F50 || - Header.Signature == 0x31464F50 || Header.Signature == 0x53524E45)) - SubStructs.Add(new Struct { Header = Header, DataOffset = - stream.Position, Data = stream.ReadBytes(Header.SectionSize) }); - else if (Header.ID <= ID) - { stream.LongPosition -= Header.Length; break; } - else SubStructs.Add(ReadStruct(ref stream, Header)); - } - - for (int i = 0; i < SubStructs.Capacity; i++) - { - string Sig = SubStructs[i].Header.ToString(); - if (Sig == "ENRS" || Sig == "EOFC" || Sig == "POF0" || Sig == "POF1") - { - if (Sig == "EOFC") Struct.EOFC = true; - else if (Sig == "ENRS") Struct.ENRS = F2nd.ENRS.Read(SubStructs[i].Data); - else Struct.POF = F2nd.POF .Read(SubStructs[i].Data, Sig == "POF1"); - SubStructs.RemoveAt(i); SubStructs.Capacity--; i--; - } - } - - if (SubStructs.Capacity > 0) Struct.SubStructs = SubStructs.ToArray(); - return Struct; - } - } -} diff --git a/KKdMainLib/IO/Extensions.cs b/KKdMainLib/IO/Extensions.cs index af3e5ef..351a746 100644 --- a/KKdMainLib/IO/Extensions.cs +++ b/KKdMainLib/IO/Extensions.cs @@ -19,9 +19,15 @@ namespace KKdMainLib.IO } return s.ToArray(); } + + public static byte PeekByte(this Stream stream) + { byte val = stream.ReadByte(); stream.LongPosition--; return val; } + public static char PeekCharASCII(this Stream stream) + { byte val = stream.ReadByte(); stream.LongPosition--; return (char)val; } public static char PeekCharUTF8(this Stream stream) { long LongPosition = stream.LongPosition; char val = stream.ReadCharUTF8(); stream.LongPosition = LongPosition; return val; } + public static Stream SkipWhitespace(this Stream stream) { while (true) @@ -29,6 +35,25 @@ namespace KKdMainLib.IO else break; return stream; } + + public static bool Assert(this Stream stream, byte next) + { if (stream.PeekByte() == next) { stream.PeekByte(); return true; } else return false; } + public static bool Assert(this Stream stream, byte[] next) + { + for (var i = 0; i < next.Length; i++) + if (!stream.Assert(next[i])) return false; + return true; + } + + public static bool AssertASCII(this Stream stream, char next) + { if (stream.PeekCharUTF8() == next) { stream.ReadCharUTF8(); return true; } else return false; } + public static bool AssertASCII(this Stream stream, string next) + { + for (var i = 0; i < next.Length; i++) + if (!stream.AssertASCII(next[i])) return false; + return true; + } + public static bool Assert(this Stream stream, char next) { if (stream.PeekCharUTF8() == next) { stream.ReadCharUTF8(); return true; } else return false; } public static bool Assert(this Stream stream, string next) diff --git a/KKdMainLib/IO/JSON.cs b/KKdMainLib/IO/JSON.cs index 9208928..e551afd 100644 --- a/KKdMainLib/IO/JSON.cs +++ b/KKdMainLib/IO/JSON.cs @@ -173,11 +173,11 @@ namespace KKdMainLib.IO { string s = ""; while (char.IsDigit(_IO.SkipWhitespace(). PeekCharUTF8())) s += _IO.ReadCharUTF8(); return s; } - public JSON Write(MsgPack MsgPack, string End = "\n", string TabChar = " ") - { Write(MsgPack, End, TabChar, "", true); return this; } + public JSON Write(MsgPack MsgPack, string End = "\n", string TabChar = " ") => + Write(MsgPack, End, TabChar, "", true); - public JSON Write(MsgPack MsgPack, bool Style = false) - { Write(MsgPack, "\n", " ", "", Style); return this; } + public JSON Write(MsgPack MsgPack, bool Style = false) => + Write(MsgPack, "\n", " ", "", Style); private JSON Write(MsgPack MsgPack, string End, string TabChar, string Tab, bool Style, bool IsArray = false) { @@ -185,7 +185,7 @@ namespace KKdMainLib.IO Tab += TabChar; if (MsgPack.Name != null && !IsArray) _IO.Write("\"" + MsgPack.Name + "\":" + (Style ? " " : "")); if (MsgPack.Object == null) { WriteNil(); return this; } - + if (MsgPack.List.NotNull) { WriteMap(); @@ -228,33 +228,13 @@ namespace KKdMainLib.IO if (Style) _IO.Write(OldTab); WriteArr(true); } - else if (MsgPack.Object is MsgPack msg) - Write(msg, End, TabChar, Tab, Style); - else Write(MsgPack.Object, End, TabChar, Tab, Style); + else if (MsgPack.Object is MsgPack msg) Write(msg, End, TabChar, Tab, Style); + else if (MsgPack.Object is string str) Write(str); + else _IO.Write(BaseExtensions.ToString(MsgPack.Object)); return this; } - private void Write(object obj, string End, string TabChar, string Tab, bool Style) - { - if (obj == null) { WriteNil(); return; } - switch (obj) - { - case MsgPack val: Write(val, End, TabChar, Tab, Style); break; - case string val: Write(val); break; - case bool Boolean: - case sbyte Int8 : - case byte UInt8 : - case short Int16: - case ushort UInt16: - case int Int32: - case uint UInt32: - case long Int64: - case ulong UInt64: - case float Float32: - case double Float64: _IO.Write(BaseExtensions.ToString(obj)); break; - } - } private void Write(string val) => _IO.Write("\"" + val .Replace("\\", "\\\\").Replace("/" , "\\/").Replace("\"", "\\\"") .Replace("\0", "\\0" ).Replace("\b", "\\b").Replace("\f", "\\f" ) diff --git a/KKdMainLib/IO/MP.cs b/KKdMainLib/IO/MP.cs index 05ca9fe..8959ca8 100644 --- a/KKdMainLib/IO/MP.cs +++ b/KKdMainLib/IO/MP.cs @@ -16,8 +16,8 @@ namespace KKdMainLib.IO public MsgPack Read(bool Array = false) { MsgPack MsgPack = MsgPack.New; - if (!Array) MsgPack.Name = ReadString((Types)_IO.ReadByte()); byte Unk = _IO.ReadByte(); + if (!Array) { MsgPack.Name = ReadString((Types)Unk); Unk = _IO.ReadByte(); } Types Type = (Types)Unk; if (Type >= Types.FixMap && Type <= Types.FixMapMax) @@ -30,7 +30,7 @@ namespace KKdMainLib.IO MsgPack.Object = new MsgPack[Unk - (byte)Types.FixArr]; for (int i = 0; i < Unk - (byte)Types.FixArr; i++) MsgPack[i] = Read( true); } - else if (Type >= Types.FixStr && Type <= Types.FixStrMax) MsgPack.Object = ReadString( Type); + else if (Type >= Types.FixStr && Type <= Types.FixStrMax) MsgPack.Object = ReadString(Type); else if (Type >= Types.PosInt && Type <= Types.PosIntMax) MsgPack.Object = Unk; else if (Type >= Types.NegInt && Type <= Types.NegIntMax) MsgPack.Object = (sbyte)Unk; else diff --git a/KKdMainLib/IO/Stream.cs b/KKdMainLib/IO/Stream.cs index 8097d46..e560c07 100644 --- a/KKdMainLib/IO/Stream.cs +++ b/KKdMainLib/IO/Stream.cs @@ -368,8 +368,8 @@ namespace KKdMainLib.IO ValWrite &= 0xFF; } - public void CheckRead () { if (BitRead > 0) ValRead = 0; BitRead = 8; } - public void CheckWrited() { if (BitWrite > 0) { Write(ValWrite); ValWrite = 0; BitWrite = 0; } } + public void CheckRead () { if (BitRead > 0) ValRead = 0; BitRead = 8; } + public void CheckWrited() { if (BitWrite > 0) { WriteByte((byte)ValWrite); ValWrite = 0; BitWrite = 0; } } public byte[] ToArray(bool Close) { byte[] Data = ToArray(); if (Close) this.Close(); return Data; } diff --git a/KKdMainLib/KKdMainLib.csproj b/KKdMainLib/KKdMainLib.csproj index 6222a4d..af1199e 100644 --- a/KKdMainLib/KKdMainLib.csproj +++ b/KKdMainLib/KKdMainLib.csproj @@ -42,10 +42,10 @@ - - - - + + + + @@ -61,6 +61,7 @@ + diff --git a/KKdMainLib/Main.cs b/KKdMainLib/Main.cs index 894cfaa..4860e3e 100644 --- a/KKdMainLib/Main.cs +++ b/KKdMainLib/Main.cs @@ -82,35 +82,33 @@ namespace KKdMainLib Multiselect = true, Title = "Choose file(s) to open:" }; ofd.Filter = GetArgs("All;", false, "*"); - if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") + - GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + JSON + MsgPack; + if (filetype == "a3da") ofd.Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") + + GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + JSON + MsgPack; else if (filetype == "bin" ) ofd.Filter = GetArgs("BIN" , "bin", "json", "mp") + BIN + JSON + MsgPack; + else if (filetype == "blt" ) ofd.Filter = GetArgs("BLT" , "blt"); else if (filetype == "bon" ) ofd.Filter = GetArgs("BON" , "bon", "bin", "json", "mp") + GetArgs("BON", true, "bon") + BIN + JSON + MsgPack; + else if (filetype == "cct" ) ofd.Filter = GetArgs("CCT" , "cct"); else if (filetype == "databank") ofd.Filter = GetArgs("DAT", "dat", "json", "mp") + GetArgs("DAT", true, "dat") + JSON + MsgPack; else if (filetype == "dex" ) ofd.Filter = GetArgs("DEX" , "dex", "bin", "json", "mp") + GetArgs("DEX", true, "dex") + BIN + JSON + MsgPack; + else if (filetype == "dft") ofd.Filter = GetArgs("DFT" , "dft"); else if (filetype == "diva") ofd.Filter = GetArgs("DIVA", "diva", "wav") + GetArgs("DIVA", true, "diva") + GetArgs("WAV", true, "wav"); else if (filetype == "dsc" ) ofd.Filter = GetArgs("DSC" , "dsc", "json", "mp") + GetArgs("DSC", true, "dsc") + JSON + MsgPack; else if (filetype == "farc") ofd.Filter = "FARC Archives (*.farc)|*.farc"; - else if (filetype == "image") ofd.Filter = GetArgs("Image", "dds", "png") + - GetArgs("DDS", true, "dds") + GetArgs("PNG", true, "png"); else if (filetype == "json") ofd.Filter = "JSON (*.json)|*.json"; - else if (filetype == "kki" ) ofd.Filter = GetArgs("KKI", "kki"); else if (filetype == "mp" ) ofd.Filter = GetArgs("MessagePack", "mp"); - else if (filetype == "ppd" ) ofd.Filter = GetArgs("PPD", "ppd", "pak", "mod") + - GetArgs("PPD", true, "ppd") + GetArgs("PAK", true, "pak") + GetArgs("MOD", true, "mod"); - else if (filetype == "str" ) ofd.Filter = GetArgs("STR", "str", "bin", "json", "mp") + + else if (filetype == "lit") ofd.Filter = GetArgs("LIT" , "lit"); + else if (filetype == "str" ) ofd.Filter = GetArgs("STR" , "str", "bin", "json", "mp") + GetArgs("STR", true, "str") + BIN + JSON + MsgPack; - else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG", "vag", "wav") + + else if (filetype == "vag" ) ofd.Filter = GetArgs("VAG" , "vag", "wav") + GetArgs("VAG", true, "vag") + GetArgs("WAV", true, "wav"); - if (ofd.ShowDialog() == DialogResult.OK) - FileNames = ofd.FileNames; + if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames; ofd.Dispose(); } else if (code == 2) @@ -126,27 +124,6 @@ namespace KKdMainLib } return ""; } - - public static void ChooseSave(string filetype, - out string InitialDirectory, out string[] FileNames) - { - InitialDirectory = ""; - FileNames = new string[0]; - Console.WriteLine("Choose file to save:"); - SaveFileDialog sfd = new SaveFileDialog { InitialDirectory = Application.StartupPath }; - switch (filetype) - { - case "kki": - sfd.Filter = "KKI file (*.kki)|*.kki"; - break; - } - if (sfd.ShowDialog() == DialogResult.OK) - { - InitialDirectory = sfd.InitialDirectory.ToString(); - FileNames = sfd.FileNames; - } - sfd.Dispose(); - } public static string NullTerminated(this string Source, ref int i, byte End) { diff --git a/KKdMainLib/Mot.cs b/KKdMainLib/Mot.cs new file mode 100644 index 0000000..6e72cd8 --- /dev/null +++ b/KKdMainLib/Mot.cs @@ -0,0 +1,327 @@ +//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/ + +using KKdBaseLib; +using KKdMainLib.IO; + +namespace KKdMainLib +{ + public struct Mot + { + private int i, i0, i1; + private MotHeader[] MOT; + private Stream IO; + + public void MOTReader(string file) + { + IO = File.OpenReader(file + ".bin"); + + i = 0; + while (true) + if (IO.ReadInt64() == 0) break; + else { IO.ReadInt64(); i++; } + if (i == 0) return; + + int MOTCount = i; + MsgPack m = new MsgPack(MOTCount, "Mot"); + MOT = new MotHeader[MOTCount]; + for (i = 0; i < MOTCount; i++) + { + ref MotHeader Mot = ref MOT[i]; + Mot.KeySet .Offset = IO.ReadInt32(); + Mot.KeySetTypesOffset = IO.ReadInt32(); + Mot. KeySetOffset = IO.ReadInt32(); + Mot.BoneInfo .Offset = IO.ReadInt32(); + } + + for (i = 0; i < MOTCount; i++) + { + ref MotHeader Mot = ref MOT[i]; + + i0 = 1; + IO.Position = Mot.BoneInfo.Offset; + IO.ReadUInt16(); + while (IO.ReadUInt16() != 0) i0++; + + Mot.BoneInfo.Value = new BoneInfo[i0]; + IO.Position = Mot.BoneInfo.Offset; + for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++) + Mot.BoneInfo.Value[i0].Id = IO.ReadUInt16(); + + IO.Position = Mot.KeySet.Offset; + int info = IO.ReadUInt16(); + Mot.HighBits = info >> 14; + Mot.FrameCount = IO.ReadUInt16(); + + Mot.KeySet.Value = new KeySet[info & 0x3FFF]; + IO.Position = Mot.KeySetTypesOffset; + for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + if (i0 % 8 == 0) i1 = IO.ReadUInt16(); + + Mot.KeySet.Value[i0] = new KeySet { Type = (KeySetType)((i1 >> (i0 % 8 * 2)) & 0b11) }; + } + + IO.Position = Mot.KeySetOffset; + for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + ref KeySet Key = ref Mot.KeySet.Value[i0]; + if (Key.Type == KeySetType.Static) + { Key.Keys = new KFT2[1]; + Key.Keys[0].V = IO.ReadSingle(); } + else if (Key.Type == KeySetType.Linear) + { + Key.Keys = new KFT2[IO.ReadUInt16()]; + for (i1 = 0; i1 < Key.Keys.Length; i1++) + Key.Keys[i1].F = IO.ReadUInt16(); + IO.Align(0x4); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + Key.Keys[i1].V = IO.ReadSingle(); + } + else if (Key.Type == KeySetType.Interpolated) + { + Key.Keys = new KFT2[IO.ReadUInt16()]; + for (i1 = 0; i1 < Key.Keys.Length; i1++) + Key.Keys[i].F = IO.ReadUInt16(); + IO.Align(0x4); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + { Key.Keys[i1].V = IO.ReadSingle(); Key.Keys[i1].T = IO.ReadSingle(); } + } + } + } + IO.Close(); + } + + public void MOTWriter(string file) + { + if (MOT == null) return; + IO = File.OpenWriter(file + ".bin"); + + int MOTCount = MOT.Length; + IO.Position = (MOTCount + 1) << 4; + for (i = 0; i < MOTCount; i++) + { + ref MotHeader Mot = ref MOT[i]; + Mot.KeySet.Offset = IO.Position; + IO.Write((ushort)((Mot.HighBits << 14) | (Mot.KeySet.Value.Length & 0x3FFF))); + IO.Write((ushort)Mot.FrameCount); + + Mot.KeySetTypesOffset = IO.Position; + for (i0 = 0, i1 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + i1 |= ((byte)Mot.KeySet.Value[i0].Type << (i0 % 8 * 2)) & (0b11 << (i0 % 8 * 2)); + + if (i0 % 8 == 7) { IO.Write((ushort)i1); i1 = 0; } + } + IO.Write((ushort)i1); + + IO.Align(0x4); + Mot.KeySetOffset = IO.Position; + for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + ref KeySet Key = ref Mot.KeySet.Value[i0]; + if (Key.Type == KeySetType.Static) + IO.Write(Key.Keys[0].V); + else if (Key.Type == KeySetType.Linear) + { + IO.Write((ushort)Key.Keys.Length); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + IO.Write(Key.Keys[i1].F); + IO.Align(0x4); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + IO.Write(Key.Keys[i1].V); + } + else if (Key.Type == KeySetType.Interpolated) + { + IO.Write((ushort)Key.Keys.Length); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + IO.Write(Key.Keys[i1].F); + IO.Align(0x4); + for (i1 = 0; i1 < Key.Keys.Length; i1++) + { IO.Write(Key.Keys[i1].V); IO.Write(Key.Keys[i1].T); } + } + } + IO.Align(0x4); + + Mot.BoneInfo.Offset = IO.Position; + for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++) + IO.Write((ushort)Mot.BoneInfo.Value[i0].Id); + IO.Write((ushort)0); + } + IO.Align(0x4, true); + + IO.Position = 0; + for (i = 0; i < MOTCount; i++) + { + ref MotHeader Mot = ref MOT[i]; + IO.Write(Mot.KeySet .Offset); + IO.Write(Mot.KeySetTypesOffset); + IO.Write(Mot. KeySetOffset); + IO.Write(Mot.BoneInfo .Offset); + } + + IO.Close(); + } + + public void MsgPackReader(string file, bool JSON) + { + MOT = null; + + MsgPack MsgPack = file.ReadMP(JSON); + if (!MsgPack.ElementArray("MOT", out MsgPack MOTS)) { MsgPack.Dispose(); return; } + + if (MOTS.Array != null) + if (MOTS.Array.Length > 0) + { + MOT = new MotHeader[MOTS.Array.Length]; + for (int i = 0; i < MOT.Length; i++) + MsgPackReader(MOTS.Array[i], ref MOT[i]); + } + + MsgPack.Dispose(); + } + + public void MsgPackWriter(string file, bool JSON) + { + int MOTCount = MOT.Length; + MsgPack MOTS = new MsgPack(MOTCount, "MOT"); + for (i = 0; i < MOTCount; i++) + MOTS[i] = MsgPackWriter(ref MOT[i]); + MOTS.Write(true, file, JSON); + } + + public void MsgPackReader(MsgPack MOT, ref MotHeader Mot) + { + MsgPack Temp = MsgPack.New; + Mot.HighBits = MOT.ReadInt32("HighBits" ); + Mot.FrameCount = MOT.ReadInt32("FrameCount"); + + if (!MOT.ElementArray("KeySets", out Temp)) return; + + Mot.KeySet.Value = new KeySet[Temp.Array.Length]; + for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + ref KeySet KeySet = ref Mot.KeySet.Value[i0]; + + if (Temp.Array[i0].Array == null || Temp.Array[i0].Array.Length != 2) continue; + KeySet.Type = (KeySetType)Temp.Array[i0].Array[0].ReadInt32(); + + MsgPack keySet = Temp.Array[i0].Array[1]; + + if (keySet.Array == null) { KeySet.Type = 0; continue; } + else if (KeySet.Type == KeySetType.None) continue; + else if (KeySet.Type == KeySetType.Static) + { + KeySet.Keys = new KFT2[1]; + KeySet.Keys[0].F = keySet.Array[0][0].ReadUInt16(); + KeySet.Keys[0].V = keySet.Array[0][1].ReadSingle(); + } + else if (KeySet.Type == KeySetType.Linear) + { + KeySet.Keys = new KFT2[keySet.Array.Length]; + for (i1 = 0; i1 < keySet.Array.Length; i1++) + { + KeySet.Keys[i1].F = keySet.Array[i1][0].ReadUInt16(); + KeySet.Keys[i1].V = keySet.Array[i1][1].ReadSingle(); + } + } + else if (KeySet.Type == KeySetType.Interpolated) + { + KeySet.Keys = new KFT2[keySet.Array.Length]; + for (i1 = 0; i1 < keySet.Array.Length; i1++) + { + KeySet.Keys[i1].F = keySet.Array[i1][0].ReadUInt16(); + KeySet.Keys[i1].V = keySet.Array[i1][1].ReadSingle(); + KeySet.Keys[i1].T = keySet.Array[i1][2].ReadSingle(); + } + } + } + + if (MOT.ElementArray("BoneInfo", out Temp)) + { + Mot.BoneInfo.Value = new BoneInfo[Temp.Array.Length]; + for (i = 0; i < Mot.BoneInfo.Value.Length; i++) + Mot.BoneInfo.Value[i].Id = Temp[i].ReadInt32(); + } + else return; + } + + public MsgPack MsgPackWriter(ref MotHeader Mot) + { + MsgPack MOT = MsgPack.NewReserve(4).Add("FrameCount", Mot.FrameCount).Add("HighBits", Mot.HighBits); + + MsgPack KeySets = new MsgPack(Mot.KeySet.Value.Length, "KeySets"); + for (i0 = 0; i0 < Mot.KeySet.Value.Length; i0++) + { + ref KeySet KeySet = ref Mot.KeySet.Value[i0]; + if (KeySet.Type == KeySetType.None) continue; + + KeySets[i0] = new MsgPack(2); + KeySets[i0].Array[0] = (MsgPack)(byte)KeySet.Type; + KeySets[i0].Array[1] = new MsgPack(KeySet.Keys.Length); + if (KeySet.Type == KeySetType.Static) + { + KeySets[i0].Array[1][0] = new MsgPack(2); + KeySets[i0].Array[1][0].Array[0] = (MsgPack)KeySet.Keys[0].F; + KeySets[i0].Array[1][0].Array[1] = (MsgPack)KeySet.Keys[0].V; + } + else if (KeySet.Type == KeySetType.Linear) + for (i1 = 0; i1 < KeySet.Keys.Length; i1++) + { + KeySets[i0].Array[1][i1] = new MsgPack(2); + KeySets[i0].Array[1][i1].Array[0] = (MsgPack)KeySet.Keys[i1].F; + KeySets[i0].Array[1][i1].Array[1] = (MsgPack)KeySet.Keys[i1].V; + } + else + for (i1 = 0; i1 < KeySet.Keys.Length; i1++) + { + KeySets[i0].Array[1][i1] = new MsgPack(3); + KeySets[i0].Array[1][i1].Array[0] = (MsgPack)KeySet.Keys[i1].F; + KeySets[i0].Array[1][i1].Array[1] = (MsgPack)KeySet.Keys[i1].V; + KeySets[i0].Array[1][i1].Array[2] = (MsgPack)KeySet.Keys[i1].T; + } + } + MOT.Add(KeySets); + + MsgPack BoneInfo = new MsgPack(Mot.BoneInfo.Value.Length, "BoneInfo"); + for (i0 = 0; i0 < Mot.BoneInfo.Value.Length; i0++) + BoneInfo[i0] = (MsgPack)Mot.BoneInfo.Value[i0].Id; + MOT.Add(BoneInfo); + + return MOT; + } + + public struct MotHeader + { + public int KeySetOffset; + public int KeySetTypesOffset; + public Pointer< KeySet []> KeySet ; + public Pointer BoneInfo; + + public int HighBits; + public int FrameCount; + } + + public struct KeySet + { + public KFT2[] Keys; + public KeySetType Type; + + public override string ToString() => $"Type: {Type}" + (Type == KeySetType.Static ? + $"; Value: {Keys[0].Check()}" : Type > KeySetType.Static ? $"; Keys: {Keys.Length}" : ""); + } + + public enum KeySetType : byte + { + None = 0b00, + Static = 0b01, + Linear = 0b10, + Interpolated = 0b11, + } + + public struct BoneInfo + { + public string Name; + public int Id; + } + } +} diff --git a/KKdMainLib/Properties/AssemblyInfo.cs b/KKdMainLib/Properties/AssemblyInfo.cs index 5b03fc6..8b73bc5 100644 --- a/KKdMainLib/Properties/AssemblyInfo.cs +++ b/KKdMainLib/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("2BA7EFC6-91D1-8BBC-C487-06C7F36CC789")] -[assembly: AssemblyVersion("0.4.7.1")] -[assembly: AssemblyFileVersion("0.4.7.1")] +[assembly: AssemblyVersion("0.4.7.2")] +[assembly: AssemblyFileVersion("0.4.7.2")] diff --git a/KKdMainLib/STR.cs b/KKdMainLib/STR.cs index c22ae3a..d012e3e 100644 --- a/KKdMainLib/STR.cs +++ b/KKdMainLib/STR.cs @@ -1,6 +1,6 @@ using KKdBaseLib; +using KKdBaseLib.F2; using KKdMainLib.IO; -using KKdMainLib.F2nd; namespace KKdMainLib { @@ -183,7 +183,7 @@ namespace KKdMainLib if (STRs[i].Str.Value == null) STRs[i].Str.Value = ""; } - MsgPack = MsgPack.New; + MsgPack.Dispose(); } public void MsgPackWriter(string file, bool JSON) diff --git a/KKdSoundLib/VAG.cs b/KKdSoundLib/VAG.cs index 07884d8..2ce3e03 100644 --- a/KKdSoundLib/VAG.cs +++ b/KKdSoundLib/VAG.cs @@ -89,7 +89,6 @@ namespace KKdSoundLib VAGData.DataPtr[i * ch + c] = temp_bufferPtr[i ]; VAGData.DataPtr[i2 * ch + c] = temp_bufferPtr[i2]; } - } else for (i1 = 0; i1 < VAGData.Size; i1++, VAGData.DataPtr += VBS) diff --git a/PD_Tool/PD_Tool.csproj b/PD_Tool/PD_Tool.csproj index 879b0c6..ee41724 100644 --- a/PD_Tool/PD_Tool.csproj +++ b/PD_Tool/PD_Tool.csproj @@ -39,14 +39,19 @@ IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE1006 - + + + + + + diff --git a/PD_Tool/Program.cs b/PD_Tool/Program.cs index 02bcd6b..4bb44d6 100644 --- a/PD_Tool/Program.cs +++ b/PD_Tool/Program.cs @@ -1,4 +1,5 @@ using System; +using KKdMainLib; using KKdMainLib.IO; using KKdMain = KKdMainLib.Main; using KKdFARC = KKdMainLib.FARC; @@ -7,11 +8,16 @@ namespace PD_Tool { public static class Program { + [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] + static extern bool SetProcessDPIAware(); + [ThreadStatic] public static string function = ""; [STAThread] public static void Main(string[] args) { + SetProcessDPIAware(); + Console.Title = "PD_Tool"; if (args.Length == 0) { @@ -41,6 +47,9 @@ namespace PD_Tool private static void MainMenu() { + GC.Collect(); + Console. InputEncoding = System.Text.Encoding.Unicode; + Console.OutputEncoding = System.Text.Encoding.Unicode; Console.Title = "PD_Tool"; Console.Clear(); @@ -52,8 +61,9 @@ namespace PD_Tool KKdMain.ConsoleDesign("3. Decrypt from DIVAFILE"); KKdMain.ConsoleDesign("4. Encrypt to DIVAFILE"); KKdMain.ConsoleDesign("5. DB_Tools"); - KKdMain.ConsoleDesign("6. Converting Tools"); - KKdMain.ConsoleDesign(JSON ? "7. MsgPack to JSON" : "7. JSON to MsgPack"); + KKdMain.ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools"); + KKdMain.ConsoleDesign("7. F/F2/X/FT Converting Tools"); + KKdMain.ConsoleDesign(JSON ? "8. MsgPack to JSON" : "9. JSON to MsgPack"); KKdMain.ConsoleDesign(false); KKdMain.ConsoleDesign(JSON ? "M. MessagePack" : "J. JSON"); KKdMain.ConsoleDesign("Q. Quit"); @@ -81,17 +91,17 @@ namespace PD_Tool else if (function == "6") { Console.Clear(); - Console.Title = "Converter Tools"; + Console.Title = "AC/DT/F/AFT/FT Converting Tools"; KKdMain.ConsoleDesign(true); - KKdMain.ConsoleDesign(" Choose tool:"); + KKdMain.ConsoleDesign(" Choose converter:"); KKdMain.ConsoleDesign(false); - KKdMain.ConsoleDesign("1. A3DA Converter"); - KKdMain.ConsoleDesign("2. AET Converter"); - KKdMain.ConsoleDesign("3. DataBank Converter"); - KKdMain.ConsoleDesign("4. DEX Converter"); - KKdMain.ConsoleDesign("5. DIVA Converter"); - KKdMain.ConsoleDesign("6. STR Converter"); - KKdMain.ConsoleDesign("7. VAG Converter"); + KKdMain.ConsoleDesign("1. A3DA" ); + KKdMain.ConsoleDesign("2. AET" ); + KKdMain.ConsoleDesign("3. DataBank"); + KKdMain.ConsoleDesign("4. DEX" ); + KKdMain.ConsoleDesign("5. DIVA" ); + KKdMain.ConsoleDesign("6. MOT" ); + KKdMain.ConsoleDesign("7. STR" ); KKdMain.ConsoleDesign(false); KKdMain.ConsoleDesign("R. Return to Main Menu"); KKdMain.ConsoleDesign(false); @@ -104,17 +114,56 @@ namespace PD_Tool else if (Function == "3") Tools.DB .Processor(JSON); else if (Function == "4") Tools.DEX.Processor(JSON); else if (Function == "5") Tools.DIV.Processor(); - else if (Function == "6") Tools.STR.Processor(JSON); - else if (Function == "7") Tools.VAG.Processor(); + else if (Function == "6") Tools.MOT.Processor(JSON); + else if (Function == "7") Tools.STR.Processor(JSON); else function = Function; } else if (function == "7") + { + Console.Clear(); + Console.Title = "F/F2/X/FT Converting Tools"; + KKdMain.ConsoleDesign(true); + KKdMain.ConsoleDesign(" Choose converter:"); + KKdMain.ConsoleDesign(false); + KKdMain.ConsoleDesign("1. A3DA" ); + KKdMain.ConsoleDesign("2. Bloom" ); + KKdMain.ConsoleDesign("3. Color Correction"); + KKdMain.ConsoleDesign("4. DEX" ); + KKdMain.ConsoleDesign("5. DOF" ); + KKdMain.ConsoleDesign("6. Light" ); + KKdMain.ConsoleDesign("7. STR" ); + KKdMain.ConsoleDesign("8. VAG" ); + KKdMain.ConsoleDesign(false); + KKdMain.ConsoleDesign("R. Return to Main Menu"); + KKdMain.ConsoleDesign(false); + KKdMain.ConsoleDesign(true); + Console.WriteLine(); + string Function = Console.ReadLine(); + Console.Clear(); + if (Function == "1") Tools.A3D.Processor(JSON); + else if (Function == "2") Tools.BLT.Processor(); + else if (Function == "3") Tools.CCT.Processor(); + else if (Function == "4") Tools.DEX.Processor(JSON); + else if (Function == "5") Tools.DFT.Processor(); + else if (Function == "6") Tools.LIT.Processor(); + else if (Function == "7") Tools.STR.Processor(JSON); + else if (Function == "8") Tools.VAG.Processor(); + else function = Function; + } + else if (function == "8") { KKdMain.Choose(1, JSON ? "mp" : "json", out string[] FileNames); - if (JSON) foreach (string file in FileNames) - KKdMainLib.MPExt.ToJSON (file.Replace(Path.GetExtension(file), "")); - else foreach (string file in FileNames) - KKdMainLib.MPExt.ToMsgPack(file.Replace(Path.GetExtension(file), "")); + foreach (string file in FileNames) + if (JSON) + { + Console.Title = "MsgPack to JSON: " + Path.GetFileNameWithoutExtension(file); + MPExt.ToJSON (file.Replace(Path.GetExtension(file), "")); + } + else + { + Console.Title = "JSON to MsgPack: " + Path.GetFileNameWithoutExtension(file); + MPExt.ToMsgPack(file.Replace(Path.GetExtension(file), "")); + } } } diff --git a/PD_Tool/Properties/AssemblyInfo.cs b/PD_Tool/Properties/AssemblyInfo.cs index ea2ff75..784a998 100644 --- a/PD_Tool/Properties/AssemblyInfo.cs +++ b/PD_Tool/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ using System.Runtime.InteropServices; [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")] -[assembly: AssemblyVersion("0.4.7.1")] -[assembly: AssemblyFileVersion("0.4.7.1")] +[assembly: AssemblyVersion("0.4.7.2")] +[assembly: AssemblyFileVersion("0.4.7.2")] diff --git a/PD_Tool/classes/Tools/BLT.cs b/PD_Tool/classes/Tools/BLT.cs new file mode 100644 index 0000000..ce7cf7b --- /dev/null +++ b/PD_Tool/classes/Tools/BLT.cs @@ -0,0 +1,33 @@ +using System; +using KKdMainLib; +using KKdMainLib.IO; +using KKdMainLib.F2; + +namespace PD_Tool.Tools +{ + public class BLT + { + public static void Processor() + { + Console.Title = "Bloom Converter"; + Bloom Bloom; + Main.Choose(1, "blt", out string[] FileNames); + if (FileNames.Length < 1) return; + string filepath = ""; + string ext = ""; + + foreach (string file in FileNames) + { + Bloom = new Bloom(); + ext = Path.GetExtension(file); + filepath = file.Replace(ext, ""); + ext = ext.ToLower(); + + Console.Title = "Bloom Converter: " + Path.GetFileNameWithoutExtension(file); + if (ext == ".blt") { Bloom.BLTReader(filepath); Bloom.TXTWriter(filepath); } + //else if (ext == ".txt") { Bloom.TXTReader(filepath); Bloom.BLTWriter(filepath); } + Bloom = new Bloom(); + } + } + } +} diff --git a/PD_Tool/classes/Tools/CCT.cs b/PD_Tool/classes/Tools/CCT.cs new file mode 100644 index 0000000..09529fb --- /dev/null +++ b/PD_Tool/classes/Tools/CCT.cs @@ -0,0 +1,33 @@ +using System; +using KKdMainLib; +using KKdMainLib.IO; +using KKdMainLib.F2; + +namespace PD_Tool.Tools +{ + public class CCT + { + public static void Processor() + { + Console.Title = "Color Correction Converter"; + ColorCorrection ColorCorrection; + Main.Choose(1, "cct", out string[] FileNames); + if (FileNames.Length < 1) return; + string filepath = ""; + string ext = ""; + + foreach (string file in FileNames) + { + ColorCorrection = new ColorCorrection(); + ext = Path.GetExtension(file); + filepath = file.Replace(ext, ""); + ext = ext.ToLower(); + + Console.Title = "Color Correction Converter: " + Path.GetFileNameWithoutExtension(file); + if (ext == ".cct") { ColorCorrection.CCTReader(filepath); ColorCorrection.TXTWriter(filepath); } + //else if (ext == ".txt") { ColorCorrection.TXTReader(filepath); ColorCorrection.BLTWriter(filepath); } + ColorCorrection = new ColorCorrection(); + } + } + } +} diff --git a/PD_Tool/classes/Tools/DEX.cs b/PD_Tool/classes/Tools/DEX.cs index 6db7442..96863d0 100644 --- a/PD_Tool/classes/Tools/DEX.cs +++ b/PD_Tool/classes/Tools/DEX.cs @@ -31,7 +31,7 @@ namespace PD_Tool.Tools Main.ConsoleDesign(" Choose type of exporting file:"); Main.ConsoleDesign(false); Main.ConsoleDesign("1. F/FT PS3/PS4/PSVita"); - Main.ConsoleDesign("2. F2nd PS3/PSVita"); + Main.ConsoleDesign("2. F2 PS3/PSVita"); Main.ConsoleDesign("3. X PS4/PSVita"); if ( MP && !JSON) Main.ConsoleDesign("9. MessagePack"); if (_JSON && JSON) Main.ConsoleDesign("9. JSON"); @@ -47,6 +47,7 @@ namespace PD_Tool.Tools else if (format == "9" && (MP && _JSON)) Format = Format.NULL; else return; + int state; foreach (string file in FileNames) { DEX = new KKdDEX(); @@ -56,12 +57,15 @@ namespace PD_Tool.Tools Console.Title = "DEX Converter: " + Path.GetFileNameWithoutExtension(file); if (ext == ".bin" || ext == ".dex") - DEX. DEXReader(filepath, ext ); - else DEX.MsgPackReader(filepath, JSON); + state = DEX. DEXReader(filepath, ext ); + else state = DEX.MsgPackReader(filepath, JSON); - if (Format > Format.NULL) - DEX. DEXWriter(filepath, Format); - else DEX.MsgPackWriter(filepath, JSON ); + if (state == 1) + { + if (Format > Format.NULL) + DEX. DEXWriter(filepath, Format); + else DEX.MsgPackWriter(filepath, JSON); + } DEX = null; } } diff --git a/PD_Tool/classes/Tools/DFT.cs b/PD_Tool/classes/Tools/DFT.cs new file mode 100644 index 0000000..4d44278 --- /dev/null +++ b/PD_Tool/classes/Tools/DFT.cs @@ -0,0 +1,33 @@ +using System; +using KKdMainLib; +using KKdMainLib.IO; +using KKdMainLib.F2; + +namespace PD_Tool.Tools +{ + public class DFT + { + public static void Processor() + { + Console.Title = "DOF Converter"; + DOF DOF; + Main.Choose(1, "dft", out string[] FileNames); + if (FileNames.Length < 1) return; + string filepath = ""; + string ext = ""; + + foreach (string file in FileNames) + { + DOF = new DOF(); + ext = Path.GetExtension(file); + filepath = file.Replace(ext, ""); + ext = ext.ToLower(); + + Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file); + if (ext == ".dft") { DOF.DFTReader(filepath); DOF.TXTWriter(filepath); } + //else if (ext == ".txt") { DOF.TXTReader(filepath); DOF.DFTWriter(filepath); } + DOF = new DOF(); + } + } + } +} diff --git a/PD_Tool/classes/Tools/LIT.cs b/PD_Tool/classes/Tools/LIT.cs new file mode 100644 index 0000000..f9dea83 --- /dev/null +++ b/PD_Tool/classes/Tools/LIT.cs @@ -0,0 +1,33 @@ +using System; +using KKdMainLib; +using KKdMainLib.IO; +using KKdMainLib.F2; + +namespace PD_Tool.Tools +{ + public class LIT + { + public static void Processor() + { + Console.Title = "Light Converter"; + Light LIT; + Main.Choose(1, "lit", out string[] FileNames); + if (FileNames.Length < 1) return; + string filepath = ""; + string ext = ""; + + foreach (string file in FileNames) + { + LIT = new Light(); + ext = Path.GetExtension(file); + filepath = file.Replace(ext, ""); + ext = ext.ToLower(); + + Console.Title = "Light Converter: " + Path.GetFileNameWithoutExtension(file); + if (ext == ".lit") { LIT.LITReader(filepath); LIT.TXTWriter(filepath); } + //else if (ext == ".txt") { LIT.TXTReader(filepath); LIT.LITWriter(filepath); } + LIT = new Light(); + } + } + } +} diff --git a/PD_Tool/classes/Tools/MOT.cs b/PD_Tool/classes/Tools/MOT.cs new file mode 100644 index 0000000..8383c4b --- /dev/null +++ b/PD_Tool/classes/Tools/MOT.cs @@ -0,0 +1,40 @@ +using System; +using KKdMainLib; +using KKdMainLib.IO; + +namespace PD_Tool.Tools +{ + public class MOT + { + public static void Processor(bool JSON) + { + Console.Title = "MOT Converter"; + Mot Mot; + Main.Choose(1, "bin", out string[] FileNames); + if (FileNames.Length < 1) return; + string filepath = ""; + string ext = ""; + + foreach (string file in FileNames) + { + Mot = new Mot(); + ext = Path.GetExtension(file); + filepath = file.Replace(ext, ""); + ext = ext.ToLower(); + + Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file); + if (ext == ".bin") + { + Mot. MOTReader(filepath); + Mot.MsgPackWriter(filepath, JSON); + } + else if (ext == ".mp" || ext == ".json") + { + Mot.MsgPackReader(filepath, ext == ".json"); + Mot. MOTWriter(filepath); + } + Mot = new Mot(); + } + } + } +}