diff --git a/KKdBaseLib/F2/POF.cs b/KKdBaseLib/F2/POF.cs
index 99bbf02..be746cd 100644
--- a/KKdBaseLib/F2/POF.cs
+++ b/KKdBaseLib/F2/POF.cs
@@ -77,7 +77,7 @@ namespace KKdBaseLib.F2
private int length(bool shiftX = false)
{
- int length = 5;
+ int length = 6;
long offset = 0;
byte bitShift = (byte)(shiftX ? 3 : 2);
int max1 = 0x00100 >> bitShift;
diff --git a/KKdBaseLib/KKdBaseLib.csproj b/KKdBaseLib/KKdBaseLib.csproj
index 794f857..d21bfc0 100644
--- a/KKdBaseLib/KKdBaseLib.csproj
+++ b/KKdBaseLib/KKdBaseLib.csproj
@@ -4,14 +4,14 @@
korenkonder
- korenkonder © 2019-2020
+ korenkonder © 2019-2020
A base library
- 0.4.9.3
+ 0.4.9.4
KKdBaseLib
KKdBaseLib
net461
KKdBaseLib
- 0.4.9.3
+ 0.4.9.4
AnyCPU
diff --git a/KKdBaseLib/KKdDict.cs b/KKdBaseLib/KKdDict.cs
index 7b87751..f6e9c5b 100644
--- a/KKdBaseLib/KKdDict.cs
+++ b/KKdBaseLib/KKdDict.cs
@@ -73,7 +73,7 @@ namespace KKdBaseLib
public void Add(KeyValuePair pair)
{
- if (IsNull) return;
+ if (IsNull || ContainsKey(pair.Key)) return;
count++;
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
@@ -84,7 +84,7 @@ namespace KKdBaseLib
public void Add(TKey key, TValue val)
{
- if (IsNull) return;
+ if (IsNull || ContainsKey(key)) return;
count++;
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
@@ -231,6 +231,6 @@ namespace KKdBaseLib
{ Key = key; Value = value; }
public override string ToString() =>
- $"(Key: {Key}; value: {Value})";
+ $"(Key: {Key}; Value: {Value})";
}
}
diff --git a/KKdMainLib/Main.cs b/KKdBaseLib/Main.cs
similarity index 66%
rename from KKdMainLib/Main.cs
rename to KKdBaseLib/Main.cs
index c9a966f..3efbed9 100644
--- a/KKdMainLib/Main.cs
+++ b/KKdBaseLib/Main.cs
@@ -2,10 +2,9 @@ using System;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
-using KKdBaseLib;
using A3DADict = System.Collections.Generic.Dictionary;
-namespace KKdMainLib
+namespace KKdBaseLib
{
public static unsafe class Main
{
@@ -57,52 +56,62 @@ namespace KKdMainLib
return dict.ContainsKey(args[0]);
}
- public static bool FV(this A3DADict dict, ref bool value, char split, string args) =>
+ public static bool FV (this A3DADict dict, ref bool value, char split, string args) =>
dict.FV(out string val, args.Split(split)) ? bool.TryParse(val, out value) : false;
- public static bool FV(this A3DADict dict, ref int value, char split, string args) =>
+ public static bool FV (this A3DADict dict, ref int value, char split, string args) =>
dict.FV(out string val, args.Split(split)) ? int.TryParse(val, out value) : false;
- public static bool FV(this A3DADict dict, ref float value, char split, string args) =>
+ public static bool FV (this A3DADict dict, ref float value, char split, string args) =>
dict.FV(out string val, args.Split(split)) ? val.ToF32(out value) : false;
- public static bool FV(this A3DADict dict, ref double value, char split, string args) =>
+ public static bool FV (this A3DADict dict, ref double value, char split, string args) =>
dict.FV(out string val, args.Split(split)) ? val.ToF64(out value) : false;
- public static bool FV(this A3DADict dict, ref string value, char split, string args)
+ public static bool FV (this A3DADict dict, ref string value, char split, string args)
{ if (dict.FV(out string val , args.Split(split)))
- { value = val; return true; } return false; }
+ { value = val; return true; } return false; }
- public static bool FV(this A3DADict dict, out bool value, string args)
+ public static bool FV (this A3DADict dict, out bool value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
return bool.TryParse(val, out value); value = false; return false; }
- public static bool FV(this A3DADict dict, out int value, string args)
+ public static bool FV (this A3DADict dict, out int value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
- return int.TryParse(val, out value); value = 0; return false; }
+ return int.TryParse(val, out value); value = 0; return false; }
- public static bool FV(this A3DADict dict, out float value, string args)
+ public static bool FV (this A3DADict dict, out float value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
- return val.ToF32(out value); value = 0; return false; }
+ return val.ToF32(out value); value = 0; return false; }
- public static bool FV(this A3DADict dict, out double value, string args)
+ public static bool FV (this A3DADict dict, out double value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
- return val.ToF64(out value); value = 0; return false; }
+ return val.ToF64(out value); value = 0; return false; }
- public static bool FV(this A3DADict dict, out int? value, string args)
+ public static bool FV(this A3DADict dict, out T value, string args) where T : struct
{ if (dict.FV(out string val , args.Split('.' )))
- { bool Val = int.TryParse(val, out int _value);
- value = _value; return Val; } value = null; return false; }
+ { bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
+ value = default; return false; }
- public static bool FV(this A3DADict dict, out float? value, string args)
+ public static bool FV (this A3DADict dict, out int? value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
- return val.ToF32(out value); value = null; return false; }
+ { bool Val = int.TryParse(val, out int _value); value = _value; return Val; }
+ value = null; return false; }
- public static bool FV(this A3DADict dict, out double? value, string args)
+ public static bool FV (this A3DADict dict, out float? value, string args)
{ if (dict.FV(out string val , args.Split('.' )))
- return val.ToF64(out value); value = null; return false; }
+ return val.ToF32(out value); value = null; return false; }
- public static bool FV(this A3DADict dict, out string value, string args) =>
+ public static bool FV (this A3DADict dict, out double? value, string args)
+ { if (dict.FV(out string val , args.Split('.' )))
+ return val.ToF64(out value); value = null; return false; }
+
+ public static bool FV(this A3DADict dict, out T? value, string args) where T : struct
+ { if (dict.FV(out string val , args.Split('.' )))
+ { bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
+ value = null; return false; }
+
+ public static bool FV (this A3DADict dict, out string value, string args) =>
dict.FV(out value, args.Split('.' ));
public static bool FV(this A3DADict dict, out string value, string[] args)
@@ -129,6 +138,24 @@ namespace KKdMainLib
return true;
}
+ public static bool FK(this A3DADict dict, string args) =>
+ dict.FK(args.Split('.' ));
+
+ public static bool FK(this A3DADict dict, string[] args)
+ {
+ if (dict == null || args.Length < 1) return false;
+
+ args[0] = args[0].ToLower();
+ if (!dict.ContainsKey(args[0])) return false;
+ else if (args.Length > 1)
+ {
+ string[] newArgs = new string[args.Length - 1];
+ for (int i = 0; i < args.Length - 1; i++) newArgs[i] = args[i + 1];
+ return ((A3DADict)dict[args[0]]).FK(newArgs);
+ }
+ return true;
+ }
+
public static void GD(this A3DADict dict, string args, char split = '.')
{
string[] dataArray = args.Split('=');
diff --git a/KKdBaseLib/MsgPack.cs b/KKdBaseLib/MsgPack.cs
index de32bc7..a1b1df9 100644
--- a/KKdBaseLib/MsgPack.cs
+++ b/KKdBaseLib/MsgPack.cs
@@ -47,7 +47,12 @@ namespace KKdBaseLib
public MsgPack this[string key, bool array]
{ get { if (!array) return this[key];
- if (Object is KKdList List) { MsgPack MsgPack = List[ElementIndex(key)];
+ if (Object is KKdList List) { MsgPack MsgPack = List[ElementIndex(key)];
+ return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
+
+ public MsgPack this[bool startsWith, string key]
+ { get { if (Object is KKdList List) { MsgPack MsgPack =
+ List[startsWith ? ElementIndexStartsWith(key) : ElementIndex(key)];
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
public MsgPack Add(MsgPack obj)
@@ -377,6 +382,17 @@ namespace KKdBaseLib
return -1;
}
+ public bool ContainsKeyStartsWith(string name) => ElementIndexStartsWith(name) > -1;
+
+ public int ElementIndexStartsWith(string name)
+ {
+ if (List.IsNull) return -1;
+
+ for (int i = 0; i < List.Count; i++)
+ if (List[i].Name.StartsWith(name)) return i;
+ return -1;
+ }
+
public struct Ext
{
@@ -384,4 +400,10 @@ namespace KKdBaseLib
public byte[] Data;
}
}
+
+ public interface IMsgPack : INull
+ {
+ //public void ReadMsgPack();
+ public MsgPack WriteMsgPack(string name);
+ }
}
diff --git a/KKdMainLib/A3DA.cs b/KKdMainLib/A3DA.cs
index 8282113..0b7feb4 100644
--- a/KKdMainLib/A3DA.cs
+++ b/KKdMainLib/A3DA.cs
@@ -1487,10 +1487,10 @@ namespace KKdMainLib
{
_IO.P = A3DCEnd;
_IO.WEOFC(0);
- _IO.O = 0;
+ _IO.O = 0;
_IO.P = 0;
- Header header = new Header { Signature = 0x41443341, Format = Format.F2,
- DataSize = A3DCEnd, SectionSize = A3DCEnd, InnerSignature = 0x01131010 };
+ Header header = new Header { Signature = 0x41443341, InnerSignature = 0x01131010,
+ Format = Format.F2, DataSize = A3DCEnd, SectionSize = A3DCEnd, UseSectionSize = true };
_IO.W(header, true);
}
@@ -1625,14 +1625,16 @@ namespace KKdMainLib
if (!a3dcOpt)
{
key.BinOffset = _IO.P;
- _IO.W(( int)key.Type );
- _IO.W((float)key.Value);
+ if (key.Type == KeyType.Null) _IO.W(0x00L);
+ else { _IO.W(( int)key.Type );
+ _IO.W((float)key.Value); }
}
else if (!usedValues.ContainsValue(key.Value))
{
key.BinOffset = _IO.P;
- _IO.W(( int)key.Type );
- _IO.W((float)key.Value);
+ if (key.Type == KeyType.Null) _IO.W(0x00L);
+ else { _IO.W(( int)key.Type );
+ _IO.W((float)key.Value); }
usedValues.Add(key.BinOffset, key.Value);
}
else key.BinOffset = usedValues.GK(key.Value);
@@ -1861,7 +1863,7 @@ namespace KKdMainLib
}
public void MsgPackWriter(string file, bool json) =>
- MsgPackWriter().Write(true, file, json);
+ MsgPackWriter().Write(false, true, file, json);
private void MsgPackReader(MsgPack a3d)
{
diff --git a/KKdMainLib/AddParam.cs b/KKdMainLib/AddParam.cs
index b52de86..58cdaa1 100644
--- a/KKdMainLib/AddParam.cs
+++ b/KKdMainLib/AddParam.cs
@@ -116,7 +116,7 @@ namespace KKdMainLib
addParam[i] = addParam[i].Add("Value", sub.Value);
}
- addParam.WriteAfterAll(true, file, json);
+ addParam.WriteAfterAll(false, true, file, json);
}
public void Dispose()
diff --git a/KKdMainLib/Aet.cs b/KKdMainLib/Aet.cs
index fad7829..1aa5273 100644
--- a/KKdMainLib/Aet.cs
+++ b/KKdMainLib/Aet.cs
@@ -646,7 +646,7 @@ namespace KKdMainLib
MsgPack aet = new MsgPack(AET.Scenes.Length, "Aet");
for (int i = 0; i < AET.Scenes.Length; i++)
aet[i] = MsgPackWriter(ref AET.Scenes[i]);
- aet.WriteAfterAll(true, file, json);
+ aet.WriteAfterAll(false, true, file, json);
}
public void MsgPackReader(MsgPack msgPack, ref Pointer aetData)
diff --git a/KKdMainLib/DB/Aet.cs b/KKdMainLib/DB/Aet.cs
index ca69746..e1521ff 100644
--- a/KKdMainLib/DB/Aet.cs
+++ b/KKdMainLib/DB/Aet.cs
@@ -213,7 +213,7 @@ namespace KKdMainLib.DB
for (i = 0; i < AetSets.Length; i++)
AetDB[i] = AetSets[i].WriteMsgPack();
- AetDB.Write(true, file, json);
+ AetDB.Write(false, true, file, json);
}
private bool disposed = false;
diff --git a/KKdMainLib/DB/Auth.cs b/KKdMainLib/DB/Auth.cs
index 98ef035..607893e 100644
--- a/KKdMainLib/DB/Auth.cs
+++ b/KKdMainLib/DB/Auth.cs
@@ -146,7 +146,7 @@ namespace KKdMainLib.DB
authDB.Add(uid);
}
- authDB.Write(true, file, json);
+ authDB.Write(false, true, file, json);
}
private bool disposed = false;
diff --git a/KKdMainLib/DB/Spr.cs b/KKdMainLib/DB/Spr.cs
index d5f9547..ce2de0a 100644
--- a/KKdMainLib/DB/Spr.cs
+++ b/KKdMainLib/DB/Spr.cs
@@ -251,7 +251,7 @@ namespace KKdMainLib.DB
for (i = 0; i < SpriteSets.Length; i++)
sprDB[i] = SpriteSets[i].WriteMsgPack();
- sprDB.Write(true, file, json);
+ sprDB.Write(false, true, file, json);
}
private bool disposed = false;
diff --git a/KKdMainLib/DEX.cs b/KKdMainLib/DEX.cs
index d016d0e..70b1cd9 100644
--- a/KKdMainLib/DEX.cs
+++ b/KKdMainLib/DEX.cs
@@ -83,7 +83,9 @@ namespace KKdMainLib
_IO = File.OpenWriter(filepath + (format > Format.F && format < Format.FT ? ".dex" : ".bin"), true);
header.Format = _IO.Format = format;
+ _IO.Format = format;
_IO.O = format > Format.F ? 0x20 : 0;
+ _IO.P = 0;
_IO.W(0x64);
_IO.W(Dex.Length);
@@ -157,7 +159,8 @@ namespace KKdMainLib
header.DataSize = offset;
header.SectionSize = offset;
header.Signature = 0x43505845;
- _IO.W(header, true);
+ header.UseSectionSize = true;
+ _IO.W(header);
}
_IO.C();
}
@@ -218,7 +221,7 @@ namespace KKdMainLib
dex[i0] = exp;
}
- dex.Write(true, file, json);
+ dex.Write(false, true, file, json);
}
private bool disposed;
diff --git a/KKdMainLib/DataBank.cs b/KKdMainLib/DataBank.cs
index b3d4e17..886b4f1 100644
--- a/KKdMainLib/DataBank.cs
+++ b/KKdMainLib/DataBank.cs
@@ -133,7 +133,7 @@ namespace KKdMainLib
}
else msgPack.Add(new MsgPack("PvList", null));
}
- msgPack.Write(file, json).Dispose();
+ msgPack.Write(file, false, json).Dispose();
}
public static string UrlEncode(string value) =>
diff --git a/KKdMainLib/Extensions.cs b/KKdMainLib/Extensions.cs
index 9adbaf4..d3d2122 100644
--- a/KKdMainLib/Extensions.cs
+++ b/KKdMainLib/Extensions.cs
@@ -60,7 +60,7 @@ namespace KKdMainLib
}
public static void WEOFC(this Stream stream, int depth = 0) =>
- stream.W(new Header { Depth = depth, Length = 0x20, Signature = 0x43464F45 });
+ stream.W(new Header { Depth = depth, Length = 0x20, Signature = 0x43464F45, UseSectionSize = true });
}
public static class POFExtensions
@@ -68,11 +68,13 @@ namespace KKdMainLib
public static void W(this Stream stream, POF pof, bool shiftX = false, int depth = 0)
{
byte[] data = pof.Write(shiftX);
- Header header = new Header { Depth = depth, Format = Format.F2,
- Length = 0x20, Signature = shiftX ? 0x31464F50 : 0x30464F50 };
- header.DataSize = header.SectionSize = data.Length;
+ Header header = new Header { Depth = depth, Format = Format.F2, Length = 0x20,
+ Signature = shiftX ? 0x31464F50 : 0x30464F50, UseSectionSize = true };
+ header.DataSize = header.SectionSize = data.Length.A(0x10);
stream.W(header);
stream.W(data);
+ for (int c = data.Length.A(0x10) - data.Length; c > 0; c--)
+ stream.W((byte)0);
}
}
@@ -82,7 +84,7 @@ namespace KKdMainLib
{
byte[] data = enrs.Write();
Header header = new Header { Depth = depth, Format = Format.F2,
- Length = 0x20, Signature = 0x53524E45 };
+ Length = 0x20, Signature = 0x53524E45, UseSectionSize = true };
header.DataSize = header.SectionSize = data.Length;
stream.W(header);
stream.W(data);
@@ -184,35 +186,35 @@ namespace KKdMainLib
return MsgPack;
}
- public static void Write(this MsgPack mp, bool temp, string file, bool json = false)
- { if (temp) MsgPack.New.Add(mp).Write(file, json).Dispose();
- else mp .Write(file, json); }
+ public static void Write(this MsgPack mp, bool ignoreNull, bool temp, string file, bool json = false)
+ { if (temp) MsgPack.New.Add(mp).Write(file, ignoreNull, json).Dispose();
+ else mp .Write(file, ignoreNull, json); }
- public static MsgPack Write(this MsgPack mp, string file, bool json = false)
+ public static MsgPack Write(this MsgPack mp, string file, bool ignoreNull, bool json = false)
{
- if (json) using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true))) _IO.W(mp, "\n", " ");
- else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp);
+ if (json) using (JSON _IO = new JSON(File.OpenWriter(file + ".json", true))) _IO.W(mp, ignoreNull, "\n", " ");
+ else using ( MP _IO = new MP(File.OpenWriter(file + ".mp" , true))) _IO.W(mp, ignoreNull);
return mp;
}
- public static void WriteAfterAll(this MsgPack mp, bool temp, string file, bool json = false)
- { if (temp) MsgPack.New.Add(mp).WriteAfterAll(file, json).Dispose();
- else mp .WriteAfterAll(file, json); }
+ public static void WriteAfterAll(this MsgPack mp, bool ignoreNull, bool temp, string file, bool json = false)
+ { if (temp) MsgPack.New.Add(mp).WriteAfterAll(file, ignoreNull, json).Dispose();
+ else mp .WriteAfterAll(file, ignoreNull, json); }
- public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool json = false)
+ public static MsgPack WriteAfterAll(this MsgPack mp, string file, bool ignoreNull, bool json = false)
{
byte[] data = null;
- if (json) using (JSON _IO = new JSON(File.OpenWriter())) { _IO.W(mp, true); data = _IO.ToArray(); }
- else using ( MP _IO = new MP(File.OpenWriter())) { _IO.W(mp ); data = _IO.ToArray(); }
+ if (json) using (JSON _IO = new JSON(File.OpenWriter())) { _IO.W(mp, ignoreNull, true); data = _IO.ToArray(); }
+ else using ( MP _IO = new MP(File.OpenWriter())) { _IO.W(mp, ignoreNull ); data = _IO.ToArray(); }
File.WriteAllBytes(file + (json ? ".json" : ".mp"), data);
return mp;
}
public static void ToJSON (this string file) =>
- file.ReadMP( ).Write(file, true).Dispose();
+ file.ReadMP( ).Write(file, false, true).Dispose();
public static void ToMsgPack(this string file) =>
- file.ReadMP(true).Write(file ).Dispose();
+ file.ReadMP(true).Write(file, false ).Dispose();
}
public static class IKFExt
diff --git a/KKdMainLib/IO/JSON.cs b/KKdMainLib/IO/JSON.cs
index 0970e6e..d00bb3b 100644
--- a/KKdMainLib/IO/JSON.cs
+++ b/KKdMainLib/IO/JSON.cs
@@ -175,18 +175,19 @@ namespace KKdMainLib.IO
{ string s = ""; while (char.IsDigit(_IO.SW().
PCUTF8())) s += _IO.RCUTF8(); return s; }
- public JSON W(MsgPack msgPack, string end = "\n", string tabChar = " ") =>
- W(msgPack, end, tabChar, "", true);
+ public JSON W(MsgPack msgPack, bool ignoreNull, string end = "\n", string tabChar = " ") =>
+ W(msgPack, ignoreNull, end, tabChar, "", true);
- public JSON W(MsgPack msgPack, bool style = false) =>
- W(msgPack, "\n", " ", "", style);
+ public JSON W(MsgPack msgPack, bool ignoreNull, bool style = false) =>
+ W(msgPack, ignoreNull, "\n", " ", "", style);
- private JSON W(MsgPack msgPack, string end, string tabChar, string tab, bool style, bool isArray = false)
+ private JSON W(MsgPack msgPack, bool ignoreNull, string end,
+ string tabChar, string tab, bool style, bool isArray = false)
{
string oldTab = tab;
tab += tabChar;
- if (msgPack.Name != null && !isArray) _IO.W("\"" + msgPack.Name + "\":" + (style ? " " : ""));
- if (msgPack.Object == null) { WN(); return this; }
+ if (msgPack.Name != null && !isArray ) _IO.W("\"" + msgPack.Name + "\":" + (style ? " " : ""));
+ if (msgPack.Object == null) { if (!ignoreNull) WN(); return this; }
if (msgPack.List.NotNull)
{
@@ -196,14 +197,14 @@ namespace KKdMainLib.IO
for (int i = 0; i < msgPack.List.Count; i++)
{
if (style) _IO.W(tab);
- W(msgPack.List[i], end, tabChar, tab, style);
+ W(msgPack.List[i], ignoreNull, end, tabChar, tab, style);
if (i + 1 < msgPack.List.Count) _IO.W(',');
if (style) _IO.W(end);
}
else if (msgPack.List.Count == 1)
{
if (style) _IO.W(tab);
- W(msgPack.List[0], end, tabChar, tab, style);
+ W(msgPack.List[0], ignoreNull, end, tabChar, tab, style);
if (style) _IO.W(end);
}
if (style) _IO.W(oldTab);
@@ -217,20 +218,20 @@ namespace KKdMainLib.IO
for (int i = 0; i < msgPack.Array.Length; i++)
{
if (style) _IO.W(tab);
- W(msgPack.Array[i], end, tabChar, tab, style, true);
+ W(msgPack.Array[i], ignoreNull, end, tabChar, tab, style, true);
if (i + 1 < msgPack.Array.Length) _IO.W(',');
if (style) _IO.W(end);
}
else if (msgPack.Array.Length == 1)
{
if (style) _IO.W(tab);
- W(msgPack.Array[0], end, tabChar, tab, style, true);
+ W(msgPack.Array[0], ignoreNull, end, tabChar, tab, style, true);
if (style) _IO.W(end);
}
if (style) _IO.W(oldTab);
WA(true);
}
- else if (msgPack.Object is MsgPack msg) W(msg, end, tabChar, tab, style);
+ else if (msgPack.Object is MsgPack msg) W(msg, ignoreNull, end, tabChar, tab, style);
else if (msgPack.Object is string str) W(str);
else _IO.W(BaseExtensions.ToS(msgPack.Object));
diff --git a/KKdMainLib/IO/MP.cs b/KKdMainLib/IO/MP.cs
index 8821cd5..b7d6297 100644
--- a/KKdMainLib/IO/MP.cs
+++ b/KKdMainLib/IO/MP.cs
@@ -166,23 +166,23 @@ namespace KKdMainLib.IO
return true;
}
- public MP W(MsgPack msgPack, bool IsArray = false)
+ public MP W(MsgPack msgPack, bool ignoreNull, bool IsArray = false)
{
if (msgPack.Name != null && !IsArray) W(msgPack.Name);
- Write(msgPack.Object);
+ Write(msgPack.Object, ignoreNull);
return this;
}
- private void Write(object obj)
+ private void Write(object obj, bool ignoreNull)
{
- if (obj == null) { WN(); return; }
+ if (obj == null) { if (!ignoreNull) WN(); return; }
switch (obj)
{
case KKdList val: WM(val.Count );
- for (int i = 0; i < val.Count ; i++) W(val[i]); break;
+ for (int i = 0; i < val.Count ; i++) W(val[i], ignoreNull); break;
case MsgPack[] val: WA(val.Length);
- for (int i = 0; i < val.Length; i++) W(val[i]); break;
- case MsgPack val: W(val); break;
+ for (int i = 0; i < val.Length; i++) W(val[i], ignoreNull); break;
+ case MsgPack val: W(val, ignoreNull); break;
case byte[] val: W(val); break;
case bool val: W(val); break;
case sbyte val: W(val); break;
diff --git a/KKdMainLib/KKdMainLib.csproj b/KKdMainLib/KKdMainLib.csproj
index 1c38ef0..ddc7550 100644
--- a/KKdMainLib/KKdMainLib.csproj
+++ b/KKdMainLib/KKdMainLib.csproj
@@ -4,14 +4,14 @@
korenkonder
- korenkonder © 2018-2020
+ korenkonder © 2018-2020
A simple library for working with Project Diva AC/DT/F/AFT/F2/X/FT/M39 files
- 0.4.9.3
+ 0.4.9.4
KKdMainLib
KKdMainLib
net461
KKdMainLib
- 0.4.9.3
+ 0.4.9.4
AnyCPU
diff --git a/KKdMainLib/Mot.cs b/KKdMainLib/Mot.cs
index 8813221..529c316 100644
--- a/KKdMainLib/Mot.cs
+++ b/KKdMainLib/Mot.cs
@@ -184,7 +184,7 @@ namespace KKdMainLib
MsgPack mot = new MsgPack(motCount, "MOT");
for (i = 0; i < motCount; i++)
mot[i] = MsgPackWriter(ref MOT[i]);
- mot.Write(true, file, json);
+ mot.Write(false, true, file, json);
}
public void MsgPackReader(MsgPack msgPack, ref MotHeader mot)
diff --git a/KKdMainLib/MotHead.cs b/KKdMainLib/MotHead.cs
index bb0d92f..50ead0b 100644
--- a/KKdMainLib/MotHead.cs
+++ b/KKdMainLib/MotHead.cs
@@ -674,7 +674,7 @@ RETURN:
I++;
}
motHead.Add(motions);
- motHead.WriteAfterAll(true, file, json);
+ motHead.WriteAfterAll(false, true, file, json);
}
private static int GetSize(int Type) =>
diff --git a/KKdMainLib/STR.cs b/KKdMainLib/STR.cs
index fcf5683..43ba83b 100644
--- a/KKdMainLib/STR.cs
+++ b/KKdMainLib/STR.cs
@@ -41,20 +41,18 @@ namespace KKdMainLib
}
else
{
- _IO.P -= 4;
+ if ((header.Signature >> 24) > 0) { header.Format = Format.DT; _IO.IsBE = true; }
+ else header.Format = Format.F;
int count = 0;
- for (int a = 0, i = 0; _IO.P > 0 && _IO.P < _IO.L; i++, count++)
- {
- a = _IO.RI32();
- if (a == 0) break;
- }
+ for (int i = header.Signature; i != 0 && _IO.P >= 0 && _IO.P < _IO.L; count++)
+ i = _IO.RI32();
Strings = new String[count];
+ _IO.P = 0;
for (int i = 0; i < count; i++)
{
- _IO.PI64 = Strings[i].Str.O;
Strings[i].ID = i;
- Strings[i].Str.V = _IO.NTUTF8();
+ Strings[i].Str.V = _IO.RSaO();
}
}
@@ -67,6 +65,7 @@ namespace KKdMainLib
if (Strings == null || Strings.Length == 0 || header.Format > Format.F2) return;
uint offset = 0;
uint currentOffset = 0;
+ Format format = header.Format;
_IO = File.OpenWriter(filepath + (header.Format > Format.AFT &&
header.Format < Format.FT ? ".str" : ".bin"), true);
_IO.Format = header.Format;
@@ -80,35 +79,34 @@ namespace KKdMainLib
_IO.WX(0x80);
_IO.P = 0x80;
for (int i = 0; i < count; i++) _IO.W(0x00L);
- _IO.A(0x10);
}
else
- {
for (int i = 0; i < count; i++) _IO.W(0x00);
- _IO.A(0x20);
- }
+ _IO.A(0x10);
KKdList usedSTR = KKdList.New;
KKdList usedSTRPos = KKdList.New;
int[] STRPos = new int[count];
- usedSTRPos.Add(_IO.P);
- usedSTR.Add("");
- _IO.W(0);
for (int i = 0; i < count; i++)
{
- if (!usedSTR.Contains(Strings[i].Str.V))
+ if (usedSTR.Contains(Strings[i].Str.V))
{
- STRPos[i] = _IO.P;
- usedSTRPos.Add(STRPos[i]);
- usedSTR.Add(Strings[i].Str.V);
- _IO.W(Strings[i].Str.V);
- _IO.W(0);
+ for (int i2 = 0; i2 < count; i2++)
+ if (usedSTR[i2] == Strings[i].Str.V)
+ { STRPos[i] = usedSTRPos[i2]; break; }
}
else
- for (int i2 = 0; i2 < count; i2++)
- if (usedSTR[i2] == Strings[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; }
+ {
+ usedSTRPos.Add(STRPos[i] = _IO.P);
+ usedSTR.Add(Strings[i].Str.V);
+ _IO.W(Strings[i].Str.V);
+ _IO.W((byte)0);
+ if (format < Format.F) _IO.A(0x8);
+ }
}
+ _IO.A(0x4);
+ _IO.L = _IO.P;
if (_IO.Format > Format.AFT)
{
@@ -124,32 +122,37 @@ namespace KKdMainLib
_IO.PU32 = offset;
_IO.W(pof, false, 1);
+ _IO.WEOFC(1);
currentOffset = _IO.PU32;
_IO.WEOFC();
header.DataSize = (int)(currentOffset - 0x40);
header.Signature = 0x41525453;
header.SectionSize = (int)(offset - 0x40);
+ header.UseSectionSize = true;
_IO.P = 0;
_IO.W(header, true);
}
else
{
_IO.P = 0;
- for (int i = 0; i < count; i++) _IO.W(STRPos[i]);
+ _IO.IsBE = header.Format < Format.F;
+ for (int i = 0; i < count; i++) _IO.WE(STRPos[i]);
}
_IO.C();
}
public void MsgPackReader(string file, bool json)
{
+ header = default;
+ Strings = default;
MsgPack temp;
MsgPack msgPack = file.ReadMPAllAtOnce(json);
- if ((temp = msgPack["STR"]).NotNull) return;
+ if ((temp = msgPack["STR"]).IsNull) return;
header = new Header();
- System.Enum.TryParse(temp.RS("Format"), out header.Format);
+ if (!System.Enum.TryParse(temp.RS("Format"), out header.Format)) return;
- if ((temp = msgPack["Strings", true]).IsNull) return;
+ if ((temp = temp["Strings", true]).IsNull) return;
Strings = new String[temp.Array.Length];
for (int i = 0; i < Strings.Length; i++)
@@ -176,7 +179,7 @@ namespace KKdMainLib
}
str.Add(strings);
- str.WriteAfterAll(true, file, json);
+ str.WriteAfterAll(false, true, file, json);
}
private bool disposed;
diff --git a/KKdMainLib/Tables.cs b/KKdMainLib/Tables.cs
index c15ebba..e9a5753 100644
--- a/KKdMainLib/Tables.cs
+++ b/KKdMainLib/Tables.cs
@@ -943,7 +943,7 @@ namespace KKdMainLib
}
msgPack.Add(sliderTouchSETable);
}
- if (msgPack.List.Count == 1) msgPack.Write(file, json);
+ if (msgPack.List.Count == 1) msgPack.Write(file, false, json);
}
private bool disposed;
diff --git a/KKdSoundLib/KKdSoundLib.csproj b/KKdSoundLib/KKdSoundLib.csproj
index 107e581..7acd409 100644
--- a/KKdSoundLib/KKdSoundLib.csproj
+++ b/KKdSoundLib/KKdSoundLib.csproj
@@ -4,7 +4,7 @@
korenkonder
- korenkonder © 2019-2020
+ korenkonder © 2019-2020
A simple library for working with Project Diva F/AFT/F2/X/FT audio files
0.1.2.0
KKdSoundLib
diff --git a/PD_Tool/Program.cs b/PD_Tool/Program.cs
index 8ff8152..1fac32d 100644
--- a/PD_Tool/Program.cs
+++ b/PD_Tool/Program.cs
@@ -29,7 +29,8 @@ namespace PD_Tool
foreach (string arg in args)
{
GC.Collect();
- if (Directory.Exists(arg)) using (KKdFARC FARC = new KKdFARC(arg, true)) FARC.Pack();
+ if (Directory.Exists(arg))
+ using (KKdFARC FARC = new KKdFARC(arg, true) { CompressionLevel = 9 }) FARC.Pack();
else if (File.Exists(arg) && Path.GetExtension(arg) == ".farc")
using (KKdFARC farc = new KKdFARC(arg)) farc.Unpack(true);
else if (File.Exists(arg))
@@ -46,7 +47,7 @@ namespace PD_Tool
private static void MainMenu()
{
- Console.Title = "PD_Tool v0.4.9.3.2";
+ Console.Title = "PD_Tool v0.4.9.4";
Console.Clear();
ConsoleDesign(true);
@@ -106,8 +107,8 @@ namespace PD_Tool
ConsoleDesign("5. DIVA" );
ConsoleDesign("6. MotHead" );
ConsoleDesign("7. MOT" );
- ConsoleDesign("8. Table" );
- ConsoleDesign("9. STR" );
+ ConsoleDesign("8. STR" );
+ ConsoleDesign("9. Table" );
ConsoleDesign(false);
ConsoleDesign("R. Return to Main Menu");
ConsoleDesign(false);
@@ -123,8 +124,8 @@ namespace PD_Tool
else if (localChoose == "5") DIV.Processor();
else if (localChoose == "6") MHD.Processor(json);
else if (localChoose == "7") MOT.Processor(json);
- else if (localChoose == "8") TBL.Processor(json);
- else if (localChoose == "9") STR.Processor(json);
+ else if (localChoose == "8") STR.Processor(json);
+ else if (localChoose == "9") TBL.Processor(json);
else choose = localChoose;
}
else if (choose[0] == '6')
@@ -206,8 +207,8 @@ namespace PD_Tool
ConsoleDesign("5. DIVA" );
ConsoleDesign("6. MotHead" );
ConsoleDesign("7. MOT" );
- ConsoleDesign("8. Table" );
- ConsoleDesign("9. STR" );
+ ConsoleDesign("8. STR" );
+ ConsoleDesign("9. Table" );
ConsoleDesign(false);
ConsoleDesign("R. Return to Main Menu");
ConsoleDesign(false);
@@ -223,8 +224,8 @@ namespace PD_Tool
else if (localChoose == "5") DIV.Processor();
else if (localChoose == "6") MHD.Processor(json);
else if (localChoose == "7") MOT.Processor(json);
- else if (localChoose == "8") TBL.Processor(json);
- else if (localChoose == "9") STR.Processor(json);
+ else if (localChoose == "8") STR.Processor(json);
+ else if (localChoose == "9") TBL.Processor(json);
else choose = localChoose;
}
else if (choose == "9")
@@ -294,6 +295,8 @@ namespace PD_Tool
string Filter = GetArgs("All;", false, "*");
if (filetype == "a3da") Filter = GetArgs("A3DA", "a3da", "farc", "json", "mp") +
GetArgs("A3DA", true, "a3da") + GetArgs("FARC", true, "farc") + json + mp;
+ else if (filetype == "adp" ) Filter = GetArgs("ADP" , "adp", "json", "mp") +
+ GetArgs("ADP", true, "adp" ) + json + mp;
else if (filetype == "bin" ) Filter = GetArgs("BIN" , "bin", "json", "mp") +
bin + json + mp;
else if (filetype == "blt" ) Filter = GetArgs("BLT" , "blt");
diff --git a/PD_Tool/Properties/AssemblyInfo.cs b/PD_Tool/Properties/AssemblyInfo.cs
index 1912310..3dc05d3 100644
--- a/PD_Tool/Properties/AssemblyInfo.cs
+++ b/PD_Tool/Properties/AssemblyInfo.cs
@@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7B5D5A3A-A6F8-4813-C97D-ACFC98F7397E")]
-[assembly: AssemblyVersion("0.4.9.3")]
-[assembly: AssemblyFileVersion("0.4.9.3")]
+[assembly: AssemblyVersion("0.4.9.4")]
+[assembly: AssemblyFileVersion("0.4.9.4")]