Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e75c7e6742 | ||
|
|
5ace6bc0e0 | ||
|
|
38851135b6 | ||
|
|
9cbeaf59c2 |
@@ -1,11 +1,11 @@
|
||||
using KKdBaseLib.A3DA;
|
||||
using KKdBaseLib.Auth3D;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct A3DAKey
|
||||
{
|
||||
public KeyType Type;
|
||||
public int Unk04;
|
||||
public float Value;
|
||||
public float MaxFrames;
|
||||
public EPType EPTypePre;
|
||||
public EPType EPTypePost;
|
||||
@@ -18,10 +18,8 @@ namespace KKdBaseLib
|
||||
public int Unk2C;
|
||||
public int Unk30;
|
||||
public int Unk34;
|
||||
public int Length;
|
||||
public int Unk3C;
|
||||
public int DataOffset; //Used only in-game and points to KFT3 Array
|
||||
public int Unk44;
|
||||
public long Length;
|
||||
public long DataOffset; //Used only in-game and points to KFT3 Array
|
||||
|
||||
public KFT3[] Keys;
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
namespace KKdBaseLib.Aet
|
||||
{
|
||||
public struct AetHeader
|
||||
{
|
||||
public Pointer<AetData>[] Data;
|
||||
}
|
||||
|
||||
public struct AetData
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public float StartFrame;
|
||||
public float EndFrame;
|
||||
public float FrameRate;
|
||||
public uint BackColor;
|
||||
public uint Width;
|
||||
public uint Height;
|
||||
public Pointer<Vector2<CountPointer<KFT2>>> Camera;
|
||||
public CountPointer<AetComposition > Compositions ;
|
||||
public CountPointer<AetSurface> Surfaces;
|
||||
public CountPointer<AetSoundEffect > SoundEffects ;
|
||||
}
|
||||
|
||||
public struct AetComposition
|
||||
{
|
||||
public int P;
|
||||
public int C { get => E != null ? E.Length : 0;
|
||||
set => E = value > -1 ? new AetLayer[value] : null; }
|
||||
|
||||
public int O;
|
||||
public AetLayer[] E;
|
||||
|
||||
public override string ToString() => "Count: " + C;
|
||||
}
|
||||
|
||||
|
||||
public struct AetLayer
|
||||
{
|
||||
public int ID;
|
||||
public int Offset;
|
||||
public Pointer<string> Name;
|
||||
public float StartFrame;
|
||||
public float EndFrame;
|
||||
public float StartOffset;
|
||||
public float PlaybackSpeed;
|
||||
public AetLayerFlags Flags;
|
||||
public byte Pad;
|
||||
public AetLayerType Type;
|
||||
public int DataOffset;
|
||||
public int ParentLayer;
|
||||
public CountPointer<AetMarker> Marker;
|
||||
public Pointer<AnimationData> Data;
|
||||
public Pointer<AudioData> ExtraData;
|
||||
|
||||
public int DataID;
|
||||
|
||||
public enum AetLayerFlags : ushort
|
||||
{
|
||||
Visible = 0b0000000000000001,
|
||||
Audible = 0b0000000000000010,
|
||||
Unk2 = 0b0000000000000100,
|
||||
Unk3 = 0b0000000000001000,
|
||||
Unk4 = 0b0000000000010000,
|
||||
AudioRealted = 0b0000000000100000,
|
||||
Unk6 = 0b0000000001000000,
|
||||
SpriteFrames = 0b0000000010000000,
|
||||
Unk8 = 0b0000000100000000,
|
||||
Unk9 = 0b0000001000000000,
|
||||
Unk10 = 0b0000010000000000,
|
||||
Unk11 = 0b0000100000000000,
|
||||
Unk12 = 0b0001000000000000,
|
||||
Unk13 = 0b0010000000000000,
|
||||
Unk14 = 0b0100000000000000,
|
||||
Unk15 = 0b1000000000000000,
|
||||
}
|
||||
|
||||
public enum AetLayerType : byte
|
||||
{
|
||||
Nop = 0,
|
||||
Pic = 1,
|
||||
Aif = 2,
|
||||
Eff = 3,
|
||||
}
|
||||
|
||||
public override string ToString() => $"ID: {ID}; Name: {Name.V}; Type: {Type}" +
|
||||
( DataID > -1 ? $"; " + $"Data ID: { DataID}" : "") +
|
||||
(ParentLayer > -1 ? $"; Parent Object ID: {ParentLayer}" : "");
|
||||
}
|
||||
|
||||
public struct AetMarker
|
||||
{
|
||||
public float Frame;
|
||||
public Pointer<string> Name;
|
||||
}
|
||||
|
||||
public struct AnimationData
|
||||
{
|
||||
public BlendMode Mode;
|
||||
public byte Padding0;
|
||||
public bool UseTextureMask;
|
||||
public byte Padding1;
|
||||
public CountPointer<KFT2> OriginX;
|
||||
public CountPointer<KFT2> OriginY;
|
||||
public CountPointer<KFT2> PositionX;
|
||||
public CountPointer<KFT2> PositionY;
|
||||
public CountPointer<KFT2> Rotation;
|
||||
public CountPointer<KFT2> ScaleX;
|
||||
public CountPointer<KFT2> ScaleY;
|
||||
public CountPointer<KFT2> Opacity;
|
||||
public Pointer<Perspective> Persp;
|
||||
|
||||
public enum BlendMode : byte
|
||||
{
|
||||
Alpha = 3,
|
||||
Additive = 5,
|
||||
DstColorZero = 6,
|
||||
SrcAlphaOneMinusSrcColor = 7,
|
||||
Transparent = 8,
|
||||
}
|
||||
|
||||
public struct Perspective
|
||||
{
|
||||
public CountPointer<KFT2> Unk1 ;
|
||||
public CountPointer<KFT2> Unk2 ;
|
||||
public CountPointer<KFT2> RotReturnX;
|
||||
public CountPointer<KFT2> RotReturnY;
|
||||
public CountPointer<KFT2> RotReturnZ;
|
||||
public CountPointer<KFT2> RotationX;
|
||||
public CountPointer<KFT2> RotationY;
|
||||
public CountPointer<KFT2> ScaleZ;
|
||||
}
|
||||
}
|
||||
|
||||
public struct AudioData
|
||||
{
|
||||
public CountPointer<KFT2> Data0;
|
||||
public CountPointer<KFT2> Data1;
|
||||
public CountPointer<KFT2> Data2;
|
||||
public CountPointer<KFT2> Data3;
|
||||
}
|
||||
|
||||
public struct AetSurface
|
||||
{
|
||||
public int O;
|
||||
public uint Color;
|
||||
public ushort Width;
|
||||
public ushort Height;
|
||||
public float Frames;
|
||||
public CountPointer<AetSpriteIdentifier> Sprites;
|
||||
|
||||
public override string ToString() => $"Width: {Width}; Height: {Height}; Color: {Color.ToString("X2")}";
|
||||
}
|
||||
|
||||
public struct AetSpriteIdentifier
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public uint ID;
|
||||
|
||||
public override string ToString() => $"ID: {ID}; Name: {Name}";
|
||||
}
|
||||
|
||||
public struct AetSoundEffect
|
||||
{
|
||||
public int O;
|
||||
public uint Unk;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
//Original: AetSet.bt Version: 5.0 by samyuu
|
||||
|
||||
namespace KKdBaseLib.Auth2D
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
public Pointer<Scene>[] Scenes;
|
||||
}
|
||||
|
||||
public struct Scene
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public float StartFrame;
|
||||
public float EndFrame;
|
||||
public float FrameRate;
|
||||
public uint BackColor;
|
||||
public uint Width;
|
||||
public uint Height;
|
||||
public Pointer<Vec2<CountPointer<KFT2>>> Camera;
|
||||
public CountPointer<Composition> Compositions;
|
||||
public CountPointer<Video > Videos;
|
||||
public CountPointer<Audio > Audios;
|
||||
}
|
||||
|
||||
public struct Composition
|
||||
{
|
||||
public int P;
|
||||
public int C { get => E != null ? E.Length : 0;
|
||||
set => E = value > -1 ? new Layer[value] : null; }
|
||||
|
||||
public int O;
|
||||
public Layer[] E;
|
||||
|
||||
public override string ToString() => "Count: " + C;
|
||||
}
|
||||
|
||||
|
||||
public struct Layer
|
||||
{
|
||||
public int ID;
|
||||
public int Offset;
|
||||
public Pointer<string> Name;
|
||||
public float StartFrame;
|
||||
public float EndFrame;
|
||||
public float OffsetFrame;
|
||||
public float TimeScale;
|
||||
public AetLayerFlags Flags;
|
||||
public AetLayerQuality Quality;
|
||||
public AetLayerType Type;
|
||||
public int VideoItemOffset;
|
||||
public int ParentLayer;
|
||||
public CountPointer<Marker> Markers;
|
||||
public Pointer<VideoData> Video;
|
||||
public Pointer<AudioData> Audio;
|
||||
|
||||
public int DataID;
|
||||
|
||||
public enum AetLayerFlags : ushort
|
||||
{
|
||||
VideoActive = 0b0000000000000001,
|
||||
AudioActive = 0b0000000000000010,
|
||||
EffectsActive = 0b0000000000000100,
|
||||
MotionBlur = 0b0000000000001000,
|
||||
FrameBlending = 0b0000000000010000,
|
||||
Locked = 0b0000000000100000,
|
||||
Shy = 0b0000000001000000,
|
||||
Collapse = 0b0000000010000000,
|
||||
AutoOrientRotation = 0b0000000100000000,
|
||||
AdjustmentLayer = 0b0000001000000000,
|
||||
TimeRemapping = 0b0000010000000000,
|
||||
LayerIs3D = 0b0000100000000000,
|
||||
LookAtCamera = 0b0001000000000000,
|
||||
LookAtPOI = 0b0010000000000000, //POI - Point Of Interest
|
||||
Solo = 0b0100000000000000,
|
||||
MarkersLocked = 0b1000000000000000,
|
||||
}
|
||||
|
||||
public enum AetLayerQuality : byte
|
||||
{
|
||||
None = 0,
|
||||
Wireframe = 1,
|
||||
Draft = 2,
|
||||
Best = 3,
|
||||
}
|
||||
|
||||
public enum AetLayerType : byte
|
||||
{
|
||||
None = 0,
|
||||
Video = 1,
|
||||
Audio = 2,
|
||||
Composition = 3,
|
||||
}
|
||||
|
||||
public override string ToString() => $"ID: {ID}; Name: {Name.V}; Type: {Type}" +
|
||||
( DataID > -1 ? $"; " + $"Data ID: { DataID}" : "") +
|
||||
(ParentLayer > -1 ? $"; Parent Object ID: {ParentLayer}" : "");
|
||||
}
|
||||
|
||||
public struct Marker
|
||||
{
|
||||
public float Frame;
|
||||
public Pointer<string> Name;
|
||||
}
|
||||
|
||||
public struct VideoData
|
||||
{
|
||||
public VideoTransferMode TransferMode;
|
||||
public byte Padding;
|
||||
public CountPointer<KFT2> AnchorX;
|
||||
public CountPointer<KFT2> AnchorY;
|
||||
public CountPointer<KFT2> PositionX;
|
||||
public CountPointer<KFT2> PositionY;
|
||||
public CountPointer<KFT2> Rotation ;
|
||||
public CountPointer<KFT2> ScaleX;
|
||||
public CountPointer<KFT2> ScaleY;
|
||||
public CountPointer<KFT2> Opacity ;
|
||||
public Pointer<Video3DData> Video3D;
|
||||
|
||||
public struct VideoTransferMode
|
||||
{
|
||||
public TransferBlendMode BlendMode;
|
||||
public TransferFlags Flags;
|
||||
public TransferTrackMatte TrackMatte;
|
||||
|
||||
public enum TransferBlendMode : byte
|
||||
{
|
||||
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
|
||||
{
|
||||
PreserveAlpha = 0b01,
|
||||
RandomizeDissolve = 0b10,
|
||||
}
|
||||
|
||||
public enum TransferTrackMatte : byte
|
||||
{
|
||||
NoTrackMatte = 0,
|
||||
Alpha = 1,
|
||||
NotAlpha = 2,
|
||||
Luma = 3,
|
||||
NotLuma = 4,
|
||||
}
|
||||
}
|
||||
|
||||
public struct Video3DData
|
||||
{
|
||||
public CountPointer<KFT2> AnchorZ;
|
||||
public CountPointer<KFT2> PositionZ;
|
||||
public CountPointer<KFT2> DirectionX;
|
||||
public CountPointer<KFT2> DirectionY;
|
||||
public CountPointer<KFT2> DirectionZ;
|
||||
public CountPointer<KFT2> RotationX;
|
||||
public CountPointer<KFT2> RotationY;
|
||||
public CountPointer<KFT2> ScaleZ;
|
||||
}
|
||||
}
|
||||
|
||||
public struct AudioData
|
||||
{
|
||||
public CountPointer<KFT2> VolumeL;
|
||||
public CountPointer<KFT2> VolumeR;
|
||||
public CountPointer<KFT2> PanL;
|
||||
public CountPointer<KFT2> PanR;
|
||||
}
|
||||
|
||||
public struct Video
|
||||
{
|
||||
public int O;
|
||||
public uint Color;
|
||||
public ushort Width;
|
||||
public ushort Height;
|
||||
public float Frames;
|
||||
public CountPointer<Source> Sources;
|
||||
|
||||
public override string ToString() => $"Width: {Width}; Height: {Height}; Color: {Color.ToString("X2")}";
|
||||
|
||||
public struct Source
|
||||
{
|
||||
public Pointer<string> Name;
|
||||
public uint ID;
|
||||
|
||||
public override string ToString() => $"ID: {ID}; Name: {Name}";
|
||||
}
|
||||
}
|
||||
|
||||
public struct Audio
|
||||
{
|
||||
public int O;
|
||||
public uint SoundID;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace KKdBaseLib.A3DA
|
||||
namespace KKdBaseLib.Auth3D
|
||||
{
|
||||
public struct A3DAData
|
||||
public struct Data
|
||||
{
|
||||
public string[] Motion;
|
||||
public string[] ObjectList;
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
public struct _
|
||||
{
|
||||
public int? CompressF16;
|
||||
public CompressF16 CompressF16;
|
||||
public string FileName;
|
||||
public string PropertyVersion;
|
||||
public string ConverterVersion;
|
||||
@@ -35,9 +35,9 @@
|
||||
|
||||
public struct Ambient
|
||||
{
|
||||
public string Name;
|
||||
public Vector4<Key> LightDiffuse;
|
||||
public Vector4<Key> RimLightDiffuse;
|
||||
public string Name;
|
||||
public Vec4<Key> LightDiffuse;
|
||||
public Vec4<Key> RimLightDiffuse;
|
||||
}
|
||||
|
||||
public struct CameraAuxiliary
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
public struct ViewPoint
|
||||
{
|
||||
public bool? FOVHorizontal;
|
||||
public bool FOVHorizontal;
|
||||
public float? Aspect;
|
||||
public float? CameraApertureH;
|
||||
public float? CameraApertureW;
|
||||
@@ -99,7 +99,21 @@
|
||||
public Key End;
|
||||
public Key Start;
|
||||
public Key Density;
|
||||
public Vector4<Key> Diffuse;
|
||||
public Vec4<Key> Diffuse;
|
||||
}
|
||||
|
||||
public enum CompressF16 : int
|
||||
{
|
||||
F32F32F32F32 = 0,
|
||||
I16F16F32F32 = 1,
|
||||
I16F16F16F16 = 2,
|
||||
}
|
||||
|
||||
public enum EPType : int
|
||||
{
|
||||
EP_1 = 1,
|
||||
EP_2 = 2,
|
||||
EP_3 = 3,
|
||||
}
|
||||
|
||||
public enum KeyType : int
|
||||
@@ -111,13 +125,6 @@
|
||||
Hold = 4,
|
||||
}
|
||||
|
||||
public enum EPType : int
|
||||
{
|
||||
EP_1 = 1,
|
||||
EP_2 = 2,
|
||||
EP_3 = 3,
|
||||
}
|
||||
|
||||
public struct Key
|
||||
{
|
||||
public KeyType? Type;
|
||||
@@ -138,10 +145,10 @@
|
||||
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 Vec3<A3DAKey> ToA3DAKey(Vec3< Key> k) =>
|
||||
new Vec3<A3DAKey> { X = (A3DAKey)k.X, Y = (A3DAKey)k.Y, Z = (A3DAKey)k.Z };
|
||||
public static Vec3< Key> ToKey (Vec3<A3DAKey> k) =>
|
||||
new Vec3< Key> { X = ( Key)k.X, Y = ( Key)k.Y, Z = ( Key)k.Z };
|
||||
|
||||
public static explicit operator Key(A3DAKey k)
|
||||
{
|
||||
@@ -152,7 +159,7 @@
|
||||
if (k.Length > 1)
|
||||
{
|
||||
key.Type = k.Type;
|
||||
key.Length = k.Length;
|
||||
key.Length = (int)k.Length;
|
||||
key.Keys = k.Keys;
|
||||
}
|
||||
else if (k.Length == 1)
|
||||
@@ -179,17 +186,12 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
key.Length = 1;
|
||||
key.Keys = new KFT3[1];
|
||||
if (k.Length == 1)
|
||||
{
|
||||
key.Type = KeyType.Value;
|
||||
key.Keys[0].V = k.Value ?? 0;
|
||||
}
|
||||
else if (k.Type.HasValue && k.Value.HasValue)
|
||||
key.Type = 0;
|
||||
key.Value = 0.0f;
|
||||
if (k.Type.HasValue && k.Value.HasValue)
|
||||
{
|
||||
key.Type = k.Type.Value;
|
||||
key.Keys[0].V = k.Value.Value;
|
||||
key.Value = k.Value.Value;
|
||||
}
|
||||
}
|
||||
return key;
|
||||
@@ -201,10 +203,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;
|
||||
}
|
||||
@@ -214,15 +216,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;
|
||||
|
||||
@@ -240,9 +242,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,29 +277,29 @@
|
||||
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 Vec2<Key> Offset;
|
||||
public Vec2<Key> Repeat;
|
||||
public Vec2<Key> Coverage;
|
||||
public Vec2<Key> TranslateFrame;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ObjectHRC
|
||||
{
|
||||
public float? Shadow;
|
||||
public int? Shadow;
|
||||
public string Name;
|
||||
public string UIDName;
|
||||
public Node[] Node;
|
||||
public Vector3<float?> JointOrient;
|
||||
public Vec3<float?> JointOrient;
|
||||
}
|
||||
|
||||
public struct PlayControl
|
||||
{
|
||||
public float? Begin;
|
||||
public float? Div;
|
||||
public float? FPS;
|
||||
public float? Offset;
|
||||
public float? Size;
|
||||
public int Begin;
|
||||
public int? Div;
|
||||
public int FPS;
|
||||
public int? Offset;
|
||||
public int Size;
|
||||
}
|
||||
|
||||
public struct PostProcess
|
||||
@@ -305,8 +307,8 @@
|
||||
public Key LensFlare;
|
||||
public Key LensGhost;
|
||||
public Key LensShaft;
|
||||
public Vector4<Key> Ambient;
|
||||
public Vector4<Key> Diffuse;
|
||||
public Vector4<Key> Specular;
|
||||
public Vec4<Key> Ambient;
|
||||
public Vec4<Key> Diffuse;
|
||||
public Vec4<Key> Specular;
|
||||
}
|
||||
}
|
||||
+43
-10
@@ -1,4 +1,4 @@
|
||||
//Original research by Samyuu
|
||||
//Original research by Samyuu
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -39,26 +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, int offset = 0, ushort seed = 0xFFFF)
|
||||
{
|
||||
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 CalculateChecksumU32(byte* data,
|
||||
int length, int offset = 0, uint seed = 0xFFFFFFFF)
|
||||
{
|
||||
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 CalculateChecksumU64(byte* data,
|
||||
int length, int offset = 0, ulong seed = 0xFFFFFFFFFFFFFFFF)
|
||||
{
|
||||
ulong result = seed;
|
||||
for (int i = offset; i < length; i++)
|
||||
result = ChecksumLookupTable[(byte)(result >> 8) ^ data[i]] ^ (result << 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
+76
-47
@@ -1,13 +1,9 @@
|
||||
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 );
|
||||
@@ -38,9 +34,6 @@ 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 ) ;
|
||||
@@ -116,22 +109,38 @@ 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; }
|
||||
@@ -145,10 +154,20 @@ namespace KKdBaseLib
|
||||
{ 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, Half val)
|
||||
{ fixed (byte* ptr = arr) *( Half*)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, Vec2 val)
|
||||
{ fixed (byte* ptr = arr) *( Vec2*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, Vec3 val)
|
||||
{ fixed (byte* ptr = arr) *( Vec3*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, Vec4 val)
|
||||
{ fixed (byte* ptr = arr) *( Vec4*)ptr = val; }
|
||||
public static void GBy(this byte[] arr, Quat val)
|
||||
{ fixed (byte* ptr = arr) *( Quat*)ptr = val; }
|
||||
|
||||
public static sbyte CITSB(this int c)
|
||||
{ return ( sbyte)(c > 0x0000007F ?
|
||||
@@ -215,7 +234,7 @@ namespace KKdBaseLib
|
||||
return d.ToString();
|
||||
}
|
||||
|
||||
private static readonly string NumberDecimalSeparator =
|
||||
private static readonly string NDS =
|
||||
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
|
||||
|
||||
public static string ToS(this bool? d) => (d ?? default).ToString();
|
||||
@@ -237,28 +256,38 @@ namespace KKdBaseLib
|
||||
public static string ToS(this ulong? d) => (d ?? default).ToString();
|
||||
public static string ToS(this ulong d) => d.ToString();
|
||||
public static string ToS(this float? d, int round) => (d ?? default).ToS(round);
|
||||
public static string ToS(this float? d) => (d ?? default).ToString();
|
||||
public static string ToS(this float d, int round) =>
|
||||
Math.Round(d, round).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static string ToS(this float d) =>
|
||||
Math.Round(d, 15).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static string ToS(this float? d) => (d ?? default).ToS();
|
||||
public static string ToS(this float d, int round)
|
||||
{ string s = (d.ToU32() & 0x80000000) != 0 ? "-" : ""; d = (d.ToU32() & 0x7FFFFFFF).ToF32();
|
||||
return s + Math.Round(d, round).ToString().ToLower().Replace(NDS, "."); }
|
||||
public static string ToS(this float d)
|
||||
{ string s = (d.ToU32() & 0x80000000) != 0 ? "-" : ""; d = (d.ToU32() & 0x7FFFFFFF).ToF32();
|
||||
return s + Math.Round(d, 15).ToString().ToLower().Replace(NDS, "."); }
|
||||
public static string ToS(this double? d, int round) => (d ?? default).ToS(round);
|
||||
public static string ToS(this double? d) => (d ?? default).ToString();
|
||||
public static string ToS(this double d, int round) =>
|
||||
Math.Round(d, round).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static string ToS(this double d) =>
|
||||
Math.Round(d, 15).ToString().ToLower().Replace(NumberDecimalSeparator, ".");
|
||||
public static float ToF32(this string s) =>
|
||||
float. Parse(s.Replace(".", NumberDecimalSeparator));
|
||||
public static bool ToF32(this string s, out float value) =>
|
||||
float.TryParse(s.Replace(".", NumberDecimalSeparator), out value);
|
||||
public static double ToF64(this string s) =>
|
||||
double. Parse(s.Replace(".", NumberDecimalSeparator));
|
||||
public static bool ToF64(this string s, out double value) =>
|
||||
double.TryParse(s.Replace(".", NumberDecimalSeparator), out value);
|
||||
public static bool ToF32(this string s, out float? value)
|
||||
{ bool Val = ToF32(s, out float val); value = val; return Val; }
|
||||
public static bool ToF64(this string s, out double? value)
|
||||
{ bool Val = ToF64(s, out double val); value = val; return Val; }
|
||||
public static string ToS(this double? d) => (d ?? default).ToS();
|
||||
public static string ToS(this double d, int round)
|
||||
{ string s = (d.ToU64() & 0x8000000000000000) != 0 ? "-" : ""; d = (d.ToU64() & 0x7FFFFFFFFFFFFFFF).ToF64();
|
||||
return s + Math.Round(d, round).ToString().ToLower().Replace(NDS, "."); }
|
||||
public static string ToS(this double d)
|
||||
{ string s = (d.ToU64() & 0x8000000000000000) != 0 ? "-" : ""; d = (d.ToU64() & 0x7FFFFFFFFFFFFFFF).ToF64();
|
||||
return s + Math.Round(d, 15).ToString().ToLower().Replace(NDS, "."); }
|
||||
public static float ToF32(this string s)
|
||||
{ if (s.Length < 1) return 0; uint d = 0; if (s[0] == '-') d = 0x80000000;
|
||||
d |= float.Parse(s.Replace(".", NDS)).ToU32(); return d.ToF32(); }
|
||||
public static double ToF64(this string s)
|
||||
{ if (s.Length < 1) return 0; ulong d = 0; if (s[0] == '-') d = 0x8000000000000000;
|
||||
d |= double.Parse(s.Replace(".", NDS)).ToU64(); return d.ToF64(); }
|
||||
public static bool ToF32(this string s, out float val)
|
||||
{ val = 0; if (s.Length < 1) return false; uint d = 0; if (s[0] == '-') d = 0x80000000;
|
||||
bool b = float.TryParse(s.Replace(".", NDS), out val); if (b) val = (d | val.ToU32()).ToF32(); return b; }
|
||||
public static bool ToF64(this string s, out double val)
|
||||
{ val = 0; if (s.Length < 1) return false; ulong d = 0; if (s[0] == '-') d = 0x8000000000000000;
|
||||
bool b = double.TryParse(s.Replace(".", NDS), out val); if (b) val = (d | val.ToU64()).ToF64(); return b; }
|
||||
public static bool ToF32(this string s, out float? val)
|
||||
{ val = null; if (s.Length < 1) return false; uint d = 0; if (s[0] == '-') d = 0x80000000;
|
||||
bool b = float.TryParse(s.Replace(".", NDS), out float t); if (b) val = (d | t.ToU32()).ToF32(); return b; }
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct ENRS : INull
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct POF : INull
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib.F2
|
||||
namespace KKdBaseLib.F2
|
||||
{
|
||||
public struct Struct
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public enum Format : byte
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public interface IKF
|
||||
{
|
||||
|
||||
@@ -1,39 +1,53 @@
|
||||
using KKdBaseLib.A3DA;
|
||||
using KKdBaseLib.Auth3D;
|
||||
|
||||
namespace KKdBaseLib.Interpolation
|
||||
{
|
||||
public struct A3DAI //A3DA Interpolation
|
||||
public class A3DAI : IInterpolation<float> //A3DA Interpolation
|
||||
{
|
||||
private A3DAKey key;
|
||||
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 => key.Keys == null ? true : key.Length < 1;
|
||||
public bool NotNull => key.Keys == null ? false : key.Length > 0;
|
||||
public float Time => t;
|
||||
public float Value => v;
|
||||
public bool IsNull => a3daKey.Keys == null ? true : a3daKey.Length < 1;
|
||||
public bool NotNull => a3daKey.Keys == null ? false : a3daKey.Length > 0;
|
||||
|
||||
public A3DAI(A3DAKey key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
public A3DAI(Key key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
this.key = key; last = rf = @if = 0;
|
||||
f = -1; df = 1;
|
||||
a3daKey = (A3DAKey)key; f = -1; df = @if = rf = t = v = 0;
|
||||
@if = a3daFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
f = -df;
|
||||
ResetFrameCount();
|
||||
|
||||
if (key.Keys != null && key.Length > 0)
|
||||
{
|
||||
firstKey = key.Keys[0];
|
||||
lastKey = key.Keys[key.Length - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public A3DAI(A3DAKey key, float a3daFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
t = 0;
|
||||
a3daKey = key; f = -1; df = v = rf = @if = 0;
|
||||
@if = a3daFramerate;
|
||||
firstKey = lastKey = default;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
f = -df;
|
||||
ResetFrameCount();
|
||||
|
||||
if (key.Keys != null && key.Length > 0)
|
||||
@@ -45,46 +59,54 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
public float SetTime(float time)
|
||||
{
|
||||
if ((int)key.Type < 1 || (int)key.Type > 4 || key.Length < 1) return 0;
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
|
||||
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)key.Type < 1 || (int)key.Type > 4 || key.Length < 1) return 0;
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
|
||||
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)key.Type < 1 || (int)key.Type > 4 || key.Length < 1) return 0;
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
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)key.Type < 1 || (int)key.Type > 4 || key.Length < 1) return 0;
|
||||
if ((int)key.Type == 1) return key.Keys[0].V;
|
||||
|
||||
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)
|
||||
@@ -95,88 +117,84 @@ namespace KKdBaseLib.Interpolation
|
||||
|
||||
if (f < firstKey.F)
|
||||
{
|
||||
if (key.EPTypePost < EPType.EP_1 || key.EPTypePost > EPType.EP_3)
|
||||
return firstKey.V;
|
||||
if (a3daKey.EPTypePost < EPType.EP_1 || a3daKey.EPTypePost > EPType.EP_3) return firstKey.V;
|
||||
|
||||
df = firstKey.F - frame;
|
||||
if (key.EPTypePre == EPType.EP_1)
|
||||
return firstKey.V - df * firstKey.T1;
|
||||
else if (key.EPTypePre == EPType.EP_2 || key.EPTypePre == EPType.EP_3)
|
||||
if (a3daKey.EPTypePre == EPType.EP_1) return firstKey.V - df * firstKey.T1;
|
||||
|
||||
frame = lastKey.F - df % a3daKey.FrameDelta;
|
||||
f = (int)frame;
|
||||
if (a3daKey.EPTypePre == EPType.EP_3)
|
||||
{
|
||||
frame = lastKey.F - df % key.FrameDelta;
|
||||
f = (int)frame;
|
||||
ep = df / a3daKey.FrameDelta;
|
||||
ep = (ep > 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = -(ep + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
}
|
||||
else if (f >= lastKey.F)
|
||||
{
|
||||
if (key.EPTypePost < EPType.EP_1 || key.EPTypePost > EPType.EP_3)
|
||||
return lastKey.V;
|
||||
if (a3daKey.EPTypePost < EPType.EP_1 || a3daKey.EPTypePost > EPType.EP_3) return lastKey.V;
|
||||
|
||||
df = frame - lastKey.F;
|
||||
if (key.EPTypePost == EPType.EP_1)
|
||||
return lastKey.V + df * lastKey.T2;
|
||||
else if (key.EPTypePost == EPType.EP_2 || key.EPTypePost == EPType.EP_3)
|
||||
if (a3daKey.EPTypePost == EPType.EP_1) return lastKey.V + df * lastKey.T2;
|
||||
|
||||
frame = firstKey.F + df % a3daKey.FrameDelta;
|
||||
f = (int)frame;
|
||||
if (a3daKey.EPTypePost == EPType.EP_3)
|
||||
{
|
||||
frame = firstKey.F + df % key.FrameDelta;
|
||||
f = (int)frame;
|
||||
ep = df / a3daKey.FrameDelta;
|
||||
ep = (ep > 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = (ep + 1) * a3daKey.ValueDelta;
|
||||
}
|
||||
}
|
||||
|
||||
if ((f < firstKey.F && key.EPTypePre == EPType.EP_3) ||
|
||||
(f >= firstKey.F && key.EPTypePost == EPType.EP_3))
|
||||
{
|
||||
ep = df / key.FrameDelta;
|
||||
ep = (ep >= 0 && ep != (int)ep) ? (ep - (int)ep > 0 ? 1 : 0) : ep;
|
||||
ep = (f < firstKey.F ? -1 : 1) * (ep + 1) * key.ValueDelta;
|
||||
}
|
||||
if (f <= firstKey.F) return firstKey.V + ep;
|
||||
else if (f >= lastKey.F) return lastKey.V + ep;
|
||||
|
||||
if (f <= firstKey.F)
|
||||
return firstKey.V + ep;
|
||||
else if (f >= lastKey.F)
|
||||
return lastKey.V + ep;
|
||||
|
||||
int data = 0;
|
||||
int length = key.Length;
|
||||
int tempLength;
|
||||
while (length > 0)
|
||||
KFT3 c, n;
|
||||
unsafe
|
||||
{
|
||||
tempLength = length >> 1;
|
||||
if (f <= key.Keys[data + tempLength].F)
|
||||
length = tempLength;
|
||||
else
|
||||
fixed (KFT3* ptr = a3daKey.Keys)
|
||||
{
|
||||
data += tempLength + 1;
|
||||
length -= tempLength + 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];
|
||||
}
|
||||
}
|
||||
|
||||
ref KFT3 c = ref key.Keys[data - 1];
|
||||
ref KFT3 n = ref key.Keys[data];
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
{
|
||||
if (key.Type == KeyType.Lerp)
|
||||
if (a3daKey.Type == KeyType.Lerp)
|
||||
{
|
||||
float t = (frame - c.F) / (n.F - c.F);
|
||||
result = (1 - t) * c.V + t * n.V;
|
||||
}
|
||||
else if (key.Type == KeyType.Hermite)
|
||||
else if (a3daKey.Type == KeyType.Hermite)
|
||||
{
|
||||
float t = (frame - c.F) / (n.F - c.F);
|
||||
float t_2 = (1 - t) * (1 - t);
|
||||
result = t_2 * c.V * (1 + 2 * t) + (t * n.V * (3 - 2 * t) +
|
||||
(t_2 * c.T2 + t * (t - 1) * n.T1) * (n.F - c.F)) * t;
|
||||
}
|
||||
else
|
||||
result = c.V;
|
||||
else result = c.V;
|
||||
}
|
||||
else
|
||||
result = frame > c.F ? n.V : c.V;
|
||||
else result = frame > c.F ? n.V : c.V;
|
||||
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,123 +1,132 @@
|
||||
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 deltaFrame;
|
||||
private float t;
|
||||
private float v;
|
||||
private float df;
|
||||
private float @if;
|
||||
private float rf;
|
||||
private float lastTime;
|
||||
|
||||
private KFT2 firstKey;
|
||||
private KFT2 lastKey;
|
||||
private KFT2 lastKey;
|
||||
|
||||
public float InterpolationFramerate
|
||||
{ get => @if; set { @if = value; deltaFrame = @if / rf; } }
|
||||
public float RequestedFramerate
|
||||
{ get => rf; set { rf = value; deltaFrame = @if / rf; } }
|
||||
public float RequestedFramerate { get => rf; set { rf = value; df = @if / rf; } }
|
||||
|
||||
public float Frame => f;
|
||||
public float Value => last;
|
||||
public float Time => t;
|
||||
public float Value => v;
|
||||
public bool IsNull => array == null ? true : array.Length < 1;
|
||||
public bool NotNull => array == null ? false : array.Length > 0;
|
||||
|
||||
public PDI(KFT2[] Array, float InterpolationFramerate = 60, float RequestedFramerate = 60)
|
||||
public PDI(KFT2[] array, float interpolationFramerate = 60, float requestedFramerate = 60)
|
||||
{
|
||||
lastTime = 0;
|
||||
this.array = Array; f = -1; deltaFrame = last = rf = @if = 0;
|
||||
@if = InterpolationFramerate;
|
||||
length = 0;
|
||||
this.array = array; f = -1; df = @if = rf = t = v = 0;
|
||||
@if = interpolationFramerate;
|
||||
firstKey = lastKey = default;
|
||||
this.RequestedFramerate = RequestedFramerate;
|
||||
f = -deltaFrame;
|
||||
RequestedFramerate = requestedFramerate;
|
||||
f = -df;
|
||||
ResetFrameCount();
|
||||
|
||||
if (Array != null && Array.Length > 0)
|
||||
if (array != null && array.Length > 0)
|
||||
{
|
||||
firstKey = Array[0];
|
||||
lastKey = Array[Array.Length - 1];
|
||||
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;
|
||||
t = frame / rf;
|
||||
f = frame * df;
|
||||
|
||||
lastTime = frame / rf;
|
||||
f = frame * deltaFrame;
|
||||
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;
|
||||
t = f / @if;
|
||||
|
||||
f += deltaFrame;
|
||||
lastTime = f / @if;
|
||||
last = Interpolate(f);
|
||||
return last;
|
||||
if (array == null || length < 1) v = 0.0f;
|
||||
else v = Interpolate(f);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private float Interpolate(float frame)
|
||||
{
|
||||
float f = (int)frame;
|
||||
|
||||
int data = 0;
|
||||
int length = array.Length;
|
||||
while (length > 0)
|
||||
if (f <= array[data + (length >> 1)].F)
|
||||
length >>= 1;
|
||||
else
|
||||
{
|
||||
int delta = (length >> 1) + 1;
|
||||
data += delta;
|
||||
length -= delta;
|
||||
}
|
||||
if (f <= firstKey.F) return firstKey.V;
|
||||
else if (f >= lastKey.F) return lastKey.V;
|
||||
|
||||
if (data == 0)
|
||||
return firstKey.V;
|
||||
else if (data >= array.Length)
|
||||
return lastKey.V;
|
||||
|
||||
KFT2 c = array[data - 1];
|
||||
KFT2 n = array[data];
|
||||
float result = c.F == n.F ? c.V : n.V;
|
||||
if (frame < n.F)
|
||||
KFT2 c, n;
|
||||
unsafe
|
||||
{
|
||||
fixed (KFT2* ptr = array)
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
float result;
|
||||
if (frame > c.F && frame < n.F)
|
||||
{
|
||||
float t = (this.f - c.F) / (n.F - c.F);
|
||||
float t_1 = t - 1;
|
||||
result = (t_1 * 2 - 1) * (c.V - n.V) * t * t +
|
||||
(t_1 * c.T + t * n.T) * t_1 * (this.f - c.F) + c.V;
|
||||
}
|
||||
else result = frame > c.F ? n.V : c.V;
|
||||
return result;
|
||||
}
|
||||
|
||||
public void ResetFrameCount() { f = -df; t = f / rf; }
|
||||
|
||||
public void ResetFrameCount() => f = -deltaFrame;
|
||||
|
||||
public override string ToString() => $"Frame: {f}, Value: {last}";
|
||||
public override string ToString() => $"F: {f}; T: {t}; V: {v}";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KFT0 : IKF
|
||||
{
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019</Copyright>
|
||||
<Copyright>korenkonder © 2019-2020</Copyright>
|
||||
<Description>A base library</Description>
|
||||
<FileVersion>0.4.8.1</FileVersion>
|
||||
<FileVersion>0.4.9.2</FileVersion>
|
||||
<PackageId>KKdBaseLib</PackageId>
|
||||
<Product>KKdBaseLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdBaseLib</Title>
|
||||
<Version>0.4.8.1</Version>
|
||||
<Version>0.4.9.2</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
+104
-79
@@ -1,34 +1,35 @@
|
||||
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> 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 };
|
||||
new KKdDict<TKey, TValue>() { count = 0, Capacity = Capacity };
|
||||
|
||||
private int count;
|
||||
private int index;
|
||||
private TKey [] keyArray;
|
||||
private TValue[] valArray;
|
||||
|
||||
public int Count { get; private set; }
|
||||
public int Count => count;
|
||||
|
||||
public bool IsNull => keyArray == null || valArray == null;
|
||||
public bool NotNull => keyArray != null && valArray != null;
|
||||
|
||||
public int Capacity { get => keyArray != null && valArray != null ? valArray.Length : -1;
|
||||
set { if (keyArray != null) System.Array.Resize(ref keyArray, value); else keyArray = new TKey [value];
|
||||
if (valArray != null) System.Array.Resize(ref valArray, value); else valArray = new TValue[value];
|
||||
if (Count >= value) Count = value; } }
|
||||
set { if (keyArray != null) System.Array.Resize(ref keyArray, value); else keyArray = new TKey [value];
|
||||
if (valArray != null) System.Array.Resize(ref valArray, value); else valArray = new TValue[value];
|
||||
if (count >= value) count = value; } }
|
||||
|
||||
|
||||
public KKdDict(TKey[] keyArray, TValue[] valArray)
|
||||
{
|
||||
this.keyArray = null; this.valArray = null; Count = 0; index = 0;
|
||||
this.keyArray = null; this.valArray = null; count = 0; index = 0;
|
||||
if (keyArray == null || valArray == null || keyArray.Length != valArray.Length) return;
|
||||
Count = valArray.Length; this.keyArray = keyArray; this.valArray = valArray; }
|
||||
count = valArray.Length; this.keyArray = keyArray; this.valArray = valArray; }
|
||||
|
||||
public KeyValuePair<TKey, TValue> Current => index < Count ?
|
||||
public KeyValuePair<TKey, TValue> Current => index < count ?
|
||||
new KeyValuePair<TKey, TValue>(keyArray[index], valArray[index]) : default;
|
||||
|
||||
object System.Collections.IEnumerator.Current => Current;
|
||||
@@ -48,18 +49,25 @@
|
||||
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 && ContainsKey(key) ? valArray[IndexOf(key)] : default;
|
||||
set { if (valArray != null && valArray.Length > 0 && ContainsKey(key)) valArray[IndexOf(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; }
|
||||
{ if (index == count - 1) { index = 0; return false; }
|
||||
else { index++ ; return true; } }
|
||||
|
||||
|
||||
public System.Collections.IEnumerator GetEnumerator() => this;
|
||||
|
||||
public void Dispose() { valArray = null; Count = 0; index = 0; }
|
||||
public void Dispose() { keyArray = null; valArray = null; count = 0; index = 0; }
|
||||
|
||||
public void Reset() => index = 0;
|
||||
|
||||
@@ -67,22 +75,22 @@
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
Count++;
|
||||
if (keyArray.Length < Count) System.Array.Resize(ref keyArray, Count);
|
||||
if (valArray.Length < Count) System.Array.Resize(ref valArray, Count);
|
||||
keyArray[Count - 1] = pair.Key;
|
||||
valArray[Count - 1] = pair.Value;
|
||||
count++;
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, count);
|
||||
keyArray[count - 1] = pair.Key;
|
||||
valArray[count - 1] = pair.Value;
|
||||
}
|
||||
|
||||
public void Add(TKey key, TValue val)
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
Count++;
|
||||
if (keyArray.Length < Count) System.Array.Resize(ref keyArray, Count);
|
||||
if (valArray.Length < Count) System.Array.Resize(ref valArray, Count);
|
||||
keyArray[Count - 1] = key;
|
||||
valArray[Count - 1] = val;
|
||||
count++;
|
||||
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
|
||||
if (valArray.Length < count) System.Array.Resize(ref valArray, count);
|
||||
keyArray[count - 1] = key;
|
||||
valArray[count - 1] = val;
|
||||
}
|
||||
|
||||
public bool RemoveKey(TKey key)
|
||||
@@ -92,12 +100,10 @@
|
||||
int index = IndexOf(key);
|
||||
if (index == -1) return false;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
}
|
||||
Count--;
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -108,96 +114,112 @@
|
||||
int index = IndexOf(val);
|
||||
if (index == -1) return false;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
|
||||
}
|
||||
Count--;
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
count--;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IsNull || index < 0 || index >= count) return;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
{
|
||||
keyArray[i - 1] = keyArray[i];
|
||||
valArray[i - 1] = valArray[i];
|
||||
}
|
||||
Count--;
|
||||
if (index + 1 < count)
|
||||
{ System.Array.Copy(keyArray, index + 1, keyArray, index, count - index);
|
||||
System.Array.Copy(valArray, index + 1, valArray, index, count - index); }
|
||||
count--;
|
||||
}
|
||||
|
||||
public void RemoveRange(int IndexStart, int IndexEnd)
|
||||
public void RemoveRange(int indexStart, int indexEnd)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
int indexcount = indexEnd - indexStart;
|
||||
if (IsNull || indexcount < 1 || indexStart < 0 || indexEnd > count) return;
|
||||
|
||||
if (IndexEnd - IndexStart != Count)
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
{
|
||||
keyArray[i] = keyArray[i + IndexEnd - IndexStart];
|
||||
valArray[i] = valArray[i + IndexEnd - IndexStart];
|
||||
}
|
||||
Count -= IndexEnd - IndexStart;
|
||||
if ((indexEnd + indexcount) < count)
|
||||
{ System.Array.Copy(keyArray, indexEnd, keyArray, indexStart, indexcount);
|
||||
System.Array.Copy(valArray, indexEnd, valArray, indexStart, indexcount); }
|
||||
count -= indexcount;
|
||||
}
|
||||
|
||||
public TValue[] ToArray() => valArray;
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
public bool ContainsKey (TKey key) => CK(key, out int index);
|
||||
public bool ContainsValue(TValue val) => CV(val, out int index);
|
||||
public bool Contains (KeyValuePair<TKey, TValue> pair) => C(pair, out int index);
|
||||
|
||||
public bool ContainsKey (TKey key, out int index) => CK(key, out index);
|
||||
public bool ContainsValue(TValue val, out int index) => CV(val, out index);
|
||||
public bool Contains (KeyValuePair<TKey, TValue> pair, out int index) => C(pair, out index);
|
||||
|
||||
private bool CK(TKey key, out int index)
|
||||
{
|
||||
index = -1;
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (keyArray[i] == null && key == null) return true;
|
||||
else if (keyArray[i] == null || key == null) continue;
|
||||
else if (keyArray[i] .Equals(key) ) return true;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (keyArray[i] == null && key == null) { index = i; return true; }
|
||||
else if (keyArray[i] == null || key == null) continue;
|
||||
else if (keyArray[i].Equals(key)) { index = i; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool ContainsValue(TValue val)
|
||||
private bool CV(TValue val, out int index)
|
||||
{
|
||||
index = -1;
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (valArray[i] == null && val == null) return true;
|
||||
else if (valArray[i] == null || val == null) continue;
|
||||
else if (valArray[i] .Equals(val) ) return true;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (valArray[i] == null && val == null) { index = i; return true; }
|
||||
else if (valArray[i] == null || val == null) continue;
|
||||
else if (valArray[i].Equals(val)) { index = i; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<TKey, TValue> pair)
|
||||
private bool C(KeyValuePair<TKey, TValue> pair, out int index)
|
||||
{
|
||||
index = -1;
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if ( keyArray[i] == null && pair.Key == null &&
|
||||
valArray[i] == null && pair.Value == null ) return true;
|
||||
else if ((keyArray[i] == null || pair.Key == null) &&
|
||||
(valArray[i] == null || pair.Value == null)) continue;
|
||||
else if ( keyArray[i] .Equals(pair.Key) &&
|
||||
valArray[i] .Equals(pair.Value) ) return true;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (keyArray[i] == null && pair.Key == null &&
|
||||
valArray[i] == null && pair.Value == null) { index = i; return true; }
|
||||
else if ((keyArray[i] == null || pair.Key == null) &&
|
||||
(valArray[i] == null || pair.Value == null)) continue;
|
||||
else if (keyArray[i].Equals(pair.Key ) &&
|
||||
valArray[i].Equals(pair.Value)) { index = i; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
public TKey GetKey(TValue val)
|
||||
{
|
||||
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];
|
||||
return default;
|
||||
}
|
||||
|
||||
private int IndexOf(TKey key)
|
||||
{
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
if (keyArray[i] == null && key == null) return i;
|
||||
else if (keyArray[i] == null || key == null) continue;
|
||||
else if (keyArray[i] .Equals(key) ) return i;
|
||||
else if (keyArray[i].Equals(key)) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int IndexOf(TValue val)
|
||||
{
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
if (keyArray[i] == null && val == null) return i;
|
||||
else if (keyArray[i] == null || val == null) continue;
|
||||
else if (keyArray[i] .Equals(val) ) return i;
|
||||
for (int i = 0; i < count; i++)
|
||||
if (valArray[i] == null && val == null) return i;
|
||||
else if (valArray[i] == null || val == null) continue;
|
||||
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>
|
||||
@@ -207,5 +229,8 @@
|
||||
|
||||
public KeyValuePair(TKey key, TValue value)
|
||||
{ Key = key; Value = value; }
|
||||
|
||||
public override string ToString() =>
|
||||
$"(Key: {Key}; value: {Value})";
|
||||
}
|
||||
}
|
||||
|
||||
+79
-43
@@ -1,33 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct KKdList<T> : System.IDisposable, IEnumerator, IEnumerable, INull
|
||||
public struct KKdList<T> : System.IDisposable, IEnumerable<T>, IEnumerable, IEnumerator, INull
|
||||
{
|
||||
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> New => new KKdList<T>() { count = 0, Capacity = 0 };
|
||||
public static KKdList<T> NewReserve(int Capacity) => new KKdList<T>() { count = 0, Capacity = Capacity };
|
||||
|
||||
private int count;
|
||||
private int index;
|
||||
private T[] array;
|
||||
|
||||
public int Count { get; private set; }
|
||||
private Enumerator enumerator;
|
||||
|
||||
public int Count => count;
|
||||
|
||||
public bool IsNull => array == null;
|
||||
public bool NotNull => array != null;
|
||||
|
||||
public int Capacity { get => array != null ? array.Length : -1;
|
||||
set { if (array != null) System.Array.Resize(ref array, value); else array = new T[value];
|
||||
if (Count >= value) Count = value; } }
|
||||
set { if (array != null) System.Array.Resize(ref array, value); else array = new T[value];
|
||||
if (Count >= value) count = value; } }
|
||||
|
||||
|
||||
public KKdList(T[] Array)
|
||||
{ index = 0; Count = Array.Length; array = Array; }
|
||||
public KKdList(T[] array)
|
||||
{ index = -1; count = array.Length; this.array = array; enumerator = new Enumerator(this.array); }
|
||||
|
||||
public T Current => index < Count ? array[index] : default;
|
||||
public T Current => index > -1 && index < Count ? array[index] : default;
|
||||
|
||||
object IEnumerator.Current => Current;
|
||||
object IEnumerator.Current => enumerator.Current;
|
||||
|
||||
public bool MoveNext() => enumerator.MoveNext();
|
||||
public void Reset() => enumerator.Reset();
|
||||
|
||||
public T this[ int index]
|
||||
{ get => array != null && index > -1 && index < array.Length ? array[index] : default;
|
||||
@@ -37,44 +43,45 @@ namespace KKdBaseLib
|
||||
{ get => array != null && index < array.Length ? array[index] : default;
|
||||
set { if (array != null && index < array.Length) array[index] = value; } }
|
||||
|
||||
public bool MoveNext()
|
||||
{ if (index == Count - 1) { index = 0; return false; }
|
||||
else { index++ ; return true; } }
|
||||
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() => this;
|
||||
public IEnumerator GetEnumerator() => enumerator = new Enumerator(array);
|
||||
|
||||
public void Dispose() { array = null; Count = 0; index = 0; }
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => enumerator = new Enumerator(array);
|
||||
|
||||
public void Reset() => index = 0;
|
||||
IEnumerator IEnumerable.GetEnumerator() => enumerator = new Enumerator(array);
|
||||
|
||||
public void Dispose() { array = null; count = 0; index = -1; }
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
if (IsNull) return;
|
||||
|
||||
Count++;
|
||||
if (array.Length < Count)
|
||||
System.Array.Resize(ref array, Count);
|
||||
array[Count - 1] = item;
|
||||
count++;
|
||||
if (array.Length < count)
|
||||
System.Array.Resize(ref array, count);
|
||||
array[count - 1] = item;
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IsNull || index < 0 || index >= count) return;
|
||||
|
||||
for (int i = index + 1; i < Count; i++)
|
||||
array[i - 1] = array[i];
|
||||
Count--;
|
||||
if (index + 1 < count)
|
||||
System.Array.Copy(array, index + 1, array, index, count - index);
|
||||
count--;
|
||||
}
|
||||
|
||||
public void RemoveRange(int IndexStart, int IndexEnd)
|
||||
public void RemoveRange(int indexStart, int indexEnd)
|
||||
{
|
||||
if (IsNull) return;
|
||||
if (IndexEnd - IndexStart < 1) return;
|
||||
int indexCount = indexEnd - indexStart;
|
||||
if (IsNull || indexCount < 1 || indexStart < 0 || indexEnd > count) return;
|
||||
|
||||
if (IndexEnd - IndexStart != Count)
|
||||
for (int i = IndexStart; i < Count; i++)
|
||||
array[i] = array[i + IndexEnd - IndexStart];
|
||||
Count -= IndexEnd - IndexStart;
|
||||
if ((indexEnd + indexCount) < count)
|
||||
System.Array.Copy(array, indexEnd, array, indexStart, indexCount);
|
||||
count -= indexCount;
|
||||
}
|
||||
|
||||
public T[] ToArray() => array;
|
||||
@@ -82,34 +89,63 @@ namespace KKdBaseLib
|
||||
public bool Contains(T val)
|
||||
{
|
||||
if (IsNull) return false;
|
||||
for (int i = 0; i < Count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
if (array[i] == null && val == null) return true;
|
||||
else if (array[i] == null || val == null) continue;
|
||||
else if (array[i] .Equals(val) ) return true;
|
||||
else if (array[i].Equals(val)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int IndexOf(T val)
|
||||
{
|
||||
if (IsNull) return -1;
|
||||
for (int i = 0; i < Count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
if (array[i] == null && val == null) return i;
|
||||
else if (array[i] == null || val == null) continue;
|
||||
else if (array[i] .Equals(val) ) return i;
|
||||
else if (array[i].Equals(val)) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{ List<T> List = (List<T>)this; List.Sort(); array = List.ToArray(); Count = List.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 KKdList<T>( List<T> list) =>
|
||||
new KKdList<T> { array = list.ToArray(), count = list.Count };
|
||||
|
||||
public static explicit operator List<T>(KKdList<T> List)
|
||||
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; }
|
||||
|
||||
public override string ToString() =>
|
||||
$"(Count: {Count}; Capacity: {Capacity}; Current: {Current})";
|
||||
|
||||
public struct Enumerator : IEnumerator<T>, IEnumerator
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
for (int i = 0; i < List.Count; i++) list.Add(List[i]);
|
||||
return list;
|
||||
private T[] array;
|
||||
private int index;
|
||||
private int count;
|
||||
private T current;
|
||||
|
||||
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; }
|
||||
else { current = default; index = count + 1; return false; }
|
||||
}
|
||||
|
||||
public T Current => current;
|
||||
|
||||
object IEnumerator.Current =>
|
||||
(index == 0 || index == array.Length + 1) ? default : current;
|
||||
|
||||
void IEnumerator.Reset() => Reset();
|
||||
|
||||
public void Reset() { index = 0; current = default; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++)
|
||||
(inverse[irow, k], inverse[icol, k]) = (inverse[icol, k], inverse[irow, k]);
|
||||
|
||||
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++)
|
||||
(inverse[k, ic], inverse[k, ir]) = (inverse[k, ir], inverse[k, ic]);
|
||||
}
|
||||
|
||||
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++)
|
||||
(inverse[irow, k], inverse[icol, k]) = (inverse[icol, k], inverse[irow, k]);
|
||||
|
||||
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++)
|
||||
(inverse[k, ic], inverse[k, ir]) = (inverse[k, ir], inverse[k, ic]);
|
||||
}
|
||||
|
||||
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,261 @@
|
||||
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; }
|
||||
|
||||
public Mat4(QuatTrans qt)
|
||||
{ Row0 = Row1 = Row2 = Row3 = default; FromQuat(qt.Quat); Row3 = new Vec4(qt.Trans, 1.0f); }
|
||||
|
||||
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++)
|
||||
(inverse[irow, k], inverse[icol, k]) = (inverse[icol, k], inverse[irow, k]);
|
||||
|
||||
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 f = inverse[k, ir];
|
||||
inverse[k, ir] = inverse[k, ic];
|
||||
inverse[k, ic] = f;
|
||||
}
|
||||
}
|
||||
|
||||
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)})";
|
||||
}
|
||||
}
|
||||
+105
-74
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
@@ -11,20 +11,20 @@ namespace KKdBaseLib
|
||||
public KKdList<MsgPack> List => Object is KKdList<MsgPack> List ? List : default;
|
||||
|
||||
public static MsgPack New => new MsgPack { Object = KKdList<MsgPack>.New };
|
||||
public static MsgPack NewReserve(int Capacity) =>
|
||||
new MsgPack { Object = KKdList<MsgPack>.NewReserve(Capacity) };
|
||||
public static MsgPack NewReserve(int capacity) =>
|
||||
new MsgPack { Object = KKdList<MsgPack>.NewReserve(capacity) };
|
||||
|
||||
public bool IsNull => Array == null && List. IsNull;
|
||||
public bool NotNull => Array != null || List.NotNull;
|
||||
|
||||
public MsgPack( string Name = null)
|
||||
{ Object = KKdList<MsgPack>.New; this.Name = Name; }
|
||||
public MsgPack( string name = null)
|
||||
{ Object = KKdList<MsgPack>.New; Name = name; }
|
||||
|
||||
public MsgPack(long Count, string Name = null)
|
||||
{ Object = Count > 0 ? new MsgPack[Count] : null; this.Name = Name; }
|
||||
public MsgPack(long count, string name = null)
|
||||
{ Object = count > -1 ? new MsgPack[count] : null; this.Name = name; }
|
||||
|
||||
public MsgPack(string Name, object Object)
|
||||
{ this.Name = Name; this.Object = Object; }
|
||||
public MsgPack(string name, object @object)
|
||||
{ Name = name; Object = @object; }
|
||||
|
||||
public static MsgPack Null => new MsgPack();
|
||||
|
||||
@@ -36,8 +36,14 @@ 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; }
|
||||
{ get => Object is KKdList<MsgPack> List ? List[ElementIndex(key)] : default;
|
||||
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];
|
||||
@@ -96,80 +102,105 @@ namespace KKdBaseLib
|
||||
public MsgPack Add( float val) => Add(new MsgPack(null, val));
|
||||
public MsgPack Add(double val) => Add(new MsgPack(null, val));
|
||||
|
||||
public MsgPack Add(string Val, bool? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, sbyte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, byte? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, short? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, ushort? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, int? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, uint? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, long? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, ulong? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, float? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Val, double? val) => val.HasValue ? Add(Val, val.Value) : this;
|
||||
public MsgPack Add(string Name, bool? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, sbyte? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, byte? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, short? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, ushort? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, int? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, uint? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, long? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, ulong? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, float? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
public MsgPack Add(string Name, double? val) => val.HasValue ? Add(Name, val.Value) : this;
|
||||
|
||||
public MsgPack Add(string Val, byte[] val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, string val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, bool val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, sbyte val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, byte val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, short val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, ushort val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, int val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, uint val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, long val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, ulong val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, float val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Val, double val) => Add(new MsgPack(Val, val));
|
||||
public MsgPack Add(string Name, byte[] val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, string val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, bool val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, sbyte val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, byte val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, short val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, ushort val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, int val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, uint val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, long val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, ulong val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, float val) => Add(new MsgPack(Name, val));
|
||||
public MsgPack Add(string Name, double val) => Add(new MsgPack(Name, val));
|
||||
|
||||
public bool RB (string Name) => RnB (Name) ?? default;
|
||||
public sbyte RI8 (string Name) => RnI8 (Name) ?? default;
|
||||
public byte RU8 (string Name) => RnU8 (Name) ?? default;
|
||||
public short RI16(string Name) => RnI16(Name) ?? default;
|
||||
public ushort RU16(string Name) => RnU16(Name) ?? default;
|
||||
public int RI32(string Name) => RnI32(Name) ?? default;
|
||||
public uint RU32(string Name) => RnU32(Name) ?? default;
|
||||
public long RI64(string Name) => RnI64(Name) ?? default;
|
||||
public ulong RU64(string Name) => RnU64(Name) ?? default;
|
||||
public float RF32(string Name) => RnF32(Name) ?? default;
|
||||
public double RF64(string Name) => RnF64(Name) ?? default;
|
||||
public bool RB (string name) => RnB (name) ?? default;
|
||||
public sbyte RI8 (string name) => RnI8 (name) ?? default;
|
||||
public byte RU8 (string name) => RnU8 (name) ?? default;
|
||||
public short RI16(string name) => RnI16(name) ?? default;
|
||||
public ushort RU16(string name) => RnU16(name) ?? default;
|
||||
public int RI32(string name) => RnI32(name) ?? default;
|
||||
public uint RU32(string name) => RnU32(name) ?? default;
|
||||
public long RI64(string name) => RnI64(name) ?? default;
|
||||
public ulong RU64(string name) => RnU64(name) ?? default;
|
||||
public float RF32(string name) => RnF32(name) ?? default;
|
||||
public double RF64(string name) => RnF64(name) ?? default;
|
||||
|
||||
public bool? RnB (string Name)
|
||||
public void R(string name, out bool? val) { val = RnB (name); }
|
||||
public void R(string name, out sbyte? val) { val = RnI8 (name); }
|
||||
public void R(string name, out byte? val) { val = RnU8 (name); }
|
||||
public void R(string name, out short? val) { val = RnI16(name); }
|
||||
public void R(string name, out ushort? val) { val = RnU16(name); }
|
||||
public void R(string name, out int? val) { val = RnI32(name); }
|
||||
public void R(string name, out uint? val) { val = RnU32(name); }
|
||||
public void R(string name, out long? val) { val = RnI64(name); }
|
||||
public void R(string name, out ulong? val) { val = RnU64(name); }
|
||||
public void R(string name, out float? val) { val = RnF32(name); }
|
||||
public void R(string name, out double? val) { val = RnF64(name); }
|
||||
|
||||
public void R(string name, out bool val) { val = RB (name); }
|
||||
public void R(string name, out sbyte val) { val = RI8 (name); }
|
||||
public void R(string name, out byte val) { val = RU8 (name); }
|
||||
public void R(string name, out short val) { val = RI16(name); }
|
||||
public void R(string name, out ushort val) { val = RU16(name); }
|
||||
public void R(string name, out int val) { val = RI32(name); }
|
||||
public void R(string name, out uint val) { val = RU32(name); }
|
||||
public void R(string name, out long val) { val = RI64(name); }
|
||||
public void R(string name, out ulong val) { val = RU64(name); }
|
||||
public void R(string name, out float val) { val = RF32(name); }
|
||||
public void R(string name, out double val) { val = RF64(name); }
|
||||
public void R(string name, out string val) { val = RS (name); }
|
||||
|
||||
public bool? RnB (string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is bool B ) return B ; return null;
|
||||
}
|
||||
public sbyte? RnI8 (string Name)
|
||||
public sbyte? RnI8 (string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return ( sbyte)U8 ; return null;
|
||||
}
|
||||
public byte? RnU8 (string Name)
|
||||
public byte? RnU8 (string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return ( byte)I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ; return null;
|
||||
}
|
||||
public short? RnI16(string Name)
|
||||
public short? RnI16(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return I16;
|
||||
else if (MsgPack.Object is ushort U16) return ( short)U16; return null;
|
||||
}
|
||||
public ushort? RnU16(string Name)
|
||||
public ushort? RnU16(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return (ushort)I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return (ushort)I16;
|
||||
else if (MsgPack.Object is ushort U16) return U16; return null;
|
||||
}
|
||||
public int? RnI32(string Name)
|
||||
public int? RnI32(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return I16;
|
||||
@@ -177,9 +208,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is int I32) return I32;
|
||||
else if (MsgPack.Object is uint U32) return ( int)U32; return null;
|
||||
}
|
||||
public uint? RnU32(string Name)
|
||||
public uint? RnU32(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return ( uint)I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return ( uint)I16;
|
||||
@@ -187,9 +218,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is int I32) return ( uint)I32;
|
||||
else if (MsgPack.Object is uint U32) return U32; return null;
|
||||
}
|
||||
public long? RnI64(string Name)
|
||||
public long? RnI64(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return I16;
|
||||
@@ -199,9 +230,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is long I64) return I64;
|
||||
else if (MsgPack.Object is ulong U64) return ( long)U64; return null;
|
||||
}
|
||||
public ulong? RnU64(string Name)
|
||||
public ulong? RnU64(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return ( ulong)I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return ( ulong)I16;
|
||||
@@ -210,9 +241,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is uint U32) return U32;
|
||||
else if (MsgPack.Object is long I64) return ( ulong)I64; return null;
|
||||
}
|
||||
public float? RnF32(string Name)
|
||||
public float? RnF32(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return I16;
|
||||
@@ -223,9 +254,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is float F32) return F32;
|
||||
else if (MsgPack.Object is double F64) return ( float)F64; return null;
|
||||
}
|
||||
public double? RnF64(string Name)
|
||||
public double? RnF64(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is sbyte I8 ) return I8 ;
|
||||
else if (MsgPack.Object is byte U8 ) return U8 ;
|
||||
else if (MsgPack.Object is short I16) return I16;
|
||||
@@ -236,9 +267,9 @@ namespace KKdBaseLib
|
||||
else if (MsgPack.Object is float F32) return F32;
|
||||
else if (MsgPack.Object is double F64) return F64; return null;
|
||||
}
|
||||
public string RS(string Name)
|
||||
public string RS(string name)
|
||||
{
|
||||
MsgPack MsgPack = this[Name];
|
||||
MsgPack MsgPack = this[name];
|
||||
if (MsgPack.Object is string S ) return S ; return null;
|
||||
}
|
||||
|
||||
@@ -326,23 +357,23 @@ namespace KKdBaseLib
|
||||
public string RS ()
|
||||
{ if (Object is string S ) return S ; return null; }
|
||||
|
||||
public MsgPack Element(string Name)
|
||||
public MsgPack Element(string name)
|
||||
{
|
||||
if (List.IsNull) return default;
|
||||
|
||||
for (int i = 0; i < List.Count; i++)
|
||||
if (List[i].Name == Name) return List[i];
|
||||
if (List[i].Name == name) return List[i];
|
||||
return default;
|
||||
}
|
||||
|
||||
public bool ContainsKey(string Name) => ElementIndex(Name) > -1;
|
||||
public bool ContainsKey(string name) => ElementIndex(name) > -1;
|
||||
|
||||
public int ElementIndex(string Name)
|
||||
public int ElementIndex(string name)
|
||||
{
|
||||
if (List.IsNull) return -1;
|
||||
|
||||
for (int i = 0; i < List.Count; i++)
|
||||
if (List[i].Name == Name) return i;
|
||||
if (List[i].Name == name) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace KKdBaseLib
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct Pointer<T>
|
||||
{
|
||||
|
||||
@@ -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)})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
namespace KKdBaseLib
|
||||
{
|
||||
public struct ButtonSE
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int ID;
|
||||
public int SortIndex;
|
||||
public string Name;
|
||||
public string SEName;
|
||||
}
|
||||
|
||||
public struct ChainSlideSE
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int ID;
|
||||
public int SortIndex;
|
||||
public string Name;
|
||||
public string FirstSEName;
|
||||
public string FailureSEName;
|
||||
public string SubSEName;
|
||||
public string SuccessSEName;
|
||||
}
|
||||
|
||||
public struct CollectionCard
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int DispNum;
|
||||
public int ID;
|
||||
public int NG;
|
||||
public int SortIndex;
|
||||
public int TypeParam;
|
||||
public string Chara;
|
||||
public string DivaProParam;
|
||||
public string ModuleAuthor;
|
||||
public string Name;
|
||||
public string NameReading;
|
||||
public string Type;
|
||||
public string WallParam;
|
||||
}
|
||||
|
||||
public struct CustomizeItem
|
||||
{
|
||||
public TableDate ShopStart;
|
||||
public TableDate ShopEnd;
|
||||
|
||||
public int ID;
|
||||
public int ObjID;
|
||||
public int NG;
|
||||
public int SellType;
|
||||
public int ShopPrice;
|
||||
public int SortIndex;
|
||||
public string Chara;
|
||||
public string Name;
|
||||
public string Parts;
|
||||
}
|
||||
|
||||
public struct Module
|
||||
{
|
||||
public TableDate ShopStart;
|
||||
public TableDate ShopEnd;
|
||||
|
||||
public int Attribute;
|
||||
public int ID;
|
||||
public int NG;
|
||||
public int ShopPrice;
|
||||
public int SortIndex;
|
||||
public string Chara;
|
||||
public string Costume;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
public struct Plate
|
||||
{
|
||||
public int Alpha;
|
||||
public int BaseID;
|
||||
public int Border;
|
||||
public int ColorB;
|
||||
public int ColorG;
|
||||
public int ColorR;
|
||||
public int ID;
|
||||
public int Shadow;
|
||||
public int ShadowAlpha;
|
||||
public int ShadowColorB;
|
||||
public int ShadowColorG;
|
||||
public int ShadowColorR;
|
||||
public string Font;
|
||||
}
|
||||
|
||||
public struct PV
|
||||
{
|
||||
public TableDate AdvStart;
|
||||
public TableDate AdvEnd;
|
||||
|
||||
public int ID;
|
||||
public int Ignore;
|
||||
public string Name;
|
||||
public Difficulty[] Easy;
|
||||
public Difficulty[] Encore;
|
||||
public Difficulty[] Extreme;
|
||||
public Difficulty[] Normal;
|
||||
public Difficulty[] Hard;
|
||||
|
||||
public struct Difficulty
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int Edition;
|
||||
public int Version;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SlideSE
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int ID;
|
||||
public int SortIndex;
|
||||
public string Name;
|
||||
public string SEName;
|
||||
}
|
||||
|
||||
public struct SliderTouchSE
|
||||
{
|
||||
public TableDate Start;
|
||||
public TableDate End;
|
||||
|
||||
public int ID;
|
||||
public int SortIndex;
|
||||
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(); } }
|
||||
|
||||
public bool IsNull => Year == -1 || Month == -1 || Day != -1;
|
||||
public bool NotNull => Year != -1 && Month != -1 && Day != -1;
|
||||
|
||||
public bool WU => Year != 2029 || Month != 1 || Day != 1;
|
||||
public bool WL => Year != 2000 || Month != 1 || Day != 1;
|
||||
|
||||
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();
|
||||
else SDU();
|
||||
if (ymd != null)
|
||||
{
|
||||
year = ymd.Value / 10000;
|
||||
month = ymd.Value / 100 % 100;
|
||||
day = ymd.Value % 100;
|
||||
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; }
|
||||
if (year < 2000) { year = 2000; month = 1; day = 1; return; }
|
||||
if (year >= 2029) { year = 2029; month = 1; day = 1; return; }
|
||||
if (month < 1) month = 1;
|
||||
else if (month > 12) month = 12;
|
||||
if (day < 1) day = 1;
|
||||
else if (day > 31 && (month == 1 || month == 3 || month == 5 ||
|
||||
month == 7 || month == 8 || month == 10 || month == 12)) day = 31;
|
||||
else if (day > 30 && (month == 4 || month == 6 ||
|
||||
month == 9 || month == 11)) day = 30;
|
||||
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")}";
|
||||
}
|
||||
}
|
||||
+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,12 +1,12 @@
|
||||
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)
|
||||
{ this.X = X; this.Y = Y; }
|
||||
public Vec2(T x, T y)
|
||||
{ X = x; Y = y; }
|
||||
|
||||
public bool IsNull => X == null && Y == null;
|
||||
public bool NotNull => X != null || Y != null;
|
||||
@@ -14,14 +14,14 @@
|
||||
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)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; }
|
||||
public Vec3(T x, T y, T z)
|
||||
{ X = x; Y = y; Z = z; }
|
||||
|
||||
public bool IsNull => X == null && Y == null && Z == null;
|
||||
public bool NotNull => X != null || Y != null || Z != null;
|
||||
@@ -29,15 +29,15 @@
|
||||
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)
|
||||
{ this.X = X; this.Y = Y; this.Z = Z; this.W = 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;
|
||||
public bool NotNull => 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.Equals(B);
|
||||
public static bool operator !=(Vector3 A, Vector3 B) => !A.Equals(B);
|
||||
|
||||
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)})";
|
||||
}
|
||||
}
|
||||
+351
-354
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,146 @@
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public unsafe struct AddParam : System.IDisposable
|
||||
{
|
||||
private long i;
|
||||
private Stream _IO;
|
||||
|
||||
public HeaderData Header;
|
||||
|
||||
public void MotHeadReader(string file)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
_IO = File.OpenReader(file + ".adp");
|
||||
Header.Count = _IO.RI64();
|
||||
Header.DataLength = _IO.RI64();
|
||||
Header.DataOffset = _IO.RI64();
|
||||
|
||||
if (Header.Count < 1 || Header.DataOffset > _IO.P || Header.DataLength > _IO.LI64
|
||||
- Header.DataOffset || Header.Count * 0x20 > _IO.LI64 - Header.DataOffset) { _IO.C(); return; }
|
||||
|
||||
Header.Data = new HeaderData.Sub[Header.Count];
|
||||
byte[] data = _IO.RBy(Header.DataLength, Header.DataOffset);
|
||||
_IO.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 MotHeadWriter(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];
|
||||
}
|
||||
|
||||
_IO = File.OpenWriter(file + ".adp", true);
|
||||
_IO.W(Header.Count);
|
||||
_IO.W(Header.DataLength);
|
||||
_IO.W(Header.DataOffset);
|
||||
_IO.W(data);
|
||||
_IO.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(true, file, json);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{ if (_IO != null) _IO.D(); _IO = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+353
-357
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;
|
||||
@@ -218,7 +218,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
+18
-20
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using A3DADict = System.Collections.Generic.Dictionary<string, object>;
|
||||
|
||||
namespace KKdMainLib.DB
|
||||
{
|
||||
@@ -15,8 +15,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
public void BINReader(string file)
|
||||
{
|
||||
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||
string[] dataArray;
|
||||
A3DADict dict = new A3DADict();
|
||||
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
|
||||
@@ -27,35 +26,34 @@ namespace KKdMainLib.DB
|
||||
if (signature != 0x5F5F5F41) return;
|
||||
_IO.RI64();
|
||||
|
||||
string[] strData = _IO.RS(_IO.L - _IO.P).Replace("\r", "").Split('\n');
|
||||
string[] strData = _IO.RS(_IO.L - _IO.P).Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
for (i = 0; i < strData.Length; i++)
|
||||
{
|
||||
dataArray = strData[i].Split('=');
|
||||
if (dataArray.Length == 2)
|
||||
dict.GetDictionary(dataArray[0], dataArray[1]);
|
||||
}
|
||||
dict.GD(strData[i]);
|
||||
strData = null;
|
||||
|
||||
if (dict.FindValue(out string value, "category.length"))
|
||||
if (dict.FV(out string value, "category.length"))
|
||||
{
|
||||
Category = new string[int.Parse(value)];
|
||||
for (i = 0; i < Category.Length; i++)
|
||||
if (dict.FindValue(out value, "category." + i + ".value"))
|
||||
if (dict.FV(out value, $"category.{i}.value"))
|
||||
Category[i] = value;
|
||||
}
|
||||
|
||||
if (dict.FindValue(out value, "uid.length"))
|
||||
if (dict.FV(out value, "uid.length"))
|
||||
{
|
||||
UIDs = new UID[int.Parse(value)];
|
||||
for (i = 0; i < UIDs.Length; i++)
|
||||
{
|
||||
dict.FindValue(out UIDs[i].Category, "uid." + i + ".category");
|
||||
dict.FindValue(out UIDs[i].OrgUid , "uid." + i + ".org_uid" );
|
||||
dict.FindValue(out UIDs[i].Size , "uid." + i + ".size" );
|
||||
dict.FindValue(out UIDs[i].Value , "uid." + i + ".value" );
|
||||
dict.FV(out UIDs[i].Category, $"uid.{i}.category");
|
||||
dict.FV(out UIDs[i].OrgUid , $"uid.{i}.org_uid" );
|
||||
dict.FV(out UIDs[i].Size , $"uid.{i}.size" );
|
||||
dict.FV(out UIDs[i].Value , $"uid.{i}.value" );
|
||||
}
|
||||
}
|
||||
|
||||
_IO.C();
|
||||
dict.Clear();
|
||||
dict = null;
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
@@ -68,7 +66,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
if (Category != null)
|
||||
{
|
||||
int[] so = Category.Length.SortWriter();
|
||||
int[] so = Category.Length.SW();
|
||||
for (i = 0; i < Category.Length; i++)
|
||||
_IO.W($"category.{so[i]}.value={ Category[so[i]]}\n");
|
||||
_IO.W($"category.length={Category.Length}\n");
|
||||
@@ -76,7 +74,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
if (UIDs != null)
|
||||
{
|
||||
int[] so = UIDs.Length.SortWriter();
|
||||
int[] so = UIDs.Length.SW();
|
||||
for (i = 0; i < UIDs.Length; i++)
|
||||
{
|
||||
if (UIDs[so[i]].Category != null && UIDs[so[i]].Category != "")
|
||||
@@ -153,7 +151,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
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;
|
||||
@@ -256,7 +256,7 @@ namespace KKdMainLib.DB
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace KKdMainLib
|
||||
MsgPack dex = new MsgPack(Dex.Length, "Dex");
|
||||
for (i0 = 0; i0 < Dex.Length; i0++)
|
||||
{
|
||||
MsgPack exp = MsgPack.New.Add("Name", this.Dex[i0].Name);
|
||||
MsgPack exp = MsgPack.New.Add("Name", Dex[i0].Name);
|
||||
MsgPack main = new MsgPack(Dex[i0].Main.Count, "Main");
|
||||
for (i1 = 0; i1 < Dex[i0].Main.Count; i1++)
|
||||
main[i1] = Dex[i0].Main[i1].Write();
|
||||
@@ -223,7 +223,7 @@ namespace KKdMainLib
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); Dex = null; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = 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;
|
||||
|
||||
+35
-53
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
@@ -58,9 +58,11 @@ namespace KKdMainLib
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (pvList != null && pvList.Length > 0)
|
||||
for (i = 0; i < pvList.Length; i++)
|
||||
_IO.W(UrlEncode(pvList[i].ToString() +
|
||||
(i < pvList.Length ? c : "")));
|
||||
{
|
||||
for (i = 0; i < pvList.Length - 1; i++)
|
||||
_IO.W(UrlEncode(pvList[i].ToString() + c));
|
||||
_IO.W(UrlEncode(pvList[i].ToString()));
|
||||
}
|
||||
else _IO.W("%2A%2A%2A");
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@ namespace KKdMainLib
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json, bool Compact = true)
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (!Success) return;
|
||||
MsgPack msgPack = MsgPack.New;
|
||||
@@ -123,11 +125,10 @@ namespace KKdMainLib
|
||||
else if (file.Contains("PvList"))
|
||||
{
|
||||
if (pvList != null)
|
||||
{
|
||||
if (Compact) msgPack.Add("Compact", Compact);
|
||||
{msgPack.Add("Compact", true);
|
||||
|
||||
MsgPack PvList = new MsgPack(pvList.Length, "PvList");
|
||||
for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP(Compact);
|
||||
for (i = 0; i < pvList.Length; i++) PvList[i] = pvList[i].WriteMP();
|
||||
msgPack.Add(PvList);
|
||||
}
|
||||
else msgPack.Add(new MsgPack("PvList", null));
|
||||
@@ -140,7 +141,8 @@ namespace KKdMainLib
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); psrData = null; pvList = null; Success = false; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; psrData = null;
|
||||
pvList = null; Success = false; disposed = true; } }
|
||||
|
||||
public struct PsrData
|
||||
{
|
||||
@@ -175,7 +177,7 @@ namespace KKdMainLib
|
||||
.Add(p2.WriteMP("P2")).Add(p3.WriteMP("P3"));
|
||||
|
||||
public override string ToString() =>
|
||||
UrlEncode(p1.ToString() + c + p2.ToString() + c + p3.ToString() + c + PV_ID);
|
||||
UrlEncode($"{p1.ToString()},{p2.ToString()},{p3.ToString()},{PV_ID}");
|
||||
}
|
||||
|
||||
public struct Player
|
||||
@@ -240,8 +242,8 @@ namespace KKdMainLib
|
||||
public struct PvList
|
||||
{
|
||||
public int PV_ID;
|
||||
public bool Enable;
|
||||
public bool Extra;
|
||||
public int Version;
|
||||
public int Edition;
|
||||
public Date AdvDemoStart;
|
||||
public Date AdvDemoEnd;
|
||||
public Date StartShow;
|
||||
@@ -249,9 +251,9 @@ namespace KKdMainLib
|
||||
|
||||
public void SetValue(string[] data, int i = 0)
|
||||
{
|
||||
PV_ID = int.Parse(data[i * 7]);
|
||||
Enable = int.Parse(data[i * 7 + 1]) == 1;
|
||||
Extra = int.Parse(data[i * 7 + 2]) == 1;
|
||||
PV_ID = int.Parse(data[i * 7]);
|
||||
Version = int.Parse(data[i * 7 + 1]);
|
||||
Edition = int.Parse(data[i * 7 + 2]);
|
||||
AdvDemoStart.SV(data[i * 7 + 3]);
|
||||
AdvDemoEnd .SV(data[i * 7 + 4]);
|
||||
StartShow .SV(data[i * 7 + 5]);
|
||||
@@ -260,16 +262,15 @@ namespace KKdMainLib
|
||||
|
||||
public void SetValue(MsgPack msg, bool Compact)
|
||||
{
|
||||
Enable = true;
|
||||
Extra = false;
|
||||
Version = 1;
|
||||
Edition = 0;
|
||||
|
||||
int? id = msg.RnI32("PV_ID");
|
||||
if (id != null) PV_ID = (int)id;
|
||||
else { id = msg.RnI32("ID"); if (id != null) PV_ID = (int)id; }
|
||||
bool? enable = msg.RnB("Enable");
|
||||
bool? extra = msg.RnB("Extra");
|
||||
if (enable != null) Enable = (bool)enable;
|
||||
if (extra != null) Extra = (bool)extra ;
|
||||
if (id != null) PV_ID = id.Value; else { id = msg.RnI32("ID"); if (id != null) PV_ID = id.Value; }
|
||||
bool? enable = msg.RnB("Enable"); if (enable != null) Version = enable.Value ? 1 : 0;
|
||||
bool? extra = msg.RnB("Extra" ); if (extra != null) Edition = extra .Value ? 1 : 0;
|
||||
int? version = msg.RnI32("Version"); if (version != null) Version = version.Value;
|
||||
int? edition = msg.RnI32("Edition"); if (edition != null) Edition = edition.Value;
|
||||
if (Compact)
|
||||
{
|
||||
AdvDemoStart.SV(msg.RnI32("AdvDemoStart"), true);
|
||||
@@ -287,33 +288,20 @@ namespace KKdMainLib
|
||||
temp.Dispose();
|
||||
}
|
||||
|
||||
public MsgPack WriteMP(bool Compact)
|
||||
public MsgPack WriteMP()
|
||||
{
|
||||
MsgPack msgPack = MsgPack.New;
|
||||
msgPack.Add("ID", PV_ID);
|
||||
if (!Enable) msgPack.Add("Enable", Enable);
|
||||
if ( Extra ) msgPack.Add("Extra" , Extra );
|
||||
if (Compact)
|
||||
{
|
||||
if (AdvDemoStart.WU) msgPack.Add("AdvDemoStart", AdvDemoStart.WI());
|
||||
if (AdvDemoEnd .WL) msgPack.Add("AdvDemoEnd" , AdvDemoEnd .WI());
|
||||
if (StartShow .WL) msgPack.Add("StartShow" , StartShow .WI());
|
||||
if ( EndShow .WU) msgPack.Add( "EndShow" , EndShow .WI());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AdvDemoStart.WU) msgPack.Add(AdvDemoStart.WriteMP("AdvDemoStart"));
|
||||
if (AdvDemoEnd .WL) msgPack.Add(AdvDemoEnd .WriteMP("AdvDemoEnd" ));
|
||||
if (StartShow .WL) msgPack.Add(StartShow .WriteMP("StartShow" ));
|
||||
if ( EndShow .WU) msgPack.Add( EndShow .WriteMP( "EndShow" ));
|
||||
}
|
||||
MsgPack msgPack = MsgPack.New.Add("ID" , PV_ID )
|
||||
.Add("Version", Version)
|
||||
.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);
|
||||
if ( EndShow .WU) msgPack.Add( "EndShow" , EndShow .Int);
|
||||
return msgPack;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
UrlEncode(PV_ID + c + (Enable ? 1 : 0) + c + (Extra ? 1 : 0) + c +
|
||||
AdvDemoStart.ToString() + c + AdvDemoEnd.ToString() + c +
|
||||
StartShow.ToString() + c + EndShow.ToString());
|
||||
UrlEncode($"{PV_ID},{Version},{Edition},{AdvDemoStart},{AdvDemoEnd},{StartShow},{EndShow}");
|
||||
}
|
||||
|
||||
public struct Date
|
||||
@@ -323,9 +311,7 @@ namespace KKdMainLib
|
||||
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(); } }
|
||||
|
||||
public bool WU => Year != 2029 || Month != 1 || Day != 1;
|
||||
@@ -371,11 +357,7 @@ namespace KKdMainLib
|
||||
CheckDate();
|
||||
}
|
||||
|
||||
public int WI() =>
|
||||
(Year * 100 + Month) * 100 + Day;
|
||||
|
||||
public MsgPack WriteMP(string name) =>
|
||||
new MsgPack(name).Add("Year", Year).Add("Month", Month).Add("Day", Day);
|
||||
public int Int => (Year * 100 + Month) * 100 + Day;
|
||||
|
||||
private void CheckDate()
|
||||
{
|
||||
@@ -393,7 +375,7 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
Year.ToString("d4") + "-" + Month.ToString("d2") + "-" + Day.ToString("d2");
|
||||
$"{Year.ToString("d4")}-{Month.ToString("d2")}-{Day.ToString("d2")}";
|
||||
}
|
||||
|
||||
public enum Difficulty
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace KKdMainLib
|
||||
public static MsgPack Write(this MsgPack mp, string file, 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 + ".json", true))) _IO.W(mp);
|
||||
else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp);
|
||||
return mp;
|
||||
}
|
||||
|
||||
@@ -230,4 +230,13 @@ namespace KKdMainLib
|
||||
return kf;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LibDeflate
|
||||
{
|
||||
public static void Extract()
|
||||
{
|
||||
if (!File.Exists("libdeflate.dll"))
|
||||
File.WriteAllBytes("libdeflate.dll", Properties.Resources.libdeflate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -60,12 +60,12 @@ namespace KKdMainLib.F2
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); BLTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = 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;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace KKdMainLib.F2
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); CCTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = 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) + "," +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace KKdMainLib.F2
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); DFTs = default; header = default; disposed = true; } }
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; DFTs = default; header = default; disposed = true; } }
|
||||
|
||||
public struct DFT
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -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 (_IO != null) _IO.D(); _IO = null; LITs = default; header = default; disposed = true; } }
|
||||
|
||||
public enum Id : int
|
||||
{
|
||||
|
||||
+57
-73
@@ -1,4 +1,4 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
@@ -11,18 +11,20 @@ namespace KKdMainLib
|
||||
public class FARC : System.IDisposable
|
||||
{
|
||||
public FARC() => NewFARC();
|
||||
public FARC(string File, bool IsDirectory = false)
|
||||
{ if (IsDirectory) DirectoryPath = File; else FilePath = File; NewFARC(); }
|
||||
public FARC(string file, bool isDirectory = false)
|
||||
{ if (isDirectory) DirectoryPath = file; else FilePath = file; NewFARC(); }
|
||||
|
||||
private void NewFARC() { Files = KKdList<FARCFile>.New; Signature = Farc.FArC; cbc = ft = false; }
|
||||
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; }
|
||||
|
||||
public KKdList<FARCFile> Files = KKdList<FARCFile>.New;
|
||||
public Type FARCType;
|
||||
public Farc Signature = Farc.FArC;
|
||||
public Format Format = Format.DT;
|
||||
public string FilePath, DirectoryPath;
|
||||
public bool HasFiles => Files.IsNull ? false : Files.Count > 0;
|
||||
|
||||
private bool cbc, ft;
|
||||
public int CompressionLevel = 12;
|
||||
|
||||
private readonly byte[] key = Text.ToASCII("project_diva.bin");
|
||||
|
||||
@@ -30,11 +32,11 @@ namespace KKdMainLib
|
||||
0x31, 0xEB, 0xA2, 0x39, 0xB8, 0x3C, 0x15, 0x57, 0xC6, 0xBB };
|
||||
|
||||
private AesManaged GetAes(bool isFT, byte[] iv) =>
|
||||
new AesManaged { KeySize = 128, Key = isFT ? keyFT : key,
|
||||
new AesManaged () { KeySize = 128, Key = isFT ? keyFT : key,
|
||||
BlockSize = 128, Mode = isFT ? CipherMode.CBC : CipherMode.ECB,
|
||||
Padding = PaddingMode.Zeros, IV = iv ?? new byte[16] };
|
||||
|
||||
public void UnPack(bool saveToDisk = true)
|
||||
public void Unpack(bool saveToDisk = true)
|
||||
{ if (HeaderReader()) { FileReader(); if (saveToDisk) SaveToDisk(); } }
|
||||
|
||||
public bool HeaderReader()
|
||||
@@ -53,12 +55,11 @@ namespace KKdMainLib
|
||||
{
|
||||
FARCType = (Type)reader.RI32E(true);
|
||||
reader.RI32();
|
||||
|
||||
int farcMode = reader.RI32E(true);
|
||||
ft = farcMode == 0x10;
|
||||
cbc = farcMode != 0x10 && farcMode != 0x40;
|
||||
|
||||
if (cbc && (FARCType & Type.ECB) != 0)
|
||||
Format = (FARCType & Type.ECB) != 0 && (farcMode & (farcMode - 1)) != 0 ? Format.FT : Format.DT;
|
||||
|
||||
if (Format == Format.FT && (FARCType & Type.ECB) != 0)
|
||||
{
|
||||
reader.Dispose();
|
||||
byte[] header = new byte[headerLength - 0x08];
|
||||
@@ -73,7 +74,6 @@ namespace KKdMainLib
|
||||
reader = File.OpenReader(header);
|
||||
|
||||
farcMode = reader.RI32E(true);
|
||||
ft = farcMode == 0x10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace KKdMainLib
|
||||
{
|
||||
reader.NT();
|
||||
reader.RI32();
|
||||
if (Signature != Farc.FArc ) reader.RI32();
|
||||
if (Signature != Farc.FArc) reader.RI32();
|
||||
reader.RI32();
|
||||
if (Signature == Farc.FARC && ft) reader.RI32();
|
||||
if (Signature == Farc.FARC && Format == Format.FT) reader.RI32();
|
||||
Count++;
|
||||
}
|
||||
reader.PI64 = Position;
|
||||
@@ -106,7 +106,7 @@ namespace KKdMainLib
|
||||
file.Offset = reader.RI32E(true);
|
||||
if (Signature != Farc.FArc) file.SizeComp = reader.RI32E(true);
|
||||
file.SizeUnc = reader.RI32E(true);
|
||||
if (Signature == Farc.FARC && ft)
|
||||
if (Signature == Farc.FARC && Format == Format.FT)
|
||||
file.Type = (Type)reader.RI32E(true);
|
||||
Files.Add(file);
|
||||
}
|
||||
@@ -156,51 +156,35 @@ namespace KKdMainLib
|
||||
}
|
||||
|
||||
int FileSize = (FARCType & Type.ECB) != 0 || (file.Type & Type.ECB) != 0 ?
|
||||
file.SizeComp.A(0x10) : file.SizeComp;
|
||||
using (MSIO.FileStream stream = new MSIO.FileStream(FilePath, MSIO.FileMode.Open,
|
||||
MSIO.FileAccess.ReadWrite, MSIO.FileShare.ReadWrite))
|
||||
file.SizeComp.A(0x10) : ((FARCType & Type.GZip) != 0 || (file.Type & Type.GZip) != 0 ? file.SizeComp : file.SizeUnc);
|
||||
using (Stream stream = File.OpenReader(FilePath))
|
||||
{
|
||||
stream.Seek(file.Offset, 0);
|
||||
file.Data = new byte[FileSize];
|
||||
|
||||
bool encrypted = false;
|
||||
if ((FARCType & Type.ECB) != 0)
|
||||
{
|
||||
if ((ft && (file.Type & Type.ECB) != 0) || cbc)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
file.Data = SkipData(file.Data, 0x10);
|
||||
}
|
||||
else
|
||||
using (AesManaged aes = GetAes(false, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(stream,
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
encrypted = true;
|
||||
}
|
||||
|
||||
bool compressed = false;
|
||||
if (((ft && (file.Type & Type.GZip) != 0) ||
|
||||
(FARCType & Type.GZip) != 0) && file.SizeUnc > 0)
|
||||
{
|
||||
GZipStream gZipStream = new GZipStream(encrypted ? new MSIO.MemoryStream(file.Data) :
|
||||
(MSIO.Stream)stream, CompressionMode.Decompress);
|
||||
byte[] Temp = new byte[file.SizeUnc];
|
||||
gZipStream.Read(Temp, 0, file.SizeUnc);
|
||||
file.Data = Temp;
|
||||
gZipStream.Dispose();
|
||||
compressed = true;
|
||||
}
|
||||
|
||||
if (!encrypted && !compressed)
|
||||
{
|
||||
file.Data = new byte[file.SizeUnc];
|
||||
stream.Read(file.Data, 0, file.SizeUnc);
|
||||
}
|
||||
stream.S(file.Offset, 0);
|
||||
file.Data = stream.RBy(FileSize);
|
||||
}
|
||||
|
||||
|
||||
if ((FARCType & Type.ECB) != 0)
|
||||
{
|
||||
if (Format == Format.FT && (file.Type & Type.ECB) != 0)
|
||||
{
|
||||
using (AesManaged aes = GetAes(true, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(new MSIO.MemoryStream(file.Data),
|
||||
aes.CreateDecryptor(), CryptoStreamMode.Read))
|
||||
cryptoStream.Read(file.Data, 0, FileSize);
|
||||
file.Data = SkipData(file.Data, 0x10);
|
||||
}
|
||||
else
|
||||
using (AesManaged aes = GetAes(false, null))
|
||||
using (CryptoStream cryptoStream = new CryptoStream(new MSIO.MemoryStream(file.Data),
|
||||
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)
|
||||
file.Data = file.Data.InflateGZip(file.SizeUnc);
|
||||
|
||||
Files[i] = file;
|
||||
return file.Data;
|
||||
}
|
||||
@@ -258,21 +242,26 @@ namespace KKdMainLib
|
||||
else if (Signature == Farc.FARC)
|
||||
{
|
||||
headerWriter.WE((int)FARCType, true);
|
||||
headerWriter.W (0x00);
|
||||
headerWriter.W (0x00);
|
||||
headerWriter.WE(0x40, true);
|
||||
headerWriter.W (0x00);
|
||||
headerWriter.W (0x00);
|
||||
headerWriter.W (0x00);
|
||||
}
|
||||
int HeaderPartLength = Signature == Farc.FArc ? 0x09 : 0x0D;
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
headerWriter.L += Path.GetFileName(Files[i].Name).Length + HeaderPartLength + 1;
|
||||
if (Signature != Farc.FArc)
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{ headerWriter.W(Files[i].Name + "\0"); headerWriter.W(0x00L); headerWriter.W(0x00); }
|
||||
else
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{ headerWriter.W(Files[i].Name + "\0"); headerWriter.W(0x00L); }
|
||||
writer.WE(headerWriter.L, true);
|
||||
writer.W(headerWriter.ToArray(true));
|
||||
writer.W (headerWriter.ToArray(true));
|
||||
}
|
||||
|
||||
int align = writer.P.A(0x10) - writer.P;
|
||||
for (int i1 = 0; i1 < align; i1++)
|
||||
writer.W((byte)(Signature == Farc.FArc ? 0x00 : 0x78));
|
||||
|
||||
writer.F();
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
CompressStuff(i, ref writer);
|
||||
|
||||
@@ -280,10 +269,9 @@ namespace KKdMainLib
|
||||
for (int i = 0; i < Files.Count; i++)
|
||||
{
|
||||
FARCFile file = Files[i];
|
||||
writer.W(Path.GetFileName(file.Name) + "\0");
|
||||
writer.W (file.Name + "\0");
|
||||
writer.WE(file.Offset, true);
|
||||
if (Signature != Farc.FArc)
|
||||
writer.WE(file.SizeComp, true);
|
||||
if (Signature != Farc.FArc) writer.WE(file.SizeComp, true);
|
||||
writer.WE(file.SizeUnc, true);
|
||||
}
|
||||
writer.Dispose();
|
||||
@@ -300,11 +288,7 @@ namespace KKdMainLib
|
||||
if (Signature == Farc.FArC || (Signature == Farc.FARC && (FARCType & Type.GZip) != 0))
|
||||
{
|
||||
file.Type |= Type.GZip;
|
||||
MSIO.MemoryStream stream = new MSIO.MemoryStream();
|
||||
using (GZipStream gZipStream = new GZipStream(stream, CompressionMode.Compress))
|
||||
gZipStream.Write(file.Data, 0, file.Data.Length);
|
||||
data = stream.ToArray();
|
||||
stream.Dispose();
|
||||
data = file.Data.DeflateGZip(CompressionLevel);
|
||||
file.SizeComp = data.Length;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
@@ -69,40 +69,40 @@ namespace KKdMainLib.IO
|
||||
public static long RIX(this Stream stream, bool isBE) => stream.IsX ?
|
||||
stream.RI64() : stream.RU32E(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 offset = -1, long length = -1)
|
||||
{
|
||||
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);
|
||||
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 = Position;
|
||||
return s;
|
||||
}
|
||||
@@ -114,11 +114,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>();
|
||||
|
||||
+81
-22
@@ -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; }
|
||||
@@ -49,7 +60,7 @@ 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[i] != null) _IO.W(data[i]); } _IO.W("\r\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) for (int i = 0; i < data.Length; i++)
|
||||
{ if (data[i] != null) _IO.W(data[i]); _IO.W("\r\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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -113,7 +113,7 @@ namespace KKdMainLib.IO
|
||||
KKdList<MsgPack> obj = KKdList<MsgPack>.New;
|
||||
if (!Extensions.As(_IO, '[')) return null;
|
||||
if (_IO.SW().PCUTF8() == ']')
|
||||
{ _IO.RCUTF8(); return null; }
|
||||
{ _IO.RCUTF8(); return obj.ToArray(); }
|
||||
|
||||
char c;
|
||||
while (true)
|
||||
|
||||
+33
-31
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
|
||||
namespace KKdMainLib.IO
|
||||
{
|
||||
@@ -196,32 +196,32 @@ namespace KKdMainLib.IO
|
||||
case float val: W(val); break;
|
||||
case double val: W(val); break;
|
||||
case string val: W(val); break;
|
||||
case MsgPack.Ext val: WE(val); break;
|
||||
case MsgPack.Ext val: W(val); break;
|
||||
}
|
||||
}
|
||||
|
||||
private void W( sbyte val) { if (val < -0x20) _IO.W(0xD0); _IO.W(val); }
|
||||
private void W( byte val) { if (val >= 0x80) _IO.W(0xCC); _IO.W(val); }
|
||||
private void W( sbyte val) { if (val < -0x20) _IO.W((byte)0xD0); _IO.W(val); }
|
||||
private void W( byte val) { if (val >= 0x80) _IO.W((byte)0xCC); _IO.W(val); }
|
||||
private void W( short val) { if (( sbyte)val == val) W(( sbyte)val);
|
||||
else if (( byte)val == val) W(( byte)val);
|
||||
else { _IO.W(0xD1); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xD1); _IO.WE(val, true); } }
|
||||
private void W(ushort val) { if (( byte)val == val) W(( byte)val);
|
||||
else { _IO.W(0xCD); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xCD); _IO.WE(val, true); } }
|
||||
private void W( int val) { if (( short)val == val) W(( short)val);
|
||||
else if ((ushort)val == val) W((ushort)val);
|
||||
else { _IO.W(0xD2); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xD2); _IO.WE(val, true); } }
|
||||
private void W( uint val) { if ((ushort)val == val) W((ushort)val);
|
||||
else { _IO.W(0xCE); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xCE); _IO.WE(val, true); } }
|
||||
private void W( long val) { if (( int)val == val) W(( int)val);
|
||||
else if (( uint)val == val) W(( uint)val);
|
||||
else { _IO.W(0xD3); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xD3); _IO.WE(val, true); } }
|
||||
private void W( ulong val) { if (( uint)val == val) W(( uint)val);
|
||||
else { _IO.W(0xCF); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xCF); _IO.WE(val, true); } }
|
||||
private void W( float val) { if (( long)val == val) W(( long)val);
|
||||
else { _IO.W(0xCA); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xCA); _IO.WE(val, true); } }
|
||||
private void W(double val) { if (( long)val == val) W(( long)val);
|
||||
else if (( float)val == val) W(( float)val);
|
||||
else { _IO.W(0xCB); _IO.WE(val, true); } }
|
||||
else { _IO.W((byte)0xCB); _IO.WE(val, true); } }
|
||||
|
||||
private void W( bool val) =>
|
||||
_IO.W((byte)(val ? 0xC3 : 0xC2));
|
||||
@@ -230,9 +230,9 @@ namespace KKdMainLib.IO
|
||||
{
|
||||
if (val == null) { WN(); return; }
|
||||
|
||||
if (val.Length < 0x100) { _IO.W(0xC4); _IO.W (( byte)val.Length ); }
|
||||
else if (val.Length < 0x10000) { _IO.W(0xC5); _IO.WE((ushort)val.Length, true); }
|
||||
else { _IO.W(0xC6); _IO.WE( val.Length, true); }
|
||||
if (val.Length < 0x100) { _IO.W((byte)0xC4); _IO.W (( byte)val.Length ); }
|
||||
else if (val.Length < 0x10000) { _IO.W((byte)0xC5); _IO.WE((ushort)val.Length, true); }
|
||||
else { _IO.W((byte)0xC6); _IO.WE( val.Length, true); }
|
||||
_IO.W(val);
|
||||
}
|
||||
|
||||
@@ -242,48 +242,50 @@ namespace KKdMainLib.IO
|
||||
|
||||
byte[] array = Text.ToUTF8(val);
|
||||
if (array.Length < 0x20) _IO.W((byte)(0xA0 | (array.Length & 0x1F)));
|
||||
else if (array.Length < 0x100) { _IO.W(0xD9); _IO.W (( byte)array.Length); }
|
||||
else if (array.Length < 0x10000) { _IO.W(0xDA); _IO.WE((ushort)array.Length, true); }
|
||||
else { _IO.W(0xDB); _IO.WE( array.Length, true); }
|
||||
else if (array.Length < 0x100) { _IO.W((byte)0xD9); _IO.W (( byte)array.Length); }
|
||||
else if (array.Length < 0x10000) { _IO.W((byte)0xDA); _IO.WE((ushort)array.Length, true); }
|
||||
else { _IO.W((byte)0xDB); _IO.WE( array.Length, true); }
|
||||
_IO.W(array);
|
||||
}
|
||||
|
||||
private void WN() => _IO.W(0xC0);
|
||||
private void WN() => _IO.W((byte)0xC0);
|
||||
|
||||
private void WA(int val)
|
||||
{
|
||||
if (val == 0) { WN(); return; }
|
||||
else if (val < 0x10) _IO.W((byte)(0x90 | (val & 0x0F)));
|
||||
else if (val < 0x10000) { _IO.W(0xDC); _IO.WE((ushort)val, true); }
|
||||
else { _IO.W(0xDD); _IO.WE( val, true); }
|
||||
else if (val < 0x10000) { _IO.W((byte)0xDC); _IO.WE((ushort)val, true); }
|
||||
else { _IO.W((byte)0xDD); _IO.WE( val, true); }
|
||||
}
|
||||
|
||||
private void WM(int val)
|
||||
{
|
||||
if (val == 0) { WN(); return; }
|
||||
else if (val < 0x10) _IO.W((byte)(0x80 | (val & 0x0F)));
|
||||
else if (val < 0x10000) { _IO.W(0xDE); _IO.WE((ushort)val, true); }
|
||||
else { _IO.W(0xDF); _IO.WE( val, true); }
|
||||
else if (val < 0x10000) { _IO.W((byte)0xDE); _IO.WE((ushort)val, true); }
|
||||
else { _IO.W((byte)0xDF); _IO.WE( val, true); }
|
||||
}
|
||||
|
||||
private void W(MsgPack.Ext val) => WE(val);
|
||||
|
||||
private void WE(MsgPack.Ext val)
|
||||
{
|
||||
if (val.Data == null) { WN(); return; }
|
||||
|
||||
if (val.Data.Length < 1 ) { WN(); return; }
|
||||
else if (val.Data.Length == 1 ) _IO.W(0xD4);
|
||||
else if (val.Data.Length == 2 ) _IO.W(0xD5);
|
||||
else if (val.Data.Length == 4 ) _IO.W(0xD6);
|
||||
else if (val.Data.Length == 8 ) _IO.W(0xD7);
|
||||
else if (val.Data.Length == 16) _IO.W(0xD8);
|
||||
else if (val.Data.Length == 1 ) _IO.W((byte)0xD4);
|
||||
else if (val.Data.Length == 2 ) _IO.W((byte)0xD5);
|
||||
else if (val.Data.Length == 4 ) _IO.W((byte)0xD6);
|
||||
else if (val.Data.Length == 8 ) _IO.W((byte)0xD7);
|
||||
else if (val.Data.Length == 16) _IO.W((byte)0xD8);
|
||||
else
|
||||
{
|
||||
if (val.Data.Length < 0x100)
|
||||
{ _IO.W(0xC7); _IO.W (( byte)val.Data.Length); }
|
||||
{ _IO.W((byte)0xC7); _IO.W (( byte)val.Data.Length); }
|
||||
else if (val.Data.Length < 0x10000)
|
||||
{ _IO.W(0xC8); _IO.WE((ushort)val.Data.Length, true); }
|
||||
{ _IO.W((byte)0xC8); _IO.WE((ushort)val.Data.Length, true); }
|
||||
else
|
||||
{ _IO.W(0xC9); _IO.WE( val.Data.Length, true); }
|
||||
{ _IO.W((byte)0xC9); _IO.WE( val.Data.Length, true); }
|
||||
}
|
||||
_IO.W(val.Type);
|
||||
_IO.W(val.Data);
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
+219
-150
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using MSIO = System.IO;
|
||||
using ENRSDict = System.Collections.Generic.Dictionary<long, int>;
|
||||
@@ -7,17 +7,20 @@ namespace KKdMainLib.IO
|
||||
{
|
||||
public unsafe class Stream : IDisposable
|
||||
{
|
||||
private int I, i, BitRead, BitWrite, TempBitRead, TempBitWrite, ValRead, ValWrite;
|
||||
private int i, j, bitRead, bitWrite, tempBitRead, tempBitWrite, valRead, valWrite;
|
||||
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;
|
||||
{ get => format;
|
||||
set { format = value;
|
||||
IsBE = format == Format.F2BE;
|
||||
IsX = format == Format.X || format == Format.XHD; } }
|
||||
|
||||
@@ -34,34 +37,33 @@ namespace KKdMainLib.IO
|
||||
public uint OU32 { get => (uint)OI64; set => OI64 = value; }
|
||||
public long OI64;
|
||||
|
||||
public int L { get => ( int)s.Length - O; set => s.SetLength(value + O); }
|
||||
public int L { get => ( int)s.Length - O; set => s.SetLength(value + O ); }
|
||||
public uint LU32 { get => (uint)s.Length - OU32; set => s.SetLength(value + OU32); }
|
||||
public long LI64 { get => s.Length - OI64; set => s.SetLength(value + OI64); }
|
||||
|
||||
public int P
|
||||
{ get => ( int)s.Position - O; set => s.Position = value + O; }
|
||||
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 int P { get => ( int)s.Position - O; set => s.Position = value + O ; }
|
||||
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;
|
||||
BitRead = 8;
|
||||
ValRead = ValRead = BitWrite = 0;
|
||||
bitRead = 8;
|
||||
valRead = valRead = bitWrite = 0;
|
||||
s = output;
|
||||
Format = Format.NULL;
|
||||
b = new byte[0x100];
|
||||
this.IsBE = isBE;
|
||||
IsBE = isBE;
|
||||
this.canRead = s.CanRead && canRead;
|
||||
this.canWrite = s.CanWrite && canWrite;
|
||||
}
|
||||
|
||||
public void C() => D(true);
|
||||
@@ -111,56 +113,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);
|
||||
@@ -173,31 +178,31 @@ 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); }
|
||||
{ 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(); }
|
||||
@@ -227,7 +232,7 @@ namespace KKdMainLib.IO
|
||||
public double RF64ENRSE(bool isBE) { RENRS(b, 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); }
|
||||
{ if (getENRS) ENRSDict.Add(P, c); cR(); 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); }
|
||||
@@ -256,115 +261,179 @@ namespace KKdMainLib.IO
|
||||
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 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[] arr = new T[length];
|
||||
byte[] buf = new byte[sizeOfT];
|
||||
fixed (byte* ptr = buf)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
cR(); s.Read(buf, 0, sizeOfT);
|
||||
arr[i] = *(T*)ptr;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public T[] WA<T>(T[] array, long length, long offset = -1) where T : unmanaged
|
||||
{
|
||||
cW();
|
||||
int sizeOfT = sizeof(T);
|
||||
if (offset > -1) s.Position = offset;
|
||||
T[] arr = new T[length];
|
||||
byte[] buf = new byte[sizeOfT];
|
||||
fixed (byte* ptr = buf)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
*(T*)ptr = arr[i];
|
||||
s.Write(buf, 0, sizeOfT);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public char RC(bool utf8 = true)
|
||||
{ cR(); return utf8 ? RCUTF8() : (char)s.ReadByte();}
|
||||
|
||||
public char RCUTF8()
|
||||
{
|
||||
cR();
|
||||
byte t;
|
||||
int T;
|
||||
int val = 0;
|
||||
for (I = 0, i = 4; I < i; I++)
|
||||
for (j = 0, i = 4; j < i; j++)
|
||||
{
|
||||
T = s.ReadByte();
|
||||
if (T == -1) return '\uFFFF';
|
||||
t = (byte)T;
|
||||
|
||||
if ((t & 0xC0) == 0x80 && I > 0) val = (val << 6) | (t & 0x3F);
|
||||
else if ((t & 0x80) == 0x00 && I == 0) return (char)t;
|
||||
else if ((t & 0xE0) == 0xC0 && I == 0) { val = t & 0x1F; i = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && I == 0) { val = t & 0x0F; i = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && I == 0) { val = t & 0x07; i = 4; }
|
||||
if ((t & 0xC0) == 0x80 && j > 0) val = (val << 6) | (t & 0x3F);
|
||||
else if ((t & 0x80) == 0x00 && j == 0) return (char)t;
|
||||
else if ((t & 0xE0) == 0xC0 && j == 0) { val = t & 0x1F; i = 2; }
|
||||
else if ((t & 0xF0) == 0xE0 && j == 0) { val = t & 0x0F; i = 3; }
|
||||
else if ((t & 0xF8) == 0xF0 && j == 0) { val = t & 0x07; i = 4; }
|
||||
else return '\uFFFF';
|
||||
}
|
||||
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, long offset = -1)
|
||||
{ cR(); byte[] buf = new byte[length]; if (offset > -1) s.Position = offset;
|
||||
s.Read(buf, 0, (int)length); return buf; }
|
||||
|
||||
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 int RBy(long length, byte[] buf, long offset = -1)
|
||||
{ cR(); if (offset > -1) s.Position = offset; return s.Read(buf, 0, (int)length); }
|
||||
|
||||
public void RBy(long Length, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) s.Position = Offset; s.Read(Buf, 0, (int)Length); }
|
||||
public byte[] RBy(long? length, long offset = -1)
|
||||
{ if (length == null) return new byte[0]; else return RBy((long)length, offset); }
|
||||
|
||||
public byte[] RBy(long? Length, int 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)
|
||||
{ if (offset > -1) s.Seek(offset, 0);
|
||||
if (bits > 0 && bits < 8) for (i = 0; i < length; i++) buf[i] = RBi(bits); CR(); }
|
||||
|
||||
public void RBy(long Length, byte Bits, byte[] Buf, long Offset = -1)
|
||||
{ if (Offset > -1) s.Seek(Offset, 0);
|
||||
if (Bits > 0 && Bits < 8) for (i = 0; i < Length; i++) Buf[i] = RBi(Bits); CR(); }
|
||||
|
||||
public byte RBi(byte Bits)
|
||||
public byte RBi(byte bits)
|
||||
{
|
||||
BitRead += Bits;
|
||||
TempBitRead = 8 - BitRead;
|
||||
if (TempBitRead < 0)
|
||||
cR();
|
||||
bitRead += bits;
|
||||
tempBitRead = 8 - bitRead;
|
||||
if (tempBitRead < 0)
|
||||
{
|
||||
BitRead = (byte)-TempBitRead;
|
||||
TempBitRead = 8 + TempBitRead;
|
||||
ValRead = (ushort)((ValRead << 8) | (byte)s.ReadByte());
|
||||
bitRead = (byte)-tempBitRead;
|
||||
tempBitRead = 8 + tempBitRead;
|
||||
valRead = (ushort)((valRead << 8) | (byte)s.ReadByte());
|
||||
}
|
||||
return (byte)((ValRead >> TempBitRead) & ((1 << Bits) - 1));
|
||||
return (byte)((valRead >> tempBitRead) & ((1 << bits) - 1));
|
||||
}
|
||||
|
||||
public byte RHB() => RBi(4);
|
||||
|
||||
public void W(int val, byte Bits)
|
||||
public void W(int val, byte bits)
|
||||
{
|
||||
val &= (1 << Bits) - 1;
|
||||
BitWrite += Bits;
|
||||
TempBitWrite = 8 - BitWrite;
|
||||
if (TempBitWrite < 0)
|
||||
cW();
|
||||
val &= (1 << bits) - 1;
|
||||
bitWrite += bits;
|
||||
tempBitWrite = 8 - bitWrite;
|
||||
if (tempBitWrite < 0)
|
||||
{
|
||||
BitWrite = (byte)-TempBitWrite;
|
||||
TempBitWrite = 8 + TempBitWrite;
|
||||
s.WriteByte((byte)(ValWrite | (val >> BitWrite)));
|
||||
ValWrite = 0;
|
||||
bitWrite = (byte)-tempBitWrite;
|
||||
tempBitWrite = 8 + tempBitWrite;
|
||||
s.WriteByte((byte)(valWrite | (val >> bitWrite)));
|
||||
valWrite = 0;
|
||||
}
|
||||
ValWrite |= val << TempBitWrite;
|
||||
ValWrite &= 0xFF;
|
||||
valWrite |= val << tempBitWrite;
|
||||
valWrite &= 0xFF;
|
||||
}
|
||||
|
||||
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; }
|
||||
public byte[] ToArray(bool close)
|
||||
{ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2018-2019</Copyright>
|
||||
<Description>A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT files</Description>
|
||||
<FileVersion>0.4.8.1</FileVersion>
|
||||
<Copyright>korenkonder © 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.2</FileVersion>
|
||||
<PackageId>KKdMainLib</PackageId>
|
||||
<Product>KKdMainLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdMainLib</Title>
|
||||
<Version>0.4.8.1</Version>
|
||||
<Version>0.4.9.2</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
+68
-83
@@ -1,8 +1,9 @@
|
||||
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
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace KKdMainLib
|
||||
{
|
||||
public const string TimeFormatHHmmssfff = "{0:d2}:{1:d2}:{2:d2}.{3:d3}";
|
||||
|
||||
public static void WriteTime(this TimeSpan time, bool writeLine = false)
|
||||
public static void WT(this TimeSpan time, bool writeLine = false)
|
||||
{
|
||||
if (writeLine) Console.WriteLine(TimeFormatHHmmssfff,
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
@@ -18,15 +19,15 @@ namespace KKdMainLib
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
}
|
||||
|
||||
public static void WriteTime(this TimeSpan time, string Text, bool writeLine = true)
|
||||
public static void WT(this TimeSpan time, string text, bool writeLine = true)
|
||||
{
|
||||
if (writeLine) Console.WriteLine(TimeFormatHHmmssfff + " - " + Text,
|
||||
if (writeLine) Console.WriteLine(TimeFormatHHmmssfff + " - " + text,
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
else Console.Write (TimeFormatHHmmssfff + " - " + Text,
|
||||
else Console.Write (TimeFormatHHmmssfff + " - " + text,
|
||||
time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
}
|
||||
|
||||
public static string NullTerminated(this string source, ref int i, byte end)
|
||||
public static string NT(this string source, ref int i, byte end)
|
||||
{
|
||||
string s = "";
|
||||
while (true)
|
||||
@@ -38,14 +39,12 @@ namespace KKdMainLib
|
||||
return s;
|
||||
}
|
||||
|
||||
public static bool StartsWith(this Dictionary<string, object> dict, string args, char split = '.') =>
|
||||
dict.StartsWith(args.Split(split));
|
||||
public static bool SW(this A3DADict dict, string args, char split = '.') =>
|
||||
dict.SW(args.Split(split));
|
||||
|
||||
public static bool StartsWith(this Dictionary<string, object> dict, string[] args)
|
||||
public static bool SW(this A3DADict dict, string[] args)
|
||||
{
|
||||
Dictionary<string, object> bufDict = new Dictionary<string, object>();
|
||||
if (dict == null) return false;
|
||||
else if (args.Length < 1) return false;
|
||||
if (dict == null || args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (args.Length > 1)
|
||||
@@ -53,82 +52,63 @@ namespace KKdMainLib
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
for (int i = 0; i < args.Length - 1; i++)
|
||||
newArgs[i] = args[i + 1];
|
||||
if (!dict.ContainsKey(args[0]))
|
||||
return false;
|
||||
bufDict = (Dictionary<string, object>)dict[args[0]];
|
||||
return StartsWith(bufDict, newArgs);
|
||||
return dict.ContainsKey(args[0]) ? SW((A3DADict)dict[args[0]], newArgs) : false;
|
||||
}
|
||||
return dict.ContainsKey(args[0]);
|
||||
}
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
ref bool value, char split, string args) =>
|
||||
dict.FindValue(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) : false;
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
ref int value, char split, string args) =>
|
||||
dict.FindValue(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) : false;
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
ref float value, char split, string args) =>
|
||||
dict.FindValue(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) : false;
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
ref double value, char split, string args) =>
|
||||
dict.FindValue(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) : false;
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> Dict,
|
||||
ref string value, char split, string args)
|
||||
{ if (Dict.FindValue(out string val, args.Split(split)))
|
||||
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; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
out bool value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
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 FindValue(this Dictionary<string, object> Dict,
|
||||
out int value, string args)
|
||||
{ if (Dict.FindValue(out string val, args.Split('.' )))
|
||||
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; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
out float value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
return val.ToF32(out value); value = 0; 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 = 0; return false; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
out double value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
return val.ToF64(out value); value = 0; 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 = 0; return false; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
out int? value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
public static bool FV(this A3DADict dict, out int? value, string args)
|
||||
{ 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 FindValue(this Dictionary<string, object> dict,
|
||||
out float? value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
return val.ToF32(out value); 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; }
|
||||
|
||||
public static bool FindValue(this Dictionary<string, object> dict,
|
||||
out double? value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
return val.ToF64(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 FindValue(this Dictionary<string, object> dict,
|
||||
out string value, string args)
|
||||
{ if (dict.FindValue(out string val, args.Split('.' )))
|
||||
{ value = val; return true; } 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 FindValue(this Dictionary<string, object> dict,
|
||||
out string value, string[] args)
|
||||
public static bool FV(this A3DADict dict, out string value, string[] args)
|
||||
{
|
||||
value = "";
|
||||
if (dict == null) return false;
|
||||
else if (args.Length < 1) return false;
|
||||
value = null;
|
||||
if (dict == null || args.Length < 1) return false;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
if (!dict.ContainsKey(args[0])) return false;
|
||||
@@ -136,12 +116,12 @@ namespace KKdMainLib
|
||||
{
|
||||
string[] newArgs = new string[args.Length - 1];
|
||||
for (int i = 0; i < args.Length - 1; i++) newArgs[i] = args[i + 1];
|
||||
return ((Dictionary<string, object>)dict[args[0]]).FindValue(out value, newArgs);
|
||||
return ((A3DADict)dict[args[0]]).FV(out value, newArgs);
|
||||
}
|
||||
else if (args.Length == 1)
|
||||
{
|
||||
if (dict[args[0]].GetType() == dict.GetType())
|
||||
return ((Dictionary<string, object>)dict[args[0]]).FindValue(out value, args);
|
||||
return ((A3DADict)dict[args[0]]).FV(out value, args);
|
||||
else if (dict[args[0]].GetType() != typeof(string)) return false;
|
||||
}
|
||||
|
||||
@@ -149,15 +129,20 @@ namespace KKdMainLib
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void GetDictionary(this Dictionary<string, object> dict,
|
||||
string args, string value, char split = '.') =>
|
||||
dict.GetDictionary(args.Split(split), value);
|
||||
|
||||
public static void GetDictionary(this Dictionary<string, object> dict,
|
||||
string[] args, string value)
|
||||
public static void GD(this A3DADict dict, string args, char split = '.')
|
||||
{
|
||||
Dictionary<string, object> bufDict = new Dictionary<string, object>();
|
||||
if (dict == null) dict = new Dictionary<string, object>();
|
||||
string[] dataArray = args.Split('=');
|
||||
if (dataArray.Length == 2)
|
||||
dict.GD(dataArray[0].Split(split), dataArray[1]);
|
||||
dataArray = null;
|
||||
}
|
||||
|
||||
public static void GD(this A3DADict dict, string args, string value, char split = '.') =>
|
||||
dict.GD(args.Split(split), value);
|
||||
|
||||
public static void GD(this A3DADict dict, string[] args, string value)
|
||||
{
|
||||
if (dict == null) dict = new A3DADict();
|
||||
else if (args.Length < 1) return;
|
||||
|
||||
args[0] = args[0].ToLower();
|
||||
@@ -169,23 +154,23 @@ namespace KKdMainLib
|
||||
if (dict[args[0]] != null)
|
||||
{
|
||||
if (dict[args[0]].GetType() == typeof(string))
|
||||
dict[args[0]] = new Dictionary<string, object> { { "", dict[args[0]] } };
|
||||
dict[args[0]] = new A3DADict { { "", dict[args[0]] } };
|
||||
}
|
||||
else dict[args[0]] = new Dictionary<string, object>();
|
||||
bufDict = (Dictionary<string, object>)dict[args[0]];
|
||||
bufDict.GetDictionary(newArgs, value);
|
||||
else dict[args[0]] = new A3DADict();
|
||||
A3DADict bufDict = (A3DADict)dict[args[0]];
|
||||
bufDict.GD(newArgs, value);
|
||||
dict[args[0]] = bufDict;
|
||||
}
|
||||
else if (!dict.ContainsKey(args[0])) dict.Add(args[0], value);
|
||||
}
|
||||
|
||||
public static TKey GetKey<TKey, TVal>(this Dictionary<TKey, TVal> dict, TVal val) =>
|
||||
public static TKey GK<TKey, TVal>(this Dictionary<TKey, TVal> dict, TVal val) =>
|
||||
dict.First((System.Collections.Generic.KeyValuePair<TKey, TVal> x) => x.Value.Equals(val)).Key;
|
||||
|
||||
public static string ToTitleCase(this string s)
|
||||
{ return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s); }
|
||||
public static string TTC(this string s) =>
|
||||
CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s);
|
||||
|
||||
public static int[] SortWriter(this int length)
|
||||
public static int[] SW(this int length)
|
||||
{
|
||||
int i = 0;
|
||||
List<string> A = new List<string>();
|
||||
|
||||
+24
-18
@@ -1,11 +1,11 @@
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
//Original: https://github.com/blueskythlikesclouds/MikuMikuLibrary/
|
||||
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct Mot
|
||||
public struct Mot : System.IDisposable
|
||||
{
|
||||
private int i, i0, i1;
|
||||
public MotHeader[] MOT;
|
||||
@@ -57,7 +57,6 @@ namespace KKdMainLib
|
||||
for (i0 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
if (i0 % 8 == 0) i1 = _IO.RU16();
|
||||
|
||||
mot.KeySet.V[i0] = new KeySet { Type = (KeySetType)((i1 >> (i0 % 8 * 2)) & 0b11) };
|
||||
}
|
||||
|
||||
@@ -94,7 +93,7 @@ namespace KKdMainLib
|
||||
public void MOTWriter(string file)
|
||||
{
|
||||
if (MOT == null) return;
|
||||
_IO = File.OpenWriter(file + ".bin");
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
|
||||
int MOTCount = MOT.Length;
|
||||
_IO.P = (MOTCount + 1) << 4;
|
||||
@@ -113,8 +112,8 @@ namespace KKdMainLib
|
||||
if (i0 % 8 == 7) { _IO.W((ushort)i1); i1 = 0; }
|
||||
}
|
||||
_IO.W((ushort)i1);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
|
||||
_IO.A(0x4);
|
||||
mot.KeySetOffset = _IO.P;
|
||||
for (i0 = 0; i0 < mot.KeySet.V.Length; i0++)
|
||||
{
|
||||
@@ -125,8 +124,8 @@ namespace KKdMainLib
|
||||
{
|
||||
_IO.W((ushort)key.Keys.Length);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W(key.Keys[i1].F);
|
||||
_IO.A(0x4);
|
||||
_IO.W((ushort)key.Keys[i1].F);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W(key.Keys[i1].V);
|
||||
}
|
||||
@@ -134,19 +133,20 @@ namespace KKdMainLib
|
||||
{
|
||||
_IO.W((ushort)key.Keys.Length);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
_IO.W(key.Keys[i1].F);
|
||||
_IO.A(0x4);
|
||||
_IO.W((ushort)key.Keys[i1].F);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
for (i1 = 0; i1 < key.Keys.Length; i1++)
|
||||
{ _IO.W(key.Keys[i1].V); _IO.W(key.Keys[i1].T); }
|
||||
}
|
||||
}
|
||||
_IO.A(0x4);
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
|
||||
mot.BoneInfo.O = _IO.P;
|
||||
for (i0 = 0; i0 < mot.BoneInfo.V.Length; i0++)
|
||||
_IO.W((ushort)mot.BoneInfo.V[i0].Id);
|
||||
_IO.W((ushort)0);
|
||||
}
|
||||
if (_IO.P % 4 != 0) _IO.W((ushort)0x00);
|
||||
_IO.A(0x4, true);
|
||||
|
||||
_IO.P = 0;
|
||||
@@ -215,9 +215,9 @@ namespace KKdMainLib
|
||||
else if (temp1.Array[0].Array == null) continue;
|
||||
else if (temp1.Array[0].Array.Length == 0) continue;
|
||||
else if (temp1.Array[0].Array.Length == 1)
|
||||
keySet.Keys[0] = new KFT2 (temp1.Array[0][0].RF32());
|
||||
keySet.Keys[0] = new KFT2(temp1.Array[0][0].RF32());
|
||||
else if (temp1.Array[0].Array.Length > 1)
|
||||
keySet.Keys[0] = new KFT2 (temp1.Array[0][0].RF32(), temp1.Array[1].RF32());
|
||||
keySet.Keys[0] = new KFT2(temp1.Array[0][0].RF32(), temp1.Array[0][1].RF32());
|
||||
}
|
||||
else if (keySet.Type == KeySetType.Linear)
|
||||
{
|
||||
@@ -228,9 +228,9 @@ namespace KKdMainLib
|
||||
if (array.Array == null) continue;
|
||||
else if (array.Array.Length == 0) continue;
|
||||
else if (array.Array.Length == 1)
|
||||
keySet.Keys[i1] = new KFT2 (array[0].RF32());
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32());
|
||||
else if (array.Array.Length == 2)
|
||||
keySet.Keys[i1] = new KFT2 (array[0].RF32(), array[1].RF32());
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32(), array[1].RF32());
|
||||
}
|
||||
}
|
||||
else if (keySet.Type == KeySetType.Interpolated)
|
||||
@@ -242,11 +242,11 @@ namespace KKdMainLib
|
||||
if (array.Array == null ||
|
||||
array.Array.Length == 0) continue;
|
||||
else if (array.Array.Length == 1)
|
||||
keySet.Keys[i1] = new KFT2 (array[0].RF32());
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32());
|
||||
else if (array.Array.Length == 2)
|
||||
keySet.Keys[i1] = new KFT2 (array[0].RF32(), array[1].RF32());
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32(), array[1].RF32());
|
||||
else if (array.Array.Length > 2)
|
||||
keySet.Keys[i1] = new KFT2 (array[0].RF32(),
|
||||
keySet.Keys[i1] = new KFT2(array[0].RF32(),
|
||||
array[1].RF32(), temp1.Array[i1][2].RF32());
|
||||
}
|
||||
}
|
||||
@@ -313,6 +313,12 @@ namespace KKdMainLib
|
||||
return mot;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_IO = null;
|
||||
MOT = null;
|
||||
}
|
||||
|
||||
public struct MotHeader
|
||||
{
|
||||
public int KeySetOffset;
|
||||
@@ -330,7 +336,7 @@ namespace KKdMainLib
|
||||
public KeySetType Type;
|
||||
|
||||
public override string ToString() => $"Type: {Type}" + (Type == KeySetType.Static ?
|
||||
$"; Value: {Keys[0].Check()}" : Type > KeySetType.Static ? $"; Keys: {Keys.Length}" : "");
|
||||
$"; Value: {Keys[0].V}" : Type > KeySetType.Static ? $"; Keys: {Keys.Length}" : "");
|
||||
}
|
||||
|
||||
public enum KeySetType : byte
|
||||
|
||||
@@ -0,0 +1,766 @@
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct MotHead : System.IDisposable
|
||||
{
|
||||
private int i, i0, i1;
|
||||
private Stream _IO;
|
||||
|
||||
public HeaderData Header;
|
||||
|
||||
public void MotHeadReader(string file)
|
||||
{
|
||||
_IO = File.OpenReader(file + ".bin");
|
||||
_IO.RI32();
|
||||
Header = new HeaderData();
|
||||
|
||||
int offset = _IO.RI32();
|
||||
if (offset < 0x10) goto RETURN;
|
||||
_IO.O = offset;
|
||||
_IO.P = 0;
|
||||
|
||||
Header. MotionSetID = _IO.RI32();
|
||||
Header.StartMotionID = _IO.RI32();
|
||||
Header. EndMotionID = _IO.RI32();
|
||||
Header.SubHeaderOffset = _IO.RI32();
|
||||
|
||||
if (Header.SubHeaderOffset < 0x10) goto RETURN;
|
||||
i0 = Header.EndMotionID - Header.StartMotionID;
|
||||
if (i0 < 0) goto RETURN;
|
||||
|
||||
_IO.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++)
|
||||
{
|
||||
if (Header.Data[i].Offset < 0x10) continue;
|
||||
|
||||
_IO.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();
|
||||
|
||||
if (Header.Data[i].DataHeaderOffset < 0x10) goto RETURN;
|
||||
_IO.P = Header.Data[i].DataHeaderOffset;
|
||||
i0 = 0;
|
||||
while (_IO.RI32() != -1) { _IO.RI32(); _IO.RI32(); i0++; }
|
||||
_IO.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();
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
if (Header.Data[i].Offset2 > 0x10)
|
||||
{
|
||||
_IO.P = Header.Data[i].Offset2;
|
||||
i0 = 0;
|
||||
while (_IO.RI32() != -1) { _IO.RI32(); i0++; }
|
||||
_IO.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();
|
||||
}
|
||||
|
||||
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;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (Header.Data[i].Array == null || Header.Data[i].Array.Length < 1) continue;
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
ref HeaderData.Sub.Data Data = ref Header.Data[i].Array[i0];
|
||||
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() };
|
||||
else
|
||||
{
|
||||
Data.Array = new int[i1 / 4];
|
||||
for (i1 = 0; i1 < Data.Array.Length; i1++) Data.Array[i1] = _IO.RI32();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RETURN:
|
||||
_IO.C();
|
||||
}
|
||||
|
||||
public void MotHeadWriter(string file)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.Length < 1) return;
|
||||
|
||||
Header.StartMotionID = 0x7FFFFFFF;
|
||||
Header.EndMotionID = 0x00000000;
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
if (Header.Data[i].MotionID < Header.StartMotionID)
|
||||
Header.StartMotionID = Header.Data[i].MotionID;
|
||||
if (Header.Data[i].MotionID > Header. EndMotionID)
|
||||
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);
|
||||
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;
|
||||
Header.Data[i].DataHeaderOffset = Header.Data[i].Offset + 0x20;
|
||||
_IO.W(0L);
|
||||
_IO.W(0L);
|
||||
_IO.W(0L);
|
||||
_IO.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);
|
||||
|
||||
for (i0 = Header.Data[i].Array.Length - 1; i0 > -1; i0--)
|
||||
{
|
||||
ref HeaderData.Sub.Data data = ref Header.Data[i].Array[i0];
|
||||
int Size = GetSize(data.Type);
|
||||
if (data.Array == null || data.Array.Length < 1 || Size < 1) continue;
|
||||
|
||||
if (data.Type == 0x3E) _IO.A(0x20, true);
|
||||
data.Offset = _IO.P;
|
||||
|
||||
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;
|
||||
|
||||
data.Offset = _IO.P;
|
||||
for (i1 = 0; i1 < data.Array.Length && i1 < Size; i1++)
|
||||
_IO.W(data.Array[i1]);
|
||||
|
||||
for (; i1 < Size; i1++) _IO.W(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Header.Data[i].Array2 != null)
|
||||
if (Header.Data[i].Array2.Length > 0)
|
||||
{
|
||||
Header.Data[i].Offset2 = _IO.P;
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{ _IO.W( 0); _IO.W(0); }
|
||||
_IO.W(-1); _IO.W(0);
|
||||
|
||||
for (i0 = Header.Data[i].Array2.Length - 1; i0 > -1; i0--)
|
||||
{
|
||||
Header.Data[i].Array2[i0].Offset = _IO.P;
|
||||
for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length && i1 < 7; i1++)
|
||||
_IO.W(Header.Data[i].Array2[i0].Array[i1]);
|
||||
|
||||
for (; i1 < 7; i1++) _IO.W(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
_IO.A(0x20, true);
|
||||
Header.SubHeaderOffset = _IO.P;
|
||||
i1 = Header.EndMotionID - Header.StartMotionID;
|
||||
|
||||
int offset = 0;
|
||||
for (i = 0, i1++; i < i1; i++)
|
||||
{
|
||||
offset = 0;
|
||||
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);
|
||||
}
|
||||
_IO.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);
|
||||
|
||||
_IO.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);
|
||||
}
|
||||
|
||||
_IO.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);
|
||||
}
|
||||
}
|
||||
|
||||
_IO.P = 0;
|
||||
_IO.W(Header.MotionSetID );
|
||||
_IO.W(Header.StartMotionID );
|
||||
_IO.W(Header. EndMotionID );
|
||||
_IO.W(Header.SubHeaderOffset);
|
||||
_IO.C();
|
||||
}
|
||||
|
||||
public void MsgPackReader(string file, bool json)
|
||||
{
|
||||
Header = new HeaderData();
|
||||
|
||||
MsgPack motHead;
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
if ((motHead = msgPack["MotHead"]).IsNull) return;
|
||||
Header.MotionSetID = motHead.RI32("MotionSetID");
|
||||
|
||||
MsgPack temp = MsgPack.New;
|
||||
MsgPack motions, array;
|
||||
if ((motions = motHead["Motions", true]).IsNull) return;
|
||||
Header.Data = new HeaderData.Sub[motions.Array.Length];
|
||||
for (i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
Header.Data[i].MotionID = motions[i].RI32("MotionID");
|
||||
Header.Data[i].SomeData = motions[i].RI32("SomeData");
|
||||
|
||||
MsgPack array2;
|
||||
if ((array2 = motions[i]["Array2", true]).NotNull)
|
||||
{
|
||||
Header.Data[i].Array2 = new HeaderData.Sub.Data2[array2.Array.Length];
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{
|
||||
Header.Data[i].Array2[i0].Frame = array2[i0].RI32("Frame");
|
||||
|
||||
MsgPack arrayArray;
|
||||
if ((arrayArray = array2[i0]["Array", true]).IsNull) continue;
|
||||
|
||||
Header.Data[i].Array2[i0].Array = new int[arrayArray.Array.Length];
|
||||
for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length; i1++)
|
||||
Header.Data[i].Array2[i0].Array[i1] = arrayArray[i1].RI32();
|
||||
}
|
||||
}
|
||||
|
||||
if ((array = motions[i]["Array", true]).IsNull) { continue; }
|
||||
|
||||
Header.Data[i].Array = new HeaderData.Sub.Data[array.Array.Length];
|
||||
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
ref HeaderData.Sub.Data data = ref Header.Data[i].Array[i0];
|
||||
data.Type = array[i0].RI32("Type");
|
||||
data.Frame = array[i0].RI32("Frame");
|
||||
|
||||
if ((temp = array[i0]["Type3"]).NotNull)
|
||||
{
|
||||
data.Type = 0x03;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type53"]).NotNull)
|
||||
{
|
||||
data.Type = 0x35;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type54"]).NotNull)
|
||||
{
|
||||
data.Type = 0x36;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type55"]).NotNull)
|
||||
{
|
||||
data.Type = 0x37;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type56"]).NotNull)
|
||||
{
|
||||
data.Type = 0x38;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type57"]).NotNull)
|
||||
{
|
||||
data.Type = 0x39;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type60"]).NotNull)
|
||||
{
|
||||
data.Type = 0x3C;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RF32("f3").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type61"]).NotNull)
|
||||
{
|
||||
data.Type = 0x3D;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RF32("f1").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type62"]).NotNull)
|
||||
{
|
||||
data.Type = 0x3E;
|
||||
data.Array = new int[0x10];
|
||||
data.Array[ 0] = temp.RI32("i0");
|
||||
data.Array[ 1] =
|
||||
((byte)temp.RI32("i1_3") << 24) | ((byte)temp.RI32("i1_2") << 16) |
|
||||
((byte)temp.RI32("i1_1") << 8) | (byte)temp.RI32("i1_0");
|
||||
data.Array[ 2] = temp.RF32("f2" ).ToI32();
|
||||
data.Array[ 3] = temp.RF32("f3" ).ToI32();
|
||||
data.Array[ 4] = temp.RF32("f4" ).ToI32();
|
||||
data.Array[ 5] = temp.RF32("f5" ).ToI32();
|
||||
data.Array[ 6] = temp.RF32("f6" ).ToI32();
|
||||
data.Array[ 7] = temp.RF32("f7" ).ToI32();
|
||||
data.Array[ 8] = temp.RF32("f8" ).ToI32();
|
||||
data.Array[ 9] = temp.RF32("f9" ).ToI32();
|
||||
data.Array[10] = temp.RF32("f10").ToI32();
|
||||
data.Array[11] = temp.RF32("f11").ToI32();
|
||||
data.Array[12] = temp.RF32("f12").ToI32();
|
||||
data.Array[13] = temp.RF32("f13").ToI32();
|
||||
data.Array[14] = temp.RF32("f14").ToI32();
|
||||
data.Array[15] = temp.RI32("i15");
|
||||
}
|
||||
else if ((temp = array[i0]["Type65"]).NotNull)
|
||||
{
|
||||
data.Type = 0x41;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type66"]).NotNull)
|
||||
{
|
||||
data.Type = 0x42;
|
||||
data.Array = new int[] { temp.RF32("f0").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type67"]).NotNull)
|
||||
{
|
||||
data.Type = 0x43;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RF32("f1").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type68"]).NotNull)
|
||||
{
|
||||
data.Type = 0x44;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RF32("f1").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type69"]).NotNull)
|
||||
{
|
||||
data.Type = 0x45;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RI32("i1") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type70"]).NotNull)
|
||||
{
|
||||
data.Type = 0x46;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type71"]).NotNull)
|
||||
{
|
||||
data.Type = 0x47;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RF32("f1").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type72"]).NotNull)
|
||||
{
|
||||
data.Type = 0x48;
|
||||
data.Array = new int[] { temp.RI32("i0"), temp.RF32("f1").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type73"]).NotNull)
|
||||
{
|
||||
data.Type = 0x49;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RI32("i2"),
|
||||
temp.RF32("f3").ToI32() };
|
||||
}
|
||||
else if ((temp = array[i0]["Type74"]).NotNull)
|
||||
{
|
||||
data.Type = 0x4A;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type62"]).NotNull)
|
||||
{
|
||||
data.Type = 0x4B;
|
||||
data.Array = new int[0x0D];
|
||||
data.Array[ 0] = temp.RI32("i0");
|
||||
data.Array[ 1] = ((byte)temp.RI32("i1_1") << 8) | (byte)temp.RI32("i1_0");
|
||||
data.Array[ 2] = temp.RF32("f2" ).ToI32();
|
||||
data.Array[ 3] = temp.RF32("f3" ).ToI32();
|
||||
data.Array[ 4] = temp.RF32("f4" ).ToI32();
|
||||
data.Array[ 5] = temp.RF32("f5" ).ToI32();
|
||||
data.Array[ 6] = temp.RF32("f6" ).ToI32();
|
||||
data.Array[ 7] = temp.RF32("f7" ).ToI32();
|
||||
data.Array[ 8] = temp.RF32("f8" ).ToI32();
|
||||
data.Array[ 9] = temp.RF32("f9" ).ToI32();
|
||||
data.Array[10] = temp.RF32("f10").ToI32();
|
||||
data.Array[11] = temp.RF32("f11").ToI32();
|
||||
data.Array[12] = temp.RF32("f12").ToI32();
|
||||
}
|
||||
else if ((temp = array[i0]["Type76"]).NotNull)
|
||||
{
|
||||
data.Type = 0x4C;
|
||||
data.Array = new int[] { temp.RI32("i0"),
|
||||
temp.RF32("f1").ToI32(),
|
||||
temp.RF32("f2").ToI32(),
|
||||
temp.RI32("i3") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type77"]).NotNull)
|
||||
{
|
||||
data.Type = 0x4D;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type79"]).NotNull)
|
||||
{
|
||||
data.Type = 0x4F;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Type80"]).NotNull)
|
||||
{
|
||||
data.Type = 0x50;
|
||||
data.Array = new int[] { temp.RI32("i0") };
|
||||
}
|
||||
else if ((temp = array[i0]["Array", true]).NotNull)
|
||||
{
|
||||
data.Array = new int[temp.Array.Length];
|
||||
for (i1 = 0; i1 < data.Array.Length; i1++)
|
||||
data.Array[i1] = temp[i1].RI32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
if (Header.Data == null || Header.Data.Length < 1) return;
|
||||
|
||||
for (i = 0, i1 = 0; i < Header.Data.Length; i++)
|
||||
if (Header.Data[i].Offset >= 0x10) i1++;
|
||||
MsgPack motHead = new MsgPack("MotHead").Add("MotionSetID", Header.MotionSetID);
|
||||
MsgPack motions = new MsgPack(i1, "Motions");
|
||||
for (int I = 0, i = 0; i < Header.Data.Length; i++)
|
||||
{
|
||||
if (Header.Data[i].Offset < 0x10) continue;
|
||||
MsgPack motion = MsgPack.New
|
||||
.Add("MotionID", Header.Data[i].MotionID)
|
||||
.Add("SomeData", Header.Data[i].SomeData);
|
||||
|
||||
if (Header.Data[i].Array == null || Header.Data[i].Array.Length < 1) { }
|
||||
else
|
||||
{
|
||||
MsgPack array = new MsgPack(Header.Data[i].Array.Length, "Array");
|
||||
for (i0 = 0; i0 < Header.Data[i].Array.Length; i0++)
|
||||
{
|
||||
ref HeaderData.Sub.Data data = ref Header.Data[i].Array[i0];
|
||||
MsgPack arrayEntry = MsgPack.New;
|
||||
arrayEntry.Add("Frame", data.Frame);
|
||||
if (data.Array == null || data.Array.Length < 1)
|
||||
arrayEntry.Add("Type", data.Type);
|
||||
else if (data.Type == 0x03)
|
||||
arrayEntry.Add(new MsgPack("Type3")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x35)
|
||||
arrayEntry.Add(new MsgPack("Type53")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x36)
|
||||
arrayEntry.Add(new MsgPack("Type54")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x37)
|
||||
arrayEntry.Add(new MsgPack("Type55")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x38)
|
||||
arrayEntry.Add(new MsgPack("Type56")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x39)
|
||||
arrayEntry.Add(new MsgPack("Type57")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x3C)
|
||||
arrayEntry.Add(new MsgPack("Type60")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("f3", data.Array[3].ToF32()));
|
||||
else if (data.Type == 0x3D)
|
||||
arrayEntry.Add(new MsgPack("Type61")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32()));
|
||||
else if (data.Type == 0x3E)
|
||||
arrayEntry.Add(new MsgPack("Type62")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("i1_0", (byte) data.Array[1])
|
||||
.Add("i1_1", (byte)(data.Array[1] >> 8))
|
||||
.Add("i1_2", (byte)(data.Array[1] >> 16))
|
||||
.Add("i1_3", (byte)(data.Array[1] >> 24))
|
||||
.Add("f2" , data.Array[ 2].ToF32())
|
||||
.Add("f3" , data.Array[ 3].ToF32())
|
||||
.Add("f4" , data.Array[ 4].ToF32())
|
||||
.Add("f5" , data.Array[ 5].ToF32())
|
||||
.Add("f6" , data.Array[ 6].ToF32())
|
||||
.Add("f7" , data.Array[ 7].ToF32())
|
||||
.Add("f8" , data.Array[ 8].ToF32())
|
||||
.Add("f9" , data.Array[ 9].ToF32())
|
||||
.Add("f10", data.Array[10].ToF32())
|
||||
.Add("f11", data.Array[11].ToF32())
|
||||
.Add("f12", data.Array[12].ToF32())
|
||||
.Add("f13", data.Array[13].ToF32())
|
||||
.Add("f14", data.Array[14].ToF32())
|
||||
.Add("i15", data.Array[15]));
|
||||
else if (data.Type == 0x41)
|
||||
arrayEntry.Add(new MsgPack("Type65")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x42)
|
||||
arrayEntry.Add(new MsgPack("Type66")
|
||||
.Add("f0", data.Array[0].ToF32()));
|
||||
else if (data.Type == 0x43)
|
||||
arrayEntry.Add(new MsgPack("Type67")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32()));
|
||||
else if (data.Type == 0x44)
|
||||
arrayEntry.Add(new MsgPack("Type68")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32()));
|
||||
else if (data.Type == 0x45)
|
||||
arrayEntry.Add(new MsgPack("Type69")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("i1", data.Array[1]));
|
||||
else if (data.Type == 0x46)
|
||||
arrayEntry.Add(new MsgPack("Type70")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x47)
|
||||
arrayEntry.Add(new MsgPack("Type71")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32()));
|
||||
else if (data.Type == 0x48)
|
||||
arrayEntry.Add(new MsgPack("Type72")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32()));
|
||||
else if (data.Type == 0x49)
|
||||
arrayEntry.Add(new MsgPack("Type73")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("i2", (short)data.Array[2])
|
||||
.Add("f3", data.Array[3].ToF32()));
|
||||
else if (data.Type == 0x4A)
|
||||
arrayEntry.Add(new MsgPack("Type74")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x4B)
|
||||
arrayEntry.Add(new MsgPack("Type75")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("i1_0", (byte) data.Array[1])
|
||||
.Add("i1_1", (byte)(data.Array[1] >> 8))
|
||||
.Add("f2" , data.Array[ 2].ToF32())
|
||||
.Add("f3" , data.Array[ 3].ToF32())
|
||||
.Add("f4" , data.Array[ 4].ToF32())
|
||||
.Add("f5" , data.Array[ 5].ToF32())
|
||||
.Add("f6" , data.Array[ 6].ToF32())
|
||||
.Add("f7" , data.Array[ 7].ToF32())
|
||||
.Add("f8" , data.Array[ 8].ToF32())
|
||||
.Add("f9" , data.Array[ 9].ToF32())
|
||||
.Add("f10", data.Array[10].ToF32())
|
||||
.Add("f11", data.Array[11].ToF32())
|
||||
.Add("f12", data.Array[12].ToF32()));
|
||||
else if (data.Type == 0x4C)
|
||||
arrayEntry.Add(new MsgPack("Type76")
|
||||
.Add("i0", data.Array[0])
|
||||
.Add("f1", data.Array[1].ToF32())
|
||||
.Add("f2", data.Array[2].ToF32())
|
||||
.Add("i3", data.Array[3]));
|
||||
else if (data.Type == 0x4D)
|
||||
arrayEntry.Add(new MsgPack("Type77")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x4F)
|
||||
arrayEntry.Add(new MsgPack("Type79")
|
||||
.Add("i0", data.Array[0]));
|
||||
else if (data.Type == 0x50)
|
||||
arrayEntry.Add(new MsgPack("Type80")
|
||||
.Add("i0", data.Array[0]));
|
||||
else
|
||||
{
|
||||
arrayEntry.Add("Type", data.Type);
|
||||
MsgPack arrayArray = new MsgPack(data.Array.Length, "Array");
|
||||
for (i1 = 0; i1 < data.Array.Length; i1++)
|
||||
arrayArray[i1] = data.Array[i1];
|
||||
arrayEntry.Add(arrayArray);
|
||||
}
|
||||
array[i0] = arrayEntry;
|
||||
}
|
||||
motion.Add(array);
|
||||
}
|
||||
|
||||
if (Header.Data[i].Array2 == null || Header.Data[i].Array2.Length < 1) { }
|
||||
else
|
||||
{
|
||||
MsgPack array2 = new MsgPack(Header.Data[i].Array2.Length, "Array2");
|
||||
for (i0 = 0; i0 < Header.Data[i].Array2.Length; i0++)
|
||||
{
|
||||
MsgPack arrayEntry = MsgPack.New.Add("Frame", Header.Data[i].Array2[i0].Frame);
|
||||
if (Header.Data[i].Array2[i0].Array == null || Header.Data[i].Array2[i0].Array.Length < 1) { }
|
||||
else
|
||||
{
|
||||
MsgPack arrayArray = new MsgPack(Header.Data[i].Array2[i0].Array.Length, "Array");
|
||||
for (i1 = 0; i1 < Header.Data[i].Array2[i0].Array.Length; i1++)
|
||||
arrayArray[i1] = Header.Data[i].Array2[i0].Array[i1];
|
||||
arrayEntry.Add(arrayArray);
|
||||
}
|
||||
array2[i0] = arrayEntry;
|
||||
}
|
||||
motion.Add(array2);
|
||||
}
|
||||
|
||||
motions[I] = motion;
|
||||
I++;
|
||||
}
|
||||
motHead.Add(motions);
|
||||
motHead.WriteAfterAll(true, file, json);
|
||||
}
|
||||
|
||||
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,
|
||||
0x40 => 0x00,
|
||||
0x41 => 0x04,
|
||||
0x42 => 0x04,
|
||||
0x43 => 0x08,
|
||||
0x44 => 0x08,
|
||||
0x45 => 0x08,
|
||||
0x46 => 0x04,
|
||||
0x47 => 0x08,
|
||||
0x48 => 0x08,
|
||||
0x49 => 0x10,
|
||||
0x4A => 0x02,
|
||||
0x4B => 0x34,
|
||||
0x4C => 0x10,
|
||||
0x4D => 0x04,
|
||||
0x4E => 0x1C,
|
||||
0x4F => 0x01,
|
||||
0x50 => 0x01,
|
||||
_ => 0x00,
|
||||
};
|
||||
|
||||
public void Dispose()
|
||||
{ if (_IO != null) _IO.D(); _IO = null; Header = default; }
|
||||
|
||||
public struct HeaderData
|
||||
{
|
||||
public int MotionSetID;
|
||||
public int StartMotionID;
|
||||
public int EndMotionID;
|
||||
public int SubHeaderOffset;
|
||||
|
||||
public Sub[] Data;
|
||||
|
||||
public struct Sub
|
||||
{
|
||||
public int Offset;
|
||||
public int MotionID;
|
||||
|
||||
public int SomeData;
|
||||
public int Offset2;
|
||||
public int DataHeaderOffset;
|
||||
|
||||
public Data[] Array;
|
||||
public Data2[] Array2;
|
||||
|
||||
public struct Data
|
||||
{
|
||||
public int Type;
|
||||
public int Frame;
|
||||
public int Offset;
|
||||
|
||||
public int[] Array;
|
||||
}
|
||||
|
||||
public struct Data2
|
||||
{
|
||||
public int Offset;
|
||||
|
||||
public int Frame;
|
||||
public int[] Array;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace KKdMainLib.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[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>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KKdMainLib.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] libdeflate {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("libdeflate", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="libdeflate" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\libdeflate.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib.F2;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace KKdMainLib
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{ if (!disposed) { if (_IO != null) _IO.Dispose(); Strings = default;
|
||||
{ if (!disposed) { if (_IO != null) _IO.D(); _IO = null; Strings = default;
|
||||
pof = default; header = default; disposed = true; } }
|
||||
|
||||
public struct String
|
||||
|
||||
@@ -0,0 +1,959 @@
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using TableDict = System.Collections.Generic.Dictionary<string, object>;
|
||||
|
||||
namespace KKdMainLib
|
||||
{
|
||||
public struct Tables : System.IDisposable
|
||||
{
|
||||
private int i0;
|
||||
private Stream _IO;
|
||||
private TableDict dict;
|
||||
|
||||
public ButtonSE[] ButtonSETable;
|
||||
public ChainSlideSE[] ChainSlideSETable;
|
||||
public SlideSE[] SlideSETable;
|
||||
public SliderTouchSE[] SliderTouchSETable;
|
||||
|
||||
public CollectionCard[] CollectionCardTable;
|
||||
public CustomizeItem[] CustomizeItemTable;
|
||||
public Module[] ModuleTable;
|
||||
public Plate[] PlateTable;
|
||||
public PV[] PVList;
|
||||
|
||||
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"));
|
||||
|
||||
public void BINReader(byte[] data)
|
||||
{
|
||||
ButtonSETable = null; ChainSlideSETable = null; SlideSETable = null; SliderTouchSETable = null;
|
||||
CollectionCardTable = null; CustomizeItemTable = null;
|
||||
ModuleTable = null; PlateTable = null; PVList = null;
|
||||
|
||||
dict = new TableDict();
|
||||
string[] strData = data.ToUTF8().Replace("\r\n", "\n").Replace("\r", "\n").Split('\n');
|
||||
for (i0 = 0; i0 < strData.Length; i0++)
|
||||
dict.GD(strData[i0]);
|
||||
strData = null;
|
||||
|
||||
int length;
|
||||
string name;
|
||||
if (dict.FV(out length, "btn_se.data_list.length"))
|
||||
{
|
||||
ButtonSETable = new ButtonSE[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "btn_se" + c + i0 + c;
|
||||
|
||||
ref ButtonSE btn = ref ButtonSETable[i0];
|
||||
dict.FV(out btn. ID , name + "id" );
|
||||
dict.FV(out btn. Name , name + "name" );
|
||||
dict.FV(out btn. SEName , name + "se_name" );
|
||||
dict.FV(out btn.SortIndex, name + "sort_index");
|
||||
|
||||
btn.Start = GetStartTableDate(dict, name);
|
||||
btn.End = GetEndTableDate(dict, name);
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "chainslide_se.data_list.length"))
|
||||
{
|
||||
ChainSlideSETable = new ChainSlideSE[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "chainslide_se" + c + i0 + c;
|
||||
|
||||
ref ChainSlideSE csld = ref ChainSlideSETable[i0];
|
||||
dict.FV(out csld. ID , name + "id" );
|
||||
dict.FV(out csld. Name , name + "name" );
|
||||
dict.FV(out csld. FirstSEName , name + "first_se_name" );
|
||||
dict.FV(out csld.FailureSEName , name + "failure_se_name" );
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "collection_card.data_list.length"))
|
||||
{
|
||||
CollectionCardTable = new CollectionCard[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "collection_card" + c + i0 + c;
|
||||
|
||||
ref CollectionCard clcrd = ref CollectionCardTable[i0];
|
||||
dict.FV(out clcrd.Chara , name + "chara" );
|
||||
dict.FV(out clcrd.DispNum , name + "disp_num" );
|
||||
dict.FV(out clcrd.DivaProParam, name + "divapro_param");
|
||||
dict.FV(out clcrd.ID , name + "id" );
|
||||
dict.FV(out clcrd.ModuleAuthor, name + "module_author");
|
||||
dict.FV(out clcrd.Name , name + "name" );
|
||||
dict.FV(out clcrd.NameReading , name + "name_reading" );
|
||||
dict.FV(out clcrd.NG , name + "ng" );
|
||||
dict.FV(out clcrd.SortIndex , name + "sort_idx" );
|
||||
dict.FV(out clcrd.Type , name + "type" );
|
||||
dict.FV(out clcrd.TypeParam , name + "type_param" );
|
||||
dict.FV(out clcrd.WallParam , name + "wall_param" );
|
||||
|
||||
clcrd.Start = GetStartTableDate(dict, name);
|
||||
clcrd.End = GetEndTableDate(dict, name);
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "cstm_item.data_list.length"))
|
||||
{
|
||||
CustomizeItemTable = new CustomizeItem[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "cstm_item" + c + i0 + c;
|
||||
|
||||
ref CustomizeItem czitm = ref CustomizeItemTable[i0];
|
||||
dict.FV(out czitm.Chara , name + "chara" );
|
||||
dict.FV(out czitm.ID , name + "id" );
|
||||
dict.FV(out czitm.Name , name + "name" );
|
||||
dict.FV(out czitm.NG , name + "ng" );
|
||||
dict.FV(out czitm.ObjID , name + "obj_id" );
|
||||
dict.FV(out czitm.Parts , name + "parts" );
|
||||
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_");
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "module.data_list.length"))
|
||||
{
|
||||
ModuleTable = new Module[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "module" + c + i0 + c;
|
||||
|
||||
ref Module mdl = ref ModuleTable[i0];
|
||||
dict.FV(out mdl.Attribute, name + "attr" );
|
||||
dict.FV(out mdl.Chara , name + "chara" );
|
||||
dict.FV(out mdl.Costume , name + "cos" );
|
||||
dict.FV(out mdl.ID , name + "id" );
|
||||
dict.FV(out mdl.Name , name + "name" );
|
||||
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_");
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "plate.data_list.length"))
|
||||
{
|
||||
PlateTable = new Plate[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "plate" + c + i0 + c;
|
||||
|
||||
ref Plate plt = ref PlateTable[i0];
|
||||
dict.FV(out plt.Alpha , name + "alpha" );
|
||||
dict.FV(out plt.BaseID , name + "base_id" );
|
||||
dict.FV(out plt.Border , name + "border" );
|
||||
dict.FV(out plt.ColorB , name + "color_b" );
|
||||
dict.FV(out plt.ColorG , name + "color_g" );
|
||||
dict.FV(out plt.ColorR , name + "color_r" );
|
||||
dict.FV(out plt.Font , name + "font" );
|
||||
dict.FV(out plt.ID , name + "id" );
|
||||
dict.FV(out plt.Shadow , name + "shadow" );
|
||||
dict.FV(out plt.ShadowAlpha , name + "shadow_alpha" );
|
||||
dict.FV(out plt.ShadowColorB, name + "shadow_color_b");
|
||||
dict.FV(out plt.ShadowColorG, name + "shadow_color_g");
|
||||
dict.FV(out plt.ShadowColorR, name + "shadow_color_r");
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "pv_list.data_list.length"))
|
||||
{
|
||||
PVList = new PV[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "pv_list" + c + i0 + c;
|
||||
|
||||
ref PV pv = ref PVList[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);
|
||||
pv.Hard = GetDifficulty(dict, name + "hard" + c);
|
||||
pv.Normal = GetDifficulty(dict, name + "normal" + c);
|
||||
}
|
||||
|
||||
static PV.Difficulty[] GetDifficulty(TableDict dict, string name)
|
||||
{
|
||||
int len, val;
|
||||
if (!dict.FV(out len, name + "length") || len < 0) return null;
|
||||
|
||||
PV.Difficulty[] arr = new PV.Difficulty[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (dict.FV(out val, $"{name}{i}.edition")) arr[i].Edition = val;
|
||||
if (dict.FV(out val, $"{name}{i}.ver" )) arr[i].Version = val;
|
||||
|
||||
arr[i].Start = GetStartTableDate(dict, $"{name}{i}.");
|
||||
arr[i].End = GetEndTableDate(dict, $"{name}{i}.");
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "slide_se.data_list.length"))
|
||||
{
|
||||
SlideSETable = new SlideSE[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "slide_se" + c + i0 + c;
|
||||
|
||||
ref SlideSE sld = ref SlideSETable[i0];
|
||||
dict.FV(out sld. ID , name + "id" );
|
||||
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);
|
||||
}
|
||||
}
|
||||
else if (dict.FV(out length, "slidertouch_se.data_list.length"))
|
||||
{
|
||||
SliderTouchSETable = new SliderTouchSE[length];
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "slidertouch_se" + c + i0 + c;
|
||||
|
||||
ref SliderTouchSE stld = ref SliderTouchSETable[i0];
|
||||
dict.FV(out stld. ID , name + "id" );
|
||||
dict.FV(out stld. Name , name + "name" );
|
||||
dict.FV(out stld. SEName , name + "se_name" );
|
||||
dict.FV(out stld.SortIndex, name + "sort_index");
|
||||
|
||||
stld.Start = GetStartTableDate(dict, name);
|
||||
stld.End = GetEndTableDate(dict, name);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
public void BINWriter(string file)
|
||||
{
|
||||
int[] so;
|
||||
int length;
|
||||
string name;
|
||||
|
||||
if (ButtonSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = ButtonSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, 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);
|
||||
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);
|
||||
}
|
||||
W("btn_se.data_list.length", length);
|
||||
_IO.W("kind=0\n");
|
||||
_IO.D();
|
||||
}
|
||||
else if (ChainSlideSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = ChainSlideSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, 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);
|
||||
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);
|
||||
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();
|
||||
}
|
||||
else if (CollectionCardTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = CollectionCardTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "collection_card" + c + so[i0] + c;
|
||||
|
||||
ref CollectionCard clcrd = ref CollectionCardTable[so[i0]];
|
||||
W(name + "chara" , clcrd.Chara );
|
||||
W(name + "disp_num" , clcrd.DispNum );
|
||||
W(name + "divapro_param", clcrd.DivaProParam);
|
||||
WriteEndTableDate(_IO, 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);
|
||||
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();
|
||||
}
|
||||
else if (CustomizeItemTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = CustomizeItemTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "cstm_item" + c + so[i0] + c;
|
||||
|
||||
ref CustomizeItem czitm = ref CustomizeItemTable[so[i0]];
|
||||
W(name + "chara" , czitm.Chara );
|
||||
W(name + "id" , czitm.ID );
|
||||
W(name + "name" , czitm.Name );
|
||||
W(name + "ng" , czitm.NG );
|
||||
W(name + "obj_id" , czitm.ObjID );
|
||||
W(name + "parts" , czitm.Parts );
|
||||
W(name + "sell_type" , czitm.SellType );
|
||||
WriteEndTableDate(_IO, name + "shop_", czitm.ShopEnd);
|
||||
W(name + "shop_price", czitm.ShopPrice);
|
||||
WriteStartTableDate(_IO, 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();
|
||||
}
|
||||
else if (ModuleTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = ModuleTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "module" + c + so[i0] + c;
|
||||
|
||||
ref Module mdl = ref ModuleTable[so[i0]];
|
||||
W(name + "attr" , mdl.Attribute);
|
||||
W(name + "chara" , mdl.Chara );
|
||||
W(name + "cos" , mdl.Costume );
|
||||
W(name + "id" , mdl.ID );
|
||||
W(name + "name" , mdl.Name );
|
||||
W(name + "ng" , mdl.NG );
|
||||
WriteEndTableDate(_IO, name + "shop_", mdl.ShopEnd);
|
||||
W(name + "shop_price", mdl.ShopPrice);
|
||||
WriteStartTableDate(_IO, name + "shop_", mdl.ShopStart);
|
||||
W(name + "sort_index", mdl.SortIndex);
|
||||
}
|
||||
W("module.data_list.length", length);
|
||||
_IO.D();
|
||||
}
|
||||
else if (PlateTable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = PlateTable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
for (i0 = 0; i0 < length; i0++)
|
||||
{
|
||||
name = "plate" + c + so[i0] + c;
|
||||
|
||||
ref Plate plt = ref PlateTable[so[i0]];
|
||||
W(name + "alpha" , plt.Alpha );
|
||||
W(name + "base_id" , plt.BaseID );
|
||||
W(name + "border" , plt.Border );
|
||||
W(name + "color_b" , plt.ColorB );
|
||||
W(name + "color_g" , plt.ColorG );
|
||||
W(name + "color_r" , plt.ColorR );
|
||||
W(name + "font" , plt.Font );
|
||||
W(name + "id" , plt.ID );
|
||||
W(name + "shadow" , plt.Shadow );
|
||||
W(name + "shadow_alpha" , plt.ShadowAlpha );
|
||||
W(name + "shadow_color_b", plt.ShadowColorB);
|
||||
W(name + "shadow_color_g", plt.ShadowColorG);
|
||||
W(name + "shadow_color_r", plt.ShadowColorR);
|
||||
}
|
||||
W("plate.data_list.length", length);
|
||||
_IO.D();
|
||||
}
|
||||
else if (PVList != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = PVList.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, 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);
|
||||
|
||||
WriteDifficulty(_IO, name + "easy.", pv.Easy );
|
||||
WriteDifficulty(_IO, name + "encore.", pv.Encore );
|
||||
WriteDifficulty(_IO, name + "extreme.", pv.Extreme);
|
||||
WriteDifficulty(_IO, 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 );
|
||||
}
|
||||
W("pv_list.data_list.length", length);
|
||||
_IO.D();
|
||||
|
||||
static void WriteDifficulty(Stream _IO, string name, PV.Difficulty[] arr)
|
||||
{
|
||||
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}.ver" + $"={diff.Version}\n");
|
||||
}
|
||||
_IO.W($"{name}.length={length}\n");
|
||||
}
|
||||
}
|
||||
else if (SlideSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = SlideSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
_IO.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);
|
||||
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);
|
||||
}
|
||||
W("slide_se.data_list.length", length);
|
||||
_IO.D();
|
||||
}
|
||||
else if (SliderTouchSETable != null)
|
||||
{
|
||||
_IO = File.OpenWriter(file + ".bin", true);
|
||||
length = SliderTouchSETable.Length;
|
||||
so = length.SW();
|
||||
WriteEmptyLines(_IO, length);
|
||||
_IO.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);
|
||||
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);
|
||||
}
|
||||
W("slidertouch_se.data_list.length", length);
|
||||
_IO.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");
|
||||
_IO.W(name + "ed_month" + "=" + date.Month + "\n");
|
||||
_IO.W(name + "ed_year" + "=" + date.Year + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void W(string Data, long val) =>
|
||||
_IO.W(Data + "=" + val + "\n");
|
||||
private void W(string Data, string val)
|
||||
{ if (val != null) _IO.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;
|
||||
|
||||
MsgPack msgPack = file.ReadMPAllAtOnce(json);
|
||||
MsgPack temp;
|
||||
if ((temp = msgPack["ButtonSETable", true]).NotNull)
|
||||
{
|
||||
ButtonSETable = new ButtonSE[temp.Array.Length];
|
||||
for (i0 = 0; i0 < ButtonSETable.Length; i0++)
|
||||
{
|
||||
MsgPack btnMP = temp[i0];
|
||||
ref ButtonSE btn = ref ButtonSETable[i0];
|
||||
btn.End .SV(btnMP.RnI32("End" ), true);
|
||||
btn.Start.SV(btnMP.RnI32("Start"), false);
|
||||
|
||||
btnMP.R( "ID" , out btn. ID );
|
||||
btnMP.R( "Name" , out btn. Name );
|
||||
btnMP.R( "SEName" , out btn. SEName );
|
||||
btnMP.R("SortIndex", out btn.SortIndex);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["ChainSlideSETable", true]).NotNull)
|
||||
{
|
||||
ChainSlideSETable = new ChainSlideSE[temp.Array.Length];
|
||||
for (i0 = 0; i0 < ChainSlideSETable.Length; i0++)
|
||||
{
|
||||
MsgPack csldMP = temp[i0];
|
||||
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 );
|
||||
csldMP.R( "Name" , out csld. Name );
|
||||
csldMP.R( "SortIndex", out csld. SortIndex);
|
||||
csldMP.R( "SubSEName" , out csld. SubSEName );
|
||||
csldMP.R("SuccessSEName" , out csld.SuccessSEName );
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["CollectionCardTable", true]).NotNull)
|
||||
{
|
||||
CollectionCardTable = new CollectionCard[temp.Array.Length];
|
||||
for (i0 = 0; i0 < CollectionCardTable.Length; i0++)
|
||||
{
|
||||
MsgPack clcrdMP = temp[i0];
|
||||
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);
|
||||
clcrdMP.R("ID" , out clcrd.ID );
|
||||
clcrdMP.R("ModuleAuthor", out clcrd.ModuleAuthor);
|
||||
clcrdMP.R("Name" , out clcrd.Name );
|
||||
clcrdMP.R("NameReading" , out clcrd.NameReading );
|
||||
clcrdMP.R("NG" , out clcrd.NG );
|
||||
clcrdMP.R("SortIndex" , out clcrd.SortIndex );
|
||||
clcrdMP.R("Type" , out clcrd.Type );
|
||||
clcrdMP.R("TypeParam" , out clcrd.TypeParam );
|
||||
clcrdMP.R("WallParam" , out clcrd.WallParam );
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["CustomizeItemTable", true]).NotNull)
|
||||
{
|
||||
CustomizeItemTable = new CustomizeItem[temp.Array.Length];
|
||||
for (i0 = 0; i0 < CustomizeItemTable.Length; i0++)
|
||||
{
|
||||
MsgPack czitmMP = temp[i0];
|
||||
ref CustomizeItem czitm = ref CustomizeItemTable[i0];
|
||||
czitm.ShopEnd .SV(czitmMP.RnI32("ShopEnd" ), true);
|
||||
czitm.ShopStart.SV(czitmMP.RnI32("ShopStart"), false);
|
||||
|
||||
czitmMP.R("Chara" , out czitm.Chara );
|
||||
czitmMP.R("ID" , out czitm.ID );
|
||||
czitmMP.R("Name" , out czitm.Name );
|
||||
czitmMP.R("NG" , out czitm.NG );
|
||||
czitmMP.R("ObjID" , out czitm.ObjID );
|
||||
czitmMP.R("Parts" , out czitm.Parts );
|
||||
czitmMP.R("SellType" , out czitm.SellType );
|
||||
czitmMP.R("ShopPrice", out czitm.ShopPrice);
|
||||
czitmMP.R("SortIndex", out czitm.SortIndex);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["ModuleTable", true]).NotNull)
|
||||
{
|
||||
ModuleTable = new Module[temp.Array.Length];
|
||||
for (i0 = 0; i0 < ModuleTable.Length; i0++)
|
||||
{
|
||||
MsgPack mdlMP = temp[i0];
|
||||
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 );
|
||||
mdlMP.R("ID" , out mdl.ID );
|
||||
mdlMP.R("Name" , out mdl.Name );
|
||||
mdlMP.R("NG" , out mdl.NG );
|
||||
mdlMP.R("ShopPrice", out mdl.ShopPrice);
|
||||
mdlMP.R("SortIndex", out mdl.SortIndex);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["PlateTable", true]).NotNull)
|
||||
{
|
||||
PlateTable = new Plate[temp.Array.Length];
|
||||
for (i0 = 0; i0 < PlateTable.Length; i0++)
|
||||
{
|
||||
MsgPack pltMP = temp[i0];
|
||||
ref Plate plt = ref PlateTable[i0];
|
||||
pltMP.R("Alpha" , out plt.Alpha );
|
||||
pltMP.R("BaseID" , out plt.BaseID );
|
||||
pltMP.R("Border" , out plt.Border );
|
||||
pltMP.R("ColorB" , out plt.ColorB );
|
||||
pltMP.R("ColorG" , out plt.ColorG );
|
||||
pltMP.R("ColorR" , out plt.ColorR );
|
||||
pltMP.R("Font" , out plt.Font );
|
||||
pltMP.R("ID" , out plt.ID );
|
||||
pltMP.R("Shadow" , out plt.Shadow );
|
||||
pltMP.R("ShadowAlpha" , out plt.ShadowAlpha );
|
||||
pltMP.R("ShadowColorB", out plt.ShadowColorB);
|
||||
pltMP.R("ShadowColorG", out plt.ShadowColorG);
|
||||
pltMP.R("ShadowColorR", out plt.ShadowColorR);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["PV", true]).NotNull)
|
||||
{
|
||||
PVList = new PV[temp.Array.Length];
|
||||
for (i0 = 0; i0 < PVList.Length; i0++)
|
||||
{
|
||||
MsgPack pvMP = temp[i0];
|
||||
ref PV pv = ref PVList[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 );
|
||||
|
||||
pv.Easy = GetDifficulty(pvMP, "Easy" );
|
||||
pv.Normal = GetDifficulty(pvMP, "Normal" );
|
||||
pv.Hard = GetDifficulty(pvMP, "Hard" );
|
||||
pv.Extreme = GetDifficulty(pvMP, "Extreme");
|
||||
pv.Encore = GetDifficulty(pvMP, "Encore" );
|
||||
}
|
||||
|
||||
static PV.Difficulty[] GetDifficulty(MsgPack mp, string name)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
MsgPack pvMP = t[i];
|
||||
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);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["SlideSETable", true]).NotNull)
|
||||
{
|
||||
SlideSETable = new SlideSE[temp.Array.Length];
|
||||
for (i0 = 0; i0 < SlideSETable.Length; i0++)
|
||||
{
|
||||
MsgPack sldMP = temp[i0];
|
||||
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 );
|
||||
sldMP.R("SortIndex", out sld.SortIndex);
|
||||
}
|
||||
}
|
||||
else if ((temp = msgPack["SliderTouchSETable", true]).NotNull)
|
||||
{
|
||||
SliderTouchSETable = new SliderTouchSE[temp.Array.Length];
|
||||
for (i0 = 0; i0 < SliderTouchSETable.Length; i0++)
|
||||
{
|
||||
MsgPack TEMP = temp[i0];
|
||||
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 );
|
||||
TEMP.R("SortIndex", out sldt.SortIndex);
|
||||
}
|
||||
}
|
||||
temp.Dispose();
|
||||
msgPack.Dispose();
|
||||
}
|
||||
|
||||
public void MsgPackWriter(string file, bool json)
|
||||
{
|
||||
MsgPack msgPack = MsgPack.New;
|
||||
if (ButtonSETable != null)
|
||||
{
|
||||
MsgPack buttonSETable = new MsgPack(ButtonSETable.Length, "ButtonSETable");
|
||||
for (i0 = 0; i0 < ButtonSETable.Length; i0++)
|
||||
{
|
||||
ref ButtonSE btn = ref ButtonSETable[i0];
|
||||
buttonSETable[i0] = MsgPack.New.Add( "End" , btn.End.Int )
|
||||
.Add( "ID" , btn. ID )
|
||||
.Add( "Name" , btn. Name )
|
||||
.Add( "SEName" , btn. SEName )
|
||||
.Add("SortIndex", btn.SortIndex)
|
||||
.Add( "Start", btn.Start.Int);
|
||||
}
|
||||
msgPack.Add(buttonSETable);
|
||||
}
|
||||
else if (ChainSlideSETable != null)
|
||||
{
|
||||
MsgPack chainSlideSETable = new MsgPack(ChainSlideSETable.Length, "ChainSlideSETable");
|
||||
for (i0 = 0; i0 < ChainSlideSETable.Length; i0++)
|
||||
{
|
||||
ref ChainSlideSE csld = ref ChainSlideSETable[i0];
|
||||
chainSlideSETable[i0] = MsgPack.New.Add( "End" , csld. End.Int )
|
||||
.Add("FailureSEName" , csld.FailureSEName )
|
||||
.Add( "FirstSEName" , csld. FirstSEName )
|
||||
.Add( "ID" , csld. ID )
|
||||
.Add( "Name" , csld. Name )
|
||||
.Add( "SubSEName" , csld. SubSEName )
|
||||
.Add("SuccessSEName" , csld.SuccessSEName )
|
||||
.Add( "SortIndex", csld. SortIndex)
|
||||
.Add( "Start", csld. Start.Int);
|
||||
}
|
||||
msgPack.Add(chainSlideSETable);
|
||||
}
|
||||
else if (CollectionCardTable != null)
|
||||
{
|
||||
MsgPack collectionCardTable = new MsgPack(CollectionCardTable.Length, "CollectionCardTable");
|
||||
for (i0 = 0; i0 < CollectionCardTable.Length; i0++)
|
||||
{
|
||||
ref CollectionCard clcrd = ref CollectionCardTable[i0];
|
||||
collectionCardTable[i0] = MsgPack.New.Add("Chara" , clcrd.Chara )
|
||||
.Add("DispNum" , clcrd.DispNum )
|
||||
.Add("DivaProParam", clcrd.DivaProParam)
|
||||
.Add("End" , clcrd.End.Int )
|
||||
.Add("ID" , clcrd.ID )
|
||||
.Add("ModuleAuthor", clcrd.ModuleAuthor)
|
||||
.Add("Name" , clcrd.Name )
|
||||
.Add("NameReading" , clcrd.NameReading )
|
||||
.Add("NG" , clcrd.NG )
|
||||
.Add("SortIndex" , clcrd.SortIndex )
|
||||
.Add("Start" , clcrd.Start.Int )
|
||||
.Add("Type" , clcrd.Type )
|
||||
.Add("TypeParam" , clcrd.TypeParam )
|
||||
.Add("WallParam" , clcrd.WallParam );
|
||||
}
|
||||
msgPack.Add(collectionCardTable);
|
||||
}
|
||||
else if (CustomizeItemTable != null)
|
||||
{
|
||||
MsgPack customizeItemTable = new MsgPack(CustomizeItemTable.Length, "CustomizeItemTable");
|
||||
for (i0 = 0; i0 < CustomizeItemTable.Length; i0++)
|
||||
{
|
||||
ref CustomizeItem czitm = ref CustomizeItemTable[i0];
|
||||
customizeItemTable[i0] = MsgPack.New.Add("Chara" , czitm.Chara )
|
||||
.Add("ID" , czitm.ID )
|
||||
.Add("Name" , czitm.Name )
|
||||
.Add("NG" , czitm.NG )
|
||||
.Add("ObjID" , czitm.ObjID )
|
||||
.Add("Parts" , czitm.Parts )
|
||||
.Add("SellType" , czitm.SellType )
|
||||
.Add("ShopEnd" , czitm.ShopEnd .Int)
|
||||
.Add("ShopPrice", czitm.ShopPrice )
|
||||
.Add("ShopStart", czitm.ShopStart.Int)
|
||||
.Add("SortIndex", czitm.SortIndex );
|
||||
}
|
||||
msgPack.Add(customizeItemTable);
|
||||
}
|
||||
else if (ModuleTable != null)
|
||||
{
|
||||
MsgPack moduleTable = new MsgPack(ModuleTable.Length, "ModuleTable");
|
||||
for (i0 = 0; i0 < ModuleTable.Length; i0++)
|
||||
{
|
||||
ref Module mdl = ref ModuleTable[i0];
|
||||
moduleTable[i0] = MsgPack.New.Add("Attribute", mdl.Attribute )
|
||||
.Add("Chara" , mdl.Chara )
|
||||
.Add("Costume" , mdl.Costume )
|
||||
.Add("ID" , mdl.ID )
|
||||
.Add("Name" , mdl.Name )
|
||||
.Add("NG" , mdl.NG )
|
||||
.Add("ShopEnd" , mdl.ShopEnd .Int)
|
||||
.Add("ShopPrice", mdl.ShopPrice )
|
||||
.Add("ShopStart", mdl.ShopStart.Int)
|
||||
.Add("SortIndex", mdl.SortIndex );
|
||||
}
|
||||
msgPack.Add(moduleTable);
|
||||
}
|
||||
else if (PlateTable != null)
|
||||
{
|
||||
MsgPack plateTable = new MsgPack(PlateTable.Length, "PlateTable");
|
||||
for (i0 = 0; i0 < PlateTable.Length; i0++)
|
||||
{
|
||||
ref Plate plt = ref PlateTable[i0];
|
||||
plateTable[i0] = MsgPack.New.Add("Alpha" , plt.Alpha )
|
||||
.Add("BaseID" , plt.BaseID )
|
||||
.Add("Border" , plt.Border )
|
||||
.Add("ColorB" , plt.ColorB )
|
||||
.Add("ColorG" , plt.ColorG )
|
||||
.Add("ColorR" , plt.ColorR )
|
||||
.Add("Font" , plt.Font )
|
||||
.Add("ID" , plt.ID )
|
||||
.Add("Shadow" , plt.Shadow )
|
||||
.Add("ShadowAlpha" , plt.ShadowAlpha )
|
||||
.Add("ShadowColorB", plt.ShadowColorB)
|
||||
.Add("ShadowColorG", plt.ShadowColorG)
|
||||
.Add("ShadowColorR", plt.ShadowColorR);
|
||||
}
|
||||
msgPack.Add(plateTable);
|
||||
}
|
||||
else if (PVList != null)
|
||||
{
|
||||
MsgPack pvList = new MsgPack(PVList.Length, "PVList");
|
||||
for (i0 = 0; i0 < PVList.Length; i0++)
|
||||
{
|
||||
ref PV pv = ref PVList[i0];
|
||||
MsgPack mp = MsgPack.New.Add("AdvEnd" , pv.AdvEnd .Int)
|
||||
.Add("AdvStart", pv.AdvStart.Int);
|
||||
|
||||
mp = mp.Add("ID" , pv.ID )
|
||||
.Add("Name" , pv.Name )
|
||||
.Add("Ignore", pv.Ignore);
|
||||
|
||||
mp.Add(WriteDifficulty("Easy" , pv.Easy ));
|
||||
mp.Add(WriteDifficulty("Normal" , pv.Normal ));
|
||||
mp.Add(WriteDifficulty("Hard" , pv.Hard ));
|
||||
mp.Add(WriteDifficulty("Extreme", pv.Extreme));
|
||||
mp.Add(WriteDifficulty("Encore" , pv.Encore ));
|
||||
pvList[i0] = mp;
|
||||
}
|
||||
msgPack.Add(pvList);
|
||||
|
||||
static MsgPack WriteDifficulty(string name, PV.Difficulty[] arr)
|
||||
{
|
||||
if (arr == null) return default;
|
||||
MsgPack mp = new MsgPack(arr.Length, name);
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
ref PV.Difficulty diff = ref arr[i];
|
||||
mp[i] = MsgPack.New.Add("Edition", diff.Edition )
|
||||
.Add("End" , diff.End.Int )
|
||||
.Add("Start" , diff.Start.Int)
|
||||
.Add("Version", diff.Version );
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
}
|
||||
else if (SlideSETable != null)
|
||||
{
|
||||
MsgPack slideSETable = new MsgPack(SlideSETable.Length, "SlideSETable");
|
||||
for (i0 = 0; i0 < SlideSETable.Length; i0++)
|
||||
{
|
||||
ref SlideSE sld = ref SlideSETable[i0];
|
||||
slideSETable[i0] = MsgPack.New.Add( "End" , sld.End.Int )
|
||||
.Add( "ID" , sld. ID )
|
||||
.Add( "Name" , sld. Name )
|
||||
.Add( "SEName" , sld. SEName )
|
||||
.Add("SortIndex", sld.SortIndex)
|
||||
.Add( "Start", sld.Start.Int);
|
||||
}
|
||||
msgPack.Add(slideSETable);
|
||||
}
|
||||
else if (SliderTouchSETable != null)
|
||||
{
|
||||
MsgPack sliderTouchSETable = new MsgPack(SliderTouchSETable.Length, "SliderTouchSETable");
|
||||
for (i0 = 0; i0 < SliderTouchSETable.Length; i0++)
|
||||
{
|
||||
ref SliderTouchSE sldt = ref SliderTouchSETable[i0];
|
||||
sliderTouchSETable[i0] = MsgPack.New.Add( "End" , sldt.End.Int )
|
||||
.Add( "ID" , sldt. ID )
|
||||
.Add( "Name" , sldt. Name )
|
||||
.Add( "SEName" , sldt. SEName )
|
||||
.Add("SortIndex", sldt.SortIndex)
|
||||
.Add( "Start", sldt.Start.Int);
|
||||
}
|
||||
msgPack.Add(sliderTouchSETable);
|
||||
}
|
||||
if (msgPack.List.Count == 1) msgPack.Write(file, json);
|
||||
}
|
||||
|
||||
private bool disposed;
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed) return;
|
||||
if (_IO != null) _IO.D(); _IO = 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
+7
-7
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
@@ -20,9 +20,9 @@ namespace KKdSoundLib
|
||||
if (reader.RS(0x04) != "DIVA") { reader.C(); return; }
|
||||
|
||||
reader.RI32();
|
||||
Data.Size = reader.RU32();
|
||||
Data.SampleRate = reader.RU32();
|
||||
Data.SamplesCount = reader.RU32();
|
||||
Data.Size = reader.RI32();
|
||||
Data.SampleRate = reader.RI32();
|
||||
Data.SamplesCount = reader.RI32();
|
||||
reader.RI64();
|
||||
Data.Channels = reader.RU16();
|
||||
reader.RU16();
|
||||
@@ -195,9 +195,9 @@ namespace KKdSoundLib
|
||||
|
||||
public struct DIVAFile
|
||||
{
|
||||
public uint Size;
|
||||
public uint SampleRate;
|
||||
public uint SamplesCount;
|
||||
public int Size;
|
||||
public int SampleRate;
|
||||
public int SamplesCount;
|
||||
public string Name;
|
||||
public ushort Channels;
|
||||
public byte[] Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdBaseLib;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace KKdSoundLib
|
||||
@@ -34,7 +34,7 @@ namespace KKdSoundLib
|
||||
if (Header.Format == 0x01 || Header.Format == 0x03 || Header.Format == 0xFFFE)
|
||||
{
|
||||
Header.Channels = _IO.RU16();
|
||||
Header.SampleRate = _IO.RU32();
|
||||
Header.SampleRate = _IO.RI32();
|
||||
_IO.RI32(); _IO.RI16();
|
||||
Header.Bytes = _IO.RU16();
|
||||
if (Header.Bytes % 8 != 0) return Header;
|
||||
@@ -51,8 +51,8 @@ namespace KKdSoundLib
|
||||
if (Header.Bytes == 8 && Header.Format == 1) return Header;
|
||||
_IO.S(Offset + 0x14, 0);
|
||||
if (_IO.RS(4) != "data") return Header;
|
||||
Header.Size = _IO.RU32();
|
||||
Header.HeaderSize = _IO.PU32;
|
||||
Header.Size = _IO.RI32();
|
||||
Header.HeaderSize = _IO.P;
|
||||
Header.IsSupported = true;
|
||||
return Header;
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<Authors>korenkonder</Authors>
|
||||
<Company></Company>
|
||||
<Configuration></Configuration>
|
||||
<Copyright>korenkonder © 2019</Copyright>
|
||||
<Copyright>korenkonder © 2019-2020</Copyright>
|
||||
<Description>A simple library for working with Project Diva F/AFT/F2/X/FT audio files</Description>
|
||||
<FileVersion>0.1.1.1</FileVersion>
|
||||
<FileVersion>0.1.2.0</FileVersion>
|
||||
<PackageId>KKdSoundLib</PackageId>
|
||||
<Product>KKdSoundLib</Product>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Title>KKdSoundLib</Title>
|
||||
<Version>0.1.1.1</Version>
|
||||
<Version>0.1.2.0</Version>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
+470
-440
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -1,12 +1,12 @@
|
||||
namespace KKdSoundLib
|
||||
namespace KKdSoundLib
|
||||
{
|
||||
public static class WAV
|
||||
{
|
||||
public struct Header
|
||||
{
|
||||
public uint Size;
|
||||
public uint SampleRate;
|
||||
public uint HeaderSize;
|
||||
public int Size;
|
||||
public int SampleRate;
|
||||
public int HeaderSize;
|
||||
public uint ChannelMask;
|
||||
public bool IsSupported;
|
||||
public ushort Bytes;
|
||||
|
||||
+87
-84
@@ -1,85 +1,88 @@
|
||||
<?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\MOT.cs" />
|
||||
<Compile Include="classes\STR.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>
|
||||
<?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\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" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>del Microsoft.Win32.Primitives.dll
|
||||
del netstandard.dll
|
||||
del PD_Tool.exe.config
|
||||
@@ -176,6 +179,6 @@ 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>
|
||||
del System.Xml.XPath.XDocument.dll</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
+139
-60
@@ -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(); }
|
||||
|
||||
@@ -28,7 +31,7 @@ namespace PD_Tool
|
||||
GC.Collect();
|
||||
if (Directory.Exists(arg)) using (KKdFARC FARC = new KKdFARC(arg, true)) FARC.Pack();
|
||||
else if (File.Exists(arg) && Path.GetExtension(arg) == ".farc")
|
||||
using (KKdFARC farc = new KKdFARC(arg)) farc.UnPack(true);
|
||||
using (KKdFARC farc = new KKdFARC(arg)) farc.Unpack(true);
|
||||
else if (File.Exists(arg))
|
||||
{
|
||||
using (reader = File.OpenReader(arg))
|
||||
@@ -43,9 +46,7 @@ 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.2";
|
||||
Console.Clear();
|
||||
|
||||
ConsoleDesign(true);
|
||||
@@ -53,12 +54,13 @@ namespace PD_Tool
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("1. Extract FARC Archive");
|
||||
ConsoleDesign("2. Create FARC Archive");
|
||||
ConsoleDesign("3. Decrypt from DIVAFILE");
|
||||
ConsoleDesign("4. Encrypt to DIVAFILE");
|
||||
ConsoleDesign("5. DB_Tools");
|
||||
ConsoleDesign("6. AC/DT/F/AFT/FT Converting Tools");
|
||||
ConsoleDesign("7. F/F2/X/FT Converting Tools");
|
||||
ConsoleDesign(json ? "8. MsgPack to JSON" : "9. JSON to MsgPack");
|
||||
ConsoleDesign("3. Decrypt/Encrypt from/to DIVAFILE");
|
||||
ConsoleDesign("4. DB_Tools");
|
||||
ConsoleDesign("5. AC/DT/F/AFT Converting Tools");
|
||||
ConsoleDesign("6. F/F2/FT Converting Tools");
|
||||
ConsoleDesign("7. X/XHD Converting Tools");
|
||||
ConsoleDesign("8. FT/M39 Converting Tools");
|
||||
ConsoleDesign(json ? "9. MsgPack to JSON" : "9. JSON to MsgPack");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(json ? "M. MessagePack" : "J. JSON");
|
||||
ConsoleDesign("Q. Quit");
|
||||
@@ -69,72 +71,88 @@ 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') DataBase.Processor(json);
|
||||
else if (choose[0] == '5')
|
||||
{
|
||||
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. STR" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine();
|
||||
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. Table" );
|
||||
ConsoleDesign("9. STR" );
|
||||
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);
|
||||
else if (localChoose == "4") DEX.Processor(json);
|
||||
else if (localChoose == "5") DIV.Processor();
|
||||
else if (localChoose == "6") MOT.Processor(json);
|
||||
else if (localChoose == "7") STR.Processor(json);
|
||||
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 choose = localChoose;
|
||||
}
|
||||
else if (choose == "7")
|
||||
else if (choose[0] == '6')
|
||||
{
|
||||
Console.Clear();
|
||||
Console.Title = "F/F2/X/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. Particles" );
|
||||
ConsoleDesign("8. STR" );
|
||||
ConsoleDesign("9. VAG" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine();
|
||||
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();
|
||||
@@ -145,7 +163,66 @@ namespace PD_Tool
|
||||
else if (localChoose == "8") VAG.Processor();
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose == "8")
|
||||
else if (choose[0] == '7')
|
||||
{
|
||||
string localChoose = "";
|
||||
if (choose.Length == 1)
|
||||
{
|
||||
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();
|
||||
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[0] == '8')
|
||||
{
|
||||
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. Table" );
|
||||
ConsoleDesign("9. STR" );
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign("R. Return to Main Menu");
|
||||
ConsoleDesign(false);
|
||||
ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string localChoose = Console.ReadLine().ToUpper();
|
||||
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") TBL.Processor(json);
|
||||
else if (localChoose == "9") STR.Processor(json);
|
||||
else choose = localChoose;
|
||||
}
|
||||
else if (choose == "9")
|
||||
{
|
||||
Console.Title = json ? "MsgPack to JSON" : "JSON to MsgPack";
|
||||
Choose(1, json ? "mp" : "json", out string[] fileNames);
|
||||
@@ -225,12 +302,14 @@ namespace PD_Tool
|
||||
else if (filetype == "dft" ) Filter = GetArgs("DFT" , "dft");
|
||||
else if (filetype == "diva") Filter = GetArgs("DIVA", "diva", "wav") +
|
||||
GetArgs("DIVA", true, "diva") + wav;
|
||||
else if (filetype == "farc") Filter = "FARC Archives (*.farc)|*.farc";
|
||||
else if (filetype == "farc") Filter = GetArgs("FARC", "farc");
|
||||
else if (filetype == "json") Filter = GetArgs("JSON", "json");
|
||||
else if (filetype == "mp" ) Filter = GetArgs("MessagePack", "mp");
|
||||
else if (filetype == "lit") Filter = GetArgs("LIT" , "lit");
|
||||
else if (filetype == "str" ) Filter = GetArgs("STR" , "str", "bin", "json", "mp") +
|
||||
GetArgs("STR", true, "str") + bin + json + mp;
|
||||
else if (filetype == "tbl" ) Filter = GetArgs("Table" , "bin", "farc", "json", "mp") +
|
||||
bin + GetArgs("FARC Archives", true, "farc") + json + mp;
|
||||
else if (filetype == "vag" ) Filter = GetArgs("VAG" , "vag", "wav") +
|
||||
GetArgs("VAG", true, "vag") + wav;
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyTitle("PD_Tool")]
|
||||
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files")]
|
||||
[assembly: AssemblyDescription("A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PD_Tool")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2017-2019")]
|
||||
[assembly: AssemblyCopyright("korenkonder © 2017-2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
|
||||
[assembly: AssemblyVersion("0.4.8.1")]
|
||||
[assembly: AssemblyFileVersion("0.4.8.1")]
|
||||
[assembly: AssemblyVersion("0.4.9.2")]
|
||||
[assembly: AssemblyFileVersion("0.4.9.2")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdA3DA = KKdMainLib.A3DA;
|
||||
@@ -36,7 +36,7 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "1") format = Format.DT ;
|
||||
else if (choose == "2") format = Format.F ;
|
||||
else if (choose == "3") format = Format.AFT ;
|
||||
@@ -70,8 +70,6 @@ namespace PD_Tool
|
||||
using (a3da = new KKdA3DA(true))
|
||||
{
|
||||
a3da.MsgPackReader(filepath, ext == ".json");
|
||||
a3da.Data._.CompressF16 = format > Format.AFT && format <
|
||||
Format.FT ? format == Format.MGF ? 2 : 1 : 0;
|
||||
a3da.Head.Format = format;
|
||||
|
||||
File.WriteAllBytes(filepath + ".a3da", (choose != "1" &&
|
||||
@@ -113,8 +111,6 @@ namespace PD_Tool
|
||||
if (state == 1)
|
||||
{
|
||||
KKdFARC.FARCFile file = farc.Files[i];
|
||||
a3da.Data._.CompressF16 = format > Format.AFT && format <
|
||||
Format.FT ? format == Format.MGF ? 2 : 1 : 0;
|
||||
a3da.Head.Format = format;
|
||||
file.Data = (choose != "1" && choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter();
|
||||
farc.Files[i] = file;
|
||||
@@ -162,8 +158,6 @@ namespace PD_Tool
|
||||
{
|
||||
KKdFARC.FARCFile file = default;
|
||||
file.Name = list[i];
|
||||
a3daArray[i].Data._.CompressF16 = format > Format.AFT && format <
|
||||
Format.FT ? format == Format.MGF ? 2 : 1 : 0;
|
||||
a3daArray[i].Head.Format = format;
|
||||
file.Data = (choose != "1" && choose != "3") ? a3daArray[i].A3DCWriter() : a3daArray[i].A3DAWriter();
|
||||
farc.Files.Add(file);
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
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)
|
||||
{
|
||||
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.MotHeadReader(filepath);
|
||||
adp.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
adp.MsgPackReader(filepath, ext == ".json");
|
||||
adp.MotHeadWriter(filepath);
|
||||
}
|
||||
adp.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdAet = KKdMainLib.Aet.Aet;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
@@ -13,9 +13,9 @@ namespace PD_Tool
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
string filepath, ext;
|
||||
KKdAet aet;
|
||||
Aet aet;
|
||||
foreach (string file in fileNames)
|
||||
using (aet = new KKdAet())
|
||||
using (aet = new Aet())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Bloom Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".blt") { blt.BLTReader(filepath); blt.TXTWriter(filepath); }
|
||||
if (ext == ".blt") { blt.BLTReader(filepath); blt.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { blt.TXTReader(filepath); blt.BLTWriter(filepath); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Color Correction Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".cct") { cct.CCTReader(filepath); cct.TXTWriter(filepath); }
|
||||
if (ext == ".cct") { cct.CCTReader(filepath); cct.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { cct.TXTReader(filepath); cct.BLTWriter(filepath); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-19
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -16,22 +16,7 @@ namespace PD_Tool
|
||||
if (file.EndsWith(".mp" )) { mp = false; break; }
|
||||
else if (file.EndsWith(".json")) { mp = false; break; }
|
||||
|
||||
string choose = "1";
|
||||
if (mp)
|
||||
{
|
||||
Console.Clear();
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of exporting file:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. Compact");
|
||||
Program.ConsoleDesign("2. Normal");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine();
|
||||
}
|
||||
|
||||
uint num2 = (uint)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
uint num2 = (uint)(DateTime.Now.Ticks / 10000000);
|
||||
string[] file_split;
|
||||
string filepath, ext;
|
||||
KKdMainLib.DataBank db;
|
||||
@@ -50,8 +35,15 @@ namespace PD_Tool
|
||||
filepath = file.Replace(filename + ".dat", "");
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
db. DBReader(file);
|
||||
db.MsgPackWriter(filepath + file_split[0] + "_" +
|
||||
file_split[1] + "_" + file_split[2], json, choose != "2");
|
||||
db.MsgPackWriter(filepath + file_split[0] + "_" +
|
||||
file_split[1] + "_" + file_split[2], json);
|
||||
}
|
||||
else if (ext == ".bin" && mp)
|
||||
{
|
||||
filepath = file.Replace(".bin", "");
|
||||
Console.Title = "DataBank Converter: " + filename;
|
||||
db. DBReader(file);
|
||||
db.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if ((ext == ".mp" || ext == ".json") && !mp)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib.IO;
|
||||
using KKdDEX = KKdMainLib.DEX;
|
||||
@@ -12,7 +12,7 @@ namespace PD_Tool
|
||||
Console.Title = "DEX Converter";
|
||||
Program.Choose(1, "dex", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
|
||||
bool mp = true;
|
||||
bool _json = true;
|
||||
foreach (string file in fileNames)
|
||||
@@ -32,8 +32,8 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine();
|
||||
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
|
||||
Format format = Format.NULL;
|
||||
if (choose == "1") format = Format.F ;
|
||||
else if (choose == "2") format = Format.F2LE;
|
||||
@@ -49,11 +49,11 @@ namespace PD_Tool
|
||||
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 (format > Format.NULL) DEX. DEXWriter(filepath, format);
|
||||
else DEX.MsgPackWriter(filepath, json);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "DOF Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".dft") { dft.DFTReader(filepath); dft.TXTWriter(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;
|
||||
|
||||
@@ -28,4 +28,4 @@ namespace PD_Tool
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using KKdMainLib;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
@@ -8,9 +8,10 @@ namespace PD_Tool
|
||||
public static void Decrypt(string file)
|
||||
{
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.RI64() != 0x454C494641564944) { reader.C(); return; }
|
||||
ulong head = reader.RU64();
|
||||
reader.C();
|
||||
|
||||
if (head != 0x454C494641564944) return;
|
||||
System.Console.Title = "DIVAFILE Decrypt: " + Path.GetFileName(file);
|
||||
file.Decrypt();
|
||||
}
|
||||
@@ -18,9 +19,10 @@ namespace PD_Tool
|
||||
public static void Encrypt(string file)
|
||||
{
|
||||
Stream reader = File.OpenReader(file);
|
||||
if (reader.RI64() == 0x454C494641564944) { reader.C(); return; }
|
||||
ulong head = reader.RU64();
|
||||
reader.C();
|
||||
|
||||
if (head == 0x454C494641564944) return;
|
||||
System.Console.Title = "DIVAFILE Encrypt: " + Path.GetFileName(file);
|
||||
file.Encrypt();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Aet = KKdMainLib.DB.Aet;
|
||||
using Auth = KKdMainLib.DB.Auth;
|
||||
@@ -23,7 +23,7 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
string format = Console.ReadLine();
|
||||
string format = Console.ReadLine().ToUpper();
|
||||
if (format == "1") AuthDBProcessor(json);
|
||||
if (format == "2") AETDBProcessor(json);
|
||||
if (format == "3") SPRDBProcessor(json);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace PD_Tool
|
||||
{
|
||||
Console.Title = "FARC Extractor: " + Path.GetFileNameWithoutExtension(fileExtract);
|
||||
using (KKdFARC farc = new KKdFARC(fileExtract))
|
||||
farc.UnPack();
|
||||
farc.Unpack();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -35,8 +35,8 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(true);
|
||||
Program.ConsoleDesign(" Choose type of created FARC:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. FArc [DT/DT2/DTex/F/F2/X]");
|
||||
Program.ConsoleDesign("2. FArC [DT/DT2/DTex/F/F2/X] (Compressed)");
|
||||
Program.ConsoleDesign("1. FArc (Uncompressed)");
|
||||
Program.ConsoleDesign("2. FArC (Compressed)");
|
||||
Program.ConsoleDesign("3. FARC [F/F2/X]");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("R. Return to Main Menu");
|
||||
@@ -62,7 +62,7 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
if (choose == "2" || choose == "4") farc.FARCType |= KKdFARC.Type.GZip;
|
||||
if (choose == "3" || choose == "4") farc.FARCType |= KKdFARC.Type.ECB ;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdMainLib.F2;
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace PD_Tool
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Light Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".lit") { lit.LITReader(filepath); lit.TXTWriter(filepath); }
|
||||
if (ext == ".lit") { lit.LITReader(filepath); lit.TXTWriter(filepath); }
|
||||
//else if (ext == ".txt") { lit.TXTReader(filepath); lit.LITWriter(filepath); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class MHD
|
||||
{
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "MotHead Converter";
|
||||
Program.Choose(1, "bin", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
string filepath, ext;
|
||||
MotHead mhd;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
mhd.MsgPackReader(filepath, ext == ".json");
|
||||
mhd.MotHeadWriter(filepath);
|
||||
}
|
||||
mhd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-19
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib;
|
||||
using KKdMainLib.IO;
|
||||
|
||||
@@ -11,29 +11,28 @@ namespace PD_Tool
|
||||
Console.Title = "MOT Converter";
|
||||
Program.Choose(1, "bin", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
|
||||
string filepath, ext;
|
||||
Mot mot;
|
||||
foreach (string file in fileNames)
|
||||
{
|
||||
mot = new Mot();
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
using (mot = new Mot())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
mot. MOTReader(filepath);
|
||||
mot.MsgPackWriter(filepath, json);
|
||||
Console.Title = "MOT Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
mot. MOTReader(filepath);
|
||||
mot.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
mot.MsgPackReader(filepath, ext == ".json");
|
||||
mot. MOTWriter(filepath);
|
||||
}
|
||||
}
|
||||
else if (ext == ".mp" || ext == ".json")
|
||||
{
|
||||
mot.MsgPackReader(filepath, ext == ".json");
|
||||
mot. MOTWriter(filepath);
|
||||
}
|
||||
mot = new Mot();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KKdMainLib.IO;
|
||||
using KKdSTR = KKdMainLib.STR;
|
||||
|
||||
@@ -20,8 +20,7 @@ namespace PD_Tool
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "PD_Tool: Converter Tools: STR Reader: " +
|
||||
Path.GetFileNameWithoutExtension(file);
|
||||
Console.Title = "STR Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".str" || ext == ".bin")
|
||||
{
|
||||
str.STRReader (filepath, ext);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdBaseLib;
|
||||
using KKdMainLib;
|
||||
using KKdFARC = KKdMainLib.FARC;
|
||||
|
||||
namespace PD_Tool
|
||||
{
|
||||
public class TBL
|
||||
{
|
||||
public static void Processor(bool json)
|
||||
{
|
||||
Console.Title = "Table Converter";
|
||||
Program.Choose(1, "tbl", out string[] fileNames);
|
||||
if (fileNames.Length < 1) return;
|
||||
|
||||
string filepath, ext;
|
||||
Tables tbl;
|
||||
foreach (string file in fileNames)
|
||||
using (tbl = new Tables())
|
||||
{
|
||||
ext = Path.GetExtension(file);
|
||||
filepath = file.Replace(ext, "");
|
||||
ext = ext.ToLower();
|
||||
|
||||
Console.Title = "Table Converter: " + Path.GetFileNameWithoutExtension(file);
|
||||
if (ext == ".bin")
|
||||
{
|
||||
tbl.BINReader (filepath);
|
||||
tbl.MsgPackWriter(filepath, json);
|
||||
}
|
||||
else if (ext == ".farc")
|
||||
using (KKdFARC farc = new KKdFARC(file))
|
||||
FARCProcessor(ref tbl, farc, filepath, json);
|
||||
else if (ext == ".json" || ext == ".mp")
|
||||
{
|
||||
tbl.MsgPackReader(filepath, ext == ".json");
|
||||
tbl.BINWriter (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void FARCProcessor(ref Tables tbl, KKdFARC farc, string filepath, bool json)
|
||||
{
|
||||
if (!farc.HeaderReader()) return;
|
||||
if (!farc.HasFiles) return;
|
||||
|
||||
int file = -1;
|
||||
KKdList<string> list = KKdList<string>.New;
|
||||
for (int i = 0; i < farc.Files.Count; i++)
|
||||
if (farc.Files[i].Name.ToLower().EndsWith(".bin")) { file = i; break; }
|
||||
if (file == -1) return;
|
||||
|
||||
farc.Unpack(false);
|
||||
tbl.BINReader (farc.Files[file].Data);
|
||||
tbl.MsgPackWriter(filepath.Replace(Path.GetFileName(filepath),
|
||||
Path.GetFileNameWithoutExtension(farc.Files[file].Name)), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
using KKdVAG = KKdSoundLib.VAG;
|
||||
|
||||
@@ -25,15 +25,16 @@ namespace PD_Tool
|
||||
Program.ConsoleDesign(" Choose type of format to export:");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign("1. VAG (Downmix to 1 ch)");
|
||||
Program.ConsoleDesign("2. HEVAG [Fastest]");
|
||||
Program.ConsoleDesign("2. HEVAG [Fastest] (Multichannel VAG)");
|
||||
Program.ConsoleDesign("3. HEVAG [Fast]");
|
||||
Program.ConsoleDesign("4. HEVAG [Medium]");
|
||||
Program.ConsoleDesign("5. HEVAG [Slow]");
|
||||
Program.ConsoleDesign("6. HEVAG [Slowest]");
|
||||
Program.ConsoleDesign("7. HEVAG [Slow as hell] (Full HEVAG)");
|
||||
Program.ConsoleDesign(false);
|
||||
Program.ConsoleDesign(true);
|
||||
Console.WriteLine();
|
||||
choose = Console.ReadLine();
|
||||
choose = Console.ReadLine().ToUpper();
|
||||
}
|
||||
|
||||
string filepath, ext;
|
||||
@@ -51,4 +52,4 @@ namespace PD_Tool
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
# PD_Tool
|
||||
A simple tool for working with Project Diva DT/FT/F/F2/X files
|
||||
A simple tool for working with Project Diva AC/DT/F/AFT/F2/X/FT files
|
||||
|
||||
# Dependencies:
|
||||
+ `.NET Standard 2.0`: Required to build KKdBaseLib, KKdMainLib and KKdSoundLib C# projects.
|
||||
+ `.NET Framework 4.6.1`: Required to run/build PD_Tool C# project.
|
||||
|
||||
# Tools:
|
||||
- `FARC Extract/Create`
|
||||
- `DIVAFILE Encrypt/Decrypt`
|
||||
- `DIVAFILE Decrypt/Encrypt`
|
||||
- `DB_Tools`
|
||||
- `Aet DB Converter`
|
||||
- `Auth DB Converter`
|
||||
- `Spr DB Converter`
|
||||
- `Converting Tools`
|
||||
- `AC/DT/F/AFT/FT Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `AET Converter`
|
||||
- `DataBank Converter`
|
||||
- `DEX Converter`
|
||||
- `DIVA Converter`
|
||||
- `MOT Converter`
|
||||
- `STR Converter`
|
||||
- `F/F2/X/FT Converting Tools`
|
||||
- `A3DA Converter`
|
||||
- `Bloom Converter`
|
||||
- `Color Correction Converter`
|
||||
- `DEX Converter`
|
||||
- `DOF Converter`
|
||||
- `Light Converter`
|
||||
- `STR Converter`
|
||||
- `VAG Converter`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user