Skip to content

Commit

Permalink
パックとアンパックとでページを分けた。
Browse files Browse the repository at this point in the history
グループ設定をパック画面に移動
機能していない戻るボタンを削除
  • Loading branch information
logue committed Oct 8, 2021
1 parent 3491d6b commit 56e195a
Show file tree
Hide file tree
Showing 19 changed files with 522 additions and 336 deletions.
5 changes: 3 additions & 2 deletions NgsPacker/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
_ = containerRegistry.RegisterInstance<IZamboniService>(Container.Resolve<ZamboniService>());

// ページの登録
containerRegistry.RegisterForNavigation<HomePage>();
containerRegistry.RegisterForNavigation<UnpackPage>();
containerRegistry.RegisterForNavigation<PackPage>();
containerRegistry.RegisterForNavigation<AboutPage>();
containerRegistry.RegisterForNavigation<SettingsPage>();
}
Expand All @@ -119,7 +120,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
// 進捗ダイアログモジュール
moduleCatalog.AddModule<ProgressDialog.Module>();
_ = moduleCatalog.AddModule<ProgressDialog.Module>();
}
}
}
3 changes: 2 additions & 1 deletion NgsPacker/NgsPacker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<RepositoryType>git</RepositoryType>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>1.1.1</Version>
<Version>1.2.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>
Expand All @@ -40,6 +40,7 @@
<PackageReference Include="WPFLocalizeExtension" Version="3.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ProgressDialogModule\ProgressDialog.csproj" />
<ProjectReference Include="..\ZamboniLib\ZamboniLib\ZamboniLib.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
32 changes: 29 additions & 3 deletions NgsPacker/Properties/Resources.Designer.cs

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

14 changes: 11 additions & 3 deletions NgsPacker/Properties/Resources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@
<value>処理完了時にデスクトップ通知を出します。</value>
</data>
<data name="WhiteListText" xml:space="preserve">
<value>グループ1に分類するファイル
(後方一致・改行区切り)</value>
<value>グループ1に分類するファイル(後方一致・改行区切り)</value>
</data>
<data name="UnpackText" xml:space="preserve">
<value>アンパック</value>
Expand Down Expand Up @@ -205,7 +204,7 @@
<value>ファイル一覧を出力</value>
</data>
<data name="ExportFileListInformationText" xml:space="preserve">
<value>PSO2のdataディレクトリ内にあるwin32(PSO2のデータ)か、win32_reboot(PSO2NGSのデータ)ディレクトリを選択してください。</value>
<value>データファイルに含まれるファイル一覧をCSV型式で出力します。PSO2のdataディレクトリ内にあるwin32(PSO2のデータ)か、win32_reboot(PSO2NGSのデータ)ディレクトリを選択してください。</value>
</data>
<data name="Pso2BinPathText" xml:space="preserve">
<value>pso2_binのパス:</value>
Expand All @@ -229,4 +228,13 @@
<data name="PackInputPathText" xml:space="preserve">
<value>パックしたいファイルの入ったフォルダを指定してください。</value>
</data>
<data name="UnpackByFileListText" xml:space="preserve">
<value>ファイルリストからアンパックする</value>
</data>
<data name="UnpackByFilelistInformationText" xml:space="preserve">
<value>改行区切りのファイルリストに含まれるファイルのみを一括アンパックします。</value>
</data>
<data name="SaveText" xml:space="preserve">
<value>保存</value>
</data>
</root>
14 changes: 11 additions & 3 deletions NgsPacker/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@
<value>A desktop notification is issued when the process is completed.</value>
</data>
<data name="WhiteListText" xml:space="preserve">
<value>File name to classify into group 1
(last match, Line break delimiter)</value>
<value>File name to classify into group 1 (last match, Line break delimiter)</value>
</data>
<data name="UnpackText" xml:space="preserve">
<value>Unpack</value>
Expand Down Expand Up @@ -209,7 +208,7 @@ USE AT YOUR OWN RISK.</value>
<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>
<value>Outputs the list of files included in the data file in CSV format. Select the win32 (PSO2 data) or win32_reboot (PSO2NGS data) directory in the PSO2 data directory.</value>
</data>
<data name="Pso2BinPathText" xml:space="preserve">
<value>Path of pso2_bin Path:</value>
Expand All @@ -233,4 +232,13 @@ Please select the correct directory.</value>
<data name="PackInputPathText" xml:space="preserve">
<value>Specify the folder that contains the files you want to pack.</value>
</data>
<data name="UnpackByFileListText" xml:space="preserve">
<value>Unpack from file list</value>
</data>
<data name="UnpackByFilelistInformationText" xml:space="preserve">
<value>Batch unpacks only the files contained in the line-delimited file list.</value>
</data>
<data name="SaveText" xml:space="preserve">
<value>Save</value>
</data>
</root>
3 changes: 1 addition & 2 deletions NgsPacker/Services/ZamboniService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using ImTools;
using NgsPacker.Exeptions;
using NgsPacker.Helpers;
using NgsPacker.Interfaces;
using NgsPacker.Models;
using Prism.Events;
Expand Down Expand Up @@ -206,7 +205,7 @@ public Task Unpack(string inputPath, string outputPath = null, bool sepalate = f
public async Task<List<string>> Filelist(string inputPath)
{
List<string> ret = new();
List<string> entries = new (Directory.EnumerateFiles(inputPath, "*.*", SearchOption.AllDirectories));
List<string> entries = new(Directory.EnumerateFiles(inputPath, "*.*", SearchOption.AllDirectories));
Debug.WriteLine("Entries: ", entries.Count);

// CSVのヘッダ
Expand Down
28 changes: 26 additions & 2 deletions NgsPacker/ViewModels/AboutPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@

namespace NgsPacker.ViewModels
{
/// <summary>
/// バージョン情報ページビューモデル
/// </summary>
public class AboutPageViewModel : BindableBase
{
/// <summary>
/// Gets the VisitCommand
/// プロジェクトサイト閲覧ボタンのコマンド.
/// </summary>
public DelegateCommand VisitCommand { get; }

/// <summary>
/// NexusModsサイト閲覧ボタンのコマンド.
/// </summary>
public DelegateCommand VisitNexusModsCommand { get; }

/// <summary>
/// ロゴ画像.
/// </summary>
Expand All @@ -39,6 +46,7 @@ public class AboutPageViewModel : BindableBase
public AboutPageViewModel()
{
VisitCommand = new DelegateCommand(ExecuteVisitCommand);
VisitNexusModsCommand = new DelegateCommand(ExecuteVisitNexusModsCommand);
Assembly = new AppAssemblyModel();

Logo = BitmapToImageSource.Convert(Properties.Resources.AppIcon);
Expand All @@ -49,7 +57,23 @@ public AboutPageViewModel()
/// </summary>
private void ExecuteVisitCommand()
{
string url = "https://github.com/logue/NgsPacker";
Go("https://github.com/logue/NgsPacker");
}

/// <summary>
/// NexusModsへ
/// </summary>
private void ExecuteVisitNexusModsCommand()
{
Go("https://www.nexusmods.com/phantasystaronline2newgenesis/mods/26");
}

/// <summary>
/// リンク
/// </summary>
/// <param name="url"></param>
private static void Go(string url)
{
try
{
_ = Process.Start(url);
Expand Down
154 changes: 154 additions & 0 deletions NgsPacker/ViewModels/PackPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// -----------------------------------------------------------------------
// <copyright file="HomePageViewModel.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 Microsoft.Toolkit.Uwp.Notifications;
using NgsPacker.Helpers;
using NgsPacker.Interfaces;
using Prism.Commands;
using Prism.Mvvm;
using SourceChord.FluentWPF;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NgsPacker.ViewModels
{
/// <summary>
/// パックページビューモデル
/// </summary>
public class PackPageViewModel : BindableBase
{
/// <summary>
/// 多言語化サービス
/// </summary>
private readonly ILocalizerService LocalizerService;

/// <summary>
/// Zamboniサービス
/// </summary>
private readonly IZamboniService ZamboniService;

/// <summary>
/// パック
/// </summary>
public DelegateCommand PackCommand { get; private set; }

/// <summary>
/// 設定を保存
/// </summary>
public DelegateCommand SaveCommand { get; private set; }

/// <summary>
/// パック時に圧縮する
/// </summary>
public bool IsCompress { get; set; }

/// <summary>
/// パック時に暗号化する
/// </summary>
public bool IsCrypt { get; set; }

/// <summary>
/// ホワイトリスト
/// </summary>
public static string WhiteList
{
get => Properties.Settings.Default.WhiteList;
set
{
Properties.Settings.Default.WhiteList = value;
Properties.Settings.Default.Save();
}
}

/// <summary>
/// コンストラクタ
/// </summary>
/// <param name="localizerService">多言語化サービス</param>
/// <param name="zamboniService">Zamboniサービス</param>
public PackPageViewModel(ILocalizerService localizerService, IZamboniService zamboniService)
{
// パックのイベント割当
PackCommand = new DelegateCommand(ExecutePackCommand);
// 設定保存のイベント割当
SaveCommand = new DelegateCommand(ExecuteSaveCommand);

IsCompress = true;

// サービスのインジェクション
LocalizerService = localizerService;
ZamboniService = zamboniService;
}

/// <summary>
/// パック処理
/// </summary>
private async void ExecutePackCommand()
{
// フォルダ選択ダイアログ
FolderPicker picker = new();
picker.Title = LocalizerService.GetLocalizedString("PackInputPathText");
picker.InputPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
// ファイルダイアログを表示
if (picker.ShowDialog() != true)
{
return;
}

// ファイル保存ダイアログ
using SaveFileDialog saveFileDialog = new()
{
Title = LocalizerService.GetLocalizedString("SaveAsDialogText"),
Filter = LocalizerService.GetLocalizedString("IceFileFilterText"),
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
FileName = "pso2data.ice"
};

// ダイアログを表示
DialogResult dialogResult = saveFileDialog.ShowDialog();
if (dialogResult != DialogResult.OK)
{
// キャンセルされたので終了
return;
}

_ = await Task.Run(async () =>
{
// Iceで圧縮(結構重い)
byte[] iceStream = await ZamboniService.Pack(picker.ResultPath, IsCompress, IsCrypt);
await File.WriteAllBytesAsync(saveFileDialog.FileName, iceStream);

return Task.CompletedTask;
});

// 完了通知
if (Properties.Settings.Default.NotifyComplete)
{
// トースト通知
new ToastContentBuilder()
.AddText(LocalizerService.GetLocalizedString("PackText"))
.AddText(LocalizerService.GetLocalizedString("CompleteText"))
.Show();
}
else
{
_ = AcrylicMessageBox.Show(System.Windows.Application.Current.MainWindow,
LocalizerService.GetLocalizedString("PackText"), LocalizerService.GetLocalizedString("CompleteText"));
}
}

/// <summary>
/// 設定保存.
/// </summary>
private void ExecuteSaveCommand()
{
// 設定を保存
Properties.Settings.Default.Save();
}
}
}
Loading

0 comments on commit 56e195a

Please sign in to comment.