スタイル: コーディング規約に準拠したコードフォーマットの適用(this.の明示、空白スタイルの統一)
- 自インスタンスメンバーアクセスへの this. 付与(28ファイル) - .editorconfig に準拠したインデント・波括弧・空白スタイルの適用 - UTF-8 (BOMあり)、CRLF改行コード、行末空白除去の整合性検証
This commit is contained in:
1 parent
2fa40c950f
commit
ae86b53147
28 files changed
+1362
-1380
No files matched your search
@@ -27,15 +27,15 @@ namespace GameLauncher
|
||||
|
||||
public WolfSaveEditorDialog(TkoolGameItem game, WolfSaveService saveService)
|
||||
{
|
||||
InitializeComponent();
|
||||
_game = game;
|
||||
_saveService = saveService;
|
||||
this.InitializeComponent();
|
||||
this._game = game;
|
||||
this._saveService = saveService;
|
||||
|
||||
lblGameTitle.Text = _game.Title;
|
||||
lblGamePath.Text = _game.RootDirectory;
|
||||
txtInfoBackupDir.Text = AppPathHelper.GetGameBackupDirectory(_game.FolderName, _game.RootDirectory);
|
||||
this.lblGameTitle.Text = this._game.Title;
|
||||
this.lblGamePath.Text = this._game.RootDirectory;
|
||||
this.txtInfoBackupDir.Text = AppPathHelper.GetGameBackupDirectory(this._game.FolderName, this._game.RootDirectory);
|
||||
|
||||
LoadSaveFileList();
|
||||
this.LoadSaveFileList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -45,36 +45,36 @@ namespace GameLauncher
|
||||
{
|
||||
try
|
||||
{
|
||||
var files = _saveService.GetSaveFiles(_game.RootDirectory);
|
||||
cboSaveFiles.Items.Clear();
|
||||
var files = this._saveService.GetSaveFiles(this._game.RootDirectory);
|
||||
this.cboSaveFiles.Items.Clear();
|
||||
|
||||
foreach (var f in files)
|
||||
{
|
||||
cboSaveFiles.Items.Add(Path.GetFileName(f));
|
||||
this.cboSaveFiles.Items.Add(Path.GetFileName(f));
|
||||
}
|
||||
|
||||
if (cboSaveFiles.Items.Count > 0)
|
||||
if (this.cboSaveFiles.Items.Count > 0)
|
||||
{
|
||||
cboSaveFiles.SelectedIndex = 0;
|
||||
this.cboSaveFiles.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblStatus.Text = "セーブデータ(*.sav)が見つかりませんでした。";
|
||||
this.lblStatus.Text = "セーブデータ(*.sav)が見つかりませんでした。";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lblStatus.Text = $"セーブファイル列挙エラー: {ex.Message}";
|
||||
this.lblStatus.Text = $"セーブファイル列挙エラー: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private void cboSaveFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (cboSaveFiles.SelectedItem == null) return;
|
||||
var fileName = cboSaveFiles.SelectedItem.ToString();
|
||||
if (this.cboSaveFiles.SelectedItem == null) return;
|
||||
var fileName = this.cboSaveFiles.SelectedItem.ToString();
|
||||
if (string.IsNullOrEmpty(fileName)) return;
|
||||
|
||||
LoadSaveFile(fileName);
|
||||
this.LoadSaveFile(fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,46 +84,46 @@ namespace GameLauncher
|
||||
{
|
||||
try
|
||||
{
|
||||
var files = _saveService.GetSaveFiles(_game.RootDirectory);
|
||||
var files = this._saveService.GetSaveFiles(this._game.RootDirectory);
|
||||
var fullPath = files.FirstOrDefault(f => string.Equals(Path.GetFileName(f), fileName, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (string.IsNullOrEmpty(fullPath) || !File.Exists(fullPath))
|
||||
{
|
||||
lblStatus.Text = $"ファイルが存在しません: {fileName}";
|
||||
this.lblStatus.Text = $"ファイルが存在しません: {fileName}";
|
||||
return;
|
||||
}
|
||||
|
||||
_currentSaveData = _saveService.LoadSave(fullPath);
|
||||
_allVariables = [.. _currentSaveData.Variables];
|
||||
_allStrings = [.. _currentSaveData.Strings];
|
||||
this._currentSaveData = this._saveService.LoadSave(fullPath);
|
||||
this._allVariables = [.. this._currentSaveData.Variables];
|
||||
this._allStrings = [.. this._currentSaveData.Strings];
|
||||
|
||||
// メタ情報表示
|
||||
txtInfoTitle.Text = string.IsNullOrEmpty(_currentSaveData.GameTitle) ? "(不明)" : _currentSaveData.GameTitle;
|
||||
txtInfoVersion.Text = $"0x{_currentSaveData.FileVersion:X4}";
|
||||
txtInfoEncoding.Text = _currentSaveData.IsUtf8 ? "UTF-8" : "Shift-JIS (CP932)";
|
||||
txtInfoSize.Text = $"{_currentSaveData.RawDecryptedBytes.Length:N0} バイト";
|
||||
this.txtInfoTitle.Text = string.IsNullOrEmpty(this._currentSaveData.GameTitle) ? "(不明)" : this._currentSaveData.GameTitle;
|
||||
this.txtInfoVersion.Text = $"0x{this._currentSaveData.FileVersion:X4}";
|
||||
this.txtInfoEncoding.Text = this._currentSaveData.IsUtf8 ? "UTF-8" : "Shift-JIS (CP932)";
|
||||
this.txtInfoSize.Text = $"{this._currentSaveData.RawDecryptedBytes.Length:N0} バイト";
|
||||
|
||||
ApplyFilter();
|
||||
this.ApplyFilter();
|
||||
|
||||
lblStatus.Text = $"'{fileName}' を正常に読み込みました。";
|
||||
lblSaveCount.Text = $"変数項目: {_allVariables.Count}件, 文字列項目: {_allStrings.Count}件";
|
||||
this.lblStatus.Text = $"'{fileName}' を正常に読み込みました。";
|
||||
this.lblSaveCount.Text = $"変数項目: {this._allVariables.Count}件, 文字列項目: {this._allStrings.Count}件";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"セーブデータの読み込みに失敗しました:\n{ex.Message}", "読み込みエラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
lblStatus.Text = $"読み込みエラー: {ex.Message}";
|
||||
this.lblStatus.Text = $"読み込みエラー: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnReload_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (cboSaveFiles.SelectedItem != null)
|
||||
if (this.cboSaveFiles.SelectedItem != null)
|
||||
{
|
||||
LoadSaveFile(cboSaveFiles.SelectedItem.ToString()!);
|
||||
this.LoadSaveFile(this.cboSaveFiles.SelectedItem.ToString()!);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadSaveFileList();
|
||||
this.LoadSaveFileList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,23 +132,23 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void ApplyFilter()
|
||||
{
|
||||
var filter = txtFilter.Text?.Trim() ?? string.Empty;
|
||||
var filter = this.txtFilter.Text?.Trim() ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(filter))
|
||||
{
|
||||
dgVariables.ItemsSource = _allVariables;
|
||||
dgStrings.ItemsSource = _allStrings;
|
||||
this.dgVariables.ItemsSource = this._allVariables;
|
||||
this.dgStrings.ItemsSource = this._allStrings;
|
||||
}
|
||||
else
|
||||
{
|
||||
dgVariables.ItemsSource = _allVariables
|
||||
this.dgVariables.ItemsSource = this._allVariables
|
||||
.Where(v => v.DisplayName.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||
v.Category.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||
v.Value.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||
v.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
dgStrings.ItemsSource = _allStrings
|
||||
this.dgStrings.ItemsSource = this._allStrings
|
||||
.Where(s => s.Value.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
|
||||
s.Offset.ToString("X").Contains(filter, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
@@ -157,7 +157,7 @@ namespace GameLauncher
|
||||
|
||||
private void txtFilter_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
ApplyFilter();
|
||||
this.ApplyFilter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -165,21 +165,21 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void btnSearchValue_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!int.TryParse(txtTargetValue.Text.Trim(), out int target))
|
||||
if (!int.TryParse(this.txtTargetValue.Text.Trim(), out int target))
|
||||
{
|
||||
MessageBox.Show("検索する数値を半角数字で入力してください。(例: 現在の所持金やステータス)", "入力エラー", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
var matches = _allVariables.Where(v => v.Value == target).ToList();
|
||||
var matches = this._allVariables.Where(v => v.Value == target).ToList();
|
||||
if (matches.Count == 0)
|
||||
{
|
||||
MessageBox.Show($"値が {target:N0} と一致する変数が見つかりませんでした。", "検索結果", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
dgVariables.ItemsSource = matches;
|
||||
lblStatus.Text = $"値 {target:N0} に一致する候補が {matches.Count} 件見つかりました。";
|
||||
this.dgVariables.ItemsSource = matches;
|
||||
this.lblStatus.Text = $"値 {target:N0} に一致する候補が {matches.Count} 件見つかりました。";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,7 +187,7 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void btnSetMaxTarget_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (dgVariables.ItemsSource is not IEnumerable<WolfVariableItem> currentList) return;
|
||||
if (this.dgVariables.ItemsSource is not IEnumerable<WolfVariableItem> currentList) return;
|
||||
var list = currentList.ToList();
|
||||
if (list.Count == 0) return;
|
||||
|
||||
@@ -201,8 +201,8 @@ namespace GameLauncher
|
||||
{
|
||||
item.Value = 9999999;
|
||||
}
|
||||
dgVariables.Items.Refresh();
|
||||
lblStatus.Text = $"{list.Count} 件の値を 9,999,999 に変更しました。保存ボタンを押すと反映されます。";
|
||||
this.dgVariables.Items.Refresh();
|
||||
this.lblStatus.Text = $"{list.Count} 件の値を 9,999,999 に変更しました。保存ボタンを押すと反映されます。";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,14 +214,14 @@ namespace GameLauncher
|
||||
if (sender is Button btn && btn.Tag is WolfVariableItem item)
|
||||
{
|
||||
item.Value = 9999999;
|
||||
dgVariables.Items.Refresh();
|
||||
lblStatus.Text = $"{item.DisplayName} の値を 9,999,999 に設定しました。";
|
||||
this.dgVariables.Items.Refresh();
|
||||
this.lblStatus.Text = $"{item.DisplayName} の値を 9,999,999 に設定しました。";
|
||||
}
|
||||
}
|
||||
|
||||
private void dgVariables_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||
{
|
||||
lblStatus.Text = "値を編集しました。「上書き保存」を押すとバックアップを作成して保存されます。";
|
||||
this.lblStatus.Text = "値を編集しました。「上書き保存」を押すとバックアップを作成して保存されます。";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -229,7 +229,7 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void btnSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_currentSaveData == null)
|
||||
if (this._currentSaveData == null)
|
||||
{
|
||||
MessageBox.Show("保存対象のセーブデータがありません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
@@ -238,19 +238,19 @@ namespace GameLauncher
|
||||
try
|
||||
{
|
||||
// 変数リストの最新値をモデルへ反映
|
||||
_currentSaveData.Variables = _allVariables;
|
||||
this._currentSaveData.Variables = this._allVariables;
|
||||
|
||||
// 保存実行 (自動バックアップ)
|
||||
string backupPath = _saveService.SaveToFile(_currentSaveData, _game.FolderName, _game.RootDirectory);
|
||||
string backupPath = this._saveService.SaveToFile(this._currentSaveData, this._game.FolderName, this._game.RootDirectory);
|
||||
|
||||
var msg = $"セーブデータ '{_currentSaveData.FileName}' を安全に上書き保存しました!\n\n【バックアップ保存先】\n{backupPath}";
|
||||
var msg = $"セーブデータ '{this._currentSaveData.FileName}' を安全に上書き保存しました!\n\n【バックアップ保存先】\n{backupPath}";
|
||||
MessageBox.Show(msg, "保存完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
lblStatus.Text = $"保存完了 (バックアップ: {Path.GetFileName(backupPath)})";
|
||||
this.lblStatus.Text = $"保存完了 (バックアップ: {Path.GetFileName(backupPath)})";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"保存中にエラーが発生しました:\n{ex.Message}", "保存エラー", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
lblStatus.Text = $"保存エラー: {ex.Message}";
|
||||
this.lblStatus.Text = $"保存エラー: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,20 +259,20 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void btnExportJson_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_currentSaveData == null) return;
|
||||
if (this._currentSaveData == null) return;
|
||||
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
Title = "セーブデータを JSON としてエクスポート",
|
||||
Filter = "JSON ファイル (*.json)|*.json",
|
||||
FileName = $"{Path.GetFileNameWithoutExtension(_currentSaveData.FileName)}_export.json"
|
||||
FileName = $"{Path.GetFileNameWithoutExtension(this._currentSaveData.FileName)}_export.json"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
_saveService.ExportToJson(_currentSaveData, sfd.FileName);
|
||||
this._saveService.ExportToJson(this._currentSaveData, sfd.FileName);
|
||||
MessageBox.Show($"JSON ファイルをエクスポートしました:\n{sfd.FileName}", "エクスポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -287,7 +287,7 @@ namespace GameLauncher
|
||||
/// </summary>
|
||||
private void btnImportJson_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_currentSaveData == null) return;
|
||||
if (this._currentSaveData == null) return;
|
||||
|
||||
var ofd = new OpenFileDialog
|
||||
{
|
||||
@@ -299,9 +299,9 @@ namespace GameLauncher
|
||||
{
|
||||
try
|
||||
{
|
||||
_saveService.ImportFromJson(_currentSaveData, ofd.FileName);
|
||||
_allVariables = [.. _currentSaveData.Variables];
|
||||
ApplyFilter();
|
||||
this._saveService.ImportFromJson(this._currentSaveData, ofd.FileName);
|
||||
this._allVariables = [.. this._currentSaveData.Variables];
|
||||
this.ApplyFilter();
|
||||
MessageBox.Show("JSON データを正常に取り込みました。「上書き保存」を押すとファイルへ反映されます。", "インポート完了", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -318,7 +318,7 @@ namespace GameLauncher
|
||||
{
|
||||
try
|
||||
{
|
||||
var dir = AppPathHelper.GetGameBackupDirectory(_game.FolderName, _game.RootDirectory);
|
||||
var dir = AppPathHelper.GetGameBackupDirectory(this._game.FolderName, this._game.RootDirectory);
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
Reference in new issue
Block a user