diff --git a/GUI/ConvertMedia.xaml b/GUI/ConvertMedia.xaml
index 4bbc7d8a..b2583ced 100644
--- a/GUI/ConvertMedia.xaml
+++ b/GUI/ConvertMedia.xaml
@@ -4,6 +4,7 @@
xmlns:s="clr-namespace:GARbro.GUI.Strings"
xmlns:p="clr-namespace:GARbro.GUI.Properties"
xmlns:g="clr-namespace:GameRes;assembly=GameRes"
+ xmlns:local="clr-namespace:GARbro.GUI"
Title="{x:Static s:guiStrings.TextConvertMedia}" ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
ResizeMode="NoResize" SizeToContent="WidthAndHeight"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
@@ -15,6 +16,18 @@
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=appLastImageFormat, Mode=TwoWay}"/>
+
+
+
+
+
+
+
+
+
@@ -23,4 +36,7 @@
+
+
+
diff --git a/GUI/ConvertMedia.xaml.cs b/GUI/ConvertMedia.xaml.cs
index a027794c..e4cff0fc 100644
--- a/GUI/ConvertMedia.xaml.cs
+++ b/GUI/ConvertMedia.xaml.cs
@@ -1,4 +1,7 @@
using System.Windows;
+using System.Windows.Input;
+using GARbro.GUI.Strings;
+using Microsoft.WindowsAPICodePack.Dialogs;
namespace GARbro.GUI
{
@@ -12,6 +15,32 @@ namespace GARbro.GUI
InitializeComponent ();
}
+ private void BrowseExec (object sender, ExecutedRoutedEventArgs e)
+ {
+ var dlg = new CommonOpenFileDialog
+ {
+ Title = guiStrings.TextChooseDestDir,
+ IsFolderPicker = true,
+ InitialDirectory = DestinationDir.Text,
+
+ AddToMostRecentlyUsedList = false,
+ AllowNonFileSystemItems = false,
+ EnsureFileExists = true,
+ EnsurePathExists = true,
+ EnsureReadOnly = false,
+ EnsureValidNames = true,
+ Multiselect = false,
+ ShowPlacesList = true,
+ };
+ if (dlg.ShowDialog (this) == CommonFileDialogResult.Ok)
+ DestinationDir.Text = dlg.FileName;
+ }
+
+ public void CanExecuteAlways (object sender, CanExecuteRoutedEventArgs e)
+ {
+ e.CanExecute = true;
+ }
+
private void ConvertButton_Click (object sender, RoutedEventArgs e)
{
this.DialogResult = true;
diff --git a/GUI/GarConvert.cs b/GUI/GarConvert.cs
index 3b6a7ef0..64576f21 100644
--- a/GUI/GarConvert.cs
+++ b/GUI/GarConvert.cs
@@ -2,7 +2,7 @@
//! \date Fri Aug 22 08:22:47 2014
//! \brief Game resources conversion methods.
//
-// Copyright (C) 2014-2015 by morkt
+// Copyright (C) 2014-2016 by morkt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
@@ -56,6 +56,14 @@ namespace GARbro.GUI
return;
}
var convert_dialog = new ConvertMedia();
+
+ string destination = ViewModel.Path.First();
+ if (ViewModel.IsArchive)
+ destination = Path.GetDirectoryName (destination);
+ if (!IsWritableDirectory (destination) && Directory.Exists (Settings.Default.appLastDestination))
+ destination = Settings.Default.appLastDestination;
+ convert_dialog.DestinationDir.Text = destination;
+
convert_dialog.Owner = this;
var result = convert_dialog.ShowDialog() ?? false;
if (!result)
@@ -68,16 +76,24 @@ namespace GARbro.GUI
}
try
{
- Directory.SetCurrentDirectory (ViewModel.Path.First());
+ destination = convert_dialog.DestinationDir.Text;
+ Directory.SetCurrentDirectory (destination);
var converter = new GarConvertMedia (this);
converter.IgnoreErrors = convert_dialog.IgnoreErrors.IsChecked ?? false;
converter.Convert (source, format);
+ Settings.Default.appLastDestination = destination;
}
catch (Exception X)
{
PopupError (X.Message, guiStrings.TextMediaConvertError);
}
}
+
+ bool IsWritableDirectory (string path)
+ {
+ var info = new DirectoryInfo (path);
+ return !info.Attributes.HasFlag (FileAttributes.ReadOnly);
+ }
}
internal class GarConvertMedia
@@ -165,13 +181,14 @@ namespace GARbro.GUI
{
if (null == input)
return;
+ string output_name = Path.GetFileName (filename);
var source_ext = Path.GetExtension (filename).TrimStart ('.').ToLowerInvariant();
string source_format = input.SourceFormat;
if (CommonAudioFormats.Contains (source_format))
{
if (source_ext == source_format)
return;
- string output_name = Path.ChangeExtension (filename, source_format);
+ output_name = Path.ChangeExtension (output_name, source_format);
using (var output = CreateNewFile (output_name))
{
input.Source.Position = 0;
@@ -182,7 +199,7 @@ namespace GARbro.GUI
{
if (source_ext == "wav")
return;
- string output_name = Path.ChangeExtension (filename, "wav");
+ output_name = Path.ChangeExtension (output_name, "wav");
using (var output = CreateNewFile (output_name))
AudioFormat.Wav.Write (input, output);
}
@@ -194,8 +211,9 @@ namespace GARbro.GUI
string source_ext = Path.GetExtension (filename).TrimStart ('.').ToLowerInvariant();
if (m_image_format.Extensions.Any (ext => ext == source_ext))
return;
+ string target_name = Path.GetFileName (filename);
string target_ext = m_image_format.Extensions.FirstOrDefault();
- string target_name = Path.ChangeExtension (filename, target_ext);
+ target_name = Path.ChangeExtension (target_name, target_ext);
using (var file = File.OpenRead (filename))
{
var image = ImageFormat.Read (filename, file);
diff --git a/GUI/Strings/guiStrings.Designer.cs b/GUI/Strings/guiStrings.Designer.cs
index b2955d1f..2fdbb6ae 100644
--- a/GUI/Strings/guiStrings.Designer.cs
+++ b/GUI/Strings/guiStrings.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34209
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -312,6 +312,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Destination directory.
+ ///
+ public static string LabelDestinationDir {
+ get {
+ return ResourceManager.GetString("LabelDestinationDir", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Choose destination format for images.
///
diff --git a/GUI/Strings/guiStrings.ko-KR.resx b/GUI/Strings/guiStrings.ko-KR.resx
index cebfb3ca..a94085ca 100644
--- a/GUI/Strings/guiStrings.ko-KR.resx
+++ b/GUI/Strings/guiStrings.ko-KR.resx
@@ -448,4 +448,8 @@
없음
-
+
+ Destination directory
+ translation pending
+
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.resx b/GUI/Strings/guiStrings.resx
index 270ee6ea..8650c712 100644
--- a/GUI/Strings/guiStrings.resx
+++ b/GUI/Strings/guiStrings.resx
@@ -449,4 +449,7 @@ Overwrite?
none
+
+ Destination directory
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.ru-RU.resx b/GUI/Strings/guiStrings.ru-RU.resx
index 20682e3c..0ec35161 100644
--- a/GUI/Strings/guiStrings.ru-RU.resx
+++ b/GUI/Strings/guiStrings.ru-RU.resx
@@ -470,4 +470,7 @@
без типа
+
+ Сохранить результаты в
+
\ No newline at end of file
diff --git a/GUI/Strings/guiStrings.zh-Hans.resx b/GUI/Strings/guiStrings.zh-Hans.resx
index d8076d7d..965ee7f2 100644
--- a/GUI/Strings/guiStrings.zh-Hans.resx
+++ b/GUI/Strings/guiStrings.zh-Hans.resx
@@ -449,4 +449,8 @@
无
+
+ Destination directory
+ translation pending
+
\ No newline at end of file