mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-25 04:14: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";
|
static private string DefaultPassPhrase = "Selene.Default.Password";
|
||||||
|
|
||||||
public static readonly string[] KnownSchemes = new string[] {
|
public static readonly Dictionary<string,string> KnownSchemes = new Dictionary<string,string> {
|
||||||
arcStrings.KCAPDefault,
|
{ arcStrings.KCAPDefault, "" },
|
||||||
"Okaa-san ga Ippai!",
|
{ "Okaa-san ga Ippai!", "hahadata256pasyamada2zikan" },
|
||||||
};
|
|
||||||
private static readonly string[] Keys = new string[] {
|
|
||||||
"", // default
|
|
||||||
"hahadata256pasyamada2zikan", // "Okaa-san ga Ippai!"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public PackOpener ()
|
public PackOpener ()
|
||||||
@ -127,13 +123,10 @@ namespace GameRes.Formats.Selene
|
|||||||
|
|
||||||
public static string GetPassPhrase (string title)
|
public static string GetPassPhrase (string title)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert (KnownSchemes.Length == Keys.Length,
|
string pass;
|
||||||
"Number of known encryptions schemes does not match available pass phrases.");
|
if (string.IsNullOrEmpty (title) || !KnownSchemes.TryGetValue (title, out pass))
|
||||||
var index = Array.IndexOf (KnownSchemes, title);
|
|
||||||
if (index != -1)
|
|
||||||
return Keys[index];
|
|
||||||
else
|
|
||||||
return "";
|
return "";
|
||||||
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object GetAccessWidget ()
|
public override object GetAccessWidget ()
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
Text="{Binding Source={x:Static p:Settings.Default}, Path=KCAPPassPhrase, Mode=TwoWay}"
|
Text="{Binding Source={x:Static p:Settings.Default}, Path=KCAPPassPhrase, Mode=TwoWay}"
|
||||||
Width="{Binding ElementName=EncScheme, Path=ActualWidth}"/>
|
Width="{Binding ElementName=EncScheme, Path=ActualWidth}"/>
|
||||||
<Label Content="{x:Static s:arcStrings.LabelScheme}" Target="{Binding ElementName=EncScheme}"
|
<Label Content="{x:Static s:arcStrings.LabelScheme}" Target="{Binding ElementName=EncScheme}"
|
||||||
Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right"/>
|
Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right"/>
|
||||||
<ComboBox Name="EncScheme" Grid.Column="1" Grid.Row="2" Margin="0,3,0,0"
|
<ComboBox Name="EncScheme" Grid.Column="1" Grid.Row="1" Margin="0,3,0,0"
|
||||||
ItemsSource="{Binding Source={x:Static fmt:PackOpener.KnownSchemes}, Mode=OneWay}"
|
ItemsSource="{Binding Source={x:Static fmt:PackOpener.KnownSchemes}, Path=Keys, Mode=OneWay}"
|
||||||
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=KCAPScheme, Mode=TwoWay}" />
|
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=KCAPScheme, Mode=TwoWay}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -13,10 +13,9 @@ namespace GameRes.Formats.GUI
|
|||||||
public WidgetKCAP ()
|
public WidgetKCAP ()
|
||||||
{
|
{
|
||||||
InitializeComponent ();
|
InitializeComponent ();
|
||||||
EncScheme.SelectionChanged += OnSchemeChanged;
|
|
||||||
|
|
||||||
if (null == EncScheme.SelectedItem)
|
if (null == EncScheme.SelectedItem)
|
||||||
EncScheme.SelectedIndex = 0;
|
EncScheme.SelectedIndex = 0;
|
||||||
|
EncScheme.SelectionChanged += OnSchemeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSchemeChanged (object sender, SelectionChangedEventArgs e)
|
void OnSchemeChanged (object sender, SelectionChangedEventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user