diff --git a/ArcFormats/LiveMaker/ImageGAL.cs b/ArcFormats/LiveMaker/ImageGAL.cs index 8ec07f65..2d8c2b5b 100644 --- a/ArcFormats/LiveMaker/ImageGAL.cs +++ b/ArcFormats/LiveMaker/ImageGAL.cs @@ -57,7 +57,7 @@ namespace GameRes.Formats.LiveMaker [Serializable] public class GalScheme : ResourceScheme { - public Dictionary KnownKeys; + public Dictionary KnownKeys; } [Export(typeof(ImageFormat))] @@ -67,7 +67,7 @@ namespace GameRes.Formats.LiveMaker public override string Description { get { return "LiveMaker image format"; } } public override uint Signature { get { return 0x656C6147; } } // 'Gale' - public static Dictionary KnownKeys = new Dictionary(); + public static Dictionary KnownKeys = new Dictionary(); public override ResourceScheme Scheme { @@ -145,7 +145,7 @@ namespace GameRes.Formats.LiveMaker public override ResourceOptions GetDefaultOptions () { - return new GalOptions { Key = Settings.Default.GALKey }; + return new GalOptions { Key = KeyFromString (Settings.Default.GALKey) }; } public override object GetAccessWidget () @@ -160,6 +160,13 @@ namespace GameRes.Formats.LiveMaker var options = Query (arcStrings.ArcImageEncrypted); return options.Key; } + + public static uint KeyFromString (string key) + { + if (string.IsNullOrWhiteSpace (key) || key.Length < 4) + return 0; + return (uint)(key[0] | key[1] << 8 | key[2] << 16 | key[3] << 24); + } } internal sealed class GalReader : IDisposable diff --git a/ArcFormats/LiveMaker/WidgetGAL.xaml b/ArcFormats/LiveMaker/WidgetGAL.xaml index 98a6efe5..c1f16ee5 100644 --- a/ArcFormats/LiveMaker/WidgetGAL.xaml +++ b/ArcFormats/LiveMaker/WidgetGAL.xaml @@ -5,41 +5,16 @@ xmlns:p="clr-namespace:GameRes.Formats.Properties" xmlns:local="clr-namespace:GameRes.Formats.GUI" MaxWidth="250" Orientation="Vertical"> - - - - - - - - - + - - - - - - - - - - diff --git a/ArcFormats/LiveMaker/WidgetGAL.xaml.cs b/ArcFormats/LiveMaker/WidgetGAL.xaml.cs index 2ea1c943..4d3cbfba 100644 --- a/ArcFormats/LiveMaker/WidgetGAL.xaml.cs +++ b/ArcFormats/LiveMaker/WidgetGAL.xaml.cs @@ -18,56 +18,9 @@ namespace GameRes.Formats.GUI public WidgetGAL() { InitializeComponent(); - var first_item = new KeyValuePair (arcStrings.ArcIgnoreEncryption, 0u); - var items = new KeyValuePair[] { first_item }; + var first_item = new KeyValuePair (arcStrings.ArcIgnoreEncryption, ""); + var items = new KeyValuePair[] { first_item }; this.Title.ItemsSource = items.Concat (GalFormat.KnownKeys.OrderBy (x => x.Key)); } } - - [ValueConversion(typeof(uint), typeof(string))] - public class GaleKeyConverter : IValueConverter - { - public object Convert (object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is uint) - return ((uint)value).ToString ("X"); - else if (value is string) - return ConvertBack (value, targetType, parameter, culture); - else - return ""; - } - - public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is uint) - return Convert (value, targetType, parameter, culture); - string strValue = value as string; - uint result_key; - if (!string.IsNullOrWhiteSpace (strValue) - && uint.TryParse (strValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result_key)) - return result_key; - else - return null; - } - } - - public class GaleKeyRule : ValidationRule - { - public override ValidationResult Validate (object value, CultureInfo cultureInfo) - { - uint key = 0; - try - { - if (value is uint) - key = (uint)value; - else if (!string.IsNullOrWhiteSpace (value as string)) - key = UInt32.Parse ((string)value, NumberStyles.HexNumber); - } - catch - { - return new ValidationResult (false, arcStrings.INTKeyRequirement); - } - return new ValidationResult (true, null); - } - } } diff --git a/ArcFormats/Properties/Settings.Designer.cs b/ArcFormats/Properties/Settings.Designer.cs index 33527eb1..0e3e0e2a 100644 --- a/ArcFormats/Properties/Settings.Designer.cs +++ b/ArcFormats/Properties/Settings.Designer.cs @@ -552,10 +552,10 @@ namespace GameRes.Formats.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0")] - public uint GALKey { + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string GALKey { get { - return ((uint)(this["GALKey"])); + return ((string)(this["GALKey"])); } set { this["GALKey"] = value; diff --git a/ArcFormats/Properties/Settings.settings b/ArcFormats/Properties/Settings.settings index cfbeabf8..31fddf01 100644 --- a/ArcFormats/Properties/Settings.settings +++ b/ArcFormats/Properties/Settings.settings @@ -134,8 +134,8 @@ - - 0 + + \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.Designer.cs b/ArcFormats/Strings/arcStrings.Designer.cs index 314db7e0..b8f94df6 100644 --- a/ArcFormats/Strings/arcStrings.Designer.cs +++ b/ArcFormats/Strings/arcStrings.Designer.cs @@ -189,7 +189,7 @@ namespace GameRes.Formats.Strings { } /// - /// Looks up a localized string similar to Choose title or enter 32-bit hex key. + /// Looks up a localized string similar to Choose title or enter a key. /// public static string GALChoose { get { diff --git a/ArcFormats/Strings/arcStrings.ko-KR.resx b/ArcFormats/Strings/arcStrings.ko-KR.resx index 3b5f99b7..1f6efdf8 100644 --- a/ArcFormats/Strings/arcStrings.ko-KR.resx +++ b/ArcFormats/Strings/arcStrings.ko-KR.resx @@ -373,7 +373,6 @@ 적절한 암호체계를 선택하세요. - Choose title or enter 32-bit hex key - translation pending + 제목을 선택하거나 암호값 입력하기 \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.resx b/ArcFormats/Strings/arcStrings.resx index 5d53d179..0f6f2d0f 100644 --- a/ArcFormats/Strings/arcStrings.resx +++ b/ArcFormats/Strings/arcStrings.resx @@ -376,6 +376,6 @@ choose appropriate encryption scheme. Choose appropriate encryption scheme. - Choose title or enter 32-bit hex key + Choose title or enter a key \ No newline at end of file diff --git a/ArcFormats/Strings/arcStrings.ru-RU.resx b/ArcFormats/Strings/arcStrings.ru-RU.resx index 24908644..f8b0ae22 100644 --- a/ArcFormats/Strings/arcStrings.ru-RU.resx +++ b/ArcFormats/Strings/arcStrings.ru-RU.resx @@ -159,7 +159,7 @@ Ключи шифрования - Выберите наименование или введите 32-битный ключ + Выберите наименование или введите ключ Выберите исполняемый файл diff --git a/ArcFormats/Strings/arcStrings.zh-Hans.resx b/ArcFormats/Strings/arcStrings.zh-Hans.resx index 96d3659f..d7e5ec1d 100644 --- a/ArcFormats/Strings/arcStrings.zh-Hans.resx +++ b/ArcFormats/Strings/arcStrings.zh-Hans.resx @@ -378,7 +378,6 @@ Choose appropriate encryption scheme. translation pending - Choose title or enter 32-bit hex key - translation pending + 请选择游戏名称或输入密钥 \ No newline at end of file diff --git a/ArcFormats/app.config b/ArcFormats/app.config index 872810cf..b61ce74d 100644 --- a/ArcFormats/app.config +++ b/ArcFormats/app.config @@ -137,7 +137,7 @@ - 0 +