Compare commits

...
3 Commits
Author SHA1 Message Date
korenkonder cd2eab5b8e Release v0.4.9.4.2 (Hotfix)
STR
2020-06-19 19:09:36 +03:00
korenkonder 8dd10b2fa4 Release v0.4.9.4.1 (Hotfix)
STR
2020-06-19 18:57:04 +03:00
korenkonder 35dee99307 Release v0.4.9.4
A3DA, DEX, STR
2020-06-19 14:09:15 +03:00
24 changed files with 201 additions and 132 deletions
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder © 2019-2020</Copyright>
<Copyright>korenkonder © 2019-2020</Copyright>
<Description>A base library</Description>
<FileVersion>0.4.9.3</FileVersion>
<FileVersion>0.4.9.4</FileVersion>
<PackageId>KKdBaseLib</PackageId>
<Product>KKdBaseLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdBaseLib</Title>
<Version>0.4.9.3</Version>
<Version>0.4.9.4</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+3 -3
View File
@@ -73,7 +73,7 @@ namespace KKdBaseLib
public void Add(KeyValuePair<TKey, TValue> pair)
{
if (IsNull) return;
if (IsNull || ContainsKey(pair.Key)) return;
count++;
if (keyArray.Length < count) System.Array.Resize(ref keyArray, count);
@@ -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})";
}
}
+50 -23
View File
@@ -2,10 +2,9 @@ using System;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using KKdBaseLib;
using A3DADict = System.Collections.Generic.Dictionary<string, object>;
namespace KKdMainLib
namespace KKdBaseLib
{
public static unsafe class Main
{
@@ -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<T>(this A3DADict dict, out T value, string args) where T : struct
{ if (dict.FV(out string val , args.Split('.' )))
{ bool Val = int.TryParse(val, out int _value);
value = _value; return Val; } value = null; return false; }
{ 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<T>(this A3DADict dict, out T? value, string args) where T : struct
{ if (dict.FV(out string val , args.Split('.' )))
{ bool Val = Enum.TryParse(val, out T _value); value = _value; return Val; }
value = null; return false; }
public static bool FV (this A3DADict dict, out string value, string args) =>
dict.FV(out value, args.Split('.' ));
public static bool FV(this A3DADict dict, out string value, string[] args)
@@ -129,6 +138,24 @@ namespace KKdMainLib
return true;
}
public static bool FK(this A3DADict dict, string args) =>
dict.FK(args.Split('.' ));
public static bool FK(this A3DADict dict, string[] args)
{
if (dict == null || args.Length < 1) return false;
args[0] = args[0].ToLower();
if (!dict.ContainsKey(args[0])) return false;
else if (args.Length > 1)
{
string[] newArgs = new string[args.Length - 1];
for (int i = 0; i < args.Length - 1; i++) newArgs[i] = args[i + 1];
return ((A3DADict)dict[args[0]]).FK(newArgs);
}
return true;
}
public static void GD(this A3DADict dict, string args, char split = '.')
{
string[] dataArray = args.Split('=');
+23 -1
View File
@@ -47,7 +47,12 @@ namespace KKdBaseLib
public MsgPack this[string key, bool array]
{ get { if (!array) return this[key];
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
if (Object is KKdList<MsgPack> List) { MsgPack MsgPack = List[ElementIndex(key)];
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
public MsgPack this[bool startsWith, string key]
{ get { if (Object is KKdList<MsgPack> List) { MsgPack MsgPack =
List[startsWith ? ElementIndexStartsWith(key) : ElementIndex(key)];
return MsgPack.Object is MsgPack[] ? MsgPack : default; } return default; } }
public MsgPack Add(MsgPack obj)
@@ -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);
}
}
+10 -8
View File
@@ -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)
{
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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<Scene> aetData)
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+5 -2
View File
@@ -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;
+1 -1
View File
@@ -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) =>
+21 -19
View File
@@ -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
+13 -12
View File
@@ -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));
+7 -7
View File
@@ -166,23 +166,23 @@ namespace KKdMainLib.IO
return true;
}
public MP W(MsgPack msgPack, bool IsArray = false)
public MP W(MsgPack msgPack, bool ignoreNull, bool IsArray = false)
{
if (msgPack.Name != null && !IsArray) W(msgPack.Name);
Write(msgPack.Object);
Write(msgPack.Object, ignoreNull);
return this;
}
private void Write(object obj)
private void Write(object obj, bool ignoreNull)
{
if (obj == null) { WN(); return; }
if (obj == null) { if (!ignoreNull) WN(); return; }
switch (obj)
{
case KKdList<MsgPack> val: WM(val.Count );
for (int i = 0; i < val.Count ; i++) W(val[i]); break;
for (int i = 0; i < val.Count ; i++) W(val[i], ignoreNull); break;
case MsgPack[] val: WA(val.Length);
for (int i = 0; i < val.Length; i++) W(val[i]); break;
case MsgPack val: W(val); break;
for (int i = 0; i < val.Length; i++) W(val[i], ignoreNull); break;
case MsgPack val: W(val, ignoreNull); break;
case byte[] val: W(val); break;
case bool val: W(val); break;
case sbyte val: W(val); break;
+3 -3
View File
@@ -4,14 +4,14 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder © 2018-2020</Copyright>
<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.3</FileVersion>
<FileVersion>0.4.9.4</FileVersion>
<PackageId>KKdMainLib</PackageId>
<Product>KKdMainLib</Product>
<TargetFramework>net461</TargetFramework>
<Title>KKdMainLib</Title>
<Version>0.4.9.3</Version>
<Version>0.4.9.4</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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) =>
+37 -28
View File
@@ -22,6 +22,8 @@ namespace KKdMainLib
if (header.Signature == 0x41525453)
{
header = _IO.ReadHeader(true, false);
_IO.IsBE = header.UseBigEndian;
_IO.Format = header.Format;
int count = _IO.RI32E();
int offset = _IO.RI32E();
@@ -41,20 +43,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,9 +67,11 @@ 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;
_IO.IsBE = header.UseBigEndian;
pof.Offsets = KKdList<long>.New;
long count = Strings.LongLength;
@@ -80,35 +82,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<string> usedSTR = KKdList<string>.New;
KKdList<int> usedSTRPos = KKdList<int>.New;
int[] STRPos = new int[count];
usedSTRPos.Add(_IO.P);
usedSTR.Add("");
_IO.W(0);
for (int i = 0; i < count; i++)
{
if (!usedSTR.Contains(Strings[i].Str.V))
if (usedSTR.Contains(Strings[i].Str.V))
{
STRPos[i] = _IO.P;
usedSTRPos.Add(STRPos[i]);
usedSTR.Add(Strings[i].Str.V);
_IO.W(Strings[i].Str.V);
_IO.W(0);
for (int i2 = 0; i2 < count; i2++)
if (usedSTR[i2] == Strings[i].Str.V)
{ STRPos[i] = usedSTRPos[i2]; break; }
}
else
for (int i2 = 0; i2 < count; i2++)
if (usedSTR[i2] == Strings[i].Str.V) { STRPos[i] = usedSTRPos[i2]; break; }
{
usedSTRPos.Add(STRPos[i] = _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 +125,39 @@ 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;
bool? isBE = temp.RnB("UseBigEndian");
if (isBE.HasValue) header.UseBigEndian = isBE.Value;
if ((temp = msgPack["Strings", true]).IsNull) return;
if ((temp = temp["Strings", true]).IsNull) return;
Strings = new String[temp.Array.Length];
for (int i = 0; i < Strings.Length; i++)
@@ -166,6 +174,7 @@ namespace KKdMainLib
{
if (Strings == null || Strings.Length == 0) return;
MsgPack str = new MsgPack("STR").Add("Format", header.Format.ToString());
if (header.UseBigEndian) str.Add("UseBigEndian", header.UseBigEndian);
MsgPack strings = new MsgPack(Strings.Length, "Strings");
for (int i = 0; i < Strings.Length; i++)
{
@@ -176,7 +185,7 @@ namespace KKdMainLib
}
str.Add(strings);
str.WriteAfterAll(true, file, json);
str.WriteAfterAll(false, true, file, json);
}
private bool disposed;
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -4,7 +4,7 @@
<Authors>korenkonder</Authors>
<Company></Company>
<Configuration></Configuration>
<Copyright>korenkonder © 2019-2020</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.2.0</FileVersion>
<PackageId>KKdSoundLib</PackageId>
+13 -10
View File
@@ -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");
+2 -2
View File
@@ -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")]