Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df0cb255fc | ||
|
|
89c9afd0c5 | ||
|
|
cd2eab5b8e | ||
|
|
8dd10b2fa4 | ||
|
|
35dee99307 | ||
|
|
b49b86887e | ||
|
|
a0a3737b47 | ||
|
|
9c86616dcd | ||
|
|
e2990dccaf | ||
|
|
e75c7e6742 | ||
|
|
5ace6bc0e0 |
+25
-1
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib.Auth3D;
|
||||
using KKdBaseLib.Auth3D;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -22,5 +22,29 @@ namespace KKdBaseLib
|
||||
public long DataOffset; //Used only in-game and points to KFT3 Array
|
||||
|
||||
public KFT3[] Keys;
|
||||
|
||||
public A3DAKey(Key k)
|
||||
{
|
||||
Type = 0; Value = MaxFrames = FrameDelta = ValueDelta = 0; EPTypePre = EPTypePost = 0;
|
||||
Unk1C = Unk20 = Unk24 = Unk28 = Unk2C = Unk30 = Unk34 = 0;
|
||||
Length = DataOffset = 0; Keys = null;
|
||||
|
||||
EPTypePost = k.EPTypePost;
|
||||
EPTypePre = k.EPTypePre;
|
||||
MaxFrames = k.Max ?? 0;
|
||||
if (k.Type > KeyType.Value && k.Length > 1)
|
||||
{
|
||||
Type = k.Type;
|
||||
Length = k.Length;
|
||||
Keys = k.Keys;
|
||||
FrameDelta = k.Keys[k.Length - 1].F - k.Keys[0].F;
|
||||
ValueDelta = k.Keys[k.Length - 1].V - k.Keys[0].V;
|
||||
}
|
||||
else
|
||||
{
|
||||
Type = k.Type;
|
||||
Value = k.Type > 0 ? k.Value : 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public class HeadData : System.Attribute { }
|
||||
public class Padding : System.Attribute { }
|
||||
public class Binary : System.Attribute { }
|
||||
public class Offset : System.Attribute { }
|
||||
public class Count : System.Attribute { }
|
||||
public class Flags : System.Attribute { }
|
||||
}
|
||||
+52
-15
@@ -1,4 +1,6 @@
|
||||
namespace KKdBaseLib.Auth2D
|
||||
//Original: AetSet.bt Version: 5.0 by samyuu
|
||||
|
||||
namespace KKdBaseLib.Auth2D
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
@@ -14,10 +16,10 @@
|
||||
public uint BackColor;
|
||||
public uint Width;
|
||||
public uint Height;
|
||||
public Pointer<Vector2<CountPointer<KFT2>>> Camera;
|
||||
public CountPointer<Composition> Compositions;
|
||||
public CountPointer<Video > Videos;
|
||||
public CountPointer<Audio > Audios;
|
||||
public Pointer<Vec2<CountPointer<KFT2>>> Camera;
|
||||
public CountPointer<Composition> Composition;
|
||||
public CountPointer<Video > Video;
|
||||
public CountPointer<Audio > Audio;
|
||||
}
|
||||
|
||||
public struct Composition
|
||||
@@ -45,9 +47,9 @@
|
||||
public AetLayerFlags Flags;
|
||||
public AetLayerQuality Quality;
|
||||
public AetLayerType Type;
|
||||
public int VideoItemOffset;
|
||||
public int VidItmOff; //VideoItemOffset
|
||||
public int ParentLayer;
|
||||
public CountPointer<Marker> Markers;
|
||||
public CountPointer<Marker> Marker;
|
||||
public Pointer<VideoData> Video;
|
||||
public Pointer<AudioData> Audio;
|
||||
|
||||
@@ -122,11 +124,46 @@
|
||||
|
||||
public enum TransferBlendMode : byte
|
||||
{
|
||||
Alpha = 3,
|
||||
Additive = 5,
|
||||
DstColorZero = 6,
|
||||
SrcAlphaOneMinusSrcColor = 7,
|
||||
Transparent = 8,
|
||||
None = 0,
|
||||
Copy = 1,
|
||||
Behind = 2,
|
||||
Normal = 3,
|
||||
Dissolve = 4,
|
||||
Add = 5,
|
||||
Multiply = 6,
|
||||
Screen = 7,
|
||||
Overlay = 8,
|
||||
SoftLight = 9,
|
||||
HardLight = 10,
|
||||
Darken = 11,
|
||||
Lighten = 12,
|
||||
ClassicDifference = 13,
|
||||
Hue = 14,
|
||||
Saturation = 15,
|
||||
Color = 16,
|
||||
Luminosity = 17,
|
||||
StenciilAlpha = 18,
|
||||
StencilLuma = 19,
|
||||
SilhouetteAlpha = 20,
|
||||
SilhouetteLuma = 21,
|
||||
LuminescentPremul = 22,
|
||||
AlphaAdd = 23,
|
||||
ClassicColorDodge = 24,
|
||||
ClassicColorBurn = 25,
|
||||
Exclusion = 26,
|
||||
Difference = 27,
|
||||
ColorDodge = 28,
|
||||
ColorBurn = 29,
|
||||
LinearDodge = 30,
|
||||
LinearBurn = 31,
|
||||
LinearLight = 32,
|
||||
VividLight = 33,
|
||||
PinLight = 34,
|
||||
HardMix = 35,
|
||||
LighterColor = 36,
|
||||
DarkerColor = 37,
|
||||
Subtract = 38,
|
||||
Divide = 39,
|
||||
}
|
||||
|
||||
public enum TransferFlags : byte
|
||||
@@ -173,11 +210,11 @@
|
||||
public ushort Width;
|
||||
public ushort Height;
|
||||
public float Frames;
|
||||
public CountPointer<Source> Sources;
|
||||
public CountPointer<Identifier> Identifiers;
|
||||
|
||||
public override string ToString() => $"Width: {Width}; Height: {Height}; Color: {Color.ToString("X2")}";
|
||||
public override string ToString() => $"Width: {Width}; Height: {Height}; Color: {Color:X2)}";
|
||||
|
||||
public struct Source
|
||||
public struct Identifier
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public uint ID;
|
||||
|
||||
+59
-86
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.Auth3D
|
||||
namespace KKdBaseLib.Auth3D
|
||||
{
|
||||
public struct Data
|
||||
{
|
||||
@@ -36,17 +36,17 @@
|
||||
public struct Ambient
|
||||
{
|
||||
public string Name;
|
||||
public Vector4<Key> LightDiffuse;
|
||||
public Vector4<Key> RimLightDiffuse;
|
||||
public Vec4<Key>? LightDiffuse;
|
||||
public Vec4<Key>? RimLightDiffuse;
|
||||
}
|
||||
|
||||
public struct CameraAuxiliary
|
||||
{
|
||||
public Key Gamma;
|
||||
public Key Exposure;
|
||||
public Key Saturate;
|
||||
public Key GammaRate;
|
||||
public Key AutoExposure;
|
||||
public Key? Gamma;
|
||||
public Key? Exposure;
|
||||
public Key? Saturate;
|
||||
public Key? GammaRate;
|
||||
public Key? AutoExposure;
|
||||
}
|
||||
|
||||
public struct CameraRoot
|
||||
@@ -99,7 +99,7 @@
|
||||
public Key End;
|
||||
public Key Start;
|
||||
public Key Density;
|
||||
public Vector4<Key> Diffuse;
|
||||
public Vec4<Key>? Diffuse;
|
||||
}
|
||||
|
||||
public enum CompressF16 : int
|
||||
@@ -127,16 +127,41 @@
|
||||
|
||||
public struct Key
|
||||
{
|
||||
public KeyType? Type;
|
||||
public KeyType Type;
|
||||
public int Length;
|
||||
public int? BinOffset;
|
||||
public EPType EPTypePre;
|
||||
public EPType EPTypePost;
|
||||
public float? Max;
|
||||
public float? Value;
|
||||
public float Value;
|
||||
public RawD RawData;
|
||||
public KFT3[] Keys;
|
||||
|
||||
public Key(A3DAKey k)
|
||||
{
|
||||
Type = 0;
|
||||
Value = 0;
|
||||
Length = 0;
|
||||
BinOffset = null;
|
||||
RawData = default;
|
||||
Keys = null;
|
||||
|
||||
EPTypePost = k.EPTypePost;
|
||||
EPTypePre = k.EPTypePre;
|
||||
Max = k.MaxFrames;
|
||||
if (k.Length > 1)
|
||||
{
|
||||
Type = k.Type;
|
||||
Length = (int)k.Length;
|
||||
Keys = k.Keys;
|
||||
}
|
||||
else if (k.Length == 1)
|
||||
{
|
||||
Type = KeyType.Value;
|
||||
Value = k.Keys[0].V;
|
||||
}
|
||||
}
|
||||
|
||||
public struct RawD
|
||||
{
|
||||
public int KeyType;
|
||||
@@ -144,58 +169,6 @@
|
||||
public string ValueType;
|
||||
public string[] ValueList;
|
||||
}
|
||||
|
||||
public static Vector3<A3DAKey> ToA3DAKey(Vector3< Key> k) =>
|
||||
new Vector3<A3DAKey> { X = (A3DAKey)k.X, Y = (A3DAKey)k.Y, Z = (A3DAKey)k.Z };
|
||||
public static Vector3< Key> ToKey (Vector3<A3DAKey> k) =>
|
||||
new Vector3< Key> { X = ( Key)k.X, Y = ( Key)k.Y, Z = ( Key)k.Z };
|
||||
|
||||
public static explicit operator Key(A3DAKey k)
|
||||
{
|
||||
Key key = default;
|
||||
key.EPTypePost = k.EPTypePost;
|
||||
key.EPTypePre = k.EPTypePre;
|
||||
key.Max = k.MaxFrames;
|
||||
if (k.Length > 1)
|
||||
{
|
||||
key.Type = k.Type;
|
||||
key.Length = (int)k.Length;
|
||||
key.Keys = k.Keys;
|
||||
}
|
||||
else if (k.Length == 1)
|
||||
{
|
||||
key.Type = KeyType.Value;
|
||||
key.Value = k.Keys[0].V;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public static explicit operator A3DAKey(Key k)
|
||||
{
|
||||
A3DAKey key = default;
|
||||
key.EPTypePost = k.EPTypePost;
|
||||
key.EPTypePre = k.EPTypePre;
|
||||
key.MaxFrames = k.Max ?? 0;
|
||||
if (k.Type != null && k.Length > 1)
|
||||
{
|
||||
key.Type = k.Type.Value;
|
||||
key.Length = k.Length;
|
||||
key.Keys = k.Keys;
|
||||
key.FrameDelta = k.Keys[k.Length - 1].F - k.Keys[0].F;
|
||||
key.ValueDelta = k.Keys[k.Length - 1].V - k.Keys[0].V;
|
||||
}
|
||||
else
|
||||
{
|
||||
key.Type = 0;
|
||||
key.Value = 0.0f;
|
||||
if (k.Type.HasValue && k.Value.HasValue)
|
||||
{
|
||||
key.Type = k.Type.Value;
|
||||
key.Value = k.Value.Value;
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
public struct Light
|
||||
@@ -203,10 +176,10 @@
|
||||
public int? Id;
|
||||
public string Name;
|
||||
public string Type;
|
||||
public Vector4<Key> Ambient;
|
||||
public Vector4<Key> Diffuse;
|
||||
public Vector4<Key> Specular;
|
||||
public Vector4<Key> Incandescence;
|
||||
public Vec4<Key>? Ambient;
|
||||
public Vec4<Key>? Diffuse;
|
||||
public Vec4<Key>? Specular;
|
||||
public Vec4<Key>? Incandescence;
|
||||
public ModelTransform Position;
|
||||
public ModelTransform SpotDirection;
|
||||
}
|
||||
@@ -216,15 +189,15 @@
|
||||
public string Name;
|
||||
public string HashName;
|
||||
public Key GlowIntensity;
|
||||
public Vector4<Key> BlendColor;
|
||||
public Vector4<Key> Incandescence;
|
||||
public Vec4<Key>? BlendColor;
|
||||
public Vec4<Key>? Incandescence;
|
||||
}
|
||||
|
||||
public struct MObjectHRC
|
||||
{
|
||||
public string Name;
|
||||
public Node[] Node;
|
||||
public Vector3<float?> JointOrient;
|
||||
public Vec3<float?> JointOrient;
|
||||
public Instance[] Instances;
|
||||
public ModelTransform MT;
|
||||
|
||||
@@ -242,9 +215,9 @@
|
||||
public bool Writed;
|
||||
public int? BinOffset;
|
||||
public Key Visibility;
|
||||
public Vector3<Key> Rot;
|
||||
public Vector3<Key> Scale;
|
||||
public Vector3<Key> Trans;
|
||||
public Vec3<Key> Rot;
|
||||
public Vec3<Key> Scale;
|
||||
public Vec3<Key> Trans;
|
||||
}
|
||||
|
||||
public struct Node
|
||||
@@ -275,12 +248,12 @@
|
||||
public struct TextureTransform
|
||||
{
|
||||
public string Name;
|
||||
public Key Rotate;
|
||||
public Key RotateFrame;
|
||||
public Vector2<Key> Offset;
|
||||
public Vector2<Key> Repeat;
|
||||
public Vector2<Key> Coverage;
|
||||
public Vector2<Key> TranslateFrame;
|
||||
public Key? Rotate;
|
||||
public Key? RotateFrame;
|
||||
public Vec2<Key?> Offset;
|
||||
public Vec2<Key?> Repeat;
|
||||
public Vec2<Key?> Coverage;
|
||||
public Vec2<Key?> TranslateFrame;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +263,7 @@
|
||||
public string Name;
|
||||
public string UIDName;
|
||||
public Node[] Node;
|
||||
public Vector3<float?> JointOrient;
|
||||
public Vec3<float?> JointOrient;
|
||||
}
|
||||
|
||||
public struct PlayControl
|
||||
@@ -304,11 +277,11 @@
|
||||
|
||||
public struct PostProcess
|
||||
{
|
||||
public Key LensFlare;
|
||||
public Key LensGhost;
|
||||
public Key LensShaft;
|
||||
public Vector4<Key> Ambient;
|
||||
public Vector4<Key> Diffuse;
|
||||
public Vector4<Key> Specular;
|
||||
public Key? LensFlare;
|
||||
public Key? LensGhost;
|
||||
public Key? LensShaft;
|
||||
public Vec4<Key>? Ambient;
|
||||
public Vec4<Key>? Diffuse;
|
||||
public Vec4<Key>? Specular;
|
||||
}
|
||||
}
|
||||
|
||||
+28
-19
@@ -1,4 +1,4 @@
|
||||
//Original research by Samyuu
|
||||
//Original research by Samyuu
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -39,50 +39,59 @@ namespace KKdBaseLib
|
||||
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0,
|
||||
};
|
||||
|
||||
public static ushort CalculateChecksum(this byte[] data)
|
||||
public static ushort CalculateChecksum(byte[] data,
|
||||
int offset = 0, ushort seed = 0xFFFF)
|
||||
{
|
||||
ushort result = 0xFFFF;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
int length = data.Length;
|
||||
ushort result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static uint CalculateChecksumUInt(this byte[] data)
|
||||
public static uint CalculateChecksumU32(byte[] data,
|
||||
int offset = 0, uint seed = 0xFFFFFFFF)
|
||||
{
|
||||
uint result = 0xFFFFFFFF;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
int length = data.Length;
|
||||
uint result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ulong CalculateChecksumULong(this byte[] data)
|
||||
public static ulong CalculateChecksumU64(byte[] data,
|
||||
int offset = 0, ulong seed = 0xFFFFFFFFFFFFFFFF)
|
||||
{
|
||||
ulong result = 0xFFFFFFFFFFFFFFFF;
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
int length = data.Length;
|
||||
ulong result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static unsafe ushort CalculateChecksum(byte* data, int length)
|
||||
public static unsafe ushort CalculateChecksum(byte* data,
|
||||
int length, int offset = 0, ushort seed = 0xFFFF)
|
||||
{
|
||||
ushort result = 0xFFFF;
|
||||
for (int i = 0; i < length; i++)
|
||||
ushort result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = (ushort)(ChecksumLookupTable[(result >> 8) ^ data[i]] ^ (result << 8));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static unsafe uint CalculateChecksumUInt(byte* data, int length)
|
||||
public static unsafe uint CalculateChecksumU32(byte* data,
|
||||
int length, int offset = 0, uint seed = 0xFFFFFFFF)
|
||||
{
|
||||
uint result = 0xFFFFFFFF;
|
||||
for (int i = 0; i < length; i++)
|
||||
uint result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static unsafe ulong CalculateChecksumULong(byte* data, int length)
|
||||
public static unsafe ulong CalculateChecksumU64(byte* data,
|
||||
int length, int offset = 0, ulong seed = 0xFFFFFFFFFFFFFFFF)
|
||||
{
|
||||
ulong result = 0xFFFFFFFFFFFFFFFF;
|
||||
for (int i = 0; i < length; i++)
|
||||
ulong result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
+120
-47
@@ -1,17 +1,13 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static unsafe class Extensions
|
||||
{
|
||||
private const double RadPi = 180 / Math.PI;
|
||||
public static double ToDegrees(this double val) => val * RadPi;
|
||||
public static double ToRadians(this double val) => val / RadPi;
|
||||
|
||||
public static double Acos (this double d ) => Math.Acos (d );
|
||||
public static double Asin (this double d ) => Math.Asin (d );
|
||||
public static double Atan (this double d ) => Math.Atan (d );
|
||||
public static double Aсtg (this double d ) => 1 / Math.Atan (d );
|
||||
public static double Actg (this double d ) => 1 / Math.Atan (d );
|
||||
public static double Cos (this double d ) => Math.Cos (d );
|
||||
public static double Cosh (this double val) => Math.Cosh (val);
|
||||
public static double Sin (this double a ) => Math.Sin (a );
|
||||
@@ -30,7 +26,6 @@ namespace KKdBaseLib
|
||||
public static int Sign (this double val) => Math.Sign (val);
|
||||
public static double Sqrt (this double d ) => Math.Sqrt (d );
|
||||
|
||||
|
||||
public static double Atan2(this double y , double x ) => Math.Atan2(y , x );
|
||||
public static double Log (this double val , double newBase) => Math.Log (val , newBase);
|
||||
public static double Max (this double val1, double val2 ) => Math.Max (val1, val2 );
|
||||
@@ -38,13 +33,10 @@ namespace KKdBaseLib
|
||||
public static double Pow (this double x , double y ) => Math.Pow (x , y );
|
||||
public static double Round(this double val , int d ) => Math.Round(val , d );
|
||||
|
||||
public static float ToDegrees(this float val) => (float)(val * RadPi);
|
||||
public static float ToRadians(this float val) => (float)(val / RadPi);
|
||||
|
||||
public static float Acos (this float d ) => (float) Math.Acos (d ) ;
|
||||
public static float Asin (this float d ) => (float) Math.Asin (d ) ;
|
||||
public static float Atan (this float d ) => (float) Math.Atan (d ) ;
|
||||
public static float Aсtg (this float d ) => (float)(1 / Math.Atan (d ));
|
||||
public static float Actg (this float d ) => (float)(1 / Math.Atan (d ));
|
||||
public static float Cos (this float d ) => (float) Math.Cos (d ) ;
|
||||
public static float Cosh (this float val) => (float) Math.Cosh (val) ;
|
||||
public static float Sin (this float a ) => (float) Math.Sin (a ) ;
|
||||
@@ -62,7 +54,6 @@ namespace KKdBaseLib
|
||||
public static float Round (this float d ) => (float) Math.Round (d ) ;
|
||||
public static float Sqrt (this float d ) => (float) Math.Sqrt (d ) ;
|
||||
|
||||
|
||||
public static float Atan2(this float y , float x ) => (float)Math.Atan2(y , x );
|
||||
public static float Log (this float val , float newBase) => (float)Math.Log (val , newBase);
|
||||
public static float Max (this float val1, float val2 ) => Math.Max (val1, val2 );
|
||||
@@ -96,10 +87,29 @@ namespace KKdBaseLib
|
||||
public static byte[] E(this byte[] le, byte len, bool isBE)
|
||||
{ if (isBE) { for (byte i = 0; i < len; i++) buf[i] = le[i];
|
||||
for (byte i = 0; i < len; i++) le[len - i - 1] = buf[i]; } return le; }
|
||||
|
||||
public static short E(this short le)
|
||||
{ for (byte i = 0; i < 2; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 2; i++) { le = (short)((int)le | buf[i]); if (i < 1) le <<= 8; } return le; }
|
||||
public static ushort E(this ushort le)
|
||||
{ for (byte i = 0; i < 2; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 2; i++) { le |= buf[i]; if (i < 1) le <<= 8; } return le; }
|
||||
public static int E(this int le)
|
||||
{ for (byte i = 0; i < 4; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 4; i++) { le |= buf[i]; if (i < 3) le <<= 8; } return le; }
|
||||
public static uint E(this uint le)
|
||||
{ for (byte i = 0; i < 4; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 4; i++) { le |= buf[i]; if (i < 3) le <<= 8; } return le; }
|
||||
public static long E(this long le)
|
||||
{ for (byte i = 0; i < 8; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 8; i++) { le |= buf[i]; if (i < 7) le <<= 8; } return le; }
|
||||
public static ulong E(this ulong le)
|
||||
{ for (byte i = 0; i < 8; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 8; i++) { le |= buf[i]; if (i < 7) le <<= 8; } return le; }
|
||||
|
||||
public static short E(this short le, bool isBE)
|
||||
{ if (isBE) { for (byte i = 0; i < 2; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 2; i++) { le = (short)((int)le |
|
||||
buf[i]); if (i < 1) le <<= 8; } } return le; }
|
||||
for (byte i = 0; i < 2; i++) { le = (short)((int)le | buf[i]); if (i < 1) le <<= 8; } } return le; }
|
||||
public static ushort E(this ushort le, bool isBE)
|
||||
{ if (isBE) { for (byte i = 0; i < 2; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 2; i++) { le |= buf[i]; if (i < 1) le <<= 8; } } return le; }
|
||||
@@ -116,39 +126,65 @@ namespace KKdBaseLib
|
||||
{ if (isBE) { for (byte i = 0; i < 8; i++) { buf[i] = (byte)le; le >>= 8; } le = 0;
|
||||
for (byte i = 0; i < 8; i++) { le |= buf[i]; if (i < 7) le <<= 8; } } return le; }
|
||||
|
||||
public static short TI16(this byte[] arr)
|
||||
{ short val; fixed (byte* ptr = arr) val = *( short*)ptr; return val; }
|
||||
public static ushort TU16(this byte[] arr)
|
||||
{ ushort val; fixed (byte* ptr = arr) val = *(ushort*)ptr; return val; }
|
||||
public static int TI32(this byte[] arr)
|
||||
{ int val; fixed (byte* ptr = arr) val = *( int*)ptr; return val; }
|
||||
public static uint TU32(this byte[] arr)
|
||||
{ uint val; fixed (byte* ptr = arr) val = *( uint*)ptr; return val; }
|
||||
public static long TI64(this byte[] arr)
|
||||
{ long val; fixed (byte* ptr = arr) val = *( long*)ptr; return val; }
|
||||
public static ulong TU64(this byte[] arr)
|
||||
{ ulong val; fixed (byte* ptr = arr) val = *( ulong*)ptr; return val; }
|
||||
public static float TF32(this byte[] arr)
|
||||
{ float val; fixed (byte* ptr = arr) val = *( float*)ptr; return val; }
|
||||
public static double TF64(this byte[] arr)
|
||||
{ double val; fixed (byte* ptr = arr) val = *(double*)ptr; return val; }
|
||||
public static short TI16(this byte[] arr, int offset = 0)
|
||||
{ short val; fixed (byte* ptr = arr) val = *( short*)(ptr + offset); return val; }
|
||||
public static ushort TU16(this byte[] arr, int offset = 0)
|
||||
{ ushort val; fixed (byte* ptr = arr) val = *(ushort*)(ptr + offset); return val; }
|
||||
public static int TI24(this byte[] arr, int offset = 0)
|
||||
{ int val; fixed (byte* ptr = arr) val = (*(ushort*)(ptr + offset))
|
||||
| ((( short)*(sbyte*)(ptr + offset + 2)) << 16); return val; }
|
||||
public static uint TU24(this byte[] arr, int offset = 0)
|
||||
{ uint val; fixed (byte* ptr = arr) val = (*(ushort*)(ptr + offset))
|
||||
| ((( uint)*( byte*)(ptr + offset + 2)) << 16); return val; }
|
||||
public static int TI32(this byte[] arr, int offset = 0)
|
||||
{ int val; fixed (byte* ptr = arr) val = *( int*)(ptr + offset); return val; }
|
||||
public static uint TU32(this byte[] arr, int offset = 0)
|
||||
{ uint val; fixed (byte* ptr = arr) val = *( uint*)(ptr + offset); return val; }
|
||||
public static long TI64(this byte[] arr, int offset = 0)
|
||||
{ long val; fixed (byte* ptr = arr) val = *( long*)(ptr + offset); return val; }
|
||||
public static ulong TU64(this byte[] arr, int offset = 0)
|
||||
{ ulong val; fixed (byte* ptr = arr) val = *( ulong*)(ptr + offset); return val; }
|
||||
public static Half TF16(this byte[] arr, int offset = 0)
|
||||
{ Half val; fixed (byte* ptr = arr) val = *( Half*)(ptr + offset); return val; }
|
||||
public static float TF32(this byte[] arr, int offset = 0)
|
||||
{ float val; fixed (byte* ptr = arr) val = *( float*)(ptr + offset); return val; }
|
||||
public static double TF64(this byte[] arr, int offset = 0)
|
||||
{ double val; fixed (byte* ptr = arr) val = *(double*)(ptr + offset); return val; }
|
||||
public static Vec2 TV2 (this byte[] arr, int offset = 0)
|
||||
{ Vec2 val; fixed (byte* ptr = arr) val = *( Vec2*)(ptr + offset); return val; }
|
||||
public static Vec3 TV3 (this byte[] arr, int offset = 0)
|
||||
{ Vec3 val; fixed (byte* ptr = arr) val = *( Vec3*)(ptr + offset); return val; }
|
||||
public static Vec4 TV4 (this byte[] arr, int offset = 0)
|
||||
{ Vec4 val; fixed (byte* ptr = arr) val = *( Vec4*)(ptr + offset); return val; }
|
||||
public static Quat TQ (this byte[] arr, int offset = 0)
|
||||
{ Quat val; fixed (byte* ptr = arr) val = *( Quat*)(ptr + offset); return val; }
|
||||
|
||||
public static void GBy(this byte[] arr, short val)
|
||||
{ fixed (byte* ptr = arr) *( short*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, ushort val)
|
||||
{ fixed (byte* ptr = arr) *(ushort*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, int val)
|
||||
{ fixed (byte* ptr = arr) *( int*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, uint val)
|
||||
{ fixed (byte* ptr = arr) *( uint*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, long val)
|
||||
{ fixed (byte* ptr = arr) *( long*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, ulong val)
|
||||
{ fixed (byte* ptr = arr) *( ulong*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, float val)
|
||||
{ fixed (byte* ptr = arr) *( float*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, double val)
|
||||
{ fixed (byte* ptr = arr) *(double*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, short val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( short*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, ushort val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *(ushort*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, int val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( int*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, uint val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( uint*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, long val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( long*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, ulong val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( ulong*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, Half val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( Half*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, float val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( float*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, double val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *(double*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, Vec2 val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( Vec2*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, Vec3 val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( Vec3*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, Vec4 val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( Vec4*)(ptr + offset) = val; }
|
||||
public static void GBy(this byte[] arr, Quat val, int offset = 0)
|
||||
{ fixed (byte* ptr = arr) *( Quat*)(ptr + offset) = val; }
|
||||
|
||||
public static sbyte CITSB(this int c)
|
||||
{ return ( sbyte)(c > 0x0000007F ?
|
||||
@@ -203,7 +239,10 @@ namespace KKdBaseLib
|
||||
public static double ToF64(this long i) => *(double*)&i;
|
||||
public static double ToF64(this ulong i) => *(double*)&i;
|
||||
|
||||
public static string ToString(this int d, bool BE) =>
|
||||
public static string ToS(this int d, bool BE) =>
|
||||
BitConverter.GetBytes(d.E(BE)).ToASCII();
|
||||
|
||||
public static string ToS(this uint d, bool BE) =>
|
||||
BitConverter.GetBytes(d.E(BE)).ToASCII();
|
||||
|
||||
public static string ToS(this object d)
|
||||
@@ -270,5 +309,39 @@ namespace KKdBaseLib
|
||||
public static bool ToF64(this string s, out double? val)
|
||||
{ val = null; if (s.Length < 1) return false; ulong d = 0; if (s[0] == '-') d = 0x8000000000000000;
|
||||
bool b = double.TryParse(s.Replace(".", NDS), out double t); if (b) val = (d | t.ToU64()).ToF64(); return b; }
|
||||
|
||||
public static T[] ReverseEndian<T>(this T[] a)
|
||||
{
|
||||
if (a == null || a.Length < 1) return a;
|
||||
|
||||
int length = a.Length;
|
||||
T[] b = new T[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
b[i] = (T)ReverseEndian(a[i]);
|
||||
return b;
|
||||
}
|
||||
|
||||
public static object ReverseEndian(this object a)
|
||||
{
|
||||
object c = default;
|
||||
System.Reflection.FieldInfo[] d = a.GetType().GetFields();
|
||||
foreach (System.Reflection.FieldInfo field in d)
|
||||
{
|
||||
object e = field.GetValue(a);
|
||||
Type t = field.FieldType;
|
||||
if (t == typeof( short)) e = (( short)e).E();
|
||||
else if (t == typeof(ushort)) e = ((ushort)e).E();
|
||||
else if (t == typeof( int)) e = (( int)e).E();
|
||||
else if (t == typeof( uint)) e = (( uint)e).E();
|
||||
else if (t == typeof( long)) e = (( long)e).E();
|
||||
else if (t == typeof( ulong)) e = (( ulong)e).E();
|
||||
else if (t == typeof( float)) e = (( float)e).ToI32().E().ToF32();
|
||||
else if (t == typeof(double)) e = ((double)e).ToI64().E().ToF64();
|
||||
else if (t == typeof( Half)) e = (Half)((ushort)(Half)e).E();
|
||||
else e = ReverseEndian(e);
|
||||
field.SetValue(a, e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct ENRS : INull
|
||||
{
|
||||
|
||||
+13
-13
@@ -1,23 +1,23 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
public int Signature;
|
||||
public int DataSize;
|
||||
public int Length;
|
||||
public int Flags;
|
||||
public int Depth;
|
||||
public int SectionSize;
|
||||
public int Mode;
|
||||
public int InnerSignature;
|
||||
public int SectionSignature;
|
||||
public uint Signature; // 0x00
|
||||
public uint DataSize; // 0x04
|
||||
public uint Length; // 0x08
|
||||
public uint Flags; // 0x0C
|
||||
public uint Depth; // 0x10
|
||||
public uint SectionSize; // 0x14
|
||||
public uint Version; // 0x18
|
||||
public uint InnerSignature; // 0x30
|
||||
public uint SectionSignature; // 0x40
|
||||
|
||||
public Format Format;
|
||||
public bool NotUseDataSizeAsSectionSize;
|
||||
public bool UseBigEndian;
|
||||
public bool UseSectionSize;
|
||||
|
||||
public bool IsBE => Format == Format.F2BE;
|
||||
public bool IsX => Format == Format.X || Format == Format.XHD;
|
||||
|
||||
public override string ToString() => Signature.ToString(false);
|
||||
public override string ToString() => Signature.ToS(false);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-12
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct POF : INull
|
||||
{
|
||||
@@ -16,24 +16,28 @@
|
||||
Offsets = KKdList<long>.New;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
int i = 0, offset = 0, v = 0;
|
||||
long offset = 0;
|
||||
int i = 0, j = 0, v = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
|
||||
int length = *(int*)ptr - 4;
|
||||
byte* localPtr = ptr + 4;
|
||||
byte* l = ptr + 4;
|
||||
Offsets.Capacity = length;
|
||||
while (length > i)
|
||||
{
|
||||
v = *ptr & 0x3F;
|
||||
Val = (Value)(*ptr & 0xC0);
|
||||
localPtr++; i++;
|
||||
if (Val == Value.Int32 )
|
||||
{ v = (v << 24) | (ptr[0] << 16) | (ptr[1] << 8) | ptr[2]; localPtr += 3; i += 3; }
|
||||
else if (Val == Value.Int16 )
|
||||
{ v = (v << 8) | ptr[0]; localPtr += 1; i += 3; }
|
||||
else if (Val == Value.Invalid) break;
|
||||
v = *l & 0x3F;
|
||||
Val = (Value)(*l & 0xC0);
|
||||
if (Val == Value.Int32)
|
||||
{ v = (v << 24) | (l[1] << 16) | (l[2] << 8) | l[3]; l += 4; i += 4; }
|
||||
else if (Val == Value.Int16)
|
||||
{ v = (v << 8) | l[1]; l += 2; i += 2; }
|
||||
else if (Val == Value.Int8 ) { l ++ ; i ++ ; }
|
||||
else break;
|
||||
j++;
|
||||
offset += v;
|
||||
Offsets.Add(offset << bitShift);
|
||||
}
|
||||
Offsets.Capacity = j;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +77,7 @@
|
||||
|
||||
private int length(bool shiftX = false)
|
||||
{
|
||||
int length = 5;
|
||||
int length = 6;
|
||||
long offset = 0;
|
||||
byte bitShift = (byte)(shiftX ? 3 : 2);
|
||||
int max1 = 0x00100 >> bitShift;
|
||||
|
||||
+19
-18
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Struct
|
||||
{
|
||||
@@ -9,10 +9,10 @@
|
||||
public ENRS ENRS;
|
||||
public POF POF;
|
||||
|
||||
public int Length => length(false);
|
||||
public int LengthX => length( true);
|
||||
public uint Length => length(false);
|
||||
public uint LengthX => length( true);
|
||||
|
||||
public int Depth => Header.Depth;
|
||||
public uint Depth => Header.Depth;
|
||||
|
||||
public bool HasPOF => POF .NotNull;
|
||||
public bool HasENRS => ENRS.NotNull;
|
||||
@@ -20,29 +20,30 @@
|
||||
|
||||
public long DataOffset;
|
||||
|
||||
public override string ToString() => $"{Header.ToString()}" +
|
||||
$"{(HasSubStructs ? $"; SubStructs: {SubStructs.Length}" : "")}" +
|
||||
$"{(HasENRS ? "; Has ENRS" : "")}{(HasPOF ? "; Has POF" : "")}";
|
||||
|
||||
private int length(bool shiftX = false)
|
||||
public void Update(bool ShiftX = false)
|
||||
{
|
||||
int length = Data != null ? Data.Length : 0;
|
||||
if (HasPOF ) length += 0x20 + (shiftX ? POF.LengthX : POF.Length);
|
||||
if (HasENRS) length += 0x20 + ENRS.Length;
|
||||
Header.SectionSize = Data != null ? (uint)Data.Length : 0;
|
||||
Header.DataSize = length(ShiftX);
|
||||
}
|
||||
|
||||
private uint length(bool shiftX = false)
|
||||
{
|
||||
uint length = Data != null ? (uint)Data.Length : 0;
|
||||
if (HasPOF ) length += 0x20 + (uint)(shiftX ? POF.LengthX : POF.Length);
|
||||
if (HasENRS) length += 0x20 + (uint)ENRS.Length;
|
||||
|
||||
if (HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < SubStructs.Length; i++)
|
||||
length += (shiftX ? SubStructs[i].LengthX : SubStructs[i].Length) + SubStructs[i].Header.Length;
|
||||
length += (uint)(shiftX ? SubStructs[i].LengthX : SubStructs[i].Length)
|
||||
+ SubStructs[i].Header.Length;
|
||||
length += 0x20;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
public void Update(bool ShiftX = false)
|
||||
{
|
||||
Header.SectionSize = Data != null ? Data.Length : 0;
|
||||
Header.DataSize = length(ShiftX);
|
||||
}
|
||||
public override string ToString() => $"{Header}" +
|
||||
$"{(HasSubStructs ? $"; SubStructs: {SubStructs.Length}" : "")}" +
|
||||
$"{(HasENRS ? "; Has ENRS" : "")}{(HasPOF ? "; Has POF" : "")}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public enum Format : byte
|
||||
{
|
||||
@@ -9,11 +9,11 @@
|
||||
DTe = 4,
|
||||
F = 5,
|
||||
AFT = 6,
|
||||
F2LE = 7,
|
||||
F2BE = 8,
|
||||
MGF = 9,
|
||||
X = 10,
|
||||
XHD = 11,
|
||||
FT = 12,
|
||||
F2 = 7,
|
||||
MGF = 8,
|
||||
X = 9,
|
||||
XHD = 10,
|
||||
FT = 11,
|
||||
M39 = 12,
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public interface IKF
|
||||
{
|
||||
|
||||
@@ -1,33 +1,32 @@
|
||||
using KKdBaseLib.Auth3D;
|
||||
using KKdBaseLib.Auth3D;
|
||||
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public struct A3DAI //A3DA Interpolation
|
||||
public class A3DAI : IInterpolation<float> //A3DA Interpolation
|
||||
{
|
||||
private A3DAKey a3daKey;
|
||||
|
||||
private float f;
|
||||
private float last;
|
||||
private float t;
|
||||
private float v;
|
||||
private float df;
|
||||
private float @if;
|
||||
private float rf;
|
||||
private float lastTime;
|
||||
|
||||
private KFT3 firstKey;
|
||||
private KFT3 lastKey;
|
||||
|
||||
public float InterpolationFramerate { get => @if; set { @if = value; df = @if / rf; } }
|
||||
public float RequestedFramerate { get => rf; set { rf = value; df = @if / rf; } }
|
||||
public float RequestedFramerate { get => rf; set { rf = value; df = @if / rf; } }
|
||||
|
||||
public float Frame => f;
|
||||
public float Value => last;
|
||||
public bool IsNull => a3daKey.Keys == null ? true : a3daKey.Length < 1;
|
||||
public bool NotNull => a3daKey.Keys == null ? false : a3daKey.Length > 0;
|
||||
public float Time => t;
|
||||
public float Value => v;
|
||||
public bool IsNull => a3daKey.Keys == null || a3daKey.Length < 1;
|
||||
public bool NotNull => a3daKey.Keys != null && a3daKey.Length > 0;
|
||||
|
||||
public A3DAI(Key key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
a3daKey = (A3DAKey)key; f = -1; df = last = rf = @if = 0;
|
||||
a3daKey = new A3DAKey(key); f = -1; df = @if = rf = t = v = 0;
|
||||
@if = a3daFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
@@ -43,8 +42,8 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
public A3DAI(A3DAKey key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
a3daKey = key; f = -1; df = last = rf = @if = 0;
|
||||
t = 0;
|
||||
a3daKey = key; f = -1; df = v = rf = @if = 0;
|
||||
@if = a3daFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
@@ -60,50 +59,54 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
public float SetTime(float time)
|
||||
{
|
||||
if ((int)a3daKey.Type < 0 || (int)a3daKey.Type > 4) return 0.0f;
|
||||
else if ((int)a3daKey.Type < 2) return a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) return 0.0f;
|
||||
|
||||
lastTime = time;
|
||||
t = time;
|
||||
f = time * @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
|
||||
int type = (int)a3daKey.Type;
|
||||
if (type < 0 || type > 4) v = 0.0f;
|
||||
else if (type < 2) v = a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
return v;
|
||||
}
|
||||
|
||||
public float SetFrame(float frame)
|
||||
{
|
||||
if ((int)a3daKey.Type < 0 || (int)a3daKey.Type > 4) return 0.0f;
|
||||
else if ((int)a3daKey.Type < 2) return a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) return 0.0f;
|
||||
|
||||
lastTime = frame / rf;
|
||||
t = frame / rf;
|
||||
f = frame * df;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
|
||||
int type = (int)a3daKey.Type;
|
||||
if (type < 0 || type > 4) v = 0.0f;
|
||||
else if (type < 2) v = a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
return v;
|
||||
}
|
||||
|
||||
public float NextFrame(float time)
|
||||
{
|
||||
if ((int)a3daKey.Type < 0 || (int)a3daKey.Type > 4) return 0.0f;
|
||||
else if ((int)a3daKey.Type < 2) return a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) return 0.0f;
|
||||
t += time;
|
||||
f = t * @if;
|
||||
|
||||
lastTime += time;
|
||||
f = lastTime * @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
int type = (int)a3daKey.Type;
|
||||
if (type < 0 || type > 4) v = 0.0f;
|
||||
else if (type < 2) v = a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
return v;
|
||||
}
|
||||
|
||||
public float NextFrame()
|
||||
{
|
||||
if ((int)a3daKey.Type < 0 || (int)a3daKey.Type > 4) return 0.0f;
|
||||
else if ((int)a3daKey.Type < 2) return a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) return 0.0f;
|
||||
|
||||
f += df;
|
||||
lastTime = f / @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
t = f / @if;
|
||||
|
||||
int type = (int)a3daKey.Type;
|
||||
if (type < 0 || type > 4) v = 0.0f;
|
||||
else if (type < 2) v = a3daKey.Value;
|
||||
else if (a3daKey.Length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
return v;
|
||||
}
|
||||
|
||||
private float Interpolate(float frame)
|
||||
@@ -148,19 +151,27 @@ namespace KKdBaseLib.Interpolation
|
||||
if (f <= firstKey.F) return firstKey.V + ep;
|
||||
else if (f >= lastKey.F) return lastKey.V + ep;
|
||||
|
||||
long key = 0;
|
||||
long length = a3daKey.Length;
|
||||
long temp;
|
||||
while (length > 0)
|
||||
if (f > a3daKey.Keys[key + (temp = length >> 1)].F)
|
||||
KFT3 c, n;
|
||||
unsafe
|
||||
{
|
||||
fixed (KFT3* ptr = a3daKey.Keys)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
long key = 0;
|
||||
long length = a3daKey.Length;
|
||||
long temp;
|
||||
while (length > 0)
|
||||
if (f > a3daKey.Keys[key + (temp = length >> 1)].F)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
}
|
||||
else length = temp;
|
||||
|
||||
c = ptr[key - 1];
|
||||
n = ptr[key];
|
||||
}
|
||||
else length = temp;
|
||||
}
|
||||
|
||||
ref KFT3 c = ref a3daKey.Keys[key - 1];
|
||||
ref KFT3 n = ref a3daKey.Keys[key];
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
{
|
||||
@@ -182,8 +193,8 @@ namespace KKdBaseLib.Interpolation
|
||||
return result + ep;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() => f = -df;
|
||||
public void ResetFrameCount() { f = -df; t = f / rf; }
|
||||
|
||||
public override string ToString() => $"Frame: {f}, Value: {last}";
|
||||
public override string ToString() => $"F: {f}; T: {t}; V: {v}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
namespace KKdBaseLib.Interpolation
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public interface IInterpolation : INull
|
||||
public interface IInterpolation<T> : INull
|
||||
{
|
||||
float RequestedFramerate { get; set; }
|
||||
float InterpolationFramerate { get; set; }
|
||||
float RequestedFramerate { get; set; }
|
||||
|
||||
float Frame { get; }
|
||||
float Value { get; }
|
||||
float Time { get; }
|
||||
T Value { get; }
|
||||
|
||||
float SetTime (float time);
|
||||
float SetFrame(float frame);
|
||||
float NextFrame(float time);
|
||||
float NextFrame();
|
||||
T SetTime (float time);
|
||||
T SetFrame(float frame);
|
||||
T NextFrame(float time);
|
||||
T NextFrame();
|
||||
void ResetFrameCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
namespace KKdBaseLib.Interpolation
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public struct PDI : IInterpolation //Project DIVA Interpolation
|
||||
public class PDI : IInterpolation<float> //Project DIVA Interpolation
|
||||
{
|
||||
private KFT2[] array;
|
||||
private int length;
|
||||
|
||||
private float f;
|
||||
private float last;
|
||||
private float t;
|
||||
private float v;
|
||||
private float df;
|
||||
private float @if;
|
||||
private float rf;
|
||||
private float lastTime;
|
||||
|
||||
private KFT2 firstKey;
|
||||
private KFT2 lastKey;
|
||||
|
||||
public float InterpolationFramerate { get => @if; set { @if = value; df = @if / rf; } }
|
||||
public float RequestedFramerate { get => rf; set { rf = value; df = @if / rf; } }
|
||||
public float RequestedFramerate { get => rf; set { rf = value; df = @if / rf; } }
|
||||
|
||||
public float Frame => f;
|
||||
public float Value => last;
|
||||
public bool IsNull => array == null ? true : array.Length < 1;
|
||||
public bool NotNull => array == null ? false : array.Length > 0;
|
||||
public float Time => t;
|
||||
public float Value => v;
|
||||
public bool IsNull => array == null || array.Length < 1;
|
||||
public bool NotNull => array != null && array.Length > 0;
|
||||
|
||||
public PDI(KFT2[] array, float interpolationFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
this.array = array; f = -1; df = last = rf = @if = 0;
|
||||
length = 0;
|
||||
this.array = array; f = -1; df = @if = rf = t = v = 0;
|
||||
@if = interpolationFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
@@ -36,47 +37,52 @@
|
||||
{
|
||||
firstKey = array[0];
|
||||
lastKey = array[array.Length - 1];
|
||||
length = array.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public float SetTime(float time)
|
||||
{
|
||||
if (array == null || array.Length < 1) return 0;
|
||||
|
||||
lastTime = time;
|
||||
t = time;
|
||||
f = time * @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
|
||||
if (array == null || length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public float SetFrame(float frame)
|
||||
{
|
||||
if (array == null || array.Length < 1) return 0;
|
||||
|
||||
lastTime = frame / rf;
|
||||
t = frame / rf;
|
||||
f = frame * df;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
|
||||
if (array == null || length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public float NextFrame(float time)
|
||||
{
|
||||
if (array == null || array.Length < 1) return 0;
|
||||
t += time;
|
||||
f = t * @if;
|
||||
|
||||
lastTime += time;
|
||||
f = lastTime * @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
if (array == null || length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public float NextFrame()
|
||||
{
|
||||
if (array == null || array.Length < 1) return 0;
|
||||
|
||||
f += df;
|
||||
lastTime = f / @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
t = f / @if;
|
||||
|
||||
if (array == null || length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private float Interpolate(float frame)
|
||||
@@ -86,19 +92,27 @@
|
||||
if (f <= firstKey.F) return firstKey.V;
|
||||
else if (f >= lastKey.F) return lastKey.V;
|
||||
|
||||
int key = 0;
|
||||
int length = array.Length;
|
||||
int temp;
|
||||
while (length > 0)
|
||||
if (f > array[key + (temp = length >> 1)].F)
|
||||
KFT2 c, n;
|
||||
unsafe
|
||||
{
|
||||
fixed (KFT2* ptr = array)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
long key = 0;
|
||||
long length = this.length;
|
||||
long temp;
|
||||
while (length > 0)
|
||||
if (f > array[key + (temp = length >> 1)].F)
|
||||
{
|
||||
key += temp + 1;
|
||||
length -= temp + 1;
|
||||
}
|
||||
else length = temp;
|
||||
|
||||
c = ptr[key - 1];
|
||||
n = ptr[key];
|
||||
}
|
||||
else length = temp;
|
||||
}
|
||||
|
||||
ref KFT2 c = ref array[key - 1];
|
||||
ref KFT2 n = ref array[key];
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
{
|
||||
@@ -111,8 +125,8 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() => f = -df;
|
||||
public void ResetFrameCount() { f = -df; t = f / rf; }
|
||||
|
||||
public override string ToString() => $"Frame: {f}, Value: {last}";
|
||||
public override string ToString() => $"F: {f}; T: {t}; V: {v}";
|
||||
}
|
||||
}
|
||||
|
||||
+24
-6
@@ -1,10 +1,10 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KFT0 : IKF
|
||||
{
|
||||
public float F;
|
||||
|
||||
public KFT0(float F = 0)
|
||||
public KFT0(float F)
|
||||
{ this.F = F; }
|
||||
|
||||
public KFT0 ToT0() => this;
|
||||
@@ -55,7 +55,10 @@
|
||||
public float F;
|
||||
public float V;
|
||||
|
||||
public KFT1(float F = 0, float V = 0)
|
||||
public KFT1(float F)
|
||||
{ this.F = F; V = 0; }
|
||||
|
||||
public KFT1(float F, float V)
|
||||
{ this.F = F; this.V = V; }
|
||||
|
||||
public KFT0 ToT0() =>
|
||||
@@ -109,7 +112,13 @@
|
||||
public float V;
|
||||
public float T;
|
||||
|
||||
public KFT2(float F = 0, float V = 0, float T = 0)
|
||||
public KFT2(float F)
|
||||
{ this.F = F; V = T = 0; }
|
||||
|
||||
public KFT2(float F, float V)
|
||||
{ this.F = F; this.V = V; T = 0; }
|
||||
|
||||
public KFT2(float F, float V, float T)
|
||||
{ this.F = F; this.V = V; this.T = T; }
|
||||
|
||||
public KFT0 ToT0() =>
|
||||
@@ -118,7 +127,7 @@
|
||||
new KFT1(F, V);
|
||||
public KFT2 ToT2() => this;
|
||||
public KFT3 ToT3() =>
|
||||
new KFT3(F, V, T, T);
|
||||
new KFT3(F, V, T);
|
||||
|
||||
public KFT3 ToT3(IKF Previous) =>
|
||||
Previous is KFT2 PreviousT2 ?
|
||||
@@ -169,7 +178,16 @@
|
||||
public float T1;
|
||||
public float T2;
|
||||
|
||||
public KFT3(float F = 0, float V = 0, float T1 = 0, float T2 = 0)
|
||||
public KFT3(float F)
|
||||
{ this.F = F; V = T1 = T2 = 0; }
|
||||
|
||||
public KFT3(float F, float V)
|
||||
{ this.F = F; this.V = V; T1 = T2 = 0; }
|
||||
|
||||
public KFT3(float F, float V, float T)
|
||||
{ this.F = F; this.V = V; T1 = T2 = T; }
|
||||
|
||||
public KFT3(float F, float V, float T1, float T2)
|
||||
{ this.F = F; this.V = V; this.T1 = T1; this.T2 = T2; }
|
||||
|
||||
public KFT0 ToT0() =>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019-2020</Copyright>
|
||||
<Copyright>korenkonder (C) 2019-2020</Copyright>
|
||||
<Description>A base library</Description>
|
||||
<FileVersion>0.4.9.0</FileVersion>
|
||||
<FileVersion>0.4.9.6</FileVersion>
|
||||
<PackageId>KKdBaseLib</PackageId>
|
||||
<Product>KKdBaseLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<Title>KKdBaseLib</Title>
|
||||
<Version>0.4.9.0</Version>
|
||||
<Version>0.4.9.6</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,6 +37,9 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
+34
-20
@@ -1,11 +1,11 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KKdDict<TKey, TValue> : System.IDisposable, System.Collections.IEnumerator, INull
|
||||
{
|
||||
public static KKdDict<TKey, TValue> Null => new KKdDict<TKey, TValue>();
|
||||
public static KKdDict<TKey, TValue> New => new KKdDict<TKey, TValue>() { count = 0, Capacity = 0 };
|
||||
public static KKdDict<TKey, TValue> NewReserve(int Capacity) =>
|
||||
new KKdDict<TKey, TValue>() { count = 0, Capacity = Capacity };
|
||||
public static KKdDict<TKey, TValue> NewReserve(int capacity) =>
|
||||
new KKdDict<TKey, TValue>() { count = 0, Capacity = capacity };
|
||||
|
||||
private int count;
|
||||
private int index;
|
||||
@@ -49,9 +49,17 @@
|
||||
set { if (keyArray != null && valArray != null && index < keyArray.Length &&
|
||||
index < valArray.Length) { keyArray[index] = value.Key; valArray[index] = value.Value; } } }
|
||||
|
||||
public KeyValuePair<TKey, TValue> this[long index, bool list]
|
||||
{ get => keyArray != null && valArray != null && index > -1 && index < keyArray.Length &&
|
||||
index < valArray.Length ? new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
set { if (keyArray != null && valArray != null && index > -1 && index < keyArray.Length &&
|
||||
index < valArray.Length) { keyArray[index] = value.Key; valArray[index] = value.Value; } } }
|
||||
|
||||
public TValue this[TKey key]
|
||||
{ get => valArray != null && valArray.Length > 0 && CK(key, out int index) ? valArray[index] : default;
|
||||
set { if (valArray != null && valArray.Length > 0) if (CK(key, out int index)) valArray[index] = value; else Add(key, value); } }
|
||||
{ get => valArray != null && valArray.Length > 0
|
||||
&& CK(key, out int index) ? valArray[index] : default;
|
||||
set { if (valArray != null && valArray.Length > 0)
|
||||
if (CK(key, out int index)) valArray[index] = value; else Add(key, value); } }
|
||||
|
||||
public bool MoveNext()
|
||||
{ if (index == count - 1) { index = 0; return false; }
|
||||
@@ -65,22 +73,22 @@
|
||||
|
||||
public void Add(KeyValuePair<TKey, TValue> pair)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IsNull || ContainsKey(pair.Key)) return;
|
||||
|
||||
count++;
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, count);
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, keyArray.Length * 2 + 1);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, valArray.Length * 2 + 1);
|
||||
keyArray[count - 1] = pair.Key;
|
||||
valArray[count - 1] = pair.Value;
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue val)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IsNull || ContainsKey(key)) return;
|
||||
|
||||
count++;
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, count);
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, keyArray.Length * 2 + 1);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, valArray.Length * 2 + 1);
|
||||
keyArray[count - 1] = key;
|
||||
valArray[count - 1] = val;
|
||||
}
|
||||
@@ -93,8 +101,8 @@
|
||||
if (index == -1) return false;
|
||||
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index - 1);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index - 1); }
|
||||
count--;
|
||||
return true;
|
||||
}
|
||||
@@ -107,8 +115,8 @@
|
||||
if (index == -1) return false;
|
||||
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index - 1);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index - 1); }
|
||||
count--;
|
||||
return true;
|
||||
}
|
||||
@@ -118,8 +126,8 @@
|
||||
if (IsNull || index < 0 || index >= count) return;
|
||||
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index - 1);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index - 1); }
|
||||
count--;
|
||||
}
|
||||
|
||||
@@ -184,9 +192,9 @@
|
||||
{
|
||||
if (IsNull) return default;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (keyArray[i] == null && val == null) return keyArray[i];
|
||||
else if (keyArray[i] == null || val == null) continue;
|
||||
else if (keyArray[i].Equals(val)) return keyArray[i];
|
||||
if (valArray[i] == null && val == null) return keyArray[i];
|
||||
else if (valArray[i] == null || val == null) continue;
|
||||
else if (valArray[i].Equals(val)) return keyArray[i];
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -209,6 +217,9 @@
|
||||
else if (valArray[i].Equals(val)) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"(Count: {Count}; Capacity: {Capacity}; Current: {Current})";
|
||||
}
|
||||
|
||||
public struct KeyValuePair<TKey, TValue>
|
||||
@@ -218,5 +229,8 @@
|
||||
|
||||
public KeyValuePair(TKey key, TValue value)
|
||||
{ Key = key; Value = value; }
|
||||
|
||||
public override string ToString() =>
|
||||
$"(Key: {Key}; Value: {Value})";
|
||||
}
|
||||
}
|
||||
|
||||
+20
-11
@@ -1,4 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KKdBaseLib
|
||||
@@ -7,7 +7,7 @@ namespace KKdBaseLib
|
||||
{
|
||||
public static KKdList<T> Null => new KKdList<T>();
|
||||
public static KKdList<T> New => new KKdList<T>() { count = 0, Capacity = 0 };
|
||||
public static KKdList<T> NewReserve(int Capacity) => new KKdList<T>() { count = 0, Capacity = Capacity };
|
||||
public static KKdList<T> NewReserve(int capacity) => new KKdList<T>() { count = 0, Capacity = capacity };
|
||||
|
||||
private int count;
|
||||
private int index;
|
||||
@@ -43,6 +43,10 @@ namespace KKdBaseLib
|
||||
{ get => array != null && index < array.Length ? array[index] : default;
|
||||
set { if (array != null && index < array.Length) array[index] = value; } }
|
||||
|
||||
public T this[long index]
|
||||
{ get => array != null && index < array.Length ? array[index] : default;
|
||||
set { if (array != null && index < array.Length) array[index] = value; } }
|
||||
|
||||
public IEnumerator GetEnumerator() => enumerator = new Enumerator(array);
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => enumerator = new Enumerator(array);
|
||||
@@ -57,7 +61,7 @@ namespace KKdBaseLib
|
||||
|
||||
count++;
|
||||
if (array.Length < count)
|
||||
System.Array.Resize(ref array, count);
|
||||
System.Array.Resize(ref array, array.Length * 2 + 1);
|
||||
array[count - 1] = item;
|
||||
}
|
||||
|
||||
@@ -66,7 +70,7 @@ namespace KKdBaseLib
|
||||
if (IsNull || index < 0 || index >= count) return;
|
||||
|
||||
if (index + 1 < count)
|
||||
System.Array.Copy(array, index + 1, array, index, count - index);
|
||||
System.Array.Copy(array, index + 1, array, index, count - index - 1);
|
||||
count--;
|
||||
}
|
||||
|
||||
@@ -103,13 +107,18 @@ namespace KKdBaseLib
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{ List<T> List = (List<T>)this; List.Sort(); array = List.ToArray(); count = List.Count; }
|
||||
{ Capacity = Count; List<T> List = (List<T>)this; List.Sort();
|
||||
array = List.ToArray(); count = List.Count; }
|
||||
|
||||
public static explicit operator KKdList<T>( List<T> list) =>
|
||||
new KKdList<T> { array = list.ToArray(), count = list.Count };
|
||||
|
||||
public static explicit operator List<T>(KKdList<T> list)
|
||||
{ List<T> outList = new List<T>(); for (int i = 0; i < list.Count; i++) outList.Add(list[i]); return outList; }
|
||||
{ list.Capacity = list.Count; List<T> outList = new List<T>();
|
||||
for (int i = 0; i < list.Count; i++) outList.Add(list[i]); return outList; }
|
||||
|
||||
public override string ToString() =>
|
||||
$"(Count: {Count}; Capacity: {Capacity}; Current: {Current})";
|
||||
|
||||
public struct Enumerator : IEnumerator<T>, IEnumerator
|
||||
{
|
||||
@@ -117,14 +126,14 @@ namespace KKdBaseLib
|
||||
private int index;
|
||||
private int count;
|
||||
private T current;
|
||||
|
||||
internal Enumerator(T[] array)
|
||||
|
||||
internal Enumerator(T[] array)
|
||||
{ this.array = array; count = index = 0; current = default;
|
||||
if (array != null && array.Length > 0) { current = array[0]; count = array.Length; } }
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{ array = null; count = index = 0; current = default; }
|
||||
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (index < count) { current = array[index]; index++; return true; }
|
||||
@@ -132,7 +141,7 @@ namespace KKdBaseLib
|
||||
}
|
||||
|
||||
public T Current => current;
|
||||
|
||||
|
||||
object IEnumerator.Current =>
|
||||
(index == 0 || index == array.Length + 1) ? default : current;
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
using A3DADict = System.Collections.Generic.Dictionary<string, object>;
|
||||
|
||||
namespace KKdMainLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public static unsafe class Main
|
||||
{
|
||||
@@ -52,57 +51,67 @@ namespace KKdMainLib
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
for (int i = 0; i < args.Length - 1; i++)
|
||||
newArgs[i] = args[i + 1];
|
||||
return dict.ContainsKey(args[0]) ? SW((A3DADict)dict[args[0]], newArgs) : false;
|
||||
return dict.ContainsKey(args[0]) && SW((A3DADict)dict[args[0]], newArgs);
|
||||
}
|
||||
return dict.ContainsKey(args[0]);
|
||||
}
|
||||
|
||||
public static bool FV(this A3DADict dict, ref bool value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) ? bool.TryParse(val, out value) : false;
|
||||
public static bool FV (this A3DADict dict, ref bool value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && bool.TryParse(val, out value);
|
||||
|
||||
public static bool FV(this A3DADict dict, ref int value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) ? int.TryParse(val, out value) : false;
|
||||
public static bool FV (this A3DADict dict, ref int value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && int.TryParse(val, out value);
|
||||
|
||||
public static bool FV(this A3DADict dict, ref float value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) ? val.ToF32(out value) : false;
|
||||
public static bool FV (this A3DADict dict, ref float value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && val.ToF32(out value);
|
||||
|
||||
public static bool FV(this A3DADict dict, ref double value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) ? val.ToF64(out value) : false;
|
||||
public static bool FV (this A3DADict dict, ref double value, char split, string args) =>
|
||||
dict.FV(out string val, args.Split(split)) && val.ToF64(out value);
|
||||
|
||||
public static bool FV(this A3DADict dict, ref string value, char split, string args)
|
||||
public static bool FV (this A3DADict dict, ref string value, char split, string args)
|
||||
{ if (dict.FV(out string val , args.Split(split)))
|
||||
{ value = val; return true; } return false; }
|
||||
{ value = val; return true; } return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out bool value, string args)
|
||||
public static bool FV (this A3DADict dict, out bool value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return bool.TryParse(val, out value); value = false; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out int value, string args)
|
||||
public static bool FV (this A3DADict dict, out int value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return int.TryParse(val, out value); value = 0; return false; }
|
||||
return int.TryParse(val, out value); value = 0; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out float value, string args)
|
||||
public static bool FV (this A3DADict dict, out float value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF32(out value); value = 0; return false; }
|
||||
return val.ToF32(out value); value = 0; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out double value, string args)
|
||||
public static bool FV (this A3DADict dict, out double value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF64(out value); value = 0; return false; }
|
||||
return val.ToF64(out value); value = 0; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out int? value, string args)
|
||||
public static bool FV<T>(this A3DADict dict, out T value, string args) where T : struct
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = int.TryParse(val, out int _value);
|
||||
value = _value; return Val; } value = null; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out float? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF32(out value); value = null; return false; }
|
||||
{ bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
|
||||
value = default; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out double? value, string args)
|
||||
public static bool FV (this A3DADict dict, out int? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF64(out value); value = null; return false; }
|
||||
{ bool Val = int.TryParse(val, out int _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV(this A3DADict dict, out string value, string args) =>
|
||||
public static bool FV (this A3DADict dict, out float? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF32(out value); value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out double? value, string args)
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
return val.ToF64(out value); value = null; return false; }
|
||||
|
||||
public static bool FV<T>(this A3DADict dict, out T? value, string args) where T : struct
|
||||
{ if (dict.FV(out string val , args.Split('.' )))
|
||||
{ bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
|
||||
value = null; return false; }
|
||||
|
||||
public static bool FV (this A3DADict dict, out string value, string args) =>
|
||||
dict.FV(out value, args.Split('.' ));
|
||||
|
||||
public static bool FV(this A3DADict dict, out string value, string[] args)
|
||||
@@ -129,6 +138,24 @@ namespace KKdMainLib
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool FK(this A3DADict dict, string args) =>
|
||||
dict.FK(args.Split('.' ));
|
||||
|
||||
public static bool FK(this A3DADict dict, string[] args)
|
||||
{
|
||||
if (dict == null || args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (!dict.ContainsKey(args[0])) return false;
|
||||
else if (args.Length > 1)
|
||||
{
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
for (int i = 0; i < args.Length - 1; i++) newArgs[i] = args[i + 1];
|
||||
return ((A3DADict)dict[args[0]]).FK(newArgs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void GD(this A3DADict dict, string args, char split = '.')
|
||||
{
|
||||
string[] dataArray = args.Split('=');
|
||||
@@ -0,0 +1,130 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Mat2
|
||||
{
|
||||
[FieldOffset(0x00)] public Vec2 Row0;
|
||||
[FieldOffset(0x08)] public Vec2 Row1;
|
||||
|
||||
public Vec2 Column0 { get => new Vec2(Row0.X, Row1.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; } }
|
||||
public Vec2 Column1 { get => new Vec2(Row0.Y, Row1.X);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; } }
|
||||
|
||||
public static Mat2 Identity => new Mat2(new Vec2(1.0f, 0.0f),
|
||||
new Vec2(0.0f, 1.0f));
|
||||
|
||||
public Mat2(Vec2 row0, Vec2 row1)
|
||||
{ Row0 = row0; Row1 = row1; }
|
||||
|
||||
public Mat2 Invert() => -this;
|
||||
|
||||
public static Mat2 operator +(Mat2 left, Mat2 right)
|
||||
{ left.Row0 += right.Row0; left.Row1 += right.Row1; return left; }
|
||||
|
||||
public static Mat2 operator -(Mat2 left, Mat2 right)
|
||||
{ left.Row0 -= right.Row0; left.Row1 -= right.Row1; return left; }
|
||||
|
||||
public static Mat2 operator -(Mat2 mat)
|
||||
{
|
||||
int[] colIdx = { 0, 0 };
|
||||
int[] rowIdx = { 0, 0 };
|
||||
int[] pivotIdx = { -1, -1 };
|
||||
|
||||
Mat2 result = mat;
|
||||
float[,] inverse =
|
||||
{
|
||||
{ mat.Row0.X, mat.Row0.Y },
|
||||
{ mat.Row1.X, mat.Row1.Y }
|
||||
};
|
||||
int icol = 0;
|
||||
int irow = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
float maxPivot = 0.0f;
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
if (pivotIdx[j] == 0) continue;
|
||||
|
||||
for (int k = 0; k < 2; k++)
|
||||
{
|
||||
if (pivotIdx[k] == -1)
|
||||
{
|
||||
float absVal = System.Math.Abs(inverse[j, k]);
|
||||
if (absVal > maxPivot)
|
||||
{
|
||||
maxPivot = absVal;
|
||||
irow = j;
|
||||
icol = k;
|
||||
}
|
||||
}
|
||||
else if (pivotIdx[k] > 0)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
pivotIdx[icol]++;
|
||||
|
||||
if (irow != icol)
|
||||
for (int k = 0; k < 2; k++)
|
||||
{ float t = inverse[irow, k]; inverse[irow, k] = inverse[icol, k]; inverse[icol, k] = t; }
|
||||
|
||||
rowIdx[i] = irow;
|
||||
colIdx[i] = icol;
|
||||
|
||||
float pivot = inverse[icol, icol];
|
||||
|
||||
float oneOverPivot = 1.0f / pivot;
|
||||
inverse[icol, icol] = 1.0f;
|
||||
for (int k = 0; k < 2; k++)
|
||||
inverse[icol, k] *= oneOverPivot;
|
||||
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
if (icol == j) continue;
|
||||
|
||||
float f = inverse[j, icol];
|
||||
inverse[j, icol] = 0.0f;
|
||||
for (int k = 0; k < 3; k++)
|
||||
inverse[j, k] -= inverse[icol, k] * f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 1; j >= 0; j--)
|
||||
{
|
||||
int ir = rowIdx[j];
|
||||
int ic = colIdx[j];
|
||||
for (int k = 0; k < 2; k++)
|
||||
{ float t = inverse[k, ic]; inverse[k, ic] = inverse[k, ir]; inverse[k, ir] = t; }
|
||||
}
|
||||
|
||||
result.Row0.X = inverse[0, 0]; result.Row0.Y = inverse[0, 1];
|
||||
result.Row1.X = inverse[1, 0]; result.Row1.Y = inverse[1, 1];
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat2 operator *(Mat2 left, Mat2 right)
|
||||
{
|
||||
Mat2 result = default;
|
||||
result.Row0 = left.Row0.X * right.Row0 + left.Row0.Y * right.Row1;
|
||||
result.Row1 = left.Row1.X * right.Row0 + left.Row1.Y * right.Row1;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat2 operator *(Mat2 mat, float scale) =>
|
||||
new Mat2(mat.Row0 * scale, mat.Row1 * scale);
|
||||
|
||||
public static bool operator ==(Mat2 A, Mat2 B) => A.Equals(B);
|
||||
public static bool operator !=(Mat2 A, Mat2 B) => !A.Equals(B);
|
||||
|
||||
public bool Equals(Mat2 other) =>
|
||||
Row0 == other.Row0 && Row1 == other.Row1;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override string ToString() => $"({Row0}; {Row1})";
|
||||
public string ToString(int d) => $"({Row0.ToString(d)}; {Row1.ToString(d)})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Mat3
|
||||
{
|
||||
[FieldOffset(0x00)] public Vec3 Row0;
|
||||
[FieldOffset(0x0C)] public Vec3 Row1;
|
||||
[FieldOffset(0x18)] public Vec3 Row2;
|
||||
|
||||
public Vec3 Column0 { get => new Vec3(Row0.X, Row1.X, Row2.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; } }
|
||||
public Vec3 Column1 { get => new Vec3(Row0.Y, Row1.X, Row2.Y);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; } }
|
||||
public Vec3 Column2 { get => new Vec3(Row0.Z, Row1.Z, Row2.Z);
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z;} }
|
||||
|
||||
public static Mat3 Identity => new Mat3(new Vec3(1.0f, 0.0f, 0.0f),
|
||||
new Vec3(0.0f, 1.0f, 0.0f),
|
||||
new Vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
public Mat3(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
|
||||
{ Row0 = new Vec3(m00, m01, m02); Row1 = new Vec3(m10, m11, m12); Row2 = new Vec3(m20, m21, m22);}
|
||||
|
||||
public Mat3(Vec3 row0, Vec3 row1, Vec3 row2)
|
||||
{ Row0 = row0; Row1 = row1; Row2 = row2; }
|
||||
|
||||
public Mat3(Mat4 mat)
|
||||
{ Row0 = new Vec3(mat.Row0); Row1 = new Vec3(mat.Row1); Row2 = new Vec3(mat.Row2); }
|
||||
|
||||
public Mat3(Quat q)
|
||||
{
|
||||
float qx = q.X;
|
||||
float qy = q.Y;
|
||||
float qz = q.Z;
|
||||
float qw = q.W;
|
||||
float g = qx + qx;
|
||||
float h = qy + qy;
|
||||
float k = qz + qz;
|
||||
float a = qx * g;
|
||||
float l = qx * h;
|
||||
float m = qy * h;
|
||||
qx *= k;
|
||||
qy *= k;
|
||||
qz *= k;
|
||||
|
||||
Row0 = new Vec3(1.0f - qz - m, l - qw * k, qx + qw * h);
|
||||
Row1 = new Vec3( l + qw * k, 1.0f - qz - a, qy - qw * g);
|
||||
Row2 = new Vec3( qx - qw * h, qy + qw * g, 1.0f - m - a);
|
||||
}
|
||||
|
||||
public Quat ToQuat()
|
||||
{
|
||||
Vec3 row0 = Row0;
|
||||
Vec3 row1 = Row1;
|
||||
Vec3 row2 = Row2;
|
||||
|
||||
Quat q = default;
|
||||
var trace = 0.25 * (row0.X + row1.Y + row2.Z+ 1.0);
|
||||
|
||||
if (trace > 0)
|
||||
{
|
||||
double sq = System.Math.Sqrt(trace);
|
||||
|
||||
q.W = (float)sq;
|
||||
sq = 1.0 / (4.0 * sq);
|
||||
q.X = (float)((row1.Z - row2.Y) * sq);
|
||||
q.Y = (float)((row2.X - row0.Z) * sq);
|
||||
q.Z = (float)((row0.Y - row1.X) * sq);
|
||||
}
|
||||
else if (row0.X > row1.Y && row0.X > row2.Z)
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row0.X - row1.Y - row2.Z);
|
||||
|
||||
q.X = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row2.Y - row1.Z) * sq);
|
||||
q.Y = (float)((row1.X + row0.Y) * sq);
|
||||
q.Z = (float)((row2.X + row0.Z) * sq);
|
||||
}
|
||||
else if (row1.Y > row2.Z)
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row1.Y - row0.X - row2.Z);
|
||||
|
||||
q.Y = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row2.X - row0.Z) * sq);
|
||||
q.X = (float)((row1.X + row0.Y) * sq);
|
||||
q.Z = (float)((row2.Y + row1.Z) * sq);
|
||||
}
|
||||
else
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row2.Z - row0.X - row1.Y);
|
||||
|
||||
q.Z = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row1.X - row0.Y) * sq);
|
||||
q.X = (float)((row2.X + row0.Z) * sq);
|
||||
q.Y = (float)((row2.Y + row1.Z) * sq);
|
||||
}
|
||||
|
||||
return q.Normalized;
|
||||
}
|
||||
|
||||
public Mat3 Invert() => -this;
|
||||
|
||||
public static Mat3 operator +(Mat3 left, Mat3 right)
|
||||
{ left.Row0 += right.Row0; left.Row1 += right.Row1; left.Row2 += right.Row2; return left; }
|
||||
|
||||
public static Mat3 operator -(Mat3 left, Mat3 right)
|
||||
{ left.Row0 -= right.Row0; left.Row1 -= right.Row1; left.Row2 -= right.Row2; return left; }
|
||||
|
||||
public static Mat3 operator -(Mat3 mat)
|
||||
{
|
||||
int[] colIdx = { 0, 0, 0 };
|
||||
int[] rowIdx = { 0, 0, 0 };
|
||||
int[] pivotIdx = { -1, -1, -1 };
|
||||
|
||||
Mat3 result = mat;
|
||||
float[,] inverse =
|
||||
{
|
||||
{ mat.Row0.X, mat.Row0.Y, mat.Row0.Z },
|
||||
{ mat.Row1.X, mat.Row1.Y, mat.Row1.Z },
|
||||
{ mat.Row2.X, mat.Row2.Y, mat.Row2.Z }
|
||||
};
|
||||
int icol = 0;
|
||||
int irow = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
float maxPivot = 0.0f;
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
if (pivotIdx[j] == 0) continue;
|
||||
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
if (pivotIdx[k] == -1)
|
||||
{
|
||||
float absVal = System.Math.Abs(inverse[j, k]);
|
||||
if (absVal > maxPivot)
|
||||
{
|
||||
maxPivot = absVal;
|
||||
irow = j;
|
||||
icol = k;
|
||||
}
|
||||
}
|
||||
else if (pivotIdx[k] > 0)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
pivotIdx[icol]++;
|
||||
|
||||
if (irow != icol)
|
||||
for (int k = 0; k < 3; k++)
|
||||
{ float t = inverse[irow, k]; inverse[irow, k] = inverse[icol, k]; inverse[icol, k] = t; }
|
||||
|
||||
rowIdx[i] = irow;
|
||||
colIdx[i] = icol;
|
||||
|
||||
float pivot = inverse[icol, icol];
|
||||
|
||||
float oneOverPivot = 1.0f / pivot;
|
||||
inverse[icol, icol] = 1.0f;
|
||||
for (int k = 0; k < 3; k++)
|
||||
inverse[icol, k] *= oneOverPivot;
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
if (icol == j) continue;
|
||||
|
||||
float f = inverse[j, icol];
|
||||
inverse[j, icol] = 0.0f;
|
||||
for (int k = 0; k < 3; k++)
|
||||
inverse[j, k] -= inverse[icol, k] * f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 2; j >= 0; j--)
|
||||
{
|
||||
int ir = rowIdx[j];
|
||||
int ic = colIdx[j];
|
||||
for (int k = 0; k < 3; k++)
|
||||
{ float t = inverse[k, ic]; inverse[k, ic] = inverse[k, ir]; inverse[k, ir] = t; }
|
||||
}
|
||||
|
||||
result.Row0.X = inverse[0, 0]; result.Row0.Y = inverse[0, 1]; result.Row0.Z = inverse[0, 2];
|
||||
result.Row1.X = inverse[1, 0]; result.Row1.Y = inverse[1, 1]; result.Row1.Z = inverse[1, 2];
|
||||
result.Row2.X = inverse[2, 0]; result.Row2.Y = inverse[2, 1]; result.Row2.Z = inverse[2, 2];
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat3 operator *(Mat3 left, Mat3 right)
|
||||
{
|
||||
Mat3 result = default;
|
||||
result.Row0 = left.Row0.X * right.Row0 + left.Row0.Y * right.Row1 + left.Row0.Z * right.Row2;
|
||||
result.Row1 = left.Row1.X * right.Row0 + left.Row1.Y * right.Row1 + left.Row1.Z * right.Row2;
|
||||
result.Row2 = left.Row2.X * right.Row0 + left.Row2.Y * right.Row1 + left.Row2.Z * right.Row2;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat3 operator *(Mat3 mat, float scale) =>
|
||||
new Mat3(mat.Row0 * scale, mat.Row1 * scale, mat.Row2 * scale);
|
||||
|
||||
public static bool operator ==(Mat3 A, Mat3 B) => A.Equals(B);
|
||||
public static bool operator !=(Mat3 A, Mat3 B) => !A.Equals(B);
|
||||
|
||||
public bool Equals(Mat3 other) =>
|
||||
Row0 == other.Row0 && Row1 == other.Row1 && Row2 == other.Row2;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override string ToString() => $"({Row0}; {Row1}; {Row2})";
|
||||
public string ToString(int d) => $"({Row0.ToString(d)}; {Row1.ToString(d)}; {Row2.ToString(d)})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Mat4
|
||||
{
|
||||
[FieldOffset(0x00)] public Vec4 Row0;
|
||||
[FieldOffset(0x10)] public Vec4 Row1;
|
||||
[FieldOffset(0x20)] public Vec4 Row2;
|
||||
[FieldOffset(0x30)] public Vec4 Row3;
|
||||
|
||||
public Vec4 Column0 { get => new Vec4(Row0.X, Row1.X, Row2.X, Row3.X);
|
||||
set { Row0.X = value.X; Row1.X = value.Y; Row2.X = value.Z; Row3.X = value.W; } }
|
||||
public Vec4 Column1 { get => new Vec4(Row0.Y, Row1.X, Row2.Y, Row3.Y);
|
||||
set { Row0.Y = value.X; Row1.Y = value.Y; Row2.Y = value.Z; Row3.Y = value.W; } }
|
||||
public Vec4 Column2 { get => new Vec4(Row0.Z, Row1.Z, Row2.Z, Row3.Z);
|
||||
set { Row0.Z = value.X; Row1.Z = value.Y; Row2.Z = value.Z; Row3.Z = value.W; } }
|
||||
public Vec4 Column3 { get => new Vec4(Row0.W, Row1.W, Row2.W, Row3.W);
|
||||
set { Row0.W = value.X; Row1.W = value.Y; Row2.W = value.Z; Row3.W = value.W; } }
|
||||
|
||||
public static Mat4 Identity => new Mat4(new Vec4(1.0f, 0.0f, 0.0f, 0.0f),
|
||||
new Vec4(0.0f, 1.0f, 0.0f, 0.0f),
|
||||
new Vec4(0.0f, 0.0f, 1.0f, 0.0f),
|
||||
new Vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
public Mat4(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13,
|
||||
float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
|
||||
{ Row0 = new Vec4(m00, m01, m02, m03); Row1 = new Vec4(m10, m11, m12, m13);
|
||||
Row2 = new Vec4(m20, m21, m22, m23); Row3 = new Vec4(m30, m31, m32, m33); }
|
||||
|
||||
public Mat4(Vec4 row0, Vec4 row1, Vec4 row2, Vec4 row3)
|
||||
{ Row0 = row0; Row1 = row1; Row2 = row2; Row3 = row3; }
|
||||
|
||||
public Mat4(Mat3 mat)
|
||||
{ Row0 = new Vec4(mat.Row0); Row1 = new Vec4(mat.Row1);
|
||||
Row2 = new Vec4(mat.Row2); Row3 = new Vec4(0.0f, 0.0f, 0.0f, 1.0f); }
|
||||
|
||||
public Mat4(Quat q)
|
||||
{ Row0 = Row1 = Row2 = Row3 = default; FromQuat(q); }
|
||||
|
||||
public Mat4(Quat q, Vec3 t)
|
||||
{ Row0 = Row1 = Row2 = Row3 = default; FromQuat(q); Row3 = new Vec4(t, 1.0f); }
|
||||
|
||||
public Mat4(Quat q, Vec4 t)
|
||||
{ Row0 = Row1 = Row2 = Row3 = default; FromQuat(q); Row3 = t; }
|
||||
|
||||
private void FromQuat(Quat q)
|
||||
{
|
||||
float qx = q.X;
|
||||
float qy = q.Y;
|
||||
float qz = q.Z;
|
||||
float qw = q.W;
|
||||
|
||||
float g = qx + qx;
|
||||
float h = qy + qy;
|
||||
float k = qz + qz;
|
||||
float a = qx * g;
|
||||
float l = qx * h;
|
||||
float m = qy * h;
|
||||
qx *= k;
|
||||
qy *= k;
|
||||
qz *= k;
|
||||
|
||||
Row0 = new Vec4(1.0f - (qz + m), l - qw * k , qx + qw * h , 0.0f);
|
||||
Row1 = new Vec4( l + qw * k , 1.0f - (qz + a), qy - qw * g , 0.0f);
|
||||
Row2 = new Vec4( qx - qw * h , qy + qw * g , 1.0f - (a + m), 0.0f);
|
||||
Row3 = new Vec4(0.0f , 0.0f , 0.0f , 1.0f);
|
||||
}
|
||||
|
||||
public Quat ToQuat()
|
||||
{
|
||||
Vec4 row0 = Row0;
|
||||
Vec4 row1 = Row1;
|
||||
Vec4 row2 = Row2;
|
||||
|
||||
Quat q = default;
|
||||
var trace = 0.25 * (row0.X + row1.Y + row2.Z+ 1.0);
|
||||
|
||||
if (trace > 0)
|
||||
{
|
||||
double sq = System.Math.Sqrt(trace);
|
||||
|
||||
q.W = (float)sq;
|
||||
sq = 1.0 / (4.0 * sq);
|
||||
q.X = (float)((row1.Z - row2.Y) * sq);
|
||||
q.Y = (float)((row2.X - row0.Z) * sq);
|
||||
q.Z = (float)((row0.Y - row1.X) * sq);
|
||||
}
|
||||
else if (row0.X > row1.Y && row0.X > row2.Z)
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row0.X - row1.Y - row2.Z);
|
||||
|
||||
q.X = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row2.Y - row1.Z) * sq);
|
||||
q.Y = (float)((row1.X + row0.Y) * sq);
|
||||
q.Z = (float)((row2.X + row0.Z) * sq);
|
||||
}
|
||||
else if (row1.Y > row2.Z)
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row1.Y - row0.X - row2.Z);
|
||||
|
||||
q.Y = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row2.X - row0.Z) * sq);
|
||||
q.X = (float)((row1.X + row0.Y) * sq);
|
||||
q.Z = (float)((row2.Y + row1.Z) * sq);
|
||||
}
|
||||
else
|
||||
{
|
||||
double sq = 2.0 * System.Math.Sqrt(1.0 + row2.Z - row0.X - row1.Y);
|
||||
|
||||
q.Z = (float)(0.25 * sq);
|
||||
sq = 1.0 / sq;
|
||||
q.W = (float)((row1.X - row0.Y) * sq);
|
||||
q.X = (float)((row2.X + row0.Z) * sq);
|
||||
q.Y = (float)((row2.Y + row1.Z) * sq);
|
||||
}
|
||||
|
||||
return q.Normalized;
|
||||
}
|
||||
|
||||
public Mat4 Invert() => -this;
|
||||
|
||||
public Mat4 Translate(Vec3 vec)
|
||||
{ Row3 = new Vec4(vec, 1.0f) * this; return this; }
|
||||
|
||||
public Mat4 Translate(Vec4 vec)
|
||||
{ Row3 = vec * this; return this; }
|
||||
|
||||
public static Mat4 operator +(Mat4 left, Mat4 right)
|
||||
{ left.Row0 += right.Row0; left.Row1 += right.Row1;
|
||||
left.Row2 += right.Row2; left.Row3 += right.Row3; return left; }
|
||||
|
||||
public static Mat4 operator -(Mat4 left, Mat4 right)
|
||||
{ left.Row0 -= right.Row0; left.Row1 -= right.Row1;
|
||||
left.Row2 -= right.Row2; left.Row3 -= right.Row3; return left; }
|
||||
|
||||
public static Mat4 operator -(Mat4 mat)
|
||||
{
|
||||
int[] colIdx = { 0, 0, 0, 0 };
|
||||
int[] rowIdx = { 0, 0, 0, 0 };
|
||||
int[] pivotIdx = { -1, -1, -1, -1 };
|
||||
|
||||
Mat4 result = mat;
|
||||
float[,] inverse =
|
||||
{
|
||||
{ mat.Row0.X, mat.Row0.Y, mat.Row0.Z, mat.Row0.W },
|
||||
{ mat.Row1.X, mat.Row1.Y, mat.Row1.Z, mat.Row1.W },
|
||||
{ mat.Row2.X, mat.Row2.Y, mat.Row2.Z, mat.Row2.W },
|
||||
{ mat.Row3.X, mat.Row3.Y, mat.Row3.Z, mat.Row3.W }
|
||||
};
|
||||
int icol = 0;
|
||||
int irow = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float maxPivot = 0.0f;
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (pivotIdx[j] == 0) continue;
|
||||
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
if (pivotIdx[k] == -1)
|
||||
{
|
||||
float absVal = System.Math.Abs(inverse[j, k]);
|
||||
if (absVal > maxPivot)
|
||||
{
|
||||
maxPivot = absVal;
|
||||
irow = j;
|
||||
icol = k;
|
||||
}
|
||||
}
|
||||
else if (pivotIdx[k] > 0)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
pivotIdx[icol]++;
|
||||
|
||||
if (irow != icol)
|
||||
for (int k = 0; k < 4; k++)
|
||||
{ float t = inverse[irow, k]; inverse[irow, k] = inverse[icol, k]; inverse[icol, k] = t; }
|
||||
|
||||
rowIdx[i] = irow;
|
||||
colIdx[i] = icol;
|
||||
|
||||
float pivot = inverse[icol, icol];
|
||||
|
||||
float oneOverPivot = 1.0f / pivot;
|
||||
inverse[icol, icol] = 1.0f;
|
||||
for (int k = 0; k < 4; k++)
|
||||
inverse[icol, k] *= oneOverPivot;
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (icol == j) continue;
|
||||
|
||||
float f = inverse[j, icol];
|
||||
inverse[j, icol] = 0.0f;
|
||||
for (int k = 0; k < 4; k++)
|
||||
inverse[j, k] -= inverse[icol, k] * f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 3; j >= 0; j--)
|
||||
{
|
||||
int ir = rowIdx[j];
|
||||
int ic = colIdx[j];
|
||||
for (int k = 0; k < 4; k++)
|
||||
{ float t = inverse[k, ic]; inverse[k, ic] = inverse[k, ir]; inverse[k, ir] = t; }
|
||||
}
|
||||
|
||||
result.Row0.X = inverse[0, 0]; result.Row0.Y = inverse[0, 1];
|
||||
result.Row0.Z = inverse[0, 2]; result.Row0.W = inverse[0, 3];
|
||||
result.Row1.X = inverse[1, 0]; result.Row1.Y = inverse[1, 1];
|
||||
result.Row1.Z = inverse[1, 2]; result.Row1.W = inverse[1, 3];
|
||||
result.Row2.X = inverse[2, 0]; result.Row2.Y = inverse[2, 1];
|
||||
result.Row2.Z = inverse[2, 2]; result.Row2.W = inverse[2, 3];
|
||||
result.Row3.X = inverse[3, 0]; result.Row3.Y = inverse[3, 1];
|
||||
result.Row3.Z = inverse[3, 2]; result.Row3.W = inverse[3, 3];
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat4 operator *(Mat4 left, Mat4 right)
|
||||
{
|
||||
Mat4 result = default;
|
||||
result.Row0 = left.Row0.X * right.Row0 + left.Row0.Y * right.Row1
|
||||
+ left.Row0.Z * right.Row2 + left.Row0.W * right.Row3;
|
||||
result.Row1 = left.Row1.X * right.Row0 + left.Row1.Y * right.Row1
|
||||
+ left.Row1.Z * right.Row2 + left.Row1.W * right.Row3;
|
||||
result.Row2 = left.Row2.X * right.Row0 + left.Row2.Y * right.Row1
|
||||
+ left.Row2.Z * right.Row2 + left.Row2.W * right.Row3;
|
||||
result.Row3 = left.Row3.X * right.Row0 + left.Row3.Y * right.Row1
|
||||
+ left.Row3.Z * right.Row2 + left.Row3.W * right.Row3;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mat4 operator *(Mat4 mat, float scale) =>
|
||||
new Mat4(mat.Row0 * scale, mat.Row1 * scale, mat.Row2 * scale, mat.Row3 * scale);
|
||||
|
||||
public static bool operator ==(Mat4 A, Mat4 B) => A.Equals(B);
|
||||
public static bool operator !=(Mat4 A, Mat4 B) => !A.Equals(B);
|
||||
|
||||
public bool Equals(Mat4 other) =>
|
||||
Row0 == other.Row0 && Row1 == other.Row1 && Row2 == other.Row2 && Row3 == other.Row3;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override string ToString() => $"({Row0}; {Row1}; {Row2}; {Row3})";
|
||||
public string ToString(int d) => $"({Row0.ToString(d)}; {Row1.ToString(d)}; {Row2.ToString(d)}; {Row3.ToString(d)})";
|
||||
}
|
||||
}
|
||||
+29
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -36,14 +36,23 @@ namespace KKdBaseLib
|
||||
{ get => Object is MsgPack[] Array ? Array[index] : default;
|
||||
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
|
||||
|
||||
public MsgPack this[long index]
|
||||
{ get => Object is MsgPack[] Array ? Array[index] : default;
|
||||
set { if (Object is MsgPack[] Array) { Array[index] = value; Object = Array; } } }
|
||||
|
||||
public MsgPack this[string key]
|
||||
{ get => Object is KKdList<MsgPack> List ? List[ElementIndex(key)] : default;
|
||||
set { if (Object is KKdList<MsgPack> List && value.Object != null)
|
||||
set { if (Object is KKdList<MsgPack> List && value.Object != null)
|
||||
{ List.Add(value); Object = List; } } }
|
||||
|
||||
public MsgPack this[string key, bool array]
|
||||
{ get { if (!array) return this[key];
|
||||
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
|
||||
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
|
||||
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
|
||||
|
||||
public MsgPack this[bool startsWith, string key]
|
||||
{ get { if (Object is KKdList<MsgPack> List) { MsgPack MsgPack =
|
||||
List[startsWith ? ElementIndexStartsWith(key) : ElementIndex(key)];
|
||||
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
|
||||
|
||||
public MsgPack Add(MsgPack obj)
|
||||
@@ -373,6 +382,17 @@ namespace KKdBaseLib
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool ContainsKeyStartsWith(string name) => ElementIndexStartsWith(name) > -1;
|
||||
|
||||
public int ElementIndexStartsWith(string name)
|
||||
{
|
||||
if (List.IsNull) return -1;
|
||||
|
||||
for (int i = 0; i < List.Count; i++)
|
||||
if (List[i].Name.StartsWith(name)) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public struct Ext
|
||||
{
|
||||
@@ -380,4 +400,10 @@ namespace KKdBaseLib
|
||||
public byte[] Data;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMsgPack : INull
|
||||
{
|
||||
//public void ReadMsgPack();
|
||||
public MsgPack WriteMsgPack(string name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Pointer<T>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Quat
|
||||
{
|
||||
[FieldOffset(0x00)] public float X;
|
||||
[FieldOffset(0x04)] public float Y;
|
||||
[FieldOffset(0x08)] public float Z;
|
||||
[FieldOffset(0x0C)] public float W;
|
||||
|
||||
public static Quat Identity => new Quat(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
public Quat(float X, float Y, float Z)
|
||||
{
|
||||
X *= 0.5f;
|
||||
Y *= 0.5f;
|
||||
Z *= 0.5f;
|
||||
|
||||
var c1 = (float)System.Math.Cos(X);
|
||||
var c2 = (float)System.Math.Cos(Y);
|
||||
var c3 = (float)System.Math.Cos(Z);
|
||||
var s1 = (float)System.Math.Sin(X);
|
||||
var s2 = (float)System.Math.Sin(Y);
|
||||
var s3 = (float)System.Math.Sin(Z);
|
||||
|
||||
this.X = s1 * c2 * c3 + c1 * s2 * s3;
|
||||
this.Y = c1 * s2 * c3 - s1 * c2 * s3;
|
||||
this.Z = c1 * c2 * s3 + s1 * s2 * c3;
|
||||
W = c1 * c2 * c3 - s1 * s2 * s3;
|
||||
}
|
||||
|
||||
public Quat(Vec3 vec) : this(vec.X, vec.Y, vec.Z)
|
||||
{ }
|
||||
|
||||
public Quat(float X, float Y, float Z, float W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public Quat(Vec3 vec, float W)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; this.W = W; }
|
||||
|
||||
public Quat(Vec4 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; W = vec.W; }
|
||||
|
||||
public Vec3 XYZ { get => new Vec3(X, Y, Z); set { X = value.X; Y = value.Y; Z = value.Z; } }
|
||||
|
||||
public float Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
|
||||
public float LengthSquared => X * X + Y * Y + Z * Z + W * W;
|
||||
public Quat Normalized => new Quat(X, Y, Z, W) * (Length == 0.0f ? 1.0f : (1.0f / Length));
|
||||
public Vec3 Euler { get
|
||||
{
|
||||
if (LengthSquared == 0) return default;
|
||||
|
||||
const float SINGULARITY_THRESHOLD = 0.4999995f;
|
||||
const float HalfPI = (float)(System.Math.PI * 0.5);
|
||||
|
||||
float sqx = X * X, sqy = Y * Y, sqz = Z * Z, sqw = W * W;
|
||||
float unit = sqx + sqy + sqz + sqw;
|
||||
float singularityTest = X * Z + Y * W;
|
||||
|
||||
if (singularityTest > SINGULARITY_THRESHOLD * unit)
|
||||
return new Vec3(0.0f, HalfPI, (float)(System.Math.Atan2(X, W) * 2.0));
|
||||
else if (singularityTest < -SINGULARITY_THRESHOLD * unit)
|
||||
return new Vec3(0.0f, -HalfPI, -(float)(System.Math.Atan2(X, W) * 2.0));
|
||||
else
|
||||
return new Vec3((float)System.Math.Atan2(2 * (X * W - Y * Z), sqw - sqx - sqy + sqz),
|
||||
(float)System.Math.Asin (2 * singularityTest / unit),
|
||||
(float)System.Math.Atan2(2 * (Z * W - X * Y), sqw + sqx - sqy - sqz));
|
||||
}
|
||||
}
|
||||
public Vec3 EulerDeg { get
|
||||
{
|
||||
if (LengthSquared == 0) return default;
|
||||
|
||||
const float SINGULARITY_THRESHOLD = 0.4999995f;
|
||||
const float HalfPI = (float)(System.Math.PI * 0.5);
|
||||
|
||||
float sqx = X * X, sqy = Y * Y, sqz = Z * Z, sqw = W * W;
|
||||
float unit = sqx + sqy + sqz + sqw;
|
||||
float singularityTest = X * Z + Y * W;
|
||||
|
||||
if (singularityTest > SINGULARITY_THRESHOLD * unit)
|
||||
return new Vec3(0.0f, HalfPI, (float)(System.Math.Atan2(X, W) * 2.0));
|
||||
else if (singularityTest < -SINGULARITY_THRESHOLD * unit)
|
||||
return new Vec3(0.0f, -HalfPI, -(float)(System.Math.Atan2(X, W) * 2.0));
|
||||
else
|
||||
return new Vec3((float)System.Math.Atan2(2 * (X * W - Y * Z), sqw - sqx - sqy + sqz),
|
||||
(float)System.Math.Asin (2 * singularityTest / unit),
|
||||
(float)System.Math.Atan2(2 * (Z * W - X * Y), sqw + sqx - sqy - sqz))
|
||||
* (float)(180.0 / System.Math.PI);
|
||||
}
|
||||
}
|
||||
|
||||
public static Quat operator +(Quat left, Quat right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; left.W += right.W; return left; }
|
||||
public static Quat operator -(Quat left, Quat right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; left.W -= right.W; return left; }
|
||||
public static Quat operator -(Quat quat) =>
|
||||
new Quat(-quat.X, -quat.Y, -quat.Z, quat.W);
|
||||
public static Quat operator *( Quat quat, float scale)
|
||||
{ quat.X *= scale ; quat.Y *= scale ; quat.Z *= scale ; quat.W *= scale ; return quat; }
|
||||
public static Quat operator *(float scale, Quat quat)
|
||||
{ quat.X *= scale ; quat.Y *= scale ; quat.Z *= scale ; quat.W *= scale ; return quat; }
|
||||
public static Quat operator *( Quat quat, Vec4 scale)
|
||||
{ quat.X *= scale.X; quat.Y *= scale.Y; quat.Z *= scale.Z; quat.W *= scale.W; return quat; }
|
||||
public static Quat operator *( Quat left, Quat right) =>
|
||||
new Quat(right.W * left.XYZ + left.W * right.XYZ + Vec3.Cross(left.XYZ, right.XYZ),
|
||||
left.W * right.W - Vec3.Dot(left.XYZ, right.XYZ)).Normalized;
|
||||
public static Quat operator /( Quat left, Quat right) =>
|
||||
left * -right;
|
||||
public static bool operator ==(Quat A, Quat B) => A.Equals(B);
|
||||
public static bool operator !=(Quat A, Quat B) => !A.Equals(B);
|
||||
|
||||
public static float Distance (Vec4 left, Vec4 right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W)).Sqrt();
|
||||
public static float DistanceSquared(Vec4 left, Vec4 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W);
|
||||
public static float Dot(Vec4 left, Vec4 right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
|
||||
public Vec4 Round( ) =>
|
||||
new Vec4 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Vec4 Round(int d) =>
|
||||
new Vec4 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
|
||||
public static Quat Slerp(Quat q1, Quat q2, float blend)
|
||||
{
|
||||
if (q1.LengthSquared == 0.0f)
|
||||
return q2.LengthSquared == 0.0f ? Identity : q2;
|
||||
else if (q2.LengthSquared == 0.0f)
|
||||
return q1;
|
||||
|
||||
float cosHalfAngle = Vec4.Dot((Vec4)q1, (Vec4)q2);
|
||||
|
||||
if (cosHalfAngle >= 1.0f || cosHalfAngle <= -1.0f)
|
||||
return q1;
|
||||
|
||||
if (cosHalfAngle < 0.0f)
|
||||
{
|
||||
q2.XYZ = -q2.XYZ;
|
||||
q2.W = -q2.W;
|
||||
cosHalfAngle = -cosHalfAngle;
|
||||
}
|
||||
|
||||
float blendA;
|
||||
float blendB;
|
||||
if (cosHalfAngle < 0.99f)
|
||||
{
|
||||
float halfAngle = (float)System.Math.Acos(cosHalfAngle);
|
||||
float sinHalfAngle = (float)System.Math.Sin(halfAngle);
|
||||
float oneOverSinHalfAngle = 1.0f / sinHalfAngle;
|
||||
blendA = (float)System.Math.Sin(halfAngle * (1.0f - blend)) * oneOverSinHalfAngle;
|
||||
blendB = (float)System.Math.Sin(halfAngle * blend) * oneOverSinHalfAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
blendA = 1.0f - blend;
|
||||
blendB = blend;
|
||||
}
|
||||
|
||||
Quat result = new Quat(blendA * q1.XYZ + blendB * q2.XYZ, blendA * q1.W + blendB * q2.W);
|
||||
return result.Normalized;
|
||||
}
|
||||
|
||||
public static explicit operator Vec4(Quat quat) =>
|
||||
new Vec4(quat.XYZ, quat.W);
|
||||
public static explicit operator Quat(Vec4 vec) =>
|
||||
new Quat( vec.XYZ, vec.W);
|
||||
|
||||
public bool Equals(Vec4 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z && W == other.W;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
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)})";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib.Tables
|
||||
{
|
||||
public struct ButtonSE
|
||||
{
|
||||
@@ -137,13 +137,13 @@
|
||||
public string Name;
|
||||
public string SEName;
|
||||
}
|
||||
|
||||
|
||||
public struct TableDate : INull
|
||||
{
|
||||
private int year;
|
||||
private int month;
|
||||
private int day;
|
||||
|
||||
|
||||
public int Year { get => year; set { year = value; CheckDate(); } }
|
||||
public int Month { get => month; set { month = value; CheckDate(); } }
|
||||
public int Day { get => day; set { day = value; CheckDate(); } }
|
||||
@@ -157,7 +157,7 @@
|
||||
public void SN () => Year = -1;
|
||||
public void SDL() => Year = 2000;
|
||||
public void SDU() => Year = 2029;
|
||||
|
||||
|
||||
public void SV(int? ymd, bool setDefaultUpper)
|
||||
{
|
||||
if (!setDefaultUpper) SDL();
|
||||
@@ -170,9 +170,9 @@
|
||||
CheckDate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Int => NotNull ? (Year * 100 + Month) * 100 + Day : -1;
|
||||
|
||||
|
||||
private void CheckDate()
|
||||
{
|
||||
if (year == -1 || month == -1 || day == -1) { year = -1; month = -1; day = -1; return; }
|
||||
@@ -188,8 +188,8 @@
|
||||
else if (day > 29 && month == 2 && year % 4 == 0) day = 29;
|
||||
else if (day > 28 && month == 2 && year % 4 != 0) day = 28;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString() =>
|
||||
$"{Year.ToString("d4")}-{Month.ToString("d2")}-{Day.ToString("d2")}";
|
||||
$"{Year:d4}-{Month:d2}-{Day:d2}";
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -7,10 +7,13 @@ namespace KKdBaseLib
|
||||
public readonly static Encoding ShiftJIS = Encoding.GetEncoding(932);
|
||||
|
||||
public static string ToASCII(this byte[] Array) => Encoding.ASCII.GetString(Array ?? new byte[0]);
|
||||
public static string ToUTF8 (this byte[] Array) => Encoding.UTF8 .GetString(Array ?? new byte[0]);
|
||||
public static byte[] ToASCII(this string Data ) => Encoding.ASCII.GetBytes (Data ?? "" );
|
||||
public static byte[] ToUTF8 (this string Data ) => Encoding.UTF8 .GetBytes (Data ?? "" );
|
||||
public static byte[] ToASCII(this char[] Data ) => Encoding.ASCII.GetBytes (Data ?? new char[0]);
|
||||
public static string ToSJIS (this byte[] Array) => ShiftJIS.GetString(Array ?? new byte[0]);
|
||||
public static byte[] ToSJIS (this string Data ) => ShiftJIS.GetBytes (Data ?? "" );
|
||||
public static byte[] ToSJIS (this char[] Data ) => ShiftJIS.GetBytes (Data ?? new char[0]);
|
||||
public static string ToUTF8 (this byte[] Array) => Encoding.UTF8 .GetString(Array ?? new byte[0]);
|
||||
public static byte[] ToUTF8 (this string Data ) => Encoding.UTF8 .GetBytes (Data ?? "" );
|
||||
public static byte[] ToUTF8 (this char[] Data ) => Encoding.UTF8 .GetBytes (Data ?? new char[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector2<T> : INull
|
||||
public struct Vec2<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
|
||||
public Vector2(T x, T y)
|
||||
public Vec2(T x, T y)
|
||||
{ X = x; Y = y; }
|
||||
|
||||
public bool IsNull => X == null && Y == null;
|
||||
@@ -14,13 +14,13 @@
|
||||
public override string ToString() => $"({X}; {Y})";
|
||||
}
|
||||
|
||||
public struct Vector3<T> : INull
|
||||
public struct Vec3<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
public T Z;
|
||||
|
||||
public Vector3(T x, T y, T z)
|
||||
public Vec3(T x, T y, T z)
|
||||
{ X = x; Y = y; Z = z; }
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null;
|
||||
@@ -29,14 +29,14 @@
|
||||
public override string ToString() => $"({X}; {Y}; {Z})";
|
||||
}
|
||||
|
||||
public struct Vector4<T> : INull
|
||||
public struct Vec4<T> : INull
|
||||
{
|
||||
public T X;
|
||||
public T Y;
|
||||
public T Z;
|
||||
public T W;
|
||||
|
||||
public Vector4(T x, T y, T z, T w)
|
||||
public Vec4(T x, T y, T z, T w)
|
||||
{ X = x; Y = y; Z = z; W = w; }
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null && W == null;
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Vec2
|
||||
{
|
||||
[FieldOffset(0x00)] public float X;
|
||||
[FieldOffset(0x04)] public float Y;
|
||||
|
||||
public Vec2(float val)
|
||||
{ X = val; Y = val; }
|
||||
|
||||
public Vec2(float X, float Y)
|
||||
{ this.X = X; this.Y = Y; }
|
||||
|
||||
public Vec2(Vec4 vec)
|
||||
{ X = vec.X; Y = vec.Y; }
|
||||
|
||||
public float Length => (X * X + Y * Y).Sqrt();
|
||||
public float LengthSquared => X * X + Y * Y;
|
||||
public Vec2 Normalized => this = Length == 0.0f ? new Vec2() : this * (1.0f / Length);
|
||||
|
||||
public static Vec2 operator +(Vec2 left, Vec2 right)
|
||||
{ left.X += right.X; left.Y += right.Y; return left; }
|
||||
public static Vec2 operator -(Vec2 left, Vec2 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; return left; }
|
||||
public static Vec2 operator -(Vec2 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; return vec; }
|
||||
public static Vec2 operator *(Vec2 vec, float scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; return vec; }
|
||||
public static Vec2 operator *( float scale, Vec2 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; return vec; }
|
||||
public static Vec2 operator *(Vec2 vec, Vec2 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; return vec; }
|
||||
public static Vec2 operator /(Vec2 vec, float scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; return vec; }
|
||||
public static Vec2 operator /(Vec2 vec, Vec2 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; return vec; }
|
||||
public static bool operator ==(Vec2 A, Vec2 B) => A.X == B.X && A.Y == B.Y;
|
||||
public static bool operator !=(Vec2 A, Vec2 B) => A.X != B.X || A.Y != B.Y;
|
||||
|
||||
public static Vec2 operator *(Vec2 vec, Mat2 mat) =>
|
||||
new Vec2(vec.X * mat.Row0.X + vec.Y * mat.Row1.X,
|
||||
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y);
|
||||
|
||||
public static float Distance (Vec2 left, Vec2 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y).Sqrt();
|
||||
public static float DistanceSquared(Vec2 left, Vec2 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y);
|
||||
public static float Dot(Vec2 left, Vec2 right) =>
|
||||
left.X * right.X + left.Y * right.Y;
|
||||
public static Vec2 Lerp(Vec2 a, Vec2 b, float blend) =>
|
||||
new Vec2 { X = blend * (b.X - a.X) + a.X, Y = blend * (b.Y - a.Y) + a.Y };
|
||||
public static Vec2 Lerp(Vec2 a, Vec2 b, Vec2 blend) =>
|
||||
new Vec2 { X = blend.X * (b.X - a.X) + a.X, Y = blend.Y * (b.Y - a.Y) + a.Y };
|
||||
public Vec2 Round( ) =>
|
||||
new Vec2 { X = X.Round( ), Y = Y.Round( ) };
|
||||
public Vec2 Round(int d) =>
|
||||
new Vec2 { X = X.Round(d), Y = Y.Round(d) };
|
||||
|
||||
public bool Equals(Vec2 other) =>
|
||||
X == other.X && Y == other.Y;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override string ToString() => $"({X}; {Y})";
|
||||
public string ToString(int d) => $"({X.Round(d)}; {Y.Round(d)})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Vec3
|
||||
{
|
||||
[FieldOffset(0x00)] public float X;
|
||||
[FieldOffset(0x04)] public float Y;
|
||||
[FieldOffset(0x08)] public float Z;
|
||||
|
||||
public Vec3(float val)
|
||||
{ X = val; Y = val; Z = val; }
|
||||
|
||||
public Vec3(float X, float Y)
|
||||
{ this.X = X; this.Y = Y; Z = 0.0f; }
|
||||
|
||||
public Vec3(float X, float Y, float Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
|
||||
public Vec3(Vec2 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = 0.0f; }
|
||||
|
||||
public Vec3(Vec2 vec, float Z)
|
||||
{ X = vec.X; Y = vec.Y; this.Z = Z; }
|
||||
|
||||
public Vec3(Vec4 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; }
|
||||
|
||||
public Vec2 XY => new Vec2(X, Y);
|
||||
|
||||
public float Length => (X * X + Y * Y + Z * Z).Sqrt();
|
||||
public float LengthSquared => X * X + Y * Y + Z * Z;
|
||||
public Vec3 Normalized => this = Length == 0.0f ? new Vec3() : this * (1.0f / Length);
|
||||
|
||||
public static Vec3 operator +(Vec3 left, Vec3 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; return left; }
|
||||
public static Vec3 operator -(Vec3 left, Vec3 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; return left; }
|
||||
public static Vec3 operator -(Vec3 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; return vec; }
|
||||
public static Vec3 operator *( Vec3 vec, float scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vec3 operator *(float scale, Vec3 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vec3 operator *( Vec3 vec, Vec3 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; return vec; }
|
||||
public static Vec3 operator /( Vec3 vec, float scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; return vec; }
|
||||
public static Vec3 operator /( Vec3 vec, Vec3 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; return vec; }
|
||||
public static bool operator ==(Vec3 A, Vec3 B) => A.X == B.X && A.Y == B.Y && A.Z == B.Z;
|
||||
public static bool operator !=(Vec3 A, Vec3 B) => A.X != B.X || A.Y != B.Y || A.Z != B.Z;
|
||||
|
||||
public static Vec3 operator *(Vec3 vec, Mat3 mat) =>
|
||||
new Vec3(vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X,
|
||||
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y,
|
||||
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z);
|
||||
|
||||
public static float Distance (Vec3 left, Vec3 right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z)).Sqrt();
|
||||
public static float DistanceSquared(Vec3 left, Vec3 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z);
|
||||
public static float Dot(Vec3 left, Vec3 right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||
public static Vec3 Cross(Vec3 left, Vec3 right) =>
|
||||
new Vec3 { X = left.Y * right.Z - left.Z * right.Y,
|
||||
Y = left.Z * right.X - left.X * right.Z,
|
||||
Z = left.X * right.Y - left.Y * right.X, };
|
||||
public static Vec3 Lerp(Vec3 a, Vec3 b, float blend) =>
|
||||
new Vec3 { X = blend * (b.X - a.X) + a.X,
|
||||
Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z };
|
||||
public static Vec3 Lerp(Vec3 a, Vec3 b, Vec3 blend) =>
|
||||
new Vec3 { X = blend.X * (b.X - a.X) + a.X,
|
||||
Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z };
|
||||
public Vec3 Round( ) =>
|
||||
new Vec3 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ) };
|
||||
public Vec3 Round(int d) =>
|
||||
new Vec3 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d) };
|
||||
|
||||
public bool Equals(Vec3 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
public override string ToString() => $"({X}; {Y}; {Z})";
|
||||
public string ToString(int d) => $"({X.Round(d)}; {Y.Round(d)}; {Z.Round(d)})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Vec4
|
||||
{
|
||||
[FieldOffset(0x00)] public float X;
|
||||
[FieldOffset(0x04)] public float Y;
|
||||
[FieldOffset(0x08)] public float Z;
|
||||
[FieldOffset(0x0C)] public float W;
|
||||
|
||||
public Vec4(float val)
|
||||
{ X = val; Y = val; Z = val; W = 0.0f; }
|
||||
|
||||
public Vec4(float X, float Y)
|
||||
{ this.X = X; this.Y = Y; Z = 0.0f; W = 0.0f; }
|
||||
|
||||
public Vec4(float X, float Y, float Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; W = 0.0f; }
|
||||
|
||||
public Vec4(float X, float Y, float Z, float W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public Vec4(Vec2 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = 0.0f; W = 0.0f; }
|
||||
|
||||
public Vec4(Vec2 vec, float Z)
|
||||
{ X = vec.X; Y = vec.Y; this.Z = Z; W = 0.0f; }
|
||||
|
||||
public Vec4(Vec2 vec, float Z, float W)
|
||||
{ X = vec.X; Y = vec.Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public Vec4(Vec3 vec)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; W = 0.0f; }
|
||||
|
||||
public Vec4(Vec3 vec, float W)
|
||||
{ X = vec.X; Y = vec.Y; Z = vec.Z; this.W = W; }
|
||||
|
||||
public Vec2 XY { get => new Vec2(X, Y ); set { X = value.X; Y = value.Y; } }
|
||||
public Vec3 XYZ { get => new Vec3(X, Y, Z); set { X = value.X; Y = value.Y; Z = value.Z; } }
|
||||
|
||||
public float Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
|
||||
public float LengthSquared => X * X + Y * Y + Z * Z + W * W;
|
||||
public Vec4 Normalized => new Vec4(X, Y, Z, W) * (Length == 0.0f ? 1.0f : (1.0f / Length));
|
||||
|
||||
public static Vec4 operator +(Vec4 left, Vec4 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; left.W += right.W; return left; }
|
||||
public static Vec4 operator -(Vec4 left, Vec4 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; left.W -= right.W; return left; }
|
||||
public static Vec4 operator -(Vec4 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; vec.W = -vec.W; return vec; }
|
||||
public static Vec4 operator *( Vec4 vec, float scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vec4 operator *(float scale, Vec4 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vec4 operator *( Vec4 vec, Vec4 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; vec.W *= scale.W; return vec; }
|
||||
public static Vec4 operator /( Vec4 vec, float scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; vec.W /= scale ; return vec; }
|
||||
public static Vec4 operator /( Vec4 vec, Vec4 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; vec.W /= scale.W; return vec; }
|
||||
public static bool operator ==(Vec4 A, Vec4 B) => A.Equals(B);
|
||||
public static bool operator !=(Vec4 A, Vec4 B) => !A.Equals(B);
|
||||
|
||||
public static Vec4 operator +(Vec4 left, Vec3 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; return left; }
|
||||
public static Vec4 operator -(Vec4 left, Vec3 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; return left; }
|
||||
public static Vec4 operator *( Vec4 vec, Vec3 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; return vec; }
|
||||
public static Vec4 operator /( Vec4 vec, Vec3 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; return vec; }
|
||||
|
||||
public static Vec4 operator *(Vec4 vec, Mat4 mat) =>
|
||||
new Vec4(vec.X * mat.Row0.X + vec.Y * mat.Row1.X + vec.Z * mat.Row2.X + vec.W * mat.Row3.X,
|
||||
vec.X * mat.Row0.Y + vec.Y * mat.Row1.Y + vec.Z * mat.Row2.Y + vec.W * mat.Row3.Y,
|
||||
vec.X * mat.Row0.Z + vec.Y * mat.Row1.Z + vec.Z * mat.Row2.Z + vec.W * mat.Row3.Z,
|
||||
vec.X * mat.Row0.W + vec.Y * mat.Row1.W + vec.Z * mat.Row2.W + vec.W * mat.Row3.W);
|
||||
|
||||
public static float Distance (Vec4 left, Vec4 right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W)).Sqrt();
|
||||
public static float DistanceSquared(Vec4 left, Vec4 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W);
|
||||
public static float Dot(Vec4 left, Vec4 right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
|
||||
public static Vec4 Lerp(Vec4 a, Vec4 b, float blend) =>
|
||||
new Vec4 { X = blend * (b.X - a.X) + a.X, Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z, W = blend * (b.W - a.W) + a.W };
|
||||
public static Vec4 Lerp(Vec4 a, Vec4 b, Vec4 blend) =>
|
||||
new Vec4 { X = blend.X * (b.X - a.X) + a.X, Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z, W = blend.W * (b.W - a.W) + a.W };
|
||||
public Vec4 Round( ) =>
|
||||
new Vec4 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Vec4 Round(int d) =>
|
||||
new Vec4 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
|
||||
public bool Equals(Vec4 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z && W == other.W;
|
||||
|
||||
public override bool Equals(object obj) => base.Equals(obj);
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
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)})";
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector3
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
|
||||
public Vector3(float X, float Y, float Z)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
|
||||
public float Length => (X * X + Y * Y + Z * Z).Sqrt();
|
||||
public Vector3 Normalized => this = Length == 0 ? new Vector3() : this / Length;
|
||||
|
||||
public static Vector3 operator +(Vector3 left, Vector3 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; return left; }
|
||||
public static Vector3 operator -(Vector3 left, Vector3 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; return left; }
|
||||
public static Vector3 operator -(Vector3 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; return vec; }
|
||||
public static Vector3 operator *(Vector3 vec, float scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vector3 operator *( float scale, Vector3 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; return vec; }
|
||||
public static Vector3 operator *(Vector3 vec, Vector3 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; return vec; }
|
||||
public static Vector3 operator /(Vector3 vec, float scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; return vec; }
|
||||
public static Vector3 operator /(Vector3 vec, Vector3 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; return vec; }
|
||||
public static bool operator ==(Vector3 A, Vector3 B) => A.X == B.X && A.Y == B.Y && A.Z == B.Z;
|
||||
public static bool operator !=(Vector3 A, Vector3 B) => A.X != B.X || A.Y != B.Y || A.Z != B.Z;
|
||||
|
||||
public static double Distance (Vector3 left, Vector3 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z).Sqrt();
|
||||
public static double DistanceSquared(Vector3 left, Vector3 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) *
|
||||
(right.Y - left.Y) + (right.Z - left.Z) * (right.Z - left.Z);
|
||||
public static double Dot(Vector3 left, Vector3 right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||
public static Vector3 Cross(Vector3 left, Vector3 right) =>
|
||||
new Vector3 { X = left.Y * right.Z - left.Z * right.Y,
|
||||
Y = left.Z * right.X - left.X * right.Z,
|
||||
Z = left.X * right.Y - left.Y * right.X, };
|
||||
public static Vector3 Lerp(Vector3 a, Vector3 b, float blend) =>
|
||||
new Vector3 { X = blend * (b.X - a.X) + a.X,
|
||||
Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z };
|
||||
public static Vector3 Lerp(Vector3 a, Vector3 b, Vector3 blend) =>
|
||||
new Vector3 { X = blend.X * (b.X - a.X) + a.X,
|
||||
Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z };
|
||||
public Vector3 Round( ) =>
|
||||
new Vector3 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ) };
|
||||
public Vector3 Round(int d) =>
|
||||
new Vector3 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d) };
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hashCode = X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Z.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
public override bool Equals(object obj) =>
|
||||
obj is Vector3 vec ? Equals(vec) : false;
|
||||
public bool Equals(Vector3 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z;
|
||||
|
||||
public override string ToString() => $"({X}; {Y}, {Z})";
|
||||
public string ToString(int d) => $"({X.Round(d)}; {Y.Round(d)}, {Z.Round(d)})";
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Vector4
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
|
||||
public Vector4(float X, float Y, float Z, float W)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = W; }
|
||||
|
||||
public float Length => (X * X + Y * Y + Z * Z + W * W).Sqrt();
|
||||
public Vector4 Normalized => this = Length == 0 ? new Vector4() : this / Length;
|
||||
|
||||
public static Vector4 operator +(Vector4 left, Vector4 right)
|
||||
{ left.X += right.X; left.Y += right.Y; left.Z += right.Z; left.W += right.W; return left; }
|
||||
public static Vector4 operator -(Vector4 left, Vector4 right)
|
||||
{ left.X -= right.X; left.Y -= right.Y; left.Z -= right.Z; left.W -= right.W; return left; }
|
||||
public static Vector4 operator -(Vector4 vec)
|
||||
{ vec.X = -vec.X; vec.Y = -vec.Y; vec.Z = -vec.Z; vec.W = -vec.W; return vec; }
|
||||
public static Vector4 operator *(Vector4 vec, float scale)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vector4 operator *( float scale, Vector4 vec)
|
||||
{ vec.X *= scale ; vec.Y *= scale ; vec.Z *= scale ; vec.W *= scale ; return vec; }
|
||||
public static Vector4 operator *(Vector4 vec, Vector4 scale)
|
||||
{ vec.X *= scale.X; vec.Y *= scale.Y; vec.Z *= scale.Z; vec.W *= scale.W; return vec; }
|
||||
public static Vector4 operator /(Vector4 vec, float scale)
|
||||
{ vec.X /= scale ; vec.Y /= scale ; vec.Z /= scale ; vec.W /= scale ; return vec; }
|
||||
public static Vector4 operator /(Vector4 vec, Vector4 scale)
|
||||
{ vec.X /= scale.X; vec.Y /= scale.Y; vec.Z /= scale.Z; vec.W /= scale.W; return vec; }
|
||||
public static bool operator ==(Vector4 A, Vector4 B) => A.Equals(B);
|
||||
public static bool operator !=(Vector4 A, Vector4 B) => !A.Equals(B);
|
||||
|
||||
public static double Distance (Vector4 left, Vector4 right) =>
|
||||
((right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W)).Sqrt();
|
||||
public static double DistanceSquared(Vector4 left, Vector4 right) =>
|
||||
(right.X - left.X) * (right.X - left.X) + (right.Y - left.Y) * (right.Y - left.Y) +
|
||||
(right.Z - left.Z) * (right.Z - left.Z) + (right.W - left.W) * (right.W - left.W);
|
||||
public static double Dot(Vector4 left, Vector4 right) =>
|
||||
left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W;
|
||||
public static Vector4 Lerp(Vector4 a, Vector4 b, float blend) =>
|
||||
new Vector4 { X = blend * (b.X - a.X) + a.X,
|
||||
Y = blend * (b.Y - a.Y) + a.Y,
|
||||
Z = blend * (b.Z - a.Z) + a.Z,
|
||||
W = blend * (b.W - a.W) + a.W };
|
||||
public static Vector4 Lerp(Vector4 a, Vector4 b, Vector4 blend) =>
|
||||
new Vector4 { X = blend.X * (b.X - a.X) + a.X,
|
||||
Y = blend.Y * (b.Y - a.Y) + a.Y,
|
||||
Z = blend.Z * (b.Z - a.Z) + a.Z,
|
||||
W = blend.W * (b.W - a.W) + a.W };
|
||||
public Vector4 Round( ) =>
|
||||
new Vector4 { X = X.Round( ), Y = Y.Round( ), Z = Z.Round( ), W = W.Round( ) };
|
||||
public Vector4 Round(int d) =>
|
||||
new Vector4 { X = X.Round(d), Y = Y.Round(d), Z = Z.Round(d), W = W.Round(d) };
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
int hashCode = X.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Y.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ Z.GetHashCode();
|
||||
hashCode = (hashCode * 397) ^ W.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
public override bool Equals(object obj) =>
|
||||
obj is Vector4 vec ? Equals(vec) : false;
|
||||
public bool Equals(Vector4 other) =>
|
||||
X == other.X && Y == other.Y && Z == other.Z && W == other.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)})";
|
||||
}
|
||||
}
|
||||
+308
-268
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdBaseLib.Auth3D;
|
||||
@@ -14,7 +14,7 @@ namespace KKdMainLib
|
||||
public Data Data;
|
||||
public A3DAHeader Head;
|
||||
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
private bool a3dc;
|
||||
private bool a3dcOpt;
|
||||
private int i, i0, i1;
|
||||
@@ -38,20 +38,20 @@ namespace KKdMainLib
|
||||
public A3DA(bool a3dcOpt = true)
|
||||
{ a3dc = false; i = i0 = i1 = soi = soi0 = soi1 = 0; value = null;
|
||||
name = null; nameView = null; so = null; so0 = null; so1 = null;
|
||||
dataArray = null; _IO = null; Head = default; Data = default;
|
||||
dataArray = null; s = null; Head = default; Data = default;
|
||||
dict = null; usedValues = null; this.a3dcOpt = a3dcOpt; }
|
||||
|
||||
public int A3DAReader(string file)
|
||||
{ using (_IO = File.OpenReader(file + ".a3da"))
|
||||
return A3DAReader(ref _IO); }
|
||||
{ using (s = File.OpenReader(file + ".a3da"))
|
||||
return A3DAReader(ref s); }
|
||||
|
||||
public int A3DAReader(byte[] data)
|
||||
{ using (_IO = File.OpenReader(data))
|
||||
return A3DAReader(ref _IO); }
|
||||
{ using (s = File.OpenReader(data))
|
||||
return A3DAReader(ref s); }
|
||||
|
||||
public byte[] A3DAWriter() => A3DAWriter(false);
|
||||
|
||||
private int A3DAReader(ref Stream _IO)
|
||||
private int A3DAReader(ref Stream s)
|
||||
{
|
||||
name = "";
|
||||
nameView = "";
|
||||
@@ -61,44 +61,44 @@ namespace KKdMainLib
|
||||
Head = new A3DAHeader();
|
||||
Header header = new Header();
|
||||
|
||||
Head.Format = _IO.Format = Format.F;
|
||||
header.SectionSignature = _IO.RI32();
|
||||
Head.Format = s.Format = Format.F;
|
||||
header.SectionSignature = s.RU32();
|
||||
if (header.SectionSignature == 0x41443341)
|
||||
{ header = _IO.ReadHeader(true, true); Head.Format = header.Format; }
|
||||
{ header = s.ReadHeader(true, true); Head.Format = header.Format; }
|
||||
if (header.SectionSignature != 0x44334123) return 0;
|
||||
|
||||
_IO.O = _IO.P - 4;
|
||||
header.SectionSignature = _IO.RI32();
|
||||
s.O = s.P - 4;
|
||||
header.SectionSignature = s.RU32();
|
||||
|
||||
if (header.SectionSignature == 0x5F5F5F41)
|
||||
{
|
||||
_IO.P = 0x10;
|
||||
header.Format = _IO.Format = Format.DT;
|
||||
s.P = 0x10;
|
||||
header.Format = s.Format = Format.DT;
|
||||
}
|
||||
else if (header.SectionSignature == 0x5F5F5F43)
|
||||
{
|
||||
_IO.P = 0x10;
|
||||
_IO.RI32();
|
||||
_IO.RI32();
|
||||
Head.HeaderOffset = _IO.RI32E(true);
|
||||
s.P = 0x10;
|
||||
s.RI32();
|
||||
s.RI32();
|
||||
Head.HeaderOffset = s.RI32E(true);
|
||||
|
||||
_IO.P = Head.HeaderOffset;
|
||||
if (_IO.RI32() != 0x50) return 0;
|
||||
Head.StringOffset = _IO.RI32E(true);
|
||||
Head.StringLength = _IO.RI32E(true);
|
||||
Head.Count = _IO.RI32E(true);
|
||||
if (_IO.RI32() != 0x4C42) return 0;
|
||||
Head.BinaryOffset = _IO.RI32E(true);
|
||||
Head.BinaryLength = _IO.RI32E(true);
|
||||
s.P = Head.HeaderOffset;
|
||||
if (s.RI32() != 0x50) return 0;
|
||||
Head.StringOffset = s.RI32E(true);
|
||||
Head.StringLength = s.RI32E(true);
|
||||
Head.Count = s.RI32E(true);
|
||||
if (s.RI32() != 0x4C42) return 0;
|
||||
Head.BinaryOffset = s.RI32E(true);
|
||||
Head.BinaryLength = s.RI32E(true);
|
||||
|
||||
_IO.P = Head.StringOffset;
|
||||
s.P = Head.StringOffset;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
if (header.Format == Format.DT)
|
||||
Head.StringLength = _IO.L - 0x10;
|
||||
Head.StringLength = s.L - 0x10;
|
||||
|
||||
string[] strData = _IO.RS(Head.StringLength).Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
string[] strData = s.RS(Head.StringLength).Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
for (i = 0; i < strData.Length; i++)
|
||||
dict.GD(strData[i]);
|
||||
strData = null;
|
||||
@@ -107,12 +107,12 @@ namespace KKdMainLib
|
||||
|
||||
if (header.SectionSignature == 0x5F5F5F43)
|
||||
{
|
||||
_IO.P = _IO.O + Head.BinaryOffset;
|
||||
_IO.O = _IO.P;
|
||||
_IO.P = 0;
|
||||
byte[] data = _IO.RBy(Head.BinaryLength);
|
||||
_IO.C();
|
||||
_IO = File.OpenReader(data);
|
||||
s.P = s.O + Head.BinaryOffset;
|
||||
s.O = s.P;
|
||||
s.P = 0;
|
||||
byte[] data = s.RBy(Head.BinaryLength);
|
||||
s.C();
|
||||
s = File.OpenReader(data);
|
||||
A3DCReader();
|
||||
}
|
||||
|
||||
@@ -142,13 +142,13 @@ namespace KKdMainLib
|
||||
|
||||
Data.CameraAuxiliary = new CameraAuxiliary
|
||||
{
|
||||
AutoExposure = RK(name + "auto_exposure" + d),
|
||||
Exposure = RK(name + "exposure" + d),
|
||||
Gamma = RK(name + "gamma" + d),
|
||||
GammaRate = RK(name + "gamma_rate" + d),
|
||||
Saturate = RK(name + "saturate" + d)
|
||||
AutoExposure = RKN(name + "auto_exposure" + d),
|
||||
Exposure = RKN(name + "exposure" + d),
|
||||
Gamma = RKN(name + "gamma" + d),
|
||||
GammaRate = RKN(name + "gamma_rate" + d),
|
||||
Saturate = RKN(name + "saturate" + d),
|
||||
};
|
||||
if (Data.CameraAuxiliary.Value.GammaRate.Type != null)
|
||||
if (Data.CameraAuxiliary.Value.GammaRate.HasValue)
|
||||
if (Head.Format < Format.F || Head.Format == Format.AFT || Head.Format >= Format.FT)
|
||||
Head.Format = Format.F;
|
||||
}
|
||||
@@ -174,9 +174,9 @@ namespace KKdMainLib
|
||||
Ambient = RRGBAK(name + "Ambient" + d),
|
||||
Diffuse = RRGBAK(name + "Diffuse" + d),
|
||||
Specular = RRGBAK(name + "Specular" + d),
|
||||
LensFlare = RK (name + "lens_flare" + d),
|
||||
LensGhost = RK (name + "lens_ghost" + d),
|
||||
LensShaft = RK (name + "lens_shaft" + d),
|
||||
LensFlare = RKN (name + "lens_flare" + d),
|
||||
LensGhost = RKN (name + "lens_ghost" + d),
|
||||
LensShaft = RKN (name + "lens_shaft" + d),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace KKdMainLib
|
||||
|
||||
if (dict.SW(name + "joint_orient"))
|
||||
{
|
||||
Data.MObjectHRC[i0].JointOrient = new Vector3<float?>();
|
||||
Data.MObjectHRC[i0].JointOrient = new Vec3<float?>();
|
||||
dict.FV(out Data.MObjectHRC[i0].JointOrient.X, name + "joint_orient.x");
|
||||
dict.FV(out Data.MObjectHRC[i0].JointOrient.Y, name + "joint_orient.y");
|
||||
dict.FV(out Data.MObjectHRC[i0].JointOrient.Z, name + "joint_orient.z");
|
||||
@@ -418,18 +418,12 @@ namespace KKdMainLib
|
||||
nameView = name + "tex_transform" + d + i1 + d;
|
||||
|
||||
dict.FV(out Data.Object[i0].TexTrans[i1].Name, nameView + "name");
|
||||
Data.Object[i0].TexTrans[i1].Coverage =
|
||||
RKUV(nameView + "coverage" );
|
||||
Data.Object[i0].TexTrans[i1].Offset =
|
||||
RKUV(nameView + "offset" );
|
||||
Data.Object[i0].TexTrans[i1].Repeat =
|
||||
RKUV(nameView + "repeat" );
|
||||
Data.Object[i0].TexTrans[i1]. Rotate =
|
||||
RK (nameView + "rotate" + d);
|
||||
Data.Object[i0].TexTrans[i1]. RotateFrame =
|
||||
RK (nameView + "rotateFrame"+ d);
|
||||
Data.Object[i0].TexTrans[i1].TranslateFrame =
|
||||
RKUV(nameView + "translateFrame");
|
||||
Data.Object[i0].TexTrans[i1].Coverage = RKUV(nameView + "coverage" );
|
||||
Data.Object[i0].TexTrans[i1].Offset = RKUV(nameView + "offset" );
|
||||
Data.Object[i0].TexTrans[i1].Repeat = RKUV(nameView + "repeat" );
|
||||
Data.Object[i0].TexTrans[i1]. Rotate = RKN (nameView + "rotate" + d);
|
||||
Data.Object[i0].TexTrans[i1]. RotateFrame = RKN (nameView + "rotateFrame"+ d);
|
||||
Data.Object[i0].TexTrans[i1].TranslateFrame = RKUV(nameView + "translateFrame");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,7 +440,7 @@ namespace KKdMainLib
|
||||
|
||||
if (dict.SW(name + "joint_orient"))
|
||||
{
|
||||
Data.ObjectHRC[i0].JointOrient = new Vector3<float?>();
|
||||
Data.ObjectHRC[i0].JointOrient = new Vec3<float?>();
|
||||
dict.FV(out Data.ObjectHRC[i0].JointOrient.X, name + "joint_orient.x");
|
||||
dict.FV(out Data.ObjectHRC[i0].JointOrient.Y, name + "joint_orient.y");
|
||||
dict.FV(out Data.ObjectHRC[i0].JointOrient.Z, name + "joint_orient.z");
|
||||
@@ -495,13 +489,13 @@ namespace KKdMainLib
|
||||
private byte[] A3DAWriter(bool a3dc)
|
||||
{
|
||||
this.a3dc = a3dc;
|
||||
_IO = File.OpenWriter();
|
||||
s = File.OpenWriter();
|
||||
DateTime date = DateTime.Now;
|
||||
if (a3dc && Data._.CompressF16 != 0)
|
||||
W("", "#-compress_f16");
|
||||
s.W("#-compress_f16\n");
|
||||
if (!a3dc)
|
||||
_IO.W("#A3DA__________\n");
|
||||
_IO.W("#" + DateTime.UtcNow.ToString("ddd MMM dd HH:mm:ss yyyy",
|
||||
s.W("#A3DA__________\n");
|
||||
s.W("#" + DateTime.UtcNow.ToString("ddd MMM dd HH:mm:ss yyyy",
|
||||
System.Globalization.CultureInfo.InvariantCulture) + "\n");
|
||||
if (a3dc && Data._.CompressF16 != 0)
|
||||
W("_.compress_f16", (int)Data._.CompressF16);
|
||||
@@ -530,12 +524,12 @@ namespace KKdMainLib
|
||||
{
|
||||
name = "camera_auxiliary" + d;
|
||||
CameraAuxiliary ca = Data.CameraAuxiliary.Value;
|
||||
W(ref ca.AutoExposure, name + "auto_exposure", true);
|
||||
W(ref ca. Exposure, name + "exposure", true);
|
||||
W(ref ca.Gamma , name + "gamma" , true);
|
||||
W(ref ca.AutoExposure, name + "auto_exposure");
|
||||
W(ref ca. Exposure, name + "exposure");
|
||||
W(ref ca.Gamma , name + "gamma" );
|
||||
if (Head.Format == Format.F || (Head.Format > Format.AFT && Head.Format < Format.FT))
|
||||
W(ref ca.GammaRate , name + "gamma_rate" , true);
|
||||
W(ref ca.Saturate , name + "saturate" , true);
|
||||
W(ref ca.GammaRate , name + "gamma_rate" );
|
||||
W(ref ca.Saturate , name + "saturate" );
|
||||
Data.CameraAuxiliary = ca;
|
||||
}
|
||||
|
||||
@@ -629,11 +623,11 @@ namespace KKdMainLib
|
||||
name = "fog" + d + soi0 + d;
|
||||
ref Fog fog = ref Data.Fog[soi0];
|
||||
|
||||
W(ref fog.Diffuse, name + "Diffuse" );
|
||||
W(ref fog.Density, name + "density", true);
|
||||
W(ref fog.End , name + "end" , true);
|
||||
W(ref fog.Diffuse, name + "Diffuse");
|
||||
W(ref fog.Density, name + "density");
|
||||
W(ref fog.End , name + "end" );
|
||||
W(name + "id", fog.Id);
|
||||
W(ref fog.Start , name + "start" , true);
|
||||
W(ref fog.Start , name + "start" );
|
||||
}
|
||||
W("fog.length", Data.Fog.Length);
|
||||
}
|
||||
@@ -893,12 +887,12 @@ namespace KKdMainLib
|
||||
{
|
||||
PostProcess pp = Data.PostProcess.Value;
|
||||
name = "post_process" + d;
|
||||
W(ref pp.Ambient , name + "Ambient" );
|
||||
W(ref pp.Diffuse , name + "Diffuse" );
|
||||
W(ref pp.Specular , name + "Specular" );
|
||||
W(ref pp.LensFlare, name + "lens_flare", true);
|
||||
W(ref pp.LensGhost, name + "lens_ghost", true);
|
||||
W(ref pp.LensShaft, name + "lens_shaft", true);
|
||||
W(ref pp.Ambient , name + "Ambient" );
|
||||
W(ref pp.Diffuse , name + "Diffuse" );
|
||||
W(ref pp.Specular , name + "Specular" );
|
||||
W(ref pp.LensFlare, name + "lens_flare");
|
||||
W(ref pp.LensGhost, name + "lens_ghost");
|
||||
W(ref pp.LensShaft, name + "lens_shaft");
|
||||
Data.PostProcess = pp;
|
||||
}
|
||||
|
||||
@@ -910,9 +904,9 @@ namespace KKdMainLib
|
||||
W("point.length", Data.Point.Length);
|
||||
}
|
||||
|
||||
_IO.A(0x1, true);
|
||||
byte[] data = _IO.ToArray();
|
||||
_IO.Dispose();
|
||||
s.A(0x1, true);
|
||||
byte[] data = s.ToArray();
|
||||
s.Dispose();
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -928,15 +922,19 @@ namespace KKdMainLib
|
||||
return mt;
|
||||
}
|
||||
|
||||
private Vector4<Key> RRGBAK(string str) =>
|
||||
new Vector4<Key> { W = RK(str + "a" + d), Z = RK(str + "b" + d),
|
||||
Y = RK(str + "g" + d), X = RK(str + "r" + d) };
|
||||
private Vec4<Key>? RRGBAK(string str) =>
|
||||
dict.FV(out bool b, str) ? b ?
|
||||
(Vec4<Key>?)new Vec4<Key> { W = RK(str + "a" + d), Z = RK(str + "b" + d),
|
||||
Y = RK(str + "g" + d), X = RK(str + "r" + d) }: null : null;
|
||||
|
||||
private Vector3<Key> RV3(string str) =>
|
||||
new Vector3<Key> { X = RK(str + "x" + d), Y = RK(str + "y" + d), Z = RK(str + "z" + d) };
|
||||
private Vec3<Key> RV3(string str) =>
|
||||
new Vec3<Key> { X = RK(str + "x" + d), Y = RK(str + "y" + d), Z = RK(str + "z" + d) };
|
||||
|
||||
private Vector2<Key> RKUV(string str) =>
|
||||
new Vector2<Key> { X = RK(str + "U" + d), Y = RK(str + "V" + d) };
|
||||
private Vec2<Key?> RKUV(string str) =>
|
||||
new Vec2<Key?> { X = RKN(str + "U" + d), Y = RKN(str + "V" + d) };
|
||||
|
||||
private Key? RKN(string str) =>
|
||||
dict.FV(out bool b, str) ? b ? (Key?)RK(str) : null : null;
|
||||
|
||||
private Key RK(string str)
|
||||
{
|
||||
@@ -972,18 +970,18 @@ namespace KKdMainLib
|
||||
key.Keys = new KFT3[key.Length];
|
||||
if (key.RawData.KeyType == 0)
|
||||
for (i = 0; i < key.Length; i++)
|
||||
key.Keys[i] = new KFT3 (VL[i * ds + 0].ToF32());
|
||||
key.Keys[i] = new KFT3(VL[i * ds + 0].ToF32());
|
||||
else if (key.RawData.KeyType == 1)
|
||||
for (i = 0; i < key.Length; i++)
|
||||
key.Keys[i] = new KFT3 (VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32());
|
||||
key.Keys[i] = new KFT3(VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32());
|
||||
else if (key.RawData.KeyType == 2)
|
||||
for (i = 0; i < key.Length; i++)
|
||||
key.Keys[i] = new KFT3 (VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32(),
|
||||
VL[i * ds + 2].ToF32(), VL[i * ds + 2].ToF32());
|
||||
key.Keys[i] = new KFT3(VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32(),
|
||||
VL[i * ds + 2].ToF32());
|
||||
else if (key.RawData.KeyType == 3)
|
||||
for (i = 0; i < key.Length; i++)
|
||||
key.Keys[i] = new KFT3 (VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32(),
|
||||
VL[i * ds + 2].ToF32(), VL[i * ds + 3].ToF32());
|
||||
key.Keys[i] = new KFT3(VL[i * ds + 0].ToF32(), VL[i * ds + 1].ToF32(),
|
||||
VL[i * ds + 2].ToF32(), VL[i * ds + 3].ToF32());
|
||||
|
||||
key.RawData.ValueList = null;
|
||||
}
|
||||
@@ -1001,11 +999,9 @@ namespace KKdMainLib
|
||||
else if (type == 1) key.Keys[i] = new KFT3
|
||||
(dataArray[0].ToF32(), dataArray[1].ToF32());
|
||||
else if (type == 2) key.Keys[i] = new KFT3
|
||||
(dataArray[0].ToF32(), dataArray[1].ToF32(),
|
||||
dataArray[2].ToF32(), dataArray[2].ToF32());
|
||||
(dataArray[0].ToF32(), dataArray[1].ToF32(), dataArray[2].ToF32());
|
||||
else if (type == 3) key.Keys[i] = new KFT3
|
||||
(dataArray[0].ToF32(), dataArray[1].ToF32(),
|
||||
dataArray[2].ToF32(), dataArray[3].ToF32());
|
||||
(dataArray[0].ToF32(), dataArray[1].ToF32(), dataArray[2].ToF32(), dataArray[3].ToF32());
|
||||
}
|
||||
}
|
||||
return key;
|
||||
@@ -1025,43 +1021,42 @@ namespace KKdMainLib
|
||||
}
|
||||
}
|
||||
|
||||
private void W(ref Vector4<Key> rgba, string str)
|
||||
private void W(ref Vec4<Key>? rgba, string str)
|
||||
{
|
||||
if (rgba.X.Type == null && rgba.Y.Type == null &&
|
||||
rgba.Z.Type == null && rgba.W.Type == null) return;
|
||||
if (!rgba.HasValue) return;
|
||||
|
||||
W(str, "true");
|
||||
W(ref rgba.W, str + d + "a" + d);
|
||||
W(ref rgba.Z, str + d + "b" + d);
|
||||
W(ref rgba.Y, str + d + "g" + d);
|
||||
W(ref rgba.X, str + d + "r" + d);
|
||||
Vec4<Key> rgbav = rgba.Value;
|
||||
W(ref rgbav.W, str + d + "a" + d);
|
||||
W(ref rgbav.Z, str + d + "b" + d);
|
||||
W(ref rgbav.Y, str + d + "g" + d);
|
||||
W(ref rgbav.X, str + d + "r" + d);
|
||||
rgba = rgbav;
|
||||
}
|
||||
|
||||
private void W(ref Vector3<Key> key, string str)
|
||||
private void W(ref Vec3<Key> key, string str)
|
||||
{ W(ref key.X, str + "x" + d); W(ref key.Y, str + "y" + d); W(ref key.Z, str + "z" + d); }
|
||||
|
||||
private void W(ref Vector2<Key> uv, string str)
|
||||
{ W(ref uv.X, str + "U", true); W(ref uv.Y, str + "V", true); }
|
||||
private void W(ref Vec2<Key?> uv, string str)
|
||||
{ W(ref uv.X, str + "U"); W(ref uv.Y, str + "V"); }
|
||||
|
||||
private void W(ref Key Key, string Temp, bool setBoolean)
|
||||
{ if (Key.Type == null) return; if (setBoolean) W(Temp + "", "true"); W(ref Key, Temp + d); }
|
||||
private void W(ref Key? key, string str)
|
||||
{ if (!key.HasValue) return; Key k = key.Value; W(str, "true"); W(ref k, str + d); key = k; }
|
||||
|
||||
private void W(ref Key key, string str)
|
||||
{
|
||||
if (key.Type == null) return;
|
||||
|
||||
if (a3dc) { W(str + BO + "", key.BinOffset); return; }
|
||||
|
||||
int i = 0;
|
||||
if (key.Keys != null)
|
||||
if (key.Keys.Length == 0)
|
||||
{
|
||||
W(str + "type", (int)key.Type);
|
||||
if (key.Type > 0) W(str + "value", key.Value);
|
||||
return;
|
||||
}
|
||||
if (key.Type < KeyType.Lerp || key.Keys == null || (key.Keys != null && key.Keys.Length == 0))
|
||||
{
|
||||
W(str + "type", (int)key.Type);
|
||||
if (key.Type > 0) W(str + "value", key.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int)key.EPTypePost > 0) W(str + "ep_type_post", (int)key.EPTypePost);
|
||||
if ((int)key.EPTypePre > 0) W(str + "ep_type_pre" , (int)key.EPTypePre );
|
||||
if (key.EPTypePost > 0) W(str + "ep_type_post", (int)key.EPTypePost);
|
||||
if (key.EPTypePre > 0) W(str + "ep_type_pre" , (int)key.EPTypePre );
|
||||
if (key.RawData.KeyType == 0 && key.Keys != null)
|
||||
{
|
||||
IKF kf;
|
||||
@@ -1080,6 +1075,7 @@ namespace KKdMainLib
|
||||
}
|
||||
W(str + "key.length", key.Length);
|
||||
if (key.Max != null) W(str + "max", key.Max);
|
||||
W(str + "type", (int)key.Type);
|
||||
}
|
||||
else if (key.Keys != null)
|
||||
{
|
||||
@@ -1097,25 +1093,23 @@ namespace KKdMainLib
|
||||
else if (kf is KFT3 && keyType < 3) keyType = 3;
|
||||
}
|
||||
key.RawData.ValueListSize = length * keyType + length;
|
||||
_IO.W(str + "raw_data.value_list");
|
||||
s.W(str + "raw_data.value_list");
|
||||
if (keyType == 0) for (i = 0; i < length; i++)
|
||||
_IO.W(key.Keys[i].ToT0().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
s.W(key.Keys[i].ToT0().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
else if (keyType == 1) for (i = 0; i < length; i++)
|
||||
_IO.W(key.Keys[i].ToT1().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
s.W(key.Keys[i].ToT1().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
else if (keyType == 2) for (i = 0; i < length; i++)
|
||||
_IO.W(key.Keys[i].ToT2().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
s.W(key.Keys[i].ToT2().ToString(false) + (i + 1 < length ? "," : ""));
|
||||
else if (keyType == 3) for (i = 0; i < length; i++)
|
||||
_IO.W(key.Keys[i] .ToString(false) + (i + 1 < length ? "," : ""));
|
||||
_IO.P--;
|
||||
_IO.W('\n');
|
||||
s.W(key.Keys[i] .ToString(false) + (i + 1 < length ? "," : ""));
|
||||
s.P--;
|
||||
s.W('\n');
|
||||
W(str + "raw_data.value_list_size", key.RawData.ValueListSize);
|
||||
W(str + "raw_data.value_type" , key.RawData.ValueType );
|
||||
W(str + "raw_data_key_type" , key.RawData. KeyType );
|
||||
W(str + "type", (int)key.Type);
|
||||
}
|
||||
W(str + "type", (int)key.Type);
|
||||
if (key.RawData.KeyType == 0 && key.Keys == null && key.Type != null &&
|
||||
key.Type.Value != 0 && key.Value != null && key.Value != 0)
|
||||
W(str + "value", key.Value);
|
||||
}
|
||||
|
||||
private void W(string Data, long? val)
|
||||
@@ -1127,7 +1121,7 @@ namespace KKdMainLib
|
||||
private void W(string Data, float val) =>
|
||||
W(Data, val.ToS());
|
||||
private void W(string Data, string val)
|
||||
{ if (val != null) _IO.W(Data + "=" + val + "\n"); }
|
||||
{ if (val != null) s.W(Data + "=" + val + "\n"); }
|
||||
|
||||
private void A3DCReader()
|
||||
{
|
||||
@@ -1263,11 +1257,11 @@ namespace KKdMainLib
|
||||
Data._.CompressF16 = Head.Format > Format.AFT && Head.Format < Format.FT ?
|
||||
(Head.Format == Format.MGF ? CompressF16.I16F16F16F16 : CompressF16.I16F16F32F32) : 0;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
s = File.OpenWriter();
|
||||
for (byte i = 0; i < 2; i++)
|
||||
{
|
||||
bool ReturnToOffset = i == 1;
|
||||
_IO.P = 0;
|
||||
s.P = 0;
|
||||
|
||||
if (Data.CameraRoot != null)
|
||||
for (i0 = 0; i0 < Data.CameraRoot.Length; i0++)
|
||||
@@ -1447,55 +1441,55 @@ namespace KKdMainLib
|
||||
Data.PostProcess = pp;
|
||||
}
|
||||
|
||||
_IO.A(0x10, true);
|
||||
s.A(0x10, true);
|
||||
}
|
||||
byte[] A3DCData = _IO.ToArray(); _IO.Dispose();
|
||||
byte[] A3DCData = s.ToArray(); s.Dispose();
|
||||
byte[] A3DAData = A3DAWriter(true);
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
_IO.O = Head.Format > Format.AFT && Head.Format < Format.FT ? 0x40 : 0;
|
||||
_IO.P = 0x40;
|
||||
s = File.OpenWriter();
|
||||
s.O = Head.Format > Format.AFT && Head.Format < Format.FT ? 0x40 : 0;
|
||||
s.P = 0x40;
|
||||
|
||||
Head.StringOffset = _IO.P;
|
||||
Head.StringOffset = s.P;
|
||||
Head.StringLength = A3DAData.Length;
|
||||
_IO.W(A3DAData);
|
||||
_IO.A(0x20, true);
|
||||
s.W(A3DAData);
|
||||
s.A(0x20, true);
|
||||
|
||||
Head.BinaryOffset = _IO.P;
|
||||
Head.BinaryOffset = s.P;
|
||||
Head.BinaryLength = A3DCData.Length;
|
||||
_IO.W(A3DCData);
|
||||
_IO.A(0x10, true);
|
||||
s.W(A3DCData);
|
||||
s.A(0x10, true);
|
||||
|
||||
int A3DCEnd = _IO.P;
|
||||
uint A3DCEnd = s.PU32;
|
||||
|
||||
_IO.P = 0;
|
||||
_IO.W("#A3DC__________\n");
|
||||
_IO.W(0x2000);
|
||||
_IO.W(0x00);
|
||||
_IO.WE(0x20, true);
|
||||
_IO.W(0x10000200);
|
||||
_IO.W(0x50);
|
||||
_IO.WE(Head.StringOffset, true);
|
||||
_IO.WE(Head.StringLength, true);
|
||||
_IO.WE(0x01, true);
|
||||
_IO.W(0x4C42);
|
||||
_IO.WE(Head.BinaryOffset, true);
|
||||
_IO.WE(Head.BinaryLength, true);
|
||||
_IO.WE(0x20, true);
|
||||
s.P = 0;
|
||||
s.W("#A3DC__________\n");
|
||||
s.W(0x2000);
|
||||
s.W(0x00);
|
||||
s.WE(0x20, true);
|
||||
s.W(0x10000200);
|
||||
s.W(0x50);
|
||||
s.WE(Head.StringOffset, true);
|
||||
s.WE(Head.StringLength, true);
|
||||
s.WE(0x01, true);
|
||||
s.W(0x4C42);
|
||||
s.WE(Head.BinaryOffset, true);
|
||||
s.WE(Head.BinaryLength, true);
|
||||
s.WE(0x20, true);
|
||||
|
||||
if (Head.Format > Format.AFT && Head.Format < Format.FT)
|
||||
{
|
||||
_IO.P = A3DCEnd;
|
||||
_IO.WEOFC(0);
|
||||
_IO.O = 0;
|
||||
_IO.P = 0;
|
||||
Header header = new Header { Signature = 0x41443341, Format = Format.F2LE,
|
||||
DataSize = A3DCEnd, SectionSize = A3DCEnd, InnerSignature = 0x01131010 };
|
||||
_IO.W(header, true);
|
||||
s.PU32 = A3DCEnd;
|
||||
s.WEOFC(0);
|
||||
s.O = 0;
|
||||
s.P = 0;
|
||||
Header header = new Header { Signature = 0x41443341, InnerSignature = 0x01131010,
|
||||
Format = Format.F2, DataSize = A3DCEnd, SectionSize = A3DCEnd, UseSectionSize = true };
|
||||
s.W(header, true);
|
||||
}
|
||||
|
||||
byte[] data = _IO.ToArray();
|
||||
_IO.Dispose();
|
||||
byte[] data = s.ToArray();
|
||||
s.Dispose();
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1503,12 +1497,12 @@ namespace KKdMainLib
|
||||
{
|
||||
if (mt.BinOffset == null) return;
|
||||
|
||||
_IO.P = (int)mt.BinOffset;
|
||||
s.P = (int)mt.BinOffset;
|
||||
|
||||
ReadOffset(out mt.Scale);
|
||||
ReadOffset(out mt.Rot );
|
||||
ReadOffset(out mt.Trans);
|
||||
mt.Visibility = new Key { BinOffset = _IO.RI32() };
|
||||
mt.Visibility = new Key { BinOffset = s.RI32() };
|
||||
|
||||
RV3(ref mt.Scale );
|
||||
RV3(ref mt.Rot , true);
|
||||
@@ -1516,27 +1510,35 @@ namespace KKdMainLib
|
||||
RK (ref mt.Visibility);
|
||||
}
|
||||
|
||||
private void RRGBAK(ref Vector4<Key> rgba)
|
||||
{ RK(ref rgba.X); RK(ref rgba.Y);
|
||||
RK(ref rgba.Z); RK(ref rgba.W); }
|
||||
private void RRGBAK(ref Vec4<Key>? rgba)
|
||||
{
|
||||
if (!rgba.HasValue) return;
|
||||
Vec4<Key> rgbav = rgba.Value;
|
||||
RK(ref rgbav.X); RK(ref rgbav.Y);
|
||||
RK(ref rgbav.Z); RK(ref rgbav.W);
|
||||
rgba = rgbav;
|
||||
}
|
||||
|
||||
private void RV3(ref Vector3<Key> key, bool f16 = false)
|
||||
private void RV3(ref Vec3<Key> key, bool f16 = false)
|
||||
{ RK(ref key.X, f16); RK(ref key.Y, f16); RK(ref key.Z, f16); }
|
||||
|
||||
private void RKUV(ref Vector2<Key> uv)
|
||||
private void RKUV(ref Vec2<Key?> uv)
|
||||
{ RK(ref uv.X); RK(ref uv.Y); }
|
||||
|
||||
private void RK(ref Key? key)
|
||||
{ if (!key.HasValue) return; Key k = key.Value; RK(ref k); key = k; }
|
||||
|
||||
private void RK(ref Key key, bool f16 = false)
|
||||
{
|
||||
if (key.BinOffset == null || key.BinOffset < 0) return;
|
||||
|
||||
_IO.P = (int)key.BinOffset;
|
||||
int Type = _IO.RI32();
|
||||
key.Value = _IO.RF32();
|
||||
s.P = (int)key.BinOffset;
|
||||
int Type = s.RI32();
|
||||
key.Value = s.RF32();
|
||||
key.Type = (KeyType)(Type & 0xFF);
|
||||
if (key.Type < KeyType.Lerp) return;
|
||||
key.Max = _IO.RF32();
|
||||
key.Length = _IO.RI32 ();
|
||||
key.Max = s.RF32();
|
||||
key.Length = s.RI32 ();
|
||||
if (Type >> 8 != 0)
|
||||
{
|
||||
key.EPTypePost = (EPType)((Type >> 12) & 0xF);
|
||||
@@ -1546,93 +1548,101 @@ namespace KKdMainLib
|
||||
|
||||
if (f16 && Data._.CompressF16 == CompressF16.I16F16F16F16)
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = _IO.RU16(); kf.V = _IO.RF16();
|
||||
kf.T1 = _IO.RF16(); kf.T2 = _IO.RF16(); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = s.RU16(); kf.V = s.RF16();
|
||||
kf.T1 = s.RF16(); kf.T2 = s.RF16(); }
|
||||
else if (f16 && Data._.CompressF16 > 0)
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = _IO.RU16(); kf.V = _IO.RF16();
|
||||
kf.T1 = _IO.RF32(); kf.T2 = _IO.RF32(); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = s.RU16(); kf.V = s.RF16();
|
||||
kf.T1 = s.RF32(); kf.T2 = s.RF32(); }
|
||||
else
|
||||
for (int i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = _IO.RF32(); kf.V = _IO.RF32();
|
||||
kf.T1 = _IO.RF32(); kf.T2 = _IO.RF32(); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; kf.F = s.RF32(); kf.V = s.RF32();
|
||||
kf.T1 = s.RF32(); kf.T2 = s.RF32(); }
|
||||
}
|
||||
|
||||
private void ReadOffset(out Vector3<Key> key)
|
||||
{ key = new Vector3<Key> { X = new Key { BinOffset = _IO.RI32() },
|
||||
Y = new Key { BinOffset = _IO.RI32() },
|
||||
Z = new Key { BinOffset = _IO.RI32() }, }; }
|
||||
private void ReadOffset(out Vec3<Key> key)
|
||||
{ key = new Vec3<Key> { X = new Key { BinOffset = s.RI32() },
|
||||
Y = new Key { BinOffset = s.RI32() },
|
||||
Z = new Key { BinOffset = s.RI32() }, }; }
|
||||
|
||||
private void WO(ref ModelTransform mt, bool ReturnToOffset)
|
||||
{
|
||||
if (ReturnToOffset)
|
||||
{
|
||||
_IO.P = (int)mt.BinOffset;
|
||||
s.P = (int)mt.BinOffset;
|
||||
WriteOffset(mt.Scale);
|
||||
WriteOffset(mt.Rot );
|
||||
WriteOffset(mt.Trans);
|
||||
_IO.W(mt.Visibility.BinOffset);
|
||||
s.W(mt.Visibility.BinOffset);
|
||||
}
|
||||
else { mt.BinOffset = _IO.P; _IO.P += 0x30; _IO.L += 0x30; }
|
||||
else { mt.BinOffset = s.P; s.P += 0x30; s.L += 0x30; }
|
||||
}
|
||||
|
||||
private void WriteOffset(Vector3<Key> key)
|
||||
{ _IO.W(key.X.BinOffset); _IO.W(key.Y.BinOffset); _IO.W(key.Z.BinOffset); }
|
||||
private void WriteOffset(Vec3<Key> key)
|
||||
{ s.W(key.X.BinOffset); s.W(key.Y.BinOffset); s.W(key.Z.BinOffset); }
|
||||
|
||||
private void W(ref ModelTransform mt)
|
||||
{ W(ref mt.Scale); W(ref mt.Rot, true); W(ref mt.Trans); W(ref mt.Visibility); }
|
||||
|
||||
private void W(ref Vector4<Key> rgba)
|
||||
{ W(ref rgba.X); W(ref rgba.Y); W(ref rgba.Z); W(ref rgba.W); }
|
||||
private void W(ref Vec4<Key>? rgba)
|
||||
{
|
||||
if (!rgba.HasValue) return;
|
||||
|
||||
private void W(ref Vector3<Key> key, bool f16 = false)
|
||||
Vec4<Key> rgbav = rgba.Value;
|
||||
W(ref rgbav.X); W(ref rgbav.Y);
|
||||
W(ref rgbav.Z); W(ref rgbav.W);
|
||||
rgba = rgbav;
|
||||
}
|
||||
|
||||
private void W(ref Vec3<Key> key, bool f16 = false)
|
||||
{ W(ref key.X, f16); W(ref key.Y, f16); W(ref key.Z, f16); }
|
||||
|
||||
private void W(ref Vector2<Key> uv)
|
||||
private void W(ref Vec2<Key?> uv)
|
||||
{ W(ref uv.X); W(ref uv.Y); }
|
||||
|
||||
private void W(ref Key? key)
|
||||
{ if (!key.HasValue) return; Key k = key.Value; W(ref k); key = k; }
|
||||
|
||||
private void W(ref Key key, bool f16 = false)
|
||||
{
|
||||
if (key.Type == null) return;
|
||||
|
||||
int i = 0;
|
||||
if (key.Keys != null)
|
||||
if (key.Type > KeyType.Value && key.Keys != null)
|
||||
{
|
||||
key.BinOffset = _IO.P;
|
||||
key.BinOffset = s.P;
|
||||
int Type = (int)key.Type & 0xFF;
|
||||
Type |= ((int)key.EPTypePost & 0xF) << 12;
|
||||
Type |= ((int)key.EPTypePre & 0xF) << 8;
|
||||
_IO.W(Type);
|
||||
_IO.W(0x00);
|
||||
_IO.W((float)key.Max);
|
||||
_IO.W(key.Keys.Length);
|
||||
s.W(Type);
|
||||
s.W(0x00);
|
||||
s.W((float)key.Max);
|
||||
s.W(key.Keys.Length);
|
||||
|
||||
if (f16 && Data._.CompressF16 == CompressF16.I16F16F16F16)
|
||||
for (i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; _IO.W((ushort)kf.F ); _IO.W((Half)kf.V );
|
||||
_IO.W(( Half)kf.T1); _IO.W((Half)kf.T2); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; s.W((ushort)kf.F ); s.W((Half)kf.V );
|
||||
s.W(( Half)kf.T1); s.W((Half)kf.T2); }
|
||||
else if (f16 && Data._.CompressF16 > 0)
|
||||
for (i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; _IO.W((ushort)kf.F ); _IO.W((Half)kf.V );
|
||||
_IO.W( kf.T1); _IO.W( kf.T2); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; s.W((ushort)kf.F ); s.W((Half)kf.V );
|
||||
s.W( kf.T1); s.W( kf.T2); }
|
||||
else
|
||||
for (i = 0; i < key.Keys.Length; i++)
|
||||
{ ref KFT3 kf = ref key.Keys[i]; _IO.W( kf.F ); _IO.W( kf.V );
|
||||
_IO.W( kf.T1); _IO.W( kf.T2); }
|
||||
{ ref KFT3 kf = ref key.Keys[i]; s.W( kf.F ); s.W( kf.V );
|
||||
s.W( kf.T1); s.W( kf.T2); }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!a3dcOpt)
|
||||
{
|
||||
key.BinOffset = _IO.P;
|
||||
_IO.W(( int)key.Type );
|
||||
_IO.W((float)key.Value);
|
||||
key.BinOffset = s.P;
|
||||
if (key.Type == 0) s.W(0x00L);
|
||||
else { s.W((int)key.Type); s.W((float)key.Value); }
|
||||
}
|
||||
else if (!usedValues.ContainsValue(key.Value))
|
||||
{
|
||||
key.BinOffset = _IO.P;
|
||||
_IO.W(( int)key.Type );
|
||||
_IO.W((float)key.Value);
|
||||
key.BinOffset = s.P;
|
||||
if (key.Type == 0) s.W(0x00L);
|
||||
else { s.W((int)key.Type); s.W((float)key.Value); }
|
||||
usedValues.Add(key.BinOffset, key.Value);
|
||||
}
|
||||
else key.BinOffset = usedValues.GK(key.Value);
|
||||
@@ -1798,15 +1808,25 @@ namespace KKdMainLib
|
||||
MK (ref mt.Visibility, ref mMT.Visibility);
|
||||
}
|
||||
|
||||
private void MRGBAK(ref Vector4<Key> rgba, ref Vector4<Key> mRGBA)
|
||||
{ MK(ref rgba.X, ref mRGBA.X); MK(ref rgba.Y, ref mRGBA.Y);
|
||||
MK(ref rgba.Z, ref mRGBA.Z); MK(ref rgba.W, ref mRGBA.W); }
|
||||
private void MRGBAK(ref Vec4<Key>? rgba, ref Vec4<Key>? mRGBA)
|
||||
{
|
||||
if (!rgba.HasValue) return;
|
||||
|
||||
private void MV3(ref Vector3<Key> key, ref Vector3<Key> mKey)
|
||||
Vec4<Key> rgbav = rgba.Value;
|
||||
Vec4<Key> mrgbav = mRGBA.Value;
|
||||
MK(ref rgbav.X, ref mrgbav.X); MK(ref rgbav.Y, ref mrgbav.Y);
|
||||
MK(ref rgbav.Z, ref mrgbav.Z); MK(ref rgbav.W, ref mrgbav.W);
|
||||
mRGBA = mrgbav;
|
||||
}
|
||||
|
||||
private void MV3(ref Vec3<Key> key, ref Vec3<Key> mKey)
|
||||
{ MK(ref key.X, ref mKey.X); MK(ref key.Y, ref mKey.Y); MK(ref key.Z, ref mKey.Z); }
|
||||
|
||||
private void MKUV(ref Vector2<Key> uv, ref Vector2<Key> mUV)
|
||||
private void MKUV(ref Vec2<Key?> uv, ref Vec2<Key?> mUV)
|
||||
{ MK(ref uv.X, ref mUV.X); MK(ref uv.Y, ref mUV.Y); }
|
||||
|
||||
private void MK(ref Key? key, ref Key? mKey)
|
||||
{ if (!key.HasValue || !mKey.HasValue) return; Key k = key.Value; Key mk = mKey.Value; MK(ref k, ref mk); key = k; mKey = mk; }
|
||||
|
||||
private void MK(ref Key key, ref Key mKey)
|
||||
{
|
||||
@@ -1861,7 +1881,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json) =>
|
||||
MsgPackWriter().Write(true, file, json);
|
||||
MsgPackWriter().Write(false, true, file, json);
|
||||
|
||||
private void MsgPackReader(MsgPack a3d)
|
||||
{
|
||||
@@ -1892,11 +1912,11 @@ namespace KKdMainLib
|
||||
if ((temp = a3d["CameraAuxiliary"]).NotNull)
|
||||
Data.CameraAuxiliary = new CameraAuxiliary
|
||||
{
|
||||
AutoExposure = temp.RK("AutoExposure"),
|
||||
Exposure = temp.RK( "Exposure"),
|
||||
Gamma = temp.RK("Gamma" ),
|
||||
GammaRate = temp.RK("GammaRate" ),
|
||||
Saturate = temp.RK("Saturate" ),
|
||||
AutoExposure = temp.RKN("AutoExposure"),
|
||||
Exposure = temp.RKN( "Exposure"),
|
||||
Gamma = temp.RKN("Gamma" ),
|
||||
GammaRate = temp.RKN("GammaRate" ),
|
||||
Saturate = temp.RKN("Saturate" ),
|
||||
};
|
||||
|
||||
if ((temp = a3d["CameraRoot", true]).NotNull)
|
||||
@@ -2026,7 +2046,7 @@ namespace KKdMainLib
|
||||
};
|
||||
|
||||
if ((temp1 = temp[i0]["JointOrient"]).NotNull)
|
||||
Data.MObjectHRC[i0].JointOrient = new Vector3<float?>
|
||||
Data.MObjectHRC[i0].JointOrient = new Vec3<float?>
|
||||
{
|
||||
X = temp1.RnF32("X"),
|
||||
Y = temp1.RnF32("Y"),
|
||||
@@ -2111,8 +2131,8 @@ namespace KKdMainLib
|
||||
Coverage = temp1[i1].RKUV("Coverage" ),
|
||||
Offset = temp1[i1].RKUV("Offset" ),
|
||||
Repeat = temp1[i1].RKUV("Repeat" ),
|
||||
Rotate = temp1[i1].RK ( "Rotate" ),
|
||||
RotateFrame = temp1[i1].RK ( "RotateFrame"),
|
||||
Rotate = temp1[i1].RKN ( "Rotate" ),
|
||||
RotateFrame = temp1[i1].RKN ( "RotateFrame"),
|
||||
TranslateFrame = temp1[i1].RKUV("TranslateFrame"),
|
||||
};
|
||||
}
|
||||
@@ -2132,7 +2152,7 @@ namespace KKdMainLib
|
||||
};
|
||||
|
||||
if ((temp1 = temp[i0]["JointOrient"]).NotNull)
|
||||
Data.ObjectHRC[i0].JointOrient = new Vector3<float?>
|
||||
Data.ObjectHRC[i0].JointOrient = new Vec3<float?>
|
||||
{
|
||||
X = temp1.RF32("X"),
|
||||
Y = temp1.RF32("Y"),
|
||||
@@ -2189,9 +2209,9 @@ namespace KKdMainLib
|
||||
{
|
||||
Ambient = temp.RRGBAK("Ambient" ),
|
||||
Diffuse = temp.RRGBAK("Diffuse" ),
|
||||
LensFlare = temp.RK ("LensFlare"),
|
||||
LensGhost = temp.RK ("LensGhost"),
|
||||
LensShaft = temp.RK ("LensShaft"),
|
||||
LensFlare = temp.RKN ("LensFlare"),
|
||||
LensGhost = temp.RKN ("LensGhost"),
|
||||
LensShaft = temp.RKN ("LensShaft"),
|
||||
Specular = temp.RRGBAK("Specular" ),
|
||||
};
|
||||
|
||||
@@ -2506,7 +2526,7 @@ namespace KKdMainLib
|
||||
dataArray = null;
|
||||
usedValues = null;
|
||||
dict = null;
|
||||
_IO = null;
|
||||
s = null;
|
||||
Data = default;
|
||||
Head = default;
|
||||
}
|
||||
@@ -2521,36 +2541,39 @@ namespace KKdMainLib
|
||||
new ModelTransform { Rot = msgPack.RV3("Rot" ), Scale = msgPack.RV3("Scale" ),
|
||||
Trans = msgPack.RV3("Trans"), Visibility = msgPack.RK ("Visibility") };
|
||||
|
||||
public static Vector4<Key> RRGBAK(this MsgPack msgPack, string name) =>
|
||||
public static Vec4<Key> RRGBAK(this MsgPack msgPack, string name) =>
|
||||
msgPack[name].RRGBAK();
|
||||
|
||||
public static Vector4<Key> RRGBAK(this MsgPack msgPack) =>
|
||||
new Vector4<Key> { X = msgPack.RK("R"), Y = msgPack.RK("G"),
|
||||
public static Vec4<Key> RRGBAK(this MsgPack msgPack) =>
|
||||
new Vec4<Key> { X = msgPack.RK("R"), Y = msgPack.RK("G"),
|
||||
Z = msgPack.RK("B"), W = msgPack.RK("A") };
|
||||
|
||||
public static Vector3<Key> RV3(this MsgPack msgPack, string name) =>
|
||||
public static Vec3<Key> RV3(this MsgPack msgPack, string name) =>
|
||||
msgPack[name].RV3();
|
||||
|
||||
public static Vector3<Key> RV3(this MsgPack msgPack) =>
|
||||
new Vector3<Key> { X = msgPack.RK("X"), Y = msgPack.RK("Y"), Z = msgPack.RK("Z") };
|
||||
public static Vec3<Key> RV3(this MsgPack msgPack) =>
|
||||
new Vec3<Key> { X = msgPack.RK("X"), Y = msgPack.RK("Y"), Z = msgPack.RK("Z") };
|
||||
|
||||
public static Vector2<Key> RKUV(this MsgPack msgPack, string name) =>
|
||||
public static Vec2<Key?> RKUV(this MsgPack msgPack, string name) =>
|
||||
msgPack[name].RKUV();
|
||||
|
||||
public static Vector2<Key> RKUV(this MsgPack msgPack) =>
|
||||
new Vector2<Key> { X = msgPack.RK("U"), Y = msgPack.RK("V") };
|
||||
public static Vec2<Key?> RKUV(this MsgPack msgPack) =>
|
||||
new Vec2<Key?> { X = msgPack.RKN("U"), Y = msgPack.RKN("V") };
|
||||
|
||||
public static Key? RKN(this MsgPack msgPack, string name) =>
|
||||
msgPack[name].Object != null ? (Key?)msgPack[name].RK() : default;
|
||||
|
||||
public static Key RK(this MsgPack msgPack, string name) =>
|
||||
msgPack[name].ReadKey();
|
||||
msgPack[name].RK();
|
||||
|
||||
public static Key ReadKey(this MsgPack msgPack)
|
||||
public static Key RK(this MsgPack msgPack)
|
||||
{
|
||||
if (msgPack.Object == null) return default;
|
||||
|
||||
Key key = new Key { Max = msgPack.RnF32("Max"), Value = msgPack.RnF32("Value") };
|
||||
Key key = new Key { Max = msgPack.RnF32("Max"), Value = msgPack.RF32("Value") };
|
||||
if (Enum.TryParse(msgPack.RS("EPTypePost"), out EPType EPTypePost)) key.EPTypePost = EPTypePost;
|
||||
if (Enum.TryParse(msgPack.RS("EPTypePre" ), out EPType EPTypePre )) key.EPTypePre = EPTypePre;
|
||||
if (!Enum.TryParse(msgPack.RS("Type"), out KeyType KeyType)) { key.Value = null; return key; }
|
||||
if (!Enum.TryParse(msgPack.RS("Type"), out KeyType KeyType)) { key.Value = 0; return key; }
|
||||
key.Type = KeyType;
|
||||
if (key.Type == 0) { key.Value = 0; return key; }
|
||||
else if (key.Type < KeyType.Lerp) return key;
|
||||
@@ -2573,12 +2596,10 @@ namespace KKdMainLib
|
||||
(trans[i][0].RF32(), trans[i][1].RF32());
|
||||
else if (trans[i].Array.Length == 3)
|
||||
key.Keys[i] = new KFT3
|
||||
(trans[i][0].RF32(), trans[i][1].RF32(),
|
||||
trans[i][2].RF32(), trans[i][2].RF32());
|
||||
(trans[i][0].RF32(), trans[i][1].RF32(), trans[i][2].RF32());
|
||||
else if (trans[i].Array.Length == 4)
|
||||
key.Keys[i] = new KFT3
|
||||
(trans[i][0].RF32(), trans[i][1].RF32(),
|
||||
trans[i][2].RF32(), trans[i][3].RF32());
|
||||
(trans[i][0].RF32(), trans[i][1].RF32(), trans[i][2].RF32(), trans[i][3].RF32());
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@@ -2595,23 +2616,41 @@ namespace KKdMainLib
|
||||
.Add("Trans" , ref mt.Trans )
|
||||
.Add("Visibility", ref mt.Visibility));
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vector4<Key> rgba) =>
|
||||
(rgba.X.Type == null && rgba.Y.Type == null &&
|
||||
rgba.Z.Type == null && rgba.W.Type == null) ? msgPack :
|
||||
msgPack.Add(new MsgPack(name).Add("R", ref rgba.X).Add("G", ref rgba.Y)
|
||||
.Add("B", ref rgba.Z).Add("A", ref rgba.W));
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vec4<Key>? rgba)
|
||||
{
|
||||
if (!rgba.HasValue) return msgPack;
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vector3<Key> key) =>
|
||||
Vec4<Key> rgbav = rgba.Value;
|
||||
msgPack = msgPack.Add(new MsgPack(name).Add("R", ref rgbav.X).Add("G", ref rgbav.Y)
|
||||
.Add("B", ref rgbav.Z).Add("A", ref rgbav.W));
|
||||
rgba = rgbav;
|
||||
return msgPack;
|
||||
}
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vec3<Key> key) =>
|
||||
msgPack.Add(new MsgPack(name).Add("X", ref key.X).Add("Y", ref key.Y).Add("Z", ref key.Z));
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vector2<Key> uv) =>
|
||||
(uv.X.Type == null && uv.Y.Type == null) ? msgPack :
|
||||
msgPack.Add(new MsgPack(name).Add("U", ref uv.X).Add("V", ref uv.Y));
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Vec2<Key?> uv)
|
||||
{
|
||||
if (!uv.X.HasValue && !uv.Y.HasValue) return msgPack;
|
||||
MsgPack m = new MsgPack(name);
|
||||
if (uv.X.HasValue) m = m.Add("U", ref uv.X);
|
||||
if (uv.Y.HasValue) m = m.Add("V", ref uv.Y);
|
||||
return msgPack.Add(m);
|
||||
}
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Key? key)
|
||||
{
|
||||
if (!key.HasValue) return msgPack;
|
||||
|
||||
Key k = key.Value;
|
||||
msgPack = msgPack.Add(name, ref k);
|
||||
key = k;
|
||||
return msgPack;
|
||||
}
|
||||
|
||||
public static MsgPack Add(this MsgPack msgPack, string name, ref Key key)
|
||||
{
|
||||
if (key.Type == null) return msgPack;
|
||||
|
||||
MsgPack keys = new MsgPack(name).Add("Type", key.Type.ToString());
|
||||
if (key.Keys != null && key.Type != KeyType.Null)
|
||||
{
|
||||
@@ -2639,7 +2678,8 @@ namespace KKdMainLib
|
||||
keys.Add(Trans);
|
||||
}
|
||||
else if (key.Value != 0) keys.Add("Value", key.Value);
|
||||
return msgPack.Add(keys);
|
||||
msgPack.Add(keys);
|
||||
return msgPack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public unsafe struct AddParam : System.IDisposable
|
||||
{
|
||||
private long i;
|
||||
private Stream s;
|
||||
|
||||
public HeaderData Header;
|
||||
|
||||
public void AddParamReader(string file)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
s = File.OpenReader(file + ".adp");
|
||||
Header.Count = s.RI64();
|
||||
Header.DataLength = s.RI64();
|
||||
Header.DataOffset = s.RI64();
|
||||
|
||||
if (Header.Count < 1 || Header.DataOffset > s.P || Header.DataLength > s.LI64
|
||||
- Header.DataOffset || Header.Count * 0x20 > s.LI64 - Header.DataOffset) { s.C(); return; }
|
||||
|
||||
Header.Data = new HeaderData.Sub[Header.Count];
|
||||
byte[] data = s.RBy(Header.DataLength, Header.DataOffset);
|
||||
s.C();
|
||||
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
Header.Data[i] = hPtr[i];
|
||||
}
|
||||
|
||||
data = null;
|
||||
}
|
||||
|
||||
public void AddParamWriter(string file)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.LongLength < 1) return;
|
||||
|
||||
Header.Count = Header.Data.LongLength;
|
||||
Header.DataLength = Header.Count * 0x20;
|
||||
Header.DataOffset = 0x18L;
|
||||
|
||||
byte[] data = new byte[Header.DataLength];
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
HeaderData.Sub* hPtr = (HeaderData.Sub*)ptr;
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
hPtr[i] = Header.Data[i];
|
||||
}
|
||||
|
||||
s = File.OpenWriter(file + ".adp", true);
|
||||
s.W(Header.Count);
|
||||
s.W(Header.DataLength);
|
||||
s.W(Header.DataOffset);
|
||||
s.W(data);
|
||||
s.C();
|
||||
data = null;
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
MsgPack addParam;
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
if ((addParam = msgPack["AddParam", true]).IsNull) return;
|
||||
|
||||
Header.Count = addParam.Array.LongLength;
|
||||
Header.Data = new HeaderData.Sub[Header.Count];
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
{
|
||||
ref HeaderData.Sub sub = ref Header.Data[i];
|
||||
sub.Time = addParam[i].RF32("Time");
|
||||
sub.Flags = addParam[i].RI32("Flags");
|
||||
sub.Frame = addParam[i].RI32("Frame");
|
||||
sub.ID = addParam[i].RI32("ID");
|
||||
sub.Value = addParam[i].RF32("Value");
|
||||
|
||||
sub.PVBranch = addParam[i].RnI32("PVBranch") ?? 0;
|
||||
float? f = addParam[i].RnF32("Value");
|
||||
if (f.HasValue)
|
||||
{
|
||||
if (sub.ID == 0) { float v = 0; *(uint*)&v = addParam[i].RU32("Value"); sub.Value = v; }
|
||||
else sub.Value = f.Value;
|
||||
}
|
||||
else { float v = 0; *(uint*)&v = 0xFFFFFFFF; sub.Value = v; }
|
||||
|
||||
}
|
||||
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.LongLength < 1) return;
|
||||
|
||||
MsgPack addParam = new MsgPack(Header.Data.LongLength, "AddParam");
|
||||
fixed (HeaderData.Sub* ptr = Header.Data)
|
||||
for (i = 0; i < Header.Count; i++)
|
||||
{
|
||||
ref HeaderData.Sub sub = ref Header.Data[i];
|
||||
addParam[i] = MsgPack.New.Add("Time", sub.Time).Add("Flags", sub.Flags).Add("Frame", sub.Frame);
|
||||
|
||||
if (sub.PVBranch > 0)
|
||||
addParam[i] = addParam[i].Add("PVBranch", sub.PVBranch);
|
||||
|
||||
addParam[i] = addParam[i].Add("ID", sub.ID);
|
||||
|
||||
if (sub.ID == 0)
|
||||
addParam[i] = addParam[i].Add("Value", *(uint*)&ptr[i].Value);
|
||||
else if (*(uint*)&ptr[i].Value != 0xFFFFFFFF)
|
||||
addParam[i] = addParam[i].Add("Value", sub.Value);
|
||||
|
||||
}
|
||||
addParam.WriteAfterAll(false, true, file, json);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{ if (s != null) s.D(); s = null; Header = default; }
|
||||
|
||||
public struct HeaderData
|
||||
{
|
||||
public long Count;
|
||||
public long DataLength;
|
||||
public long DataOffset;
|
||||
|
||||
public Sub[] Data;
|
||||
|
||||
public struct Sub
|
||||
{
|
||||
public float Time;
|
||||
public int Flags;
|
||||
public int Frame;
|
||||
public int Pad0C;
|
||||
public int PVBranch;
|
||||
public int ID;
|
||||
public float Value;
|
||||
public int Pad1C;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+425
-426
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
@@ -213,12 +213,12 @@ namespace KKdMainLib.DB
|
||||
for (i = 0; i < AetSets.Length; i++)
|
||||
AetDB[i] = AetSets[i].WriteMsgPack();
|
||||
|
||||
AetDB.Write(true, file, json);
|
||||
AetDB.Write(false, true, file, json);
|
||||
}
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); AetSets = null; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; AetSets = null; disposed = true; } }
|
||||
|
||||
public struct AET
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using A3DADict = System.Collections.Generic.Dictionary<string, object>;
|
||||
@@ -146,12 +146,12 @@ namespace KKdMainLib.DB
|
||||
authDB.Add(uid);
|
||||
}
|
||||
|
||||
authDB.Write(true, file, json);
|
||||
authDB.Write(false, true, file, json);
|
||||
}
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); Category = null; UIDs = null; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; Category = null; UIDs = null; disposed = true; } }
|
||||
|
||||
public struct UID
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using KKdBaseLib;
|
||||
@@ -251,12 +251,12 @@ namespace KKdMainLib.DB
|
||||
for (i = 0; i < SpriteSets.Length; i++)
|
||||
sprDB[i] = SpriteSets[i].WriteMsgPack();
|
||||
|
||||
sprDB.Write(true, file, json);
|
||||
sprDB.Write(false, true, file, json);
|
||||
}
|
||||
|
||||
private bool disposed = false;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); SpriteSets = null; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; SpriteSets = null; disposed = true; } }
|
||||
|
||||
public struct SpriteTexture
|
||||
{
|
||||
|
||||
+88
-83
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace KKdMainLib
|
||||
{
|
||||
private int i, i0, i1;
|
||||
private Header header;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public EXP[] Dex;
|
||||
|
||||
@@ -16,150 +16,155 @@ namespace KKdMainLib
|
||||
{
|
||||
Dex = null;
|
||||
header = new Header();
|
||||
_IO = File.OpenReader(filepath + ext);
|
||||
s = File.OpenReader(filepath + ext);
|
||||
|
||||
header.Format = Format.F;
|
||||
header.SectionSignature = _IO.RI32();
|
||||
header.SectionSignature = s.RU32();
|
||||
if (header.SectionSignature == 0x43505845)
|
||||
header = _IO.ReadHeader(true, true);
|
||||
header = s.ReadHeader(true, true);
|
||||
if (header.SectionSignature != 0x64) return;
|
||||
|
||||
_IO.O = _IO.P - 0x4;
|
||||
Dex = new EXP[_IO.RI32()];
|
||||
int DEXOffset = _IO.RI32();
|
||||
int DEXNameOffset = _IO.RI32();
|
||||
if (DEXNameOffset == 0x00) { _IO.Format = header.Format = Format.X; DEXNameOffset = (int)_IO.RIX(); }
|
||||
s.O = s.P - 0x4;
|
||||
Dex = new EXP[s.RI32()];
|
||||
int DEXOffset = s.RI32();
|
||||
int DEXNameOffset = s.RI32();
|
||||
if (DEXNameOffset == 0x00) { s.Format = header.Format = Format.X; DEXNameOffset = (int)s.RIX(); }
|
||||
|
||||
_IO.P = DEXOffset;
|
||||
s.P = DEXOffset;
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
{
|
||||
Dex[i].MainOffset = (int)_IO.RIX();
|
||||
Dex[i].EyesOffset = (int)_IO.RIX();
|
||||
Dex[i].MainOffset = (int)s.RIX();
|
||||
Dex[i].EyesOffset = (int)s.RIX();
|
||||
}
|
||||
_IO.P = DEXNameOffset;
|
||||
s.P = DEXNameOffset;
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
Dex[i].NameOffset = (int)_IO.RIX();
|
||||
Dex[i].NameOffset = (int)s.RIX();
|
||||
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
{
|
||||
EXPElement element = new EXPElement();
|
||||
Dex[i].Main = KKdList<EXPElement>.New;
|
||||
_IO.P = Dex[i].MainOffset;
|
||||
s.P = Dex[i].MainOffset;
|
||||
while (true)
|
||||
{
|
||||
element.Frame = _IO.RF32();
|
||||
element.Both = _IO.RU16();
|
||||
element.ID = _IO.RU16();
|
||||
element.Value = _IO.RF32();
|
||||
element.Trans = _IO.RF32();
|
||||
element.Frame = s.RF32();
|
||||
element.Both = s.RU16();
|
||||
element.ID = s.RU16();
|
||||
element.Value = s.RF32();
|
||||
element.Trans = s.RF32();
|
||||
if (element.Frame == 999999 || element.Both == 0xFFFF) break;
|
||||
Dex[i].Main.Add(element);
|
||||
}
|
||||
Dex[i].Main.Capacity = Dex[i].Main.Count;
|
||||
|
||||
Dex[i].Eyes = KKdList<EXPElement>.New;
|
||||
_IO.P = Dex[i].EyesOffset;
|
||||
s.P = Dex[i].EyesOffset;
|
||||
while(true)
|
||||
{
|
||||
element.Frame = _IO.RF32();
|
||||
element.Both = _IO.RU16();
|
||||
element.ID = _IO.RU16();
|
||||
element.Value = _IO.RF32();
|
||||
element.Trans = _IO.RF32();
|
||||
element.Frame = s.RF32();
|
||||
element.Both = s.RU16();
|
||||
element.ID = s.RU16();
|
||||
element.Value = s.RF32();
|
||||
element.Trans = s.RF32();
|
||||
if (element.Frame == 999999 || element.Both == 0xFFFF) break;
|
||||
Dex[i].Eyes.Add(element);
|
||||
}
|
||||
Dex[i].Eyes.Capacity = Dex[i].Eyes.Count;
|
||||
|
||||
Dex[i].Name = _IO.RSaO(Dex[i].NameOffset);
|
||||
Dex[i].Name = s.RSaO(Dex[i].NameOffset);
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void DEXWriter(string filepath, Format Format)
|
||||
public void DEXWriter(string filepath, Format format)
|
||||
{
|
||||
if (Dex == null || Dex.Length < 1) return;
|
||||
|
||||
header = new Header();
|
||||
_IO = File.OpenWriter(filepath + (Format > Format.F && Format < Format.FT ? ".dex" : ".bin"), true);
|
||||
header.Format = _IO.Format = Format;
|
||||
s = File.OpenWriter(filepath + (format > Format.F && format < Format.FT ? ".dex" : ".bin"), true);
|
||||
header.Format = s.Format = format;
|
||||
|
||||
_IO.O = Format > Format.F ? 0x20 : 0;
|
||||
_IO.W(0x64);
|
||||
_IO.W(Dex.Length);
|
||||
s.Format = format;
|
||||
s.O = format > Format.F ? 0x20 : 0;
|
||||
s.P = 0;
|
||||
s.W(0x64);
|
||||
s.W(Dex.Length);
|
||||
|
||||
_IO.WX(header.IsX ? 0x28 : 0x20);
|
||||
_IO.WX(0x00);
|
||||
s.WX(header.IsX ? 0x28 : 0x20);
|
||||
s.WX(0x00);
|
||||
|
||||
int Position0 = _IO.P;
|
||||
_IO.W(0x00L);
|
||||
_IO.W(0x00L);
|
||||
int Position0 = s.P;
|
||||
s.W(0x00L);
|
||||
s.W(0x00L);
|
||||
|
||||
for (i = 0; i < Dex.Length * 3; i++) _IO.WX(0x00);
|
||||
_IO.A(0x20);
|
||||
for (i = 0; i < Dex.Length * 3; i++) s.WX(0x00);
|
||||
s.A(0x20);
|
||||
|
||||
for (i0 = 0; i0 < Dex.Length; i0++)
|
||||
{
|
||||
Dex[i0].MainOffset = _IO.P;
|
||||
Dex[i0].MainOffset = s.P;
|
||||
for (i1 = 0; i1 < Dex[i0].Main.Count; i1++)
|
||||
{
|
||||
_IO.W(Dex[i0].Main[i1].Frame);
|
||||
_IO.W(Dex[i0].Main[i1].Both );
|
||||
_IO.W(Dex[i0].Main[i1].ID );
|
||||
_IO.W(Dex[i0].Main[i1].Value);
|
||||
_IO.W(Dex[i0].Main[i1].Trans);
|
||||
s.W(Dex[i0].Main[i1].Frame);
|
||||
s.W(Dex[i0].Main[i1].Both );
|
||||
s.W(Dex[i0].Main[i1].ID );
|
||||
s.W(Dex[i0].Main[i1].Value);
|
||||
s.W(Dex[i0].Main[i1].Trans);
|
||||
}
|
||||
_IO.W(999999f);
|
||||
_IO.W(0xFFFF);
|
||||
_IO.W(0x0L);
|
||||
_IO.A(0x20);
|
||||
s.W(999999f);
|
||||
s.W(0xFFFF);
|
||||
s.W(0x0L);
|
||||
s.A(0x20);
|
||||
|
||||
Dex[i0].EyesOffset = _IO.P;
|
||||
Dex[i0].EyesOffset = s.P;
|
||||
for (i1 = 0; i1 < Dex[i0].Eyes.Count; i1++)
|
||||
{
|
||||
_IO.W(Dex[i0].Eyes[i1].Frame);
|
||||
_IO.W(Dex[i0].Eyes[i1].Both );
|
||||
_IO.W(Dex[i0].Eyes[i1].ID );
|
||||
_IO.W(Dex[i0].Eyes[i1].Value);
|
||||
_IO.W(Dex[i0].Eyes[i1].Trans);
|
||||
s.W(Dex[i0].Eyes[i1].Frame);
|
||||
s.W(Dex[i0].Eyes[i1].Both );
|
||||
s.W(Dex[i0].Eyes[i1].ID );
|
||||
s.W(Dex[i0].Eyes[i1].Value);
|
||||
s.W(Dex[i0].Eyes[i1].Trans);
|
||||
}
|
||||
_IO.W(999999f);
|
||||
_IO.W(0xFFFF);
|
||||
_IO.W(0x0L);
|
||||
_IO.A(0x20);
|
||||
s.W(999999f);
|
||||
s.W(0xFFFF);
|
||||
s.W(0x0L);
|
||||
s.A(0x20);
|
||||
}
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
{
|
||||
Dex[i].NameOffset = _IO.P;
|
||||
_IO.W(Dex[i].Name + "\0");
|
||||
Dex[i].NameOffset = s.P;
|
||||
s.W(Dex[i].Name + "\0");
|
||||
}
|
||||
_IO.A(0x10, true);
|
||||
s.A(0x10, true);
|
||||
|
||||
_IO.P = header.IsX ? 0x28 : 0x20;
|
||||
s.P = header.IsX ? 0x28 : 0x20;
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
{
|
||||
_IO.WX(Dex[i].MainOffset);
|
||||
_IO.WX(Dex[i].EyesOffset);
|
||||
s.WX(Dex[i].MainOffset);
|
||||
s.WX(Dex[i].EyesOffset);
|
||||
}
|
||||
int namesPosition = _IO.P;
|
||||
int namesPosition = s.P;
|
||||
for (i = 0; i < Dex.Length; i++)
|
||||
_IO.WX(Dex[i].NameOffset);
|
||||
s.WX(Dex[i].NameOffset);
|
||||
|
||||
_IO.P = Position0 - (header.IsX ? 8 : 4);
|
||||
_IO.W(namesPosition);
|
||||
s.P = Position0 - (header.IsX ? 8 : 4);
|
||||
s.W(namesPosition);
|
||||
|
||||
if (Format > Format.F)
|
||||
if (format > Format.F)
|
||||
{
|
||||
int offset = _IO.L;
|
||||
_IO.O = 0;
|
||||
_IO.P = _IO.L;
|
||||
_IO.WEOFC(0);
|
||||
_IO.P = 0;
|
||||
uint offset = s.LU32;
|
||||
s.O = 0;
|
||||
s.P = s.L;
|
||||
s.WEOFC(0);
|
||||
s.P = 0;
|
||||
header.DataSize = offset;
|
||||
header.SectionSize = offset;
|
||||
header.Signature = 0x43505845;
|
||||
_IO.W(header, true);
|
||||
header.UseSectionSize = true;
|
||||
s.W(header);
|
||||
}
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
@@ -188,7 +193,7 @@ namespace KKdMainLib
|
||||
{
|
||||
Dex[i0].Eyes = KKdList<EXPElement>.New;
|
||||
Dex[i0].Eyes.Capacity = temp.Array.Length;
|
||||
for (i1 = 0; i1 < this.Dex[i0].Eyes.Capacity; i1++)
|
||||
for (i1 = 0; i1 < Dex[i0].Eyes.Capacity; i1++)
|
||||
Dex[i0].Eyes.Add(EXPElement.Read(temp[i1]));
|
||||
}
|
||||
temp.Dispose();
|
||||
@@ -218,12 +223,12 @@ namespace KKdMainLib
|
||||
dex[i0] = exp;
|
||||
}
|
||||
|
||||
dex.Write(true, file, json);
|
||||
dex.Write(false, true, file, json);
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); Dex = null; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; Dex = null; header = default; disposed = true; } }
|
||||
|
||||
public struct EXP
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
@@ -8,9 +8,7 @@ namespace KKdMainLib
|
||||
{
|
||||
public static class DIVAFILE
|
||||
{
|
||||
private static readonly byte[] Key = new byte[]
|
||||
{ 0x66, 0x69, 0x6C, 0x65, 0x20, 0x61, 0x63, 0x63,
|
||||
0x65, 0x73, 0x73, 0x20, 0x64, 0x65, 0x6E, 0x79 };
|
||||
private static readonly byte[] Key = "file access deny".ToASCII();
|
||||
|
||||
public static void Decrypt(this string file)
|
||||
{
|
||||
|
||||
+59
-46
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
@@ -7,8 +7,8 @@ namespace KKdMainLib
|
||||
{
|
||||
public struct DataBank : IDisposable
|
||||
{
|
||||
private Stream _IO;
|
||||
private int i;
|
||||
private Stream s;
|
||||
|
||||
public PvList[] pvList;
|
||||
public PsrData[] psrData;
|
||||
@@ -44,29 +44,41 @@ namespace KKdMainLib
|
||||
else if (file.Contains("PvList")) Success = true;
|
||||
}
|
||||
|
||||
public void DBWriter(string file, uint num2)
|
||||
public byte[] DBWriter(string file)
|
||||
{
|
||||
if (!Success) return;
|
||||
if (!Success) return null;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
s = File.OpenWriter();
|
||||
if (file.Contains("psrData"))
|
||||
{
|
||||
if (psrData != null && psrData.Length > 0)
|
||||
for (i = 0; i < psrData.Length; i++)
|
||||
_IO.W(psrData[i].ToString() + c);
|
||||
if (psrData[i].PV_ID == 92)
|
||||
s.W(psrData[i].ToString() + c);
|
||||
else
|
||||
s.W(psrData[i].ToString() + c);
|
||||
}
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (pvList != null && pvList.Length > 0)
|
||||
{
|
||||
for (i = 0; i < pvList.Length - 1; i++)
|
||||
_IO.W(UrlEncode(pvList[i].ToString() + c));
|
||||
_IO.W(UrlEncode(pvList[i].ToString()));
|
||||
s.W(UrlEncode(pvList[i].ToString() + c));
|
||||
s.W(UrlEncode(pvList[i].ToString()));
|
||||
}
|
||||
else _IO.W("%2A%2A%2A");
|
||||
else s.W("%2A%2A%2A");
|
||||
}
|
||||
|
||||
return s.ToArray(true);
|
||||
}
|
||||
|
||||
public void DBWriter(string file, uint num2)
|
||||
{
|
||||
if (!Success) return;
|
||||
|
||||
byte[] data = DBWriter(file);
|
||||
if (data == null) return;
|
||||
|
||||
byte[] data = _IO.ToArray(true);
|
||||
ushort num = DCC.CalculateChecksum(data);
|
||||
File.WriteAllBytes(file + "_" + num + "_" + num2 + ".dat", data);
|
||||
}
|
||||
@@ -133,15 +145,15 @@ namespace KKdMainLib
|
||||
}
|
||||
else msgPack.Add(new MsgPack("PvList", null));
|
||||
}
|
||||
msgPack.Write(file, json).Dispose();
|
||||
msgPack.Write(file, false, json).Dispose();
|
||||
}
|
||||
|
||||
public static string UrlEncode(string value) =>
|
||||
WebUtility.UrlEncode(value).Replace("+", "%20");
|
||||
WebUtility.UrlEncode(value).Replace("+", "%20").Replace("!", "%21").Replace("*", "%2A");
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); psrData = null;
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; psrData = null;
|
||||
pvList = null; Success = false; disposed = true; } }
|
||||
|
||||
public struct PsrData
|
||||
@@ -166,9 +178,9 @@ namespace KKdMainLib
|
||||
else { id = msg.RnI32("ID"); if (id != null) PV_ID = (int)id; }
|
||||
|
||||
MsgPack temp;
|
||||
if ((temp = msg["P1", true]).NotNull) p1.SetValue(temp);
|
||||
if ((temp = msg["P2", true]).NotNull) p2.SetValue(temp);
|
||||
if ((temp = msg["P3", true]).NotNull) p3.SetValue(temp);
|
||||
if ((temp = msg["P1"]).NotNull) p1.SetValue(temp);
|
||||
if ((temp = msg["P2"]).NotNull) p2.SetValue(temp);
|
||||
if ((temp = msg["P3"]).NotNull) p3.SetValue(temp);
|
||||
temp.Dispose();
|
||||
}
|
||||
|
||||
@@ -177,35 +189,35 @@ namespace KKdMainLib
|
||||
.Add(p2.WriteMP("P2")).Add(p3.WriteMP("P3"));
|
||||
|
||||
public override string ToString() =>
|
||||
UrlEncode($"{p1.ToString()},{p2.ToString()},{p3.ToString()},{PV_ID}");
|
||||
UrlEncode($"{p1},{p2},{p3},{PV_ID}");
|
||||
}
|
||||
|
||||
public struct Player
|
||||
{
|
||||
public int Score0;
|
||||
public int Score1;
|
||||
public string Name0;
|
||||
public string Name1;
|
||||
public string Name;
|
||||
public string NameExtra;
|
||||
public int Score;
|
||||
public int ScoreExtra;
|
||||
public Difficulty Diff;
|
||||
public bool Has2P => Name1 != null;
|
||||
public bool HasExtra => NameExtra != null;
|
||||
|
||||
public void SetValue(string[] data, int i = 0, int offset = 0)
|
||||
{
|
||||
string[] array = data[i * 13 + offset * 4].Split('.');
|
||||
Score0 = int.Parse(array[0]);
|
||||
if (array.Length > 1) Score1 = int.Parse(array[1]);
|
||||
Score = int.Parse(array[0]);
|
||||
if (array.Length > 1) ScoreExtra = int.Parse(array[1]);
|
||||
string text = "";
|
||||
for (int j = 0; j < data[i * 13 + 1 + offset * 4].Length; j++)
|
||||
{
|
||||
text += data[i * 13 + 1 + offset * 4][j].ToString();
|
||||
if (text.EndsWith("xxx"))
|
||||
{
|
||||
Name0 = text.Remove(text.Length - 3);
|
||||
Name = text.Remove(text.Length - 3);
|
||||
text = "";
|
||||
}
|
||||
}
|
||||
if (array.Length == 1) Name0 = text;
|
||||
else Name1 = text;
|
||||
if (array.Length == 1) Name = text;
|
||||
else NameExtra = text;
|
||||
if (int.TryParse(data[i * 13 + 2 + offset * 4], out int Diff))
|
||||
this.Diff = (Difficulty)Diff;
|
||||
else
|
||||
@@ -215,28 +227,29 @@ namespace KKdMainLib
|
||||
public void SetValue(MsgPack msg)
|
||||
{
|
||||
Diff = (Difficulty)msg.RI32("Diff");
|
||||
Score0 = msg.RI32 ("Score");
|
||||
Name0 = msg.RS( "Name");
|
||||
if (Name0 == null)
|
||||
Name = msg.RS ( "Name");
|
||||
NameExtra = msg.RS ( "NameExtra");
|
||||
Score = msg.RI32("Score");
|
||||
ScoreExtra = msg.RI32("ScoreExtra");
|
||||
|
||||
if (Name == null)
|
||||
{
|
||||
Score0 = msg.RI32("Score0");
|
||||
Score1 = msg.RI32("Score1");
|
||||
Name0 = msg.RS ( "Name0");
|
||||
Name1 = msg.RS ( "Name1");
|
||||
Name = msg.RS ( "Name0");
|
||||
NameExtra = msg.RS ( "Name1");
|
||||
Score = msg.RI32("Score0");
|
||||
ScoreExtra = msg.RI32("Score1");
|
||||
}
|
||||
else Name1 = null;
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(string name) =>
|
||||
Has2P ? new MsgPack(name).Add("Diff", (int)Diff).Add("Score0", Score0)
|
||||
.Add("Score1", Score1).Add("Name0", Name0).Add("Name1", Name1) :
|
||||
new MsgPack(name).Add("Diff", (int)Diff)
|
||||
.Add("Score" , Score0).Add("Name" , Name0);
|
||||
HasExtra ? new MsgPack(name).Add("Diff", (int)Diff).Add("Name", Name)
|
||||
.Add("NameExtra", NameExtra).Add("Score", Score).Add("ScoreExtra", ScoreExtra) :
|
||||
new MsgPack(name).Add("Diff", (int)Diff).Add("Name" , Name) .Add("Score" , Score);
|
||||
|
||||
public override string ToString() =>
|
||||
(Score0 + (Has2P ? (d + Score1) : "") + c + UrlEncode(Name0) +
|
||||
(Has2P ? ("xxx" + UrlEncode(Name1)) : "") + c +
|
||||
Diff + c + (Has2P ? "0.1" : "0")).Replace("*", "%2A");
|
||||
Score + (HasExtra ? (d + ScoreExtra) : "") + c + UrlEncode(Name) +
|
||||
(HasExtra ? ("xxx" + UrlEncode(NameExtra)) : "") + c +
|
||||
(int)Diff + c + (HasExtra ? "0.1" : "0");
|
||||
}
|
||||
|
||||
public struct PvList
|
||||
@@ -290,9 +303,9 @@ namespace KKdMainLib
|
||||
|
||||
public MsgPack WriteMP()
|
||||
{
|
||||
MsgPack msgPack = MsgPack.New.Add("ID" , PV_ID )
|
||||
.Add("Version", Version)
|
||||
.Add("Edition", Edition);
|
||||
MsgPack msgPack = MsgPack.New.Add("ID" , PV_ID );
|
||||
if (Version != 1) msgPack.Add("Version", Version);
|
||||
if (Edition != 0) msgPack.Add("Edition", Edition);
|
||||
if (AdvDemoStart.WU) msgPack.Add("AdvDemoStart", AdvDemoStart.Int);
|
||||
if (AdvDemoEnd .WL) msgPack.Add("AdvDemoEnd" , AdvDemoEnd .Int);
|
||||
if (StartShow .WL) msgPack.Add("StartShow" , StartShow .Int);
|
||||
@@ -375,7 +388,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"{Year.ToString("d4")}-{Month.ToString("d2")}-{Day.ToString("d2")}";
|
||||
$"{Year:d4}-{Month:d2}-{Day:d2}";
|
||||
}
|
||||
|
||||
public enum Difficulty
|
||||
|
||||
+63
-64
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -16,31 +16,35 @@ namespace KKdMainLib
|
||||
|
||||
public static Header ReadHeader(this Stream stream, bool readSectionSignature = true)
|
||||
{
|
||||
Header header = new Header { Format = Format.F2LE, Signature = stream.RI32(),
|
||||
DataSize = stream.RI32(), Length = stream.RI32(), Flags = stream.RI32(),
|
||||
Depth = stream.RI32(), SectionSize = stream.RI32(),
|
||||
Mode = stream.RI32() };
|
||||
Header header = new Header { Format = Format.F2 };
|
||||
header.Signature = stream.RU32();
|
||||
header.DataSize = stream.RU32();
|
||||
header.Length = stream.RU32();
|
||||
header.Flags = stream.RU32();
|
||||
header.Depth = stream.RU32();
|
||||
header.SectionSize = stream.RU32();
|
||||
header.Version = stream.RU32();
|
||||
stream.RI32();
|
||||
if ((header.Flags & 0x08000000) == 0x08000000) header.Format = Format.F2BE;
|
||||
header.NotUseDataSizeAsSectionSize = (header.Flags & 0x10000000) != 0x10000000;
|
||||
header.UseBigEndian = (header.Flags & 0x08000000) != 0;
|
||||
header.UseSectionSize = (header.Flags & 0x10000000) != 0;
|
||||
if (header.Length == 0x40)
|
||||
{
|
||||
stream.RI64();
|
||||
stream.RI64();
|
||||
header.InnerSignature = stream.RI32();
|
||||
header.InnerSignature = stream.RU32();
|
||||
stream.RI32();
|
||||
stream.RI64();
|
||||
}
|
||||
stream.Format = header.Format;
|
||||
if (readSectionSignature) header.SectionSignature = stream.RI32E();
|
||||
if (readSectionSignature) header.SectionSignature = stream.RU32E();
|
||||
return header;
|
||||
}
|
||||
|
||||
public static void W(this Stream stream, Header header, bool extended = false)
|
||||
{
|
||||
header.Length = (header.Format < Format.X && extended) ? 0x40 : 0x20;
|
||||
header.Flags = (!header.NotUseDataSizeAsSectionSize ? 0x10000000 : 0) |
|
||||
(header.Format == Format.F2BE ? 0x08000000 : 0);
|
||||
header.Length = (header.Format < Format.X && extended) ? 0x40u : 0x20u;
|
||||
header.Flags = (header.UseSectionSize ? 0x10000000 : 0u) |
|
||||
(header.UseBigEndian ? 0x08000000 : 0u);
|
||||
|
||||
stream.W(header.Signature);
|
||||
stream.W(header.DataSize);
|
||||
@@ -48,13 +52,11 @@ namespace KKdMainLib
|
||||
stream.W(header.Flags);
|
||||
stream.W(header.Depth);
|
||||
stream.W(header.SectionSize);
|
||||
stream.W(header.Mode);
|
||||
stream.W(header.Version);
|
||||
stream.W(0x00);
|
||||
if (header.Length == 0x40)
|
||||
{
|
||||
stream.W(header.Format < Format.MGF ? (int)((header.SectionSignature ^
|
||||
(header.DataSize * (long)header.Signature)) - header.Depth + header.SectionSize) : 0);
|
||||
stream.W(0x00);
|
||||
stream.W(0x00L);
|
||||
stream.W(0x00L);
|
||||
stream.W(header.InnerSignature);
|
||||
stream.W(0x00);
|
||||
@@ -62,31 +64,33 @@ namespace KKdMainLib
|
||||
}
|
||||
}
|
||||
|
||||
public static void WEOFC(this Stream stream, int depth = 0) =>
|
||||
stream.W(new Header { Depth = depth, Length = 0x20, Signature = 0x43464F45 });
|
||||
public static void WEOFC(this Stream stream, uint depth = 0) =>
|
||||
stream.W(new Header { Depth = depth, Length = 0x20, Signature = 0x43464F45, UseSectionSize = true });
|
||||
}
|
||||
|
||||
public static class POFExtensions
|
||||
{
|
||||
public static void W(this Stream stream, POF pof, bool shiftX = false, int depth = 0)
|
||||
public static void W(this Stream stream, POF pof, bool shiftX = false, uint depth = 0)
|
||||
{
|
||||
byte[] data = pof.Write(shiftX);
|
||||
Header header = new Header { Depth = depth, Format = Format.F2LE,
|
||||
Length = 0x20, Signature = shiftX ? 0x31464F50 : 0x30464F50 };
|
||||
header.DataSize = header.SectionSize = data.Length;
|
||||
Header header = new Header { Depth = depth, Format = Format.F2, Length = 0x20,
|
||||
Signature = shiftX ? 0x31464F50u : 0x30464F50u, UseSectionSize = true };
|
||||
header.DataSize = header.SectionSize = (uint)data.Length.A(0x10);
|
||||
stream.W(header);
|
||||
stream.W(data);
|
||||
for (int c = data.Length.A(0x10) - data.Length; c > 0; c--)
|
||||
stream.W((byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ENRSExtensions
|
||||
{
|
||||
public static void W(this Stream stream, ENRS enrs, int depth = 0)
|
||||
public static void W(this Stream stream, ENRS enrs, uint depth = 0)
|
||||
{
|
||||
byte[] data = enrs.Write();
|
||||
Header header = new Header { Depth = depth, Format = Format.F2LE,
|
||||
Length = 0x20, Signature = 0x53524E45 };
|
||||
header.DataSize = header.SectionSize = data.Length;
|
||||
Header header = new Header { Depth = depth, Format = Format.F2,
|
||||
Length = 0x20, Signature = 0x53524E45, UseSectionSize = true };
|
||||
header.DataSize = header.SectionSize = (uint)data.Length;
|
||||
stream.W(header);
|
||||
stream.W(data);
|
||||
}
|
||||
@@ -105,11 +109,12 @@ namespace KKdMainLib
|
||||
|
||||
public static Struct RSt(this Stream stream, Header header)
|
||||
{
|
||||
uint l = header.UseSectionSize ? header.SectionSize : header.DataSize;
|
||||
Struct @struct = new Struct { Header = header, DataOffset =
|
||||
stream.P, Data = stream.RBy(header.SectionSize) };
|
||||
int depth = header.Depth;
|
||||
stream.P, Data = stream.RBy(l) };
|
||||
uint depth = header.Depth;
|
||||
|
||||
int lastSig = 0, sig;
|
||||
uint lastSig = 0, sig;
|
||||
long length = stream.L - stream.P;
|
||||
long position = 0;
|
||||
KKdList<Struct> subStructs = KKdList<Struct>.New;
|
||||
@@ -117,40 +122,43 @@ namespace KKdMainLib
|
||||
{
|
||||
header = stream.ReadHeader(false);
|
||||
sig = header.Signature;
|
||||
position += header.Length + header.SectionSize;
|
||||
l = header.UseSectionSize ? header.SectionSize : header.DataSize;
|
||||
position += header.Length + l;
|
||||
if (sig == 0x43464F45 && header.Depth == depth + 1) break;
|
||||
else if (sig == 0x53524E45 || (sig & 0xF0FFFFFF) == 0x30464F50)
|
||||
{
|
||||
byte[] Data = stream.RBy(header.SectionSize);
|
||||
byte[] Data = stream.RBy(l);
|
||||
if (sig == 0x53524E45) @struct.ENRS.Read(Data);
|
||||
else @struct.POF .Read(Data, sig == 0x31464F50);
|
||||
}
|
||||
else if (header.Depth == 0 && sig == 0x43505854)
|
||||
{ subStructs.Add(new Struct { Header = header, DataOffset =
|
||||
stream.P, Data = stream.RBy(header.SectionSize) }); }
|
||||
else if (header.Depth <= depth) { stream.PI64 -= header.Length; break; }
|
||||
else subStructs.Add(stream.RSt(header));
|
||||
subStructs.Add(new Struct { Header = header, DataOffset = stream.P, Data = stream.RBy(l) });
|
||||
else if (header.Depth > depth) subStructs.Add(stream.RSt(header));
|
||||
else { stream.PI64 -= header.Length; break; }
|
||||
lastSig = sig;
|
||||
}
|
||||
subStructs.Capacity = subStructs.Count;
|
||||
|
||||
if (subStructs.Capacity > 0) @struct.SubStructs = subStructs.ToArray();
|
||||
return @struct;
|
||||
}
|
||||
|
||||
public static byte[] W(this Struct Struct, bool shiftX = false, bool useDepth = true)
|
||||
public static byte[] W(this Struct @struct, bool shiftX = false, bool useDepth = true)
|
||||
{
|
||||
byte[] Data;
|
||||
using (Stream stream = File.OpenWriter()) { Struct.Update(shiftX);
|
||||
stream.W(Struct, shiftX, useDepth); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
using (Stream stream = File.OpenWriter())
|
||||
{ stream.W(@struct, shiftX, useDepth); stream.WEOFC(); Data = stream.ToArray(); }
|
||||
return Data;
|
||||
}
|
||||
|
||||
public static void W(this Stream stream, Struct @struct, bool shiftX = false, bool useDepth = true)
|
||||
{
|
||||
@struct.Update(shiftX);
|
||||
|
||||
stream.W(@struct.Header);
|
||||
stream.W(@struct.Data );
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX, useDepth ? @struct.Depth + 1 : 0);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS, useDepth ? @struct.Depth + 1 : 0);
|
||||
if (@struct.Data != null) stream.W(@struct.Data);
|
||||
if (@struct.HasPOF ) stream.W(@struct.POF , shiftX, useDepth ? @struct.Depth + 1 : 0u);
|
||||
if (@struct.HasENRS) stream.W(@struct.ENRS, useDepth ? @struct.Depth + 1 : 0u);
|
||||
if (@struct.HasSubStructs)
|
||||
{
|
||||
for (int i = 0; i < @struct.SubStructs.Length; i++)
|
||||
@@ -186,35 +194,35 @@ namespace KKdMainLib
|
||||
return MsgPack;
|
||||
}
|
||||
|
||||
public static void Write(this MsgPack mp, bool temp, string file, bool json = false)
|
||||
{ if (temp) MsgPack.New.Add(mp).Write(file, json).Dispose();
|
||||
else mp .Write(file, json); }
|
||||
public static void Write(this MsgPack mp, bool ignoreNull, bool temp, string file, bool json = false)
|
||||
{ if (temp) MsgPack.New.Add(mp).Write(file, ignoreNull, json).Dispose();
|
||||
else mp .Write(file, ignoreNull, json); }
|
||||
|
||||
public static MsgPack Write(this MsgPack mp, string file, bool json = false)
|
||||
public static MsgPack Write(this MsgPack mp, string file, bool ignoreNull, bool json = false)
|
||||
{
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true))) _IO.W(mp, "\n", " ");
|
||||
else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp);
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true))) _IO.W(mp, ignoreNull, "\n", " ");
|
||||
else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp, ignoreNull);
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void WriteAfterAll(this MsgPack mp, bool temp, string file, bool json = false)
|
||||
{ if (temp) MsgPack.New.Add(mp).WriteAfterAll(file, json).Dispose();
|
||||
else mp .WriteAfterAll(file, json); }
|
||||
public static void WriteAfterAll(this MsgPack mp, bool ignoreNull, bool temp, string file, bool json = false)
|
||||
{ if (temp) MsgPack.New.Add(mp).WriteAfterAll(file, ignoreNull, json).Dispose();
|
||||
else mp .WriteAfterAll(file, ignoreNull, json); }
|
||||
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool json = false)
|
||||
public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool ignoreNull, bool json = false)
|
||||
{
|
||||
byte[] data = null;
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter())) { _IO.W(mp, true); data = _IO.ToArray(); }
|
||||
else using ( MP _IO = new MP(File.OpenWriter())) { _IO.W(mp ); data = _IO.ToArray(); }
|
||||
if (json) using (JSON _IO = new JSON(File.OpenWriter())) { _IO.W(mp, ignoreNull, true); data = _IO.ToArray(); }
|
||||
else using ( MP _IO = new MP(File.OpenWriter())) { _IO.W(mp, ignoreNull ); data = _IO.ToArray(); }
|
||||
File.WriteAllBytes(file + (json ? ".json" : ".mp"), data);
|
||||
return mp;
|
||||
}
|
||||
|
||||
public static void ToJSON (this string file) =>
|
||||
file.ReadMP( ).Write(file, true).Dispose();
|
||||
file.ReadMP( ).Write(file, false, true).Dispose();
|
||||
|
||||
public static void ToMsgPack(this string file) =>
|
||||
file.ReadMP(true).Write(file ).Dispose();
|
||||
file.ReadMP(true).Write(file, false ).Dispose();
|
||||
}
|
||||
|
||||
public static class IKFExt
|
||||
@@ -230,13 +238,4 @@ namespace KKdMainLib
|
||||
return kf;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LibDeflate
|
||||
{
|
||||
public static void Extract()
|
||||
{
|
||||
if (!File.Exists("libdeflate.dll"))
|
||||
File.WriteAllBytes("libdeflate.dll", Properties.Resources.libdeflate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-25
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace KKdMainLib.F2
|
||||
public struct Bloom : System.IDisposable
|
||||
{
|
||||
private int i;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public CountPointer<BLT> BLTs;
|
||||
@@ -15,15 +15,15 @@ namespace KKdMainLib.F2
|
||||
public void BLTReader(string file)
|
||||
{
|
||||
BLTs = default;
|
||||
_IO = File.OpenReader(file + ".blt", true);
|
||||
header = _IO.ReadHeader();
|
||||
s = File.OpenReader(file + ".blt", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x544D4C42 || header.InnerSignature != 0x3) return;
|
||||
_IO.P -= 0x4;
|
||||
s.P -= 0x4;
|
||||
|
||||
BLTs = _IO.RCPE<BLT>();
|
||||
if (BLTs.C < 1) { _IO.C(); BLTs.C = -1; return; }
|
||||
BLTs = s.RCPE<BLT>();
|
||||
if (BLTs.C < 1) { s.C(); BLTs.C = -1; return; }
|
||||
|
||||
if (BLTs.C > 0 && BLTs.O == 0) { _IO.C(); BLTs.C = -1; return; }
|
||||
if (BLTs.C > 0 && BLTs.O == 0) { s.C(); BLTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
@@ -31,41 +31,41 @@ namespace KKdMainLib.F2
|
||||
BLTs = _IO.ReadCountPointerX<BLT>();
|
||||
}*/
|
||||
|
||||
_IO.P = BLTs.O;
|
||||
s.P = BLTs.O;
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
{
|
||||
ref BLT blt = ref BLTs.E[i];
|
||||
_IO.RI32E();
|
||||
blt.Color .X = _IO.RF32E();
|
||||
blt.Color .Y = _IO.RF32E();
|
||||
blt.Color .Z = _IO.RF32E();
|
||||
blt.Brightpass.X = _IO.RF32E();
|
||||
blt.Brightpass.Y = _IO.RF32E();
|
||||
blt.Brightpass.Z = _IO.RF32E();
|
||||
blt.Range = _IO.RF32E();
|
||||
s.RI32E();
|
||||
blt.Color .X = s.RF32E();
|
||||
blt.Color .Y = s.RF32E();
|
||||
blt.Color .Z = s.RF32E();
|
||||
blt.Brightpass.X = s.RF32E();
|
||||
blt.Brightpass.Y = s.RF32E();
|
||||
blt.Brightpass.Z = s.RF32E();
|
||||
blt.Range = s.RF32E();
|
||||
}
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (BLTs.C < 1) return;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
_IO.WPSSJIS("ID,ColorR,ColorG,ColorB,BrightpassR,BrightpassG,BrightpassB,Range\n");
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,ColorR,ColorG,ColorB,BrightpassR,BrightpassG,BrightpassB,Range\n");
|
||||
for (i = 0; i < BLTs.C; i++)
|
||||
_IO.W(i + "," + BLTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_bloom.txt", _IO.ToArray(true));
|
||||
s.W(i + "," + BLTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_bloom.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); BLTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; BLTs = default; header = default; disposed = true; } }
|
||||
|
||||
public struct BLT
|
||||
{
|
||||
public Vector3 Color;
|
||||
public Vector3 Brightpass;
|
||||
public Vec3 Color;
|
||||
public Vec3 Brightpass;
|
||||
public float Range;
|
||||
|
||||
public override string ToString() => Color .ToString(6) + "," +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace KKdMainLib.F2
|
||||
public struct ColorCorrection : System.IDisposable
|
||||
{
|
||||
private int i;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public CountPointer<CCT> CCTs;
|
||||
@@ -15,15 +15,15 @@ namespace KKdMainLib.F2
|
||||
public void CCTReader(string file)
|
||||
{
|
||||
CCTs = default;
|
||||
_IO = File.OpenReader(file + ".cct", true);
|
||||
header = _IO.ReadHeader();
|
||||
s = File.OpenReader(file + ".cct", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x54524343 || header.InnerSignature != 0x3) return;
|
||||
_IO.P -= 0x4;
|
||||
s.P -= 0x4;
|
||||
|
||||
CCTs = _IO.RCPE<CCT>();
|
||||
if (CCTs.C < 1) { _IO.C(); CCTs.C = -1; return; }
|
||||
CCTs = s.RCPE<CCT>();
|
||||
if (CCTs.C < 1) { s.C(); CCTs.C = -1; return; }
|
||||
|
||||
if (CCTs.C > 0 && CCTs.O == 0) { _IO.C(); CCTs.C = -1; return; }
|
||||
if (CCTs.C > 0 && CCTs.O == 0) { s.C(); CCTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
@@ -31,38 +31,38 @@ namespace KKdMainLib.F2
|
||||
CCTs = _IO.ReadCountPointerX<CCT>();
|
||||
}*/
|
||||
|
||||
_IO.P = CCTs.O;
|
||||
s.P = CCTs.O;
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
{
|
||||
ref CCT cct = ref CCTs.E[i];
|
||||
_IO.RI32E();
|
||||
cct.Hue = _IO.RF32E();
|
||||
cct.Saturation = _IO.RF32E();
|
||||
cct.Lightness = _IO.RF32E();
|
||||
cct.Exposure = _IO.RF32E();
|
||||
cct.Gamma.X = _IO.RF32E();
|
||||
cct.Gamma.Y = _IO.RF32E();
|
||||
cct.Gamma.Z = _IO.RF32E();
|
||||
cct.Contrast = _IO.RF32E();
|
||||
s.RI32E();
|
||||
cct.Hue = s.RF32E();
|
||||
cct.Saturation = s.RF32E();
|
||||
cct.Lightness = s.RF32E();
|
||||
cct.Exposure = s.RF32E();
|
||||
cct.Gamma.X = s.RF32E();
|
||||
cct.Gamma.Y = s.RF32E();
|
||||
cct.Gamma.Z = s.RF32E();
|
||||
cct.Contrast = s.RF32E();
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (CCTs.C < 1) return;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
_IO.WPSSJIS("ID,Hue,Saturation,Lightness,Exposure,GammaR,GammaG,GammaB,Contrast\n");
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,Hue,Saturation,Lightness,Exposure,GammaR,GammaG,GammaB,Contrast\n");
|
||||
for (i = 0; i < CCTs.C; i++)
|
||||
_IO.W(i + "," + CCTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_cc.txt", _IO.ToArray(true));
|
||||
s.W(i + "," + CCTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_cc.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); CCTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; CCTs = default; header = default; disposed = true; } }
|
||||
|
||||
public struct CCT
|
||||
{
|
||||
@@ -70,7 +70,7 @@ namespace KKdMainLib.F2
|
||||
public float Saturation;
|
||||
public float Lightness;
|
||||
public float Exposure;
|
||||
public Vector3 Gamma;
|
||||
public Vec3 Gamma;
|
||||
public float Contrast;
|
||||
|
||||
public override string ToString() => Hue .ToS(6) + "," +
|
||||
|
||||
+22
-22
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace KKdMainLib.F2
|
||||
public struct DOF : System.IDisposable
|
||||
{
|
||||
private int i;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public CountPointer<DFT> DFTs;
|
||||
@@ -15,15 +15,15 @@ namespace KKdMainLib.F2
|
||||
public void DFTReader(string file)
|
||||
{
|
||||
DFTs = default;
|
||||
_IO = File.OpenReader(file + ".dft", true);
|
||||
header = _IO.ReadHeader();
|
||||
s = File.OpenReader(file + ".dft", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x54464F44 || header.InnerSignature != 0x3) return;
|
||||
_IO.P -= 0x4;
|
||||
s.P -= 0x4;
|
||||
|
||||
DFTs = _IO.RCPE<DFT>();
|
||||
if (DFTs.C < 1) { _IO.C(); DFTs.C = -1; return; }
|
||||
DFTs = s.RCPE<DFT>();
|
||||
if (DFTs.C < 1) { s.C(); DFTs.C = -1; return; }
|
||||
|
||||
if (DFTs.C > 0 && DFTs.O == 0) { _IO.C(); DFTs.C = -1; return; }
|
||||
if (DFTs.C > 0 && DFTs.O == 0) { s.C(); DFTs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
@@ -31,36 +31,36 @@ namespace KKdMainLib.F2
|
||||
DFTs = _IO.ReadCountPointerX<DFT>();
|
||||
}*/
|
||||
|
||||
_IO.P = DFTs.O;
|
||||
s.P = DFTs.O;
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
{
|
||||
ref DFT DFT = ref DFTs.E[i];
|
||||
_IO.RI32E();
|
||||
DFT. Focus = _IO.RF32E();
|
||||
DFT. FocusRange = _IO.RF32E();
|
||||
DFT.FuzzingRange = _IO.RF32E();
|
||||
DFT.Ratio = _IO.RF32E();
|
||||
DFT.Quality = _IO.RF32E();
|
||||
if (_IO.IsX) _IO.RI32();
|
||||
s.RI32E();
|
||||
DFT. Focus = s.RF32E();
|
||||
DFT. FocusRange = s.RF32E();
|
||||
DFT.FuzzingRange = s.RF32E();
|
||||
DFT.Ratio = s.RF32E();
|
||||
DFT.Quality = s.RF32E();
|
||||
if (s.IsX) s.RI32();
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
{
|
||||
if (DFTs.C < 1) return;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
_IO.WPSSJIS("ID,Focus,FocusRange,FuzzingRange,Ratio,Quality\n");
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("ID,Focus,FocusRange,FuzzingRange,Ratio,Quality\n");
|
||||
for (i = 0; i < DFTs.C; i++)
|
||||
_IO.W(i + "," + DFTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_dof.txt", _IO.ToArray(true));
|
||||
s.W(i + "," + DFTs[i] + "\n");
|
||||
File.WriteAllBytes(file + "_dof.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); DFTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; DFTs = default; header = default; disposed = true; } }
|
||||
|
||||
public struct DFT
|
||||
{
|
||||
|
||||
+45
-45
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace KKdMainLib.F2
|
||||
public struct Light : System.IDisposable
|
||||
{
|
||||
private int i, i0;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
private Header header;
|
||||
|
||||
public CountPointer<CountPointer<LIT>> LITs;
|
||||
@@ -15,19 +15,19 @@ namespace KKdMainLib.F2
|
||||
public void LITReader(string file)
|
||||
{
|
||||
LITs = default;
|
||||
_IO = File.OpenReader(file + ".lit", true);
|
||||
header = _IO.ReadHeader();
|
||||
s = File.OpenReader(file + ".lit", true);
|
||||
header = s.ReadHeader();
|
||||
if (header.Signature != 0x4354494C || header.InnerSignature != 0x2 ||
|
||||
header.SectionSignature != 0x2) return;
|
||||
|
||||
LITs = _IO.RCPE<CountPointer<LIT>>();
|
||||
if (LITs.C < 1) { _IO.C(); LITs.C = -1; return; }
|
||||
LITs = s.RCPE<CountPointer<LIT>>();
|
||||
if (LITs.C < 1) { s.C(); LITs.C = -1; return; }
|
||||
|
||||
_IO.P = LITs.O;
|
||||
s.P = LITs.O;
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
LITs[i] = _IO.RCPX<LIT>();
|
||||
if ((LITs[i].C > 0 || LITs[i].O == 0) && !_IO.IsX) { _IO.C(); LITs.C = -1; return; }
|
||||
LITs[i] = s.RCPX<LIT>();
|
||||
if ((LITs[i].C > 0 || LITs[i].O == 0) && !s.IsX) { s.C(); LITs.C = -1; return; }
|
||||
/*{
|
||||
_IO.Format = Header.Format = Format.X;
|
||||
_IO.Offset = Header.Length;
|
||||
@@ -39,37 +39,37 @@ namespace KKdMainLib.F2
|
||||
|
||||
for (i = 0; i < LITs.C; i++)
|
||||
{
|
||||
_IO.P = LITs[i].O;
|
||||
s.P = LITs[i].O;
|
||||
for (i0 = 0; i0 < LITs[i].C; i0++)
|
||||
{
|
||||
ref LIT lit = ref LITs.E[i].E[i0];
|
||||
lit.Id = (Id )_IO.RI32E();
|
||||
lit.Flags = (Flags)_IO.RI32E();
|
||||
lit.Type = (Type )_IO.RI32E();
|
||||
if (_IO.IsX) { _IO.RI64(); _IO.RI64(); _IO.RI64(); }
|
||||
lit.Ambient .X = _IO.RF32E();
|
||||
lit.Ambient .Y = _IO.RF32E();
|
||||
lit.Ambient .Z = _IO.RF32E();
|
||||
lit.Ambient .W = _IO.RF32E();
|
||||
lit.Diffuse .X = _IO.RF32E();
|
||||
lit.Diffuse .Y = _IO.RF32E();
|
||||
lit.Diffuse .Z = _IO.RF32E();
|
||||
lit.Diffuse .W = _IO.RF32E();
|
||||
lit.Specular .X = _IO.RF32E();
|
||||
lit.Specular .Y = _IO.RF32E();
|
||||
lit.Specular .Z = _IO.RF32E();
|
||||
lit.Specular .W = _IO.RF32E();
|
||||
lit.Position .X = _IO.RF32E();
|
||||
lit.Position .Y = _IO.RF32E();
|
||||
lit.Position .Z = _IO.RF32E();
|
||||
lit.ToneCurve.X = _IO.RF32E();
|
||||
lit.ToneCurve.Y = _IO.RF32E();
|
||||
lit.ToneCurve.Z = _IO.RF32E();
|
||||
if (_IO.IsX) { _IO.RI64(); _IO.RI64(); _IO.RI64();
|
||||
_IO.RI64(); _IO.RI64(); _IO.RI32(); }
|
||||
lit.Id = (Id )s.RI32E();
|
||||
lit.Flags = (Flags)s.RI32E();
|
||||
lit.Type = (Type )s.RI32E();
|
||||
if (s.IsX) { s.RI64(); s.RI64(); s.RI64(); }
|
||||
lit.Ambient .X = s.RF32E();
|
||||
lit.Ambient .Y = s.RF32E();
|
||||
lit.Ambient .Z = s.RF32E();
|
||||
lit.Ambient .W = s.RF32E();
|
||||
lit.Diffuse .X = s.RF32E();
|
||||
lit.Diffuse .Y = s.RF32E();
|
||||
lit.Diffuse .Z = s.RF32E();
|
||||
lit.Diffuse .W = s.RF32E();
|
||||
lit.Specular .X = s.RF32E();
|
||||
lit.Specular .Y = s.RF32E();
|
||||
lit.Specular .Z = s.RF32E();
|
||||
lit.Specular .W = s.RF32E();
|
||||
lit.Position .X = s.RF32E();
|
||||
lit.Position .Y = s.RF32E();
|
||||
lit.Position .Z = s.RF32E();
|
||||
lit.ToneCurve.X = s.RF32E();
|
||||
lit.ToneCurve.Y = s.RF32E();
|
||||
lit.ToneCurve.Z = s.RF32E();
|
||||
if (s.IsX) { s.RI64(); s.RI64(); s.RI64();
|
||||
s.RI64(); s.RI64(); s.RI32(); }
|
||||
}
|
||||
}
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void TXTWriter(string file)
|
||||
@@ -77,13 +77,13 @@ namespace KKdMainLib.F2
|
||||
i = 0;
|
||||
if (LITs.C < 1) return;
|
||||
|
||||
_IO = File.OpenWriter();
|
||||
_IO.WPSSJIS("Type,AmbientR,AmbientG,AmbientB,DiffuseR,DiffuseG,DiffuseB,SpecularR,SpecularG," +
|
||||
s = File.OpenWriter();
|
||||
s.WPSSJIS("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].C; i0++)
|
||||
_IO.W(LITs[i][i0] + "," + i + "\n");
|
||||
File.WriteAllBytes(file + "_light.txt", _IO.ToArray(true));
|
||||
s.W(LITs[i][i0] + "," + i + "\n");
|
||||
File.WriteAllBytes(file + "_light.txt", s.ToArray(true));
|
||||
}
|
||||
|
||||
public struct LIT
|
||||
@@ -91,11 +91,11 @@ namespace KKdMainLib.F2
|
||||
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 Vec4 Ambient;
|
||||
public Vec4 Diffuse;
|
||||
public Vec4 Specular;
|
||||
public Vec3 Position;
|
||||
public Vec3 ToneCurve;
|
||||
|
||||
public override string ToString() => Flags == 0 ? ",,,,,,,,,,,,,,,," : Type + "," +
|
||||
((Flags & Flags.Ambient ) == 0 ? ",,," : Ambient .ToString(6) + ",") +
|
||||
@@ -107,7 +107,7 @@ namespace KKdMainLib.F2
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); LITs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; LITs = default; header = default; disposed = true; } }
|
||||
|
||||
public enum Id : int
|
||||
{
|
||||
|
||||
+14
-18
@@ -1,4 +1,4 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
@@ -14,9 +14,7 @@ namespace KKdMainLib
|
||||
public FARC(string file, bool isDirectory = false)
|
||||
{ if (isDirectory) DirectoryPath = file; else FilePath = file; NewFARC(); }
|
||||
|
||||
private void NewFARC() { if (!MSIO.File.Exists("libdeflate.dll"))
|
||||
File.WriteAllBytes("libdeflate.dll", Properties.Resources.libdeflate);
|
||||
Files = KKdList<FARCFile>.New; Signature = Farc.FArC; Format = Format.DT; }
|
||||
private void NewFARC() { Files = KKdList<FARCFile>.New; Signature = Farc.FArC; Format = Format.DT; }
|
||||
|
||||
public KKdList<FARCFile> Files = KKdList<FARCFile>.New;
|
||||
public Type FARCType;
|
||||
@@ -26,7 +24,7 @@ namespace KKdMainLib
|
||||
public bool HasFiles => Files.IsNull ? false : Files.Count > 0;
|
||||
public int CompressionLevel = 12;
|
||||
|
||||
private readonly byte[] key = Text.ToASCII("project_diva.bin");
|
||||
private readonly byte[] key = "project_diva.bin".ToASCII();
|
||||
|
||||
private readonly byte[] keyFT = { 0x13, 0x72, 0xD5, 0x7B, 0x6E, 0x9E,
|
||||
0x31, 0xEB, 0xA2, 0x39, 0xB8, 0x3C, 0x15, 0x57, 0xC6, 0xBB };
|
||||
@@ -57,9 +55,9 @@ namespace KKdMainLib
|
||||
reader.RI32();
|
||||
int farcMode = reader.RI32E(true);
|
||||
|
||||
Format = (FARCType & Type.ECB) != 0 && (farcMode & (farcMode - 1)) != 0 ? Format.FT : Format.DT;
|
||||
Format = (FARCType & Type.Enc) != 0 && (farcMode & (farcMode - 1)) != 0 ? Format.FT : Format.DT;
|
||||
|
||||
if (Format == Format.FT && (FARCType & Type.ECB) != 0)
|
||||
if (Format == Format.FT && (FARCType & Type.Enc) != 0)
|
||||
{
|
||||
reader.Dispose();
|
||||
byte[] header = new byte[headerLength - 0x08];
|
||||
@@ -155,18 +153,17 @@ namespace KKdMainLib
|
||||
return file.Data;
|
||||
}
|
||||
|
||||
int FileSize = (FARCType & Type.ECB) != 0 || (file.Type & Type.ECB) != 0 ?
|
||||
file.SizeComp.A(0x10) : ((FARCType & Type.GZip) != 0 || (file.Type & Type.GZip) != 0 ? file.SizeComp : file.SizeUnc);
|
||||
int FileSize = ((FARCType | file.Type) & Type.Enc) != 0 ? file.SizeComp.A(0x10)
|
||||
: (((FARCType | file.Type) & Type.GZip) != 0 ? file.SizeComp : file.SizeUnc);
|
||||
using (Stream stream = File.OpenReader(FilePath))
|
||||
{
|
||||
stream.S(file.Offset, 0);
|
||||
file.Data = stream.RBy(FileSize);
|
||||
}
|
||||
|
||||
|
||||
if ((FARCType & Type.ECB) != 0)
|
||||
if ((FARCType & Type.Enc) != 0)
|
||||
{
|
||||
if (Format == Format.FT && (file.Type & Type.ECB) != 0)
|
||||
if (Format == Format.FT && (file.Type & Type.Enc) != 0)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(new MSIO.MemoryStream(file.Data),
|
||||
@@ -180,9 +177,8 @@ namespace KKdMainLib
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
}
|
||||
|
||||
if (((Format == Format.FT && (file.Type & Type.GZip) != 0) ||
|
||||
(FARCType & Type.GZip) != 0) && file.SizeUnc > 0)
|
||||
|
||||
if (((file.Type | FARCType) & Type.GZip) != 0 && file.SizeUnc > 0)
|
||||
file.Data = file.Data.InflateGZip(file.SizeUnc);
|
||||
|
||||
Files[i] = file;
|
||||
@@ -223,7 +219,7 @@ namespace KKdMainLib
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (!HasFiles) return;
|
||||
if (!HasFiles || (Signature != Farc.FArc && Signature != Farc.FArC && Signature != Farc.FARC)) return;
|
||||
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
@@ -292,7 +288,7 @@ namespace KKdMainLib
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
|
||||
if (Signature == Farc.FARC && (FARCType & Type.ECB) != 0)
|
||||
if (Signature == Farc.FARC && (FARCType & Type.Enc) != 0)
|
||||
{
|
||||
int alignLength = data.Length.A(0x40);
|
||||
byte[] tempData = new byte[alignLength];
|
||||
@@ -347,7 +343,7 @@ namespace KKdMainLib
|
||||
{
|
||||
None = 0b000,
|
||||
GZip = 0b010,
|
||||
ECB = 0b100,
|
||||
Enc = 0b100,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+179
-161
@@ -1,161 +1,179 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static unsafe class DeflateInflate
|
||||
{
|
||||
private const string libDeflateString = "libdeflate.dll";
|
||||
|
||||
public static byte[] Deflate(this byte[] data, long compressionLevel)
|
||||
{
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_deflate_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_deflate_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] Inflate(this byte[] data, long length)
|
||||
{
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_deflate_decompress(d, inPtr, data.Length, outPtr, (int)length, (byte*)&actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
throw new System.Exception("DeflateInflate Error: specified input length" +
|
||||
" is less than it should be for current Deflate data");
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] DeflateGZip(this byte[] data, long compressionLevel)
|
||||
{
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_deflate_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_gzip_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] InflateGZip(this byte[] data, long length)
|
||||
{
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_gzip_decompress(d, inPtr, data.Length, outPtr, (int)length, (byte*)&actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
throw new System.Exception("DeflateInflate Error: specified input length" +
|
||||
" is less than it should be for current Deflate data");
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] DeflateZLib(this byte[] data, long compressionLevel)
|
||||
{
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_deflate_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_zlib_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] InflateZLib(this byte[] data, long length)
|
||||
{
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_zlib_decompress(d, inPtr, data.Length, outPtr, (int)length, (byte*)&actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
throw new System.Exception("DeflateInflate Error: specified input length" +
|
||||
" is less than it should be for current Deflate data");
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void* libdeflate_alloc_compressor(int compressionLevel);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void* libdeflate_alloc_decompressor();
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_deflate_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_deflate_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, byte* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, byte* actualInBytes, byte* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_gzip_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_gzip_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, byte* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, byte* actualInBytes, byte* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_zlib_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_zlib_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_zlib_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, byte* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_free_compressor(void* c);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_free_decompressor(void* d);
|
||||
}
|
||||
}
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static unsafe class DeflateInflate
|
||||
{
|
||||
public static bool HasFile = false;
|
||||
|
||||
private const string libDeflateString = "libdeflate.dll";
|
||||
|
||||
public static void CheckLib()
|
||||
{
|
||||
if (!File.Exists(libDeflateString))
|
||||
File.WriteAllBytes(libDeflateString, Properties.Resources.libdeflate);
|
||||
HasFile = true;
|
||||
}
|
||||
|
||||
public static byte[] Deflate(this byte[] data, long compressionLevel)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_deflate_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_deflate_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] Inflate(this byte[] data, long length)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_deflate_decompress(d, inPtr, data.Length, outPtr, (int)length, &actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
return data.Inflate(length * 2);
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] DeflateGZip(this byte[] data, long compressionLevel)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_gzip_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_gzip_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] InflateGZip(this byte[] data, long length)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_gzip_decompress(d, inPtr, data.Length, outPtr, (int)length, &actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
return data.InflateGZip(length * 2);
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] DeflateZLib(this byte[] data, long compressionLevel)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
void* c = libdeflate_alloc_compressor((int)compressionLevel);
|
||||
int maxOutBytes = libdeflate_zlib_compress_bound(c, data.Length);
|
||||
byte[] outData = new byte[maxOutBytes];
|
||||
int actualOut = 0;
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
actualOut = libdeflate_zlib_compress(c, inPtr, data.Length, outPtr, maxOutBytes);
|
||||
libdeflate_free_compressor(c);
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
public static byte[] InflateZLib(this byte[] data, long length)
|
||||
{
|
||||
CheckLib();
|
||||
|
||||
byte[] outData = new byte[length];
|
||||
|
||||
int actualOut = 0;
|
||||
void* d = libdeflate_alloc_decompressor();
|
||||
fixed (byte* inPtr = data)
|
||||
fixed (byte* outPtr = outData)
|
||||
libdeflate_zlib_decompress(d, inPtr, data.Length, outPtr, (int)length, &actualOut);
|
||||
libdeflate_free_decompressor(d);
|
||||
|
||||
if (actualOut == 0 || actualOut > length)
|
||||
return data.InflateZLib(length * 2);
|
||||
else if (actualOut < length)
|
||||
System.Array.Resize(ref outData, (int)actualOut);
|
||||
return outData;
|
||||
}
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void* libdeflate_alloc_compressor(int compressionLevel);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void* libdeflate_alloc_decompressor();
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_deflate_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_deflate_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_deflate_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualInBytes, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_gzip_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_gzip_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_gzip_decompress_ex(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualInBytes, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_zlib_compress_bound(void* c, int length);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern int libdeflate_zlib_compress(void* c, byte* inData, int inBytes,
|
||||
byte* outData, int maxOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_zlib_decompress(void* d, byte* inData, int inBytes,
|
||||
byte* outData, int outBytesAvail, int* actualOutBytes);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_free_compressor(void* c);
|
||||
|
||||
[DllImport(libDeflateString)]
|
||||
private static extern void libdeflate_free_decompressor(void* d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,102 @@
|
||||
using MSIO = System.IO;
|
||||
using MSIO = System.IO;
|
||||
using MSIOD = System.IO.Directory;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class Directory
|
||||
{
|
||||
public static bool Exists(string path) => MSIO.Directory.Exists(path);
|
||||
public static void Delete(string path) => MSIO.Directory.Delete(path);
|
||||
public static string GetCurrentDirectory() => MSIO.Directory.GetCurrentDirectory();
|
||||
public static string[] GetFiles(string path) => MSIO.Directory.GetFiles(path);
|
||||
public static string[] GetDirectories(string path) => MSIO.Directory.GetDirectories(path);
|
||||
public static MSIO.DirectoryInfo CreateDirectory(string path) => MSIO.Directory.CreateDirectory(path);
|
||||
public static MSIO.DirectoryInfo CreateDirectory(string path) =>
|
||||
MSIOD.CreateDirectory(path);
|
||||
|
||||
public static void Delete(string path, bool recursive) =>
|
||||
MSIOD.Delete(path, recursive);
|
||||
|
||||
public static void Delete(string path) =>
|
||||
MSIOD.Delete(path);
|
||||
|
||||
public static bool Exists(string path) =>
|
||||
MSIOD.Exists(path);
|
||||
|
||||
public static System.DateTime GetCreationTime(string path) =>
|
||||
MSIOD.GetCreationTime(path);
|
||||
|
||||
public static System.DateTime GetCreationTimeUtc(string path) =>
|
||||
MSIOD.GetCreationTimeUtc(path);
|
||||
|
||||
public static string GetCurrentDirectory() =>
|
||||
MSIOD.GetCurrentDirectory();
|
||||
|
||||
public static string[] GetDirectories(string path, string searchPattern, MSIO.SearchOption searchOption) =>
|
||||
MSIOD.GetDirectories(path, searchPattern, searchOption);
|
||||
|
||||
public static string[] GetDirectories(string path, string searchPattern) =>
|
||||
MSIOD.GetDirectories(path, searchPattern);
|
||||
|
||||
public static string[] GetDirectories(string path) =>
|
||||
MSIOD.GetDirectories(path);
|
||||
|
||||
public static string GetDirectoryRoot(string path) =>
|
||||
MSIOD.GetDirectoryRoot(path);
|
||||
|
||||
public static string[] GetFiles(string path, string searchPattern, MSIO.SearchOption searchOption) =>
|
||||
MSIOD.GetFiles(path, searchPattern, searchOption);
|
||||
|
||||
public static string[] GetFiles(string path) =>
|
||||
MSIOD.GetFiles(path);
|
||||
|
||||
public static string[] GetFiles(string path, string searchPattern) =>
|
||||
MSIOD.GetFiles(path, searchPattern);
|
||||
|
||||
public static string[] GetFileSystemEntries(string path) =>
|
||||
MSIOD.GetFileSystemEntries(path);
|
||||
|
||||
public static string[] GetFileSystemEntries(string path, string searchPattern) =>
|
||||
MSIOD.GetFileSystemEntries(path, searchPattern);
|
||||
|
||||
public static string[] GetFileSystemEntries(string path, string searchPattern, MSIO.SearchOption searchOption) =>
|
||||
MSIOD.GetFileSystemEntries(path, searchPattern, searchOption);
|
||||
|
||||
public static System.DateTime GetLastAccessTime(string path) =>
|
||||
MSIOD.GetLastAccessTime(path);
|
||||
|
||||
public static System.DateTime GetLastAccessTimeUtc(string path) =>
|
||||
MSIOD.GetLastAccessTimeUtc(path);
|
||||
|
||||
public static System.DateTime GetLastWriteTime(string path) =>
|
||||
MSIOD.GetLastWriteTime(path);
|
||||
|
||||
public static System.DateTime GetLastWriteTimeUtc(string path) =>
|
||||
MSIOD.GetLastWriteTimeUtc(path);
|
||||
|
||||
public static string[] GetLogicalDrives() =>
|
||||
MSIOD.GetLogicalDrives();
|
||||
|
||||
public static MSIO.DirectoryInfo GetParent(string path) =>
|
||||
MSIOD.GetParent(path);
|
||||
|
||||
public static void Move(string sourceDirName, string destDirName) =>
|
||||
MSIOD.Move(sourceDirName, destDirName);
|
||||
|
||||
public static void SetCreationTime(string path, System.DateTime creationTime) =>
|
||||
MSIOD.SetCreationTime(path, creationTime);
|
||||
|
||||
public static void SetCreationTimeUtc(string path, System.DateTime creationTimeUtc) =>
|
||||
MSIOD.SetCreationTimeUtc(path, creationTimeUtc);
|
||||
|
||||
public static void SetCurrentDirectory(string path) =>
|
||||
MSIOD.SetCurrentDirectory(path);
|
||||
|
||||
public static void SetLastAccessTime(string path, System.DateTime lastAccessTime) =>
|
||||
MSIOD.SetLastAccessTime(path, lastAccessTime);
|
||||
|
||||
public static void SetLastAccessTimeUtc(string path, System.DateTime lastAccessTimeUtc) =>
|
||||
MSIOD.SetLastAccessTimeUtc(path, lastAccessTimeUtc);
|
||||
|
||||
public static void SetLastWriteTime(string path, System.DateTime lastWriteTime) =>
|
||||
MSIOD.SetLastWriteTime(path, lastWriteTime);
|
||||
|
||||
public static void SetLastWriteTimeUtc(string path, System.DateTime lastWriteTimeUtc) =>
|
||||
MSIOD.SetLastWriteTimeUtc(path, lastWriteTimeUtc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-26
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
@@ -18,6 +18,7 @@ namespace KKdMainLib.IO
|
||||
if (a == end) break;
|
||||
else s.Add(a);
|
||||
}
|
||||
s.Capacity = s.Count;
|
||||
return s.ToArray();
|
||||
}
|
||||
|
||||
@@ -64,45 +65,60 @@ namespace KKdMainLib.IO
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long RIX(this Stream stream ) => stream.IsX ?
|
||||
stream.RI64() : stream.RU32E( );
|
||||
public static long RIX(this Stream stream, bool isBE) => stream.IsX ?
|
||||
stream.RI64() : stream.RU32E(isBE);
|
||||
public static long RIX(this Stream stream ) =>
|
||||
stream.IsX ? stream.RI64() : stream.RI32E( );
|
||||
public static long RIX(this Stream stream, bool isBE) =>
|
||||
stream.IsX ? stream.RI64() : stream.RI32E(isBE);
|
||||
|
||||
public static void WX(this Stream stream, long val, ref POF POF)
|
||||
public static void WX(this Stream stream, long val, ref POF pof)
|
||||
{ if (stream.IsX) stream.W ( val);
|
||||
else stream.WE((int)val); POF.Offsets.Add(stream.P); }
|
||||
public static void WX(this Stream stream, long val, ref POF POF, bool IsBE)
|
||||
else stream.WE((int)val); pof.Offsets.Add(stream.P); }
|
||||
public static void WX(this Stream stream, long val, ref POF pof, bool isBE)
|
||||
{ if (stream.IsX) stream.W ( val );
|
||||
else stream.WE((int)val, IsBE); POF.Offsets.Add(stream.P); }
|
||||
else stream.WE((int)val, isBE); pof.Offsets.Add(stream.P); }
|
||||
|
||||
public static void WX(this Stream stream, long val)
|
||||
{ if (stream.IsX) stream.W ( val);
|
||||
else stream.WE((int)val); }
|
||||
public static void WX(this Stream stream, long val, bool IsBE)
|
||||
public static void WX(this Stream stream, long val, bool isBE)
|
||||
{ if (stream.IsX) stream.W ( val );
|
||||
else stream.WE((int)val, IsBE); }
|
||||
else stream.WE((int)val, isBE); }
|
||||
|
||||
public static byte[] RaO(this Stream stream, long Offset = -1, long Length = -1)
|
||||
public static byte[] RaO(this Stream stream, long offset = -1, long length = -1)
|
||||
{
|
||||
byte[] arr = null;
|
||||
long Position = stream.PI64;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.RIX(); }
|
||||
stream.PI64 = Offset;
|
||||
if (Length == -1) arr = stream.NT();
|
||||
else arr = stream.RBy(Length);
|
||||
if (offset == -1) { Position += stream.IsX ? 8 : 4; offset = stream.RIX(); }
|
||||
stream.PI64 = offset;
|
||||
if (length == -1) arr = stream.NT();
|
||||
else arr = stream.RBy(length);
|
||||
stream.PI64 = Position;
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long Offset = -1, long Length = -1)
|
||||
public static string RSaO(this Stream stream)
|
||||
{
|
||||
long Position = stream.PI64 + (stream.IsX ? 8 : 4);
|
||||
stream.PI64 = stream.RIX();
|
||||
string s = stream.NTUTF8();
|
||||
stream.PI64 = Position;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long offset)
|
||||
{
|
||||
string s = null;
|
||||
long Position = stream.PI64;
|
||||
if (Offset == -1) { Position += stream.IsX ? 8 : 4; Offset = stream.RIX(); }
|
||||
stream.PI64 = Offset;
|
||||
if (Length == -1) s = stream.NTUTF8();
|
||||
else s = stream.RSUTF8(Length);
|
||||
stream.PI64 = offset;
|
||||
string s = stream.NTUTF8();
|
||||
stream.PI64 = Position;
|
||||
return s;
|
||||
}
|
||||
|
||||
public static string RSaO(this Stream stream, long offset, long length)
|
||||
{
|
||||
long Position = stream.PI64;
|
||||
stream.PI64 = offset;
|
||||
string s = stream.RSUTF8(length);
|
||||
stream.PI64 = Position;
|
||||
return s;
|
||||
}
|
||||
@@ -114,11 +130,11 @@ namespace KKdMainLib.IO
|
||||
public static void WPSSJIS(this Stream stream, ref Pointer<string> val)
|
||||
{ val.O = stream.P; stream.WPSSJIS(val.V); }
|
||||
|
||||
public static string RPSSJIS(this Stream stream, long Offset = -1, long Length = -1) =>
|
||||
Text.ShiftJIS.GetString(stream.RaO(Offset, Length));
|
||||
public static string RPSSJIS(this Stream stream, long offset = -1, long length = -1) =>
|
||||
Text.ShiftJIS.GetString(stream.RaO(offset, length));
|
||||
|
||||
public static void WPSSJIS(this Stream stream, string String) =>
|
||||
stream.W(Text.ShiftJIS.GetBytes(String));
|
||||
public static void WPSSJIS(this Stream stream, string val) =>
|
||||
stream.W(val.ToSJIS());
|
||||
|
||||
public static Pointer<string> RPS(this Stream stream)
|
||||
{ Pointer<string> val = stream.RP<string>();
|
||||
|
||||
+82
-23
@@ -1,30 +1,41 @@
|
||||
using System;
|
||||
using MSIO = System.IO;
|
||||
using MSIOF = System.IO.File;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class File
|
||||
{
|
||||
public static Stream OpenReader(byte[] Data) => new Stream(new MSIO.MemoryStream(Data));
|
||||
public static Stream OpenWriter(byte[] Data) => new Stream(new MSIO.MemoryStream(Data));
|
||||
public static Stream OpenWriter( ) => new Stream(new MSIO.MemoryStream( ));
|
||||
public static Stream OpenReadWriter(byte[] data) => new Stream(new MSIO.MemoryStream(data));
|
||||
public static Stream OpenReader (byte[] data) => new Stream(new MSIO.MemoryStream(data), canWrite: false);
|
||||
public static Stream OpenWriter (byte[] data) => new Stream(new MSIO.MemoryStream(data), canRead : false);
|
||||
public static Stream OpenWriter ( ) => new Stream(new MSIO.MemoryStream( ), canRead : false);
|
||||
|
||||
public static Stream OpenReader(string file, bool ReadAllAtOnce)
|
||||
{ Stream _IO = OpenReader(file); if (ReadAllAtOnce) { byte[] data =
|
||||
public static Stream OpenReadWriter(string file)
|
||||
{ bool exist = Exists(file);
|
||||
Stream _IO = new Stream(new MSIO.FileStream(file, MSIO.FileMode.OpenOrCreate,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite)) { File = file };
|
||||
System.DateTime t = System.DateTime.UtcNow;
|
||||
if (exist) MSIOF.SetCreationTimeUtc(file, t);
|
||||
MSIOF. SetLastWriteTimeUtc(file, t);
|
||||
MSIOF.SetLastAccessTimeUtc(file, t); return _IO; }
|
||||
public static Stream OpenReader(string file, bool readAllAtOnce)
|
||||
{ Stream _IO = OpenReader(file); if (readAllAtOnce) { byte[] data =
|
||||
_IO.ToArray(); _IO.Dispose(); return OpenReader(data); } return _IO; }
|
||||
public static Stream OpenReader(string file)
|
||||
{ Stream _IO = new Stream(new MSIO.FileStream(file, MSIO.FileMode.Open, MSIO.FileAccess.ReadWrite,
|
||||
MSIO.FileShare.ReadWrite)) { File = file }; return _IO; }
|
||||
public static Stream OpenWriter(string file, bool SetLength0)
|
||||
{ Stream _IO = OpenWriter(file); if (SetLength0) _IO.SL(0); return _IO; }
|
||||
public static Stream OpenWriter(string file, int SetLength)
|
||||
{ Stream _IO = OpenWriter(file); _IO.SL(SetLength); return _IO; }
|
||||
{ Stream _IO = new Stream(new MSIO.FileStream(file, MSIO.FileMode.Open, MSIO.FileAccess.Read,
|
||||
MSIO.FileShare.ReadWrite), canWrite: false) { File = file }; return _IO; }
|
||||
public static Stream OpenWriter(string file, bool setLength0)
|
||||
{ Stream _IO = OpenWriter(file); if (setLength0) _IO.SL(0); return _IO; }
|
||||
public static Stream OpenWriter(string file, int setLength)
|
||||
{ Stream _IO = OpenWriter(file); _IO.SL(setLength); return _IO; }
|
||||
public static Stream OpenWriter(string file)
|
||||
{ Stream _IO = new Stream(new MSIO.FileStream(file,
|
||||
MSIO.FileMode.OpenOrCreate, MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite)) { File = file };
|
||||
MSIO.File. SetCreationTimeUtc(file, DateTime.UtcNow);
|
||||
MSIO.File. SetLastWriteTimeUtc(file, DateTime.UtcNow);
|
||||
MSIO.File.SetLastAccessTimeUtc(file, DateTime.UtcNow); return _IO; }
|
||||
{ bool exist = Exists(file);
|
||||
Stream _IO = new Stream(new MSIO.FileStream(file, MSIO.FileMode.OpenOrCreate,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite), canRead: false) { File = file };
|
||||
System.DateTime t = System.DateTime.UtcNow;
|
||||
if (!exist) MSIOF.SetCreationTimeUtc(file, t);
|
||||
MSIOF. SetLastWriteTimeUtc(file, t);
|
||||
MSIOF.SetLastAccessTimeUtc(file, t); return _IO; }
|
||||
|
||||
public static byte[] ReadAllBytes(string file, int length, int offset)
|
||||
{ byte[] Data; using (Stream _IO = OpenReader(file)) Data = _IO.RBy(length, offset); return Data; }
|
||||
@@ -48,8 +59,8 @@ namespace KKdMainLib.IO
|
||||
|
||||
public static void WriteAllLines(string file, string[] data)
|
||||
{ using Stream _IO = OpenWriter(file, true);
|
||||
if (data != null) for (int i = 0; i < data.Length; i++)
|
||||
if (data[i] != null) _IO.W(data[i] + "\r\n"); }
|
||||
if (data != null) { int c = data.Length; for (int i = 0; i < c; i++)
|
||||
{ if (data[i] != null) _IO.W(data[i]); if (i + 1 < c) _IO.W("\n"); } } }
|
||||
|
||||
public static void WriteAllBytes(string file, byte[] data, long length)
|
||||
{ using Stream _IO = OpenWriter(file, true); if (data != null) { _IO.W(data); _IO.LI64 = length; } }
|
||||
@@ -59,10 +70,58 @@ namespace KKdMainLib.IO
|
||||
|
||||
public static void WriteAllLines(string file, string[] data, long length)
|
||||
{ using Stream _IO = OpenWriter(file, true);
|
||||
if (data != null) { for (int i = 0; i < data.Length; i++)
|
||||
if (data[i] != null) _IO.W(data[i] + "\r\n"); } _IO.LI64 = length; }
|
||||
if (data != null) { int c = data.Length; for (int i = 0; i < c; i++)
|
||||
{ if (data[i] != null) _IO.W(data[i]); if (i + 1 < c) _IO.W("\n"); } _IO.LI64 = length; } }
|
||||
|
||||
public static bool Exists(string file) => MSIO.File.Exists(file);
|
||||
public static void Delete(string file) => MSIO.File.Delete(file);
|
||||
public static bool Exists(string file) =>
|
||||
MSIOF.Exists(file);
|
||||
|
||||
public static void Delete(string file) =>
|
||||
MSIOF.Delete(file);
|
||||
|
||||
public static MSIO.FileAttributes GetAttributes(string path) =>
|
||||
MSIOF.GetAttributes(path);
|
||||
|
||||
public static System.DateTime GetCreationTime(string path) =>
|
||||
MSIOF.GetCreationTime(path);
|
||||
|
||||
public static System.DateTime GetCreationTimeUtc(string path) =>
|
||||
MSIOF.GetCreationTimeUtc(path);
|
||||
|
||||
public static System.DateTime GetLastAccessTime(string path) =>
|
||||
MSIOF.GetLastAccessTime(path);
|
||||
|
||||
public static System.DateTime GetLastAccessTimeUtc(string path) =>
|
||||
MSIOF.GetLastAccessTimeUtc(path);
|
||||
|
||||
public static System.DateTime GetLastWriteTime(string path) =>
|
||||
MSIOF.GetLastWriteTime(path);
|
||||
|
||||
public static System.DateTime GetLastWriteTimeUtc(string path) =>
|
||||
MSIOF.GetLastWriteTimeUtc(path);
|
||||
|
||||
public static void Move(string sourceFileName, string destFileName) =>
|
||||
MSIOF.Move(sourceFileName, destFileName);
|
||||
|
||||
public static void SetAttributes(string path, MSIO.FileAttributes fileAttributes) =>
|
||||
MSIOF.SetAttributes(path, fileAttributes);
|
||||
|
||||
public static void SetCreationTime(string path, System.DateTime creationTime) =>
|
||||
MSIOF.SetCreationTime(path, creationTime);
|
||||
|
||||
public static void SetCreationTimeUtc(string path, System.DateTime creationTimeUtc) =>
|
||||
MSIOF.SetCreationTimeUtc(path, creationTimeUtc);
|
||||
|
||||
public static void SetLastAccessTime(string path, System.DateTime lastAccessTime) =>
|
||||
MSIOF.SetLastAccessTime(path, lastAccessTime);
|
||||
|
||||
public static void SetLastAccessTimeUtc(string path, System.DateTime lastAccessTimeUtc) =>
|
||||
MSIOF.SetLastAccessTimeUtc(path, lastAccessTimeUtc);
|
||||
|
||||
public static void SetLastWriteTime(string path, System.DateTime lastWriteTime) =>
|
||||
MSIOF.SetLastWriteTime(path, lastWriteTime);
|
||||
|
||||
public static void SetLastWriteTimeUtc(string path, System.DateTime lastWriteTimeUtc) =>
|
||||
MSIOF.SetLastWriteTimeUtc(path, lastWriteTimeUtc);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-14
@@ -1,4 +1,4 @@
|
||||
//Original or reader part: https://github.com/MarcosLopezC/LightJson/
|
||||
//Original or reader part: https://github.com/MarcosLopezC/LightJson/
|
||||
|
||||
using KKdBaseLib;
|
||||
using BaseExtensions = KKdBaseLib.Extensions;
|
||||
@@ -104,7 +104,7 @@ namespace KKdMainLib.IO
|
||||
else if (c == ',') { _IO.RCUTF8(); continue; }
|
||||
else return KKdList<MsgPack>.Null;
|
||||
}
|
||||
|
||||
obj.Capacity = obj.Count;
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ namespace KKdMainLib.IO
|
||||
else if (c == ',') { _IO.RCUTF8(); continue; }
|
||||
else return null;
|
||||
}
|
||||
obj.Capacity = obj.Count;
|
||||
return obj.ToArray();
|
||||
}
|
||||
|
||||
@@ -175,18 +176,19 @@ namespace KKdMainLib.IO
|
||||
{ string s = ""; while (char.IsDigit(_IO.SW().
|
||||
PCUTF8())) s += _IO.RCUTF8(); return s; }
|
||||
|
||||
public JSON W(MsgPack msgPack, string end = "\n", string tabChar = " ") =>
|
||||
W(msgPack, end, tabChar, "", true);
|
||||
public JSON W(MsgPack msgPack, bool ignoreNull, string end = "\n", string tabChar = " ") =>
|
||||
W(msgPack, ignoreNull, end, tabChar, "", true);
|
||||
|
||||
public JSON W(MsgPack msgPack, bool style = false) =>
|
||||
W(msgPack, "\n", " ", "", style);
|
||||
public JSON W(MsgPack msgPack, bool ignoreNull, bool style = false) =>
|
||||
W(msgPack, ignoreNull, "\n", " ", "", style);
|
||||
|
||||
private JSON W(MsgPack msgPack, string end, string tabChar, string tab, bool style, bool isArray = false)
|
||||
private JSON W(MsgPack msgPack, bool ignoreNull, string end,
|
||||
string tabChar, string tab, bool style, bool isArray = false)
|
||||
{
|
||||
string oldTab = tab;
|
||||
tab += tabChar;
|
||||
if (msgPack.Name != null && !isArray) _IO.W("\"" + msgPack.Name + "\":" + (style ? " " : ""));
|
||||
if (msgPack.Object == null) { WN(); return this; }
|
||||
if (msgPack.Name != null && !isArray ) _IO.W("\"" + msgPack.Name + "\":" + (style ? " " : ""));
|
||||
if (msgPack.Object == null) { if (!ignoreNull) WN(); return this; }
|
||||
|
||||
if (msgPack.List.NotNull)
|
||||
{
|
||||
@@ -196,14 +198,14 @@ namespace KKdMainLib.IO
|
||||
for (int i = 0; i < msgPack.List.Count; i++)
|
||||
{
|
||||
if (style) _IO.W(tab);
|
||||
W(msgPack.List[i], end, tabChar, tab, style);
|
||||
W(msgPack.List[i], ignoreNull, end, tabChar, tab, style);
|
||||
if (i + 1 < msgPack.List.Count) _IO.W(',');
|
||||
if (style) _IO.W(end);
|
||||
}
|
||||
else if (msgPack.List.Count == 1)
|
||||
{
|
||||
if (style) _IO.W(tab);
|
||||
W(msgPack.List[0], end, tabChar, tab, style);
|
||||
W(msgPack.List[0], ignoreNull, end, tabChar, tab, style);
|
||||
if (style) _IO.W(end);
|
||||
}
|
||||
if (style) _IO.W(oldTab);
|
||||
@@ -217,20 +219,20 @@ namespace KKdMainLib.IO
|
||||
for (int i = 0; i < msgPack.Array.Length; i++)
|
||||
{
|
||||
if (style) _IO.W(tab);
|
||||
W(msgPack.Array[i], end, tabChar, tab, style, true);
|
||||
W(msgPack.Array[i], ignoreNull, end, tabChar, tab, style, true);
|
||||
if (i + 1 < msgPack.Array.Length) _IO.W(',');
|
||||
if (style) _IO.W(end);
|
||||
}
|
||||
else if (msgPack.Array.Length == 1)
|
||||
{
|
||||
if (style) _IO.W(tab);
|
||||
W(msgPack.Array[0], end, tabChar, tab, style, true);
|
||||
W(msgPack.Array[0], ignoreNull, end, tabChar, tab, style, true);
|
||||
if (style) _IO.W(end);
|
||||
}
|
||||
if (style) _IO.W(oldTab);
|
||||
WA(true);
|
||||
}
|
||||
else if (msgPack.Object is MsgPack msg) W(msg, end, tabChar, tab, style);
|
||||
else if (msgPack.Object is MsgPack msg) W(msg, ignoreNull, end, tabChar, tab, style);
|
||||
else if (msgPack.Object is string str) W(str);
|
||||
else _IO.W(BaseExtensions.ToS(msgPack.Object));
|
||||
|
||||
|
||||
+8
-8
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
@@ -166,23 +166,23 @@ namespace KKdMainLib.IO
|
||||
return true;
|
||||
}
|
||||
|
||||
public MP W(MsgPack msgPack, bool IsArray = false)
|
||||
public MP W(MsgPack msgPack, bool ignoreNull, bool IsArray = false)
|
||||
{
|
||||
if (msgPack.Name != null && !IsArray) W(msgPack.Name);
|
||||
Write(msgPack.Object);
|
||||
Write(msgPack.Object, ignoreNull);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Write(object obj)
|
||||
private void Write(object obj, bool ignoreNull)
|
||||
{
|
||||
if (obj == null) { WN(); return; }
|
||||
if (obj == null) { if (!ignoreNull) WN(); return; }
|
||||
switch (obj)
|
||||
{
|
||||
case KKdList<MsgPack> val: WM(val.Count );
|
||||
for (int i = 0; i < val.Count ; i++) W(val[i]); break;
|
||||
for (int i = 0; i < val.Count ; i++) W(val[i], ignoreNull); break;
|
||||
case MsgPack[] val: WA(val.Length);
|
||||
for (int i = 0; i < val.Length; i++) W(val[i]); break;
|
||||
case MsgPack val: W(val); break;
|
||||
for (int i = 0; i < val.Length; i++) W(val[i], ignoreNull); break;
|
||||
case MsgPack val: W(val, ignoreNull); break;
|
||||
case byte[] val: W(val); break;
|
||||
case bool val: W(val); break;
|
||||
case sbyte val: W(val); break;
|
||||
|
||||
+55
-15
@@ -1,26 +1,66 @@
|
||||
using MSIO = System.IO;
|
||||
using MSIOP = System.IO.Path;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
public static class Path
|
||||
{
|
||||
public static string GetFileName(string path) =>
|
||||
MSIO.Path.GetFileName(path);
|
||||
public static string GetFileNameWithoutExtension(string path) =>
|
||||
MSIO.Path.GetFileNameWithoutExtension(path);
|
||||
public static string GetExtension(string path) =>
|
||||
MSIO.Path.GetExtension(path);
|
||||
public static string GetFullPath(string path) =>
|
||||
MSIO.Path.GetFullPath(path);
|
||||
public static string Combine(string path1, string path2) =>
|
||||
MSIO.Path.Combine(path1, path2);
|
||||
public static char DirectorySeparatorChar => MSIOP.DirectorySeparatorChar;
|
||||
public static char AltDirectorySeparatorChar => MSIOP.AltDirectorySeparatorChar;
|
||||
public static char VolumeSeparatorChar => MSIOP.VolumeSeparatorChar;
|
||||
public static char PathSeparator => MSIOP.PathSeparator;
|
||||
|
||||
public static string ChangeExtension(string path, string extension) =>
|
||||
MSIOP.ChangeExtension(path, extension);
|
||||
|
||||
public static string Combine(string path1, string path2, string path3) =>
|
||||
MSIO.Path.Combine(path1, path2, path3);
|
||||
MSIOP.Combine(path1, path2, path3);
|
||||
|
||||
public static string Combine(string path1, string path2) =>
|
||||
MSIOP.Combine(path1, path2);
|
||||
|
||||
public static string Combine(string path1, string path2, string path3, string path4) =>
|
||||
MSIO.Path.Combine(path1, path2, path3, path4);
|
||||
MSIOP.Combine(path1, path2, path3, path4);
|
||||
|
||||
public static string Combine(params string[] paths) =>
|
||||
MSIO.Path.Combine(paths);
|
||||
MSIOP.Combine(paths);
|
||||
|
||||
public static string GetDirectoryName(string path) =>
|
||||
MSIO.Path.GetDirectoryName(path);
|
||||
MSIOP.GetDirectoryName(path);
|
||||
|
||||
public static string GetExtension(string path) =>
|
||||
MSIOP.GetExtension(path);
|
||||
|
||||
public static string GetFileName(string path) =>
|
||||
MSIOP.GetFileName(path);
|
||||
|
||||
public static string GetFileNameWithoutExtension(string path) =>
|
||||
MSIOP.GetFileNameWithoutExtension(path);
|
||||
|
||||
public static string GetFullPath(string path) =>
|
||||
MSIOP.GetFullPath(path);
|
||||
|
||||
public static char[] GetInvalidFileNameChars() =>
|
||||
MSIOP.GetInvalidFileNameChars();
|
||||
|
||||
public static char[] GetInvalidPathChars() =>
|
||||
MSIOP.GetInvalidPathChars();
|
||||
|
||||
public static string GetPathRoot(string path) =>
|
||||
MSIOP.GetPathRoot(path);
|
||||
|
||||
public static string GetRandomFileName() =>
|
||||
MSIOP.GetRandomFileName();
|
||||
|
||||
public static string GetTempFileName() =>
|
||||
MSIOP.GetTempFileName();
|
||||
|
||||
public static string GetTempPath() =>
|
||||
MSIOP.GetTempPath();
|
||||
|
||||
public static bool HasExtension(string path) =>
|
||||
MSIOP.HasExtension(path);
|
||||
|
||||
public static bool IsPathRooted(string path) =>
|
||||
MSIOP.IsPathRooted(path);
|
||||
}
|
||||
}
|
||||
|
||||
+236
-164
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using MSIO = System.IO;
|
||||
using ENRSDict = System.Collections.Generic.Dictionary<long, int>;
|
||||
using ENRSDict = System.Collections.Generic.Dictionary<long, byte>;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
@@ -11,15 +11,16 @@ namespace KKdMainLib.IO
|
||||
private byte[] b;
|
||||
private MSIO.Stream s;
|
||||
|
||||
private readonly bool canRead;
|
||||
private readonly bool canWrite;
|
||||
|
||||
private bool getENRS;
|
||||
|
||||
private Format format = Format.NULL;
|
||||
|
||||
public Format Format
|
||||
{ get => format;
|
||||
set { format = value;
|
||||
IsBE = format == Format.F2BE;
|
||||
IsX = format == Format.X || format == Format.XHD; } }
|
||||
{ get => format;
|
||||
set { format = value; IsX = format == Format.X || format == Format.XHD; } }
|
||||
|
||||
public ENRSDict ENRSDict;
|
||||
|
||||
@@ -42,14 +43,14 @@ namespace KKdMainLib.IO
|
||||
public uint PU32 { get => (uint)s.Position - OU32; set => s.Position = value + OU32; }
|
||||
public long PI64 { get => s.Position - OI64; set => s.Position = value + OI64; }
|
||||
|
||||
public bool CanRead => s.CanRead;
|
||||
public bool CanRead => canRead ;
|
||||
public bool CanSeek => s.CanSeek;
|
||||
public bool CanTimeout => s.CanTimeout;
|
||||
public bool CanWrite => s.CanWrite;
|
||||
public bool CanWrite => s.CanWrite && canWrite;
|
||||
|
||||
public string File = null;
|
||||
|
||||
public Stream(MSIO.Stream output = null, bool isBE = false)
|
||||
public Stream(MSIO.Stream output = null, bool isBE = false, bool canRead = true, bool canWrite = true)
|
||||
{
|
||||
if (output == null) output = MSIO.Stream.Null;
|
||||
OI64 = 0;
|
||||
@@ -59,6 +60,8 @@ namespace KKdMainLib.IO
|
||||
Format = Format.NULL;
|
||||
b = new byte[0x100];
|
||||
IsBE = isBE;
|
||||
this.canRead = s.CanRead && canRead;
|
||||
this.canWrite = s.CanWrite && canWrite;
|
||||
}
|
||||
|
||||
public void C() => D(true);
|
||||
@@ -92,12 +95,12 @@ namespace KKdMainLib.IO
|
||||
if (P % align != 0) s.Seek(P + O + Al, 0);
|
||||
}
|
||||
|
||||
public void A(long align, bool SetLength)
|
||||
public void A(long align, bool setLength)
|
||||
{
|
||||
if (SetLength) s.SetLength(P + O);
|
||||
if (setLength) s.SetLength(P + O);
|
||||
long Al = align - P % align;
|
||||
if (P % align != 0) s.Seek(P + O + Al, 0);
|
||||
if (SetLength) s.SetLength(P + O);
|
||||
if (setLength) s.SetLength(P + O);
|
||||
}
|
||||
|
||||
public void A(long align, bool setLength0, bool setLength1)
|
||||
@@ -108,56 +111,59 @@ namespace KKdMainLib.IO
|
||||
if (setLength1) s.SetLength(P + O);
|
||||
}
|
||||
|
||||
public bool RBo () => s.ReadByte() != 0;
|
||||
public sbyte RI8 () => (sbyte)s.ReadByte();
|
||||
public byte RU8 () => ( byte)s.ReadByte();
|
||||
public short RI16() { s.Read(b, 0, 2); return b.TI16(); }
|
||||
public ushort RU16() { s.Read(b, 0, 2); return b.TU16(); }
|
||||
public int RI32() { s.Read(b, 0, 4); return b.TI32(); }
|
||||
public uint RU32() { s.Read(b, 0, 4); return b.TU32(); }
|
||||
public long RI64() { s.Read(b, 0, 8); return b.TI64(); }
|
||||
public ulong RU64() { s.Read(b, 0, 8); return b.TU64(); }
|
||||
public float RF32() { s.Read(b, 0, 4); return b.TF32(); }
|
||||
public double RF64() { s.Read(b, 0, 8); return b.TF64(); }
|
||||
private void cR() { if (!canRead ) throw new Exception("Stream cannot be read!"); }
|
||||
private void cW() { if (!canWrite) throw new Exception("Stream cannot be read!"); }
|
||||
|
||||
public short RI16E() { s.Read(b, 0, 2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16E() { s.Read(b, 0, 2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32E() { s.Read(b, 0, 4); b.E(4, IsBE); return b.TI32(); }
|
||||
public uint RU32E() { s.Read(b, 0, 4); b.E(4, IsBE); return b.TU32(); }
|
||||
public long RI64E() { s.Read(b, 0, 8); b.E(8, IsBE); return b.TI64(); }
|
||||
public ulong RU64E() { s.Read(b, 0, 8); b.E(8, IsBE); return b.TU64(); }
|
||||
public float RF32E() { s.Read(b, 0, 4); b.E(4, IsBE); return b.TF32(); }
|
||||
public double RF64E() { s.Read(b, 0, 8); b.E(8, IsBE); return b.TF64(); }
|
||||
public bool RBo () { cR(); return s.ReadByte() != 0; }
|
||||
public sbyte RI8 () { cR(); return (sbyte)s.ReadByte(); }
|
||||
public byte RU8 () { cR(); return ( byte)s.ReadByte(); }
|
||||
public short RI16() { cR(); s.Read(b, 0, 2); return b.TI16(); }
|
||||
public ushort RU16() { cR(); s.Read(b, 0, 2); return b.TU16(); }
|
||||
public int RI32() { cR(); s.Read(b, 0, 4); return b.TI32(); }
|
||||
public uint RU32() { cR(); s.Read(b, 0, 4); return b.TU32(); }
|
||||
public long RI64() { cR(); s.Read(b, 0, 8); return b.TI64(); }
|
||||
public ulong RU64() { cR(); s.Read(b, 0, 8); return b.TU64(); }
|
||||
public float RF32() { cR(); s.Read(b, 0, 4); return b.TF32(); }
|
||||
public double RF64() { cR(); s.Read(b, 0, 8); return b.TF64(); }
|
||||
|
||||
public short RI16E(bool isBE) { s.Read(b, 0, 2); b.E(2, isBE); return b.TI16(); }
|
||||
public ushort RU16E(bool isBE) { s.Read(b, 0, 2); b.E(2, isBE); return b.TU16(); }
|
||||
public int RI32E(bool isBE) { s.Read(b, 0, 4); b.E(4, isBE); return b.TI32(); }
|
||||
public uint RU32E(bool isBE) { s.Read(b, 0, 4); b.E(4, isBE); return b.TU32(); }
|
||||
public long RI64E(bool isBE) { s.Read(b, 0, 8); b.E(8, isBE); return b.TI64(); }
|
||||
public ulong RU64E(bool isBE) { s.Read(b, 0, 8); b.E(8, isBE); return b.TU64(); }
|
||||
public float RF32E(bool isBE) { s.Read(b, 0, 4); b.E(4, isBE); return b.TF32(); }
|
||||
public double RF64E(bool isBE) { s.Read(b, 0, 8); b.E(8, isBE); return b.TF64(); }
|
||||
public short RI16E() { cR(); s.Read(b, 0, 2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16E() { cR(); s.Read(b, 0, 2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32E() { cR(); s.Read(b, 0, 4); b.E(4, IsBE); return b.TI32(); }
|
||||
public uint RU32E() { cR(); s.Read(b, 0, 4); b.E(4, IsBE); return b.TU32(); }
|
||||
public long RI64E() { cR(); s.Read(b, 0, 8); b.E(8, IsBE); return b.TI64(); }
|
||||
public ulong RU64E() { cR(); s.Read(b, 0, 8); b.E(8, IsBE); return b.TU64(); }
|
||||
public float RF32E() { cR(); s.Read(b, 0, 4); b.E(4, IsBE); return b.TF32(); }
|
||||
public double RF64E() { cR(); s.Read(b, 0, 8); b.E(8, IsBE); return b.TF64(); }
|
||||
|
||||
public void W(byte[] Val ) =>
|
||||
s.Write(Val ?? new byte[0], 0, Val.Length);
|
||||
public void W(byte[] Val, int Length) =>
|
||||
s.Write(Val ?? new byte[0], 0, Length);
|
||||
public void W(byte[] Val, int Offset, int Length) =>
|
||||
s.Write(Val ?? new byte[0], Offset, Length);
|
||||
public void W(char[] val, bool UTF8 = true) =>
|
||||
W(UTF8 ? val.ToUTF8() : val.ToASCII());
|
||||
public short RI16E(bool isBE) { cR(); s.Read(b, 0, 2); b.E(2, isBE); return b.TI16(); }
|
||||
public ushort RU16E(bool isBE) { cR(); s.Read(b, 0, 2); b.E(2, isBE); return b.TU16(); }
|
||||
public int RI32E(bool isBE) { cR(); s.Read(b, 0, 4); b.E(4, isBE); return b.TI32(); }
|
||||
public uint RU32E(bool isBE) { cR(); s.Read(b, 0, 4); b.E(4, isBE); return b.TU32(); }
|
||||
public long RI64E(bool isBE) { cR(); s.Read(b, 0, 8); b.E(8, isBE); return b.TI64(); }
|
||||
public ulong RU64E(bool isBE) { cR(); s.Read(b, 0, 8); b.E(8, isBE); return b.TU64(); }
|
||||
public float RF32E(bool isBE) { cR(); s.Read(b, 0, 4); b.E(4, isBE); return b.TF32(); }
|
||||
public double RF64E(bool isBE) { cR(); s.Read(b, 0, 8); b.E(8, isBE); return b.TF64(); }
|
||||
|
||||
public void W( bool val) => s.WriteByte((byte)(val ? 1 : 0));
|
||||
public void W( sbyte val) => s.WriteByte((byte) val);
|
||||
public void W( byte val) => s.WriteByte( val);
|
||||
public void W( short val) { b.GBy(val); s.Write(b, 0, 2); }
|
||||
public void W(ushort val) { b.GBy(val); s.Write(b, 0, 2); }
|
||||
public void W( int val) { b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W( uint val) { b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W( long val) { b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W( ulong val) { b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W( float val) { b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W(double val) { b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W(byte[] val )
|
||||
{ cW(); s.Write(val ?? new byte[0], 0, val.Length); }
|
||||
public void W(byte[] val, int Length)
|
||||
{ cW(); s.Write(val ?? new byte[0], 0, Length); }
|
||||
public void W(byte[] val, int offset, int length)
|
||||
{ cW(); s.Write(val ?? new byte[0], offset, length); }
|
||||
public void W(char[] val, bool utf8 = true) =>
|
||||
W(utf8 ? val.ToUTF8() : val.ToASCII());
|
||||
|
||||
public void W( bool val) { cW(); s.WriteByte((byte)(val ? 1 : 0)); }
|
||||
public void W( sbyte val) { cW(); s.WriteByte((byte) val); }
|
||||
public void W( byte val) { cW(); s.WriteByte( val); }
|
||||
public void W( short val) { cW(); b.GBy(val); s.Write(b, 0, 2); }
|
||||
public void W(ushort val) { cW(); b.GBy(val); s.Write(b, 0, 2); }
|
||||
public void W( int val) { cW(); b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W( uint val) { cW(); b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W( long val) { cW(); b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W( ulong val) { cW(); b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W( float val) { cW(); b.GBy(val); s.Write(b, 0, 4); }
|
||||
public void W(double val) { cW(); b.GBy(val); s.Write(b, 0, 8); }
|
||||
|
||||
public void W( sbyte? val) => W(val ?? default);
|
||||
public void W( byte? val) => W(val ?? default);
|
||||
@@ -170,107 +176,171 @@ namespace KKdMainLib.IO
|
||||
public void W( float? val) => W(val ?? default);
|
||||
public void W(double? val) => W(val ?? default);
|
||||
|
||||
public void W( char val, bool UTF8 = true) =>
|
||||
W(UTF8 ? val.ToString().ToUTF8() : val.ToString().ToASCII());
|
||||
public void W(string val, bool UTF8 = true) =>
|
||||
W(UTF8 ? val .ToUTF8() : val .ToASCII());
|
||||
public void W( char val, bool utf8 = true) =>
|
||||
W(utf8 ? val.ToString().ToUTF8() : val.ToString().ToASCII());
|
||||
public void W(string val, bool utf8 = true) =>
|
||||
W(utf8 ? val .ToUTF8() : val .ToASCII());
|
||||
|
||||
public void WE( short val) { b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE(ushort val) { b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE( int val) { b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE( uint val) { b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE( long val) { b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE( ulong val) { b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE( float val) { b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE(double val) { b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE( short val) { cW(); b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE(ushort val) { cW(); b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE( int val) { cW(); b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE( uint val) { cW(); b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE( long val) { cW(); b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE( ulong val) { cW(); b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE( float val) { cW(); b.GBy(val); b.E(4, IsBE); s.Write(b, 0, 4); }
|
||||
public void WE(double val) { cW(); b.GBy(val); b.E(8, IsBE); s.Write(b, 0, 8); }
|
||||
|
||||
public void WE( short val, bool isBE) { b.GBy(val); b.E(2, isBE); s.Write(b, 0, 2); }
|
||||
public void WE(ushort val, bool isBE) { b.GBy(val); b.E(2, isBE); s.Write(b, 0, 2); }
|
||||
public void WE( int val, bool isBE) { b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE( uint val, bool isBE) { b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE( long val, bool isBE) { b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE( ulong val, bool isBE) { b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE( float val, bool isBE) { b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE(double val, bool isBE) { b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE( short val, bool isBE) { cW(); b.GBy(val); b.E(2, isBE); s.Write(b, 0, 2); }
|
||||
public void WE(ushort val, bool isBE) { cW(); b.GBy(val); b.E(2, isBE); s.Write(b, 0, 2); }
|
||||
public void WE( int val, bool isBE) { cW(); b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE( uint val, bool isBE) { cW(); b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE( long val, bool isBE) { cW(); b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE( ulong val, bool isBE) { cW(); b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE( float val, bool isBE) { cW(); b.GBy(val); b.E(4, isBE); s.Write(b, 0, 4); }
|
||||
public void WE(double val, bool isBE) { cW(); b.GBy(val); b.E(8, isBE); s.Write(b, 0, 8); }
|
||||
|
||||
private void RENRS(byte[] b, int c)
|
||||
{ if (getENRS) ENRSDict.Add(P, c); s.Read(b, 0, c); }
|
||||
private void RENRS(byte c)
|
||||
{ cR(); if (getENRS) ENRSDict.Add(P, c); s.Read(b, 0, c); }
|
||||
|
||||
public short RI16ENRS() { RENRS(b, 2); return b.TI16(); }
|
||||
public ushort RU16ENRS() { RENRS(b, 2); return b.TU16(); }
|
||||
public int RI32ENRS() { RENRS(b, 4); return b.TI32(); }
|
||||
public uint RU32ENRS() { RENRS(b, 4); return b.TU32(); }
|
||||
public long RI64ENRS() { RENRS(b, 8); return b.TI64(); }
|
||||
public ulong RU64ENRS() { RENRS(b, 8); return b.TU64(); }
|
||||
public float RF32ENRS() { RENRS(b, 4); return b.TF32(); }
|
||||
public double RF64ENRS() { RENRS(b, 8); return b.TF64(); }
|
||||
public short RI16ENRS() { RENRS((byte)2); return b.TI16(); }
|
||||
public ushort RU16ENRS() { RENRS((byte)2); return b.TU16(); }
|
||||
public int RI32ENRS() { RENRS((byte)4); return b.TI32(); }
|
||||
public uint RU32ENRS() { RENRS((byte)4); return b.TU32(); }
|
||||
public long RI64ENRS() { RENRS((byte)8); return b.TI64(); }
|
||||
public ulong RU64ENRS() { RENRS((byte)8); return b.TU64(); }
|
||||
public float RF32ENRS() { RENRS((byte)4); return b.TF32(); }
|
||||
public double RF64ENRS() { RENRS((byte)8); return b.TF64(); }
|
||||
|
||||
public short RI16ENRSE() { RENRS(b, 2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE() { RENRS(b, 2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32ENRSE() { RENRS(b, 4); b.E(4, IsBE); return b.TI32(); }
|
||||
public uint RU32ENRSE() { RENRS(b, 4); b.E(4, IsBE); return b.TU32(); }
|
||||
public long RI64ENRSE() { RENRS(b, 8); b.E(8, IsBE); return b.TI64(); }
|
||||
public ulong RU64ENRSE() { RENRS(b, 8); b.E(8, IsBE); return b.TU64(); }
|
||||
public float RF32ENRSE() { RENRS(b, 4); b.E(4, IsBE); return b.TF32(); }
|
||||
public double RF64ENRSE() { RENRS(b, 8); b.E(8, IsBE); return b.TF64(); }
|
||||
public short RI16ENRSE() { RENRS((byte)2); b.E(2, IsBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE() { RENRS((byte)2); b.E(2, IsBE); return b.TU16(); }
|
||||
public int RI32ENRSE() { RENRS((byte)4); b.E(4, IsBE); return b.TI32(); }
|
||||
public uint RU32ENRSE() { RENRS((byte)4); b.E(4, IsBE); return b.TU32(); }
|
||||
public long RI64ENRSE() { RENRS((byte)8); b.E(8, IsBE); return b.TI64(); }
|
||||
public ulong RU64ENRSE() { RENRS((byte)8); b.E(8, IsBE); return b.TU64(); }
|
||||
public float RF32ENRSE() { RENRS((byte)4); b.E(4, IsBE); return b.TF32(); }
|
||||
public double RF64ENRSE() { RENRS((byte)8); b.E(8, IsBE); return b.TF64(); }
|
||||
|
||||
public short RI16ENRSE(bool isBE) { RENRS(b, 2); b.E(2, isBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE(bool isBE) { RENRS(b, 2); b.E(2, isBE); return b.TU16(); }
|
||||
public int RI32ENRSE(bool isBE) { RENRS(b, 4); b.E(4, isBE); return b.TI32(); }
|
||||
public uint RU32ENRSE(bool isBE) { RENRS(b, 4); b.E(4, isBE); return b.TU32(); }
|
||||
public long RI64ENRSE(bool isBE) { RENRS(b, 8); b.E(8, isBE); return b.TI64(); }
|
||||
public ulong RU64ENRSE(bool isBE) { RENRS(b, 8); b.E(8, isBE); return b.TU64(); }
|
||||
public float RF32ENRSE(bool isBE) { RENRS(b, 4); b.E(4, isBE); return b.TF32(); }
|
||||
public double RF64ENRSE(bool isBE) { RENRS(b, 8); b.E(8, isBE); return b.TF64(); }
|
||||
public short RI16ENRSE(bool isBE) { RENRS((byte)2); b.E(2, isBE); return b.TI16(); }
|
||||
public ushort RU16ENRSE(bool isBE) { RENRS((byte)2); b.E(2, isBE); return b.TU16(); }
|
||||
public int RI32ENRSE(bool isBE) { RENRS((byte)4); b.E(4, isBE); return b.TI32(); }
|
||||
public uint RU32ENRSE(bool isBE) { RENRS((byte)4); b.E(4, isBE); return b.TU32(); }
|
||||
public long RI64ENRSE(bool isBE) { RENRS((byte)8); b.E(8, isBE); return b.TI64(); }
|
||||
public ulong RU64ENRSE(bool isBE) { RENRS((byte)8); b.E(8, isBE); return b.TU64(); }
|
||||
public float RF32ENRSE(bool isBE) { RENRS((byte)4); b.E(4, isBE); return b.TF32(); }
|
||||
public double RF64ENRSE(bool isBE) { RENRS((byte)8); b.E(8, isBE); return b.TF64(); }
|
||||
|
||||
private void WENRS(byte[] b, int c)
|
||||
{ if (getENRS) ENRSDict.Add(P, c); s.Write(b, 0, c); }
|
||||
private void WENRS(byte c)
|
||||
{ if (getENRS) ENRSDict.Add(P, c); cW(); s.Write(b, 0, c); }
|
||||
|
||||
public void WENRS( short val) { b.GBy(val); WENRS(b, 2); }
|
||||
public void WENRS(ushort val) { b.GBy(val); WENRS(b, 2); }
|
||||
public void WENRS( int val) { b.GBy(val); WENRS(b, 4); }
|
||||
public void WENRS( uint val) { b.GBy(val); WENRS(b, 4); }
|
||||
public void WENRS( long val) { b.GBy(val); WENRS(b, 8); }
|
||||
public void WENRS( ulong val) { b.GBy(val); WENRS(b, 8); }
|
||||
public void WENRS( float val) { b.GBy(val); WENRS(b, 4); }
|
||||
public void WENRS(double val) { b.GBy(val); WENRS(b, 8); }
|
||||
public void WENRS( short val) { b.GBy(val); WENRS((byte)2); }
|
||||
public void WENRS(ushort val) { b.GBy(val); WENRS((byte)2); }
|
||||
public void WENRS( int val) { b.GBy(val); WENRS((byte)4); }
|
||||
public void WENRS( uint val) { b.GBy(val); WENRS((byte)4); }
|
||||
public void WENRS( long val) { b.GBy(val); WENRS((byte)8); }
|
||||
public void WENRS( ulong val) { b.GBy(val); WENRS((byte)8); }
|
||||
public void WENRS( float val) { b.GBy(val); WENRS((byte)4); }
|
||||
public void WENRS(double val) { b.GBy(val); WENRS((byte)8); }
|
||||
|
||||
public void WENRSE( short val) { b.GBy(val); b.E(2, IsBE); WENRS(b, 2); }
|
||||
public void WENRSE(ushort val) { b.GBy(val); b.E(2, IsBE); WENRS(b, 2); }
|
||||
public void WENRSE( int val) { b.GBy(val); b.E(4, IsBE); WENRS(b, 4); }
|
||||
public void WENRSE( uint val) { b.GBy(val); b.E(4, IsBE); WENRS(b, 4); }
|
||||
public void WENRSE( long val) { b.GBy(val); b.E(8, IsBE); WENRS(b, 8); }
|
||||
public void WENRSE( ulong val) { b.GBy(val); b.E(8, IsBE); WENRS(b, 8); }
|
||||
public void WENRSE( float val) { b.GBy(val); b.E(4, IsBE); WENRS(b, 4); }
|
||||
public void WENRSE(double val) { b.GBy(val); b.E(8, IsBE); WENRS(b, 8); }
|
||||
public void WENRSE( short val) { b.GBy(val); b.E(2, IsBE); WENRS((byte)2); }
|
||||
public void WENRSE(ushort val) { b.GBy(val); b.E(2, IsBE); WENRS((byte)2); }
|
||||
public void WENRSE( int val) { b.GBy(val); b.E(4, IsBE); WENRS((byte)4); }
|
||||
public void WENRSE( uint val) { b.GBy(val); b.E(4, IsBE); WENRS((byte)4); }
|
||||
public void WENRSE( long val) { b.GBy(val); b.E(8, IsBE); WENRS((byte)8); }
|
||||
public void WENRSE( ulong val) { b.GBy(val); b.E(8, IsBE); WENRS((byte)8); }
|
||||
public void WENRSE( float val) { b.GBy(val); b.E(4, IsBE); WENRS((byte)4); }
|
||||
public void WENRSE(double val) { b.GBy(val); b.E(8, IsBE); WENRS((byte)8); }
|
||||
|
||||
public void WENRSE( short val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS(b, 2); }
|
||||
public void WENRSE(ushort val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS(b, 2); }
|
||||
public void WENRSE( int val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS(b, 4); }
|
||||
public void WENRSE( uint val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS(b, 4); }
|
||||
public void WENRSE( long val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS(b, 8); }
|
||||
public void WENRSE( ulong val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS(b, 8); }
|
||||
public void WENRSE( float val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS(b, 4); }
|
||||
public void WENRSE(double val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS(b, 8); }
|
||||
public void WENRSE( short val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS((byte)2); }
|
||||
public void WENRSE(ushort val, bool isBE) { b.GBy(val); b.E(2, isBE); WENRS((byte)2); }
|
||||
public void WENRSE( int val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS((byte)4); }
|
||||
public void WENRSE( uint val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS((byte)4); }
|
||||
public void WENRSE( long val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS((byte)8); }
|
||||
public void WENRSE( ulong val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS((byte)8); }
|
||||
public void WENRSE( float val, bool isBE) { b.GBy(val); b.E(4, isBE); WENRS((byte)4); }
|
||||
public void WENRSE(double val, bool isBE) { b.GBy(val); b.E(8, isBE); WENRS((byte)8); }
|
||||
|
||||
public Half RF16 ( ) { ushort a = RU16 ( ); return (Half)a; }
|
||||
public Half RF16E ( ) { ushort a = RU16E ( ); return (Half)a; }
|
||||
public Half RF16E (bool isBE) { ushort a = RU16E (isBE); return (Half)a; }
|
||||
public Half RF16ENRS ( ) { ushort a = RU16E ( ); return (Half)a; }
|
||||
public Half RF16ENRSE( ) { ushort a = RU16ENRSE( ); return (Half)a; }
|
||||
public Half RF16ENRSE(bool isBE) { ushort a = RU16ENRSE(isBE); return (Half)a; }
|
||||
public int RI24 ( ) { cR(); s.Read(b, 0, 3); return b.TI24(); }
|
||||
public uint RU24 ( ) { cR(); s.Read(b, 0, 3); return b.TU24(); }
|
||||
public int RI24E( ) { cR(); s.Read(b, 0, 3); b.E(3, IsBE); return b.TI24(); }
|
||||
public uint RU24E( ) { cR(); s.Read(b, 0, 3); b.E(3, IsBE); return b.TU24(); }
|
||||
public int RI24E(bool isBE) { cR(); s.Read(b, 0, 3); b.E(3, isBE); return b.TI24(); }
|
||||
public uint RU24E(bool isBE) { cR(); s.Read(b, 0, 3); b.E(3, isBE); return b.TU24(); }
|
||||
|
||||
public void W (Half val ) => W ((ushort)val );
|
||||
public void WE (Half val ) => WE ((ushort)val );
|
||||
public void WE (Half val, bool isBE) => WE ((ushort)val, isBE);
|
||||
public void WENRS (Half val ) => WENRS ((ushort)val );
|
||||
public void WENRSE(Half val ) => WENRSE((ushort)val );
|
||||
public void WENRSE(Half val, bool isBE) => WENRSE((ushort)val, isBE);
|
||||
public Half RF16 ( ) { cR(); s.Read(b, 0, 2); return b.TF16(); }
|
||||
public Half RF16E( ) { cR(); s.Read(b, 0, 2); b.E(2, IsBE); return b.TF16(); }
|
||||
public Half RF16E(bool isBE) { cR(); s.Read(b, 0, 2); b.E(2, isBE); return b.TF16(); }
|
||||
|
||||
public char RC(bool utf8 = true) => utf8 ? RCUTF8() : (char)s.ReadByte();
|
||||
public void W (Half val ) { cW(); b.GBy(val); s.Write(b, 0, 2); }
|
||||
public void WE (Half val ) { cW(); b.GBy(val); b.E(2, IsBE); s.Write(b, 0, 2); }
|
||||
public void WE (Half val, bool isBE) { cW(); b.GBy(val); b.E(2, isBE); s.Write(b, 0, 2); }
|
||||
|
||||
public Vec2 RV2 ( ) { cR(); s.Read(b, 0, 8); return b.TV2(); }
|
||||
public Vec3 RV3 ( ) { cR(); s.Read(b, 0, 12); return b.TV3(); }
|
||||
public Vec4 RV4 ( ) { cR(); s.Read(b, 0, 16); return b.TV4(); }
|
||||
public Vec2 RV2E ( ) { cR(); s.Read(b, 0, 8); b.E( 8, IsBE); return b.TV2(); }
|
||||
public Vec3 RV3E ( ) { cR(); s.Read(b, 0, 12); b.E(12, IsBE); return b.TV3(); }
|
||||
public Vec4 RV4E ( ) { cR(); s.Read(b, 0, 16); b.E(16, IsBE); return b.TV4(); }
|
||||
public Vec2 RV2E (bool isBE) { cR(); s.Read(b, 0, 8); b.E( 8, isBE); return b.TV2(); }
|
||||
public Vec3 RV3E (bool isBE) { cR(); s.Read(b, 0, 12); b.E(12, isBE); return b.TV3(); }
|
||||
public Vec4 RV4E (bool isBE) { cR(); s.Read(b, 0, 16); b.E(16, isBE); return b.TV4(); }
|
||||
|
||||
public void W (Vec2 val ) { cW(); b.GBy(val); s.Write(b, 0, 8); }
|
||||
public void W (Vec3 val ) { cW(); b.GBy(val); s.Write(b, 0, 12); }
|
||||
public void W (Vec4 val ) { cW(); b.GBy(val); s.Write(b, 0, 16); }
|
||||
public void WE(Vec2 val ) { cW(); b.GBy(val); b.E( 8, IsBE); s.Write(b, 0, 8); }
|
||||
public void WE(Vec3 val ) { cW(); b.GBy(val); b.E(12, IsBE); s.Write(b, 0, 12); }
|
||||
public void WE(Vec4 val ) { cW(); b.GBy(val); b.E(16, IsBE); s.Write(b, 0, 16); }
|
||||
public void WE(Vec2 val, bool isBE) { cW(); b.GBy(val); b.E( 8, isBE); s.Write(b, 0, 8); }
|
||||
public void WE(Vec3 val, bool isBE) { cW(); b.GBy(val); b.E(12, isBE); s.Write(b, 0, 12); }
|
||||
public void WE(Vec4 val, bool isBE) { cW(); b.GBy(val); b.E(16, isBE); s.Write(b, 0, 16); }
|
||||
|
||||
public Quat RQ ( ) { cR(); s.Read(b, 0, 16); return b.TQ(); }
|
||||
public Quat RQE ( ) { cR(); s.Read(b, 0, 16); b.E(16, IsBE); return b.TQ(); }
|
||||
public Quat RQE (bool isBE) { cR(); s.Read(b, 0, 16); b.E(16, isBE); return b.TQ(); }
|
||||
public void W (Quat val ) { cW(); b.GBy(val); s.Write(b, 0, 16); }
|
||||
public void WE(Quat val ) { cW(); b.GBy(val); b.E(16, IsBE); s.Write(b, 0, 16); }
|
||||
public void WE(Quat val, bool isBE) { cW(); b.GBy(val); b.E(16, isBE); s.Write(b, 0, 16); }
|
||||
|
||||
public T[] RA<T>(long length, long offset = -1) where T : unmanaged
|
||||
{
|
||||
cR();
|
||||
int sizeOfT = sizeof(T);
|
||||
if (offset > -1) s.Position = offset;
|
||||
T[] array = new T[length];
|
||||
byte[] buf = new byte[sizeOfT];
|
||||
fixed (byte* ptr = buf)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
cR(); s.Read(buf, 0, sizeOfT);
|
||||
array[i] = *(T*)ptr;
|
||||
}
|
||||
|
||||
if (IsBE) array = array.ReverseEndian();
|
||||
return array;
|
||||
}
|
||||
|
||||
public void WA<T>(T[] array, long length, long offset = -1) where T : unmanaged
|
||||
{
|
||||
if (IsBE) array = array.ReverseEndian();
|
||||
|
||||
cW();
|
||||
int sizeOfT = sizeof(T);
|
||||
if (offset > -1) s.Position = offset;
|
||||
byte[] buf = new byte[sizeOfT];
|
||||
fixed (byte* ptr = buf)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
*(T*)ptr = array[i];
|
||||
s.Write(buf, 0, sizeOfT);
|
||||
}
|
||||
}
|
||||
|
||||
public char RC(bool utf8 = true)
|
||||
{ cR(); return utf8 ? RCUTF8() : (char)s.ReadByte();}
|
||||
|
||||
public char RCUTF8()
|
||||
{
|
||||
cR();
|
||||
byte t;
|
||||
int T;
|
||||
int val = 0;
|
||||
@@ -290,27 +360,26 @@ namespace KKdMainLib.IO
|
||||
return (char)val;
|
||||
}
|
||||
|
||||
public string RS(long Length, bool UTF8 = true) =>
|
||||
UTF8 ? RSUTF8(Length) : RSASCII(Length);
|
||||
public string RS(long Length, bool utf8 = true)
|
||||
{ cR(); return utf8 ? RSUTF8(Length) : RSASCII(Length);}
|
||||
|
||||
public string RSUTF8 (long length) => RBy(length).ToUTF8 ();
|
||||
public string RSASCII(long length) => RBy(length).ToASCII();
|
||||
public string RSUTF8 (long length) { cR(); return RBy(length).ToUTF8 (); }
|
||||
public string RSASCII(long length) { cR(); return RBy(length).ToASCII(); }
|
||||
|
||||
public string RS(long? length, bool utf8 = true)
|
||||
{ cR(); return utf8? RSUTF8(length) : RSASCII(length); }
|
||||
|
||||
public string RS(long? length, bool utf8 = true) =>
|
||||
utf8 ? RSUTF8(length) : RSASCII(length);
|
||||
public string RSUTF8 (long? length) { cR(); return RBy(length).ToUTF8 (); }
|
||||
public string RSASCII(long? length) { cR(); return RBy(length).ToASCII(); }
|
||||
|
||||
public string RSUTF8 (long? length) => RBy(length).ToUTF8 ();
|
||||
public string RSASCII(long? length) => RBy(length).ToASCII();
|
||||
|
||||
public byte[] RBy(long length, int offset = -1)
|
||||
{ byte[] Buf = new byte[length]; if (offset > -1) s.Position = offset;
|
||||
s.Read(Buf, 0, (int)length); return Buf; }
|
||||
public byte[] RBy(long length, long offset = -1)
|
||||
{ cR(); byte[] buf = new byte[length]; if (offset > -1) s.Position = offset;
|
||||
s.Read(buf, 0, (int)length); return buf; }
|
||||
|
||||
public int RBy(long length, byte[] buf, long offset = -1)
|
||||
{ if (offset > -1) s.Position = offset; return s.Read(buf, 0, (int)length); }
|
||||
{ cR(); if (offset > -1) s.Position = offset; return s.Read(buf, 0, (int)length); }
|
||||
|
||||
public byte[] RBy(long? length, int offset = -1)
|
||||
public byte[] RBy(long? length, long offset = -1)
|
||||
{ if (length == null) return new byte[0]; else return RBy((long)length, offset); }
|
||||
|
||||
public void RBy(long length, byte bits, byte[] buf, long offset = -1)
|
||||
@@ -319,6 +388,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
public byte RBi(byte bits)
|
||||
{
|
||||
cR();
|
||||
bitRead += bits;
|
||||
tempBitRead = 8 - bitRead;
|
||||
if (tempBitRead < 0)
|
||||
@@ -334,6 +404,7 @@ namespace KKdMainLib.IO
|
||||
|
||||
public void W(int val, byte bits)
|
||||
{
|
||||
cW();
|
||||
val &= (1 << bits) - 1;
|
||||
bitWrite += bits;
|
||||
tempBitWrite = 8 - bitWrite;
|
||||
@@ -349,19 +420,20 @@ namespace KKdMainLib.IO
|
||||
}
|
||||
|
||||
public void CR() //CheckRead
|
||||
{ if (bitRead > 0) valRead = 0; bitRead = 8; }
|
||||
{ if (bitRead > 0) valRead = 0; bitRead = 8; }
|
||||
public void CW() //CheckWrite
|
||||
{ if (bitWrite > 0) { s.WriteByte((byte)valWrite); valWrite = 0; bitWrite = 0; } }
|
||||
{ if (bitWrite > 0) { cW(); s.WriteByte((byte)valWrite); valWrite = 0; bitWrite = 0; } }
|
||||
|
||||
public byte[] ToArray(bool close)
|
||||
{ byte[] Data = ToArray(); if (close) Dispose(); return Data; }
|
||||
{ byte[] data = ToArray(); if (close) Dispose(); return data; }
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
long Position = s.Position;
|
||||
byte[] Data = RBy(s.Length, 0);
|
||||
s.Position = Position;
|
||||
return Data;
|
||||
long position = s.Position; s.Position = 0;
|
||||
byte[] data = new byte[s.Length];
|
||||
s.Read(data, 0, data.Length);
|
||||
s.Position = position;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2018-2020</Copyright>
|
||||
<Copyright>korenkonder (C) 2018-2020</Copyright>
|
||||
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files</Description>
|
||||
<FileVersion>0.4.9.0</FileVersion>
|
||||
<FileVersion>0.4.9.6</FileVersion>
|
||||
<PackageId>KKdMainLib</PackageId>
|
||||
<Product>KKdMainLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<Title>KKdMainLib</Title>
|
||||
<Version>0.4.9.0</Version>
|
||||
<Version>0.4.9.6</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,9 +37,22 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
+64
-64
@@ -1,4 +1,4 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
@@ -9,28 +9,28 @@ namespace KKdMainLib
|
||||
{
|
||||
private int i, i0, i1;
|
||||
public MotHeader[] MOT;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public void MOTReader(string file)
|
||||
{
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
s = File.OpenReader(file + ".bin");
|
||||
|
||||
i = 0;
|
||||
while (true)
|
||||
if (_IO.RI64() == 0) break;
|
||||
else { _IO.RI64(); i++; }
|
||||
if (s.RI64() == 0) break;
|
||||
else { s.RI64(); i++; }
|
||||
if (i == 0) return;
|
||||
|
||||
_IO.P = 0;
|
||||
s.P = 0;
|
||||
int motCount = i;
|
||||
MOT = new MotHeader[motCount];
|
||||
for (i = 0; i < motCount; i++)
|
||||
{
|
||||
ref MotHeader mot = ref MOT[i];
|
||||
mot.KeySet .O = _IO.RI32();
|
||||
mot.KeySetTypesOffset = _IO.RI32();
|
||||
mot. KeySetOffset = _IO.RI32();
|
||||
mot.BoneInfo .O = _IO.RI32();
|
||||
mot.KeySet .O = s.RI32();
|
||||
mot.KeySetTypesOffset = s.RI32();
|
||||
mot. KeySetOffset = s.RI32();
|
||||
mot.BoneInfo .O = s.RI32();
|
||||
}
|
||||
|
||||
for (i = 0; i < motCount; i++)
|
||||
@@ -38,128 +38,128 @@ namespace KKdMainLib
|
||||
ref MotHeader mot = ref MOT[i];
|
||||
|
||||
i0 = 1;
|
||||
_IO.P = mot.BoneInfo.O;
|
||||
_IO.RU16();
|
||||
while (_IO.RU16() != 0) i0++;
|
||||
s.P = mot.BoneInfo.O;
|
||||
s.RU16();
|
||||
while (s.RU16() != 0) i0++;
|
||||
|
||||
mot.BoneInfo.V = new BoneInfo[i0];
|
||||
_IO.P = mot.BoneInfo.O;
|
||||
s.P = mot.BoneInfo.O;
|
||||
for (i0 = 0; i0 < mot.BoneInfo.V.Length; i0++)
|
||||
mot.BoneInfo.V[i0].Id = _IO.RU16();
|
||||
mot.BoneInfo.V[i0].Id = s.RU16();
|
||||
|
||||
_IO.P = mot.KeySet.O;
|
||||
int info = _IO.RU16();
|
||||
s.P = mot.KeySet.O;
|
||||
int info = s.RU16();
|
||||
mot.HighBits = info >> 14;
|
||||
mot.FrameCount = _IO.RU16();
|
||||
mot.FrameCount = s.RU16();
|
||||
|
||||
mot.KeySet.V = new KeySet[info & 0x3FFF];
|
||||
_IO.P = mot.KeySetTypesOffset;
|
||||
s.P = mot.KeySetTypesOffset;
|
||||
for (i0 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
if (i0 % 8 == 0) i1 = _IO.RU16();
|
||||
if (i0 % 8 == 0) i1 = s.RU16();
|
||||
mot.KeySet.V[i0] = new KeySet { Type = (KeySetType)((i1 >> (i0 % 8 * 2)) & 0b11) };
|
||||
}
|
||||
|
||||
_IO.P = mot.KeySetOffset;
|
||||
s.P = mot.KeySetOffset;
|
||||
for (i0 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
ref KeySet key = ref mot.KeySet.V[i0];
|
||||
if (key.Type == KeySetType.Static)
|
||||
{ key.Keys = new KFT2[1];
|
||||
key.Keys[0].V = _IO.RF32(); }
|
||||
key.Keys[0].V = s.RF32(); }
|
||||
else if (key.Type == KeySetType.Linear)
|
||||
{
|
||||
key.Keys = new KFT2[_IO.RU16()];
|
||||
key.Keys = new KFT2[s.RU16()];
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].F = _IO.RU16();
|
||||
_IO.A(0x4);
|
||||
key.Keys[i1].F = s.RU16();
|
||||
s.A(0x4);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].V = _IO.RF32();
|
||||
key.Keys[i1].V = s.RF32();
|
||||
}
|
||||
else if (key.Type == KeySetType.Interpolated)
|
||||
{
|
||||
key.Keys = new KFT2[_IO.RU16()];
|
||||
key.Keys = new KFT2[s.RU16()];
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
key.Keys[i1].F = _IO.RU16();
|
||||
_IO.A(0x4);
|
||||
key.Keys[i1].F = s.RU16();
|
||||
s.A(0x4);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ key.Keys[i1].V = _IO.RF32(); key.Keys[i1].T = _IO.RF32(); }
|
||||
{ key.Keys[i1].V = s.RF32(); key.Keys[i1].T = s.RF32(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MOTWriter(string file)
|
||||
{
|
||||
if (MOT == null) return;
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
|
||||
int MOTCount = MOT.Length;
|
||||
_IO.P = (MOTCount + 1) << 4;
|
||||
s.P = (MOTCount + 1) << 4;
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader mot = ref MOT[i];
|
||||
mot.KeySet.O = _IO.P;
|
||||
_IO.W((ushort)((mot.HighBits << 14) | (mot.KeySet.V.Length & 0x3FFF)));
|
||||
_IO.W((ushort)mot.FrameCount);
|
||||
mot.KeySet.O = s.P;
|
||||
s.W((ushort)((mot.HighBits << 14) | (mot.KeySet.V.Length & 0x3FFF)));
|
||||
s.W((ushort)mot.FrameCount);
|
||||
|
||||
mot.KeySetTypesOffset = _IO.P;
|
||||
mot.KeySetTypesOffset = s.P;
|
||||
for (i0 = 0, i1 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
i1 |= ((byte)mot.KeySet.V[i0].Type << (i0 % 8 * 2)) & (0b11 << (i0 % 8 * 2));
|
||||
|
||||
if (i0 % 8 == 7) { _IO.W((ushort)i1); i1 = 0; }
|
||||
if (i0 % 8 == 7) { s.W((ushort)i1); i1 = 0; }
|
||||
}
|
||||
_IO.W((ushort)i1);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
s.W((ushort)i1);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
|
||||
mot.KeySetOffset = _IO.P;
|
||||
mot.KeySetOffset = s.P;
|
||||
for (i0 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
ref KeySet key = ref mot.KeySet.V[i0];
|
||||
if (key.Type == KeySetType.Static)
|
||||
_IO.W(key.Keys[0].V);
|
||||
s.W(key.Keys[0].V);
|
||||
else if (key.Type == KeySetType.Linear)
|
||||
{
|
||||
_IO.W((ushort)key.Keys.Length);
|
||||
s.W((ushort)key.Keys.Length);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W((ushort)key.Keys[i1].F);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
s.W((ushort)key.Keys[i1].F);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W(key.Keys[i1].V);
|
||||
s.W(key.Keys[i1].V);
|
||||
}
|
||||
else if (key.Type == KeySetType.Interpolated)
|
||||
{
|
||||
_IO.W((ushort)key.Keys.Length);
|
||||
s.W((ushort)key.Keys.Length);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W((ushort)key.Keys[i1].F);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
s.W((ushort)key.Keys[i1].F);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ _IO.W(key.Keys[i1].V); _IO.W(key.Keys[i1].T); }
|
||||
{ s.W(key.Keys[i1].V); s.W(key.Keys[i1].T); }
|
||||
}
|
||||
}
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
|
||||
mot.BoneInfo.O = _IO.P;
|
||||
mot.BoneInfo.O = s.P;
|
||||
for (i0 = 0; i0 < mot.BoneInfo.V.Length; i0++)
|
||||
_IO.W((ushort)mot.BoneInfo.V[i0].Id);
|
||||
_IO.W((ushort)0);
|
||||
s.W((ushort)mot.BoneInfo.V[i0].Id);
|
||||
s.W((ushort)0);
|
||||
}
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
_IO.A(0x4, true);
|
||||
if (s.P % 4 != 0) s.W((ushort)0x00);
|
||||
s.A(0x4, true);
|
||||
|
||||
_IO.P = 0;
|
||||
s.P = 0;
|
||||
for (i = 0; i < MOTCount; i++)
|
||||
{
|
||||
ref MotHeader mot = ref MOT[i];
|
||||
_IO.W(mot.KeySet .O );
|
||||
_IO.W(mot.KeySetTypesOffset);
|
||||
_IO.W(mot. KeySetOffset);
|
||||
_IO.W(mot.BoneInfo .O );
|
||||
s.W(mot.KeySet .O );
|
||||
s.W(mot.KeySetTypesOffset);
|
||||
s.W(mot. KeySetOffset);
|
||||
s.W(mot.BoneInfo .O );
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
@@ -184,7 +184,7 @@ namespace KKdMainLib
|
||||
MsgPack mot = new MsgPack(motCount, "MOT");
|
||||
for (i = 0; i < motCount; i++)
|
||||
mot[i] = MsgPackWriter(ref MOT[i]);
|
||||
mot.Write(true, file, json);
|
||||
mot.Write(false, true, file, json);
|
||||
}
|
||||
|
||||
public void MsgPackReader(MsgPack msgPack, ref MotHeader mot)
|
||||
@@ -315,7 +315,7 @@ namespace KKdMainLib
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_IO = null;
|
||||
s = null;
|
||||
MOT = null;
|
||||
}
|
||||
|
||||
|
||||
+121
-110
@@ -1,63 +1,63 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct MotHead
|
||||
public struct MotHead : System.IDisposable
|
||||
{
|
||||
private int i, i0, i1;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public HeaderData Header;
|
||||
|
||||
public void MotHeadReader(string file)
|
||||
{
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
_IO.RI32();
|
||||
s = File.OpenReader(file + ".bin");
|
||||
s.RI32();
|
||||
Header = new HeaderData();
|
||||
|
||||
int offset = _IO.RI32();
|
||||
int offset = s.RI32();
|
||||
if (offset < 0x10) goto RETURN;
|
||||
_IO.O = offset;
|
||||
_IO.P = 0;
|
||||
s.O = offset;
|
||||
s.P = 0;
|
||||
|
||||
Header. MotionSetID = _IO.RI32();
|
||||
Header.StartMotionID = _IO.RI32();
|
||||
Header. EndMotionID = _IO.RI32();
|
||||
Header.SubHeaderOffset = _IO.RI32();
|
||||
Header. MotionSetID = s.RI32();
|
||||
Header.StartMotionID = s.RI32();
|
||||
Header. EndMotionID = s.RI32();
|
||||
Header.SubHeaderOffset = s.RI32();
|
||||
|
||||
if (Header.SubHeaderOffset < 0x10) goto RETURN;
|
||||
i0 = Header.EndMotionID - Header.StartMotionID;
|
||||
if (i0 < 0) goto RETURN;
|
||||
|
||||
_IO.P = Header.SubHeaderOffset;
|
||||
s.P = Header.SubHeaderOffset;
|
||||
Header.Data = new HeaderData.Sub[++i0];
|
||||
for (i = 0; i < Header.Data.Length; i++) Header.Data[i].Offset = _IO.RI32();
|
||||
for (i = 0; i < Header.Data.Length; i++) Header.Data[i].Offset = s.RI32();
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
if (Header.Data[i].Offset < 0x10) continue;
|
||||
|
||||
_IO.P = Header.Data[i].Offset;
|
||||
s.P = Header.Data[i].Offset;
|
||||
|
||||
Header.Data[i].MotionID = Header.StartMotionID + i;
|
||||
Header.Data[i].SomeData = _IO.RI32();
|
||||
_IO.RI64();
|
||||
_IO.RI64();
|
||||
Header.Data[i].Offset2 = _IO.RI32();
|
||||
Header.Data[i].DataHeaderOffset = _IO.RI32();
|
||||
Header.Data[i].SomeData = s.RI32();
|
||||
s.RI64();
|
||||
s.RI64();
|
||||
Header.Data[i].Offset2 = s.RI32();
|
||||
Header.Data[i].DataHeaderOffset = s.RI32();
|
||||
|
||||
if (Header.Data[i].DataHeaderOffset < 0x10) goto RETURN;
|
||||
_IO.P = Header.Data[i].DataHeaderOffset;
|
||||
s.P = Header.Data[i].DataHeaderOffset;
|
||||
i0 = 0;
|
||||
while (_IO.RI32() != -1) { _IO.RI32(); _IO.RI32(); i0++; }
|
||||
_IO.P = Header.Data[i].DataHeaderOffset;
|
||||
while (s.RI32() != -1) { s.RI32(); s.RI32(); i0++; }
|
||||
s.P = Header.Data[i].DataHeaderOffset;
|
||||
|
||||
Header.Data[i].Array = new HeaderData.Sub.Data[i0];
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
Header.Data[i].Array[i0].Type = _IO.RI32();
|
||||
Header.Data[i].Array[i0].Frame = _IO.RI32();
|
||||
Header.Data[i].Array[i0].Offset = _IO.RI32();
|
||||
Header.Data[i].Array[i0].Type = s.RI32();
|
||||
Header.Data[i].Array[i0].Frame = s.RI32();
|
||||
Header.Data[i].Array[i0].Offset = s.RI32();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,25 +65,25 @@ namespace KKdMainLib
|
||||
{
|
||||
if (Header.Data[i].Offset2 > 0x10)
|
||||
{
|
||||
_IO.P = Header.Data[i].Offset2;
|
||||
s.P = Header.Data[i].Offset2;
|
||||
i0 = 0;
|
||||
while (_IO.RI32() != -1) { _IO.RI32(); i0++; }
|
||||
_IO.P = Header.Data[i].Offset2;
|
||||
while (s.RI32() != -1) { s.RI32(); i0++; }
|
||||
s.P = Header.Data[i].Offset2;
|
||||
|
||||
Header.Data[i].Array2 = new HeaderData.Sub.Data2[i0];
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{
|
||||
Header.Data[i].Array2[i0].Frame = _IO.RI32();
|
||||
Header.Data[i].Array2[i0].Offset = _IO.RI32();
|
||||
Header.Data[i].Array2[i0].Frame = s.RI32();
|
||||
Header.Data[i].Array2[i0].Offset = s.RI32();
|
||||
}
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{
|
||||
if (Header.Data[i].Array2[i0].Offset < 0x10) goto RETURN;
|
||||
_IO.P = Header.Data[i].Array2[i0].Offset;
|
||||
s.P = Header.Data[i].Array2[i0].Offset;
|
||||
Header.Data[i].Array2[i0].Array = new int[7];
|
||||
for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length; i1++)
|
||||
Header.Data[i].Array2[i0].Array[i1] = _IO.RI32();
|
||||
Header.Data[i].Array2[i0].Array[i1] = s.RI32();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,24 +92,25 @@ namespace KKdMainLib
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
ref HeaderData.Sub.Data Data = ref Header.Data[i].Array[i0];
|
||||
if (!GetSize(Data.Type, out i1)) goto RETURN;
|
||||
if ((i1 = GetSize(Data.Type)) < 1) continue;
|
||||
|
||||
|
||||
if (Data.Offset > 0)
|
||||
{
|
||||
_IO.P = Data.Offset;
|
||||
if (i1 == 0x01) Data.Array = new int[] { _IO.RU8 () };
|
||||
else if (i1 == 0x02) Data.Array = new int[] { _IO.RU16() };
|
||||
s.P = Data.Offset;
|
||||
if (i1 == 0x01) Data.Array = new int[] { s.RU8 () };
|
||||
else if (i1 == 0x02) Data.Array = new int[] { s.RU16() };
|
||||
else
|
||||
{
|
||||
Data.Array = new int[i1 / 4];
|
||||
for (i1 = 0; i1 < Data.Array.Length; i1++) Data.Array[i1] = _IO.RI32();
|
||||
for (i1 = 0; i1 < Data.Array.Length; i1++) Data.Array[i1] = s.RI32();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RETURN:
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MotHeadWriter(string file)
|
||||
@@ -126,77 +127,75 @@ RETURN:
|
||||
Header. EndMotionID = Header.Data[i].MotionID;
|
||||
}
|
||||
|
||||
_IO = File.OpenWriter(file + ".bin");
|
||||
_IO.W(0x01);
|
||||
_IO.W(0x20);
|
||||
_IO.A(0x20, true);
|
||||
_IO.O = 0x20;
|
||||
_IO.P = 0;
|
||||
_IO.W(0);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
s.W(0x01);
|
||||
s.W(0x20);
|
||||
s.A(0x20, true);
|
||||
s.O = 0x20;
|
||||
s.P = 0;
|
||||
s.W(0);
|
||||
for (int I = Header.EndMotionID - Header.StartMotionID; I > -1; I--)
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
if (Header.StartMotionID + I == Header.Data[i].MotionID)
|
||||
{
|
||||
_IO.A(0x20, true);
|
||||
Header.Data[i].Offset = _IO.P;
|
||||
s.A(0x20, true);
|
||||
Header.Data[i].Offset = s.P;
|
||||
Header.Data[i].DataHeaderOffset = Header.Data[i].Offset + 0x20;
|
||||
_IO.W(0L);
|
||||
_IO.W(0L);
|
||||
_IO.W(0L);
|
||||
_IO.W(0L);
|
||||
s.W(0L);
|
||||
s.W(0L);
|
||||
s.W(0L);
|
||||
s.W(0L);
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{ _IO.W( 0); _IO.W( 0); _IO.W(0); }
|
||||
_IO.W(-1); _IO.W(-1); _IO.W(0);
|
||||
{ s.W( 0); s.W( 0); s.W(0); }
|
||||
s.W(-1); s.W(-1); s.W(0);
|
||||
|
||||
for (i0 = Header.Data[i].Array.Length - 1; i0 > -1; i0--)
|
||||
{
|
||||
ref HeaderData.Sub.Data data = ref Header.Data[i].Array[i0];
|
||||
if (data.Array != null)
|
||||
if (data.Array.Length > 0 &&
|
||||
GetSize(data.Type, out int Size))
|
||||
{
|
||||
if (data.Type == 0x3E) _IO.A(0x20, true);
|
||||
data.Offset = _IO.P;
|
||||
int Size = GetSize(data.Type);
|
||||
if (data.Array == null || data.Array.Length < 1 || Size < 1) continue;
|
||||
|
||||
if (Size == 0x01) _IO.W(( byte)data.Array[0]);
|
||||
else if (Size == 0x02) _IO.W((short)data.Array[0]);
|
||||
else
|
||||
{
|
||||
if (_IO.P % 0x4 != 0) _IO.A(0x04, true);
|
||||
Size /= 4;
|
||||
if (data.Type == 0x3E) s.A(0x20, true);
|
||||
data.Offset = s.P;
|
||||
|
||||
data.Offset = _IO.P;
|
||||
for (i1 = 0; i1 < data.Array.Length && i1 < Size; i1++)
|
||||
_IO.W(data.Array[i1]);
|
||||
if (Size == 0x01) s.W(( byte)data.Array[0]);
|
||||
else if (Size == 0x02) s.W((short)data.Array[0]);
|
||||
else
|
||||
{
|
||||
if (s.P % 0x4 != 0) s.A(0x04, true);
|
||||
Size /= 4;
|
||||
|
||||
for (; i1 < Size; i1++) _IO.W(0);
|
||||
}
|
||||
}
|
||||
data.Offset = s.P;
|
||||
for (i1 = 0; i1 < data.Array.Length && i1 < Size; i1++)
|
||||
s.W(data.Array[i1]);
|
||||
|
||||
for (; i1 < Size; i1++) s.W(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Header.Data[i].Array2 != null)
|
||||
if (Header.Data[i].Array2.Length > 0)
|
||||
{
|
||||
Header.Data[i].Offset2 = _IO.P;
|
||||
Header.Data[i].Offset2 = s.P;
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{ _IO.W( 0); _IO.W(0); }
|
||||
_IO.W(-1); _IO.W(0);
|
||||
{ s.W( 0); s.W(0); }
|
||||
s.W(-1); s.W(0);
|
||||
|
||||
for (i0 = Header.Data[i].Array2.Length - 1; i0 > -1; i0--)
|
||||
{
|
||||
Header.Data[i].Array2[i0].Offset = _IO.P;
|
||||
Header.Data[i].Array2[i0].Offset = s.P;
|
||||
for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length && i1 < 7; i1++)
|
||||
_IO.W(Header.Data[i].Array2[i0].Array[i1]);
|
||||
s.W(Header.Data[i].Array2[i0].Array[i1]);
|
||||
|
||||
for (; i1 < 7; i1++) _IO.W(0);
|
||||
for (; i1 < 7; i1++) s.W(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
_IO.A(0x20, true);
|
||||
Header.SubHeaderOffset = _IO.P;
|
||||
s.A(0x20, true);
|
||||
Header.SubHeaderOffset = s.P;
|
||||
i1 = Header.EndMotionID - Header.StartMotionID;
|
||||
|
||||
int offset = 0;
|
||||
@@ -206,44 +205,44 @@ RETURN:
|
||||
for (i0 = 0; i0 < Header.Data.Length; i0++)
|
||||
if (Header.StartMotionID + i == Header.Data[i0].MotionID)
|
||||
{ offset = Header.Data[i0].Offset; break; }
|
||||
_IO.W(offset);
|
||||
s.W(offset);
|
||||
}
|
||||
_IO.A(0x20, true);
|
||||
s.A(0x20, true);
|
||||
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
_IO.P = Header.Data[i].Offset;
|
||||
_IO.W(Header.Data[i].SomeData);
|
||||
_IO.W(0);
|
||||
_IO.W(0L);
|
||||
_IO.W(0x040004);
|
||||
_IO.W(Header.Data[i].Offset2);
|
||||
_IO.W(Header.Data[i].DataHeaderOffset);
|
||||
_IO.W(0);
|
||||
s.P = Header.Data[i].Offset;
|
||||
s.W(Header.Data[i].SomeData);
|
||||
s.W(0);
|
||||
s.W(0L);
|
||||
s.W(0x040004);
|
||||
s.W(Header.Data[i].Offset2);
|
||||
s.W(Header.Data[i].DataHeaderOffset);
|
||||
s.W(0);
|
||||
|
||||
_IO.P = Header.Data[i].DataHeaderOffset;
|
||||
s.P = Header.Data[i].DataHeaderOffset;
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
_IO.W(Header.Data[i].Array[i0].Type );
|
||||
_IO.W(Header.Data[i].Array[i0].Frame );
|
||||
_IO.W(Header.Data[i].Array[i0].Offset);
|
||||
s.W(Header.Data[i].Array[i0].Type );
|
||||
s.W(Header.Data[i].Array[i0].Frame );
|
||||
s.W(Header.Data[i].Array[i0].Offset);
|
||||
}
|
||||
|
||||
_IO.P = Header.Data[i].Offset2;
|
||||
s.P = Header.Data[i].Offset2;
|
||||
if (Header.Data[i].Array2 != null)
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{
|
||||
_IO.W(Header.Data[i].Array2[i0].Frame );
|
||||
_IO.W(Header.Data[i].Array2[i0].Offset);
|
||||
s.W(Header.Data[i].Array2[i0].Frame );
|
||||
s.W(Header.Data[i].Array2[i0].Offset);
|
||||
}
|
||||
}
|
||||
|
||||
_IO.P = 0;
|
||||
_IO.W(Header.MotionSetID );
|
||||
_IO.W(Header.StartMotionID );
|
||||
_IO.W(Header. EndMotionID );
|
||||
_IO.W(Header.SubHeaderOffset);
|
||||
_IO.C();
|
||||
s.P = 0;
|
||||
s.W(Header.MotionSetID );
|
||||
s.W(Header.StartMotionID );
|
||||
s.W(Header. EndMotionID );
|
||||
s.W(Header.SubHeaderOffset);
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
@@ -675,19 +674,29 @@ RETURN:
|
||||
I++;
|
||||
}
|
||||
motHead.Add(motions);
|
||||
motHead.WriteAfterAll(true, file, json);
|
||||
motHead.WriteAfterAll(false, true, file, json);
|
||||
}
|
||||
|
||||
private static bool GetSize(int Type, out int Size)
|
||||
{
|
||||
Size = Type switch
|
||||
private static int GetSize(int Type) =>
|
||||
Type switch
|
||||
{
|
||||
0x02 => 0x02,
|
||||
0x03 => 0x04,
|
||||
0x04 => 0x04,
|
||||
0x07 => 0x08,
|
||||
0x08 => 0x08,
|
||||
0x0D => 0x0C,
|
||||
0x11 => 0x1C,
|
||||
0x1D => 0x30,
|
||||
0x20 => 0x10,
|
||||
0x21 => 0x18,
|
||||
0x35 => 0x14,
|
||||
0x36 => 0x14,
|
||||
0x37 => 0x14,
|
||||
0x38 => 0x14,
|
||||
0x39 => 0x14,
|
||||
0x3A => 0x14,
|
||||
0x3B => 0x04,
|
||||
0x3C => 0x10,
|
||||
0x3D => 0x08,
|
||||
0x3E => 0x40,
|
||||
@@ -705,12 +714,14 @@ RETURN:
|
||||
0x4B => 0x34,
|
||||
0x4C => 0x10,
|
||||
0x4D => 0x04,
|
||||
0x4E => 0x1C,
|
||||
0x4F => 0x01,
|
||||
0x50 => 0x04,
|
||||
0x50 => 0x01,
|
||||
_ => 0x00,
|
||||
};
|
||||
return Size > 0;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{ if (s != null) s.D(); s = null; Header = default; }
|
||||
|
||||
public struct HeaderData
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
+9
-9
@@ -1,4 +1,4 @@
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
namespace KKdMainLib.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -23,15 +23,15 @@ namespace KKdMainLib.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
@@ -45,7 +45,7 @@ namespace KKdMainLib.Properties {
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
@@ -59,7 +59,7 @@ namespace KKdMainLib.Properties {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
|
||||
+79
-70
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -8,148 +8,156 @@ namespace KKdMainLib
|
||||
{
|
||||
private POF pof;
|
||||
private Header header;
|
||||
private Stream _IO;
|
||||
private Stream s;
|
||||
|
||||
public String[] Strings;
|
||||
|
||||
public int STRReader(string filepath, string ext)
|
||||
{
|
||||
_IO = File.OpenReader(filepath + ext);
|
||||
s = File.OpenReader(filepath + ext);
|
||||
|
||||
header = new Header();
|
||||
_IO.Format = Format.F;
|
||||
header.Signature = _IO.RI32();
|
||||
s.Format = Format.F;
|
||||
header.Signature = s.RU32();
|
||||
if (header.Signature == 0x41525453)
|
||||
{
|
||||
header = _IO.ReadHeader(true, false);
|
||||
header = s.ReadHeader(true, false);
|
||||
s.IsBE = header.UseBigEndian;
|
||||
s.Format = header.Format;
|
||||
|
||||
int count = _IO.RI32E();
|
||||
int offset = _IO.RI32E();
|
||||
int count = s.RI32E();
|
||||
int offset = s.RI32E();
|
||||
|
||||
_IO.P = offset;
|
||||
s.P = offset;
|
||||
Strings = new String[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Strings[i].Str.O = _IO.RI32E();
|
||||
Strings[i].ID = _IO.RI32E();
|
||||
Strings[i].Str.O = s.RI32E();
|
||||
Strings[i].ID = s.RI32E();
|
||||
}
|
||||
|
||||
_IO.O = 0;
|
||||
s.O = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
Strings[i].Str.V = Strings[i].Str.O > 0 ?
|
||||
_IO.RSaO(Strings[i].Str.O) : null;
|
||||
s.RSaO(Strings[i].Str.O) : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_IO.P -= 4;
|
||||
if ((header.Signature >> 24) > 0) { header.Format = Format.DT; s.IsBE = true; }
|
||||
else header.Format = Format.F;
|
||||
int count = 0;
|
||||
for (int a = 0, i = 0; _IO.P > 0 && _IO.P < _IO.L; i++, count++)
|
||||
{
|
||||
a = _IO.RI32();
|
||||
if (a == 0) break;
|
||||
}
|
||||
for (uint i = header.Signature; i != 0 && s.P >= 0 && s.P < s.L; count++)
|
||||
i = s.RU32();
|
||||
Strings = new String[count];
|
||||
|
||||
s.P = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_IO.PI64 = Strings[i].Str.O;
|
||||
Strings[i].ID = i;
|
||||
Strings[i].Str.V = _IO.NTUTF8();
|
||||
Strings[i].Str.V = s.RSaO();
|
||||
}
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
s.C();
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void STRWriter(string filepath)
|
||||
{
|
||||
if (Strings == null || Strings.Length == 0 || header.Format > Format.F2BE) return;
|
||||
if (Strings == null || Strings.Length == 0 || header.Format > Format.F2) return;
|
||||
uint offset = 0;
|
||||
uint currentOffset = 0;
|
||||
_IO = File.OpenWriter(filepath + (header.Format > Format.AFT &&
|
||||
Format format = header.Format;
|
||||
s = File.OpenWriter(filepath + (header.Format > Format.AFT &&
|
||||
header.Format < Format.FT ? ".str" : ".bin"), true);
|
||||
_IO.Format = header.Format;
|
||||
s.Format = header.Format;
|
||||
s.IsBE = header.UseBigEndian;
|
||||
pof.Offsets = KKdList<long>.New;
|
||||
|
||||
long count = Strings.LongLength;
|
||||
if (_IO.Format > Format.AFT && _IO.Format < Format.FT)
|
||||
if (s.Format > Format.AFT && s.Format < Format.FT)
|
||||
{
|
||||
_IO.P = 0x40;
|
||||
_IO.WX(count, ref pof);
|
||||
_IO.WX(0x80);
|
||||
_IO.P = 0x80;
|
||||
for (int i = 0; i < count; i++) _IO.W(0x00L);
|
||||
_IO.A(0x10);
|
||||
s.P = 0x40;
|
||||
s.WX(count, ref pof);
|
||||
s.WX(0x80);
|
||||
s.P = 0x80;
|
||||
for (int i = 0; i < count; i++) s.W(0x00L);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i++) _IO.W(0x00);
|
||||
_IO.A(0x20);
|
||||
}
|
||||
for (int i = 0; i < count; i++) s.W(0x00);
|
||||
s.A(0x10);
|
||||
|
||||
KKdList<string> usedSTR = KKdList<string>.New;
|
||||
KKdList<int> usedSTRPos = KKdList<int>.New;
|
||||
int[] STRPos = new int[count];
|
||||
|
||||
usedSTRPos.Add(_IO.P);
|
||||
usedSTR.Add("");
|
||||
_IO.W(0);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!usedSTR.Contains(Strings[i].Str.V))
|
||||
if (usedSTR.Contains(Strings[i].Str.V))
|
||||
{
|
||||
STRPos[i] = _IO.P;
|
||||
usedSTRPos.Add(STRPos[i]);
|
||||
usedSTR.Add(Strings[i].Str.V);
|
||||
_IO.W(Strings[i].Str.V);
|
||||
_IO.W(0);
|
||||
for (int i2 = 0; i2 < count; i2++)
|
||||
if (usedSTR[i2] == Strings[i].Str.V)
|
||||
{ STRPos[i] = usedSTRPos[i2]; break; }
|
||||
}
|
||||
else
|
||||
for (int i2 = 0; i2 < count; i2++)
|
||||
if (usedSTR[i2] == Strings[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; }
|
||||
{
|
||||
usedSTRPos.Add(STRPos[i] = s.P);
|
||||
usedSTR.Add(Strings[i].Str.V);
|
||||
s.W(Strings[i].Str.V);
|
||||
s.W((byte)0);
|
||||
if (format < Format.F) s.A(0x8);
|
||||
}
|
||||
}
|
||||
s.A(0x4);
|
||||
s.L = s.P;
|
||||
|
||||
if (_IO.Format > Format.AFT)
|
||||
if (s.Format > Format.AFT)
|
||||
{
|
||||
_IO.A(0x10);
|
||||
offset = _IO.PU32;
|
||||
_IO.P = 0x80;
|
||||
s.A(0x10);
|
||||
offset = s.PU32;
|
||||
s.P = 0x80;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
pof.Offsets.Add(_IO.P);
|
||||
_IO.WE(STRPos[i]);
|
||||
_IO.WE(Strings[i].ID);
|
||||
pof.Offsets.Add(s.P);
|
||||
s.WE(STRPos[i]);
|
||||
s.WE(Strings[i].ID);
|
||||
}
|
||||
|
||||
_IO.PU32 = offset;
|
||||
_IO.W(pof, false, 1);
|
||||
currentOffset = _IO.PU32;
|
||||
_IO.WEOFC();
|
||||
header.DataSize = (int)(currentOffset - 0x40);
|
||||
s.PU32 = offset;
|
||||
s.W(pof, false, 1);
|
||||
s.WEOFC(1);
|
||||
currentOffset = s.PU32;
|
||||
s.WEOFC();
|
||||
header.DataSize = currentOffset - 0x40;
|
||||
header.Signature = 0x41525453;
|
||||
header.SectionSize = (int)(offset - 0x40);
|
||||
_IO.P = 0;
|
||||
_IO.W(header, true);
|
||||
header.SectionSize = offset - 0x40;
|
||||
header.UseSectionSize = true;
|
||||
s.P = 0;
|
||||
s.W(header, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_IO.P = 0;
|
||||
for (int i = 0; i < count; i++) _IO.W(STRPos[i]);
|
||||
s.P = 0;
|
||||
s.IsBE = header.Format < Format.F;
|
||||
for (int i = 0; i < count; i++) s.WE(STRPos[i]);
|
||||
}
|
||||
_IO.C();
|
||||
s.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
header = default;
|
||||
Strings = default;
|
||||
MsgPack temp;
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
if ((temp = msgPack["STR"]).NotNull) return;
|
||||
if ((temp = msgPack["STR"]).IsNull) return;
|
||||
|
||||
header = new Header();
|
||||
System.Enum.TryParse(temp.RS("Format"), out header.Format);
|
||||
if (!System.Enum.TryParse(temp.RS("Format"), out header.Format)) return;
|
||||
bool? isBE = temp.RnB("UseBigEndian");
|
||||
if (isBE.HasValue) header.UseBigEndian = isBE.Value;
|
||||
|
||||
if ((temp = msgPack["Strings", true]).IsNull) return;
|
||||
if ((temp = temp["Strings", true]).IsNull) return;
|
||||
|
||||
Strings = new String[temp.Array.Length];
|
||||
for (int i = 0; i < Strings.Length; i++)
|
||||
@@ -166,6 +174,7 @@ namespace KKdMainLib
|
||||
{
|
||||
if (Strings == null || Strings.Length == 0) return;
|
||||
MsgPack str = new MsgPack("STR").Add("Format", header.Format.ToString());
|
||||
if (header.UseBigEndian) str.Add("UseBigEndian", header.UseBigEndian);
|
||||
MsgPack strings = new MsgPack(Strings.Length, "Strings");
|
||||
for (int i = 0; i < Strings.Length; i++)
|
||||
{
|
||||
@@ -176,12 +185,12 @@ namespace KKdMainLib
|
||||
}
|
||||
str.Add(strings);
|
||||
|
||||
str.WriteAfterAll(true, file, json);
|
||||
str.WriteAfterAll(false, true, file, json);
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); Strings = default;
|
||||
{ if (!disposed) { if (s != null) s.D(); s = null; Strings = default;
|
||||
pof = default; header = default; disposed = true; } }
|
||||
|
||||
public struct String
|
||||
|
||||
+105
-115
@@ -1,5 +1,6 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdBaseLib.Tables;
|
||||
using TableDict = System.Collections.Generic.Dictionary<string, object>;
|
||||
|
||||
namespace KKdMainLib
|
||||
@@ -7,8 +8,8 @@ namespace KKdMainLib
|
||||
public struct Tables : System.IDisposable
|
||||
{
|
||||
private int i0;
|
||||
private Stream _IO;
|
||||
private TableDict dict;
|
||||
private Stream s;
|
||||
|
||||
public ButtonSE[] ButtonSETable;
|
||||
public ChainSlideSE[] ChainSlideSETable;
|
||||
@@ -19,21 +20,10 @@ namespace KKdMainLib
|
||||
public CustomizeItem[] CustomizeItemTable;
|
||||
public Module[] ModuleTable;
|
||||
public Plate[] PlateTable;
|
||||
public PV[] PVList;
|
||||
public PV[] PVListTable;
|
||||
|
||||
private const string c = ".";
|
||||
|
||||
public Tables(bool def = true)
|
||||
{
|
||||
i0 = 0;
|
||||
_IO = null;
|
||||
dict = null;
|
||||
disposed = false;
|
||||
ButtonSETable = null; ChainSlideSETable = null; SlideSETable = null; SliderTouchSETable = null;
|
||||
CollectionCardTable = null; CustomizeItemTable = null;
|
||||
ModuleTable = null; PlateTable = null; PVList = null;
|
||||
}
|
||||
|
||||
public void BINReader(string file) =>
|
||||
BINReader(File.ReadAllBytes(file + ".bin"));
|
||||
|
||||
@@ -41,7 +31,7 @@ namespace KKdMainLib
|
||||
{
|
||||
ButtonSETable = null; ChainSlideSETable = null; SlideSETable = null; SliderTouchSETable = null;
|
||||
CollectionCardTable = null; CustomizeItemTable = null;
|
||||
ModuleTable = null; PlateTable = null; PVList = null;
|
||||
ModuleTable = null; PlateTable = null; PVListTable = null;
|
||||
|
||||
dict = new TableDict();
|
||||
string[] strData = data.ToUTF8().Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
@@ -83,7 +73,7 @@ namespace KKdMainLib
|
||||
dict.FV(out csld. SortIndex, name + "sort_index");
|
||||
dict.FV(out csld. SubSEName , name + "sub_se_name" );
|
||||
dict.FV(out csld.SuccessSEName , name + "success_se_name" );
|
||||
|
||||
|
||||
csld.Start = GetStartTableDate(dict, name);
|
||||
csld.End = GetEndTableDate(dict, name);
|
||||
}
|
||||
@@ -130,7 +120,7 @@ namespace KKdMainLib
|
||||
dict.FV(out czitm.SellType , name + "sell_type" );
|
||||
dict.FV(out czitm.ShopPrice, name + "shop_price");
|
||||
dict.FV(out czitm.SortIndex, name + "sort_index");
|
||||
|
||||
|
||||
czitm.ShopStart = GetStartTableDate(dict, name + "shop_");
|
||||
czitm.ShopEnd = GetEndTableDate(dict, name + "shop_");
|
||||
}
|
||||
@@ -151,7 +141,7 @@ namespace KKdMainLib
|
||||
dict.FV(out mdl.NG , name + "ng" );
|
||||
dict.FV(out mdl.ShopPrice, name + "shop_price");
|
||||
dict.FV(out mdl.SortIndex, name + "sort_index");
|
||||
|
||||
|
||||
mdl.ShopStart = GetStartTableDate(dict, name + "shop_");
|
||||
mdl.ShopEnd = GetEndTableDate(dict, name + "shop_");
|
||||
}
|
||||
@@ -181,19 +171,19 @@ namespace KKdMainLib
|
||||
}
|
||||
else if (dict.FV(out length, "pv_list.data_list.length"))
|
||||
{
|
||||
PVList = new PV[length];
|
||||
PVListTable = new PV[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "pv_list" + c + i0 + c;
|
||||
|
||||
ref PV pv = ref PVList[i0];
|
||||
ref PV pv = ref PVListTable[i0];
|
||||
dict.FV(out pv.ID , name + "id" );
|
||||
dict.FV(out pv.Ignore, name + "ignore");
|
||||
dict.FV(out pv.Name , name + "name" );
|
||||
|
||||
|
||||
pv.AdvStart = GetStartTableDate(dict, name + "adv_demo_");
|
||||
pv.AdvEnd = GetEndTableDate(dict, name + "adv_demo_");
|
||||
|
||||
|
||||
pv.Easy = GetDifficulty(dict, name + "easy" + c);
|
||||
pv.Encore = GetDifficulty(dict, name + "encore" + c);
|
||||
pv.Extreme = GetDifficulty(dict, name + "extreme" + c);
|
||||
@@ -230,7 +220,7 @@ namespace KKdMainLib
|
||||
dict.FV(out sld. Name , name + "name" );
|
||||
dict.FV(out sld. SEName , name + "se_name" );
|
||||
dict.FV(out sld.SortIndex, name + "sort_index");
|
||||
|
||||
|
||||
sld.Start = GetStartTableDate(dict, name);
|
||||
sld.End = GetEndTableDate(dict, name);
|
||||
}
|
||||
@@ -256,18 +246,18 @@ namespace KKdMainLib
|
||||
static TableDate GetStartTableDate(TableDict dict, string name)
|
||||
{
|
||||
TableDate date = default; date.SDL(); int val;
|
||||
if (dict.FV(out val, name + "st_day" )) date.Day = val;
|
||||
if (dict.FV(out val, name + "st_month")) date.Month = val;
|
||||
if (dict.FV(out val, name + "st_year" )) date.Year = val;
|
||||
if (dict.FV(out val, name + "st_month")) date.Month = val;
|
||||
if (dict.FV(out val, name + "st_day" )) date.Day = val;
|
||||
return date;
|
||||
}
|
||||
|
||||
static TableDate GetEndTableDate(TableDict dict, string name)
|
||||
{
|
||||
TableDate date = default; date.SDU(); int val;
|
||||
if (dict.FV(out val, name + "ed_day" )) date.Day = val;
|
||||
if (dict.FV(out val, name + "ed_month")) date.Month = val;
|
||||
if (dict.FV(out val, name + "ed_year" )) date.Year = val;
|
||||
if (dict.FV(out val, name + "ed_month")) date.Month = val;
|
||||
if (dict.FV(out val, name + "ed_day" )) date.Day = val;
|
||||
return date;
|
||||
}
|
||||
}
|
||||
@@ -280,57 +270,57 @@ namespace KKdMainLib
|
||||
|
||||
if (ButtonSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = ButtonSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "btn_se" + c + so[i0] + c;
|
||||
|
||||
ref ButtonSE btn = ref ButtonSETable[so[i0]];
|
||||
WriteEndTableDate(_IO, name, btn.End);
|
||||
WriteEndTableDate(s, name, btn.End);
|
||||
W(name + "id" , btn. ID );
|
||||
W(name + "name" , btn. Name );
|
||||
W(name + "se_name" , btn. SEName );
|
||||
W(name + "sort_index", btn.SortIndex);
|
||||
WriteStartTableDate(_IO, name, btn.Start);
|
||||
WriteStartTableDate(s, name, btn.Start);
|
||||
}
|
||||
W("btn_se.data_list.length", length);
|
||||
_IO.W("kind=0\n");
|
||||
_IO.D();
|
||||
s.W("kind=0\n");
|
||||
s.D();
|
||||
}
|
||||
else if (ChainSlideSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = ChainSlideSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "chainslide_se" + c + so[i0] + c;
|
||||
|
||||
ref ChainSlideSE csld = ref ChainSlideSETable[so[i0]];
|
||||
WriteEndTableDate(_IO, name, csld.End);
|
||||
WriteEndTableDate(s, name, csld.End);
|
||||
W(name + "failure_se_name" , csld.FailureSEName );
|
||||
W(name + "first_se_name" , csld. FirstSEName );
|
||||
W(name + "id" , csld. ID );
|
||||
W(name + "name" , csld. Name );
|
||||
W(name + "sort_index", csld. SortIndex);
|
||||
WriteStartTableDate(_IO, name, csld.Start);
|
||||
WriteStartTableDate(s, name, csld.Start);
|
||||
W(name + "sub_se_name" , csld. SubSEName );
|
||||
W(name + "success_se_name" , csld.SuccessSEName );
|
||||
}
|
||||
W("chainslide_se.data_list.length", length);
|
||||
_IO.W("kind=2\n");
|
||||
_IO.D();
|
||||
s.W("kind=2\n");
|
||||
s.D();
|
||||
}
|
||||
else if (CollectionCardTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = CollectionCardTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "collection_card" + c + so[i0] + c;
|
||||
@@ -339,29 +329,29 @@ namespace KKdMainLib
|
||||
W(name + "chara" , clcrd.Chara );
|
||||
W(name + "disp_num" , clcrd.DispNum );
|
||||
W(name + "divapro_param", clcrd.DivaProParam);
|
||||
WriteEndTableDate(_IO, name, clcrd.End);
|
||||
WriteEndTableDate(s, name, clcrd.End);
|
||||
W(name + "id" , clcrd.ID );
|
||||
W(name + "module_author", clcrd.ModuleAuthor);
|
||||
W(name + "name" , clcrd.Name );
|
||||
W(name + "name_reading" , clcrd.NameReading );
|
||||
W(name + "ng" , clcrd.NG );
|
||||
W(name + "sort_idx" , clcrd.SortIndex );
|
||||
WriteStartTableDate(_IO, name, clcrd.Start);
|
||||
WriteStartTableDate(s, name, clcrd.Start);
|
||||
W(name + "type" , clcrd.Type );
|
||||
W(name + "type_param" , clcrd.TypeParam );
|
||||
W(name + "wall_param" , clcrd.WallParam );
|
||||
}
|
||||
W("collection_card.data_list.length", length);
|
||||
_IO.W("patch=0\n");
|
||||
_IO.W("version=0\n");
|
||||
_IO.D();
|
||||
s.W("patch=0\n");
|
||||
s.W("version=0\n");
|
||||
s.D();
|
||||
}
|
||||
else if (CustomizeItemTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = CustomizeItemTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "cstm_item" + c + so[i0] + c;
|
||||
@@ -374,22 +364,22 @@ namespace KKdMainLib
|
||||
W(name + "obj_id" , czitm.ObjID );
|
||||
W(name + "parts" , czitm.Parts );
|
||||
W(name + "sell_type" , czitm.SellType );
|
||||
WriteEndTableDate(_IO, name + "shop_", czitm.ShopEnd);
|
||||
WriteEndTableDate(s, name + "shop_", czitm.ShopEnd);
|
||||
W(name + "shop_price", czitm.ShopPrice);
|
||||
WriteStartTableDate(_IO, name + "shop_", czitm.ShopStart);
|
||||
WriteStartTableDate(s, name + "shop_", czitm.ShopStart);
|
||||
W(name + "sort_index", czitm.SortIndex);
|
||||
}
|
||||
W("cstm_item.data_list.length", length);
|
||||
_IO.W("patch=0\n");
|
||||
_IO.W("version=0\n");
|
||||
_IO.D();
|
||||
s.W("patch=0\n");
|
||||
s.W("version=0\n");
|
||||
s.D();
|
||||
}
|
||||
else if (ModuleTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = ModuleTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "module" + c + so[i0] + c;
|
||||
@@ -401,20 +391,20 @@ namespace KKdMainLib
|
||||
W(name + "id" , mdl.ID );
|
||||
W(name + "name" , mdl.Name );
|
||||
W(name + "ng" , mdl.NG );
|
||||
WriteEndTableDate(_IO, name + "shop_", mdl.ShopEnd);
|
||||
WriteEndTableDate(s, name + "shop_", mdl.ShopEnd);
|
||||
W(name + "shop_price", mdl.ShopPrice);
|
||||
WriteStartTableDate(_IO, name + "shop_", mdl.ShopStart);
|
||||
WriteStartTableDate(s, name + "shop_", mdl.ShopStart);
|
||||
W(name + "sort_index", mdl.SortIndex);
|
||||
}
|
||||
W("module.data_list.length", length);
|
||||
_IO.D();
|
||||
s.D();
|
||||
}
|
||||
else if (PlateTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = PlateTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "plate" + c + so[i0] + c;
|
||||
@@ -435,107 +425,107 @@ namespace KKdMainLib
|
||||
W(name + "shadow_color_r", plt.ShadowColorR);
|
||||
}
|
||||
W("plate.data_list.length", length);
|
||||
_IO.D();
|
||||
s.D();
|
||||
}
|
||||
else if (PVList != null)
|
||||
else if (PVListTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = PVList.Length;
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = PVListTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
WriteEmptyLines(s, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "pv_list" + c + so[i0] + c;
|
||||
|
||||
ref PV pv = ref PVList[so[i0]];
|
||||
WriteEndTableDate(_IO, name + "adv_demo_", pv.AdvEnd );
|
||||
WriteStartTableDate(_IO, name + "adv_demo_", pv.AdvStart);
|
||||
ref PV pv = ref PVListTable[so[i0]];
|
||||
WriteEndTableDate(s, name + "adv_demo_", pv.AdvEnd );
|
||||
WriteStartTableDate(s, name + "adv_demo_", pv.AdvStart);
|
||||
|
||||
WriteDifficulty(_IO, name + "easy.", pv.Easy );
|
||||
WriteDifficulty(_IO, name + "encore.", pv.Encore );
|
||||
WriteDifficulty(_IO, name + "extreme.", pv.Extreme);
|
||||
WriteDifficulty(_IO, name + "hard.", pv.Hard );
|
||||
WriteDifficulty(s, name + "easy.", pv.Easy );
|
||||
WriteDifficulty(s, name + "encore.", pv.Encore );
|
||||
WriteDifficulty(s, name + "extreme.", pv.Extreme);
|
||||
WriteDifficulty(s, name + "hard.", pv.Hard );
|
||||
W(name + "id" , pv.ID );
|
||||
W(name + "ignore", pv.Ignore);
|
||||
W(name + "name" , pv.Name );
|
||||
WriteDifficulty(_IO, name + "extreme.", pv.Normal );
|
||||
WriteDifficulty(s, name + "normal.", pv.Normal );
|
||||
}
|
||||
W("pv_list.data_list.length", length);
|
||||
_IO.D();
|
||||
s.D();
|
||||
|
||||
static void WriteDifficulty(Stream _IO, string name, PV.Difficulty[] arr)
|
||||
{
|
||||
if (arr == null) { _IO.W($"{name}.length=0\n"); return; }
|
||||
if (arr == null) { _IO.W($"{name}length=0\n"); return; }
|
||||
|
||||
int length = arr.Length;
|
||||
int[] so = length.SW();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
ref PV.Difficulty diff = ref arr[so[i]];
|
||||
|
||||
WriteStartTableDate(_IO, $"{name}{i}.", diff.Start);
|
||||
_IO.W($"{name}{i}.edition" + $"={diff.Edition}\n");
|
||||
|
||||
WriteEndTableDate(_IO, $"{name}{i}.", diff.End );
|
||||
_IO.W($"{name}{i}.edition" + $"={diff.Edition}\n");
|
||||
WriteStartTableDate(_IO, $"{name}{i}.", diff.Start);
|
||||
_IO.W($"{name}{i}.ver" + $"={diff.Version}\n");
|
||||
}
|
||||
_IO.W($"{name}.length={length}\n");
|
||||
_IO.W($"{name}length={length}\n");
|
||||
}
|
||||
}
|
||||
else if (SlideSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = SlideSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
_IO.W("kind=1\n");
|
||||
WriteEmptyLines(s, length);
|
||||
s.W("kind=1\n");
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "slide_se" + c + so[i0] + c;
|
||||
|
||||
ref SlideSE sld = ref SlideSETable[so[i0]];
|
||||
WriteEndTableDate(_IO, name, sld.End);
|
||||
WriteEndTableDate(s, name, sld.End);
|
||||
W(name + "id" , sld. ID );
|
||||
W(name + "name" , sld. Name );
|
||||
W(name + "se_name" , sld. SEName );
|
||||
W(name + "sort_index", sld.SortIndex);
|
||||
WriteStartTableDate(_IO, name, sld.Start);
|
||||
WriteStartTableDate(s, name, sld.Start);
|
||||
}
|
||||
W("slide_se.data_list.length", length);
|
||||
_IO.D();
|
||||
s.D();
|
||||
}
|
||||
else if (SliderTouchSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
s = File.OpenWriter(file + ".bin", true);
|
||||
length = SliderTouchSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
_IO.W("kind=3\n");
|
||||
WriteEmptyLines(s, length);
|
||||
s.W("kind=3\n");
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "slidertouch_se" + c + so[i0] + c;
|
||||
|
||||
ref SliderTouchSE sldt = ref SliderTouchSETable[so[i0]];
|
||||
WriteEndTableDate(_IO, name, sldt.End);
|
||||
WriteEndTableDate(s, name, sldt.End);
|
||||
W(name + "id" , sldt. ID );
|
||||
W(name + "name" , sldt. Name );
|
||||
W(name + "se_name" , sldt. SEName );
|
||||
W(name + "sort_index", sldt.SortIndex);
|
||||
WriteStartTableDate(_IO, name, sldt.Start);
|
||||
WriteStartTableDate(s, name, sldt.Start);
|
||||
}
|
||||
W("slidertouch_se.data_list.length", length);
|
||||
_IO.D();
|
||||
s.D();
|
||||
}
|
||||
|
||||
static void WriteEmptyLines(Stream _IO, int count)
|
||||
{ for (int i = 0; i < count; i++) _IO.W("#---------------------------------------------\n"); }
|
||||
|
||||
|
||||
static void WriteStartTableDate(Stream _IO, string name, TableDate date)
|
||||
{
|
||||
_IO.W(name + "st_day" + "=" + date.Day + "\n");
|
||||
_IO.W(name + "st_month" + "=" + date.Month + "\n");
|
||||
_IO.W(name + "st_year" + "=" + date.Year + "\n");
|
||||
}
|
||||
|
||||
|
||||
static void WriteEndTableDate(Stream _IO, string name, TableDate date)
|
||||
{
|
||||
_IO.W(name + "ed_day" + "=" + date.Day + "\n");
|
||||
@@ -545,15 +535,15 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
private void W(string Data, long val) =>
|
||||
_IO.W(Data + "=" + val + "\n");
|
||||
s.W(Data + "=" + val + "\n");
|
||||
private void W(string Data, string val)
|
||||
{ if (val != null) _IO.W(Data + "=" + val + "\n"); }
|
||||
{ if (val != null) s.W(Data + "=" + val + "\n"); }
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
ButtonSETable = null; ChainSlideSETable = null; SlideSETable = null; SliderTouchSETable = null;
|
||||
CollectionCardTable = null; CustomizeItemTable = null;
|
||||
ModuleTable = null; PlateTable = null; PVList = null;
|
||||
ModuleTable = null; PlateTable = null; PVListTable = null;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack temp;
|
||||
@@ -582,7 +572,7 @@ namespace KKdMainLib
|
||||
ref ChainSlideSE csld = ref ChainSlideSETable[i0];
|
||||
csld.End .SV(csldMP.RnI32("End" ), true);
|
||||
csld.Start.SV(csldMP.RnI32("Start"), false);
|
||||
|
||||
|
||||
csldMP.R("FailureSEName" , out csld.FailureSEName );
|
||||
csldMP.R( "FirstSEName" , out csld. FirstSEName );
|
||||
csldMP.R( "ID" , out csld. ID );
|
||||
@@ -601,7 +591,7 @@ namespace KKdMainLib
|
||||
ref CollectionCard clcrd = ref CollectionCardTable[i0];
|
||||
clcrd.End .SV(clcrdMP.RnI32("End" ), true);
|
||||
clcrd.Start.SV(clcrdMP.RnI32("Start"), false);
|
||||
|
||||
|
||||
clcrdMP.R("Chara" , out clcrd.Chara );
|
||||
clcrdMP.R("DispNum" , out clcrd.DispNum );
|
||||
clcrdMP.R("DivaProParam", out clcrd.DivaProParam);
|
||||
@@ -646,7 +636,7 @@ namespace KKdMainLib
|
||||
ref Module mdl = ref ModuleTable[i0];
|
||||
mdl.ShopEnd .SV(mdlMP.RnI32("ShopEnd" ), true);
|
||||
mdl.ShopStart.SV(mdlMP.RnI32("ShopStart"), false);
|
||||
|
||||
|
||||
mdlMP.R("Attribute", out mdl.Attribute);
|
||||
mdlMP.R("Costume" , out mdl.Costume );
|
||||
mdlMP.R("Chara" , out mdl.Chara );
|
||||
@@ -679,16 +669,16 @@ namespace KKdMainLib
|
||||
pltMP.R("ShadowColorR", out plt.ShadowColorR);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["PV", true]).NotNull)
|
||||
else if ((temp = msgPack["PVList", true]).NotNull)
|
||||
{
|
||||
PVList = new PV[temp.Array.Length];
|
||||
for (i0 = 0; i0 < PVList.Length; i0++)
|
||||
PVListTable = new PV[temp.Array.Length];
|
||||
for (i0 = 0; i0 < PVListTable.Length; i0++)
|
||||
{
|
||||
MsgPack pvMP = temp[i0];
|
||||
ref PV pv = ref PVList[i0];
|
||||
ref PV pv = ref PVListTable[i0];
|
||||
pv.AdvEnd .SV(pvMP.RnI32("AdvEnd" ), true);
|
||||
pv.AdvStart.SV(pvMP.RnI32("AdvStart"), false);
|
||||
|
||||
|
||||
pvMP.R("ID" , out pv.ID );
|
||||
pvMP.R("Ignore", out pv.Ignore);
|
||||
pvMP.R("Name" , out pv.Name );
|
||||
@@ -704,7 +694,7 @@ namespace KKdMainLib
|
||||
{
|
||||
MsgPack t;
|
||||
if ((t = mp[name, true]).IsNull) return null;
|
||||
|
||||
|
||||
PV.Difficulty[] arr = new PV.Difficulty[t.Array.Length];
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
@@ -712,7 +702,7 @@ namespace KKdMainLib
|
||||
ref PV.Difficulty diff = ref arr[i];
|
||||
diff.End .SV(pvMP.RnI32("End" ), true);
|
||||
diff.Start.SV(pvMP.RnI32("Start"), false);
|
||||
|
||||
|
||||
pvMP.R("Edition", out diff.Edition);
|
||||
pvMP.R("Version", out diff.Version);
|
||||
}
|
||||
@@ -728,7 +718,7 @@ namespace KKdMainLib
|
||||
ref SlideSE sld = ref SlideSETable[i0];
|
||||
sld.End .SV(sldMP.RnI32("End" ), true);
|
||||
sld.Start.SV(sldMP.RnI32("Start"), false);
|
||||
|
||||
|
||||
sldMP.R( "ID" , out sld. ID );
|
||||
sldMP.R( "Name" , out sld. Name );
|
||||
sldMP.R( "SEName" , out sld. SEName );
|
||||
@@ -744,7 +734,7 @@ namespace KKdMainLib
|
||||
ref SliderTouchSE sldt = ref SliderTouchSETable[i0];
|
||||
sldt.End .SV(TEMP.RnI32("End" ), true);
|
||||
sldt.Start.SV(TEMP.RnI32("Start"), false);
|
||||
|
||||
|
||||
TEMP.R( "ID" , out sldt. ID );
|
||||
TEMP.R( "Name" , out sldt. Name );
|
||||
TEMP.R( "SEName" , out sldt. SEName );
|
||||
@@ -875,12 +865,12 @@ namespace KKdMainLib
|
||||
}
|
||||
msgPack.Add(plateTable);
|
||||
}
|
||||
else if (PVList != null)
|
||||
else if (PVListTable != null)
|
||||
{
|
||||
MsgPack pvList = new MsgPack(PVList.Length, "PVList");
|
||||
for (i0 = 0; i0 < PVList.Length; i0++)
|
||||
MsgPack pvList = new MsgPack(PVListTable.Length, "PVList");
|
||||
for (i0 = 0; i0 < PVListTable.Length; i0++)
|
||||
{
|
||||
ref PV pv = ref PVList[i0];
|
||||
ref PV pv = ref PVListTable[i0];
|
||||
MsgPack mp = MsgPack.New.Add("AdvEnd" , pv.AdvEnd .Int)
|
||||
.Add("AdvStart", pv.AdvStart.Int);
|
||||
|
||||
@@ -942,18 +932,18 @@ namespace KKdMainLib
|
||||
}
|
||||
msgPack.Add(sliderTouchSETable);
|
||||
}
|
||||
if (msgPack.List.Count == 1) msgPack.Write(file, json);
|
||||
if (msgPack.List.Count == 1) msgPack.Write(file, false, json);
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
if (_IO != null) { _IO.D(); _IO = null; }
|
||||
if (s != null) s.D(); s = null;
|
||||
if (dict != null) { dict.Clear(); dict = null; }
|
||||
ButtonSETable = null; ChainSlideSETable = null; SlideSETable = null; SliderTouchSETable = null;
|
||||
CollectionCardTable = null; CustomizeItemTable = null;
|
||||
ModuleTable = null; PlateTable = null; PVList = null;
|
||||
ModuleTable = null; PlateTable = null; PVListTable = null; disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019-2020</Copyright>
|
||||
<Copyright>korenkonder (C) 2019-2020</Copyright>
|
||||
<Description>A simple library for working with Project Diva F/AFT/F2/X/FT audio files</Description>
|
||||
<FileVersion>0.1.2.0</FileVersion>
|
||||
<PackageId>KKdSoundLib</PackageId>
|
||||
<Product>KKdSoundLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<Title>KKdSoundLib</Title>
|
||||
<Version>0.1.2.0</Version>
|
||||
</PropertyGroup>
|
||||
@@ -24,7 +24,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -37,7 +37,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTrademark("")]
|
||||
|
||||
+15
-15
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
@@ -122,7 +122,7 @@ namespace KKdSoundLib
|
||||
writer.W((ushort)(HEVAG ? VAGData.Channels : 0x1));
|
||||
writer.W(name, 0x10);
|
||||
writer.P = 0x30;
|
||||
|
||||
|
||||
int[] samp = new int[HEVAG ? ch * (PrNRCount > 29 ? 8 : 4) : 4];
|
||||
fixed (int* sampPtr = samp)
|
||||
fixed (int* HEVAG1 = VAG.HEVAG1)
|
||||
@@ -170,7 +170,7 @@ namespace KKdSoundLib
|
||||
}
|
||||
|
||||
if (h)
|
||||
{
|
||||
{
|
||||
Calc4BitsHEVAG(HEVAG1, HEVAG2, HEVAG3, HEVAG4, v1 + c, v2 + c,
|
||||
v3 + c, v4 + c, tV1 + c, tV2 + c, tV3 + c, tV4 + c);
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace KKdSoundLib
|
||||
}
|
||||
|
||||
if (h)
|
||||
{
|
||||
{
|
||||
Calc4BitsVAG(HEVAG1, HEVAG2, v1 + c, v2 + c, tV1 + c, tV2 + c);
|
||||
|
||||
s = ((PrNR & 0xF) << 4) | (ShF & 0xF);
|
||||
@@ -241,9 +241,9 @@ namespace KKdSoundLib
|
||||
dataBuf[i] /= ch;
|
||||
if (dataBuf[i] != 0) h = true;
|
||||
}
|
||||
|
||||
|
||||
if (h)
|
||||
{
|
||||
{
|
||||
Calc4BitsVAG(HEVAG1, HEVAG2, v1, v2, tV1, tV2);
|
||||
|
||||
s = ((PrNR & 0xF) << 4) | (ShF & 0xF);
|
||||
@@ -287,7 +287,7 @@ namespace KKdSoundLib
|
||||
}
|
||||
writer.C();
|
||||
}
|
||||
|
||||
|
||||
private fixed int dataBuf[(int)BS];
|
||||
private fixed int fourBit[(int)BS];
|
||||
private fixed int tempBuf[(int)BS];
|
||||
@@ -301,7 +301,7 @@ namespace KKdSoundLib
|
||||
for (j = 0; j < PrNRCount; j++)
|
||||
{
|
||||
PrNR = j;
|
||||
|
||||
|
||||
Calc4Bits_VAG(HEVAG1, HEVAG2, v1, v2, tV1, tV2);
|
||||
|
||||
s1 = *v1; s2 = *v2;
|
||||
@@ -320,7 +320,7 @@ namespace KKdSoundLib
|
||||
if (err < min) { PrNRf = j; min = err; }
|
||||
}
|
||||
PrNR = PrNRf;
|
||||
|
||||
|
||||
Calc4Bits_VAG(HEVAG1, HEVAG2, v1, v2, tV1, tV2);
|
||||
* v1 = s1; * v2 = s2;
|
||||
*tV1 = tS1; *tV2 = tS2;
|
||||
@@ -344,12 +344,12 @@ namespace KKdSoundLib
|
||||
e = (e + g) ^ g;
|
||||
if (e > max) max = e;
|
||||
}
|
||||
|
||||
|
||||
for (ShF = 12, ShM = 0x400000; ShF > 0; ShF--, ShM >>= 1)
|
||||
if ((ShM & (max + (ShM >> 4))) == ShM) break;
|
||||
ShFf = 8 + ShF;
|
||||
ShF = 12 - ShF;
|
||||
|
||||
|
||||
tS1 = *tV1; tS2 = *tV2;
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
@@ -376,7 +376,7 @@ namespace KKdSoundLib
|
||||
for (j = 0; j < PrNRCount; j++)
|
||||
{
|
||||
PrNR = j;
|
||||
|
||||
|
||||
Calc4Bits_HEVAG(HEVAG1, HEVAG2, HEVAG3, HEVAG4, v1, v2, v3, v4, tV1, tV2, tV3, tV4);
|
||||
|
||||
s1 = *v1; s2 = *v2; s3 = *v3; s4 = *v4;
|
||||
@@ -395,7 +395,7 @@ namespace KKdSoundLib
|
||||
if (err < min) { PrNRf = j; min = err; }
|
||||
}
|
||||
PrNR = PrNRf;
|
||||
|
||||
|
||||
Calc4Bits_HEVAG(HEVAG1, HEVAG2, HEVAG3, HEVAG4, v1, v2, v3, v4, tV1, tV2, tV3, tV4);
|
||||
* v1 = s1; * v2 = s2; * v3 = s3; * v4 = s4;
|
||||
*tV1 = tS1; *tV2 = tS2; *tV3 = tS3; *tV4 = tS4;
|
||||
@@ -427,7 +427,7 @@ namespace KKdSoundLib
|
||||
if ((ShM & (max + (ShM >> 4))) == ShM) break;
|
||||
ShFf = 8 + ShF;
|
||||
ShF = 12 - ShF;
|
||||
|
||||
|
||||
tS1 = *tV1; tS2 = *tV2; tS3 = *tV3; tS4 = *tV4;
|
||||
for (i = 0; i < BS; i++)
|
||||
{
|
||||
@@ -741,7 +741,7 @@ namespace KKdSoundLib
|
||||
public byte[] Flags;
|
||||
public int[] Data;
|
||||
}
|
||||
|
||||
|
||||
private static readonly int[] ShiftFactor =
|
||||
{ 0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1 };
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace KKdSoundLib
|
||||
namespace KKdSoundLib
|
||||
{
|
||||
public static class WAV
|
||||
{
|
||||
|
||||
+83
-182
@@ -1,183 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PD_Tool</RootNamespace>
|
||||
<AssemblyName>PD_Tool</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\build\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>embedded</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\build\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\A3D.cs" />
|
||||
<Compile Include="classes\AET.cs" />
|
||||
<Compile Include="classes\BLT.cs" />
|
||||
<Compile Include="classes\CCT.cs" />
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\DB.cs" />
|
||||
<Compile Include="classes\DEX.cs" />
|
||||
<Compile Include="classes\DFT.cs" />
|
||||
<Compile Include="classes\DIV.cs" />
|
||||
<Compile Include="classes\DIVAFILE.cs" />
|
||||
<Compile Include="classes\FARC.cs" />
|
||||
<Compile Include="classes\LIT.cs" />
|
||||
<Compile Include="classes\MHD.cs" />
|
||||
<Compile Include="classes\MOT.cs" />
|
||||
<Compile Include="classes\STR.cs" />
|
||||
<Compile Include="classes\TBL.cs" />
|
||||
<Compile Include="classes\VAG.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{437f63f1-8c23-429e-ab14-38b85c9edb16}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2ba7efc6-91d1-8bbc-c487-06c7f36cc789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdSoundLib\KKdSoundLib.csproj">
|
||||
<Project>{d8a3f2d7-10cc-5723-ec9a-45d3b9c2df77}</Project>
|
||||
<Name>KKdSoundLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del Microsoft.Win32.Primitives.dll
|
||||
del netstandard.dll
|
||||
del PD_Tool.exe.config
|
||||
del System.AppContext.dll
|
||||
del System.Collections.Concurrent.dll
|
||||
del System.Collections.dll
|
||||
del System.Collections.NonGeneric.dll
|
||||
del System.Collections.Specialized.dll
|
||||
del System.ComponentModel.dll
|
||||
del System.ComponentModel.EventBasedAsync.dll
|
||||
del System.ComponentModel.Primitives.dll
|
||||
del System.ComponentModel.TypeConverter.dll
|
||||
del System.Console.dll
|
||||
del System.Data.Common.dll
|
||||
del System.Diagnostics.Contracts.dll
|
||||
del System.Diagnostics.Debug.dll
|
||||
del System.Diagnostics.FileVersionInfo.dll
|
||||
del System.Diagnostics.Process.dll
|
||||
del System.Diagnostics.StackTrace.dll
|
||||
del System.Diagnostics.TextWriterTraceListener.dll
|
||||
del System.Diagnostics.Tools.dll
|
||||
del System.Diagnostics.TraceSource.dll
|
||||
del System.Diagnostics.Tracing.dll
|
||||
del System.Drawing.Primitives.dll
|
||||
del System.Dynamic.Runtime.dll
|
||||
del System.Globalization.Calendars.dll
|
||||
del System.Globalization.dll
|
||||
del System.Globalization.Extensions.dll
|
||||
del System.IO.Compression.dll
|
||||
del System.IO.Compression.ZipFile.dll
|
||||
del System.IO.dll
|
||||
del System.IO.FileSystem.dll
|
||||
del System.IO.FileSystem.DriveInfo.dll
|
||||
del System.IO.FileSystem.Primitives.dll
|
||||
del System.IO.FileSystem.Watcher.dll
|
||||
del System.IO.IsolatedStorage.dll
|
||||
del System.IO.MemoryMappedFiles.dll
|
||||
del System.IO.Pipes.dll
|
||||
del System.IO.UnmanagedMemoryStream.dll
|
||||
del System.Linq.dll
|
||||
del System.Linq.Expressions.dll
|
||||
del System.Linq.Parallel.dll
|
||||
del System.Linq.Queryable.dll
|
||||
del System.Net.Http.dll
|
||||
del System.Net.NameResolution.dll
|
||||
del System.Net.NetworkInformation.dll
|
||||
del System.Net.Ping.dll
|
||||
del System.Net.Primitives.dll
|
||||
del System.Net.Requests.dll
|
||||
del System.Net.Security.dll
|
||||
del System.Net.Sockets.dll
|
||||
del System.Net.WebHeaderCollection.dll
|
||||
del System.Net.WebSockets.Client.dll
|
||||
del System.Net.WebSockets.dll
|
||||
del System.ObjectModel.dll
|
||||
del System.Reflection.dll
|
||||
del System.Reflection.Extensions.dll
|
||||
del System.Reflection.Primitives.dll
|
||||
del System.Resources.Reader.dll
|
||||
del System.Resources.ResourceManager.dll
|
||||
del System.Resources.Writer.dll
|
||||
del System.Runtime.CompilerServices.VisualC.dll
|
||||
del System.Runtime.dll
|
||||
del System.Runtime.Extensions.dll
|
||||
del System.Runtime.Handles.dll
|
||||
del System.Runtime.InteropServices.dll
|
||||
del System.Runtime.InteropServices.RuntimeInformation.dll
|
||||
del System.Runtime.Numerics.dll
|
||||
del System.Runtime.Serialization.Formatters.dll
|
||||
del System.Runtime.Serialization.Json.dll
|
||||
del System.Runtime.Serialization.Primitives.dll
|
||||
del System.Runtime.Serialization.Xml.dll
|
||||
del System.Security.Claims.dll
|
||||
del System.Security.Cryptography.Algorithms.dll
|
||||
del System.Security.Cryptography.Csp.dll
|
||||
del System.Security.Cryptography.Encoding.dll
|
||||
del System.Security.Cryptography.Primitives.dll
|
||||
del System.Security.Cryptography.X509Certificates.dll
|
||||
del System.Security.Principal.dll
|
||||
del System.Security.SecureString.dll
|
||||
del System.Text.Encoding.dll
|
||||
del System.Text.Encoding.Extensions.dll
|
||||
del System.Text.RegularExpressions.dll
|
||||
del System.Threading.dll
|
||||
del System.Threading.Overlapped.dll
|
||||
del System.Threading.Tasks.dll
|
||||
del System.Threading.Tasks.Parallel.dll
|
||||
del System.Threading.Thread.dll
|
||||
del System.Threading.ThreadPool.dll
|
||||
del System.Threading.Timer.dll
|
||||
del System.ValueTuple.dll
|
||||
del System.Xml.ReaderWriter.dll
|
||||
del System.Xml.XDocument.dll
|
||||
del System.Xml.XmlDocument.dll
|
||||
del System.Xml.XmlSerializer.dll
|
||||
del System.Xml.XPath.dll
|
||||
del System.Xml.XPath.XDocument.dll</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PD_Tool</RootNamespace>
|
||||
<AssemblyName>PD_Tool</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\build\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>embedded</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\build\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<NoWarn>IDE0004, IDE0032, IDE0044, IDE0045, IDE0046, IDE0055, IDE0059, IDE0066, IDE0069, IDE1006</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="classes\A3D.cs" />
|
||||
<Compile Include="classes\ADP.cs" />
|
||||
<Compile Include="classes\AET.cs" />
|
||||
<Compile Include="classes\BLT.cs" />
|
||||
<Compile Include="classes\CCT.cs" />
|
||||
<Compile Include="classes\DataBase.cs" />
|
||||
<Compile Include="classes\DB.cs" />
|
||||
<Compile Include="classes\DEX.cs" />
|
||||
<Compile Include="classes\DFT.cs" />
|
||||
<Compile Include="classes\DIV.cs" />
|
||||
<Compile Include="classes\DIVAFILE.cs" />
|
||||
<Compile Include="classes\FARC.cs" />
|
||||
<Compile Include="classes\LIT.cs" />
|
||||
<Compile Include="classes\MHD.cs" />
|
||||
<Compile Include="classes\MOT.cs" />
|
||||
<Compile Include="classes\STR.cs" />
|
||||
<Compile Include="classes\TBL.cs" />
|
||||
<Compile Include="classes\VAG.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KKdBaseLib\KKdBaseLib.csproj">
|
||||
<Project>{437f63f1-8c23-429e-ab14-38b85c9edb16}</Project>
|
||||
<Name>KKdBaseLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdMainLib\KKdMainLib.csproj">
|
||||
<Project>{2ba7efc6-91d1-8bbc-c487-06c7f36cc789}</Project>
|
||||
<Name>KKdMainLib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\KKdSoundLib\KKdSoundLib.csproj">
|
||||
<Project>{d8a3f2d7-10cc-5723-ec9a-45d3b9c2df77}</Project>
|
||||
<Name>KKdSoundLib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
+144
-77
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
@@ -18,6 +18,9 @@ namespace PD_Tool
|
||||
{
|
||||
SetProcessDPIAware();
|
||||
|
||||
Console. InputEncoding = System.Text.Encoding.Unicode;
|
||||
Console.OutputEncoding = System.Text.Encoding.Unicode;
|
||||
|
||||
Console.Title = "PD_Tool";
|
||||
if (args.Length == 0) { while (choose != "Q") MainMenu(); Exit(); }
|
||||
|
||||
@@ -26,7 +29,8 @@ namespace PD_Tool
|
||||
foreach (string arg in args)
|
||||
{
|
||||
GC.Collect();
|
||||
if (Directory.Exists(arg)) using (KKdFARC FARC = new KKdFARC(arg, true)) FARC.Pack();
|
||||
if (Directory.Exists(arg))
|
||||
using (KKdFARC FARC = new KKdFARC(arg, true) { CompressionLevel = 9 }) FARC.Pack();
|
||||
else if (File.Exists(arg) && Path.GetExtension(arg) == ".farc")
|
||||
using (KKdFARC farc = new KKdFARC(arg)) farc.Unpack(true);
|
||||
else if (File.Exists(arg))
|
||||
@@ -43,23 +47,22 @@ namespace PD_Tool
|
||||
|
||||
private static void MainMenu()
|
||||
{
|
||||
Console. InputEncoding = System.Text.Encoding.Unicode;
|
||||
Console.OutputEncoding = System.Text.Encoding.Unicode;
|
||||
Console.Title = "PD_Tool";
|
||||
Console.Title = "PD_Tool v0.4.9.6";
|
||||
Console.Clear();
|
||||
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose action:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. Extract FARC Archive");
|
||||
ConsoleDesign("2. Create FARC Archive");
|
||||
ConsoleDesign("2. Create FARC Archive");
|
||||
ConsoleDesign("3. Decrypt from DIVAFILE");
|
||||
ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
ConsoleDesign("5. DB_Tools");
|
||||
ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools");
|
||||
ConsoleDesign("7. F/F2/FT Converting Tools");
|
||||
ConsoleDesign("8. X/XHD Converting Tools");
|
||||
ConsoleDesign(json ? "9. MsgPack to JSON" : "9. JSON to MsgPack");
|
||||
ConsoleDesign("6. AC/DT/F/AFT Converting Tools");
|
||||
ConsoleDesign("7. F/F2/FT Converting Tools");
|
||||
ConsoleDesign("8. X/XHD Converting Tools");
|
||||
ConsoleDesign("9. FT/M39 Converting Tools");
|
||||
ConsoleDesign(json ? "A. MsgPack to JSON" : "A. JSON to MsgPack");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(json ? "M. MessagePack" : "J. JSON");
|
||||
ConsoleDesign("Q. Quit");
|
||||
@@ -70,42 +73,56 @@ namespace PD_Tool
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
bool isNumber = int.TryParse(choose, out int result);
|
||||
if (isNumber) Functions();
|
||||
if (choose == "M") json = false;
|
||||
else if (choose == "J") json = true ;
|
||||
|
||||
if (choose == null || choose == "") return;
|
||||
if (choose[0] == 'M') json = false;
|
||||
else if (choose[0] == 'J') json = true ;
|
||||
}
|
||||
|
||||
private static void Functions()
|
||||
{
|
||||
Console.Clear();
|
||||
if (choose == "1" || choose == "2") FARC.Processor(choose == "1");
|
||||
else if (choose == "3" || choose == "4")
|
||||
if (choose == null || choose == "") return;
|
||||
|
||||
if (choose[0] == '1' || choose[0] == '2') FARC.Processor(choose == "1");
|
||||
else if (choose[0] == '3')
|
||||
{
|
||||
Choose(1, "", out string[] FileNames);
|
||||
foreach (string FileName in FileNames) DIVAFILE.Decrypt(FileName);
|
||||
}
|
||||
else if (choose == "5") DataBase.Processor(json);
|
||||
else if (choose == "6")
|
||||
else if (choose[0] == '4')
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "AC/DT/F/AFT/FT Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. AET" );
|
||||
ConsoleDesign("3. DataBank");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DIVA" );
|
||||
ConsoleDesign("6. MotHead" );
|
||||
ConsoleDesign("7. MOT" );
|
||||
ConsoleDesign("8. Table" );
|
||||
ConsoleDesign("9. STR" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine().ToUpper();
|
||||
Choose(1, "", out string[] FileNames);
|
||||
foreach (string FileName in FileNames) DIVAFILE.Encrypt(FileName);
|
||||
}
|
||||
else if (choose[0] == '5') DataBase.Processor(json);
|
||||
else if (choose[0] == '6')
|
||||
{
|
||||
string localChoose = "";
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "AC/DT/F/AFT Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. AET" );
|
||||
ConsoleDesign("3. DataBank");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DIVA" );
|
||||
ConsoleDesign("6. MotHead" );
|
||||
ConsoleDesign("7. MOT" );
|
||||
ConsoleDesign("8. STR" );
|
||||
ConsoleDesign("9. Table" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
localChoose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") AET.Processor(json);
|
||||
else if (localChoose == "3") DB .Processor(json);
|
||||
@@ -113,31 +130,36 @@ namespace PD_Tool
|
||||
else if (localChoose == "5") DIV.Processor();
|
||||
else if (localChoose == "6") MHD.Processor(json);
|
||||
else if (localChoose == "7") MOT.Processor(json);
|
||||
else if (localChoose == "8") TBL.Processor(json);
|
||||
else if (localChoose == "9") STR.Processor(json);
|
||||
else if (localChoose == "8") STR.Processor(json);
|
||||
else if (localChoose == "9") TBL.Processor(json);
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose == "7")
|
||||
else if (choose[0] == '7')
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "F/F2/FT Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. Bloom" );
|
||||
ConsoleDesign("3. Color Correction");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DOF" );
|
||||
ConsoleDesign("6. Light" );
|
||||
ConsoleDesign("7. STR" );
|
||||
ConsoleDesign("8. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine().ToUpper();
|
||||
string localChoose = "";
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "F/F2/FT Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. Bloom" );
|
||||
ConsoleDesign("3. Color Correction");
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DOF" );
|
||||
ConsoleDesign("6. Light" );
|
||||
ConsoleDesign("7. STR" );
|
||||
ConsoleDesign("8. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
localChoose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") BLT.Processor();
|
||||
else if (localChoose == "3") CCT.Processor();
|
||||
@@ -148,28 +170,71 @@ namespace PD_Tool
|
||||
else if (localChoose == "8") VAG.Processor();
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose == "8")
|
||||
else if (choose[0] == '8')
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "X Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. DEX" );
|
||||
ConsoleDesign("3. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine().ToUpper();
|
||||
string localChoose = "";
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "X/XHD Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. DEX" );
|
||||
ConsoleDesign("3. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
localChoose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") DEX.Processor(json);
|
||||
else if (localChoose == "3") VAG.Processor();
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose == "9")
|
||||
else if (choose[0] == '9')
|
||||
{
|
||||
string localChoose = "";
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "FT/M39 Converting Tools";
|
||||
ConsoleDesign(true);
|
||||
ConsoleDesign(" Choose converter:");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. A3DA" );
|
||||
ConsoleDesign("2. AddParam");
|
||||
ConsoleDesign("3. AET" );
|
||||
ConsoleDesign("4. DEX" );
|
||||
ConsoleDesign("5. DIVA" );
|
||||
ConsoleDesign("6. MotHead" );
|
||||
ConsoleDesign("7. MOT" );
|
||||
ConsoleDesign("8. STR" );
|
||||
ConsoleDesign("9. Table" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
localChoose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
else localChoose = choose[1].ToString();
|
||||
if (localChoose == "1") A3D.Processor(json);
|
||||
else if (localChoose == "2") ADP.Processor(json);
|
||||
else if (localChoose == "3") AET.Processor(json);
|
||||
else if (localChoose == "4") DEX.Processor(json);
|
||||
else if (localChoose == "5") DIV.Processor();
|
||||
else if (localChoose == "6") MHD.Processor(json);
|
||||
else if (localChoose == "7") MOT.Processor(json);
|
||||
else if (localChoose == "8") STR.Processor(json);
|
||||
else if (localChoose == "9") TBL.Processor(json);
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose[0] == 'A')
|
||||
{
|
||||
Console.Title = json ? "MsgPack to JSON" : "JSON to MsgPack";
|
||||
Choose(1, json ? "mp" : "json", out string[] fileNames);
|
||||
@@ -188,7 +253,7 @@ namespace PD_Tool
|
||||
}
|
||||
|
||||
public static void Exit() => Environment.Exit(0);
|
||||
|
||||
|
||||
public static void ConsoleDesign(string text, params string[] args)
|
||||
{
|
||||
text = string.Format(text, args);
|
||||
@@ -236,6 +301,8 @@ namespace PD_Tool
|
||||
string Filter = GetArgs("All;", false, "*");
|
||||
if (filetype == "a3da") Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
|
||||
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + json + mp;
|
||||
else if (filetype == "adp" ) Filter = GetArgs("ADP" , "adp", "json", "mp") +
|
||||
GetArgs("ADP", true, "adp" ) + json + mp;
|
||||
else if (filetype == "bin" ) Filter = GetArgs("BIN" , "bin", "json", "mp") +
|
||||
bin + json + mp;
|
||||
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt");
|
||||
@@ -259,7 +326,7 @@ namespace PD_Tool
|
||||
bin + GetArgs("FARC Archives", true, "farc") + json + mp;
|
||||
else if (filetype == "vag" ) Filter = GetArgs("VAG" , "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + wav;
|
||||
|
||||
|
||||
using OpenFileDialog ofd = new OpenFileDialog { //InitialDirectory = Application.StartupPath,
|
||||
Filter = Filter, Multiselect = true, Title = "Choose file(s) to open:" };
|
||||
if (ofd.ShowDialog() == DialogResult.OK) FileNames = ofd.FileNames;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("PD_Tool")]
|
||||
@@ -6,10 +6,10 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PD_Tool")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2017-2020")]
|
||||
[assembly: AssemblyCopyright("korenkonder (C) 2017-2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.9.0")]
|
||||
[assembly: AssemblyFileVersion("0.4.9.0")]
|
||||
[assembly: AssemblyVersion("0.4.9.6")]
|
||||
[assembly: AssemblyFileVersion("0.4.9.6")]
|
||||
|
||||
+52
-47
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdA3DA = KKdMainLib.A3DA;
|
||||
@@ -20,36 +20,36 @@ namespace PD_Tool
|
||||
|
||||
Format format = Format.NULL;
|
||||
string choose = "";
|
||||
if (mp)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. A3DA [DT/AC/F]");
|
||||
Program.ConsoleDesign("2. A3DC [DT/AC/F]");
|
||||
Program.ConsoleDesign("3. A3DA [AFT/FT] ");
|
||||
Program.ConsoleDesign("4. A3DC [AFT/FT] ");
|
||||
Program.ConsoleDesign("5. A3DC [F2] ");
|
||||
Program.ConsoleDesign("6. A3DC [MGF] ");
|
||||
Program.ConsoleDesign("7. A3DC [X] ");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "1") format = Format.DT ;
|
||||
else if (choose == "2") format = Format.F ;
|
||||
else if (choose == "3") format = Format.AFT ;
|
||||
else if (choose == "4") format = Format.AFT ;
|
||||
else if (choose == "5") format = Format.F2LE;
|
||||
else if (choose == "6") format = Format.MGF ;
|
||||
else if (choose == "7") format = Format.X ;
|
||||
else return;
|
||||
}
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. A3DA [DT/AC/F]");
|
||||
Program.ConsoleDesign("2. A3DC [DT/AC/F]");
|
||||
Program.ConsoleDesign("3. A3DA [AFT/FT/M39]");
|
||||
Program.ConsoleDesign("4. A3DC [AFT/FT/M39]");
|
||||
Program.ConsoleDesign("5. A3DC [F2]");
|
||||
Program.ConsoleDesign("6. A3DC [MGF]");
|
||||
Program.ConsoleDesign("7. A3DC [X]");
|
||||
if (!mp) Program.ConsoleDesign($"8. {(json ? "JSON" : "MsgPack")}");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "1") format = Format.DT ;
|
||||
else if (choose == "2") format = Format.F ;
|
||||
else if (choose == "3") format = Format.AFT;
|
||||
else if (choose == "4") format = Format.AFT;
|
||||
else if (choose == "5") format = Format.F2;
|
||||
else if (choose == "6") format = Format.MGF;
|
||||
else if (choose == "7") format = Format.X ;
|
||||
else if (choose == "8") format = Format.NULL;
|
||||
else return;
|
||||
|
||||
int state;
|
||||
string filepath, ext;
|
||||
KKdA3DA a3da;
|
||||
KKdFARC farc;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
@@ -58,13 +58,21 @@ namespace PD_Tool
|
||||
|
||||
Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".farc")
|
||||
using (KKdFARC farc = new KKdFARC(file))
|
||||
using (farc = new KKdFARC(file))
|
||||
FARCProcessor(farc, choose, format);
|
||||
else if (ext == ".a3da")
|
||||
using (a3da = new KKdA3DA(true))
|
||||
{
|
||||
state = a3da.A3DAReader(filepath);
|
||||
if (state == 1) a3da.MsgPackWriter(filepath, json);
|
||||
if (state == 1)
|
||||
if (choose == "8") a3da.MsgPackWriter(filepath, json);
|
||||
else
|
||||
{
|
||||
a3da.Head.Format = format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
|
||||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
}
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
using (a3da = new KKdA3DA(true))
|
||||
@@ -72,26 +80,21 @@ namespace PD_Tool
|
||||
a3da.MsgPackReader(filepath, ext == ".json");
|
||||
a3da.Head.Format = format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose != "1" &&
|
||||
choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter());
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
|
||||
choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void FARCProcessor(KKdFARC farc, string choose, Format format)
|
||||
{
|
||||
if (!farc.HeaderReader()) return;
|
||||
if (!farc.HasFiles) return;
|
||||
if (!farc.HeaderReader() || !farc.HasFiles) return;
|
||||
|
||||
KKdList<string> list = KKdList<string>.New;
|
||||
for (int i = 0; i < farc.Files.Count; i++)
|
||||
{
|
||||
string file = farc.Files[i].Name.ToLower();
|
||||
bool div = false;
|
||||
for (int i0 = 0; i0 < 159 && !div; i0++)
|
||||
if (file.Contains("div_" + i0)) div = true;
|
||||
|
||||
if (!div && file.EndsWith(".a3da")) list.Add(file);
|
||||
if (!file.Contains("_div_") && file.EndsWith(".a3da")) list.Add(file);
|
||||
}
|
||||
|
||||
KKdList<string> A3DAlist = KKdList<string>.New;
|
||||
@@ -100,7 +103,7 @@ namespace PD_Tool
|
||||
A3DAlist.Add(farc.Files[i].Name);
|
||||
|
||||
byte[] data = null;
|
||||
if (list.Count == A3DAlist.Count || (format > Format.AFT && format < Format.FT))
|
||||
if (list.Count == A3DAlist.Count)
|
||||
{
|
||||
KKdA3DA a3da;
|
||||
for (int i = 0; i < A3DAlist.Count; i++)
|
||||
@@ -112,7 +115,7 @@ namespace PD_Tool
|
||||
{
|
||||
KKdFARC.FARCFile file = farc.Files[i];
|
||||
a3da.Head.Format = format;
|
||||
file.Data = (choose != "1" && choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter();
|
||||
file.Data = (choose == "1"|| choose == "3") ? a3da.A3DAWriter() : a3da.A3DCWriter();
|
||||
farc.Files[i] = file;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +124,7 @@ namespace PD_Tool
|
||||
}
|
||||
|
||||
KKdA3DA[] a3daArray;
|
||||
using (KKdList<KKdA3DA> a3daList = KKdList<KKdA3DA>.New)
|
||||
using (KKdList<KKdA3DA> a3daList = KKdList<KKdA3DA>.NewReserve(list.Count))
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
@@ -139,27 +142,29 @@ namespace PD_Tool
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (a3daArray[i].Data.PlayControl.Div == null) continue;
|
||||
float Div = a3daArray[i].Data.PlayControl.Div.Value;
|
||||
int div = a3daArray[i].Data.PlayControl.Div.Value;
|
||||
string filename = Path.GetFileNameWithoutExtension(list[i]);
|
||||
string ext = Path.GetExtension(list[i]);
|
||||
KKdA3DA a3da;
|
||||
for (int i1 = 1; i1 < Div; i1++)
|
||||
for (int i1 = 1; i1 < div; i1++)
|
||||
using (a3da = new KKdA3DA(true))
|
||||
{
|
||||
string file = Path.GetFileNameWithoutExtension(list[i]) +
|
||||
"_div_" + i1 + Path.GetExtension(list[i]);
|
||||
string file = filename + "_div_" + i1 + ext;
|
||||
data = farc.FileReader(file);
|
||||
int state = a3da.A3DAReader(data);
|
||||
if (state == 1) a3daArray[i].A3DAMerger(ref a3da.Data);
|
||||
}
|
||||
a3daArray[i].Data.PlayControl.Div = null;
|
||||
}
|
||||
|
||||
|
||||
farc.Files.Capacity = 0;
|
||||
farc.Files.Capacity = list.Count;
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
KKdFARC.FARCFile file = default;
|
||||
file.Name = list[i];
|
||||
a3daArray[i].Head.Format = format;
|
||||
file.Data = (choose != "1" && choose != "3") ? a3daArray[i].A3DCWriter() : a3daArray[i].A3DAWriter();
|
||||
file.Data = (choose == "1" || choose == "3") ? a3daArray[i].A3DAWriter() : a3daArray[i].A3DCWriter();
|
||||
farc.Files.Add(file);
|
||||
}
|
||||
farc.Save();
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class ADP
|
||||
{
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Add Param Converter";
|
||||
Program.Choose(1, "adp", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
string filepath, ext;
|
||||
AddParam adp;
|
||||
foreach (string file in fileNames)
|
||||
using (adp = new AddParam())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Add Param Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".adp")
|
||||
{
|
||||
adp.AddParamReader(filepath);
|
||||
adp. MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
adp. MsgPackReader(filepath, ext == ".json");
|
||||
adp.AddParamWriter(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
|
||||
+11
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,8 +22,16 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Bloom Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".blt") { blt.BLTReader(filepath); blt.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { blt.TXTReader(filepath); blt.BLTWriter(filepath); }
|
||||
if (ext == ".blt")
|
||||
{
|
||||
blt.BLTReader(filepath);
|
||||
blt.TXTWriter(filepath);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
{
|
||||
blt.TXTReader(filepath);
|
||||
blt.BLTWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,8 +22,16 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Color Correction Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".cct") { cct.CCTReader(filepath); cct.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { cct.TXTReader(filepath); cct.BLTWriter(filepath); }
|
||||
if (ext == ".cct")
|
||||
{
|
||||
cct.CCTReader(filepath);
|
||||
cct.TXTWriter(filepath);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
{
|
||||
blt.TXTReader(filepath);
|
||||
blt.CCTWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -16,7 +16,7 @@ namespace PD_Tool
|
||||
if (file.EndsWith(".mp" )) { mp = false; break; }
|
||||
else if (file.EndsWith(".json")) { mp = false; break; }
|
||||
|
||||
uint num2 = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
uint num2 = (uint)((DateTime.Now.Ticks - 621355968000000000) / 10000000);
|
||||
string[] file_split;
|
||||
string filepath, ext;
|
||||
KKdMainLib.DataBank db;
|
||||
|
||||
+13
-13
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdDEX = KKdMainLib.DEX;
|
||||
@@ -24,9 +24,9 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of exporting file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. F/FT PS3/PS4/PSVita");
|
||||
Program.ConsoleDesign("2. F2 PS3/PSVita");
|
||||
Program.ConsoleDesign("3. X PS4/PSVita");
|
||||
Program.ConsoleDesign("1. F/AFT/FT/M39 PS3/PS4/PSV/AC/NSW");
|
||||
Program.ConsoleDesign("2. F2 PS3/PSV");
|
||||
Program.ConsoleDesign("3. X PS4/PSV");
|
||||
if ( mp && !json) Program.ConsoleDesign("9. MessagePack");
|
||||
if (_json && json) Program.ConsoleDesign("9. JSON");
|
||||
Program.ConsoleDesign(false);
|
||||
@@ -35,27 +35,27 @@ namespace PD_Tool
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
|
||||
Format format = Format.NULL;
|
||||
if (choose == "1") format = Format.F ;
|
||||
else if (choose == "2") format = Format.F2LE;
|
||||
else if (choose == "3") format = Format.X ;
|
||||
if (choose == "1") format = Format.F ;
|
||||
else if (choose == "2") format = Format.F2;
|
||||
else if (choose == "3") format = Format.X ;
|
||||
else if (choose == "9" && mp && _json) format = Format.NULL;
|
||||
else return;
|
||||
|
||||
string filepath, ext;
|
||||
KKdDEX DEX;
|
||||
KKdDEX dex;
|
||||
foreach (string file in fileNames)
|
||||
using (DEX = new KKdDEX())
|
||||
using (dex = new KKdDEX())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DEX Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin" || ext == ".dex") DEX. DEXReader(filepath, ext );
|
||||
else DEX.MsgPackReader(filepath, json);
|
||||
if (ext == ".bin" || ext == ".dex") dex. DEXReader(filepath, ext );
|
||||
else dex.MsgPackReader(filepath, json);
|
||||
|
||||
if (format > Format.NULL) DEX. DEXWriter(filepath, format);
|
||||
else DEX.MsgPackWriter(filepath, json);
|
||||
if (format > Format.NULL) dex. DEXWriter(filepath, format);
|
||||
else dex.MsgPackWriter(filepath, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,8 +22,16 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".dft") { dft.DFTReader(filepath); dft.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { dft.TXTReader(filepath); dft.DFTWriter(filepath); }
|
||||
if (ext == ".dft")
|
||||
{
|
||||
dft.DFTReader(filepath);
|
||||
dft.TXTWriter(filepath);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
{
|
||||
dft.TXTReader(filepath);
|
||||
dft.DFTWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdSoundLib;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdMainLib;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aet = KKdMainLib.DB.Aet;
|
||||
using Auth = KKdMainLib.DB.Auth;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace PD_Tool
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "2" || choose == "4") farc.FARCType |= KKdFARC.Type.GZip;
|
||||
if (choose == "3" || choose == "4") farc.FARCType |= KKdFARC.Type.ECB ;
|
||||
if (choose == "3" || choose == "4") farc.FARCType |= KKdFARC.Type.Enc ;
|
||||
}
|
||||
else if (choose == "R") return;
|
||||
else farc.Signature = KKdFARC.Farc.FArC;
|
||||
|
||||
+11
-3
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,8 +22,16 @@ namespace PD_Tool
|
||||
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); }
|
||||
if (ext == ".lit")
|
||||
{
|
||||
lit.LITReader(filepath);
|
||||
lit.TXTWriter(filepath);
|
||||
}
|
||||
/*else if (ext == ".txt")
|
||||
{
|
||||
lit.TXTReader(filepath);
|
||||
lit.LITWriter(filepath);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-18
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -15,25 +15,24 @@ namespace PD_Tool
|
||||
string filepath, ext;
|
||||
MotHead mhd;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
mhd = new MotHead();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
using (mhd = new MotHead())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "MotHead Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
mhd.MotHeadReader(filepath);
|
||||
mhd.MsgPackWriter(filepath, json);
|
||||
Console.Title = "MotHead Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
mhd.MotHeadReader(filepath);
|
||||
mhd.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
mhd.MsgPackReader(filepath, ext == ".json");
|
||||
mhd.MotHeadWriter(filepath);
|
||||
}
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
mhd.MsgPackReader(filepath, ext == ".json");
|
||||
mhd.MotHeadWriter(filepath);
|
||||
}
|
||||
mhd = new MotHead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+73
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -24,6 +24,78 @@ namespace PD_Tool
|
||||
Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
/*KKdBaseLib.KKdDict<int, int> a = KKdBaseLib.KKdDict<int, int>.New;
|
||||
while (true)
|
||||
{
|
||||
string b = Console.ReadLine();
|
||||
if (b == "") break;
|
||||
string[] c = b.Split(' ');
|
||||
if (c.Length == 2)
|
||||
a.Add(int.Parse(c[0]), int.Parse(c[1]));
|
||||
}
|
||||
a.Add(0, 1);
|
||||
a.Add(1648, 3);
|
||||
a.Add(2139, 2);
|
||||
a.Add(5416, 4);
|
||||
a.Add(6589, 5);
|
||||
a.Add(7783, 1);
|
||||
mot.MOTReader(filepath);
|
||||
|
||||
Mot.KeySet[] oks = mot.MOT[1].KeySet.V;
|
||||
Mot.MotHeader mh = mot.MOT[1];
|
||||
mh.KeySet.V = new Mot.KeySet[mh.KeySet.V.Length];
|
||||
Mot.KeySet[] ok = mh.KeySet.V;
|
||||
for (int i = 0; i < mh.KeySet.V.Length; i++)
|
||||
{
|
||||
KKdBaseLib.Interpolation.PDI[] pdi = new KKdBaseLib.Interpolation.PDI[mot.MOT.Length];
|
||||
for (int h = 0; h < mot.MOT.Length; h++)
|
||||
pdi[h] = new KKdBaseLib.Interpolation.PDI(mot.MOT[h].KeySet.V[i].Keys);
|
||||
|
||||
KKdBaseLib.KKdList<KKdBaseLib.KFT2> kf = KKdBaseLib.KKdList<KKdBaseLib.KFT2>.New;
|
||||
|
||||
bool old = false;
|
||||
KKdBaseLib.KFT2 v = default;
|
||||
KKdBaseLib.KFT2 ov = default;
|
||||
int k = -1;
|
||||
for (int h = 0; h < mh.FrameCount; h++)
|
||||
{
|
||||
if (a.ContainsKey(h))
|
||||
k = a[h];
|
||||
else if (k == -1) continue;
|
||||
|
||||
ref KKdBaseLib.Interpolation.PDI pdil = ref pdi[k];
|
||||
|
||||
v.F = h;
|
||||
v.V = pdil.SetFrame(h);
|
||||
if (h == 0 || ov.V != v.V)
|
||||
{
|
||||
if (old) { old = false; kf.Add(ov); }
|
||||
kf.Add(v);
|
||||
}
|
||||
else old = true;
|
||||
ov = v;
|
||||
}
|
||||
kf.Capacity = kf.Count;
|
||||
ok[i].Keys = kf.ToArray();
|
||||
ok[i].Type = Mot.KeySetType.Linear;
|
||||
|
||||
for (int h = 0; h < mot.MOT.Length; h++)
|
||||
pdi[h] = default;
|
||||
}
|
||||
for (int i = 0; i < mh.KeySet.V.Length; i++)
|
||||
{
|
||||
if (ok[i].Keys.Length != 1) continue;
|
||||
|
||||
if (ok[i].Keys[0].V == 0)
|
||||
{
|
||||
ok[i].Keys[0].F = 0;
|
||||
ok[i].Type = Mot.KeySetType.None;
|
||||
}
|
||||
else ok[i].Type = Mot.KeySetType.Static;
|
||||
}
|
||||
mot.MOT[1].KeySet.V = ok;
|
||||
Array.Resize(ref mot.MOT, 2);
|
||||
mot.MOTWriter(filepath + "_mod");*/
|
||||
mot. MOTReader(filepath);
|
||||
mot.MsgPackWriter(filepath, json);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdSTR = KKdMainLib.STR;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace PD_Tool
|
||||
Console.Title = "STR Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".str" || ext == ".bin")
|
||||
{
|
||||
str.STRReader (filepath, ext);
|
||||
str.STRReader (filepath, ext);
|
||||
str.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdVAG = KKdSoundLib.VAG;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PD_Tool
|
||||
A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files
|
||||
A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
|
||||
|
||||
# Dependencies:
|
||||
+ `.NET Standard 2.0`: Required to build KKdBaseLib, KKdMainLib and KKdSoundLib C# projects.
|
||||
@@ -12,15 +12,17 @@ A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files
|
||||
- `Aet DB Converter`
|
||||
- `Auth DB Converter`
|
||||
- `Spr DB Converter`
|
||||
- `AC/DT/F/AFT/FT Converting Tools`
|
||||
- `AC/DT/F/AFT Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `AET Converter`
|
||||
- `DataBank Converter`
|
||||
- `DEX Converter`
|
||||
- `DIVA Converter`
|
||||
- `MotHead Converter`
|
||||
- `MOT Converter`
|
||||
- `Table Converter`
|
||||
- `STR Converter`
|
||||
- `F/F2/X/FT Converting Tools`
|
||||
- `F/F2/FT Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `Bloom Converter`
|
||||
- `Color Correction Converter`
|
||||
@@ -29,3 +31,17 @@ A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files
|
||||
- `Light Converter`
|
||||
- `STR Converter`
|
||||
- `VAG Converter`
|
||||
- `X/XHD Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `DEX Converter`
|
||||
- `VAG Converter`
|
||||
- `FT/M39 Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `AddParam Converter`
|
||||
- `AET Converter`
|
||||
- `DEX Converter`
|
||||
- `DIVA Converter`
|
||||
- `MotHead Converter`
|
||||
- `MOT Converter`
|
||||
- `Table Converter`
|
||||
- `STR Converter`
|
||||
|
||||
Reference in New Issue
Block a user