mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(PackOpener): store known schemes as Dictionary.
This commit is contained in:
parent
2c2dfec477
commit
5b56d8df14
@ -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<string,string> KnownSchemes = new Dictionary<string,string> {
|
||||
{ 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 ()
|
||||
|
@ -20,8 +20,8 @@
|
||||
Text="{Binding Source={x:Static p:Settings.Default}, Path=KCAPPassPhrase, Mode=TwoWay}"
|
||||
Width="{Binding ElementName=EncScheme, Path=ActualWidth}"/>
|
||||
<Label Content="{x:Static s:arcStrings.LabelScheme}" Target="{Binding ElementName=EncScheme}"
|
||||
Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right"/>
|
||||
<ComboBox Name="EncScheme" Grid.Column="1" Grid.Row="2" Margin="0,3,0,0"
|
||||
ItemsSource="{Binding Source={x:Static fmt:PackOpener.KnownSchemes}, Mode=OneWay}"
|
||||
Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right"/>
|
||||
<ComboBox Name="EncScheme" Grid.Column="1" Grid.Row="1" Margin="0,3,0,0"
|
||||
ItemsSource="{Binding Source={x:Static fmt:PackOpener.KnownSchemes}, Path=Keys, Mode=OneWay}"
|
||||
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=KCAPScheme, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
|
@ -13,10 +13,9 @@ namespace GameRes.Formats.GUI
|
||||
public WidgetKCAP ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
EncScheme.SelectionChanged += OnSchemeChanged;
|
||||
|
||||
if (null == EncScheme.SelectedItem)
|
||||
EncScheme.SelectedIndex = 0;
|
||||
EncScheme.SelectionChanged += OnSchemeChanged;
|
||||
}
|
||||
|
||||
void OnSchemeChanged (object sender, SelectionChangedEventArgs e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user