diff --git a/App.config b/App.config
index 922da4fb..3940edd0 100644
--- a/App.config
+++ b/App.config
@@ -79,6 +79,12 @@
PNG
+
+ False
+
+
+ True
+
diff --git a/ExtractArchive.xaml b/ExtractArchive.xaml
index 9bd08323..d05a2c61 100644
--- a/ExtractArchive.xaml
+++ b/ExtractArchive.xaml
@@ -4,33 +4,54 @@
xmlns:s="clr-namespace:GARbro.GUI.Strings"
xmlns:p="clr-namespace:GARbro.GUI.Properties"
xmlns:local="clr-namespace:GARbro.GUI"
- Title="{x:Static s:guiStrings.TextExtractTitle}" Height="200" Width="411.713"
+ Title="{x:Static s:guiStrings.TextExtractTitle}" Height="228" Width="411.713"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
+
-
-
+
+
-
-
-
diff --git a/ExtractArchive.xaml.cs b/ExtractArchive.xaml.cs
index 64c19bd1..088b9d0d 100644
--- a/ExtractArchive.xaml.cs
+++ b/ExtractArchive.xaml.cs
@@ -1,6 +1,6 @@
// Game Resource Browser
//
-// Copyright (C) 2014 by morkt
+// Copyright (C) 2014-2015 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
@@ -49,8 +49,6 @@ namespace GARbro.GUI
Destination = destination;
DestinationDir.EnterKeyDown += acb_OnEnterKeyDown;
- ExtractImages.IsChecked = Settings.Default.appExtractImages;
- ExtractText.IsChecked = Settings.Default.appExtractText;
ExtractText.IsEnabled = false;
TextEncoding.IsEnabled = false;
@@ -67,15 +65,7 @@ namespace GARbro.GUI
void ExtractButton_Click (object sender, RoutedEventArgs e)
{
this.DialogResult = true;
- Settings.Default.appExtractImages = this.ExtractImages.IsChecked.Value;
- Settings.Default.appExtractText = this.ExtractText.IsChecked.Value;
ExportImageFormat (ImageConversionFormat);
}
-
- public ImageFormat GetImageFormat ()
- {
- var selected = ImageConversionFormat.SelectedItem as ImageFormatModel;
- return null != selected ? selected.Source : null;
- }
}
}
diff --git a/ExtractFile.xaml b/ExtractFile.xaml
index 032eccc3..fc070b2a 100644
--- a/ExtractFile.xaml
+++ b/ExtractFile.xaml
@@ -17,14 +17,20 @@
Command="{x:Static local:Commands.Browse}">
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ExtractFile.xaml.cs b/ExtractFile.xaml.cs
index 5f0984b9..35e89954 100644
--- a/ExtractFile.xaml.cs
+++ b/ExtractFile.xaml.cs
@@ -1,6 +1,6 @@
// Game Resource Browser
//
-// Copyright (C) 2014 by morkt
+// Copyright (C) 2014-2015 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
@@ -48,20 +48,40 @@ namespace GARbro.GUI
DestinationDir.EnterKeyDown += acb_OnEnterKeyDown;
if ("image" == entry.Type)
{
- ImageConversionOptions.Visibility = Visibility.Visible;
- TextConversionOptions.Visibility = Visibility.Collapsed;
+ ActiveOption = ImageConversionOptions;
InitImageFormats (ImageConversionFormat);
}
else if ("script" == entry.Type)
{
- ImageConversionOptions.Visibility = Visibility.Collapsed;
- TextConversionOptions.Visibility = Visibility.Visible;
+ ActiveOption = TextConversionOptions;
TextEncoding.IsEnabled = false;
}
+ else if ("audio" == entry.Type)
+ {
+ ActiveOption = AudioConversionOptions;
+ }
else
{
- ImageConversionOptions.Visibility = Visibility.Collapsed;
- TextConversionOptions.Visibility = Visibility.Collapsed;
+ ActiveOption = null;
+ }
+ }
+
+ private UIElement m_active_option;
+ public UIElement ActiveOption
+ {
+ get { return m_active_option; }
+ set
+ {
+ if (value == m_active_option)
+ return;
+ m_active_option = value;
+ if (null != m_active_option)
+ m_active_option.Visibility = Visibility.Visible;
+ foreach (var c in ConversionTypePanel.Children.Cast())
+ {
+ if (c != m_active_option)
+ c.Visibility = Visibility.Collapsed;
+ }
}
}
@@ -75,7 +95,7 @@ namespace GARbro.GUI
void ExtractButton_Click (object sender, RoutedEventArgs e)
{
this.DialogResult = true;
- if (ImageConversionOptions.Visibility == Visibility.Visible)
+ if (ImageConversionOptions == ActiveOption)
{
ExportImageFormat (ImageConversionFormat);
}
diff --git a/GARbro.GUI.csproj b/GARbro.GUI.csproj
index 5c23d738..14ff9c37 100644
--- a/GARbro.GUI.csproj
+++ b/GARbro.GUI.csproj
@@ -140,6 +140,7 @@
ExtractFile.xaml
+
diff --git a/GameRes/ArcFile.cs b/GameRes/ArcFile.cs
index cbb8fde1..80957ac8 100644
--- a/GameRes/ArcFile.cs
+++ b/GameRes/ArcFile.cs
@@ -2,7 +2,7 @@
//! \date Tue Jul 08 12:53:45 2014
//! \brief Game Archive file class.
//
-// Copyright (C) 2014 by morkt
+// Copyright (C) 2014-2015 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
@@ -149,7 +149,7 @@ namespace GameRes
///
public Stream CreateFile (Entry entry)
{
- return m_interface.CreateFile (entry.Name);
+ return ArchiveFormat.CreateFile (entry.Name);
}
#region IDisposable Members
diff --git a/GameRes/GameRes.cs b/GameRes/GameRes.cs
index 30080773..a6b7f009 100644
--- a/GameRes/GameRes.cs
+++ b/GameRes/GameRes.cs
@@ -2,7 +2,7 @@
//! \date Mon Jun 30 20:12:13 2014
//! \brief game resources browser.
//
-// Copyright (C) 2014 by morkt
+// Copyright (C) 2014-2015 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
@@ -153,7 +153,7 @@ namespace GameRes
/// Create file corresponding to in current directory and open it
/// for writing. Overwrites existing file, if any.
///
- public Stream CreateFile (string filename)
+ static public Stream CreateFile (string filename)
{
filename = CreatePath (filename);
if (File.Exists (filename))
diff --git a/GarAudio.cs b/GarAudio.cs
new file mode 100644
index 00000000..273695e2
--- /dev/null
+++ b/GarAudio.cs
@@ -0,0 +1,71 @@
+//! \file GarAudio.cs
+//! \date Thu May 14 13:58:03 2015
+//! \brief GARbro audio formats conversions.
+//
+// Copyright (C) 2015 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
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+//
+
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using GameRes;
+using GARbro.GUI.Strings;
+
+namespace GARbro.GUI
+{
+ public partial class MainWindow : Window
+ {
+ void ExtractAudio (ArcFile arc, Entry entry)
+ {
+ using (var file = arc.OpenEntry (entry))
+ using (var sound = AudioFormat.Read (file))
+ {
+ if (null == sound)
+ throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpret, entry.Name));
+ ConvertAudio (entry.Name, sound);
+ }
+ }
+
+ public static readonly HashSet CommonAudioFormats = new HashSet { "wav", "mp3", "ogg" };
+
+ void ConvertAudio (string entry_name, SoundInput input)
+ {
+ string source_format = input.SourceFormat;
+ if (CommonAudioFormats.Contains (source_format))
+ {
+ string output_name = Path.ChangeExtension (entry_name, source_format);
+ using (var output = ArchiveFormat.CreateFile (output_name))
+ {
+ input.Source.Position = 0;
+ input.Source.CopyTo (output);
+ }
+ }
+ else
+ {
+ var wav_format = FormatCatalog.Instance.AudioFormats.Where (f => f.Tag == "WAV").First();
+ string output_name = Path.ChangeExtension (entry_name, "wav");
+ using (var output = ArchiveFormat.CreateFile (output_name))
+ wav_format.Write (input, output);
+ }
+ }
+ }
+}
diff --git a/GarExtract.cs b/GarExtract.cs
index a1493227..49044755 100644
--- a/GarExtract.cs
+++ b/GarExtract.cs
@@ -2,7 +2,7 @@
//! \date Fri Jul 25 05:52:27 2014
//! \brief Extract archive frontend.
//
-// Copyright (C) 2014 by morkt
+// Copyright (C) 2014-2015 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
@@ -138,8 +138,11 @@ namespace GARbro.GUI
IEnumerable file_list = arc.Dir;
bool skip_images = !extractDialog.ExtractImages.IsChecked.Value;
bool skip_script = !extractDialog.ExtractText.IsChecked.Value;
- if (skip_images || skip_script)
- file_list = file_list.Where (f => !(skip_images && f.Type == "image") && !(skip_script && f.Type == "script"));
+ bool skip_audio = !extractDialog.ExtractAudio.IsChecked.Value;
+ if (skip_images || skip_script || skip_audio)
+ file_list = file_list.Where (f => !(skip_images && f.Type == "image") &&
+ !(skip_script && f.Type == "script") &&
+ !(skip_audio && f.Type == "audio"));
if (!file_list.Any())
{
@@ -208,7 +211,9 @@ namespace GARbro.GUI
extractProgressDialog.Description = file_list.First().Name;
extractProgressDialog.ProgressBarStyle = ProgressBarStyle.MarqueeProgressBar;
}
+ bool convert_audio = Settings.Default.appConvertAudio;
int extract_count = 0;
+ Exception pending_error = null;
extractProgressDialog.DoWork += (s, e) =>
{
try
@@ -222,6 +227,8 @@ namespace GARbro.GUI
extractProgressDialog.ReportProgress (extract_count*100/total, null, entry.Name);
if (null != image_format && entry.Type == "image")
ExtractImage (arc, entry, image_format);
+ else if (convert_audio && entry.Type == "audio")
+ ExtractAudio (arc, entry);
else
arc.Extract (entry);
++extract_count;
@@ -229,7 +236,7 @@ namespace GARbro.GUI
}
catch (Exception X)
{
- SetStatusText (X.Message);
+ pending_error = X;
}
};
extractProgressDialog.RunWorkerCompleted += (s, e) => {
@@ -241,6 +248,8 @@ namespace GARbro.GUI
Dispatcher.Invoke (RefreshView);
}
SetStatusText (Localization.Format ("MsgExtractedFiles", extract_count));
+ if (null != pending_error)
+ PopupError (pending_error.Message, guiStrings.MsgErrorExtracting);
};
extractProgressDialog.ShowDialog (this);
}
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 7d30c964..e9432921 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -309,5 +309,29 @@ namespace GARbro.GUI.Properties {
this["appLastImageFormat"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool appConvertAudio {
+ get {
+ return ((bool)(this["appConvertAudio"]));
+ }
+ set {
+ this["appConvertAudio"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool appExtractAudio {
+ get {
+ return ((bool)(this["appExtractAudio"]));
+ }
+ set {
+ this["appExtractAudio"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 731994b0..960a8b12 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -74,5 +74,11 @@
PNG
+
+ False
+
+
+ True
+
\ No newline at end of file
diff --git a/Strings/guiStrings.Designer.cs b/Strings/guiStrings.Designer.cs
index d5880d9b..97e0dec2 100644
--- a/Strings/guiStrings.Designer.cs
+++ b/Strings/guiStrings.Designer.cs
@@ -756,6 +756,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Convert audio to common format.
+ ///
+ public static string TextConvertAudio {
+ get {
+ return ResourceManager.GetString("TextConvertAudio", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Convert images.
///
@@ -801,6 +810,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Extract audio.
+ ///
+ public static string TextExtractAudio {
+ get {
+ return ResourceManager.GetString("TextExtractAudio", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Extract images.
///
@@ -873,6 +891,15 @@ namespace GARbro.GUI.Strings {
}
}
+ ///
+ /// Looks up a localized string similar to Either WAV, MP3 or OGG.
+ ///
+ public static string TooltipAudioFormats {
+ get {
+ return ResourceManager.GetString("TooltipAudioFormats", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Back.
///
diff --git a/Strings/guiStrings.resx b/Strings/guiStrings.resx
index 7827c8d3..b4675af8 100644
--- a/Strings/guiStrings.resx
+++ b/Strings/guiStrings.resx
@@ -399,4 +399,13 @@ Overwrite?
Encoding
+
+ Convert audio to common format
+
+
+ Extract audio
+
+
+ Either WAV, MP3 or OGG
+
\ No newline at end of file
diff --git a/Strings/guiStrings.ru-RU.resx b/Strings/guiStrings.ru-RU.resx
index 17b5b4c5..74625f7a 100644
--- a/Strings/guiStrings.ru-RU.resx
+++ b/Strings/guiStrings.ru-RU.resx
@@ -414,4 +414,13 @@
Кодировка
+
+ Преобразовывать аудио в стандартный формат
+
+
+ Извлекать аудио
+
+
+ WAV, MP3, либо OGG
+
\ No newline at end of file