130 lines
4.6 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|