Skip to content

Commit

Permalink
Added ability to export in Json format
Browse files Browse the repository at this point in the history
  • Loading branch information
Endergreen12 committed May 6, 2024
1 parent f8c4393 commit 7d4541d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
30 changes: 29 additions & 1 deletion Func.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ public enum Message
SpecifyMediaType,
FailedToParseMediaType,

// Loading
// Loading, Copying
MediaCatalogLoading,
DirCreated,
CopyStart,
SourceFileNotFound,
AskExportJson,
JsonExported,
Done
}

Expand Down Expand Up @@ -220,6 +222,32 @@ public static string getLocalizedString(Message message, Language language) // T
}
break;

case Message.AskExportJson:
switch (language)
{
case Language.Japanese:
locString = "MediaCatalogをJson形式でエクスポートすることができます。エクスポートしますか?(Y/N)";
break;

default:
locString = "You can export MediaCatalog in Json format. Do you want to export? (Y/N)";
break;
}
break;

case Message.JsonExported:
switch (language)
{
case Language.Japanese:
locString = "{0}をエクスポートしました";
break;

default:
locString = "Exported {0}";
break;
}
break;

case Message.Done:
switch (language)
{
Expand Down
26 changes: 22 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
using static Blue_Archive_Assets_Converter.Func;
using MemoryPack;
using System.Reflection;
using System.Reflection.Metadata;
using System.Text.Json;

Console.WriteLine("Blue Archive Assets Converter v{0} | Endergreen12", Assembly.GetExecutingAssembly().GetName().Version);
breakLine();

string mediaPatchPath = "";
Language language;

if (args.Length == 0 || !Enum.TryParse<Language>(args[0], out language)) // Override language | 言語をオーバーライド
{
language = getUserLanguage();
Expand Down Expand Up @@ -63,7 +64,7 @@
Console.WriteLine(getLocalizedString(Message.SpecifyMediaType, language));
Console.WriteLine(String.Join(Environment.NewLine, Enum.GetNames<MediaType>())); // List of MediaType | MediaTypeの一覧
userSpecifiedMediaType = Console.ReadLine();
if(userSpecifiedMediaType != "" && !Enum.TryParse<MediaType>(userSpecifiedMediaType, out specifiedMediaType)) // Failed to parse MediaType | MediaTypeのParseに失敗
if(userSpecifiedMediaType != "" && !Enum.TryParse(userSpecifiedMediaType, out specifiedMediaType)) // Failed to parse MediaType | MediaTypeのParseに失敗
{
Console.WriteLine(getLocalizedString(Message.FailedToParseMediaType, language));
pressAnyKey(language);
Expand All @@ -73,7 +74,7 @@


/*
Loading | ローディング
Loading, Copying | ローディング、コピー
*/


Expand Down Expand Up @@ -117,7 +118,7 @@



/* Copy files | ファイルをコピー */
/* Copy source files to output folder | ソースファイルをoutputフォルダにコピー */
// Since the file name contains Crc, use it to confirm its existence // TODO: Reveal the mysterious UInt64 numbers in front of the Crc | Crcの前についてる謎のUInt64の数字の正体を明かす
// ファイル名にCrcを含んでいるのでそれを利用して存在を確認する // This one is a mystery | こいつが謎 -> [652901576978586]_[4235271580] <- This is Crc | これはCrc
string[] srcFileArray = Directory.GetFiles(mediaPatchPath, "*_" + media.Crc.ToString());
Expand All @@ -139,6 +140,7 @@
Console.Write(new string(' ', lastLogLength));
Console.SetCursorPosition(curPos.Left, curPos.Top);

// Write log | ログを出力
if(srcFileArray.Length > 0)
{
string log = srcFileArray[0] + " -> " + media.Path;
Expand All @@ -153,7 +155,23 @@
lastLogLength = 0;
}
}
breakLine();



/* Export MediaCatalog as json | json形式でのMediaCatalogのエクスポート */
Console.WriteLine(getLocalizedString(Message.AskExportJson, language));
if(Console.ReadLine().Equals("y", StringComparison.OrdinalIgnoreCase))
{
string catalogJsonName = "MediaCatalog.json";
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(catalogJsonName, JsonSerializer.Serialize(mediaCatalog, jsonSerializerOptions));
breakLine();
Console.WriteLine(getLocalizedString(Message.JsonExported, language), catalogJsonName);
}
breakLine(2);



Console.WriteLine(getLocalizedString(Message.Done, language), outputFolderName, Directory.GetCurrentDirectory());
pressAnyKey(language);

0 comments on commit 7d4541d

Please sign in to comment.