rearranged archive parameters widgets.

This commit is contained in:
morkt 2014-07-26 23:11:24 +04:00
parent 6bf0e89f21
commit 5019124514
9 changed files with 42 additions and 28 deletions

View File

@ -273,9 +273,16 @@ namespace GameRes.Formats
return table;
}
public override ResourceOptions GetOptions ()
{
return new ResourceOptions {
Widget = new GUI.WidgetNPA()
};
}
NpaTitleId QueryGameEncryption ()
{
var widget = new GUI.WidgetNPA (KnownSchemes[(int)Settings.Default.NPAScheme]);
var widget = new GUI.WidgetNPA();
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.ArcEncryptedNotice,

View File

@ -55,14 +55,9 @@ namespace GameRes.Formats
return new ZLibStream (input, CompressionMode.Decompress);
}
uint m_last_key = Settings.Default.YPFKey;
uint QueryEncryptionKey ()
{
uint? key = m_last_key;
if (m_last_key > 0xff)
key = null;
var widget = new GUI.WidgetYPF (key);
var widget = new GUI.WidgetYPF();
var args = new ParametersRequestEventArgs
{
Notice = arcStrings.YPFNotice,
@ -72,10 +67,9 @@ namespace GameRes.Formats
if (!args.InputResult)
throw new OperationCanceledException();
key = widget.GetKey();
m_last_key = null != key && key.Value < 0x100 ? key.Value : DefaultKey;
Settings.Default.YPFKey = m_last_key;
return m_last_key;
uint last_key = widget.GetKey() ?? DefaultKey;
Settings.Default.YPFKey = last_key;
return last_key;
}
private class Parser
@ -99,9 +93,8 @@ namespace GameRes.Formats
{
uint dir_offset = 0x20;
uint dir_remaining = m_dir_size;
uint num;
var dir = new List<Entry> ((int)m_count);
for (num = 0; num < m_count; ++num)
for (uint num = 0; num < m_count; ++num)
{
if (dir_remaining < 0x17)
break;

View File

@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="clr-namespace:GameRes.Formats.Strings"
xmlns:fmt="clr-namespace:GameRes.Formats"
xmlns:local="clr-namespace:GameRes.Formats.GUI"
MaxWidth="260">
<Grid.Resources>
@ -52,6 +53,7 @@
<Label Content="{x:Static s:arcStrings.INTLabelScheme}" 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:IntOpener.KnownSchemes}, Path=Keys, Mode=OneWay}"
Width="{Binding ElementName=Passkey, Path=ActualWidth}"
SelectedValue="{Binding Path=Scheme}"/>
</Grid>

View File

@ -25,7 +25,6 @@ namespace GameRes.Formats.GUI
{
InitializeComponent();
this.DataContext = encryption_info;
EncScheme.ItemsSource = IntOpener.KnownSchemes.Keys;
Passphrase.TextChanged += OnPassphraseChanged;
EncScheme.SelectionChanged += OnSchemeChanged;

View File

@ -1,6 +1,10 @@
<Grid x:Class="GameRes.Formats.GUI.WidgetNPA"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fmt="clr-namespace:GameRes.Formats"
xmlns:p="clr-namespace:GameRes.Formats.Properties"
MaxWidth="250">
<ComboBox Name="Scheme" Margin="5" Width="180"/>
<ComboBox Name="Scheme" Width="180"
ItemsSource="{Binding Source={x:Static fmt:NpaOpener.KnownSchemes}, Mode=OneWay}"
SelectedIndex="{Binding Source={x:Static p:Settings.Default}, Path=NPAScheme, Mode=TwoWay}"/>
</Grid>

View File

@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using GameRes.Formats.Properties;
namespace GameRes.Formats.GUI
{
@ -8,11 +9,10 @@ namespace GameRes.Formats.GUI
/// </summary>
public partial class WidgetNPA : Grid
{
public WidgetNPA (string scheme)
public WidgetNPA ()
{
InitializeComponent();
Scheme.ItemsSource = NpaOpener.KnownSchemes;
Scheme.SelectedItem = scheme;
Scheme.SelectedItem = NpaOpener.KnownSchemes[(int)Settings.Default.NPAScheme];
}
public string GetScheme()

View File

@ -1,6 +1,9 @@
<Grid x:Class="GameRes.Formats.GUI.WidgetXP3"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fmt="clr-namespace:GameRes.Formats.KiriKiri"
xmlns:p="clr-namespace:GameRes.Formats.Properties"
MaxWidth="250">
<ComboBox Name="Scheme" Margin="5" Width="180"/>
<ComboBox Name="Scheme" ItemsSource="{Binding Source={x:Static fmt:Xp3Opener.KnownSchemes}, Path=Keys, Mode=OneWay}"
SelectedValue="{Binding Source={x:Static p:Settings.Default}, Path=XP3Scheme, Mode=TwoWay}" Width="180"/>
</Grid>

View File

@ -1,6 +1,9 @@
using System.Windows;
using System.Windows.Controls;
using GameRes.Formats.KiriKiri;
using GameRes.Formats.Properties;
using GameRes.Formats.Strings;
namespace GameRes.Formats.GUI
{
@ -9,16 +12,16 @@ namespace GameRes.Formats.GUI
/// </summary>
public partial class WidgetXP3 : Grid
{
public WidgetXP3 (string scheme)
public WidgetXP3 ()
{
InitializeComponent();
Scheme.ItemsSource = Xp3Opener.KnownSchemes.Keys;
Scheme.SelectedItem = scheme;
if (null == Scheme.SelectedItem)
Scheme.SelectedItem = arcStrings.ArcNoEncryption;
}
public string GetScheme ()
public ICrypt GetScheme ()
{
return Scheme.SelectedItem as string;
return Xp3Opener.GetScheme (Scheme.SelectedItem as string);
}
}
}

View File

@ -1,5 +1,6 @@
using System.Windows;
using System.Windows.Controls;
using GameRes.Formats.Properties;
namespace GameRes.Formats.GUI
{
@ -8,11 +9,13 @@ namespace GameRes.Formats.GUI
/// </summary>
public partial class WidgetYPF : Grid
{
public WidgetYPF (uint? key)
public WidgetYPF ()
{
InitializeComponent();
if (null != key)
this.Passkey.Text = key.Value.ToString();
uint key = Settings.Default.YPFKey;
if (key < 0x100)
this.Passkey.Text = key.ToString();
else
this.Passkey.Text = null;
}
@ -20,7 +23,7 @@ namespace GameRes.Formats.GUI
public uint? GetKey ()
{
uint key;
if (uint.TryParse (this.Passkey.Text, out key))
if (uint.TryParse (this.Passkey.Text, out key) && key < 0x100)
return key;
else
return null;