From 5b56d8df142f4b3f868d8c5ac4d39d507fb1e51f Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 11 Mar 2015 18:51:52 +0400 Subject: [PATCH] (PackOpener): store known schemes as Dictionary. --- ArcFormats/ArcKCAP.cs | 19 ++++++------------- ArcFormats/WidgetKCAP.xaml | 6 +++--- ArcFormats/WidgetKCAP.xaml.cs | 3 +-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/ArcFormats/ArcKCAP.cs b/ArcFormats/ArcKCAP.cs index 170267f6..7a6a5d5f 100644 --- a/ArcFormats/ArcKCAP.cs +++ b/ArcFormats/ArcKCAP.cs @@ -66,13 +66,9 @@ namespace GameRes.Formats.Selene static private string DefaultPassPhrase = "Selene.Default.Password"; - public static readonly string[] KnownSchemes = new string[] { - arcStrings.KCAPDefault, - "Okaa-san ga Ippai!", - }; - private static readonly string[] Keys = new string[] { - "", // default - "hahadata256pasyamada2zikan", // "Okaa-san ga Ippai!" + public static readonly Dictionary KnownSchemes = new Dictionary { + { arcStrings.KCAPDefault, "" }, + { "Okaa-san ga Ippai!", "hahadata256pasyamada2zikan" }, }; public PackOpener () @@ -127,13 +123,10 @@ namespace GameRes.Formats.Selene public static string GetPassPhrase (string title) { - System.Diagnostics.Debug.Assert (KnownSchemes.Length == Keys.Length, - "Number of known encryptions schemes does not match available pass phrases."); - var index = Array.IndexOf (KnownSchemes, title); - if (index != -1) - return Keys[index]; - else + string pass; + if (string.IsNullOrEmpty (title) || !KnownSchemes.TryGetValue (title, out pass)) return ""; + return pass; } public override object GetAccessWidget () diff --git a/ArcFormats/WidgetKCAP.xaml b/ArcFormats/WidgetKCAP.xaml index 5a9550f5..dda63108 100644 --- a/ArcFormats/WidgetKCAP.xaml +++ b/ArcFormats/WidgetKCAP.xaml @@ -20,8 +20,8 @@ Text="{Binding Source={x:Static p:Settings.Default}, Path=KCAPPassPhrase, Mode=TwoWay}" Width="{Binding ElementName=EncScheme, Path=ActualWidth}"/>