Files
GameLauncher/ConfigDialog.xaml.cs
T
armonica ae86b53147 スタイル: コーディング規約に準拠したコードフォーマットの適用(this.の明示、空白スタイルの統一)
- 自インスタンスメンバーアクセスへの this. 付与(28ファイル)
- .editorconfig に準拠したインデント・波括弧・空白スタイルの適用
- UTF-8 (BOMあり)、CRLF改行コード、行末空白除去の整合性検証
2026-10-20 10:14:26 +09:00

130 lines
4.7 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using GameLauncher.Helpers;
using GameLauncher.Models;
namespace GameLauncher
{
/// <summary>
/// 設定ダイアログのロジック
/// </summary>
public partial class ConfigDialog : Window
{
private readonly LauncherConfig _config;
public bool IsSaved { get; private set; }
public ConfigDialog(LauncherConfig config)
{
this.InitializeComponent();
this._config = config;
this.txtRgssExtractorPath.Text = this._config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
this.txtWolfExtractorPath.Text = this._config.WolfExtractorPath ?? string.Empty;
this.txtWindowResizeToolPath.Text = this._config.WindowResizeToolPath ?? string.Empty;
this.txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
this.chkDefaultApplyMod.IsChecked = this._config.DefaultApplyMod;
}
private void btnBrowseExtractor_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog
{
Title = "RGSS Extractor の実行ファイルを選択してください",
Filter = "実行ファイル (*.exe)|*.exe|すべてのファイル (*.*)|*.*",
FileName = "RGSS Extractor.exe"
};
var currentDir = Path.GetDirectoryName(this.txtRgssExtractorPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
this.txtRgssExtractorPath.Text = ofd.FileName;
}
}
private void btnBrowseWolfExtractor_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog
{
Title = "Wolf RPG 解凍ツール (UberWolfCli.exe / WolfDec.exe) を選択してください",
Filter = "実行ファイル (*.exe)|*.exe|すべてのファイル (*.*)|*.*",
FileName = "UberWolfCli.exe"
};
var currentDir = Path.GetDirectoryName(this.txtWolfExtractorPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
this.txtWolfExtractorPath.Text = ofd.FileName;
}
}
private void btnBrowseWindowResizeTool_Click(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog
{
Title = "ウィンドウ拡大用の外部ツール(Sizer等)を選択してください",
Filter = "実行ファイル (*.exe)|*.exe|すべてのファイル (*.*)|*.*",
FileName = "Sizer.exe"
};
var currentDir = Path.GetDirectoryName(this.txtWindowResizeToolPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
this.txtWindowResizeToolPath.Text = ofd.FileName;
}
}
private void btnOpenBackupsDir_Click(object sender, RoutedEventArgs e)
{
try
{
var dir = AppPathHelper.GetBackupsDirectory();
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
Process.Start(new ProcessStartInfo { FileName = dir, UseShellExecute = true });
}
catch (Exception ex)
{
MessageBox.Show($"バックアップフォルダを開けませんでした:\n{ex.Message}", "エラー", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
this._config.RgssExtractorPath = this.txtRgssExtractorPath.Text.Trim();
this._config.WolfExtractorPath = this.txtWolfExtractorPath.Text.Trim();
this._config.WindowResizeToolPath = this.txtWindowResizeToolPath.Text.Trim();
this._config.DefaultApplyMod = this.chkDefaultApplyMod.IsChecked == true;
this.IsSaved = true;
this.DialogResult = true;
this.Close();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
}
}