Files
GameLauncher/ConfigDialog.xaml.cs
T
armonica 8cea2a147d refactor: reorganize engine-based structure and add agent rules
- Engines/ 配下へエンジン別に再編 (Common/Rgss/Tkool/Tyrano/Wolf/Unity/Nwjs)
- ゲーム個別処理を Engines/<Engine>/Games/<GameName>/ へ分離し、共通処理から明示呼び出し
- 外部ツールを Engines/<Engine>/Tools/ へ移動し、AppPathHelper 経由で解決
- 旧 Tools/ 直下参照と不要な参照ファイル/バックアップを削除
- エージェント規則 AGENTS.md を追加し、README から参照
- publish.ps1 を Engines/<Engine>/Tools/ の再帰配置に対応
2026-10-07 02:30:49 +09:00

130 lines
4.6 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)
{
InitializeComponent();
_config = config;
txtRgssExtractorPath.Text = _config.RgssExtractorPath ?? @"C:\Soft\RGSS-Extractor-v1.0\RGSS Extractor.exe";
txtWolfExtractorPath.Text = _config.WolfExtractorPath ?? string.Empty;
txtWindowResizeToolPath.Text = _config.WindowResizeToolPath ?? string.Empty;
txtBackupsPath.Text = AppPathHelper.GetBackupsDirectory();
chkDefaultApplyMod.IsChecked = _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(txtRgssExtractorPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
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(txtWolfExtractorPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
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(txtWindowResizeToolPath.Text);
if (!string.IsNullOrEmpty(currentDir) && Directory.Exists(currentDir))
{
ofd.InitialDirectory = currentDir;
}
if (ofd.ShowDialog() == true)
{
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)
{
_config.RgssExtractorPath = txtRgssExtractorPath.Text.Trim();
_config.WolfExtractorPath = txtWolfExtractorPath.Text.Trim();
_config.WindowResizeToolPath = txtWindowResizeToolPath.Text.Trim();
_config.DefaultApplyMod = chkDefaultApplyMod.IsChecked == true;
IsSaved = true;
DialogResult = true;
Close();
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
}
}