Skip to content

Commit

Permalink
ファイル一覧をCSV型式でエクスポートするように。(win32rebootディレクトリの場合は親ディレクトリ名も含める)
Browse files Browse the repository at this point in the history
  • Loading branch information
logue committed Oct 3, 2021
1 parent 74a3219 commit a6f05a9
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 70 deletions.
2 changes: 2 additions & 0 deletions NgsPacker/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// 多言語化
_ = containerRegistry.RegisterInstance<ILocalizerService>(Container.Resolve<LocalizerService>());

_ = containerRegistry.RegisterInstance<IProgressContentDialogService>(Container.Resolve<ProgressContentDialogService>());
// Zamboni
_ = containerRegistry.RegisterInstance<IZamboniService>(Container.Resolve<ZamboniService>());

Expand Down
17 changes: 17 additions & 0 deletions NgsPacker/Interfaces/IProgressContentDialogService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// -----------------------------------------------------------------------
// <copyright file="IProgressContentDialogService.cs" company="Logue">
// Copyright (c) 2021 Masashi Yoshikawa All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>
// -----------------------------------------------------------------------

using System.Threading.Tasks;

namespace NgsPacker.Services
{
public interface IProgressContentDialogService
{
Task ShowAsync();
void Hide();
}
}
6 changes: 5 additions & 1 deletion NgsPacker/NgsPacker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
<RepositoryType>git</RepositoryType>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>1.0.1</Version>
<Version>1.1.0</Version>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<PackageTags>PSO2;Phantasy Star Online2;Phantasy Star Online New Genesis;PSO2NGS;Packer;Unpacker</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<ApplicationIcon>ice-cubes.ico</ApplicationIcon>
<PackageIcon>ice-cubes.png</PackageIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
Expand Down Expand Up @@ -58,6 +59,9 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Update="Resources\ice-cubes.png">
<Pack>True</Pack>
</None>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
Expand Down
11 changes: 10 additions & 1 deletion NgsPacker/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions NgsPacker/Properties/Resources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,7 @@
<data name="ExportFileListText" xml:space="preserve">
<value>ファイル一覧を出力</value>
</data>
<data name="ExportFileListInformationText" xml:space="preserve">
<value>PSO2のdataディレクトリ内にあるwin32(PSO2のデータ)か、win32_reboot(PSO2NGSのデータ)ディレクトリを選択してください。</value>
</data>
</root>
3 changes: 3 additions & 0 deletions NgsPacker/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,7 @@ USE AT YOUR OWN RISK.</value>
<data name="ExportFileListText" xml:space="preserve">
<value>Export Filelist</value>
</data>
<data name="ExportFileListInformationText" xml:space="preserve">
<value>Select the win32 (PSO2 data) or win32_reboot (PSO2NGS data) directory in the PSO2 data directory.</value>
</data>
</root>
25 changes: 25 additions & 0 deletions NgsPacker/Services/ProgressContentDialogService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using NgsPacker.Views;
using System.Threading.Tasks;

namespace NgsPacker.Services
{
public class ProgressContentDialogService : IProgressContentDialogService
{
private ProgressContentDialog contentDialog;

public ProgressContentDialogService()
{
contentDialog = new();
}

public async Task ShowAsync()
{
_ = await contentDialog.ShowAsync();
}

public void Hide()
{
contentDialog.Hide();
}
}
}
99 changes: 52 additions & 47 deletions NgsPacker/Services/ZamboniService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void Unpack(string inputPath, string outputPath = null, bool sepalate = f

foreach (IceEntryModel model in groupOneFiles.Concat(groupTwoFiles))
{
Debug.WriteLine(model.FileName);
// ファイル名(ひどい可読性だ)
string fileName = destinaton + (sepalate ?
(model.Group == IceGroupEnum.GROUP1 ? "group1" : "group2") + Path.DirectorySeparatorChar : "")
Expand All @@ -171,76 +172,80 @@ public void Unpack(string inputPath, string outputPath = null, bool sepalate = f
/// ファイル一覧を取得
/// </summary>
/// <param name="inputPath">解析するdataディレクトリ</param>
/// <returns></returns>
/// <returns>CSV配列</returns>
public List<string> Filelist(string inputPath)
{
List<string> ret = new();
string[] entries = Directory.EnumerateFiles(inputPath, "*.*", SearchOption.AllDirectories).ToArray();
Debug.WriteLine("Entries: ", entries.Length);

// CSVのヘッダ
ret.Add("filename,version,group,content");
foreach (string path in entries)
{
if (path.Contains("."))
{
continue;
}
Debug.WriteLine(path);
// Iceファイルを読み込む
using (FileStream fileStream = File.OpenRead(path))

// Iceファイルをバイトとして読み込む
byte[] buffer = File.ReadAllBytes(path);

// Iceファイルのヘッダチェック
if (buffer.Length <= 127 || buffer[0] != 73 || buffer[1] != 67 || buffer[2] != 69 || buffer[3] != 0)
{
byte[] numArray = new byte[4];
_ = fileStream.Read(numArray, 0, 4);
_ = fileStream.Seek(0L, SeekOrigin.Begin);

continue;
}

string str1 = Encoding.ASCII.GetString(numArray).Replace("\0", "");
if (str1 != "ICE")
{
fileStream.Close();
// ICEファイルでない
continue;
}

ret.Add(Path.GetFileName(path) + "\t\t\t" + str1);
// メモリーストリームを生成
using MemoryStream ms = new(buffer);
// ヘッダを確認
_ = ms.Seek(8L, SeekOrigin.Begin);
int num = ms.ReadByte();
_ = ms.Seek(0L, SeekOrigin.Begin);

// Iceファイルをパースする
IceFile iceFile = IceFile.LoadIceFile(fileStream);

FileInfo fileInfo = new(path);

if (iceFile == null)
{
fileStream.Close();
// パース不能
continue;
}
// NGSのデータファイルの場合、親ディレクトリのパスも含める
string ice =
(fileInfo.Directory.Name != "win32" ? fileInfo.Directory.Name + Path.DirectorySeparatorChar : "")
+ fileInfo.Name + ",ICE" + num + ",";

// グループ1のファイルをパース
if (iceFile.groupOneFiles != null)
// Iceファイルを読み込む
IceFile iceFile = IceFile.LoadIceFile(ms);
if (iceFile == null)
{
ret.Add(ice + "0,ERROR");
continue;
}



// グループ1のファイルをパース
if (iceFile.groupOneFiles != null)
{
byte[][] groupOneFiles = iceFile.groupOneFiles;
for (int index = 0; index < groupOneFiles.Length; ++index)
{
ret.Add("\tGroup 1:");
byte[][] groupOneFiles = iceFile.groupOneFiles;
for (int index = 0; index < groupOneFiles.Length; ++index)
{
int int32 = BitConverter.ToInt32(groupOneFiles[index], 16);
string str2 = Encoding.ASCII.GetString(groupOneFiles[index], 64, int32).TrimEnd(new char[1]);
ret.Add("\t\t" + str2);
}
int int32 = BitConverter.ToInt32(groupOneFiles[index], 16);
string str2 = Encoding.ASCII.GetString(groupOneFiles[index], 64, int32).TrimEnd(new char[1]);
ret.Add(ice + "1," + str2);
}
}

// グループ2のファイルをパース
if (iceFile.groupOneFiles != null)
// グループ2のファイルをパース
if (iceFile.groupOneFiles != null)
{
byte[][] groupTwoFiles = iceFile.groupTwoFiles;
for (int index = 0; index < groupTwoFiles.Length; ++index)
{
ret.Add("\tGroup 2:");
byte[][] groupTwoFiles = iceFile.groupTwoFiles;
for (int index = 0; index < groupTwoFiles.Length; ++index)
{
int int32 = BitConverter.ToInt32(groupTwoFiles[index], 16);
string str2 = Encoding.ASCII.GetString(groupTwoFiles[index], 64, int32).TrimEnd(new char[1]);
ret.Add("\t\t" + str2);
}

int int32 = BitConverter.ToInt32(groupTwoFiles[index], 16);
string str2 = Encoding.ASCII.GetString(groupTwoFiles[index], 64, int32).TrimEnd(new char[1]);
ret.Add(ice + "2," + str2);
}
}
ret.Add("");
ret.Add("");
}
return ret;
}
Expand Down
Loading

0 comments on commit a6f05a9

Please sign in to comment.